Re: [PHP] The Data Literacy Test
On Wed, 2008-09-24 at 21:45 -0400, Eric Butera wrote: On Wed, Sep 24, 2008 at 9:22 PM, Shelley [EMAIL PROTECTED] wrote: 2008/9/25 Philip Thompson [EMAIL PROTECTED] On Sep 24, 2008, at 7:29 AM, Maciek Sokolewicz wrote: tedd wrote: At 12:25 PM +0100 9/24/08, Ashley Sheridan wrote: On Wed, 2008-09-24 at 09:20 +0800, Shelley wrote: http://phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test The Data Literacy Test: http://www.phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test What the smeg is this? I don't know, but I figure 27. Cheers, tedd yes, I think 27 aswell... - Tul No no no. We all know the answer is 42. ? How come 42? -- With best regards, Shelley Shyan http://phparch.cn The question can't exist in the same universe as the answer. :( But 42 is THE answer ;) Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Questions regarding limits of processes launched by system, exec, passthru ...
Hello all, Is there a way to limit the memory consumption and / or the CPU consumption of processes launched by the php functions system, exec, passthru, proc_open and shell_exec? We use mod_php with an apache (mpm-prefork) on Linux. The following settings don't have any effect at all: PHP: max_execution_time 30 memory_limit 8M Apache: RLimitCPU 30 30 RLimitMEM 8388608 8388608 The limits above do have effect on php-scripts (without system calls) and on CGIs (as well on processes launched by CGIs). Any Ideas? Kind Regards valli PS: I tested it with the following two scripts: system_memorytest.php = html head titlephp-systemcall-memory test/title /head body php-systemcall-memory testbr ... and here's the system call:br pre ?php $cmd = '/usr/bin/perl -e \' $| = 1; print start of the systemcallbr\n; $s = teststr_; while (1) { print len=.length($s).br\n; sleep(1); $s .= $s; } \''; print htmlspecialchars($cmd); ? /pre ?php ob_flush(); flush(); system($cmd); ? /body /html system_timeouttest.php == html head titlephp-systemcall-timeout test/title /head body php-systemcall-timeout testbr ... and here's the system call:br pre ?php $cmd = '/usr/bin/perl -e \' $| = 1; print start of the systemcallbr\n; $i = 0; while (1) { if (($i % 1000) == 0) { print i=.$i.br\n; } $i += 1; } \''; print htmlspecialchars($cmd); ? /pre ?php ob_flush(); flush(); system($cmd); ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Wierd Variable Initialization
On 25 September 2008 03:45, VamVan advised: So guys, I found some thing strange that happened to me yesterday. Its small but kinda freaked me out. So I have a tokenmap.php that I include include in different configuration files. Some are classes and some are simple php files. So in my tokenmap.php I have declared an array as global. SO $GLOBAL['tokenmap'] = array() As a good programming practice what I did was: require_once('tokenmap.php'); $tokenmap = array(); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); The above displays empty array But when I do this , it works require_once('tokenmap.php'); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); Its kind of wierd for me. I am trying to understand. Can some one shed some light on it for me. Well, $GLOBALS['tokenmap'] is *exactly* *the* *same* *thing* as $tokenmap when you're in the global scope (which I assume you are for what you describe here to make sense). So the assignment: $tokenmap = array(); is the same as: $GLOBALS['tokenmap'] = array(); And the assignment: $tokenmap = $GLOBALS['tokenmap']; is essentially useless as it's the same as: $tokenmap = $tokenmap; ... or: $GLOBALS['tokenmap'] = $tokenmap; ... or even: $GLOBALS['tokenmap'] = $GLOBALS['tokenmap']; Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] curl_exec hangs/freezes on shared hosting
I use the following script to make forward an ajax call from the browser to a server other than my main webserver. On my homeserver (debian/apache2/php5 with rootxs) it runs fine, but on my shared hosting (servage.net, phpinfo at http://mediabeez.veerman.ws/mb/sn.php) it freezes / hangs on curl_exec(). I've already asked my hoster's supportstaff about this, but they are a bit clueless and are very slow to respond atm. So i'm wondering if you know anything about curl_exec hanging/freezing because of some server configuration setting. If i'd know what it is that's causing this, maybe i can work around it? I'd also like to know about forward-scripts that can do POST and GET, and use fopen() instead of curl. Maybe that fixes it. The script I currently use: ?php /** * Transport for Cross-domain AJAX calls * * This is an implementation of a transport channel for utilizing cross-domain * AJAX calls. This script is passed the data through AJAX along with two special * hidden field containing the action URL and the http method (GET/POST). It then * sends the form fields to that URL and returns the response. * * @packageCrossDomainAjax * @categoryCURL * @authorMd Emran Hasan [EMAIL PROTECTED] * @linkhttp://www.phpfour.com */ require_once ('lib_html.php'); // The actual form action $action = $_REQUEST['url']; // Submission method $method = $_REQUEST['method']; // Query string $fields = ''; // Prepare the fields for query string, don't include the action URL OR method if (count($_REQUEST) 2) { foreach ($_REQUEST as $key = $value) { if ($key != 'url' || $key != 'method') { $fields .= $key . '=' . rawurlencode($value) . ''; } } } // Strip the last comma $fields = substr($fields, 0, strlen($fields) - 1); // Initiate cURL $ch = curl_init(); // Do we need to POST of GET ? if (strtoupper($method) == 'POST') { curl_setopt($ch, CURLOPT_URL, $action); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); } else { curl_setopt($ch, CURLOPT_URL, $action . '?' . $fields); } // Follow redirects and return the transfer curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); curl_setopt($connection, CURLOPT_TIMEOUT, 45);// 45 secs. download page curl_setopt($connection, CURLOPT_CONNECTTIMEOUT, 30); // 30 server found curl_setopt($connection, CURLOPT_VERBOSE, 1); // Get result and close cURL //tmlDump ($action); $result = curl_exec($ch); curl_close($ch); // Return the response echo $result; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] spreadsheets are opened read only
Thodoris wrote: If you are trying to open a file that has a URL instead of a local path, then it will always be opened as read-only, and there is no way to change this. If you are opening it using a local path (samba, nfs, fish, etc) then I would check to see the file permissions. As the file is being written by Apache from a form upload, the file will have Apache permissions. Either exec out to a shell script and change the owner (chown) of the file, or have Apache modify the persions with the built-in PHP command chmod. Ash www.ashleysheridan.co.uk Well what is bothering me is that the rights are identical to all dirs from the document root to all containing folders and I doubled checked that. Plus the rights are also the same. grr!! I think I may reconsider to change my career and start training elephants in a zoo or something. The resulting amount of excrement will at least be less than what you get dealing with some M$ applications :-) Cheers -- David Robley Talk about memory! This system even has a sense of guilt! Today is Pungenday, the 49th day of Bureaucracy in the YOLD 3174. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: curl_exec hangs/freezes on shared hosting
Rene Veerman wrote: I use the following script to make forward an ajax call from the browser to a server other than my main webserver. On my homeserver (debian/apache2/php5 with rootxs) it runs fine, but on my shared hosting (servage.net, phpinfo at http://mediabeez.veerman.ws/mb/sn.php) it freezes / hangs on curl_exec(). I've already asked my hoster's supportstaff about this, but they are a bit clueless and are very slow to respond atm. So i'm wondering if you know anything about curl_exec hanging/freezing because of some server configuration setting. If i'd know what it is that's causing this, maybe i can work around it? I'd also like to know about forward-scripts that can do POST and GET, and use fopen() instead of curl. Maybe that fixes it. The script I currently use: ?php /** * Transport for Cross-domain AJAX calls * * This is an implementation of a transport channel for utilizing cross-domain * AJAX calls. This script is passed the data through AJAX along with two special * hidden field containing the action URL and the http method (GET/POST). It then * sends the form fields to that URL and returns the response. * * @packageCrossDomainAjax * @categoryCURL * @authorMd Emran Hasan [EMAIL PROTECTED] * @linkhttp://www.phpfour.com */ require_once ('lib_html.php'); // The actual form action $action = $_REQUEST['url']; // Submission method $method = $_REQUEST['method']; // Query string $fields = ''; // Prepare the fields for query string, don't include the action URL OR method if (count($_REQUEST) 2) { foreach ($_REQUEST as $key = $value) { if ($key != 'url' || $key != 'method') { $fields .= $key . '=' . rawurlencode($value) . ''; } } } // Strip the last comma $fields = substr($fields, 0, strlen($fields) - 1); // Initiate cURL $ch = curl_init(); // Do we need to POST of GET ? if (strtoupper($method) == 'POST') { curl_setopt($ch, CURLOPT_URL, $action); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); } else { curl_setopt($ch, CURLOPT_URL, $action . '?' . $fields); } // Follow redirects and return the transfer curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); curl_setopt($connection, CURLOPT_TIMEOUT, 45);// 45 secs. download page curl_setopt($connection, CURLOPT_CONNECTTIMEOUT, 30); // 30 server found curl_setopt($connection, CURLOPT_VERBOSE, 1); // Get result and close cURL //tmlDump ($action); $result = curl_exec($ch); curl_close($ch); // Return the response echo $result; ? do a phpinfo() and check if sockets are enabled.. lots of shared hosts have them turned off -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Pass parameters via url inside a php cron job
Hi there, I would like to run a php file via cron job and there is a parameter to be passed. Unfortunatelly this does not work: # /usr/local/bin/php /home/www/create_notification_emails.php?tf=2 Could not open input file: /home/www/create_notification_emails.php?tf=2 The problem seems to be the ?tf=2 How do I pass parameters to this script? I need the same script but executed in different time frames which is passed by the parameter. Any ideas? Thank you for any hint, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pass parameters via url inside a php cron job
Merlin Morgenstern wrote: Hi there, I would like to run a php file via cron job and there is a parameter to be passed. Unfortunatelly this does not work: # /usr/local/bin/php /home/www/create_notification_emails.php?tf=2 Could not open input file: /home/www/create_notification_emails.php?tf=2 The problem seems to be the ?tf=2 How do I pass parameters to this script? I need the same script but executed in different time frames which is passed by the parameter. Any ideas? Thank you for any hint, Merlin Hi Merlin, Commandline arguments (for things like Cron) are a bit different than URL parameters. Try lookup information on argv and argc: http://www/php.net/features.commandline -- Aschwin Wesselius /'What you would like to be done to you, do that to the other'/
Re: [PHP] Re: curl_exec hangs/freezes on shared hosting
Nathan Rixham wrote: do a phpinfo() and check if sockets are enabled.. lots of shared hosts have them turned off yep, sockets are enabled on the shared hoster. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pass parameters via url inside a php cron job
Merlin Morgenstern schreef: Hi there, I would like to run a php file via cron job and there is a parameter to be passed. Unfortunatelly this does not work: # /usr/local/bin/php /home/www/create_notification_emails.php?tf=2 Could not open input file: /home/www/create_notification_emails.php?tf=2 The problem seems to be the ?tf=2 something like: /usr/local/bin/php /home/www/create_notification_emails.php -tf=2 you can retrieve input args via $argv variable - I suggest finding a package that parses this input for you so you don't have to manually do it, search for something like php GetOpt package ... PEAR has one for sure. How do I pass parameters to this script? I need the same script but executed in different time frames which is passed by the parameter. Any ideas? Thank you for any hint, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pass parameters via url inside a php cron job
Hello Jochem, thank you this has solved my problem: bla.php 2 $tf = $argv[1]; Best regards, Merlin Jochem Maas wrote: Merlin Morgenstern schreef: Hi there, I would like to run a php file via cron job and there is a parameter to be passed. Unfortunatelly this does not work: # /usr/local/bin/php /home/www/create_notification_emails.php?tf=2 Could not open input file: /home/www/create_notification_emails.php?tf=2 The problem seems to be the ?tf=2 something like: /usr/local/bin/php /home/www/create_notification_emails.php -tf=2 you can retrieve input args via $argv variable - I suggest finding a package that parses this input for you so you don't have to manually do it, search for something like php GetOpt package ... PEAR has one for sure. How do I pass parameters to this script? I need the same script but executed in different time frames which is passed by the parameter. Any ideas? Thank you for any hint, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] curl_exec hangs/freezes on shared hosting
It's actually the server i'm calling that's at fault, it didn't serve connections from the outside world.. So not a php thing at all, sry for the wasted time.. Rene Veerman wrote: I use the following script to make forward an ajax call from the browser to a server other than my main webserver. On my homeserver (debian/apache2/php5 with rootxs) it runs fine, but on my shared hosting (servage.net, phpinfo at http://mediabeez.veerman.ws/mb/sn.php) it freezes / hangs on curl_exec(). I've already asked my hoster's supportstaff about this, but they are a bit clueless and are very slow to respond atm. So i'm wondering if you know anything about curl_exec hanging/freezing because of some server configuration setting. If i'd know what it is that's causing this, maybe i can work around it? I'd also like to know about forward-scripts that can do POST and GET, and use fopen() instead of curl. Maybe that fixes it. The script I currently use: ?php /** * Transport for Cross-domain AJAX calls * * This is an implementation of a transport channel for utilizing cross-domain * AJAX calls. This script is passed the data through AJAX along with two special * hidden field containing the action URL and the http method (GET/POST). It then * sends the form fields to that URL and returns the response. * * @packageCrossDomainAjax * @categoryCURL * @authorMd Emran Hasan [EMAIL PROTECTED] * @linkhttp://www.phpfour.com */ require_once ('lib_html.php'); // The actual form action $action = $_REQUEST['url']; // Submission method $method = $_REQUEST['method']; // Query string $fields = ''; // Prepare the fields for query string, don't include the action URL OR method if (count($_REQUEST) 2) { foreach ($_REQUEST as $key = $value) { if ($key != 'url' || $key != 'method') { $fields .= $key . '=' . rawurlencode($value) . ''; } } } // Strip the last comma $fields = substr($fields, 0, strlen($fields) - 1); // Initiate cURL $ch = curl_init(); // Do we need to POST of GET ? if (strtoupper($method) == 'POST') { curl_setopt($ch, CURLOPT_URL, $action); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); } else { curl_setopt($ch, CURLOPT_URL, $action . '?' . $fields); } // Follow redirects and return the transfer curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); curl_setopt($connection, CURLOPT_TIMEOUT, 45);// 45 secs. download page curl_setopt($connection, CURLOPT_CONNECTTIMEOUT, 30); // 30 server found curl_setopt($connection, CURLOPT_VERBOSE, 1); // Get result and close cURL //tmlDump ($action); $result = curl_exec($ch); curl_close($ch); // Return the response echo $result; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] calling functions from one or multiple files
At 3:44 PM -0400 9/24/08, Robert Cummings wrote: Seems kind of silly to have every function in it's own file. Also seems kind of cluttered ot have every function in one file. Now grouping related functions into a single file... that's sounds like a good middle ground. Cheers, Rob. The Goldie Locks solution. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...
-Original Message- Is there a way to limit the memory consumption and / or the CPU consumption of processes launched by the php functions system, exec, passthru, proc_open and shell_exec? I suspect... PHP pretty much releases control to the shell or whatever, and just waits around for it to finish. You'll have to put limits into the called processes, I think I could be wrong. ___ The information in this email or in any file attached hereto is intended only for the personal and confiden- tial use of the individual or entity to which it is addressed and may contain information that is propri- etary and confidential. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communica- tion is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product. Email trans- mission cannot be guaranteed to be secure or error- free. P6070214
Re: [PHP] Pass parameters via url inside a php cron job
On Thu, Sep 25, 2008 at 6:34 AM, Merlin Morgenstern [EMAIL PROTECTED] wrote: Hello Jochem, thank you this has solved my problem: bla.php 2 $tf = $argv[1]; Conversely, on a *NIX system, if you want to grab it via the web - locally or from a remote server - you can do this: * * * * * /bin/env GET http://www.example.com/index.html?example=given; /dev/null 21 (^--- cron schedule) (^--- your URL) -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Math problems (No not high school math!)
So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED]
Re: [PHP] Math problems (No not high school math!)
Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... Consider adding a column for the total hours and calculate it when saving the record. It should make everything that follows easier. Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Math problems (No not high school math!)
Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] sounds like a mysql job.. whats the SQL? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Math problems (No not high school math!)
On Sep 25, 2008, at 11:19 AM, Nathan Rixham wrote: Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] sounds like a mysql job.. whats the SQL? Actually where this is displayed, it is just a display portion, but when I do the insert here is my SQL: switch ($_GET['opt']){ case signin; //$sqlopt = INSERT INTO `timeStore` ('timein', 'timeout', 'empID') VALUES('{$timenow}', 'NULL', '{$auth['empID']}'); $sqlopt = INSERT INTO `timeStore` VALUES(\{$timenow}\, \NULL \, \{$_SESSION['userInfo']['empID']}\, \\, \{$_SESSION['userInfo']['fullname']}\); break; case signout; $sqlopt = UPDATE `timeStore` SET `timeout`=\{$timenow}\ WHERE `empID`=\{$_SESSION['userInfo']['empID']}\ AND `timeout`=\NULL\; break; } if(isset($_GET['opt'])){ mysql_query($sqlopt) or die(sqlopt failed: .mysql_error()); echo BRSQL OPT: .$sqlopt.BR; header(Location: timecard.php); echo BReaking at opt get; } Yes I know it's ugly with all the escaping but I'm working my way through that :P -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math problems (No not high school math!)
Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] Doesn't seem logical to have the weekly total displayed at the end of each day. Are you wanting a subtotal of each day being added to the weekly total to be displayed next to each day? If that is the case, the just have one variable that you add each days total to that doesn't get reset when the new DAY is started. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Math problems (No not high school math!)
On Sep 25, 2008, at 11:24 AM, Jason Pruim wrote: On Sep 25, 2008, at 11:19 AM, Nathan Rixham wrote: Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] sounds like a mysql job.. whats the SQL? Actually where this is displayed, it is just a display portion, but when I do the insert here is my SQL: switch ($_GET['opt']){ case signin; //$sqlopt = INSERT INTO `timeStore` ('timein', 'timeout', 'empID') VALUES('{$timenow}', 'NULL', '{$auth['empID']}'); $sqlopt = INSERT INTO `timeStore` VALUES(\{$timenow}\, \NULL \, \{$_SESSION['userInfo']['empID']}\, \\, \{$_SESSION['userInfo']['fullname']}\); break; case signout; $sqlopt = UPDATE `timeStore` SET `timeout`=\{$timenow}\ WHERE `empID`=\{$_SESSION['userInfo']['empID']}\ AND `timeout`= \NULL\; break; } if(isset($_GET['opt'])){ mysql_query($sqlopt) or die(sqlopt failed: .mysql_error()); echo BRSQL OPT: .$sqlopt.BR; header(Location: timecard.php); echo BReaking at opt get; } Yes I know it's ugly with all the escaping but I'm working my way through that :P Per an e-mail I just received suggesting that it may be wise to include the select SQL here it is: $sql = SELECT * from `timestore` order by `empID`; $row[]= mysql_query($sql) or die(Could not perform query: . mysql_error()); $result = $row[0]; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math problems (No not high school math!)
On Sep 25, 2008, at 11:28 AM, Jim Lucas wrote: Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] Doesn't seem logical to have the weekly total displayed at the end of each day. Are you wanting a subtotal of each day being added to the weekly total to be displayed next to each day? If that is the case, the just have one variable that you add each days total to that doesn't get reset when the new DAY is started. Hi Jim, You are correct, I want it to look something like this: Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day TOTAL FOR WEEK: X -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...
On Thu, Sep 25, 2008 at 4:28 AM, Valentin Schmid - ICSurselva AG [EMAIL PROTECTED] wrote: Hello all, Is there a way to limit the memory consumption and / or the CPU consumption of processes launched by the php functions system, exec, passthru, proc_open and shell_exec? Since you're working on a *NIX system, check out PHP's pcntl_* functions[1] and the *NIX `nice` function[2]. 1: http://www.php.net/manual/en/ref.pcntl.php 2: http://www.manpagez.com/man/1/nice/ -- /Daniel P. Brown More full-root dedicated server packages: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math problems (No not high school math!)
Jason Pruim wrote: On Sep 25, 2008, at 11:28 AM, Jim Lucas wrote: Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] Doesn't seem logical to have the weekly total displayed at the end of each day. Are you wanting a subtotal of each day being added to the weekly total to be displayed next to each day? If that is the case, the just have one variable that you add each days total to that doesn't get reset when the new DAY is started. Hi Jim, You are correct, I want it to look something like this: Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day TOTAL FOR WEEK: X -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] This should work for you. $totalWeek = 0; // Initialize total holder while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalWeek += totalday; // Builds the total from the daily total echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } # Display Weekly total echo WEEKTOTAL tr td colspan='4' align='right'TOTAL FOR WEEK: {$totalWeek}/td /tr WEEKTOTAL; echo /table /div /body; -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Math problems (No not high school math!)
Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- How about having mysql do all the tedious stuff? SELECT TIMESTAMPDIFF(HOUR, timein, timeout) FROM table WHERE WEEK(timein) = $someWeek; would give you the amount of hours between 2 time-values. Then you could SUM it all up, group by user and return that. SELECT SUM(timeout-timein) as secs, SUM(timeout-timein)/3600 as hours, userid FROM table WHERE timein = $START_OF_WEEK AND timeout = $END_OF_WEEK GROUP BY userid; simple as that :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math problems (No not high school math!)
-Original Message- From: Jason Pruim [mailto:[EMAIL PROTECTED] Subject: [PHP] Math problems (No not high school math!) So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) Something like this should work: Select SUM(timediff(`timeout`, `timein`)) where date = X; And for a week: Select SUM(timediff(`timeout`, `timein`)) where week(date) = week_of_year ; (Not tested) Simcha Younger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wierd Variable Initialization
Interesting. Thank you On Thu, Sep 25, 2008 at 2:01 AM, Ford, Mike [EMAIL PROTECTED] wrote: On 25 September 2008 03:45, VamVan advised: So guys, I found some thing strange that happened to me yesterday. Its small but kinda freaked me out. So I have a tokenmap.php that I include include in different configuration files. Some are classes and some are simple php files. So in my tokenmap.php I have declared an array as global. SO $GLOBAL['tokenmap'] = array() As a good programming practice what I did was: require_once('tokenmap.php'); $tokenmap = array(); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); The above displays empty array But when I do this , it works require_once('tokenmap.php'); $tokenmap = $GLOBAL['tokenmap']; print_r($tokenmap); Its kind of wierd for me. I am trying to understand. Can some one shed some light on it for me. Well, $GLOBALS['tokenmap'] is *exactly* *the* *same* *thing* as $tokenmap when you're in the global scope (which I assume you are for what you describe here to make sense). So the assignment: $tokenmap = array(); is the same as: $GLOBALS['tokenmap'] = array(); And the assignment: $tokenmap = $GLOBALS['tokenmap']; is essentially useless as it's the same as: $tokenmap = $tokenmap; ... or: $GLOBALS['tokenmap'] = $tokenmap; ... or even: $GLOBALS['tokenmap'] = $GLOBALS['tokenmap']; Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math problems (No not high school math!)
On Sep 25, 2008, at 11:44 AM, Jim Lucas wrote: Jason Pruim wrote: On Sep 25, 2008, at 11:28 AM, Jim Lucas wrote: Jason Pruim wrote: So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] Doesn't seem logical to have the weekly total displayed at the end of each day. Are you wanting a subtotal of each day being added to the weekly total to be displayed next to each day? If that is the case, the just have one variable that you add each days total to that doesn't get reset when the new DAY is started. Hi Jim, You are correct, I want it to look something like this: Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day TOTAL FOR WEEK: X -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] This should work for you. $totalWeek = 0; // Initialize total holder while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalWeek += totalday; // Builds the total from the daily total echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } # Display Weekly total echo WEEKTOTAL tr td colspan='4' align='right'TOTAL FOR WEEK: {$totalWeek}/td /tr WEEKTOTAL; echo /table /div /body; Hi Everyone, Just letting you all know (And for the archives) that I decided to use Jim's solution provided above. It works perfectly for what I am attempting to do. Thanks to everyone for their help! -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Math problems (No not high school math!)
Jason Pruim a écrit : $totalday = $totalday/60/60; If you're working with legal dates, this is wrong. A day can be 23 or 25 hours long. Thing about time changing (winter and summer time). Use strtotime to avoid this kind of problems. -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Filters and sanitizing a regexp
Is it possible to use the php filter function to sanitize a regular expression such as to return just the date part of a string that may be passed by an nonobservant user? #\d\d/\d\d/\d\d\d\d# input would be something like as02/05/2008df I want to use the filter to give me just the date should some oaf not leave the date field as just digits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Filters and sanitizing a regexp
by the by I'm using filter_var($string, FITER_VALIDATE_REGEXP, blah blah blah) Frank Stanovcak [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is it possible to use the php filter function to sanitize a regular expression such as to return just the date part of a string that may be passed by an nonobservant user? #\d\d/\d\d/\d\d\d\d# input would be something like as02/05/2008df I want to use the filter to give me just the date should some oaf not leave the date field as just digits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math problems (No not high school math!)
Run another query and let MySQL add it up. -Original Message- From: Jason Pruim [mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 2008 10:05 AM To: PHP General List Subject: [PHP] Math problems (No not high school math!) So I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){ $timein = date(m/d/y h:i:s, $row['timein']); $timeout = date(m/d/y h:i:s, $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@#?#$*^ echo ADMIN tr td{$row['Name']}/td td{$timein}/td td{$timeout}/td td{$totalday}/td /tr ADMIN; } echo /table /div /body; -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com [EMAIL PROTECTED] ___ The information in this email or in any file attached hereto is intended only for the personal and confiden- tial use of the individual or entity to which it is addressed and may contain information that is propri- etary and confidential. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communica- tion is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product. Email trans- mission cannot be guaranteed to be secure or error- free. P6070214 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filters and sanitizing a regexp
-Original Message- From: Frank Stanovcak [mailto:[EMAIL PROTECTED] Sent: Thursday, September 25, 2008 12:41 PM To: php-general@lists.php.net Subject: [PHP] Filters and sanitizing a regexp Is it possible to use the php filter function to sanitize a regular expression such as to return just the date part of a string that may be passed by an nonobservant user? #\d\d/\d\d/\d\d\d\d# input would be something like as02/05/2008df I want to use the filter to give me just the date should some oaf not leave the date field as just digits. Using preg_match and numbered groups, you could re-build the variable like this: ?php $var = as02/05/2008df; $matches = array(); preg_match(#(\d{2})\D*(\d{2})\D*(\d{4})#, $var, $matches); if(count($matches) != 4) { echo Invalid databr /; } else { $filtered = $matches[1] . $matches[2] . $matches[3]; echo $filtered; } ? HTH, Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filters and sanitizing a regexp
... Hi, Had to have a play with this. Here's my (somewhat stricter) regex: preg_match('/((?:[0-3]?[0-9])?\d)-([0-1]?\d)-20\d\d/', '31-12-2000', $matches); if (!empty($matches[1]) AND $matches[1] 31) $matches = array(); if (!empty($matches[2]) AND $matches[2] 12) $matches = array(); You could probably do the checks for the day and month within the regex, but it's late :-) -- Richard Heyes HTML5 Graphing for FF, Chrome, Opera and Safari: http://www.phpguru.org/RGraph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filters and sanitizing a regexp
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Richard Heyes Sent: Thursday, September 25, 2008 2:28 PM To: Boyd, Todd M. Cc: Frank Stanovcak; php-general@lists.php.net Subject: Re: [PHP] Filters and sanitizing a regexp ... Hi, Had to have a play with this. Here's my (somewhat stricter) regex: preg_match('/((?:[0-3]?[0-9])?\d)-([0-1]?\d)-20\d\d/', '31-12-2000', $matches); if (!empty($matches[1]) AND $matches[1] 31) $matches = array(); if (!empty($matches[2]) AND $matches[2] 12) $matches = array(); You could probably do the checks for the day and month within the regex, but it's late :-) I don't think that one is quite right... Your optionals (?) are confusing. Why [0-3]?[0-9] AND the \d? Why [0-9] at all (since \d is essentially [0-9])? Why use the discarded capture group (?:) since the [0-3] is already optional? It's on! :D ?php $var = as12/32/2000df; $matches = array(); preg_match('#(\d?[0-9])\D*([0-3]?\d)\D*(\d{4})#', $var, $matches); if(count($matches) != 4 || $matches[1] 12 || $matches[2] 31) $matches = NULL; ? MMDD 4 life, yo! Although, I would honestly prefer it if the world went to MMDD as a standard. Just seems to sort itself out more intuitively to the way I perceive time. (FYI, I'm not sure about the if() statement working out or not... I'm assuming PHP will drop through to the then part if there aren't 4 elements in the array instead of arbitrarily testing the possibly-missing elements... but I didn't test that part.) Also, I used \D* to save space (and confusion). You could just as easily use (?:-|/) for hyphens or slashes. Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Don't understand what is this $arr['N']['#']
Greetings, It flance. In reply to Your message dated Thursday, September 25, 2008, 0:21:59, -Original Message- I am working on the code of a former employee and I don't understand what this $arr['N']['#'] refers to. I know it is a multidimensional associative array but the # i don't what this means. '#' is just a string value. It has no special meaning whatsoever. except in the deranged world of the original author :D You're right. Because associative arrays are meant to make code easier to understand by using meaningful indexes. That, actually, COULD be meaningful index. In some cases. Please don't top post any more. thank you. -- Sincerely Yours, ANR Daemon [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The Data Literacy Test
Ashley Sheridan schreef: On Wed, 2008-09-24 at 21:45 -0400, Eric Butera wrote: On Wed, Sep 24, 2008 at 9:22 PM, Shelley [EMAIL PROTECTED] wrote: 2008/9/25 Philip Thompson [EMAIL PROTECTED] On Sep 24, 2008, at 7:29 AM, Maciek Sokolewicz wrote: tedd wrote: At 12:25 PM +0100 9/24/08, Ashley Sheridan wrote: On Wed, 2008-09-24 at 09:20 +0800, Shelley wrote: http://phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test The Data Literacy Test: http://www.phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test What the smeg is this? I don't know, but I figure 27. Cheers, tedd yes, I think 27 aswell... - Tul No no no. We all know the answer is 42. ? How come 42? -- With best regards, Shelley Shyan http://phparch.cn The question can't exist in the same universe as the answer. :( But 42 is THE answer ;) yes indeed, it's the answer to life, the universe and everthing. oh crap, I just gave it away. as penance the next time a strange asks me directions I'm gonna just say 42. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling functions from one or multiple files
tedd schreef: At 3:44 PM -0400 9/24/08, Robert Cummings wrote: Seems kind of silly to have every function in it's own file. Also seems kind of cluttered ot have every function in one file. Now grouping related functions into a single file... that's sounds like a good middle ground. Cheers, Rob. The Goldie Locks solution. otherwise known as mediorce ... rather like his blowup doll :-P Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling functions from one or multiple files
On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote: tedd schreef: At 3:44 PM -0400 9/24/08, Robert Cummings wrote: Seems kind of silly to have every function in it's own file. Also seems kind of cluttered ot have every function in one file. Now grouping related functions into a single file... that's sounds like a good middle ground. Cheers, Rob. The Goldie Locks solution. otherwise known as mediorce ... rather like his blowup doll :-P Cheers, tedd Why does it always come back to that poor doll?! Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling functions from one or multiple files
Ashley Sheridan schreef: On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote: tedd schreef: At 3:44 PM -0400 9/24/08, Robert Cummings wrote: Seems kind of silly to have every function in it's own file. Also seems kind of cluttered ot have every function in one file. Now grouping related functions into a single file... that's sounds like a good middle ground. Cheers, Rob. The Goldie Locks solution. otherwise known as mediorce ... rather like his blowup doll :-P Cheers, tedd Why does it always come back to that poor doll?! dunno, but it's rather apt to say 'screw the doll' :-P Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filters and sanitizing a regexp
On Thu, Sep 25, 2008 at 3:57 PM, Boyd, Todd M. [EMAIL PROTECTED] wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Richard Heyes Sent: Thursday, September 25, 2008 2:28 PM To: Boyd, Todd M. Cc: Frank Stanovcak; php-general@lists.php.net Subject: Re: [PHP] Filters and sanitizing a regexp ... Hi, Had to have a play with this. Here's my (somewhat stricter) regex: preg_match('/((?:[0-3]?[0-9])?\d)-([0-1]?\d)-20\d\d/', '31-12-2000', $matches); if (!empty($matches[1]) AND $matches[1] 31) $matches = array(); if (!empty($matches[2]) AND $matches[2] 12) $matches = array(); You could probably do the checks for the day and month within the regex, but it's late :-) I don't think that one is quite right... Your optionals (?) are confusing. Why [0-3]?[0-9] AND the \d? Why [0-9] at all (since \d is essentially [0-9])? Why use the discarded capture group (?:) since the [0-3] is already optional? It's on! :D ?php $var = as12/32/2000df; $matches = array(); preg_match('#(\d?[0-9])\D*([0-3]?\d)\D*(\d{4})#', $var, $matches); if(count($matches) != 4 || $matches[1] 12 || $matches[2] 31) $matches = NULL; ? MMDD 4 life, yo! Although, I would honestly prefer it if the world went to MMDD as a standard. Just seems to sort itself out more intuitively to the way I perceive time. (FYI, I'm not sure about the if() statement working out or not... I'm assuming PHP will drop through to the then part if there aren't 4 elements in the array instead of arbitrarily testing the possibly-missing elements... but I didn't test that part.) Also, I used \D* to save space (and confusion). You could just as easily use (?:-|/) for hyphens or slashes. Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php my contribution /^\d{1,2}(\/)\d{1,2}(\/)\d{4}$/ -- Bastien Cat, the other other white meat
Re: [PHP] Filters and sanitizing a regexp
I'd return an error. You can use this function to make sure they entered a valid date: http://us.php.net/checkdate Provide a template like: (Month/Day/Year) or for EU (Day/Month/Year) If it's not valid, return an error and let them fix it. Chances are, if they entered more characters than a date, the date you parse might not be the one that they wanted. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Frank Stanovcak wrote: Is it possible to use the php filter function to sanitize a regular expression such as to return just the date part of a string that may be passed by an nonobservant user? #\d\d/\d\d/\d\d\d\d# input would be something like as02/05/2008df I want to use the filter to give me just the date should some oaf not leave the date field as just digits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The Data Literacy Test
At 9:22 AM +0800 9/25/08, Shelley wrote: 2008/9/25 Philip Thompson [EMAIL PROTECTED] On Sep 24, 2008, at 7:29 AM, Maciek Sokolewicz wrote: tedd wrote: At 12:25 PM +0100 9/24/08, Ashley Sheridan wrote: On Wed, 2008-09-24 at 09:20 +0800, Shelley wrote: http://phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test The Data Literacy Test: http://www.phparch.cn/index.php/php/34-php-basics/202-the-data-literacy-test What the smeg is this? I don't know, but I figure 27. Cheers, tedd yes, I think 27 aswell... - Tul No no no. We all know the answer is 42. ? How come 42? The answer to the question of Life, The Universe, and Everything, is 42. -= Bill =- -- With best regards, Shelley Shyan http://phparch.cn -- A libertarian, immoral society is enticing you to excesses. Enjoy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unicode problems
This is slightly OT but I honestly don't know what else I can do. I was asked to migrate a website from diff hosts. Okay, pretty easy, right? Well, as usual, it wasn't. Site pages content type was ISO-8559-1 and it was developed for a MySQL5 database that used latin1 as charset and InnoDB as storage system. Pretty normal and ran smoothly. The client database is a old 4.0 MySQL that (I'm not sure if they're just disabled but it) doesn't have InnoDB and latin1. So I'm stuck with MyISAM and UTF8. No, they can't change it - their hosting want them to migrate to MSSQL and they can't switch hosts for whatever reason. After I uploaded the files and ran it, my HTML files displayed correctly but all accented chars that came from DB were displayed with weird chars, as I imagined it would. I then set my html content type to UTF-8 and I also had problems, but in backwards this time - DB values were OK and website content was bad. I couldn't find any good function/script to convert all my files to UTF-8 and then I built my own. It uses iconv and works like a charm. But unfortunately I still can't get all pages to work. I have no idea why or how, but *some* queries return the text in ISO-8859-1. I even dropped the table and recreated them explictly saying it's a UTF8 table but some rows are in ISO and others in UTF-8 (that or some mysql_fetch_* functions converts them). It's been 2 days and I still can't see a solution. I even thougth of adding utf_decode on all of mysql_fetch* results, but I didn't build this website so I don't feel like adding that in *every* call (it doesn't have a wrapper for mysql_* functions). So, I'm here to humbly ask for your help. What can be wrong? PHP Version is 4.4.8 Thanks, -- Thiago Henrique Pojda http://nerdnaweb.blogspot.com
Re: [PHP] Unicode problems
Thiago H. Pojda wrote: This is slightly OT but I honestly don't know what else I can do. I was asked to migrate a website from diff hosts. Okay, pretty easy, right? Well, as usual, it wasn't. Site pages content type was ISO-8559-1 and it was developed for a MySQL5 database that used latin1 as charset and InnoDB as storage system. Pretty normal and ran smoothly. The client database is a old 4.0 MySQL that (I'm not sure if they're just disabled but it) doesn't have InnoDB and latin1. So I'm stuck with MyISAM and UTF8. No, they can't change it - their hosting want them to migrate to MSSQL and they can't switch hosts for whatever reason. Tried either of these? http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html http://forums.mysql.com/read.php?10,52929,56552#msg-56552 -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling functions from one or multiple files
On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote: tedd schreef: At 3:44 PM -0400 9/24/08, Robert Cummings wrote: Seems kind of silly to have every function in it's own file. Also seems kind of cluttered ot have every function in one file. Now grouping related functions into a single file... that's sounds like a good middle ground. Cheers, Rob. The Goldie Locks solution. otherwise known as mediorce ... rather like his blowup doll :-P What's mediorce? Is that like an orc that's not too large, but not too small? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calling functions from one or multiple files
On Fri, 2008-09-26 at 02:10 +0200, Jochem Maas wrote: Ashley Sheridan schreef: On Fri, 2008-09-26 at 01:05 +0200, Jochem Maas wrote: tedd schreef: At 3:44 PM -0400 9/24/08, Robert Cummings wrote: Seems kind of silly to have every function in it's own file. Also seems kind of cluttered ot have every function in one file. Now grouping related functions into a single file... that's sounds like a good middle ground. Cheers, Rob. The Goldie Locks solution. otherwise known as mediorce ... rather like his blowup doll :-P Cheers, tedd Why does it always come back to that poor doll?! dunno, but it's rather apt to say 'screw the doll' :-P Hmm. I tried: apt-get screw the doll E: Invalid operation screw What am I doing wrong? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DEV] Re: [PHP] PHP 5.3.0alpha2
OK, I finally went to do it and this link doesn't work: PHP 5.3.0alpha2 VC9 x86 http://downloads.php.net/pierre/php-5.3.0alpha2-nts-Win32-VC9.zip On Thu, Sep 4, 2008 at 5:23 AM, Johannes Schlüter [EMAIL PROTECTED] wrote: On Wed, 2008-09-03 at 23:36 -0700, steve wrote: It is pretty much include() and its relatives. Autoloading with a lot of possible include paths. I'm sure if you had a Zend Framework App and put it on Windows, and took out all the require_onces with paths in them Try 5.3 please, our implementation of realpath(), one of the biggest require_once slowdowns, as well as other parts were improved quite a lot. Feedback is welcome :-) johannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php