php-general Digest 11 Jul 2008 16:37:10 -0000 Issue 5563
with distributed computing, and parallel computing were my favourites... and here I am programming for the Web... I guess it's distributed ;) Cheers, Rob. Todd and Rob: I understand. But, I'm more inclined to agree with Rob, I actually *DO* miss Algorithms and such. There are great minds out there and it's nice to be able to touch their genius. As for favorites, I liked digital filters, FFT, ray theory, computed surfaces, and all versions of AI. I even developed an algorithm to explain why migrating birds fly in a V formation. Some exciting Geek stuff. But here I sit programming the web and following a client's instructions I don't like that 'Buy Button' in blue, make it red. I feel like a 45 that's being used to swat flies. But hey, we all can't be born rich and most of us have to work for a living. At least I have work. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com ---End Message--- ---BeginMessage--- On Thu, 2008-07-10 at 16:29 -0500, Philip Thompson wrote: On Jul 10, 2008, at 3:35 PM, Omar Noppe wrote: Is there any reason to pick a black background en white fonts in your editor (for example writability)? I think a black background is much easier on the eyes And on the environment since the energy needed to sustain it is lower. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ---End Message--- ---BeginMessage--- On Thu, 2008-07-10 at 23:47 +0100, Colin Guthrie wrote: Dan Joseph wrote: You could probably save even more if you didn't use those unneeded returns also: ?php function aFunction($a,$b){if($a-$b0){while($a+$b0){if($c){$c++;}else{$c++;}}return 'negative';}else{return 'possitive';}} ? I think that's still perfectly legible. And that looks like a suspiciously unnecessary ? at the end there I wonder what I'll spend my 24 bits on that could be 1/1000 of a nipple in a grainy jpeg ;) You only want to sharpen that image if the rest is easy on the eyes too. Some things are better left grainy. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ---End Message--- ---BeginMessage--- On Jul 10, 2008, at 9:33 PM, Robert Cummings wrote: On Thu, 2008-07-10 at 16:29 -0500, Philip Thompson wrote: On Jul 10, 2008, at 3:35 PM, Omar Noppe wrote: Is there any reason to pick a black background en white fonts in your editor (for example writability)? I think a black background is much easier on the eyes And on the environment since the energy needed to sustain it is lower. Cheers, Rob. I find if I read stuff on a black background, I start seeing fuzzy streaks. I do use a light grey to edit in though. Be cool to see screenshots of people's set-ups. The light grey is the only alteration I've ever made from BBedit's default settings. -dg ---End Message--- ---BeginMessage--- On Thu, 2008-07-10 at 21:45 -0700, dg wrote: Be cool to see screenshots of people's set-ups. The light grey is the only alteration I've ever made from BBedit's default settings. http://www.interjinn.com/bleh/snapshot.20080711.png Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ---End Message--- ---BeginMessage--- On Jul 10, 2008, at 10:31 PM, Robert Cummings wrote: http://www.interjinn.com/bleh/snapshot.20080711.png very kewl. Maybe I'll ask Rich Siegel to pose shirtless for my BBedit background... I'm used to line numbers along the side, especially given all my errors, how do you zoom in on them without seeing them there? -dg ---End Message--- ---BeginMessage--- On Thu, 2008-07-10 at 22:49 -0700, dg wrote: On Jul 10, 2008, at 10:31 PM, Robert Cummings wrote: http://www.interjinn.com/bleh/snapshot.20080711.png very kewl. Maybe I'll ask Rich Siegel to pose shirtless for my BBedit background... I'm used to line numbers along the side, especially given all my errors, how do you zoom in on them without seeing them there? CTRL+K L, input line number Also the line the cursor is currently on is displayed at the top right corner. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ---End Message--- ---BeginMessage--- On Fri, 2008-07-11 at 07:55 +0800, paragasu wrote: what Robert suggest, is something exactly what the big-big photos gallery out there used to store their image. Distributing the image into many servers. But i am not very sure, how they store the image location information inside the database. But i like the idea of using imageUId to determine where to store the image. I think, storing image in a bucket with 100 images each can make the image more manageable.. thanks for that idea.. That physical location on the hard drive just needs to be a configuration variable for the site. As long as all the servers use the same physical path, then it's a no brainer. Cheers, Rob. -- http
Re: [PHP] include_path, permissions question
O/H dg ??: Hello, I'd greatly appreciate some help with some problems I'm hitting. I have a site set up on a dev server and it works fine. In transferring it to the clients server, it's getting all weird. When I first transferred created files, the owner was joe. And they worked fine. When I republished those files using fwrite, the owner changed to httpd. And includes and file_get_contents stopped working. I tried changing the owner, but couldn't. I changed include_path. I turned on error reporting and got: Warning: include(includes/common.php): failed to open stream: Inappropriate ioctl for device in /**/local/home/**/dev.**.net/alb**acl.php on line 5 Warning: file_get_contents(): SAFE MODE Restriction in effect. The script whose uid/gid is 398/398 is not allowed to access includes/lyrics_box_scripts.txt owned by uid/gid 191739/191739 in /**/local/home/**/dev.**.net/alb**acl.php on line 11 Thanks in advance for any assistance. -dg I think that a file stores a userid not the user so if for e.g. you have a user in your system that has id 1001 and you move this file preserving the rights to another computer the owner will become the user that has userid 1001 on the new system. In case there no user having the 1001 id then you will see just 1001 on the ownership when you ls. In case you don't preserve the rights of the then I think that the user that copies/moves the files takes the ownership of the files. Since I believe that you are a unix user man cp on you system to see what is the switch for preserving rights (it is -p on Linux if I recall correctly) an make sure the same user gets the same id (usually happens for apache. On the other hand you may just simply change the ownership recursively like chmod -R apache:apache dir which is much easier. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] apache/vhosts wuestion...
Hi.. I recognize that this might be off base!! I've got an apache/vhosts question that i'm grappling with. I've got a linux/apache system, and I'm trying to get multiple vhosts to work. If this is an appropriate place, I'll provide additional information on the issue. I've looked/researched via the 'net but my issues are still with me! Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date() and strtotime()
Hello everybody, I hope you all have a nice day, mines not that good 'cause i have encountered a strange problem. i have a few functions to work with dates. they are all very simple, a few lines of code. this first one does just gives you the monday of the current week: function get_monday($date) { $input_date = strtotime($date); $date_array = date_parse(date('r',$input_date)); $get_sunday = 7 - $date_array['relative']['weekday']; $day_label = date(D, d.m.y,mktime(0, 0, 0, date(m) , date(d)+$get_sunday, date(Y))); $new_day_label = strtotime($day_label); $monday = date(D, d.m.y,mktime(0, 0, 0, date(m,$new_day_label) , date(d,$new_day_label)-6, date(Y,$new_day_label))); return($monday); } now for testing purpose we say today is friday, 11.07.2008, this function returns correct Mon, 07.07.08. now the problems lies in the second function or more in strtotime. this second function just takes the inputed date and does some formating so it will fit into the mysql db or query. function get_mysql_date($date) { $old_date = strtotime($date); $new_date = date(Y-m-d,$old_date); return($new_date); } But now the strange thing happening is, this function outputs '2008-07-14' which is monday of the next week. now i think the problems lies somewhere in strtotime(), cause if i do this: $dateForTable = $date_class-get_monday($today); $dateTest =strtotime($dateForTable); $dateTest2 =date('r',$yousuck); it will also output 'Mon, 14 Jul 2008 07:07:08 +0200'. i think strtotime() takes just the first part 'Mon' and looks what date the next monday is. i'm realtivly new to php so any help solving this problem will be greatly appreciated. thanks alot to all. greetings from switzerland Fabian Frei [EMAIL PROTECTED] fon: 071-390 04 35 mobile: 079-733 45 27 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apache/vhosts wuestion...
bruce wrote: Hi.. I recognize that this might be off base!! I've got an apache/vhosts question that i'm grappling with. I've got a linux/apache system, and I'm trying to get multiple vhosts to work. If this is an appropriate place, I'll provide additional information on the issue. I've looked/researched via the 'net but my issues are still with me! Thanks You guess it, this isn't an appropriate place. What pieces are you struggling with as the Apache documentation works great for this stuff. I've got 6 hosts on a single server with no issues using the Apache documentation. Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date() and strtotime()
On Fri, Jul 11, 2008 at 9:03 AM, Fabian Frei [EMAIL PROTECTED] wrote: Hello everybody, I hope you all have a nice day, mines not that good 'cause i have encountered a strange problem. i have a few functions to work with dates. they are all very simple, a few lines of code. this first one does just gives you the monday of the current week: function get_monday($date) { $input_date = strtotime($date); $date_array = date_parse(date('r',$input_date)); $get_sunday = 7 - $date_array['relative']['weekday']; $day_label = date(D, d.m.y,mktime(0, 0, 0, date(m) , date(d)+$get_sunday, date(Y))); $new_day_label = strtotime($day_label); $monday = date(D, d.m.y,mktime(0, 0, 0, date(m,$new_day_label) , date(d,$new_day_label)-6, date(Y,$new_day_label))); return($monday); } now for testing purpose we say today is friday, 11.07.2008, this function returns correct Mon, 07.07.08. now the problems lies in the second function or more in strtotime. this second function just takes the inputed date and does some formating so it will fit into the mysql db or query. function get_mysql_date($date) { $old_date = strtotime($date); $new_date = date(Y-m-d,$old_date); return($new_date); } But now the strange thing happening is, this function outputs '2008-07-14' which is monday of the next week. now i think the problems lies somewhere in strtotime(), cause if i do this: $dateForTable = $date_class-get_monday($today); $dateTest =strtotime($dateForTable); $dateTest2 =date('r',$yousuck); it will also output 'Mon, 14 Jul 2008 07:07:08 +0200'. i think strtotime() takes just the first part 'Mon' and looks what date the next monday is. i'm realtivly new to php so any help solving this problem will be greatly appreciated. thanks alot to all. greetings from switzerland Fabian Frei [EMAIL PROTECTED] fon: 071-390 04 35 mobile: 079-733 45 27 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php function get_monday() { return date(Y-m-d, strtotime(last monday)); } function get_mysql_date() { return date(Y-m-d); } would seem to be much simpler -- Bastien Cat, the other other white meat
Re: [PHP] apache/vhosts wuestion...
On Fri, Jul 11, 2008 at 8:55 AM, bruce [EMAIL PROTECTED] wrote: Hi.. I recognize that this might be off base!! I've got an apache/vhosts question that i'm grappling with. I've got a linux/apache system, and I'm trying to get multiple vhosts to work. If this is an appropriate place, I'll provide additional information on the issue. Check the archives and mailing lists at http://httpd.apache.org/. To give you a pointer, though, you'll need to either do an include into the httpd.conf file or modify that file itself to include a NameVirtualHost setting and VirtualHost container. It works fine. I've worked with servers that have had hundreds of virtual hosts. The Apache folks are friendly, and don't bite *that* hard -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] OT - RE: [PHP] scalable web gallery
At 12:31 AM -0400 7/11/08, Robert Cummings wrote: On Thu, 2008-07-10 at 12:06 -0500, Boyd, Todd M. wrote: tedd also sent me an e-mail that sparked a memory of mine... the b-trees, regardless of their efficiency, still assign each dir/file INode an identifying number. This number, obviously, can only get so large in the context of one b-tree object (i.e., a directory). In spite of this mental exercise, I do *NOT* miss my Data Structures Algorithms class. :) Really? That along with distributed computing, and parallel computing were my favourites... and here I am programming for the Web... I guess it's distributed ;) Cheers, Rob. Todd and Rob: I understand. But, I'm more inclined to agree with Rob, I actually *DO* miss Algorithms and such. There are great minds out there and it's nice to be able to touch their genius. As for favorites, I liked digital filters, FFT, ray theory, computed surfaces, and all versions of AI. I even developed an algorithm to explain why migrating birds fly in a V formation. Some exciting Geek stuff. But here I sit programming the web and following a client's instructions I don't like that 'Buy Button' in blue, make it red. I feel like a 45 that's being used to swat flies. But hey, we all can't be born rich and most of us have to work for a living. At least I have work. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scalable web gallery
At 10:41 AM -0400 7/10/08, Daniel Brown wrote: Still, I'd create 16 subdirectories under the images directory: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f. Then name the file as an MD5 hash of the image uploaded, and place it in the directory matching the first character of the new file name. Why not use a hash table based upon the name of the file and distribute files that way? You don't even need a directory until you actually need one -- then create one 'on-the-fly' and drop the file into it. As such, it's easy to find the file again by simply hashing it's name -- you don't even need to store a path for the file, only the name of the file. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question regarding OO
?php /* I have a question here regarding object orientation in PHP and any other language. Let's start with some hypothetical code: */ // --- 1st CLASS class ParkingLot { var size; // size in sq feet var max_number_of_cars; // how many cars there is space for function __construct($size, $max_cars) { $this-size = $size; $this-max_number_of_cars = $max_cars; } }; cpark = new ParkingLot(5, 17); // --- 2nd CLASS class ParkingSpace extends ParkingLot { var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars ) var occupied_by; // ID of the car on the parking space var st_time; // Unix time stamp set when the car parks function __construct($car, $id) { $this-st_time = time(); $this-occupied_by = $car; $this-ps_ID = $id; } }; /* OK, so i got a parking lot class and its subclass parking space. Now the question: I want a list of occupied parking spaces, where do I put that? One might put it into the ParkingLot Class, but wouldn't that be a recursion (a child instance in the parent class)? */ $occ_parking_spaces = array(); $occ_parking_spaces[] = new ParkingSpace('Joes Car', 8); $occ_parking_spaces[] = new ParkingSpace('My Prshe', 17); $occ_parking_spaces[] = new ParkingSpace('Toms Caddy', 4); /* After a while a method to print all occupied spaces is necessary. Correct me if I'm wrong, but I usually add it to the ParkingLot class. class ParkingLot { // previous code ... var $occ_parking_spaces = array(); function print_occ_spaces() { var_dump($this-occ_parking_spaces) } }; What bothers me here is that I'm actually having a list of child classes in the parent class, is there a better/correct way to do this? I hope I made myself clear. Greetz, Yeti */ ?
Re: [PHP] Question regarding OO
On Fri, 2008-07-11 at 18:03 +0200, Yeti wrote: ?php /* I have a question here regarding object orientation in PHP and any other language. Let's start with some hypothetical code: */ // --- 1st CLASS class ParkingLot { var size; // size in sq feet var max_number_of_cars; // how many cars there is space for function __construct($size, $max_cars) { $this-size = $size; $this-max_number_of_cars = $max_cars; } }; cpark = new ParkingLot(5, 17); // --- 2nd CLASS class ParkingSpace extends ParkingLot { Here's the point of your comfusion. ParkingSpace is not really a ParkingLot is it? I mean you could say a parking lot having a single parking space qualifies, but not really. I see you problem being similar to apples versus apple tree. You wouldn't do the following (would you?): ?php class AppleTree { } class Apple extends AppleTree { } ? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Relocating and POSTing
At 7:20 PM +0100 7/10/08, Alex Chamberlain wrote: I need to send a header('Location:') and send some data along with it - how would I do this?? Thanks, Alex Alext: Or you could just: ob_clean(); include('theNextScript.php'); exit(); The variable in your parent script will be passed to the next script. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question regarding OO
Object-oriented programming, with it's class and object approach, is meant to model real life more closely than functional programming. In, a parking space is physically inside a parking lot, but a parking space is not a subclass of a parking lot. It's not a variation or mini parking lot. It's an entirely different entity. A parking lot consists of parking spaces, but a parking space is its own thing. In other words, don't extend ParkingSpace from ParkingLot. They should be separate classes entirely. As for the recursion... no, that won't be a problem. Each ParkingSpace you're instantiating is a separate instance, and won't be related to the parent ParkingLot in anyway way internally. ?php class ParkingSpace { var $size; var $num_spaces; var $spaces = array(); } class ParkingSpace { var $ps_ID; var $occupied_by; var $st_time; } ? In the above class definition, simply populate the $spaces array with instances of the ParkingSpace class. ~Ted On 11-Jul-08, at 9:03 AM, Yeti wrote: ?php /* I have a question here regarding object orientation in PHP and any other language. Let's start with some hypothetical code: */ // --- 1st CLASS class ParkingLot { var size; // size in sq feet var max_number_of_cars; // how many cars there is space for function __construct($size, $max_cars) { $this-size = $size; $this-max_number_of_cars = $max_cars; } }; cpark = new ParkingLot(5, 17); // --- 2nd CLASS class ParkingSpace extends ParkingLot { var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars ) var occupied_by; // ID of the car on the parking space var st_time; // Unix time stamp set when the car parks function __construct($car, $id) { $this-st_time = time(); $this-occupied_by = $car; $this-ps_ID = $id; } }; /* OK, so i got a parking lot class and its subclass parking space. Now the question: I want a list of occupied parking spaces, where do I put that? One might put it into the ParkingLot Class, but wouldn't that be a recursion (a child instance in the parent class)? */ $occ_parking_spaces = array(); $occ_parking_spaces[] = new ParkingSpace('Joes Car', 8); $occ_parking_spaces[] = new ParkingSpace('My Prshe', 17); $occ_parking_spaces[] = new ParkingSpace('Toms Caddy', 4); /* After a while a method to print all occupied spaces is necessary. Correct me if I'm wrong, but I usually add it to the ParkingLot class. class ParkingLot { // previous code ... var $occ_parking_spaces = array(); function print_occ_spaces() { var_dump($this-occ_parking_spaces) } }; What bothers me here is that I'm actually having a list of child classes in the parent class, is there a better/correct way to do this? I hope I made myself clear. Greetz, Yeti */ ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question regarding OO
Corrected code example: (too early in the morning to think) ?php class ParkingLot { var $size; var $num_spaces; var $spaces = array(); } class ParkingSpace { var $ps_ID; var $occupied_by; var $st_time; } ? In the above class definition, simply populate the $spaces array with instances of the ParkingSpace class. ~Ted -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Relocating and POSTing
Ahh, but they are on different webservers At the moment, I am just using a query string. How long is the limit of the query string?? Alex -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: 11 July 2008 17:12 To: Alex Chamberlain; PHP General list Subject: Re: [PHP] Relocating and POSTing At 7:20 PM +0100 7/10/08, Alex Chamberlain wrote: I need to send a header('Location:') and send some data along with it - how would I do this?? Thanks, Alex Alext: Or you could just: ob_clean(); include('theNextScript.php'); exit(); The variable in your parent script will be passed to the next script. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: 11/07/2008 06:47 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: 11/07/2008 06:47 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: 11/07/2008 06:47 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Relocating and POSTing
On Fri, Jul 11, 2008 at 12:26 PM, Alex Chamberlain [EMAIL PROTECTED] wrote: Ahh, but they are on different webservers That's why I mentioned cURL at the very beginning, if it had to be done as a POST request. At the moment, I am just using a query string. How long is the limit of the query string?? There is no official limit in the protocol, but you may want to check out Section 3.2.1 of RFC 2068 for more on that. The limits are in what the client is capable of sending, and what the server is capable of receiving. A quick S of TFW should give you the information you need regarding PHP and the remote server's configuration. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What font/size do you use for programming?
On Thu, Jul 10, 2008 at 5:29 PM, Philip Thompson [EMAIL PROTECTED] wrote: On Jul 10, 2008, at 3:35 PM, Omar Noppe wrote: Is there any reason to pick a black background en white fonts in your editor (for example writability)? I think a black background is much easier on the eyes I use a big font on a black background because it doesn't strain my eyes as much. I started out with Monaco 9pt (or bitstream vera sans mono 9pt on linux) on white. Slowly though I kept getting more frequent headaches. Now I use black with big fonts and I'm fine. I have really good vision and all that, but just hours of coding will get to me. As a side bonus, using a bigger font also helps me adhere to wrapping at the 80 character margin too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question regarding OO
On Fri, Jul 11, 2008 at 12:03 PM, Yeti [EMAIL PROTECTED] wrote: ?php /* I have a question here regarding object orientation in PHP and any other language. Let's start with some hypothetical code: */ // --- 1st CLASS class ParkingLot { var size; // size in sq feet var max_number_of_cars; // how many cars there is space for function __construct($size, $max_cars) { $this-size = $size; $this-max_number_of_cars = $max_cars; } }; cpark = new ParkingLot(5, 17); // --- 2nd CLASS class ParkingSpace extends ParkingLot { var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars ) var occupied_by; // ID of the car on the parking space var st_time; // Unix time stamp set when the car parks function __construct($car, $id) { $this-st_time = time(); $this-occupied_by = $car; $this-ps_ID = $id; } }; /* OK, so i got a parking lot class and its subclass parking space. Now the question: I want a list of occupied parking spaces, where do I put that? One might put it into the ParkingLot Class, but wouldn't that be a recursion (a child instance in the parent class)? */ $occ_parking_spaces = array(); $occ_parking_spaces[] = new ParkingSpace('Joes Car', 8); $occ_parking_spaces[] = new ParkingSpace('My Prshe', 17); $occ_parking_spaces[] = new ParkingSpace('Toms Caddy', 4); /* After a while a method to print all occupied spaces is necessary. Correct me if I'm wrong, but I usually add it to the ParkingLot class. class ParkingLot { // previous code ... var $occ_parking_spaces = array(); function print_occ_spaces() { var_dump($this-occ_parking_spaces) } }; What bothers me here is that I'm actually having a list of child classes in the parent class, is there a better/correct way to do this? I hope I made myself clear. Greetz, Yeti */ ? Listen to what everyone else has said so far. Look up IS-A versus HAS-A. Favor composition over inheritance. You want your parking lot to have spaces, but spaces don't have to be in a parking lot. http://www.javacamp.org/moreclasses/oop/oop5.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Relocating and POSTing
At 12:37 PM -0400 7/11/08, Daniel Brown wrote: On Fri, Jul 11, 2008 at 12:26 PM, Alex Chamberlain [EMAIL PROTECTED] wrote: Ahh, but they are on different webservers That's why I mentioned cURL at the very beginning, if it had to be done as a POST request. At the moment, I am just using a query string. How long is the limit of the query string?? There is no official limit in the protocol, but you may want to check out Section 3.2.1 of RFC 2068 for more on that. The limits are in what the client is capable of sending, and what the server is capable of receiving. A quick S of TFW should give you the information you need regarding PHP and the remote server's configuration. Incidentally, I did some minor testing on this a few years ago and found the lengths vary greatly between servers. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Relocating and POSTing
On Fri, Jul 11, 2008 at 1:07 PM, tedd [EMAIL PROTECTED] wrote: Incidentally, I did some minor testing on this a few years ago and found the lengths vary greatly between servers. and browsers. If I remember correctly, on Winblows alone, Opera is capable of somewhere in the 4,500 character range, while Internet Exploder is only capable of 2048+slack (2083 bytes). And pre-1.0 HTTP days, it was common for many servers not to accept more than 255 characters on GET. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] Question regarding OO
-- Forwarded message -- From: Yeti [EMAIL PROTECTED] Date: Fri, Jul 11, 2008 at 2:08 PM Subject: Re: [PHP] Question regarding OO To: Eric Butera [EMAIL PROTECTED] I understand my error in thinking now. Apple can't extend Tree. Oak, Evergreen or Willow extend Tree. I thank you all for helping me to understand. On 7/11/08, Eric Butera [EMAIL PROTECTED] wrote: On Fri, Jul 11, 2008 at 12:03 PM, Yeti [EMAIL PROTECTED] wrote: ?php /* I have a question here regarding object orientation in PHP and any other language. Let's start with some hypothetical code: */ // --- 1st CLASS class ParkingLot { var size; // size in sq feet var max_number_of_cars; // how many cars there is space for function __construct($size, $max_cars) { $this-size = $size; $this-max_number_of_cars = $max_cars; } }; cpark = new ParkingLot(5, 17); // --- 2nd CLASS class ParkingSpace extends ParkingLot { var ps_ID; // ID of the parking space ( 1 .. max_number_of_cars ) var occupied_by; // ID of the car on the parking space var st_time; // Unix time stamp set when the car parks function __construct($car, $id) { $this-st_time = time(); $this-occupied_by = $car; $this-ps_ID = $id; } }; /* OK, so i got a parking lot class and its subclass parking space. Now the question: I want a list of occupied parking spaces, where do I put that? One might put it into the ParkingLot Class, but wouldn't that be a recursion (a child instance in the parent class)? */ $occ_parking_spaces = array(); $occ_parking_spaces[] = new ParkingSpace('Joes Car', 8); $occ_parking_spaces[] = new ParkingSpace('My Prshe', 17); $occ_parking_spaces[] = new ParkingSpace('Toms Caddy', 4); /* After a while a method to print all occupied spaces is necessary. Correct me if I'm wrong, but I usually add it to the ParkingLot class. class ParkingLot { // previous code ... var $occ_parking_spaces = array(); function print_occ_spaces() { var_dump($this-occ_parking_spaces) } }; What bothers me here is that I'm actually having a list of child classes in the parent class, is there a better/correct way to do this? I hope I made myself clear. Greetz, Yeti */ ? Listen to what everyone else has said so far. Look up IS-A versus HAS-A. Favor composition over inheritance. You want your parking lot to have spaces, but spaces don't have to be in a parking lot. http://www.javacamp.org/moreclasses/oop/oop5.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding OO
[snip] I understand my error in thinking now. Apple can't extend Tree. Oak, Evergreen or Willow extend Tree. I thank you all for helping me to understand. [/snip] By jove, I think he's got it! Parking space could be a member variable of parking lot, that would make sense. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] cookie encoding/decoding
Anyone have any ideas on this at all? -Original Message- From: Jeff Demel [mailto:[EMAIL PROTECTED] Sent: Thursday, July 10, 2008 10:50 AM To: php-general@lists.php.net Subject: [PHP] cookie encoding/decoding I have a situation where a cookie is being set elsewhere on a site by ASP.NET, and I want to read it in my PHP. However, when getting a cookie in PHP, it does an automatic urldecode (or some kind of decoding). Since the cookie is entered in its pure form, with no encoding, on the ASP.NET side, PHP is actually converting/decoding correct characters that don't need decoding. So, for example a plus sign would become a blank space. This, of course, means I'm getting incorrect info from the cookie. Is there a way to turn off this PHP feature? Perhaps a flag in the .ini file? -Jeff -- 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] Relocating and POSTing
At 1:19 PM -0400 7/11/08, Daniel Brown wrote: On Fri, Jul 11, 2008 at 1:07 PM, tedd [EMAIL PROTECTED] wrote: Incidentally, I did some minor testing on this a few years ago and found the lengths vary greatly between servers. and browsers. If I remember correctly, on Winblows alone, Opera is capable of somewhere in the 4,500 character range, while Internet Exploder is only capable of 2048+slack (2083 bytes). And pre-1.0 HTTP days, it was common for many servers not to accept more than 255 characters on GET. Yes, those are generally the numbers I found as well. In my more current test, I had one test that exceeded 5000 characters, but most were in the 2000 character range. So what it boils down to is, you can send a respectable number of characters via a GET, but if it's going to be in the 1K range, it's best to test (it's best to test anyway). Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] OT - RE: [PHP] scalable web gallery
-Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, July 10, 2008 11:31 PM To: Boyd, Todd M. Cc: php-general@lists.php.net Subject: RE: [PHP] OT - RE: [PHP] scalable web gallery On Thu, 2008-07-10 at 12:06 -0500, Boyd, Todd M. wrote: -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, July 10, 2008 11:24 AM To: Boyd, Todd M. Cc: Daniel Brown; php-general@lists.php.net Subject: Re: [PHP] OT - RE: [PHP] scalable web gallery On Thu, 2008-07-10 at 10:18 -0500, Boyd, Todd M. wrote: -Original Message- From: Daniel Brown [mailto:[EMAIL PROTECTED] Sent: Thursday, July 10, 2008 9:42 AM To: paragasu Cc: php-general@lists.php.net Subject: Re: [PHP] scalable web gallery ---8--- snip And for the record, in the olden days, there was a limit of about 2048 files per directory, back when no one thought there would ever be a need for nearly that many files. Then, with improved filesystems, the limit was rumored to be another magic number: 65535. That depended on the operating system, filesystem, and the kernel. I think (but don't quote me on this) that BeOS had the 65535 limit. Now, on an ext3 filesystem (we're not counting ReiserFS because (1) I was never a fan, and (2) he might kill me if I say something bad! 8^O) you're okay with hundreds of thousands of files per directory. ls'ing will be a bit of a pain in the ass, and if you're in Bash, you probably don't want to double-TAB the directory, but all in all, you'll be okay. Still, I'd create 16 subdirectories under the images directory: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f. Then name the file as an MD5 hash of the image uploaded, and place it in the directory matching the first character of the new file name. Aren't directory structures in Windows (2.x) and even DOS (4.x) built with B-Trees? I wouldn't figure there would be any kind of limit--excepting memory, of course--to how many files or subdirectories can be linked to a single node. Been a while since I've played with those underlying data structures we all take for granted, though, so maybe I'm way off base. They may all be B-Trees but the storage mechanism often differs between one filesystem and another. FAT16 and FAT32 both suffered from limitations on the number of files that could exist in a directory. Actually, I may be wrong about FAT32, but I do know for certain it had massive slowdown if it hit some magic number. tedd also sent me an e-mail that sparked a memory of mine... the b-trees, regardless of their efficiency, still assign each dir/file INode an identifying number. This number, obviously, can only get so large in the context of one b-tree object (i.e., a directory). In spite of this mental exercise, I do *NOT* miss my Data Structures Algorithms class. :) Really? That along with distributed computing, and parallel computing were my favourites... and here I am programming for the Web... I guess it's distributed ;) Don't get me wrong--I enjoyed the class very much. I had never seen sorting algorithms outside of the Bubble Sort, so learning Pivot, Shell, etc. was quite a blast. Self-balancing data trees and such were a real eye-opener as to the power of data structures, too. I'm just... glad I don't have to learn it all over again in a classroom environment. :) Haven't taken a distributed computing class just yet, but I've still got a bit until I graduate, and these elective credits are burning a hole in my pocket... Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Question regarding OO
-Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2008 1:51 PM To: Eric Butera; php php Subject: RE: [PHP] Question regarding OO [snip] I understand my error in thinking now. Apple can't extend Tree. Oak, Evergreen or Willow extend Tree. I thank you all for helping me to understand. [/snip] By jove, I think he's got it! Parking space could be a member variable of parking lot, that would make sense. One thing at a time, Jay... one thing at a time. ;) Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] OT - RE: [PHP] scalable web gallery
At 5:01 PM -0500 7/11/08, Boyd, Todd M. wrote: Don't get me wrong--I enjoyed the class very much. I had never seen sorting algorithms outside of the Bubble Sort, so learning Pivot, Shell, etc. was quite a blast. I used to hang with a bunch of Macintosh software developers. It was brought to discussion about which sort would be best and everyone submitted theirs. I won the competition with a Quicksort. They all wow'ed about how fast it was, but I told them I didn't want to improve on it any more because I was afraid if I did, it would go back in time. Self-balancing data trees and such were a real eye-opener as to the power of data structures, too. Self-balancing data trees were one of my favorites -- I even wrote a Macintosh application showing the operation of a splay binary-tree, as seen here (for those who have Macs): http://sperling.com/freeware.php A splay is based upon how often a search is preformed for a specific item. The more often the search, the closer the item appears toward the top of the tree -- thus less time to find it. The up and downside of the splay is that the tree is balanced each time a search is preformed -- requiring more time to balance it, but less time to find the item -- kind of a trade-off that works for some situations. I am sure that many search engines use a similar approach. I'm just... glad I don't have to learn it all over again in a classroom environment. :) Not me, I would love to be in a classroom again. You would think that three degrees would burn me out, but just the opposite, I can't get enough of this stuff -- I'm constantly reading and programming everything I can lay my hands on. The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT - RE: [PHP] scalable web gallery
tedd wrote: The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective. Cheers, tedd This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT - RE: [PHP] scalable web gallery
Jim Lucas wrote: tedd wrote: The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective. Cheers, tedd This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases. ...and he even calls the IOS an ISO sometimes ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT - RE: [PHP] scalable web gallery
Shawn McKenzie wrote: Jim Lucas wrote: tedd wrote: The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective. Cheers, tedd This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases. ...and he even calls the IOS an ISO sometimes ;-) good catch, lazy/tired finger TGIF -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scalable web gallery
Why not use a hash table based upon the name of the file and distribute files that way? sorry tedd, i don't really get it. but i am interested to know more about the hash table concept. can you explain a little bit more.. thanks.. On 7/11/08, tedd [EMAIL PROTECTED] wrote: At 10:41 AM -0400 7/10/08, Daniel Brown wrote: Still, I'd create 16 subdirectories under the images directory: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f. Then name the file as an MD5 hash of the image uploaded, and place it in the directory matching the first character of the new file name. Why not use a hash table based upon the name of the file and distribute files that way? You don't even need a directory until you actually need one -- then create one 'on-the-fly' and drop the file into it. As such, it's easy to find the file again by simply hashing it's name -- you don't even need to store a path for the file, only the name of the file. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Most popular per month
Hey! The client has a set of 50 images that keep rotating everyday and when a user clicks one of those images he is taken to that images site, in the background (database) i maintain a counter _for the day_ and then display the top ten images everyday in this format: 1-10 before the next days counter starts this data is stored in a table which has a simple structure like this img_id1 int,img_id2 int (etc till img_id10) Now the client wants a little extra functionality, and with me sucking at maths I need some help please, basically he now wants to have a chart with all the 50 images there and showing _via percentages_ instead of the present 1-10 display which ones are the most popular till date. example: 1. image name: (percentage here) 2. image name: (percentage here) 3. image name: (percentage here) etc any ideas on where i can start/ code tips/ urls etc would be most appreciated. Also, if i am not mistaken there was some charting software to display this kind of data in pie and line charts... anybody know what i am talking about? because i cant find such a link in my bookmarks. Thanks in advance, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Most popular per month
Ryan S wrote: Hey! The client has a set of 50 images that keep rotating everyday and when a user clicks one of those images he is taken to that images site, in the background (database) i maintain a counter _for the day_ and then display the top ten images everyday in this format: 1-10 before the next days counter starts this data is stored in a table which has a simple structure like this img_id1 int,img_id2 int (etc till img_id10) Now the client wants a little extra functionality, and with me sucking at maths I need some help please, basically he now wants to have a chart with all the 50 images there and showing _via percentages_ instead of the present 1-10 display which ones are the most popular till date. example: 1. image name: (percentage here) 2. image name: (percentage here) 3. image name: (percentage here) etc any ideas on where i can start/ code tips/ urls etc would be most appreciated. Also, if i am not mistaken there was some charting software to display this kind of data in pie and line charts... anybody know what i am talking about? because i cant find such a link in my bookmarks. Thanks in advance, Ryan percentages: $total=img1 int + img2 int + img3 int + img50 int; $perc1=(img1 int)/$total; $perc2=(img2 int)/$total; . .. . $perc50=(img50 int)/$total; You can do it per day, per month, per year, per 28 days, per PMS cycle, per anything you want provided you have the data to do it. Google had an pie chart thingie, check the archives of this list. HTH, Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT - RE: [PHP] scalable web gallery
At 7:22 PM -0500 7/11/08, Shawn McKenzie wrote: Jim Lucas wrote: tedd wrote: The only downside of the classroom environment is that I can honestly learn more from this group et al than I can in a classroom. I just don't see academia keeping up with technology. By time the instructors prepare their class-notes, their class-notes are outdated -- or so is my perspective. This is so true. Our Community College here in Central Oregon has a Cisco class that is based on the IOS from about 8 years ago. Some of the things that the guy teaches are not even in the current ISO. Or the work-a-rounds he talks about for problems in that ISO have already been fixed in the current releases. ...and he even calls the IOS an ISO sometimes ;-) He just proved his point, right? I deal with local colleges a bit -- taught a few classes. Recently our local Community College (LCC) decided to return to their previous database. They tried using Oracle for about six years, but they could never get it to work and finally gave up. Unfortunately in the process, they spent over $20 million dollars, which included a help desk that cost over $650,000 per year, and everything failed miserably. They simply didn't have the experience and no one would admit that they didn't. Instead of hiring local talent, the board of trustees sought out experts from NYC who encouraged them to throw even more money at the problem. You see, NYC has all their colleges running on Oracle, but they also have over 200 full-time Oracle programmers working on it. It wasn't until the Federal government threaten to hold up government money (because the college wasn't paying students their grant and other monies) that the college wised up and retreated from their We're just like NYC attitude. Sometimes, these smart people aren't as smart as they think they are. Cheers, tedd PS: BTW -- I offered my talents but they didn't have the professional curiosity to even reply. I'm afraid that the bad news isn't over for the local taxpayer just yet. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scalable web gallery
At 8:51 AM +0800 7/12/08, paragasu wrote: Why not use a hash table based upon the name of the file and distribute files that way? sorry tedd, i don't really get it. but i am interested to know more about the hash table concept. can you explain a little bit more.. paragasu: A hash table is simply a result from an algorithm where you take the name of the file and produce a number from it. It can be any computation you want that produces a number -- such as just totalling the number of letters in the name. For example, tedd.gif would compute to 4, whereas Rob.gif would be a meager 3, and Daniel.gif would be a six (which is probably over-rated for him anyway). :-) Now, just use our respective number for storage in directories -- tedd.gif would be stored in directory 4, Ron.gif would be stored in directory 3, and Daniel.gif in directory 6. If you store the names of the files in a database, then you don't need to store the paths as well because the paths can be computed from the file names -- do you see? Also, you don't need to create a directory until there's actually a need for one. This is old logic for creating memory structures where we weren't forced to allocate memory beforehand -- it's like a large array with holes in it. It's kind of slick when you can apply it to other stuff. Now, the example I gave was pretty simple. However, a good hash algorithm is one that distributes things evenly, and that's a bit more complicated -- I'll leave that for another time. now returning you to your normal television viewing pleasure :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php