Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Jason Norwood-Young

haliphax wrote:

Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.
  


I disagree somewhat. A good framework should actually reduce bloat. It 
encourages you to implement proper MVC architecture, helps you avoid 
those rambling "function.php" files, and if it's well built, things like 
DB connectivity should already be optimised. I like CI because it does 
all of that fairly well, and tends to perform faster than something some 
coder (like myself) hacked together in the smallest time-frame possible. 
I use it on some pretty big sites - one with DB's with 10's of millions 
of records, and one site with over 1.5 million users a month. Personal 
thumbs up for CI, but use whatever suits your skill level, timeframe and 
requirements. Some frameworks will increase bloat, but sometimes that's 
worth it to get the project out the door in a given timeframe. If you're 
doing a blog on caring for chickens, throw it up in an hour with 
WordPress. If you're planning on being the next NY Times, WordPress will 
not be a kind mistress.


There are down sides to CI too, but it suits my needs for the types of 
sites I produce.


J

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Jason Norwood-Young

haliphax wrote:

On Mon, Mar 9, 2009 at 1:26 PM, Jason Norwood-Young
 wrote:
  

haliphax wrote:


Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.

  

I disagree somewhat. A good framework should actually reduce bloat. It
encourages you to implement proper MVC architecture, helps you avoid those
rambling "function.php" files, and if it's well built, things like DB
connectivity should already be optimised. I like CI because it does all of
that fairly well, and tends to perform faster than something some coder
(like myself) hacked together in the smallest time-frame possible. I use it
on some pretty big sites - one with DB's with 10's of millions of records,
and one site with over 1.5 million users a month. Personal thumbs up for CI,
but use whatever suits your skill level, timeframe and requirements. Some
frameworks will increase bloat, but sometimes that's worth it to get the
project out the door in a given timeframe. If you're doing a blog on caring
for chickens, throw it up in an hour with WordPress. If you're planning on
being the next NY Times, WordPress will not be a kind mistress.

There are down sides to CI too, but it suits my needs for the types of sites
I produce.



Framework = Overhead (when compared to vanilla PHP). Period. I'm not
saying it's overhead that will cripple your application, or that
frameworks should be avoided... quite the contrary, in fact. I have
recently fallen in love with CodeIgniter myself--I'm just saying that
one should be at least respectfully aware of the overhead that comes
hand-in-hand with a(ny) framework, and weigh those against what you
feel is acceptable for your purpose.
  
And I'm saying that using vanilla PHP sometimes (I'd say more often than 
not - especially with a group of developers of varying skill and 
experience) leads to sloppy programming, bad architecture and monolithic 
libraries, which in turn can lead to more overhead than simply starting 
with a framework. Not that a framework will save you from bad code - but 
it should point you in the right direction and make it obvious how you 
*should* do things.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Evaluating math without eval()

2008-04-10 Thread Jason Norwood-Young
Hi all

First post to this list! I'm trying to figure out how to evaluate a
string with a mathematical expression and get a result, but without
using eval() as I'm accepting user input into the string. I don't just
want addition, subtraction, multiplication and division - I'd like to
take advantage of other functions like ceil, floor etc. 

So the string "18-10" should give me 8, "ceil(1/2)*10" should be 10 (if
my maths is correct) and the string "18-10;\r\nunlink('/var/www/*');"
should not execute.

Any ideas?

Thanks!
Jason


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Evaluating math without eval()

2008-04-10 Thread Jason Norwood-Young

On Thu, 2008-04-10 at 13:15 +0100, Richard Heyes wrote:
> > First post to this list! I'm trying to figure out how to evaluate a
> > string with a mathematical expression and get a result, but without
> > using eval() as I'm accepting user input into the string. I don't just
> > want addition, subtraction, multiplication and division - I'd like to
> > take advantage of other functions like ceil, floor etc. 
> > 
> > So the string "18-10" should give me 8, "ceil(1/2)*10" should be 10 (if
> > my maths is correct) and the string "18-10;\r\nunlink('/var/www/*');"
> > should not execute.
> 
> If you can provide your users with distinct inputs (if it's a form) go 
> that route.

Thanks Richard

Unfortunately it's not that simple. The equation sits in a DB and can be
anything - eg. ((([valuation]/[purchaseprice])/100)*100)/[numyears]
would be a typical field. [valuation], [purchaseprice] and [numyears]
gets replaced by relevant fields from user-entered data. But the system
is expandable which means I don't know what the equations, data or
fields are going to be beforehand. 

I'm working on some kinda preg_replace function to sanitize the data at
the moment and then run an eval - arg I hate regexp! Ideally eval would
have some kind of sandboxing option, or you could limit the functions
available in an eval.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Evaluating math without eval()

2008-04-10 Thread Jason Norwood-Young
On Thu, 2008-04-10 at 13:15 +0100, Richard Heyes wrote:
> > First post to this list! I'm trying to figure out how to evaluate a
> > string with a mathematical expression and get a result, but without
> > using eval() as I'm accepting user input into the string. I don't just
> > want addition, subtraction, multiplication and division - I'd like to
> > take advantage of other functions like ceil, floor etc. 

In reply to my own question, I came up with the following function based
on a comment on php.net
(http://www.php.net/manual/en/function.eval.php#71045). I had a look at
the array returned by get_defined_functions() and the maths functions
seem mostly to be grouped (with the exception of the random number
stuff). It works on my installation but there's nothing in the
documentation about get_defined_functions() returning in a particular
order - it would be safer to list each math function but I'm lazy.

protected function safe_eval($s) {
$funcs=get_defined_functions();
$funcs=$funcs["internal"];
$funcs=array_slice($funcs,array_search("abs",
$funcs),array_search("rad2deg",$funcs)-array_search("abs",$funcs));
$sfuncs="(".implode(")(",$funcs).")";
$s=preg_replace('`([^+\-*=/\(\)\d\^<>&|\.'.$sfuncs.']*)`','',$s);
if (empty($s)) {
return 0;
} else {
try {
eval("\$s=$s;");
return $s;
} catch(Exception $e) {
return 0;
}
}
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Help with SSH2 persistent connection in php

2008-04-11 Thread Jason Norwood-Young
On Fri, 2008-04-11 at 10:14 -0300, Rodrigo Reis da Rocha wrote:
> I want to make an persistent connection via ssh2 to a server with php, but
> all I can get with the present API is an temporary connection that is lost
> at end of the script.
> Anyone have an idea of how I can save the Resource and reuse it on future
> scripts instead of having to reconnect over and over again?

Hi Rodrigo

I recently did a little app that maintained persistent connections to a
XMPP server - a similar solution should apply to your problem.

I built a memory-resident app in the middle that received a unique ID
from my PHP page (you could use session_id for instance), assigned that
ID to a connection and created a permanent connection. It also queued
incoming messages so that when the PHP script connected again, it could
send through the queued messages, so that the end-user didn't miss
anything.

Initially I tried using PHP-cli for the memory-resident app but
eventually settled on Twistd Python because it was better at running
resident and handling multiple connections from different users without
blocking anything. On the front-end I used PHP and Ajax to give a
feeling of a "live" connection.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Evaluating math without eval()

2008-04-13 Thread Jason Norwood-Young

On Sat, 2008-04-12 at 09:05 -0500, Ray Hauge wrote:
> 
> you might be able to leverage a call to expr on a bash sell.  Just 
> replace the variables you're expecting with preg_replace or some
similar 
> function.
> 
> http://hacktux.com/bashmath
>
http://sysblogd.wordpress.com/2007/08/26/let-bash-do-the-math-doing-calculations-using-that-bash/
> 
> I'm not sure if that's any more secure than eval though.

Good idea Ray. I'm thinking that it might be safer to exec a separate
app - preferably sandboxed. That way it could still be PHP (or anything
else really) but without the headache of compromising the main
application.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Alter Table newbie help needed ...

2008-04-19 Thread Jason Norwood-Young

On Sat, 2008-04-19 at 14:23 -0700, revDAVE wrote:
> Newbie - MAC - MAMP on port 8889
> 
> I have this connection to Mysql database called 'test'
> 
> 
> Other Php stuff works ok but now I'm trying to alter the table (never did
> that before...)
> 
> 
> 
> Connection called 'try1'...
> 
>  # FileName="Connection_php_mysql.htm"
> # Type="MYSQL"
> # HTTP="true"
> $hostname_try1 = "127.0.0.1:8889";
> $database_try1 = "test";
> $username_try1 = "test";
> $password_try1 = "test";
> $try1 = mysql_pconnect($hostname_try1, $username_try1, $password_try1) or
> trigger_error(mysql_error(),E_USER_ERROR);
> ?>
> 
> The lines below don't error  but also don't do anything
> 
> I must be missing something here Right? Maybe it doesn't know to use
> try1 connection? How do I add that?
> 
>  $sql = 'ALTER TABLE `ztest` ADD `myfield2` VARCHAR(10) NOT NULL;';
> ---or---
> $sql = 'ALTER TABLE `ztest` RENAME TO `ztest2`;';
> 
>  ?>

Might be obvious but you are doing "mysql_query($sql);", right?

Also add a try catch around your mysql_query to check what's happening.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Check RAW data

2008-04-20 Thread Jason Norwood-Young
On Sun, 2008-04-20 at 15:52 +0200, rb wrote:
> I'm getting from an external source a PNG image in raw format (encoded in 
> base64).
> 
> And with this code I'll echo on the screen.
> 
> --
> $img=base64_decode($_POST['img']);
> 
> header("Content-type: image/png");
> echo $img;
> --

A quick way would be to try and make an image with the GD library.
Something like:
if (imagecreatefromstring($img)) {
header("Content-type:image/png");
echo $img;
}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Cron php & refresh

2008-04-20 Thread Jason Norwood-Young

On Sun, 2008-04-20 at 13:32 -0500, Larry Garfield wrote:
> On Sunday 20 April 2008, Jeffrey wrote:
> > I'm working on an application that includes e-mail notifications of
> > certain events. Because the application will have hundreds or thousands
> > of users, I've designed it so that e-mail notifications are saved to a
> > MySQL table. Then a regular cron job runs a php page to select the data
> > from the table, put it into a mail() command and mail.
> >
> > My original vision was to have the script do about 50 mails, then pause
> > for a 5 seconds, do a meta refresh and run through another 50 and so on
> > - with experimentation in numbers as necessary. This process was set up
> > because I recall reading somewhere - perhaps the manual - that it is not
> > a good thing to run too many php mail()s in succession. Also, I worry
> > about php time-outs.
> >
> > If you know more about PHP and 'nix than I do, you already realise the
> > fatal flaw here: meta refresh doesn't work on a cron job.
> >
> > Question: is there an alternative? I appreciate I could use sleep()
> > after every 50 mails - but there would still be the time-out problem.
> >
> > I've searched the manual and via Google - but haven't found anything -
> > possibly I am searching on the wrong terms.
> >
> > Your help will be much appreciated.
> 
> Why not just have the cron task itself run every 5 minutes?  Every 5  
> minutes, 
> hit a PHP script that will pull the next 50 messages to send and send them, 
> then exit.  In 5 minutes minus the time that takes, cron will fire your 
> script again.  Problem solved.  

If you take this approach, just make sure you build a proper queuing
system or mark the mails you're processing as being processed in the DB.
Otherwise you could end up with a situation where the system takes
longer than 5 minutes to process the mails (it shouldn't, but you never
know - maybe there's a rogue process or the mail queue is backed up or
something) and then the PHP script starts at the beginning of those 50
mails again. It's an obvious error, but I've done it in an app where I
thought "There's no way the process won't finish before the next cron
job starts", and then it happened and I ended up sending a couple
thousand SMS's out twice at cost to my client. Oops.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Fwd: Re: [PHP] Alter Table newbie help needed ...]

2008-04-21 Thread Jason Norwood-Young
Darn forgot to hit "reply to all"

 Forwarded Message ----
From: Jason Norwood-Young <[EMAIL PROTECTED]>
To: revDAVE <[EMAIL PROTECTED]>
Subject: Re: [PHP] Alter Table newbie help needed ...
Date: Mon, 21 Apr 2008 23:52:30 +0200

On Mon, 2008-04-21 at 14:04 -0700, revDAVE wrote:
> Jason & David,
> 
> Thanks so much for your help
> 
> BTW: to reiterate the problem: I guess it was not knowing to use the 'try1'
> connection ( try1.ztest) - and used 'connect2' connection instead...
> 
> Error said : Table 'connect2.ztest' doesn't exist
> (connect2 was some other one I set up for something else)
> 
> Q: Is there a way to insure that it uses the right connection ( try1 - not
> connect2 )?

Hi revDAVE

You'll simplify your life dramatically by using one database and one
connection per application. If you're not going to do that, you can make
sure the table is there in PHP with something like:

function check_table_exists($tablename) {
$sqlresult=mysql_query("SHOW TABLES LIKE $tablename");
if (mysql_num_rows($sqlresult)==1) {
return true;
}
return false;
}

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: php framework vs just php?

2008-04-22 Thread Jason Norwood-Young
On Tue, 2008-04-22 at 21:06 +0800, Kinch Zhang wrote:
> On 4/22/08, Tony Marston <[EMAIL PROTECTED]> wrote:
> >
> > If you don't use a framework then obviously you are writing nothing but
> > mickey mouse programs, and wouldn't stand a chance when it comes to
> > writing
> > a proper application.
> 
> 
> 
> I agree , you couldn't avoid using a framework unless you're writing a PHP
> toy application.

And I disagree. I'm just putting the finishing touches on a large
multi-user asset management system, built without a framework (apart
from my own collection of objects I wrote and reuse to accelerate
development). 40 000 lines of code and my previous version is currently
being used by banks and such. We'll move them over to the new one soon.
It's taken about 3 months full-time work.

But, while I think there's nothing wrong with building from scratch as
long as you architect carefully before you start, I think that there's
also nothing wrong with frameworks. As long as you choose the one that
is best going to suit your needs from the start, it can make life
significantly easier. If you're building a web site for a client, you'd
be insane to not seriously consider a CMS like Drupal or even WordPress
(don't laugh - it's got quite a competent plug-in system and if you're
in a rush you can bang something good out the door in a day.) I'm
currently building a project based on CodeIgniter, and apart from quite
a rigid structure, you do most of the stuff yourself anyhow. I dumped
the built-in DB object for one of my own and now development is
cruising. 

So, my philosophy is one of choosing the tool that best suits your
needs, your client's needs and your project's needs, rather than using
or not using frameworks based on some preconception.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] foreach loop to set variables

2008-04-25 Thread Jason Norwood-Young

On Fri, 2008-04-25 at 06:12 -0700, jamest wrote:
> I am passing an array to a class which I want to take the array data and
> create some variables from the array's keys and values.
> 
> So I want to create (in this case 21) new variables that I want to create in
> the foreach but with no success.
> 
> foreach ($formdata as $key => $value) {
>   echo "$key = $value";
> }
> 
> This echo's all the data how I would expect.  But taking the echo out to
> have:
> 
> foreach ($formdata as $key => $value) {
>   $key = $value;
> }
> 
> But this doesn't work. The variables aren't set.
> 
> I was thinking that I could set up the variables outside of the function by
> using public $variablename for all the different variables then set the
> variable value using:
> 
> foreach ($formdata as $key => $value) {
>   $this->key = $value;
> }

How about $this->formdata?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] peer review (was php framework vs just php?)

2008-04-26 Thread Jason Norwood-Young

On Fri, 2008-04-25 at 17:32 -0500, Jay Blanchard wrote:
> [snip]
> I can't say I've ever had a form that exactly matched a database table
> for a user perspective. From an admin perspective that changes, but that
> was when I downloaded PHPMyAdmin for the client. It was amazing, every
> form matched the database table and you could view all the rows too, and
> even create your own queries.
> 
> Table discovery is something I use for marshalling data back and forth
> from database tables, but not usually for presenting a user form.
> [/snip]
> 
> That is why there is code to exclude columns from the form and
> essentially the group of functions pretty much does what phpmyadmin
> does. Handling multiple tables in one form of course is a different
> story.
> 

Actually it's quite easy. I've got a similar object to the one you guys
described (can't really share it - I'm on salary so technically it
belongs to my boss.) Anyhow when I do my table layout, if there's a
look-up, I name the field "lookuptable_id" in the DB. In my object, it
looks for any field ending in "_id" (or whatever you specify to the
object - "_id" is just the default) and it creates a drop-down of the
options. 

The object also takes an array of ignore_fields, hidden_fields (good for
ID's on updates), friendlynames (you don't always want to use the
fieldname in the database, but anyhow the object replaces underscores
and capitalises), and a bunch of other customising array properties with
useful defaults. It also detects whether this is an insert or update and
knows how to route the action, and has support for file uploads (and
customises the enctype of the form for that).

So basically you can have a very nice form, customised, with one or two
lines of code to draw the form, as long as you design your object and DB
well. 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Kindla 0T, but here goes...

2008-06-16 Thread Jason Norwood-Young

On Fri, 2008-06-13 at 16:32 -0500, Boyd, Todd M. wrote:
> > -Original Message-
> > From: Daniel Brown [mailto:[EMAIL PROTECTED]
> > Sent: Friday, June 13, 2008 4:13 PM
> > To: Ryan S
> > Cc: php php
> > Subject: Re: [PHP] Kindla 0T, but here goes...
> > 
> > On Fri, Jun 13, 2008 at 4:49 PM, Ryan S <[EMAIL PROTECTED]> wrote:
> > >
> > > when the user clicks on any of those links i do a quick trip to the
> > DB via ajax and update the div with all the artists that his choice
> > merits... same thing when he clicks the bands name... this time i
> > display all of their songs... and here's where i am stumped... when he
> > clicks any of those songs... it should start playing in the background
> > WITHOUT reloading the whole page... is this possible or am i just
> > barking up the wrong tree?
> > 
> > Most sites, such as Project Playlist (now just Playlist.com) use
> > Flash for this.
> > 
> > Check it out:
> > 
> > http://www.playlist.com/
> 
> I agree with Daniel. Your most likely solution is to use a Flash player
> (or similar implementation) and populate a portion of your page with the
> object via AJAX (which you are already apparently comfortable with).

Or make your own Flash player with Ming and PHP. Working on that myself
at the moment.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] de lester

2008-06-27 Thread Jason Norwood-Young

On Fri, 2008-06-27 at 03:05 -0400, [EMAIL PROTECTED] wrote:
> 
> SORRY, IN THE LAST EMAIL I DONT SAY WHAT TYPE OF VIDEO I WAS WORKING, 
>  I AM WORKING WITH VIDEO  .MOV
> THANKS.
> 
> I am working with videos and I need to Know how I can obtain the
> duration of the videos
> I had a formula that did not need any function of php, but i lost de
> page, please i need any help with this.
> 
> Sorry for my english, i am from Cuba.

Here's how I do it. I make a file with the output of ffmpeg and then
just parse the file for duration. After looking at a lot of options,
this proved to be the easiest and most reliable. Here's my code that
also finds the mid-time and grabs an image of the middle frame for a
thumbnail:

//tmpname is the temp name of the video
//First we get some info about the video with ffmpeg
$cmd="/usr/local/bin/ffmpeg -i $tmpname 2> $tmpname.info";
system($cmd,$ok);
if (!$ok) {
  return false;
}
$ffinfo=file_get_contents($tmpname.".info");
$ffinfo=substr($ffinfo,strpos($ffinfo,"Duration:")+10,strlen($ffinfo));
//Now that we got the duration we parse the string so that we get hours,
mins and seconds
$ffinfo=substr($ffinfo,0,strpos($ffinfo,"."));
$runningtimeparts=explode(":",$ffinfo);
foreach($runningtimeparts as $rt) {
   $newparts[]=floor((($rt/60)*0.5)*60);
}
//Get the mid point
$midtime=($newparts[0]*3600)+($newparts[1]*60)+$newparts[2];
$midtimestr=implode(":",$newparts);
//$jpegname is the name of where you want to save the thumbnail
$cmd="/usr/local/bin/ffmpeg -i $tmpname -ss $midtimestr -y -r 1 -vframes
1 -f mjpeg $jpegname";
system($cmd);


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] unset in foreach breaks recrusion

2008-06-30 Thread Jason Norwood-Young
On Sun, 2008-06-29 at 18:25 -0800, David Sky wrote:
> Hello everyone!
> 
> A couple of days ago I submitted a bug to PHP
> http://bugs.php.net/bug.php?id=45385
> But I was mistaken, apparently it's not a bug.
> And I was "sent" here to get help.

I think you might be forgetting to return $return.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Splitting up long URLs

2008-07-01 Thread Jason Norwood-Young

On Tue, 2008-07-01 at 13:26 -0700, Brian Dunning wrote:
> I have a web page that lists "most recent comments" in a left margin.  
> Sometimes people post long URLs, or even just really really long  
> words, that force that margin to display way too wide, screwing up the  
> page layout. Is there a way to make sure URLs or other text in a  
> string gets split up so this doesn't happen?
> 
> If there's a CSS solution that's better than a PHP solution I'll take  
> that too.   :-)
> 

For URLs you can do a tinyurl-type solution. Quite easy in fact. Just
save the long url in a db table, along with a short url (say a
4-character random string). Then do a page that looks up the short url
and redirects to a long url (eg. http://www.myblog.com/r?id=Sve7
redirects to http://www.veryverylongurl.com/blahblahblah.php). For extra
points you can make the short url look like http://tiny.myblog.com/Sve7.
Just remember to put the short url creation in a loop that checks that
the short url isn't in the DB already and repeat if it is.

For long words, you could explode the words into an array, and if the
words are longer than a certain length, insert a hyphen and space for
your wrap. Then just implode back into your string and bob's your uncle.

Anyhow that's how I'd do it.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Splitting up long URLs

2008-07-01 Thread Jason Norwood-Young
On Wed, 2008-07-02 at 08:23 +0200, Jason Norwood-Young wrote:
> For URLs you can do a tinyurl-type solution. 

Dur, just realised it's only *display* that you're worried about so
shortening the url isn't really an issue. It's too early in the
morning...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problem with special characters - PHP & AJAX

2008-07-07 Thread Jason Norwood-Young

On Mon, 2008-07-07 at 19:35 +0930, Michael Kubler wrote:
> Are the messages being sent as UTF-8 or something else? Is the server 
> sending the headers as something different to that listed in the header?
> Actually, looking at it, you don't have a valid DOC-TYPE 
> ,
>  
> nor character Encoding set.

Yeah you might want to check out HTML Entities
(http://www.php.net/manual/en/function.htmlentities.php) - great help in
encoding. Then set a doc type too.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Pear DB

2008-07-10 Thread Jason Norwood-Young

On Thu, 2008-07-10 at 16:47 +1000, John Comerford wrote:
> Hi Folks,
> 
> I have just successfully lobbied for the company I work for to use 
> PHP/MySQL for our next website.  My Question is regarding DB abstraction 
> .  I know there is a Pear DB module, is this the best to use ?  I have a 
> vague memory of reading somewhere that there is a newer lib or something 
> which is considered better ?
> 

Hi John

You might consider CodeIgniter - it's a very nice, simple to use
framework with a pretty good DB abstraction layer built in.
http://codeigniter.com/

J



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Soap Call Error

2008-07-16 Thread Jason Norwood-Young

On Wed, 2008-07-16 at 17:44 -0700, VamVan wrote:
> Hello Guys,
> 
> I have been getting a wierd soap exception lately
> 
> 
> [faultstring] => looks like we got no XML document
> [faultcode] => Client
> [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
> 
> What does that mean? The call gets properly called and it does what it needs
> to do, but the response xml is always a $fault? Did anyone have this
> problem? I am using php 5.2.6 for the info.

This is usually a malformed XML document - I had the problem recently
when fetching an XML document that wasn't complete (no ). Check
what you're *actually* getting with something like:

} catch(SoapFault $exception) {
$request_xml = $client->__getLastRequestHeaders() .
$client->__getLastRequest();
$response_xml = $client->__getLastResponseHeaders() .
$client->__getLastResponse();
print "Response:".$response_xml;
print "Request:".$request_xml;
print $exception;
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??

2008-07-18 Thread Jason Norwood-Young

On Thu, 2008-07-17 at 10:41 -0400, Daniel Brown wrote:
> 9.) NEVER store passwords in a PHP script.  Instead, store them in
> a file named `inc/config.inc` in the web directory, and include them.

Dude! You forgot the most important bit:
inc/config.inc:
$dbusername="root";
$dbpassword="r00t"; //By combining letters and numbers, this password
becomes unhackable

It's important to also set your server root password the same as your DB
password so that when you hand passwords out to your outsourced
developers, secretaries, tea ladies and janitors they can have full
access to the system and don't waste your time setting up permissions.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Multi-array - What am I missing?

2008-07-23 Thread Jason Norwood-Young

On Wed, 2008-07-23 at 13:52 -0500, Chris Ditty wrote:
> Can anyone point me in the right direction?  I know I am missing something
> simple, but I can't place my hands on it.
> 
> $myCalTime = act_getCalendarDays($config, $myMonth, $myYear);
> 
> foreach($myCalTime as $calTime => $calArrayTime){
> $calArray[] = $calArrayTime['day']."=>array('NULL','linked-day
> ".strtolower($calArrayTime['reason'])."','".$calArrayTime['day']."'),";
> }
> 
> act_getCalendarDays returns this
> Array
> (
> [day] => Array
> (
> [0] => 05
> [1] => 06
> [2] => 26
> [3] => 27
> )
> 
> [reason] => Array
> (
> [0] => Vacation
> [1] => Vacation
> [2] => Vacation
> [3] => Vacation
> )
> 
> )
> 
> 
> What am I missing to get this
> =>array('NULL=','linked-day ',''),
> 
> to look like this
> 05=>array(NULL,'linked-day vacation','05'),

Your myCalTime isn't an array of arrays of arrays, like you're
suggesting in the foreach.

$calArray=array();
for($x=0;$xarray('NULL','linked-day
".strtolower($myCalTime['reason'][$x])."','".$myCalTime['day'][$x]."'),";
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Web2.0 style tags - where to start?

2008-07-28 Thread Jason Norwood-Young

On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:
> I think my first post was ambiguous. What we're thinking of is to build a
> site on which people can view videos with the option to add metadata to a
> video after viewing it.
> 
> We think that the content we have will be of wide interest to a lot of
> people and the best way to index it is for users to 'tag' it themselves,
> since it's hard for us to anticipate the uses that people may have for the
> content.

How do you plan to have users enter the info? Through the Flash player,
through some kinda Ajax form, through a form in a frame or just a static
form? 

Also, would the tags be predefined by you (eg. genres like the ID3 tag
genres) or would people be able to add their own tags?

The way I'd do it would be to let the users enter the info through an
Ajax form below the video, with suggestions popping up as they type.
Then save it in a separate table (I assume all your vids are in their
own table) with a link table between the vids table and the tags table
(M2M relationship). This means that if the tag is already in there and
linked to one vid, you don't replicate it for a second vid. It's also
very easy to do lookups of similar items. I'd also add a weighting to
the tags in the links table, maybe with the more people that add a
specific tag, the more weight that tag gets. 

Also check out http://www.music-map.com/ as an example of showing
similar music - you might even be able to plug into this data.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Web2.0 style tags - where to start?

2008-07-29 Thread Jason Norwood-Young

On Mon, 2008-07-28 at 23:57 +0100, Paul Jinks wrote:
> Jason Norwood-Young wrote:
> > On Mon, 2008-07-28 at 14:48 +0100, Paul Jinks wrote:
> >   
> >> I think my first post was ambiguous. What we're thinking of is to build a
> >> site on which people can view videos with the option to add metadata to a
> >> video after viewing it.
> >>
> >> We think that the content we have will be of wide interest to a lot of
> >> people and the best way to index it is for users to 'tag' it themselves,
> >> since it's hard for us to anticipate the uses that people may have for the
> >> content.
> >> 
> >
> > How do you plan to have users enter the info? Through the Flash player,
> > through some kinda Ajax form, through a form in a frame or just a static
> > form? 
> >
> > Also, would the tags be predefined by you (eg. genres like the ID3 tag
> > genres) or would people be able to add their own tags?
> >
> > The way I'd do it would be to let the users enter the info through an
> > Ajax form below the video, with suggestions popping up as they type.
> > Then save it in a separate table (I assume all your vids are in their
> > own table) with a link table between the vids table and the tags table
> > (M2M relationship). This means that if the tag is already in there and
> > linked to one vid, you don't replicate it for a second vid. It's also
> > very easy to do lookups of similar items. I'd also add a weighting to
> > the tags in the links table, maybe with the more people that add a
> > specific tag, the more weight that tag gets. 
> >
> > Also check out http://www.music-map.com/ as an example of showing
> > similar music - you might even be able to plug into this data.
> >
> >   
> Hi Jason
> 
> Hmm, food for thought. music-map is brilliant, though not what I'm 
> looking for graphically at the moment (was surprised to find Cesaria 
> Evora in close proximity to The Cardigans but I digress).
> 
> What you describe is pretty much what I'm chasing, thanks and helps me 
> down the road, particularly with thinking about the database set up. 
> They 'only' problem is, my php/mysql skills are some way behind my 
> javascript/actionscript  knowhow (I'm pretty much a noob here);  what I 
> could use now is a how-to tutorial to give me some code to work off, 
> either online or in a book. If it ain't there, I can build from scratch 
> but it's going to mean a lot of calls for help! =)
> 
> Many thanks
> 
> Paul

In that case, I suggest the following solution:
1. Download the unternet into your puter
2. Open the file called mysql.com
3. Read and learn
4. Open the file called php.net
5. Read and learn
6. Rinse and repeat

In all seriousness, this is a nice, simple project to learn on. You want
to look at different types of relationships in Sql (one-to-one,
one-to-many and many-to-many) and learn a bit about basic DB
architecture; make some tables and play with getting data in and out
(get PHPMyAdmin to help you out); maybe use a nice simple framework like
CodeIgniter to get you kick-started on the PHP.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Web2.0 style tags - where to start?

2008-07-30 Thread Jason Norwood-Young

On Thu, 2008-07-31 at 06:28 +0200, Nitsan Bin-Nun wrote:
> From my experience with Codeigniter, thats one of the best php frameworks I
> have ever seen.
> It functionality is awesome, you can integrate your own modifications to the
> IC core without any problems at all, for more confortable you even don't
> have to use a template system (but I'm pretty sure that you can integrate
> Smarty to IC) and write your template with a pseudo code, CI supports  ?> code inside your template!

What I love about CodeIgniter is that, while some frameworks obfuscate
my thinking, CodeIgniter clarifies my thoughts, structure and overall
architecture. MVC programming is no longer some mysterious theoretical
entity - it just makes sense with CodeIgniter. Plus it doesn't tell you
how to do something - it just gives you the structure for you to decide
and do whatever you want. And it's so light I'd barely call it a
framework - more like a kick-start. I could wax lyrical about this all
day. Maybe I should write an ode...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating new site

2008-07-31 Thread Jason Norwood-Young

On Thu, 2008-07-31 at 09:57 +, Raido wrote:
> I have investigated some frameworks.. Zend and Codeiginiter but I 
> haven't done any testing/exercises. They seem to make things much more 
> simple/faster yes...but I'm not sure how much time it will take to get 
> know one of them(or CakePHP). And I haven't got into reading 
> licences...I'm sure they have got licences that restricts something(or 
> not ?) To be honest, I kinda hate all kind of licences. There are many 
> pages info what I can and what I can't do...but I mostly like to do what 
> I have and want to do. Also, inventing the wheel once, might give good 
> experience or am I going slippery way ?

I didn't find CodeIgniter difficult to learn - a few hours of reading
and a few hours of playing. I was comfortable within one evening.

The license for CodeIgniter is pretty simple. Since it's unlikely you'll
ever need to mess with the framework itself - you can override any
object - I don't see it's modification clause really coming into play.

The meat of CodeIgniter's license (from
http://codeigniter.com/user_guide/license.html):
Permitted Use
You are permitted to use, copy, modify, and distribute the Software and
its documentation, with or without modification, for any purpose,
provided that the following conditions are met:

 1. A copy of this license agreement must be included with the
distribution.
 2. Redistributions of source code must retain the above copyright
notice in all source code files.
 3. Redistributions in binary form must reproduce the above
copyright notice in the documentation and/or other materials
provided with the distribution.
 4. Any files that have been modified must carry notices stating the
nature of the change and the names of those who changed them.
 5. Products derived from the Software must include an
acknowledgment that they are derived from CodeIgniter in their
documentation and/or other materials provided with the
distribution.
 6. Products derived from the Software may not be called
"CodeIgniter", nor may "CodeIgniter" appear in their name,
without prior written permission from EllisLab, Inc.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php