Re: [PHP] How to download a multi-part file at the server side?
Hi Aziz. Thanks for the reply. Unfortunately, making the change suggested by you does not make any difference :( Sorry, Thanks and Regards On Sat, Nov 2, 2013 at 10:51 PM, Aziz Saleh azizsa...@gmail.com wrote: On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. 1. I could have the proper $_FILES[userfile][name] been echoed back, by replacing ContentBody cbFile = new FileBody(file, image/png); with ContentBody cbFile = new FileBody(file); 2. However, now I am stuck with the following server-side code. No matter what I do, I always get a no echoed back (specifying that the file is not copied to its target place). ### ?php $headers = apache_request_headers(); foreach ($headers as $header = $value) { if($header == active_window_title) { $active_window_title = $value; break; } } $target_path = /home/ajay/success.png; move_uploaded_file($_FILES[userfile][tmp_name], $target_path); if(file_exists($target_path)) { echo yes; } else { echo no; } echo \n . $_FILES[userfile][name]; # I always get the proper file-name echoed. ? Any ideas what stupidity am I making in the PHP code? On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg ajaygargn...@gmail.com wrote: Does not work :( As per the code-snippet I pasted, $_FILES[userfile][name] should be /path/to/png/file.png However, $_FILES[userfile][name] is empty. On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie sh...@mckenzies.net wrote: Fairly easy: http://www.php.net/manual/en/features.file-upload.post-method.php On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I intend to implement a use-case, wherein the client uploads a file in multi-part format, and the server then stores the file in a mysql database (after downloading it at the server side). I have been unable to find any immediate answers through googling; I will be grateful if someone could start me in a direction to achieve the downloading at server via php requirement. (Don't think it should matter, but I use Java to upload a file in multi-part format). I will be grateful for some pointers. Thanks in advance Thanks and Regards, Ajay -- Regards, Ajay -- Regards, Ajay Ajay, try changing your mpEntity to: new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE) See if it makes a difference. Ajay
Re: [PHP] How to download a multi-part file at the server side?
On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. 1. I could have the proper $_FILES[userfile][name] been echoed back, by replacing ContentBody cbFile = new FileBody(file, image/png); with ContentBody cbFile = new FileBody(file); 2. However, now I am stuck with the following server-side code. No matter what I do, I always get a no echoed back (specifying that the file is not copied to its target place). ### ?php $headers = apache_request_headers(); foreach ($headers as $header = $value) { if($header == active_window_title) { $active_window_title = $value; break; } } $target_path = /home/ajay/success.png; move_uploaded_file($_FILES[userfile][tmp_name], $target_path); if(file_exists($target_path)) { echo yes; } else { echo no; } echo \n . $_FILES[userfile][name]; # I always get the proper file-name echoed. ? Any ideas what stupidity am I making in the PHP code? On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg ajaygargn...@gmail.com wrote: Does not work :( As per the code-snippet I pasted, $_FILES[userfile][name] should be /path/to/png/file.png However, $_FILES[userfile][name] is empty. On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie sh...@mckenzies.net wrote: Fairly easy: http://www.php.net/manual/en/features.file-upload.post-method.php On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I intend to implement a use-case, wherein the client uploads a file in multi-part format, and the server then stores the file in a mysql database (after downloading it at the server side). I have been unable to find any immediate answers through googling; I will be grateful if someone could start me in a direction to achieve the downloading at server via php requirement. (Don't think it should matter, but I use Java to upload a file in multi-part format). I will be grateful for some pointers. Thanks in advance Thanks and Regards, Ajay -- Regards, Ajay -- Regards, Ajay Ajay, try changing your mpEntity to: new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE) See if it makes a difference.
Re: [PHP] preg_replace
Hi, On Fri, Nov 01, 2013 at 11:06:29AM -0400, leam hall wrote: Despite my best efforts to ignore preg_replace... Why? :) PHP Warning: preg_replace(): Delimiter must not be alphanumeric or backslash Thoughts? You are just using it wrong. http://us2.php.net/manual/en/regexp.reference.delimiters.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FYI: Apache/PHP exploit
On 31 okt. 2013, at 01:55, Joshua Kehn j...@kehn.us wrote: Summary for those on phones? Best, -Josh ___ http://byjakt.com Currently mobile On Oct 30, 2013, at 8:37 PM, Tamara Temple tamouse.li...@gmail.com wrote: This info cruised by my screen from G+ today, thought I’d at least pass it along: http://www.exploit-db.com/exploits/29290/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It opens a shell on default ubuntu/debian lamp's, compromising several versions of php, including the 5.5 branch. Sent from my iPhone 6 Beta [Confidential use only] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Persistent connections
On 25 Oct 2013, at 12:51, Nibin V M nibi...@gmail.com wrote: Thank you for the quick response Stuart...one more doubt..at http://php.net/manual/en/features.persistent-connections.php they states = This means that when the same client makes a second request to the server, it may be served by a different child process than the first time. When opening a persistent connection, every following page requesting SQL services can reuse the same established connection to the SQL server = Is the persistent connection pool is re-used between apache child processes ? No, connections are not shared between PHP processes. Nothing is shared between PHP processes. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On Fri, Oct 25, 2013 at 3:54 PM, Stuart Dallas stu...@3ft9.com wrote: On 25 Oct 2013, at 11:10, Nibin V M nibi...@gmail.com wrote: I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. A persistent connection is closed when the PHP process ends, or it gets disconnected by the server-side or due to a network error. Attempting to explicitly close a persistent connection will do nothing without complaining. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- Regards Nibin. http://TechsWare.in -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I am puzzled. Error on one site, no error on the other
On Fri, Oct 25, 2013 at 8:27 PM, Stephen stephe...@rogers.com wrote: Problem Situation I have two web sites on the same shared host. They share code for the control panel. When executed for one site I get a warning (reproducible always), but on the other there is no warning. One my home server, set up in the same way, I do not get a warning for either site. The warning is from this code: if ( in_array( $keys, $photo_ids ) ) *Warning*: in_array() expects parameter 2 to be array, null given in */home/rois3324/include/**cpprocessforms.php* on line *203* Steps 1) Photos are transferred to incoming directory using ftp. 2) Photo data is imported into database and files moved to web site's file system 3) Photos are linked to a category by i) Specifying photos to consider by entering filespec using wildcards ii) User presented with photos iii) User selects photos to be added to category and clicks process button iv) Form returns array of photo_ids (key in database table) v) Form processor creates entry in link table that links category_id to photo_id vi) A check is made to detect and reject when the link already exists This is where the error occurs I have looked at the code, but I am at a total loss to figure out why I have trouble on one site and not the other, even though they are using the code. And my home development system has no problems. I can't play trial and error on the development system. Anyone have any ideas? This is the code where the warning is triggered: function linkphotos( $dbh, $x ) { global $thumbsdirectory; $ret_str = ; $cat_id = $x['category']; $photos = $x['list']; $sql0 = SELECT photo_filename FROM photographs WHERE photo_id = :id; $sql1 = SELECT photo_id FROM gallery_photos WHERE photo_category = :id; $sql2= INSERT INTO gallery_photos VALUES ( :id, :photo_id, :order ); $stmt = $dbh-prepare($sql0); try { foreach( $photos as $keys= $on) { $stmt-bindValue(':id', $keys); $stmt-execute(); $row = $stmt-fetch(PDO::FETCH_ASSOC)**; $filenames[$keys] = $thumbsdirectory . / . $row['photo_filename']; } } catch (PDOException $e) { return 'Error selecting existing file names: ' . $e-getMessage(); } $stmt = $dbh-prepare($sql1); try { $stmt-bindValue(':id', $cat_id); $stmt-execute(); while ( list( $id ) = $stmt-fetch(PDO::FETCH_NUM)) { $photo_ids[] = $id; } } catch (PDOException $e) { return 'Error selecting existing photos: ' . $e-getMessage(); } $stmt = $dbh-prepare($sql2); try { $stmt-bindValue(':id', $cat_id); foreach( $photos as $keys= $on) { $ret_str .= htmlimage($filenames[$keys], $filenames[$keys] ) . br /; if ( in_array( $keys, $photo_ids ) ) { warning raised here $ret_str .= Duplicate. Already in Category.br /; } else { $stmt-bindValue(':photo_id', $keys); $stmt-bindValue(':order', $keys); $stmt-execute(); $ret_str .= Added to Category.br /; } } } catch (PDOException $e) { return 'Error inserting new photos: ' . $e-getMessage(); } return $ret_str; } -- Stephen Your $photo_ids array is not declared. After $photos = $x['list']; add $photo_ids = array();
Re: [PHP] framework or not
On 25 Oct 2013, at 15:40, Robert Cummings rob...@interjinn.com wrote: On 13-10-25 10:17 AM, Stuart Dallas wrote: On 25 Oct 2013, at 15:01, Robert Cummings rob...@interjinn.com wrote: On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Who's valuation of your time actually matters? Yours, and yours alone. Therefore: Life: n years Time I can benefit from my life: n years n years / n years = 1 *hoorah* Your time is the most precious commodity you have. Whether you use a framework or not you will (hopefully) reuse code between projects. If you choose to make part of that reused code one of the many frameworks that exist, you need only do one thing to ensure it continues to be worth using: how much of your time do you spend battling against the restrictions of the framework? If that's sufficiently low then using that framework is probably a good thing. If a significant portion of your time is spent battling the framework it's time to make a change. Also remember that the only person who can truthfully judge whether you're wasting time is you, unless you earn money by selling your time to someone else in which case they have some right to decide what constitutes a waste of the time for which they're paying. I found the experience of writing my own framework to be hugely beneficial to my future productivity, but I might have struggled to justify spending the extra time it took to my employer at the time. You stripped away the context of my response. By removing the evil grin you made it look like I was serious. You should be a reporter ;) Who says I'm not! :) -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Oh wait... you meant in the smaller scheme of things :) Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On 25 Oct 2013, at 15:01, Robert Cummings rob...@interjinn.com wrote: On 13-10-24 09:41 PM, Larry Garfield wrote: On 10/23/2013 08:51 AM, Jay Blanchard wrote: [snip] a bitter rant[/snip] Dang Larry - bad night? That wasn't a bitter rant. You haven't seen me bitter. :-) That was tough love to the OP. I don't see a reason to pussyfoot around the original question, which is one that comes up about once a month. The answer is always the same: How much is your time worth? Basic math... Life: finite Time: infinite finite / infinite = 0 *sniffle* Who's valuation of your time actually matters? Yours, and yours alone. Therefore: Life: n years Time I can benefit from my life: n years n years / n years = 1 *hoorah* Your time is the most precious commodity you have. Whether you use a framework or not you will (hopefully) reuse code between projects. If you choose to make part of that reused code one of the many frameworks that exist, you need only do one thing to ensure it continues to be worth using: how much of your time do you spend battling against the restrictions of the framework? If that's sufficiently low then using that framework is probably a good thing. If a significant portion of your time is spent battling the framework it's time to make a change. Also remember that the only person who can truthfully judge whether you're wasting time is you, unless you earn money by selling your time to someone else in which case they have some right to decide what constitutes a waste of the time for which they're paying. I found the experience of writing my own framework to be hugely beneficial to my future productivity, but I might have struggled to justify spending the extra time it took to my employer at the time. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Persistent connections
On 25 Oct 2013, at 11:10, Nibin V M nibi...@gmail.com wrote: I have been reading docs and many are telling that persistent connections are kept open indefinitely. But I found in PHP docs that it will not close after script execution like requesting a page; so should it close after the request is over? So when exactly a persistent connection should close? Please advice. A persistent connection is closed when the PHP process ends, or it gets disconnected by the server-side or due to a network error. Attempting to explicitly close a persistent connection will do nothing without complaining. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
I'm looking forward to the day that I'll know everything and can stop all this learning nonsense. Sounds like the attitude most people take when they sit down to a keyboard. (Ref: http://xkcd.com/386/) Off-topic is the new on-topic Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On 13-10-22 05:38 PM, Larry Garfield wrote: If you need more convincing, I will cite Fred Brooks: http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html Excellent article, thanks for the pointer. So many assertions have stood the test of time thus far. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] framework or not
On Wed, Oct 23, 2013 at 10:26 AM, Tedd Sperling tedd.sperl...@gmail.comwrote: On Oct 23, 2013, at 12:04 AM, Robert Cummings rob...@interjinn.com wrote: On 13-10-22 05:38 PM, Larry Garfield wrote: If you need more convincing, I will cite Fred Brooks: http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html Excellent article, thanks for the pointer. So many assertions have stood the test of time thus far. Cheers, Rob. Yes, it was an excellent article. One of the things I liked about the article was the concept of Incremental Development, which is something I have practiced since the Old Apple ][ days (Incidentally, he states he learned of this in 1958 -- is that a typo?). In 1977, I started many of my programs with (pardon my failing memory of AppleSoft syntax): Gosub GatherData() Gosub ProcessData() Gosub PresentDate() END It ran, but didn't do anything. Incidentally, that resembles a one-pass MVC design, does it not? In any event, I would flesh out the code until I got what I wanted. Maybe that's one of the reasons why Android or iOS Development starts with a Default Hello World App that does very little than run. Start simple, develop complex. Is there any other way to do it? I've been programming since 1975 and that's what I was taught and that's how always do it. Was it Brian Kernighan who said the 3 rules of programming are: 1. Keep it simple. 2. Build it in stages. 3. Let someone else do the hard part.
Re: [PHP] framework or not
On Wed, Oct 23, 2013 at 11:08 AM, Tedd Sperling tedd.sperl...@gmail.comwrote: On Oct 23, 2013, at 12:34 PM, Larry Martell la...@software-horizons.com wrote: Was it Brian Kernighan who said the 3 rules of programming are: 1. Keep it simple. 2. Build it in stages. 3. Let someone else do the hard part. Sounds good to me. I would also add: I've learned something new everyday of my life -- and I'm getting damned tired of it. I'm looking forward to the day that I'll know everything and can stop all this learning nonsense. Everything that can be invented has been invented. -Charles H. Duell, Commissioner of US patent office, 1899.
Re: [PHP] If date is greater than
On Sun, 2013-10-20 at 00:00 -0400, Bastien wrote: Thanks, Bastien On Oct 19, 2013, at 10:44 PM, John Taylor-Johnston jt.johns...@usherbrooke.ca wrote: I have date strings in my mysql db. -mm-dd. I want to parse to see if the date is greater than november 2011 and less than december 2012. Is this the right approach? How bad is my syntax? |function dates_range($todaynow) { | |$date1=strtotime(2011-11-01); $date2=strtotime(2012-12-31); if (|||($|todaynow |= $date1) and |($|||todaynow| = $date2)||) || { || # do something } } ||| Easiest to convert to integers and then compare Yes, I was going to ask, why are you storing your dates as strings? MySQL has a perfectly good DATE type. It's also generally faster comparing dates within a MySQL query than PHP code. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Algorithm Help
Hi, Indeed making and maintaining the graph looks like the best approach here to tackle this problem , but what does not seem clear to me is this -- Suppose a family can host 5 children , then you need to find the set of 5 such nodes out of the total no. of nodes(assume 10) such that the total weight of all edges connecting the 5*4 nodes is minimum , how do you go about finding this set once you have constructed and maintained this graph and what will be the complexity?? On Sun, Oct 20, 2013 at 11:49 AM, German Geek geek...@gmail.com wrote: Oh and it also assumes that you don't do $graph-together('A','B'); // ... $graph-together('B', 'A'); //!! NO! If this has to be catered for you could simply sort them when inserting: public function together($who, $with) { $sorted = array($who, $with); sort($sorted); $who = $sorted[0]; $with = $sorted[1]; if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } for the together function. Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 19:13, German Geek geek...@gmail.com wrote: Try this class: ?php // ASSUMES NAMES DON'T HAVE | IN THEM!! YOU COULD USE ANOTHER // CHARACTER COMBO IF NEEDED AND explode ON THAT class Graph { protected $data = null; public function __construct($init = array()) { $this-data = $init; } public function together($who, $with) { if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } public function getLeast($n = 1) { $values = array(); foreach ($this-data as $who = $withs) { foreach ($withs as $kwith = $vwith) { $values[$who .'|'. $kwith] = $vwith; } } asort($values); $nvalues = array_slice($values, 0, $n); $pairs = array(); foreach ($nvalues as $k = $v) { $parts = explode('|', $k); $pairs[] = array($parts[0], $parts[1]); } return $pairs; } public function __toString() { return print_r($this-data, true); } } $graph = new Graph(); $graph-together('A', 'B'); $graph-together('A', 'B'); $graph-together('B', 'C'); $graph-together('A', 'C'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); echo $graph; $least = $graph-getLeast(2); print_r($least); Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 15:33, German Geek geek...@gmail.com wrote: This is how I would approach/imagine it: https://docs.google.com/drawings/d/111RISgcHyAg8NXem4H1NXnxByRUydL8GiYlGkobJwus/edit Tom has been with Andrew 0 times. Tom has been with Shelly 1 time. Christine has been with Andrew 2 times. ... So the Graph maintains who has been with who how often. For 10 or even 20 kids you might be able to go through all links (brute force). The number of links (including the ones with 0 weight) is #links = n*(n-1)/2 which is the number of links you have to maintain and then check when you want to know who should go with whom. So, if n=10: #links = 10*9/2 = 45 n=20: #links = 20*19/2 = 190 n=30: #links = 30*29/2 = 435 I think even for reasonably large groups a computer can do the job easily. I would find it quite hard to do it on paper though, so I think you should program it. You could simply store the graph in an array, and then optionally persist it to a db or file: You would get e.g.: $graph = array( '0,1' = 0, '0,2' = 2, ... Edit: Actually, maybe you can do it in a two-dimensional array, where no node is connected to itself: $n=4; function init() { global $n; $graph = array(); for ($i = 0; $i $n; ++$i) { $graph[$i] = array(); for ($j = 0; $j $n; ++$j) { $graph[$i][$j] = 0; } } return $graph; } $graph = init(); Sorry, I might be running a bit out of time here... You can use an implementation of a graph, for example this one: http://pear.php.net/package/Structures_Graph/docs/latest/li_Structures_Graph.html But it might be overkill as the 2-dimensional array would even do the trick and there might be less overhead although you are requiring more space than needed (n*(n-1)/2+n cells more to be exact). You could store it in a hashmap/associative array like this: ?php $graph = array(
Re: [PHP] Algorithm Help
You don't need to maintain the history of which kids stay where unless you want to for other reasons. You just need to find the children that have staid the least amount of time together, which this approach would do for you. So, when 4 children stay together you say 1 together with 2 1 together with 3 1 together with 4 2 together with 3 2 together with 4 3 together with 4 and that's it. And then you can find the ones that staid together the least amount of time. Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 21:53, Ayush Ladia ayushladia.for...@gmail.com wrote: Hi, Indeed making and maintaining the graph looks like the best approach here to tackle this problem , but what does not seem clear to me is this -- Suppose a family can host 5 children , then you need to find the set of 5 such nodes out of the total no. of nodes(assume 10) such that the total weight of all edges connecting the 5*4 nodes is minimum , how do you go about finding this set once you have constructed and maintained this graph and what will be the complexity?? On Sun, Oct 20, 2013 at 11:49 AM, German Geek geek...@gmail.com wrote: Oh and it also assumes that you don't do $graph-together('A','B'); // ... $graph-together('B', 'A'); //!! NO! If this has to be catered for you could simply sort them when inserting: public function together($who, $with) { $sorted = array($who, $with); sort($sorted); $who = $sorted[0]; $with = $sorted[1]; if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } for the together function. Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 19:13, German Geek geek...@gmail.com wrote: Try this class: ?php // ASSUMES NAMES DON'T HAVE | IN THEM!! YOU COULD USE ANOTHER // CHARACTER COMBO IF NEEDED AND explode ON THAT class Graph { protected $data = null; public function __construct($init = array()) { $this-data = $init; } public function together($who, $with) { if (!isset($this-data[$who])) { $this-data[$who] = array(); } if (!isset($this-data[$who][$with])) { $this-data[$who][$with] = 1; return; } $this-data[$who][$with]++; } public function getLeast($n = 1) { $values = array(); foreach ($this-data as $who = $withs) { foreach ($withs as $kwith = $vwith) { $values[$who .'|'. $kwith] = $vwith; } } asort($values); $nvalues = array_slice($values, 0, $n); $pairs = array(); foreach ($nvalues as $k = $v) { $parts = explode('|', $k); $pairs[] = array($parts[0], $parts[1]); } return $pairs; } public function __toString() { return print_r($this-data, true); } } $graph = new Graph(); $graph-together('A', 'B'); $graph-together('A', 'B'); $graph-together('B', 'C'); $graph-together('A', 'C'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); $graph-together('B', 'D'); echo $graph; $least = $graph-getLeast(2); print_r($least); Tim-Hinnerk Heuer Twitter: @geekdenz Blog: http://www.thheuer.com On 20 October 2013 15:33, German Geek geek...@gmail.com wrote: This is how I would approach/imagine it: https://docs.google.com/drawings/d/111RISgcHyAg8NXem4H1NXnxByRUydL8GiYlGkobJwus/edit Tom has been with Andrew 0 times. Tom has been with Shelly 1 time. Christine has been with Andrew 2 times. ... So the Graph maintains who has been with who how often. For 10 or even 20 kids you might be able to go through all links (brute force). The number of links (including the ones with 0 weight) is #links = n*(n-1)/2 which is the number of links you have to maintain and then check when you want to know who should go with whom. So, if n=10: #links = 10*9/2 = 45 n=20: #links = 20*19/2 = 190 n=30: #links = 30*29/2 = 435 I think even for reasonably large groups a computer can do the job easily. I would find it quite hard to do it on paper though, so I think you should program it. You could simply store the graph in an array, and then optionally persist it to a db or file: You would get e.g.: $graph = array( '0,1' = 0, '0,2' = 2, ... Edit: Actually, maybe you can do it in a two-dimensional array, where no node is connected to itself: $n=4; function init() { global $n; $graph = array(); for ($i = 0; $i $n; ++$i) { $graph[$i] = array();
Re: [PHP] If date is greater than
On Oct 20, 2013, at 4:01 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Yes, I was going to ask, why are you storing your dates as strings? MySQL has a perfectly good DATE type. It's also generally faster comparing dates within a MySQL query than PHP code. Thanks, Ash http://www.ashleysheridan.co.uk Agreed. Plus, there are many date functions provided by MySQL that are easier (possibility faster) than what you can do in PHP. Check these out: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date tedd ___ tedd sperling tedd.sperl...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trying to understand what is happening in this code
On 11 Oct 2013, at 16:20, Nathan Grey grey...@gmail.com wrote: Stuart, Jose - Thanks for your quick response. Are you saying that the processor echos all the html tags it sees. Is it doing something like this to the script: echo body echo h1The first twenty Fibonacci numbers:/h1 echo ul ?php $first = 0; $second = 1; for ($i = 0; $i 20; $i++) { ? echo li?php echo $first + $second ?/li ?php $temp = $first + $second; $first = $second; $second = $temp; } ? echo /ul echo /body Or is it just the line in question that is being echoed? I'm not sure exactly what it gets compiled to, but I also don't see why it matters. All that matters is that content outside of PHP tags will simply get echo'd. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
On 10/8/2013 11:13 AM, Simon Schick wrote: Hi, Jim I suggest to read this page of the tutorial. It seems, that it solves the questions, you posted here: http://www.php.net/manual/en/configuration.file.per-user.php Please be aware, that the ini-file is not re-read on every request, but after a defined time. Neither are all settings changeable in those per-user ini-files. Read also the other pages in this chapter, they're good to keep in mind ;) If you're now calling the script from a webserver, you called by requesting a page on a subdomain or a top-level-domain, doesn't matter. Bye, Simon On Tue, Oct 8, 2013 at 4:48 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Can someone give me an understanding of how the .ini settings are located and combined? I am under the impression that there is a full settings .ini file somewhere up high in my host's server tree and that any settings I create in .ini files in each of my domain folders are appended/updated against the 'main' ini settings to give me a 'current' group of php.ini settings. What I'm looking to find out is does an ini setting established in a test subdomain of my site affect those ini settings outside of my test subdomain? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I need more! 1 - the doc you mentioned refers to 'user.ini'. Does that literally mean the file is called 'USER.ini'? I have been placing my .ini overrides/settings in each of my folders under the name 'php.ini'. Do I have to change them all because it seems that they are working fine. 2 - I didn't understand your last paragraph. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
re: changing ini settings. If my running script modifies an ini setting I currently believe that that changed setting will apply to that specific process and any others that run after that from that same folder (since i have an ini file in each folder currently). Correct? And if I do make a setting change as above, it only affects the ini file and processes in that folder, thus leaving the setting unchanged in any and all other folders above that one. Correct? And from the article pointed out to me, I get the impression that the search for ini files bubbles up from the executing folder. If that is so, then am I correct in assuming that settings in the lowest ini file take precedence over any found in 'bubbled-up' ini files? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
Hi, Jim I suggest to read this page of the tutorial. It seems, that it solves the questions, you posted here: http://www.php.net/manual/en/configuration.file.per-user.php Please be aware, that the ini-file is not re-read on every request, but after a defined time. Neither are all settings changeable in those per-user ini-files. Read also the other pages in this chapter, they're good to keep in mind ;) If you're now calling the script from a webserver, you called by requesting a page on a subdomain or a top-level-domain, doesn't matter. Bye, Simon On Tue, Oct 8, 2013 at 4:48 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Can someone give me an understanding of how the .ini settings are located and combined? I am under the impression that there is a full settings .ini file somewhere up high in my host's server tree and that any settings I create in .ini files in each of my domain folders are appended/updated against the 'main' ini settings to give me a 'current' group of php.ini settings. What I'm looking to find out is does an ini setting established in a test subdomain of my site affect those ini settings outside of my test subdomain? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
On 10/9/2013 3:14 AM, Simon Schick wrote: On Tue, Oct 8, 2013 at 9:50 PM, Jim Giner jim.gi...@albanyhandball.comwrote: On 10/8/2013 2:42 PM, Simon Schick wrote: On Tue, Oct 8, 2013 at 5:25 PM, Jim Giner jim.gi...@albanyhandball.com* *wrote: re: changing ini settings. If my running script modifies an ini setting I currently believe that that changed setting will apply to that specific process and any others that run after that from that same folder (since i have an ini file in each folder currently). Correct? And if I do make a setting change as above, it only affects the ini file and processes in that folder, thus leaving the setting unchanged in any and all other folders above that one. Correct? And from the article pointed out to me, I get the impression that the search for ini files bubbles up from the executing folder. If that is so, then am I correct in assuming that settings in the lowest ini file take precedence over any found in 'bubbled-up' ini files? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi, Jim Never mind my last paragraph ... I was thinking the wrong way of what you wrote earlier. I haven't tested it properly in every detail, but from the perspective of what I know it's like you wrote. The file that's mentioned as php.ini is the main configuration file of your php-installation. It may be, that the user-ini file was renamed to php.ini as well, but if you read about php.ini, they always mean the configuration-file that you see listed in the output of phpinfo() as Configuration File (php.ini) Path. * You can rename the user-ini file by changing the user_ini.filename setting in the php.ini file (as written on the page I linked you to) * The php-settings are restored after/before each script-execution * The manual doesn't catch if a user-ini file was found ... just that it bubbles up to the document_root. Maybe the configuration found in user-ini files is merged, or just the first file is taken. * I don't know what happens to configuration you apply f.e. in nginx ... I know neither when settings in php-fpm are applied ... that's something left for testing, or until somebody finds the documentation explaining it (I know there is one ...), but I guess they're applied after the php.ini and before the user-ini files. Examples are listed here: http://php.net/manual/en/**install.fpm.configuration.php#**example-60http://php.net/manual/en/install.fpm.configuration.php#example-60 * What you set using set_ini() is just applied for the rest of the currently running script. Bye Simon I understand most of what you wrote and agree all except for one thing. You keep using the name user.ini and I asked for clarification on this earlier. Do I have to create files named EXACTLY that way, or are php.ini files correctly named? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi, Jim You can define the name for this file your configuration (php basic configuration file or in the webserver, calling the cgi/fcgi script). The configuration is called user_ini.filename, and it's default value is set to .user.ini. Of course, your provider (or you, if you're the administrator of the php-instance) may changed this setting to something like php.ini. Then the php-process will search for a php.ini file in the directories a user-ini file is searched in. When talking about configuration files, this may be misleading, as the basic configuration file is refered as php.ini over all in the documentation. I don't believe, that the PHP process would search for a file called php.ini, if the value is set to something like .user.ini - if that's what you mean. It may be, that you can change the setting later on, but it will have no effect (f.e. if you change it using set_ini() ... if it doesn't trigger a E_WARNING or something the like). Hope this answers the remaining question. If not, I kindly ask you to write some examples. Bye, Simon Ok - here is what I see happening now. PHPINFO shows a setting named 'user_ini.filename' set to '.user.ini' At the same time the setting loaded configuration file shows that a php.ini file was loaded from the current sub folder that this call to phpinfo was running in (as I expect!). So apparently my host has set php to look for user.ini files, but php.ini files are still accepted and loaded. I'm guessing that despite the user_ini filename setting, a PHP.ini file will still be read, which suits me just fine. Thanks for all the help Simon! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Fatal error: Call to undefined function ()
On 7 Oct 2013, at 14:24, Michael Alaimo malaimo...@gmail.com wrote: We have a server that gets a large number of requests each month. After a period of time I began to see this error in our error logs this weekend. PHP Fatal error: Call to undefined function () It does not reference a function, so I found it odd. It did give a line to a function with array_merge on it. Has anyone seen this in the apache error logs? We are using PHP 5.3.3. Show us the line, and a few lines around it. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Fatal error: Call to undefined function ()
public static function getInfo($params = array()) { $results = array(); $url = 'http://google.com'; $props = array ( 'key'= Yii::app()-params['param1'], 's'= Yii::app()-params['param2'] ); if (!empty($params)) { $props = array_merge($props, $params); $url = $url . http_build_query($props, '', '/'); It may be possible that params has unsafe data in it. The previous dev did not validate the data passed in via get. The code populating params looks like: $params = array ( 'd' = $_GET['d'], ); $job = Job::getInfo($params); On Mon, Oct 7, 2013 at 9:29 AM, Stuart Dallas stu...@3ft9.com wrote: On 7 Oct 2013, at 14:24, Michael Alaimo malaimo...@gmail.com wrote: We have a server that gets a large number of requests each month. After a period of time I began to see this error in our error logs this weekend. PHP Fatal error: Call to undefined function () It does not reference a function, so I found it odd. It did give a line to a function with array_merge on it. Has anyone seen this in the apache error logs? We are using PHP 5.3.3. Show us the line, and a few lines around it. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] PHP Fatal error: Call to undefined function ()
On 7 Oct 2013, at 14:34, Michael Alaimo malaimo...@gmail.com wrote: On Mon, Oct 7, 2013 at 9:29 AM, Stuart Dallas stu...@3ft9.com wrote: On 7 Oct 2013, at 14:24, Michael Alaimo malaimo...@gmail.com wrote: We have a server that gets a large number of requests each month. After a period of time I began to see this error in our error logs this weekend. PHP Fatal error: Call to undefined function () It does not reference a function, so I found it odd. It did give a line to a function with array_merge on it. Has anyone seen this in the apache error logs? We are using PHP 5.3.3. Show us the line, and a few lines around it. public static function getInfo($params = array()) { $results = array(); $url = 'http://google.com'; $props = array ( 'key'= Yii::app()-params['param1'], 's'= Yii::app()-params['param2'] ); if (!empty($params)) { $props = array_merge($props, $params); $url = $url . http_build_query($props, '', '/'); It may be possible that params has unsafe data in it. The previous dev did not validate the data passed in via get. The code populating params looks like: $params = array ( 'd' = $_GET['d'], ); $job = Job::getInfo($params); My best guess is that either $props or $params contain a function reference or similar construct. Examine their contents with var_dump. As a check you could expand out the effect of array_merge and see if you still get the same with a PHP implementation. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 11:21 PM, Romain CIACCAFAVA wrote: An easier way to do that would be using the diff() method of a DateTime object on another. Regards Romain Ciaccafava Romain - you were so right. A little less calculating to be done and I got the result I wished. For anyone interested here's the function I'm using to determine how much time there is until a cookie expires. The cookie in question contains the expiration datetime that was used to create a paired cookie. function GetTimeLeft($applid) { if (isset($_COOKIE[$applid])) { if (isset($_COOKIE[$applid.expire])) { $curr_time = new datetime(); $cookietime = $_COOKIE[$applid.expire]; $exp_time = new datetime(); $exp_time-setTimeStamp($cookietime); $diff = $curr_time-diff($exp_time); $days = $diff-format(%d); $days = ($days 1) ? $days days: ($days == 1) ? $days day : ''; $hms = $diff-format(%h:%i:%s); return Time left: $days $hms; } else return '?'; } else return '0'; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
This should help you out http://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-php On Oct 6, 2013 6:07 PM, Farzan Dalaee farzan.dal...@gmail.com wrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.com wrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
The resulting subtraction is not a valid timestamp, but rather the difference between the two timestamps in seconds . The resulting diff can be 1 if the timestamps are 1 seconds apart. The linkhttp://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-phpJonathan sent out contains functions that does the division for you with results. Another link you can check out: http://stackoverflow.com/a/9143387/1935500 On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] date time problem
On 10/6/2013 7:40 PM, Aziz Saleh wrote: The resulting subtraction is not a valid timestamp, but rather the difference between the two timestamps in seconds . The resulting diff can be 1 if the timestamps are 1 seconds apart. The linkhttp://stackoverflow.com/questions/365191/how-to-get-time-difference-in-minutes-in-phpJonathan sent out contains functions that does the division for you with results. Another link you can check out: http://stackoverflow.com/a/9143387/1935500 On Sun, Oct 6, 2013 at 7:29 PM, Jim Giner jim.gi...@albanyhandball.comwrote: Look at my code. The inputs are all timestamps so date should work, no? My question why am i getting an hour value in this case? jg On Oct 6, 2013, at 7:14 PM, Aziz Saleh azizsa...@gmail.com wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Good Point! I never looked at it that way. I guess the Date function can't be relied on in that case. So now I'll have to calculate my time in a mathematical way instead of letting Date translate it for me. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
On 10/6/2013 7:55 PM, Ashley Sheridan wrote: On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk Thanks Ash, but the previous (top) post explained my dilemma just as you have done here. My attempt to use a function to avoid doing the math has now been resolved. Guess I'll have to do it the old-fashioned way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date time problem
An easier way to do that would be using the diff() method of a DateTime object on another. Regards Romain Ciaccafava Le 7 oct. 2013 à 03:10, Jim Giner jim.gi...@albanyhandball.com a écrit : On 10/6/2013 7:55 PM, Ashley Sheridan wrote: On Sun, 2013-10-06 at 19:14 -0400, Aziz Saleh wrote: Jim, The date method takes in a timestamp (not seconds away). You have the seconds, you will need to manually convert those seconds to what you desire (minutes = seconds / 60), (hours = minutes / 60), etc.. Aziz On Sun, Oct 6, 2013 at 7:07 PM, Farzan Dalaee farzan.dal...@gmail.comwrote: Its so freaky Best Regards Farzan Dalaee On Oct 7, 2013, at 2:29, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:49 PM, Farzan Dalaee wrote: Try this please gmdate(H:i:s, $diff%86400) Best Regards Farzan Dalaee On Oct 7, 2013, at 2:12, Jim Giner jim.gi...@albanyhandball.com wrote: On 10/6/2013 6:36 PM, Farzan Dalaee wrote: You should use gmdate() if you want to how many hours left to expire $time_left = gmdate(H:i:s,$diff); Best Regards Farzan Dalaee On Oct 7, 2013, at 1:49, Jim Giner jim.gi...@albanyhandball.com wrote: I always hate dealing with date/time stuff in php - never get it even close until an hour or two goes by anyway I have this: // get two timestamp values $exp_time = $_COOKIE[$applid.expire]; $curr_time = time(); // get the difference $diff = $exp_time - $curr_time; // produce a display time of the diff $time_left = date(h:i:s,$diff); Currently the results are: exp_time is 06:55:07 curr_time is 06:12:03 the diff is 2584 All of these are correct. BUT time_left is 07:43:04 when it should be only 00:43:04. So - where is the hour value of '07' coming from?? And how do I get this right? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks for the quick response, but why do I want to show the time in GMT? However, I did try it, changing the 'time_left' calc to use gmdate. Now instead of a 7 for hours I have a 12. exp 07:34:52 curr 06:40:14 diff 3158 left is 12:52:38 The 52:38 is the correct value, but not the 12. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Doesn't work either. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Aziz, please try not to top post :) It's true that the date() function takes in a timestamp as its argument, but a timestamp is a number representing the number of seconds since 00:00:00 1st January 1970, so passing in a very small number of seconds is perfectly valid. The only thing that would account for the 7 hours difference is the time zone, which would also be part of the timestamp. http://en.wikipedia.org/wiki/Unix_time gives more details. Thanks, Ash http://www.ashleysheridan.co.uk Thanks Ash, but the previous (top) post explained my dilemma just as you have done here. My attempt to use a function to avoid doing the math has now been resolved. Guess I'll have to do it the old-fashioned way. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On Oct 2, 2013, at 6:23 PM, Tamara Temple tamouse.li...@gmail.com wrote: On Oct 2, 2013, at 9:05 AM, Marc Guay marc.g...@gmail.com wrote: If you have the technology handy, it could also just be easier to wipe the children's memories after each stay. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well played! (.. eying the black suit…. What's that funny stick you're hol….) I love it! Our director loved it too! Too funny! Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
Round Robin algorithm should solve this and is a fairly quick alogrithm ... http://en.wikipedia.org/wiki/Round-robin An example can be found http://forrst.com/posts/PHP_Round_Robin_Algorithm-2zm On Tue, Oct 1, 2013 at 2:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Nickolas Whiting Freelance Consultant
Re: [PHP] Algorithm Help
On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php While definitely a tempting coding exercise, I just want to say that if this is urgent in any way, shuffling cards with the kids' names on them by hand might just be faster and less frustrating :) OTOH, if this is something you're going to have to figure out week after week, then a software solution might be handy. This is also not an *easy* problem to solve; there isn't a simple approach to optimizing this sort of thing because you're building a net between all the various kids based on past stays, in addition to the constraints of host family capacity. Thus your previous code attempts might in fact be the end result. Obviously, structuring the data is the key here. I'm thinking of 3 primary models: Kids, Hosts, and Stays. Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to have joining tables with Kids and Hosts. A Stay will have one Host, and have many Kids and a date. The algorithm then needs to make the graph where it can pull out the number of times any particular kid has stayed with another, looking something like this: Amy: Ben: 10 Jill: 3 Carlos: 7 Chen: 2 Ben: Amy: 10 Jill: 5 Carlos: 8 Chen: 3 Jill: … and so on Then you be able to pull through that graph and find the smallest number of stays for each kid. Not simple, but I hope this helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On 1 Oct 2013, at 19:51, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Sounds like a job for a directed graph data structure. I wish I had time to knock up a solution but I don't right now. This article should help you get started: http://www.codediesel.com/algorithms/building-a-graph-data-structure-in-php/ -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
It also depends on the amount of kids, families and stays. If the numbers are low, by hand may be a lot easier and faster Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl 2013/10/2 Tamara Temple tamouse.li...@gmail.com On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php While definitely a tempting coding exercise, I just want to say that if this is urgent in any way, shuffling cards with the kids' names on them by hand might just be faster and less frustrating :) OTOH, if this is something you're going to have to figure out week after week, then a software solution might be handy. This is also not an *easy* problem to solve; there isn't a simple approach to optimizing this sort of thing because you're building a net between all the various kids based on past stays, in addition to the constraints of host family capacity. Thus your previous code attempts might in fact be the end result. Obviously, structuring the data is the key here. I'm thinking of 3 primary models: Kids, Hosts, and Stays. Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to have joining tables with Kids and Hosts. A Stay will have one Host, and have many Kids and a date. The algorithm then needs to make the graph where it can pull out the number of times any particular kid has stayed with another, looking something like this: Amy: Ben: 10 Jill: 3 Carlos: 7 Chen: 2 Ben: Amy: 10 Jill: 5 Carlos: 8 Chen: 3 Jill: … and so on Then you be able to pull through that graph and find the smallest number of stays for each kid. Not simple, but I hope this helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On Oct 2, 2013, at 9:51 AM, Tamara Temple tamouse.li...@gmail.com wrote: On Oct 1, 2013, at 1:51 PM, Floyd Resler fres...@adex-intl.com wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php While definitely a tempting coding exercise, I just want to say that if this is urgent in any way, shuffling cards with the kids' names on them by hand might just be faster and less frustrating :) OTOH, if this is something you're going to have to figure out week after week, then a software solution might be handy. This is also not an *easy* problem to solve; there isn't a simple approach to optimizing this sort of thing because you're building a net between all the various kids based on past stays, in addition to the constraints of host family capacity. Thus your previous code attempts might in fact be the end result. Obviously, structuring the data is the key here. I'm thinking of 3 primary models: Kids, Hosts, and Stays. Kids and Hosts seem pretty obvious. Stays is the interesing model, and needs to have joining tables with Kids and Hosts. A Stay will have one Host, and have many Kids and a date. The algorithm then needs to make the graph where it can pull out the number of times any particular kid has stayed with another, looking something like this: Amy: Ben: 10 Jill: 3 Carlos: 7 Chen: 2 Ben: Amy: 10 Jill: 5 Carlos: 8 Chen: 3 Jill: … and so on Then you be able to pull through that graph and find the smallest number of stays for each kid. Not simple, but I hope this helps. That's the only approach I could think of. I may have to tell the director it may be a bit slow but at least she won't have to do it by hand! Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
If you have the technology handy, it could also just be easier to wipe the children's memories after each stay. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On Oct 2, 2013, at 9:05 AM, Marc Guay marc.g...@gmail.com wrote: If you have the technology handy, it could also just be easier to wipe the children's memories after each stay. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well played! (.. eying the black suit…. What's that funny stick you're hol….) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hey Tim, It seems that deleteObject takes in 2 params, and you are sending it 1 param. I would recommend you look at the documentation and make sure you are sending the right params. Aziz On Sun, Sep 29, 2013 at 10:29 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi Aziz, Thank you for getting back to me! I appreciate you spotting that error. So I corrected that ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['bucket_name'];* // Create the S3 Object from the SDK $s3 = new AmazonS3(); * $result = $s3-deleteObject(array( 'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br / * input type=submit name=submit value=Delete Bucket / /form/center script /body /html And this is the error I am currently getting: Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 Not sure if I'm getting closer here... but definitely appreciate any advice anyone may have. Thanks! Tim On Sun, Sep 29, 2013 at 5:04 PM, Aziz Saleh azizsa...@gmail.com wrote: No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name.
Re: [PHP] Algorithm Help
On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This sounds remarkably like homework, which we can't help you with unless you've got a specific problem that you're stuck with. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Algorithm Help
m 1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215 On Oct 1, 2013, at 3:14 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This sounds remarkably like homework, which we can't help you with unless you've got a specific problem that you're stuck with. Thanks, Ash http://www.ashleysheridan.co.uk Oh, no, this is definitely not homework! :) Although it certainly seems like a homework question. This is a real world problem. I'm keeping track of which kids stay with which host families in the database. My initial approach was to start with kid 1 and see how many times the other kids have stayed with kid 1. The move on to kid 2, and so it. This gives me a score for pairs of kids. However, if say three kids are staying at a host family, what is the best way to determine which set of three kids have stayed together the least? Thanks! Floyd
Re: [PHP] Algorithm Help
Assuming you don't have to be exact, somthing similar to this might work. Assign each kid to a host family randomly for each kid, check how frequently it has been combined with the kids in its assigned family. if it is too close, swap with a different family when all kids in that family are processed, move on to the next family and repeat, excluding the first family for swapping. do the same for all families excluding the previous families. when you have completed all families, do another iteration or two of the whole process. Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl 2013/10/1 Floyd Resler fres...@adex-intl.com m 1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215 On Oct 1, 2013, at 3:14 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer johnme...@pueblocomputing.comwrote: On 10/1/2013 12:51 PM, Floyd Resler wrote: Here's my task: A group of kids is going to be staying with different host families throughout the next 8 months. The number of kids staying with a host family can range from 2 to 10. When deciding which kids should stay together at a host family, the idea is for the system to put together kids who have stayed with each other the least on past weekends. So, if a host family can keep 5 kids, then the group of 5 kids who have stayed together the least will be chosen. I can't think of an easy, quick way to accomplish this. I've tried various approaches that have resulted in a lot of coding and being very slow. My idea was to give each group of kids a score and the lowest score is the group that is selected. However, this approach wound of iterating through several arrays several times which was really slow. Does anyone have any ideas on this puzzle? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This sounds remarkably like homework, which we can't help you with unless you've got a specific problem that you're stuck with. Thanks, Ash http://www.ashleysheridan.co.uk Oh, no, this is definitely not homework! :) Although it certainly seems like a homework question. This is a real world problem. I'm keeping track of which kids stay with which host families in the database. My initial approach was to start with kid 1 and see how many times the other kids have stayed with kid 1. The move on to kid 2, and so it. This gives me a score for pairs of kids. However, if say three kids are staying at a host family, what is the best way to determine which set of three kids have stayed together the least? Thanks! Floyd
Re: [PHP] Switch Statement
What is the output? On Sun, Sep 29, 2013 at 1:34 AM, Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: On 09/28/2013 10:53 PM, Aziz Saleh wrote: Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz snip Aziz - Used var_dump no further information Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
On Sun, 2013-09-29 at 12:30 -0400, Tim Dunphy wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docshttp://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) { // @codeCoverageIgnoreStart throw new S3_Exception('S3 does not support ' . $bucket . ' as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.'); // @codeCoverageIgnoreEnd } Has anyone played around enough with the AWS SDK to know what I'm doing wrong here? Would anyone else be able to hazard a guess? Thanks Tim Your code is failing because $bucket_name, I suspect, is null. Where do you define this variable before you use it in this bit of code: $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Switch Statement
Hello, I suggest you put default in that switch statement and var_dump the $_POST.That should be enough for a programmer to pin point what goes wrong. P:S **You might want to consider versioning your codes to go back into its history to see what has changed. Muhsin On 09/29/2013 04:33 AM, Ethan Rosenberg wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST);//post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- Extra details: OSS:Gentoo Linux profile:x86 Hardware:msi geforce 8600GT asus p5k-se location:/home/muhsin language(s):C/C++,PHP Typo:40WPM url:http://www.mzalendo.net url:http://www.zanbytes.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) { // @codeCoverageIgnoreStart throw new S3_Exception('S3 does not support ' . $bucket . ' as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.'); // @codeCoverageIgnoreEnd } Has anyone played around enough with the AWS SDK to know what I'm doing wrong here? Would anyone else be able to hazard a guess? Thanks Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 I hope that clarifies my situation a bit. Sorry for not providing that sooner! Thanks Tim On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh azizsa...@gmail.com wrote: Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.com wrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(10): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548' This is line 548 in the above referenced file: // Validate the S3 bucket name if (!$this-validate_bucketname_support($bucket)) {
Re: [PHP] delete S3 bucket with AWS PHP SDK
No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br / * input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 I hope that clarifies my situation a bit. Sorry for not providing that sooner! Thanks Tim On Sun, Sep 29, 2013 at 1:09 PM, Aziz Saleh azizsa...@gmail.com wrote: Hi Tim, Is the call working? Does it actually get deleted? This could just be an issue (which I see alot) where developers do not check for variables or preset them before usage, causing those notices to come up (pretty harmless most of the times). Aziz On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.comwrote: Hi All, I am attempting to delete an empty S3 bucket using the AWS PHP SDK. Here's how they describe the process in the docs: $result = $client-deleteBucket(array( // Bucket is required 'Bucket' = 'string', )); You can find the full entry here: AWS PHP SDK Delete Bucket Docs http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket Here's how I approached it in my code: $s3 = new AmazonS3(); $result = $s3-deleteObject(array( 'Bucket' = $bucket_name )); But when I run it, this is the error I get: 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(10):
Re: [PHP] Re: Sending PHP mail with Authentication
On Fri, Sep 27, 2013 at 12:06:30AM +0200, Maciek Sokolewicz wrote: [snip] I'm sure I'm going to annoy people with this, but I would advise to never use PEAR. It's the biggest load of extremely badly coded PHP you'll ever find. Creating an SMTP client (with the purpose of just sending mail) is very easy to do yourself (and also a good challenge if you're not yet very skilled with PHP). Alternatively, you can indeed use a package such as PHPMailer; it's not perfect, and quite bloated for what you want probably, but it works rather well. I have to agree on the code bloat. Unless your requirements are extraordinary (which the OP's are), the native PHP mail() function is generally quite adequate. Never thought about creating a PHP email client. Interesting idea... Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hi Aziz, Thank you for getting back to me! I appreciate you spotting that error. So I corrected that ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['bucket_name'];* // Create the S3 Object from the SDK $s3 = new AmazonS3(); * $result = $s3-deleteObject(array( 'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center script /body /html And this is the error I am currently getting: Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2 /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3 /var/www/awssdk/delete_bucket.php(72): CFRuntime-__call('deleteObject', Array) #4 /var/www/awssdk/delete_bucket.php(72): AmazonS3-deleteObject(Array) #5 {main} thrown in /var/www/awssdk/services/s3.class.php on line 548 Not sure if I'm getting closer here... but definitely appreciate any advice anyone may have. Thanks! Tim On Sun, Sep 29, 2013 at 5:04 PM, Aziz Saleh azizsa...@gmail.com wrote: No Problem, the issue is that you referring to the invalid post element $bucket_name as opposed to the correct on bucket_name. *$bucket_name = $_POST['$bucket_name'];* Should be *$bucket_name = $_POST['bucket_name'];* Aziz On Sun, Sep 29, 2013 at 3:28 PM, Tim Dunphy bluethu...@gmail.com wrote: Hey guys, Sorry about that i should have posted the full code to give you some idea of context. Anyway, here it is: ?php require_once 'sdk.class.php'; if (isset($_POST['submit'])) { * $bucket_name = $_POST['$bucket_name'];* // Create the S3 Object from the SDK *$s3 = new AmazonS3();* * $result = $s3-deleteObject(array(* *'Bucket' = $bucket_name ));* // The response comes back as a Simple XML Object // In this case we just want to know if everything was okay. // If not, report the message from the XML response. if ((int) $response-isOK()) { echo 'centerDeleted Bucket'; echo 'br /br /'; echo 'a href=listbuckets.phpList Buckets/a/center'; } else { echo (string) $response-body-Message; } //echo 'br /br /'; } ? body centerh3Delete S3 Bucket/h3 form name=delete_bucket method=post action=delete_bucket.php label for=bucket_nameBucket Name:/labelbr / * input type=text id=bucket_name name=bucket_name /br /br /* input type=submit name=submit value=Delete Bucket / /form/center So, as you can see I am taking the 'bucket_value' from $_POST and passing it into the call to S3. When the form comes up on the web I give it the name of one of my S3 buckets. The result is the following error: Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php on line 67 Warning: Missing argument 2 for AmazonS3::delete_object() in /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined variable: filename in /var/www/awssdk/services/s3.class.php on line 1581 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match() expects parameter 2 to be string, array given in /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support Array as a valid bucket name. Review Bucket Restrictions and Limitations in the S3 Developer Guide for more information.' in /var/www/awssdk/services/s3.class.php:548 Stack trace: #0 /var/www/awssdk/services/s3.class.php(1594): AmazonS3-authenticate(Array, Array) #1 [internal function]: AmazonS3-delete_object(Array) #2
Re: [PHP] How to capture uploaded file data
Thanks, Bastien On Sep 27, 2013, at 12:56 AM, Mariusz Drozdowski scheme...@wp.pl wrote: Hi all php experts, I would like to ask you all a question, I hope this is the right place to ask it. I'm writing a PHP extension now in c/c++. User uploads a file (could be POST or PUT method, but I can limit it to POST only). I need to capture the file data while being uploaded, without writing it to disk on the server. I need to process the data and (maybe, depending on a situation) send it somewhere else or save it to disk. Of course I know, that I can process the file after it has been uploaded (saved on disk on the server), but I would like to avoid it. I also need to do something opposite: I need to generate a file on the fly and send it to the user. All metadata of the generated file is known beforehand (e.g. size, name). I've been searching around for some time now and I could not find anything even close to the solution. Is there any example(s) or existing PHP extension that do(es) something like this (at least something simmilar) ? If you could give me any pointers that would be awesome. Thanks for your help The question I have is why? Should your upload fail for any reason you've got a half processed file that is non-recoverable. No do-overs. If you stick to the standard processes with out the extension, Upload Save somewhere (or leave in temp upload folder) Process Send result back to user Unlink file Generating the file and sending it to the user is also pretty standard Create your dataset Send appropriate headers Send data Close connection For this, there usually isn't a need to save the file. You may run into issues streaming the data to certain browsers. Also one of the main downsides to your upload is high load situations or large file situations (where file size exceeds php's upload limit). My personal preference is to save that file to disk so that if needed I can work with it later ( if say the server load is high) and email the results to the user. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
On Sep 28, 2013, at 6:00 PM, iccsi inu...@gmail.com wrote: Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option I had exactly this situation, large list with the autocomplete. I cached the list to a JS file and ran the autocomplete from that. It works well if the list is relatively static which mine was. It will be tougher if the list is dynamic, but you could send the data down after the initial page load. HTH Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks for the information and help, Yes, my data is pretty much static, Can you please give me some link for the solution? It is the solution I am looking for my current situation, Thanks a million for helping, Regards, Iccsi, Bastien wrote in message news:deb5dfe9-ec7f-4bc5-9e2e-acfb85039...@gmail.com... On Sep 28, 2013, at 6:00 PM, iccsi inu...@gmail.com wrote: Thanks for the message and help, because I use jQuery autocomplete which has performance issue for thousands records due to network load data. I want to load the data to local table to resolve performance issue, if it possible I can load to an array in the memory. Thanks again for helping, Regards, iccsi, Bastien wrote in message news:2fd3037d-f68d-47b3-ac4f-007d9559d...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 3:24 PM, iccsi inu...@gmail.com wrote: I need create a local table on the local machine. I would like to know is it possible to down on server side or client side or jQuery to do the work. Your information and help is great appreciated, regards, Iccsi If you're looking to create a SQl table then most but not all browsers can use SQLite locally for data storage ( it does require newer browsers). You haven't stated the goal for this so other options could include sending csv or json data down to the browser and using jquery, angular or some other JS framework to manipulate that data may also be an option I had exactly this situation, large list with the autocomplete. I cached the list to a JS file and ran the autocomplete from that. It works well if the list is relatively static which mine was. It will be tougher if the list is dynamic, but you could send the data down after the initial page load. HTH Bastien= -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switch Statement
Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz On Sat, Sep 28, 2013 at 10:33 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com wrote: Dear List - I have a working program. I made one change in a switch statement, and it does not work. I'm probably missing something fundamental. Here are some code SNIPPETS... [please note that all my debug statements are at the left margin] Setup... ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_**errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); require '/home/ethan/P/wk.inc'; //password file $db = Store; $cxn =mysqli_connect($host,$user,$**password,$db); if (!$cxn) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); }// no error if($_REQUEST['welcome_already_**seen']!= already_seen) show_welcome(); //end setup function show_welcome() //this is the input screen { snip echo input type='hidden' name='welcome_already_seen' value='already_seen'; echo input type='hidden' name='next_step' value='step20' /; snip } //end input screen //Switch statement echo 'before'; print_r($_POST); //post#1 switch ( $_POST['next_step'] ) { case 'step20': { pint_r($_POST); //post#2 echo 'step20'; if(!empty($_POST['Cust_Num'])) good(); if(empty($_POST['Cust_Num'])) bad(); break; } //end step20 snip } //end switch post#1 beforeArray ( [Cust_Num] = 123 [Fname] = [Lname] = [Street] = [City] = [state] = NY [Zip] = 10952 [PH1] = [PH2] = [PH3] = [Date] = [welcome_already_seen] = already_seen [next_step] = step20 ) Cust_Num state and Zip are as entered. The switch statement is never entered, since post#2 is never displayed, and neither good() or bad() functions are entered. TIA Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks, Bastien On Sep 28, 2013, at 8:24 PM, iccsi inu...@gmail.com wrote: Thanks for the information and help, Yes, my data is pretty much static, Can you please give me some link for the solution? It is the solution I am looking for my current situation, Thanks a million for helping, Regards, Iccsi, I don't have a link unfortunately. The system I did it for is proprietary. But I do recall it was a pretty switch in the JS to view the list from the static file. The JS file with the static data was just an array and the autocomplete looked at that as the data source Sorry Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] create a local temp table in local machine
Thanks for the message, Do you have any information how to create JS file and how to access from jQuery auto complete? Thanks again for helping, Regards, Iccsi, Bastien wrote in message news:57469e24-56e6-40c9-8176-64cd8444f...@gmail.com... Thanks, Bastien On Sep 28, 2013, at 8:24 PM, iccsi inu...@gmail.com wrote: Thanks for the information and help, Yes, my data is pretty much static, Can you please give me some link for the solution? It is the solution I am looking for my current situation, Thanks a million for helping, Regards, Iccsi, I don't have a link unfortunately. The system I did it for is proprietary. But I do recall it was a pretty switch in the JS to view the list from the static file. The JS file with the static data was just an array and the autocomplete looked at that as the data source Sorry Bastien -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Switch Statement
On 09/28/2013 11:59 PM, Jim Giner wrote: ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); Ethan,Ethan,Ethan - what is all this stuff you have at the top??? Do you know how any of this is supposed to be written? You can not put Constants in quotes - they become just plain strings then, not Constants with the predefined values you (and the functions) are expecting. For example, 'on' is NOT the same as the use of the word : on. And your error_reporting setting (which you are attempting to do TWICE) is actually causing your script to NOT show any errors, which is preventing you from seeing that your script dies at the misspelled print statement and never gets to the pair of if statements that should call your good and bad functions. Hate to do this to you, but you've been attempting to pick up PHP for two years now almost and from this latest post you appear to not have learned anything. And WHY would you EVER want to have a time limit of 2400 seconds??? And stop burying functions in the middle of your straight line code. It's ridiculous and makes reading your scripts a royal PIA. Jim - Thanks. Changed error_reporting to -1. No error messages. No change in output. Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switch Statement
On 09/28/2013 10:53 PM, Aziz Saleh wrote: Ethan, can you do a var_dump instead of print_r. It might be that next_step has spaces in it causing the switch to not match. Aziz snip Aziz - Used var_dump no further information Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Switch Statement
On 9/29/2013 1:29 AM, Ethan Rosenberg wrote: On 09/28/2013 11:59 PM, Jim Giner wrote: ?php session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); Ethan,Ethan,Ethan - what is all this stuff you have at the top??? Do you know how any of this is supposed to be written? You can not put Constants in quotes - they become just plain strings then, not Constants with the predefined values you (and the functions) are expecting. For example, 'on' is NOT the same as the use of the word : on. And your error_reporting setting (which you are attempting to do TWICE) is actually causing your script to NOT show any errors, which is preventing you from seeing that your script dies at the misspelled print statement and never gets to the pair of if statements that should call your good and bad functions. Hate to do this to you, but you've been attempting to pick up PHP for two years now almost and from this latest post you appear to not have learned anything. And WHY would you EVER want to have a time limit of 2400 seconds??? And stop burying functions in the middle of your straight line code. It's ridiculous and makes reading your scripts a royal PIA. Jim - Thanks. Changed error_reporting to -1. No error messages. No change in output. Ethan CORRECT ALL THE WRONG SHIT AND YOULL GET ERROR MESSAGES!!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Switch Statement
On 9/29/2013 1:38 AM, Jim Giner wrote: session_start(); session_name(STORE); set_time_limit(2400); ini_set('display_errors', 'on'); ini_set('display_startup_errors', 'on'); error_reporting(-2); ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('html_errors', 'On'); ini_set('log_errors', 'On'); This is what you should have in place of all of the above: session_start(); error_reporting(E_ALL | E_STRICT | E_NOTICE); ini_set('display_errors', '1'); set_time_limit(2);// if you use more than 2 secs you have a problem -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and curl
Unfortunately this isn't anything to do with PHP. I don't have any info on the app, what it's supposed to return or what the parameter passed should be. The PHP soap call is working, but the app isn't returning what you want or expect I guess. On Thu, Sep 26, 2013 at 8:36 AM, Alf Stockton a...@stockton.co.za wrote: Shawn, that was silly of me. I have now removed the echo but I still do not get the expected result from the server. var_dump of $result returns:- object(stdClass)#2 (1) { [GetSequenceNoResult]= object(stdClass)#3 (6) { [iServerNo]= int(0) [iClientNo]= int(0) [bNoLimitDownload]= bool(false) [dtStartDate]= string(19) 0001-01-01T00:00:00 [dtEndDate]= string(19) 0001-01-01T00:00:00 [dtServerTime]= string(19) 0001-01-01T00:00:00 } } whereas the expected result is to have each of those fields containing data. My code now looks like ?php $strTerminalname = CIS; $version = 1.2; $client = new SoapClient( http://192.168.0.10/CISWebService/Mediamanager.asmx?WSDL;http://192.168.0.10/CISWebService/Mediamanager.asmx?WSDL ); $result = $client-GetSequenceNo($strTerminalname); print_r($result); var_dump($result); ? On 25/09/13 17:23, Shawn McKenzie wrote: $result = $client-GetSequenceNo( CIS ); shouldn't be throwing that error. Maybe you are trying to do something with $result afterwards? Try var_dump($result); On Wed, Sep 25, 2013 at 10:12 AM, Alf Stockton a...@stockton.co.za wrote: On 25/09/13 16:52, Shawn McKenzie wrote: $client-GetSequenceNo( $parameters ); That unfortunately returns alf@alf-ThinkPad-T500:~/Development/PHP/DevIt$ php php-soap-web-service.php test.txt PHP Catchable fatal error: Object of class stdClass could not be converted to string in /home/alf/Development/PHP/DevIt/php-soap-web-service.php on line 7 No matter if I use $result = $client-GetSequenceNo( CIS ); or $result = $client-GetSequenceNo($strTerminalname); -- Regards, Alf Stockton www.stockton.co.za -- -- Thanks! -Shawn -- -- Regards, Alf Stockton www.stockton.co.za -- Thanks! -Shawn
Re: [PHP] PHP and curl
SOAP functions can be called as methods of the SoapClient object. Maybe: $client-GetSequenceNo( $parameters ); -Shawn On Wed, Sep 25, 2013 at 9:17 AM, Alf Stockton a...@stockton.co.za wrote: In an attempt to interface with a webservice on a Windows 7 server I have started writing the following:- [code] ?php $strTerminalname = CIS; $version = 1.2; $client = new SoapClient(http://192.168.0.** 10/CISWebService/Mediamanager.**asmx?WSDLhttp://192.168.0.10/CISWebService/Mediamanager.asmx?WSDL ); var_dump($client-__**getFunctions()); $result = $client-__doRequest(**GetSequenceNo,$**strTerminalname,$version, $one_way = 0); ? [/code] and I execute it via php php-soap-web-service.php test.txt on my Ubuntu 13.04 laptop using php version Zend Engine v2.4.0 in return I get array(20) { [0]= string(59) GetMediaListResponse GetMediaList(GetMediaList $parameters) [1]= string(68) GetMediaListAllResponse GetMediaListAll(**GetMediaListAll $parameters) [2]= string(59) GetSoundListResponse GetSoundList(GetSoundList $parameters) [3]= string(77) GetTerminalDataXMLResponse GetTerminalDataXML(**GetTerminalDataXML $parameters) [4]= string(59) GetRouterXmlResponse GetRouterXml(GetRouterXml $parameters) [5]= string(80) GetTerminalSoundXMLResponse GetTerminalSoundXML(**GetTerminalSoundXML $parameters) [6]= string(62) SetSequenceNoResponse SetSequenceNo(SetSequenceNo $parameters) [7]= string(50) GetConfigResponse GetConfig(GetConfig $parameters) [8]= string(62) GetSequenceNoResponse GetSequenceNo(GetSequenceNo $parameters) [9]= string(95) **UpdateClientMediaLogTimeRespon**se UpdateClientMediaLogTime(**UpdateClientMediaLogTime $parameters) [10]= string(59) GetMediaListResponse GetMediaList(GetMediaList $parameters) [11]= string(68) GetMediaListAllResponse GetMediaListAll(**GetMediaListAll $parameters) [12]= string(59) GetSoundListResponse GetSoundList(GetSoundList $parameters) [13]= string(77) GetTerminalDataXMLResponse GetTerminalDataXML(**GetTerminalDataXML $parameters) [14]= string(59) GetRouterXmlResponse GetRouterXml(GetRouterXml $parameters) [15]= string(80) GetTerminalSoundXMLResponse GetTerminalSoundXML(**GetTerminalSoundXML $parameters) [16]= string(62) SetSequenceNoResponse SetSequenceNo(SetSequenceNo $parameters) [17]= string(50) GetConfigResponse GetConfig(GetConfig $parameters) [18]= string(62) GetSequenceNoResponse GetSequenceNo(GetSequenceNo $parameters) [19]= string(95) **UpdateClientMediaLogTimeRespon**se UpdateClientMediaLogTime(**UpdateClientMediaLogTime $parameters) } now this is all great but my question is how do I call each of these functions with parameters. The call I immediately need to make is to GetSequenceNo() which requires a parameter of CIS in my current configuration. How do I do this ? Obviously $client-__doRequest is not the way to go. -- Regards, Alf Stockton www.stockton.co.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
I believe this was a bug, is only a warning that may be suppressed and may have been fixed in 5.2.0. Are you aware that PHP is at 5.5.4 and that 5.1.6 is over 7 years old? -Shawn On Wed, Sep 25, 2013 at 9:09 AM, Markus Falb markus.f...@fasel.at wrote: With RHEL/CentOS 5 php I get an SSL Error RHEL/CentOS 5 php is at 5.1.6 with security fixes backported. ?php $handle = fopen(https://maps.google.com;, r); $contents = stream_get_contents($handle); fclose($handle); ? will result in something like Warning: stream_get_contents(): SSL: fatal protocol error in bla.php on line 3 Some https pages do not raise this error, e.g. https://www.redhat.com is fine What is wrong? How to debug? How to resolve? How to mitigate? Thanks -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
Just as I thought: 5.2.0 Fixed bug #39039 SSL: fatal protocol error when fetching HTTPS from servers running Google web server). (Ilia) On Wed, Sep 25, 2013 at 10:03 AM, Shawn McKenzie shawn.mcken...@gmail.comwrote: I believe this was a bug, is only a warning that may be suppressed and may have been fixed in 5.2.0. Are you aware that PHP is at 5.5.4 and that 5.1.6 is over 7 years old? -Shawn On Wed, Sep 25, 2013 at 9:09 AM, Markus Falb markus.f...@fasel.at wrote: With RHEL/CentOS 5 php I get an SSL Error RHEL/CentOS 5 php is at 5.1.6 with security fixes backported. ?php $handle = fopen(https://maps.google.com;, r); $contents = stream_get_contents($handle); fclose($handle); ? will result in something like Warning: stream_get_contents(): SSL: fatal protocol error in bla.php on line 3 Some https pages do not raise this error, e.g. https://www.redhat.com is fine What is wrong? How to debug? How to resolve? How to mitigate? Thanks -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and curl
Keep on list. $result = $client-GetSequenceNo( CIS ); shouldn't be throwing that error. Maybe you are trying to do something with $result afterwards? Try var_dump($result); On Wed, Sep 25, 2013 at 10:12 AM, Alf Stockton a...@stockton.co.za wrote: On 25/09/13 16:52, Shawn McKenzie wrote: $client-GetSequenceNo( $parameters ); That unfortunately returns alf@alf-ThinkPad-T500:~/Development/PHP/DevIt$ php php-soap-web-service.php test.txt PHP Catchable fatal error: Object of class stdClass could not be converted to string in /home/alf/Development/PHP/DevIt/php-soap-web-service.php on line 7 No matter if I use $result = $client-GetSequenceNo( CIS ); or $result = $client-GetSequenceNo($strTerminalname); -- Regards, Alf Stockton www.stockton.co.za -- -- Thanks! -Shawn --
Re: [PHP] php fopen https error
On 25.9.2013 17:12, Shawn McKenzie wrote: Just as I thought: 5.2.0 Fixed bug #39039 SSL: fatal protocol error when fetching HTTPS from servers running Google web server). (Ilia) Thanks, but ... I am not sure how what I am supposed to do with this information. #39039 says it is a bug and it was fixed. How do I proceed to understand this bug? Where can I find the appropiate patch? Where is this bug discussed? I am sorry if I strain it (too much?) but the link to this bug does not give a solution to the problem and it does not help to understand the problem. I understand that somewhere in cvs there is the solution, but I can not see an obvious way to get it from the information in #39039 -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
On 25.9.2013 17:03, Shawn McKenzie wrote: I believe this was a bug, is only a warning that may be suppressed and may have been fixed in 5.2.0. Are you aware that PHP is at 5.5.4 and that 5.1.6 is over 7 years old? Please understand that some Distributions do the only backport security stuff thing, e.g. RedHat is supporting for 10 years nowadays. I do not complain, I just try to understand the issue. Thanks -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php fopen https error
I thought I covered that. The bug was fixed 7 years ago. Upgrade PHP, I doubt there is a patch. I understand that not all coders or distributions will have the latest version of PHP, but come on, how many thousands of bugs have been fixed in 7 years? You're going to run into more. Alternatively you could try and suppress it. From the bug it sounded like it was only the warning that was the bug, so the code should work. I can't test because my PHP on CentOS is only 3 years old (5.3.3). $contents = @stream_get_contents($handle); On Wed, Sep 25, 2013 at 11:20 AM, Markus Falb markus.f...@fasel.at wrote: On 25.9.2013 17:12, Shawn McKenzie wrote: Just as I thought: 5.2.0 Fixed bug #39039 SSL: fatal protocol error when fetching HTTPS from servers running Google web server). (Ilia) Thanks, but ... I am not sure how what I am supposed to do with this information. #39039 says it is a bug and it was fixed. How do I proceed to understand this bug? Where can I find the appropiate patch? Where is this bug discussed? I am sorry if I strain it (too much?) but the link to this bug does not give a solution to the problem and it does not help to understand the problem. I understand that somewhere in cvs there is the solution, but I can not see an obvious way to get it from the information in #39039 -- Markus Falb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https question
On Sep 25, 2013, at 1:55 PM, Tedd Sperling t...@sperling.com wrote: Hi gang: I have a client who had his entire site moved to another host -- no big problem. However, the old site had a https directory, where I had secure scripts to do credit-card transactions, but the new site doesn't have a https directory -- in fact it doesn't even have a http directory at all. So, what options do I have to do secure transactions? I remember someone saying that this could be done via a .htaccess file, but I don't have the code, nor am I positive this is the answer. What do you recommend? Thanks, tedd Did you setup the server (Apache / nginx) configuration? The entire site should be served under https if you're doing CC processing Best, –Josh Joshua Kehn | @joshkehn http://joshuakehn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https question
On Sep 25, 2013, at 1:58 PM, Joshua Kehn josh.k...@gmail.com wrote: On Sep 25, 2013, at 1:55 PM, Tedd Sperling t...@sperling.com wrote: Hi gang: I have a client who had his entire site moved to another host -- no big problem. However, the old site had a https directory, where I had secure scripts to do credit-card transactions, but the new site doesn't have a https directory -- in fact it doesn't even have a http directory at all. So, what options do I have to do secure transactions? I remember someone saying that this could be done via a .htaccess file, but I don't have the code, nor am I positive this is the answer. What do you recommend? Thanks, tedd Did you setup the server (Apache / nginx) configuration? The entire site should be served under https if you're doing CC processing Best, –Josh I understand that cc processing should be done via https. Normally, that means to me that I place my $ scripts in a https directory -- the problem is that I don't have one with this host. So, I am asking how does one do that with a https directory? Thanks, tedd ___ tedd sperling tedd.sperl...@gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https question
On Sep 25, 2013, at 2:24 PM, Tedd Sperling tedd.sperl...@gmail.com wrote: I understand that cc processing should be done via https. Normally, that means to me that I place my $ scripts in a https directory -- the problem is that I don't have one with this host. So, I am asking how does one do that with a https directory? Thanks, tedd ___ tedd sperling tedd.sperl...@gmail.com I'm saying the site should be served entirely under HTTPS. There shouldn't be separate https/http directories. Apache (or whatever your web server is) has a certificate installed on it and that vhost is configured to only respond to https requests. Typically this also means running a separate vhost on http that redirects to the https variant. Where is this new host? It should be a dedicated box (vps or other) due to how the certificates need to be issued (dedicated ip address). Best, –Josh Joshua Kehn | @joshkehn http://joshuakehn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] https question
On Wed, Sep 25, 2013 at 1:55 PM, Tedd Sperling t...@sperling.com wrote: Hi gang: I have a client who had his entire site moved to another host -- no big problem. However, the old site had a https directory, where I had secure scripts to do credit-card transactions, but the new site doesn't have a https directory -- in fact it doesn't even have a http directory at all. So, what options do I have to do secure transactions? I remember someone saying that this could be done via a .htaccess file, but I don't have the code, nor am I positive this is the answer. What do you recommend? Sounds like it may have been moved from a Plesk server to a non-Plesk server (or something using a similar path setup). If it's still Apache-based, yes, an .htaccess mod_rewrite directive should suffice. And, while it's out-of-scope for this list, an example, for posterity: # .htaccess - placed in the web root RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [QSA,R,L] -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending PHP mail with Authentication
Usually if I am using a framework I would use the SMTP library associated with it. If it doesn't have one, I use phpmailer, fast and easy to setup: http://phpmailer.worxware.com/index.php?pg=examplebsmtp Aziz On Wed, Sep 25, 2013 at 4:11 PM, dealTek deal...@gmail.com wrote: Hi All, Semi newbie email question... I have used the - mail() — Send mail php function to send email from a site. now it seems the server is blocking this for safety because I should be using authentication Q: mail() does not have authentication - correct? Q: So I read from the link below that maybe I should use - PEAR Mail package is this a good choice to send mail with authentication? ...any suggestions for basic sending email with authentication (setup info and links also) would be welcome http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm -- Thanks, Dave - DealTek deal...@gmail.com [db-3] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending PHP mail with Authentication
Another vote for PHPMailer, I have it working several years already (authenticating against a Zimbra and Outlook SMTP server) without problems. Greetings. On Wed, Sep 25, 2013 at 11:12 PM, Aziz Saleh azizsa...@gmail.com wrote: Usually if I am using a framework I would use the SMTP library associated with it. If it doesn't have one, I use phpmailer, fast and easy to setup: http://phpmailer.worxware.com/index.php?pg=examplebsmtp Aziz On Wed, Sep 25, 2013 at 4:11 PM, dealTek deal...@gmail.com wrote: Hi All, Semi newbie email question... I have used the - mail() — Send mail php function to send email from a site. now it seems the server is blocking this for safety because I should be using authentication Q: mail() does not have authentication - correct? Q: So I read from the link below that maybe I should use - PEAR Mail package is this a good choice to send mail with authentication? ...any suggestions for basic sending email with authentication (setup info and links also) would be welcome http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm -- Thanks, Dave - DealTek deal...@gmail.com [db-3] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending PHP mail with Authentication
On Wed, Sep 25, 2013 at 11:48 PM, Camilo Sperberg m...@unreal4u.com wrote: Another vote for PHPMailer, I have it working several years already (authenticating against a Zimbra and Outlook SMTP server) without problems. Greetings. On Wed, Sep 25, 2013 at 11:12 PM, Aziz Saleh azizsa...@gmail.com wrote: Usually if I am using a framework I would use the SMTP library associated with it. If it doesn't have one, I use phpmailer, fast and easy to setup: http://phpmailer.worxware.com/index.php?pg=examplebsmtp Aziz On Wed, Sep 25, 2013 at 4:11 PM, dealTek deal...@gmail.com wrote: Hi All, Semi newbie email question... I have used the - mail() — Send mail php function to send email from a site. now it seems the server is blocking this for safety because I should be using authentication Q: mail() does not have authentication - correct? Q: So I read from the link below that maybe I should use - PEAR Mail package is this a good choice to send mail with authentication? ...any suggestions for basic sending email with authentication (setup info and links also) would be welcome http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm -- Thanks, Dave - DealTek deal...@gmail.com [db-3] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Another vote for PHPMailer, I have it working several years already (authenticating against a Zimbra and Outlook SMTP server) without problems. Greetings. PD: Sorry for previous mail, it has been some time that I haven't used the webmail interface of gmail :) -- Mailed by: UnReAl4U - unreal4u ICQ #: 54472056 www1: http://www.chw.net/ www2: http://unreal4u.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHPDoc way to describe the magic getter/setters [SOLVED]
On Wed, Sep 25, 2013 at 4:31 PM, Daevid Vincent dae...@daevid.com wrote: Then I randomly stumbled upon this PHPDoc @ method tag and my whole world is brighter today than it has been for the past, oh let's say DECADE! Yes, @method and @property are very handy. Out of curiosity, since you're providing magic getters and setters, why not use __get and __set instead of __call with matching on get_xxx and set_xxx? This would allow using the simpler (and IMHO much more expressive and PHP-ish) forms $obj-foo = $obj-bar + 5; Peace, David
Re: [PHP] Apache
De: Ashley Sheridan a...@ashleysheridan.co.uk Para: m...@nikha.org; Domain nikha.org m...@nikha.org Cc: php-general@lists.php.net Enviadas: Quarta-feira, 25 de Setembro de 2013 2:22 Assunto: Re: [PHP] Apache Domain nikha.org m...@nikha.org wrote: Ashley Sheridan am Montag, 23. September 2013 - 21:35: No, no, no! That is not a good stand-in for fundamental security principles! This is a better method for ensuring an image is really an image: ?php if(isset($_FILES['file'])) { list($width, $height) = getimagesize($_FILES['file']['tmp_name']); if($width $height) { $source = imagecreatefromjpeg($_FILES['file']['tmp_name']); $dest = imagecreatetruecolor($width, $height); imagecopyresampled($dest, $source, 0, 0, 0, 0, $width, $height, $width, $height); imagejpeg($dest, basename($_FILES['file']['tmp_name'])); } else echo {$_FILES['file']['name']} is not a jpeg; } ? form enctype=multipart/form-data method=post input type=file name=file/ input type=submit name=submit value=submit/ /form Obviously it's only rough, and checks only for jpeg images, but that's easy to alter. I've just tested this with a regular jpeg, the same jpeg with PHP code concatenated onto the end (which still appears to be a valid image to viewing/editing software) and a pure PHP file with a .jpg extension. In the case of the first 2, a new jpeg is generated with the same image and without the code. The third example just echoes out an error. Dear Ashley, nice, but useless for this problem! The problem was to do with an image upload, so no, not useless. First, because users may upload other things than images! PDF's, audio files, videos etc! In an earlier email I detailed some methods for validating other types, such as DomDocument for HTML, XML, svg, etc, or fpdf for PDF. And on behalf images: GD you are using handles only jpeg, gif and png. There are about hunderd other image types on the way, At the moment those are the 3 raster formats you can use on the web, so those are the ones that pose an issue. If you're using anything else, it's not for web and doesn't need to be in a publicly accessible location. users can upload! How to detect them, if the extension is missleading? The extension comes from the user. Never trust the user, ever. And even if we succeed: As your script demonstrates very well, malicious code does not affect the rendering of the image. My script does effectively strip out malicious code though, even if it can't easily be seen. The hacker says: Hi, this is a nice picture, play it, and then, please do this--follows his code, that can be a desaster for the whole system. Social engineering is a whole different issue. Yes, your script seems to purge the image file, simply because GD does not copy the malware code. But why are you sure about that? You cannot see that code, OK, but may be it was executed in the plain GD environement? GD isn't a PHP parser, and PHP doesn't execute the image before GD touches it. Infact, Apache isn't even involved between GD and the image at that point, so it won't suffer from this bad config. What you are doing is dangerous, because you force the execution of things that should be never executed! Erm, no, the image isn't being executed. no no no forget it. After all we cannot exclude that users come in with malware. If you think it's fine that a user be able to upload malware, then you're going to have a very bad time. But we MUST exclude, it is executed on the web server. This is important too, but in this profession belt and braces is best I believe. That is the Apache chainsaw massacre as Steward whould say. And probably it can be avoided by purging the filenames (not the files!). Nevertheless, the standard configuration of the Apache servers is basically unacceptable. It must execute user requests and never ever user files! Period. Have nice days, Niklaus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks, Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Sorry for this late post but I'm amazed nobody consulted the doco. The php.net site has a whole section titled Handling File Uploads. Also check out finfo_open and finfo_file. If your are a windoze user you need a dll. If you want Apache to handle PUT requests you MUST tell it to run a script as it cannot write to web root. HTH Robert
RE: [PHP] Apache
On 23 Sep 2013, at 11:37, Domain nikha.org m...@nikha.org wrote: Tamara Temple am Montag, 23. September 2013 - 06:49: GoDaddy's default plesk-generated configuration for FastCGI-served PHP files only looked to see if the file contained .php somewhere on it's path - i.e. it would happily execute 'malicilous.php.txt' as php code, even something ridiculous like 'malware.phpnoreallyiwantthistorun'. Yes, looks stupid. But my service prodider wrote me this, I quote: ---QUOTE--- This is because Apache offers features like language negotiation based on extensions, too -- the final extension doesn't always just specify the handler; it can specify other things. Apache can automatically pick a German-language script from these, for example: file.php.de file.php.en Whether this is a good idea or not is debatable. It's possible to set things up in a different way (using FilesMatch instead of AddHandler) to avoid this particular problem, but that breaks other things, so there's no perfect solution. More generally, the real problem is that scripts are looking at the final extension of uploaded files to decide whether they're safe or not, which is dangerous. They're simply assuming that a .gif file can't run a PHP interpreter, for example... which is usually true, but certainly not always: some people run all their files through PHP. ---END QUOTE--- This is somewhat daft. Yes, Apache offers this feature, but you don't need to configure it to work will all extensions. I'd be curious to know what their issue is with using FilesMatch, since that provides a way to disable this behaviour. And, honestly, who would have a PHP file per language? I think it's perfectly reasonable to not allow that, because duplicating PHP code across many files is an incredible stupid way to support multiple languages. Some people run all their files through PHP - true, but that doesn't mean they should, or that you, as a responsible web host, should be endorsing it. The problem is the weak PHP upload mechanism! As workaround my service provider tries to block suspicious filenames, but the PHP developpers themself should work on this severe security problem. PHP developers should absolutely validate all content coming in from users in every possible way, but I would be highly dubious about trusting a host who gives the reason above for what I consider a lax and insecure Apache configuration. It's like saying they sliced your arm off with their chainsaw because it's made for cutting things, attempting to dodge all responsibility for having swung it in your direction! -Stuart -- It seems this is the standard apache configuration, but that's no excuse. Googling returned many results where this was described as a major security threat e.g. Beware of the default Apache 2 config for PHP http://ilia.ws/archives/226-Beware-of-the-default-Apache-2-config-for-PHP.ht ml On that site the solution was to change AddHandler to AddType. My service provider is going the FilesMatch route. Cheers Arno -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache
Ashley Sheridan am Montag, 23. September 2013 - 21:35: No, no, no! That is not a good stand-in for fundamental security principles! This is a better method for ensuring an image is really an image: ?php if(isset($_FILES['file'])) { list($width, $height) = getimagesize($_FILES['file']['tmp_name']); if($width $height) { $source = imagecreatefromjpeg($_FILES['file']['tmp_name']); $dest = imagecreatetruecolor($width, $height); imagecopyresampled($dest, $source, 0, 0, 0, 0, $width, $height, $width, $height); imagejpeg($dest, basename($_FILES['file']['tmp_name'])); } else echo {$_FILES['file']['name']} is not a jpeg; } ? form enctype=multipart/form-data method=post input type=file name=file/ input type=submit name=submit value=submit/ /form Obviously it's only rough, and checks only for jpeg images, but that's easy to alter. I've just tested this with a regular jpeg, the same jpeg with PHP code concatenated onto the end (which still appears to be a valid image to viewing/editing software) and a pure PHP file with a .jpg extension. In the case of the first 2, a new jpeg is generated with the same image and without the code. The third example just echoes out an error. Dear Ashley, nice, but useless for this problem! First, because users may upload other things than images! PDF's, audio files, videos etc! And on behalf images: GD you are using handles only jpeg, gif and png. There are about hunderd other image types on the way, users can upload! How to detect them, if the extension is missleading? And even if we succeed: As your script demonstrates very well, malicious code does not affect the rendering of the image. The hacker says: Hi, this is a nice picture, play it, and then, please do this--follows his code, that can be a desaster for the whole system. Yes, your script seems to purge the image file, simply because GD does not copy the malware code. But why are you sure about that? You cannot see that code, OK, but may be it was executed in the plain GD environement? What you are doing is dangerous, because you force the execution of things that should be never executed! no no no forget it. After all we cannot exclude that users come in with malware. But we MUST exclude, it is executed on the web server. That is the Apache chainsaw massacre as Steward whould say. And probably it can be avoided by purging the filenames (not the files!). Nevertheless, the standard configuration of the Apache servers is basically unacceptable. It must execute user requests and never ever user files! Period. Have nice days, Niklaus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache
Tamara Temple am Montag, 23. September 2013 - 22:38: On Sep 23, 2013, at 1:36 PM, Domain nikha.org m...@nikha.org wrote: Better solutions? One I have used, and continue to use in Apache environments, is place uploads only in a place where they cannot be executed by turning off such options and handlers in that directory. This is *in addition* to untainting files and names of uploaded files. Good idea. I will do this right now Niklaus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache
Domain nikha.org m...@nikha.org wrote: Ashley Sheridan am Montag, 23. September 2013 - 21:35: No, no, no! That is not a good stand-in for fundamental security principles! This is a better method for ensuring an image is really an image: ?php if(isset($_FILES['file'])) { list($width, $height) = getimagesize($_FILES['file']['tmp_name']); if($width $height) { $source = imagecreatefromjpeg($_FILES['file']['tmp_name']); $dest = imagecreatetruecolor($width, $height); imagecopyresampled($dest, $source, 0, 0, 0, 0, $width, $height, $width, $height); imagejpeg($dest, basename($_FILES['file']['tmp_name'])); } else echo {$_FILES['file']['name']} is not a jpeg; } ? form enctype=multipart/form-data method=post input type=file name=file/ input type=submit name=submit value=submit/ /form Obviously it's only rough, and checks only for jpeg images, but that's easy to alter. I've just tested this with a regular jpeg, the same jpeg with PHP code concatenated onto the end (which still appears to be a valid image to viewing/editing software) and a pure PHP file with a .jpg extension. In the case of the first 2, a new jpeg is generated with the same image and without the code. The third example just echoes out an error. Dear Ashley, nice, but useless for this problem! The problem was to do with an image upload, so no, not useless. First, because users may upload other things than images! PDF's, audio files, videos etc! In an earlier email I detailed some methods for validating other types, such as DomDocument for HTML, XML, svg, etc, or fpdf for PDF. And on behalf images: GD you are using handles only jpeg, gif and png. There are about hunderd other image types on the way, At the moment those are the 3 raster formats you can use on the web, so those are the ones that pose an issue. If you're using anything else, it's not for web and doesn't need to be in a publicly accessible location. users can upload! How to detect them, if the extension is missleading? The extension comes from the user. Never trust the user, ever. And even if we succeed: As your script demonstrates very well, malicious code does not affect the rendering of the image. My script does effectively strip out malicious code though, even if it can't easily be seen. The hacker says: Hi, this is a nice picture, play it, and then, please do this--follows his code, that can be a desaster for the whole system. Social engineering is a whole different issue. Yes, your script seems to purge the image file, simply because GD does not copy the malware code. But why are you sure about that? You cannot see that code, OK, but may be it was executed in the plain GD environement? GD isn't a PHP parser, and PHP doesn't execute the image before GD touches it. Infact, Apache isn't even involved between GD and the image at that point, so it won't suffer from this bad config. What you are doing is dangerous, because you force the execution of things that should be never executed! Erm, no, the image isn't being executed. no no no forget it. After all we cannot exclude that users come in with malware. If you think it's fine that a user be able to upload malware, then you're going to have a very bad time. But we MUST exclude, it is executed on the web server. This is important too, but in this profession belt and braces is best I believe. That is the Apache chainsaw massacre as Steward whould say. And probably it can be avoided by purging the filenames (not the files!). Nevertheless, the standard configuration of the Apache servers is basically unacceptable. It must execute user requests and never ever user files! Period. Have nice days, Niklaus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks, Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache
Ashley Sheridan am Dienstag, 24. September 2013 - 18:22: In an earlier email I detailed some methods for validating other types, such as DomDocument for HTML, XML, svg, etc, or fpdf for PDF. Fine, gratulations! And on behalf images: GD you are using handles only jpeg, gif and png. There are about hunderd other image types on the way, At the moment those are the 3 raster formats you can use on the web, so those are the ones that pose an issue. If you're using anything else, it's not for web and doesn't need to be in a publicly accessible location. Why that???!!! Why should users only upload files, that are used for web, and what does this mean, for web? Users may store personal files on your host, because they use your website as a cloud, as it is said today. Not for web, but for personal use on everey computer connected to the internet! That is absolutly legitime and the ONLY reason to offer file uploading I can imagine! I allow it only for authenticated, subscribed users. Nevertheless those trusted users may upload (unintenionally!) infected files. And again: No virus was ever written for web, but to harm computersystems, clients and servers. They are just distributed via web. Whould be great we could block them, and I appreciate your efforts to do this. But sorry, your script shows me, that this cannot be done this way! Perhaps, if you are right and GD processing really is harmless (I'm in doubt), we have a clean jpeg (or gif or png). And then? What's about the rest? Keep in mind, that PHP is a scripting framework to create websites, certainly not a tool for virus detection! And we have a big problem with the Apache web server, not because Apache serves possibly infected files, but because all kind of files are NOT served, but passed to the script interpreter! That's awfull enough, and opens a new exploit! The hacker says: Hi, this is a nice picture, play it, and then, please do this--follows his code, that can be a desaster for the whole system. Social engineering is a whole different issue. yes, what I tried to describe is criminal. Niklaus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache
Domain nikha.org m...@nikha.org wrote: Ashley Sheridan am Dienstag, 24. September 2013 - 18:22: In an earlier email I detailed some methods for validating other types, such as DomDocument for HTML, XML, svg, etc, or fpdf for PDF. Fine, gratulations! And on behalf images: GD you are using handles only jpeg, gif and png. There are about hunderd other image types on the way, At the moment those are the 3 raster formats you can use on the web, so those are the ones that pose an issue. If you're using anything else, it's not for web and doesn't need to be in a publicly accessible location. Why that???!!! Why should users only upload files, that are used for web, and what does this mean, for web? Users may store personal files on your host, because they use your website as a cloud, as it is said today. Not for web, Ok, imagine this scenario. A user uploads a .tif. this isn't a web format, so we treat it as a binary file, uploading to a non web accessible area of the site. Tell me again where the exploit is please. but for personal use on everey computer connected to the internet! That is absolutly legitime and the ONLY reason to offer file uploading I can imagine! I allow it only for authenticated, subscribed users. Nevertheless those trusted users may upload (unintenionally!) infected files. And again: No virus was ever written for web, Not exactly true, but beyond the scope of this discussion I think but to harm computersystems, clients and servers. They are just distributed via web. Whould be great we could block them, and I appreciate your efforts to do this. But sorry, your script shows me, that this cannot be done this way! Tell me how you would get a jpg past that example and I'll look into it, as I explained that was an example not a full solution. We don't tend to just write full code for people here. Perhaps, if you are right and GD processing really is harmless (I'm in doubt), Evidence? Either give some or stop saying GD isn't secure. The PHP community needs less hyperbole and more facts. we have a clean jpeg (or gif or png). And then? What's about the rest? Keep in mind, that PHP is a scripting framework to create websites, certainly not a tool for virus detection! And we have a big problem with the Apache web server, not because Apache serves possibly infected files, but because all kind of files are NOT served, but passed to the script interpreter! that's a bad Apache setup, which I'm not saying isn't a problem, but your original solution doesn't even cover validation. That's awfull enough, and opens a new exploit! The hacker says: Hi, this is a nice picture, play it, and then, please do this--follows his code, that can be a desaster for the whole system. Social engineering is a whole different issue. yes, what I tried to describe is criminal. Niklaus Thanks, Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize() fails on file and works on it's copy (same permissions, same directory)
regardless of you, saying they have same permissions I think they do not have the same permission try to use --reference for chmod to see if there is any differences try to copy the file keeping the whole permissions from original using sudo cp -rp and check. if this copy has the warning then your problem is from the permissions. Sincerely Negin Nickparsa On Tue, Aug 13, 2013 at 11:30 AM, Michał Kochanowicz mic...@michal.waw.plwrote: Hello I've got a file, which can't be checked with filesize(). I copy it (with permissions) and then I can filesize() the copy. This is same directory, permissions are same. I don't understand what's the difference. Can you help me? Original file: File: 'DSC_5196_fx-1553725666.JPG' Size: 1907383 Blocks: 3728 IO Block: 4096 regular file Device: 803h/2051d Inode: 5905591363 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 51/http) Gid: ( 51/http) Access: 2013-08-13 00:47:28.107477918 +0200 Modify: 2013-08-12 21:38:27.219913208 +0200 Change: 2013-08-13 00:47:08.931478654 +0200 Birth: - Copy: File: 'DSC_5196_fx-1553725666_X.JPG' Size: 1907383 Blocks: 3728 IO Block: 4096 regular file Device: 803h/2051d Inode: 144 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 51/http) Gid: ( 51/http) Access: 2013-08-13 00:45:48.0 +0200 Modify: 2013-08-12 21:38:27.0 +0200 Change: 2013-08-13 00:47:28.199477914 +0200 Birth: - The only difference is inode: (5905591363 - doesn't work vs 144 - does work). Test script: html body pre ? $f3 = '/home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/** DSC_5196_fx-1553725666.JPG'; $f4 = '/home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/** DSC_5196_fx-1553725666_X.JPG'; print $f3.: .filesize($f3).\n; print $f4.: .filesize($f4).\n; ? /pre /body /html Result: Warning: filesize(): stat failed for /home/services/httpd/html.** galeria.XXX/gallery/var/**albums/988_Rok-2013/333_** Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666.JPG in /home/services/httpd/html.**galeria.michal.waw.pl/** gallery3-3.0.x/test.phphttp://html.galeria.michal.waw.pl/gallery3-3.0.x/test.phpon line 13 /home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666.JPG: /home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666_X.JPG: 1907383 Regards Michał -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] filesize() fails on file and works on it's copy (same permissions, same directory)
if you have console access and the cli version of php works, what does echo filesize('/path/to/file'); tell (try running as root, then later as uid 51/webuser) this will eliminate permission doubts also you should use ?php as start tag instead of only ? cheers Carsten On 09/23/2013 10:06 AM, Negin Nickparsa wrote: regardless of you, saying they have same permissions I think they do not have the same permission try to use --reference for chmod to see if there is any differences try to copy the file keeping the whole permissions from original using sudo cp -rp and check. if this copy has the warning then your problem is from the permissions. Sincerely Negin Nickparsa On Tue, Aug 13, 2013 at 11:30 AM, Michał Kochanowicz mic...@michal.waw.plwrote: Hello I've got a file, which can't be checked with filesize(). I copy it (with permissions) and then I can filesize() the copy. This is same directory, permissions are same. I don't understand what's the difference. Can you help me? Original file: File: 'DSC_5196_fx-1553725666.JPG' Size: 1907383 Blocks: 3728 IO Block: 4096 regular file Device: 803h/2051d Inode: 5905591363 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 51/http) Gid: ( 51/http) Access: 2013-08-13 00:47:28.107477918 +0200 Modify: 2013-08-12 21:38:27.219913208 +0200 Change: 2013-08-13 00:47:08.931478654 +0200 Birth: - Copy: File: 'DSC_5196_fx-1553725666_X.JPG' Size: 1907383 Blocks: 3728 IO Block: 4096 regular file Device: 803h/2051d Inode: 144 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 51/http) Gid: ( 51/http) Access: 2013-08-13 00:45:48.0 +0200 Modify: 2013-08-12 21:38:27.0 +0200 Change: 2013-08-13 00:47:28.199477914 +0200 Birth: - The only difference is inode: (5905591363 - doesn't work vs 144 - does work). Test script: html body pre ? $f3 = '/home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/** DSC_5196_fx-1553725666.JPG'; $f4 = '/home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/** DSC_5196_fx-1553725666_X.JPG'; print $f3.: .filesize($f3).\n; print $f4.: .filesize($f4).\n; ? /pre /body /html Result: Warning: filesize(): stat failed for /home/services/httpd/html.** galeria.XXX/gallery/var/**albums/988_Rok-2013/333_** Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666.JPG in /home/services/httpd/html.**galeria.michal.waw.pl/** gallery3-3.0.x/test.phphttp://html.galeria.michal.waw.pl/gallery3-3.0.x/test.phpon line 13 /home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666.JPG: /home/services/httpd/html.**galeria.XXX/gallery/var/** albums/988_Rok-2013/333_**Rydzewo-04-06.08.2013/Sobota/**DSC_5196_fx-1553725666_X.JPG: 1907383 Regards Michał -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache
Tamara Temple am Montag, 23. September 2013 - 06:49: GoDaddy's default plesk-generated configuration for FastCGI-served PHP files only looked to see if the file contained .php somewhere on it's path - i.e. it would happily execute 'malicilous.php.txt' as php code, even something ridiculous like 'malware.phpnoreallyiwantthistorun'. Yes, looks stupid. But my service prodider wrote me this, I quote: ---QUOTE--- This is because Apache offers features like language negotiation based on extensions, too -- the final extension doesn't always just specify the handler; it can specify other things. Apache can automatically pick a German-language script from these, for example: file.php.de file.php.en Whether this is a good idea or not is debatable. It's possible to set things up in a different way (using FilesMatch instead of AddHandler) to avoid this particular problem, but that breaks other things, so there's no perfect solution. More generally, the real problem is that scripts are looking at the final extension of uploaded files to decide whether they're safe or not, which is dangerous. They're simply assuming that a .gif file can't run a PHP interpreter, for example... which is usually true, but certainly not always: some people run all their files through PHP. ---END QUOTE--- The problem is the weak PHP upload mechanism! As workaround my service provider tries to block suspicious filenames, but the PHP developpers themself should work on this severe security problem. Niklaus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php