php-general Digest 18 Sep 2007 15:34:35 -0000 Issue 5025
php-general Digest 18 Sep 2007 15:34:35 - Issue 5025 Topics (messages 262191 through 262202): dir_object-read() on different platform 262191 by: news.php.net 262192 by: Jim Lucas 262193 by: Jim Lucas 262194 by: Jim Lucas Re: Try to find a solution, when restart Apache with PHP Script 262195 by: Rodolfo De Nadai Re: PHP preg_replace help 262196 by: Al dynamic img 262197 by: Anugrah Widya 262199 by: Daniel Brown 262202 by: Anugrah Widya Re: back-button question 262198 by: Al Re: split in to multiple pages ( pagination) 262200 by: Joker7 Re: split in to multiple pages (I think) 262201 by: Joker7 Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- Hi! I have some text and JPEG files inside a directory like: 1992-7-11.txt 1992-7-11_pic1.jpg 2000-4-10.txt 2000-4-10_pic1.jpg 2004-5-2.txt 2004-5-2_pic1.jpg On a Windows box (XP + Apache), if I do a dir_object-read() for the directory, read() reads the files above in order (eg. 1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on these files are different. However, after I ftp them to a Linux box and load the php script from the Linux box, the order is gone. The time stamps on those files on the Linux box are the same since they were all ftp and cp at the same time. Does anyone know why? Can anyone suggest a simple solution? Thanks. Davis ---End Message--- ---BeginMessage--- news.php.net wrote: Hi! I have some text and JPEG files inside a directory like: 1992-7-11.txt 1992-7-11_pic1.jpg 2000-4-10.txt 2000-4-10_pic1.jpg 2004-5-2.txt 2004-5-2_pic1.jpg On a Windows box (XP + Apache), if I do a dir_object-read() for the directory, read() reads the files above in order (eg. 1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on these files are different. However, after I ftp them to a Linux box and load the php script from the Linux box, the order is gone. The time stamps on those files on the Linux box are the same since they were all ftp and cp at the same time. Does anyone know why? Can anyone suggest a simple solution? Thanks. Davis Use glob() instead and then use sort() on the returned array. That should put things back in order ?php $ar = glob('/dir/'); sort($ar); # This should display the files in order foreach ( $ar AS $file ) { echo $file; } ? Hope that helps Jim ---End Message--- ---BeginMessage--- Jim Lucas wrote: news.php.net wrote: Hi! I have some text and JPEG files inside a directory like: 1992-7-11.txt 1992-7-11_pic1.jpg 2000-4-10.txt 2000-4-10_pic1.jpg 2004-5-2.txt 2004-5-2_pic1.jpg On a Windows box (XP + Apache), if I do a dir_object-read() for the directory, read() reads the files above in order (eg. 1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on these files are different. However, after I ftp them to a Linux box and load the php script from the Linux box, the order is gone. The time stamps on those files on the Linux box are the same since they were all ftp and cp at the same time. Does anyone know why? Can anyone suggest a simple solution? Thanks. Davis Use glob() instead and then use sort() on the returned array. That should put things back in order ?php $ar = glob('/dir/'); sort($ar); # This should display the files in order foreach ( $ar AS $file ) { echo $file; } ? Hope that helps Jim forgot, you might need to use the extension, like so. glob('/path/to/files/*.txt'); glob() does recognize '*' '?' as multi single char replacements. Jim ---End Message--- ---BeginMessage--- news.php.net wrote: Hi! I have some text and JPEG files inside a directory like: 1992-7-11.txt 1992-7-11_pic1.jpg 2000-4-10.txt 2000-4-10_pic1.jpg 2004-5-2.txt 2004-5-2_pic1.jpg On a Windows box (XP + Apache), if I do a dir_object-read() for the directory, read() reads the files above in order (eg. 1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on these files are different. However, after I ftp them to a Linux box and load the php script from the Linux box, the order is gone. The time stamps on those files on the Linux box are the same since they were all ftp and cp at the same time. Does anyone know why? Can anyone suggest a simple solution? Thanks. Davis but, to explain why it happens, it going to be like describing the differences between *nix and windows. Simply put, internally, they store file information differently and by doing this differently, they display the file list differently. Also, *nix file names are case sensitive and windows is not. Be careful with this one, it will bite you at some point. Jim ---End Message--- ---BeginMessage--- Daevid, understood...
Re: [PHP] Try to find a solution, when restart Apache with PHP Script
Daevid, understood... but in my case the php script is called once one time, and then keep's on running forever on a server background shell... The user never will have to worry about the process again, but if the process is not running on the server a message will apear on the interface or a email will be send to the administrator (me and others)... The best solution for me will be the possibility of running this PHP script on other port than the default using by apache. Thanks Daevid Vincent escreveu: We put a timeout at the top and show an error if the server never comes back. You could do whatever you want. As long as the user doesn't try to refresh the page or go somewhere else on your server, the ajax will just keep trying in the background. That's all client-side JS / AJAX. -Original Message- From: Rodolfo De Nadai [mailto:[EMAIL PROTECTED] Sent: Monday, September 17, 2007 1:00 PM To: Daevid Vincent Cc: php-general@lists.php.net Subject: Re: [PHP] Try to find a solution, when restart Apache with PHP Script Hi Daevid, This app keep alive forever as well? When you restart apache what happend to your app? Daevid Vincent escreveu: -Original Message- From: Rodolfo De Nadai [mailto:[EMAIL PROTECTED] Sent: Monday, September 17, 2007 5:25 AM To: php-general@lists.php.net Subject: [PHP] Try to find a solution, when restart Apache with PHP Script Hi all... I'm facing a serious problem with my application. I have a script write in PHP that starts in Internet Explorer, this script keep on running until a varible value change on my MySQL database. The problem is that when i restart Apache, the process child initalized isn't kill... then the apache can't be start because the script is use the port 80. To solve my problem, without change anything, the best would be that when i execute the script, it run on other port than the default 80... so this way apache could start... The is a way to redirect through php, so the script run on a diferent port?? Like change some line, or add on php.ini files?? or even in programming?? thanks ... for any info We do something like this, wherein sometimes we have to force a restart of Apache, so in order to not kill the web page for the GUI, we use AJAX to continually poll the server. Then when the server is back, we can issue a page refresh to whatever page we want... ---8 snip 8 ?php $request_interval = 1; // 10 seconds. $type = intval( $_GET[ 'type' ] ); if ( 1 == $type ) { $initial_wait = 6; // 1 minute. $title = translate('Rebooting Appliance'); $text = translate('This may take several minutes. If this page does not redirect you, click A HREF=home_start_main.phphere/A.'); } else { $initial_wait = 2; // 20 seconds. $title = translate('Rebuilding Web Certificates'); $text = translate('If this page does not redirect you in a few seconds, click A HREF=home_start_main.phphere/A.'); } ? !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD TITLE?= translate('%1$s :: Loading...', PRODUCT_fENF) ?/TITLE META HTTP-EQUIV=Content-Type CONTENT=text/html; LINK REL=STYLESHEET TYPE=text/css HREF=includes/default.css?version=1 /HEAD BODY TABLE WIDTH=100% HEIGHT=100% TR TD ALIGN=center VALIGN=middle HEIGHT=100% WIDTH=100% TABLE BORDER=0 CLASS=componentBox TR VALIGN=middle TD COLSPAN=3 CLASS=tableHeadline?=$title?/TD /TR TR VALIGN=MIDDLE TDIMG SRC=images/icons/paper_time.gif/TD TD TABLE TR TD?=$text?/TD /TR TR TD ALIGN=CENTERDIV ID=status STYLE=color:gray?= translate('Waiting...') ?/DIV/TD /TR /TABLE /TD /TR /TABLE /TD
[PHP] dynamic img
dear friends :), i have problem with dynamic image displaying here the snippets thumb.php ?php header(Content-type: image/jpg); $file = data/original/filename.jpg; readfile($file); ? img.php img src=thumb.php?filename.jpg / problem is i always get broken images, someone know how to fix this ? thx in advance anuwidy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP preg_replace help
Just use stripslashes() on your submitted data and forget about testing for magic_quotes. It's good practice anyhow. \ is not legit text regardless. haim Chaikin wrote: Hello, I am a beginner in PHP. I need help with the function preg_replace. I am trying to remove the backslashes ( \ ) from a string that is submitted by the user. It is submitted in a form but it adds \ before the quotation marks ( ). Will this change if I use the GET method instead of POST. If not can you please tell me how to use preg_replace to remove the backslashes. Thank You, Chaim Chaikin Novice PHP programmer Hotwire Band Website Administrator http://hotwire.totalh.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: back-button question
The general rule is to create or maintain every page on your server of what you what the client to see. Then send it for every submit. That way you don't have to worry about satisfying every browser and configuration there is. Πρεκατές Αλέξανδρος wrote: I'a writing first time so sorry if i reapeat but i wanted to say this in my own words and angle. My question is : Lets assume that we'r going throught php/html files a- b -- c || 1)From a to b through a link 2)from b to c through a submit button (post method) 3) c is a php script which does some mysql queries and changes some session variables and outputs a location header to return to b. While back in b we press the back button when back button is pressed my icewiesel browser gets me to 'a' page. Trying to find some sense i postulated that a browser holds in its history (for back/forward) only requests made explicitly by the user and not the ones made from withing php files (with header commands) . Is my theory right.. I'm searching in the broader context of trying to control how my bookstore website will react to random events from the user (back/forward, links etc) while in a middle of a series of php files that i want to act as a transaction. Any help- recommendations for study on the subject would be very welcomed. I have 3 books on mysql/php but that issues r not examined, Prekates Alexandros Trikala Greece -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dynamic img
Hello, Anugrah. On 9/18/07, Anugrah Widya [EMAIL PROTECTED] wrote: i have problem with dynamic image displaying here the snippets thumb.php ?php header(Content-type: image/jpg); $file = data/original/filename.jpg; readfile($file); ? img.php img src=thumb.php?filename.jpg / From your above examples, two questions come to mind: 1.) Is thumb.php in a folder above `data`? If not, adjust your path accordingly. 2.) When using the query ?filename.jpg are you going to call that as an $argv[1] variable? If you want to use it as a $_GET, $_POST, or $_REQUEST, it will need a variable name with an assigned value. For example: img src=thumb.php?img=filename.jpg Lthumb.php ? $path = ../data/original/; // In case it's a same-level directory as the PWD $img = $_GET['img']; header(Content-type: image/jpg); readfile($path.$img); ? -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] split in to multiple pages ( pagination)
In news: [EMAIL PROTECTED] - Greg Donald wrote : On Sat, 15 Sep 2007, Joker7 wrote: I'm using the code below to display news articles-which works great apart from. I can control the number of articles,but I would like to add a link to the bottom of the page to the un-displayed articles ( nexted 5 articles and so on) any pointers would be most welcome as most know my PHP skills are not the best :). ? $max_latest = 5; $filename = articlesum.php; #- open article if(file_exists($filename)){ $fh = fopen($filename, r); $old_news = fread($fh, filesize($filename)); fclose($fh); } #- get article $articles = explode(!--ARTICLE--, $old_news); $i=0; foreach ( $articles as $article ){ if(count($articles)$i){ if($max_latest = $i++){ print $article; } } } There's a bunch of how-tos and discussion on this topic already: http://google.com/search?q=php+pagination You have to manage a variable across page requests to keep track of where you are. Use that variable in your SQL as part of your offset/limit parameters. -- Greg Donald Cyberfusion Consulting http://cyberfusionconsulting.com/ Thanks for the reply - I now know what it's called :) I forgot to and it's a flat file system not the best but is ok for my needs. I spent a couple of hours following link from google an not a sausage on flat files :( Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: split in to multiple pages (I think)
In news: [EMAIL PROTECTED] - Thomas Bachmann wrote : Why don't post an example of your news file too? Joker7 schrieb: Hi, I'm using the code below to display news articles-which works great apart from. I can control the number of articles,but I would like to add a link to the bottom of the page to the un-displayed articles ( nexted 5 articles and so on) any pointers would be most welcome as most know my PHP skills are not the best :). Cheers Chris ? $max_latest = 5; $filename = articlesum.php; #- open article if(file_exists($filename)){ $fh = fopen($filename, r); $old_news = fread($fh, filesize($filename)); fclose($fh); } #- get article $articles = explode(!--ARTICLE--, $old_news); $i=0; foreach ( $articles as $article ){ if(count($articles)$i){ if($max_latest = $i++){ print $article; } } } Here you go Thomas- not mine I found it on the www. Im sorry I started using this now would have been a lot better to use mysql. Chris ? include (template.inc); include (config.php); $subject = $_POST[subject]; $summary = $_POST[summary]; $passwd = $_POST[passwd]; $date = $_POST[date]; $body = $_POST[body]; $article_id = $_POST[article_id]; #foreach($GLOBALS as $a = $b){ print li$a = $b;} $summary_template = t_summary.tp; $article_template = t_article.tp; $max_summary = 5; function summary_page ($subject, $date, $summary, $article_id) { global $summary_template; $t = new Template(); $t-set_file(SummaryPage, $summary_template); $article_url = article_.$article_id..php; $date = ($date); $summary = nl2br($summary); $t-set_var( array( subject = $subject, date= $date, summary = $summary, article_url = $article_url )); $t-parse(Summary, SummaryPage); return $t-get_var(Summary); } function main_page ($subject, $date, $summary, $article_id, $body) { global $article_template; $t = new Template(); $t-set_file(ArticlePage, $article_template); $article_url = article_.$article_id..php; $date =($date); $summary =($summary); $body =nl2br($body); $t-set_var( array( subject = $subject, date= $date, summary = $summary, body = $body, article_url = $article_url )); $t-parse(Article, ArticlePage); return $t-get_var(Article); } function add_article($filename, $news) { if(file_exists($filename)){ $fh = fopen($filename, r); $old_news = fread($fh, filesize($filename)); fclose($fh); } /* TODO: Multipage articles preg_match_all(!--ARTICLE PAGE=(\d*)--, $old_news, $matches; if( count($matches[0]) = $max_summary){ $oldfilename = $filename.($matches[0][0]+1); } */ $fh = fopen($filename, w); $news = stripslashes($news); fwrite($fh, \n\n$news $old_news); fclose($fh); } if(strcmp($subject, )){ if(!(strcmp($passwd, $password))){ add_article(article_summary.php, summary_page($subject, $date, $summary, $article_id)); add_article(article_$article_id.php, main_page($subject, $date, $summary, $article_id, $body)); echo brpa href=article_$article_id.phpArticle has been added!/a/p; }else{ echo pb Password is wrong!/b/p; } } ? form action=news.php method=post table border=0 tr td valign=topp class=header1(Password):/p/tdtd input type=password name=passwd size=20 /td/tr tr td valign=topp class=header1Subject:/p/tdtd input type=text name=subject size=50 /td/tr tr td valign=topp class=header1Article ID:/p/tdtd input type=text name=article_id value=? echo date(Y_m_j_is); ? size=30 /td/tr tr td valign=topp class=header1Date/Author:/p/tdtd textarea name=date rows=2 cols=50 wrap=soft? echo date(M j, Y\n); ?Author: /textarea /td/tr tr td valign=topp class=header1Summary:/p/tdtd textarea name=summary rows=5 cols=50 wrap=soft/textarea /td/tr tr td valign=topp class=header1Body:/p/tdtd textarea name=body rows=15 cols=50/textarea /td/tr /tablebr centerinput type=submit name=submit value=Add-Article/center /form -- Cheap As Chips Broadband http://yeah.kick-butt.co.uk Superb hosting domain name deals http://host.kick-butt.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Case insensitive ksort
Christoph Boget wrote: I looked in the docs but didn't see anything regarding case insensitivity and I fear the functionality doesn't exist. I'm just hoping I'm looking in the wrong place. Is there a way to get ksort to work without regard to case? When I sort an array using ksort, all the upper case keys end up at the top (sorted) and all the lower case keys end up at the bottom (sorted). Ideally, I'd like to see all the keys sorted (and intermixed) regardless of case. Am I going to have to do this manually? Or is there an internal php command that will do it for me? thnx, Christoph Is this what you are looking for? ?php $yourarray = array(); $sorted = natcasesort(array_keys($yourarray)); foreach ( $sorted AS $key ) { echo $yourarray[$key]; } ? -- 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] dynamic img
thumb.php ?php header(Content-type: image/jpg); $file = data/original/filename.jpg; readfile($file); ? Change header(Content-type: image/jpg); to header(Content-type: image/jpeg); Apparently IE doesn't like image/jpg [1]. [1] http://pear.php.net/bugs/bug.php?id=4586 Edward -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Case insensitive ksort
I looked in the docs but didn't see anything regarding case insensitivity and I fear the functionality doesn't exist. I'm just hoping I'm looking in the wrong place. Is there a way to get ksort to work without regard to case? When I sort an array using ksort, all the upper case keys end up at the top (sorted) and all the lower case keys end up at the bottom (sorted). Ideally, I'd like to see all the keys sorted (and intermixed) regardless of case. Am I going to have to do this manually? Or is there an internal php command that will do it for me? thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Case insensitive ksort
On 18/09/2007, Christoph Boget [EMAIL PROTECTED] wrote: I looked in the docs but didn't see anything regarding case insensitivity and I fear the functionality doesn't exist. I'm just hoping I'm looking in the wrong place. Is there a way to get ksort to work without regard to case? When I sort an array using ksort, all the upper case keys end up at the top (sorted) and all the lower case keys end up at the bottom (sorted). Ideally, I'd like to see all the keys sorted (and intermixed) regardless of case. Am I going to have to do this manually? Or is there an internal php command that will do it for me? uksort($array, 'strcasecmp'); -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic img
Anugrah Widya wrote: dear friends :), i have problem with dynamic image displaying here the snippets thumb.php ?php header(Content-type: image/jpg); $file = data/original/filename.jpg; readfile($file); ? img.php img src=thumb.php?filename.jpg / problem is i always get broken images, someone know how to fix this ? Rather than viewing img.php, go directly to thumb.php?filename.jpg in your browser. Change the content-type to text/plain and see what you get in the browser. You may also want to remove the ? at the end of thumb.php - it's not needed and may be adding whitespace to the image you are returning. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dynamic img
Daniel Brown wrote: Hello, Anugrah. On 9/18/07, Anugrah Widya [EMAIL PROTECTED] wrote: i have problem with dynamic image displaying here the snippets thumb.php ?php header(Content-type: image/jpg); $file = data/original/filename.jpg; readfile($file); ? img.php img src=thumb.php?filename.jpg / From your above examples, two questions come to mind: 1.) Is thumb.php in a folder above `data`? If not, adjust your path accordingly. 2.) When using the query ?filename.jpg are you going to call that as an $argv[1] variable? If you want to use it as a $_GET, $_POST, or $_REQUEST, it will need a variable name with an assigned value. For example: img src=thumb.php?img=filename.jpg Lthumb.php ? $path = ../data/original/; // In case it's a same-level directory as the PWD $img = $_GET['img']; header(Content-type: image/jpg); readfile($path.$img); ? -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished thank you Mr. Brown for your reply, yep thumb.php and img.php are in the same level correction for img.php img src=thumb.php?url=filename.jpg / i don't know what wrong with it, when i save the image data to another files, the image didn;t corrupted, but when displayed dynamically it's corrupted.., and the path are ok ;) did i miss something on this, and i didn;t aware of it ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Case insensitive ksort
I don't have time to look up in the manual but I don't remember a case insensitive ksort(). I think there's a uksort() where you could specify your own sorting parameters for the keys. Also, you could create the array with keys run through strtoupper() or strtolower(). If you need the proper upper/lowercase version too, you could store that separately within the array. Just some thoughts on how you could do this. good luck! -TG - Original Message - From: Christoph Boget [EMAIL PROTECTED] To: php-general@lists.php.net Date: Tue, 18 Sep 2007 11:37:01 -0400 Subject: [PHP] Case insensitive ksort I looked in the docs but didn't see anything regarding case insensitivity and I fear the functionality doesn't exist. I'm just hoping I'm looking in the wrong place. Is there a way to get ksort to work without regard to case? When I sort an array using ksort, all the upper case keys end up at the top (sorted) and all the lower case keys end up at the bottom (sorted). Ideally, I'd like to see all the keys sorted (and intermixed) regardless of case. Am I going to have to do this manually? Or is there an internal php command that will do it for me? thnx, Christoph -- 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] Questions about overloading and visibility in PHP5
I've been doing a bunch of reading about objects and overloading in PHP5, but I've got a couple of questions that I can't seem to find the answer to online. Suppose the following code in PHP5.2.4: ?php class foo { public $x; private $z = 'z'; public function __set ($name, $val) { echo Setting \$this-$name to $val...\n; $this-{$name} = $val; } public function __get ($name) { return The value of $name is {$this-{$name}}.\n; } } ? My questions are as follows: 1) It seems that the getter and setter are not called on every single call. For example, if I do the following: $bar = new foo; $bar-x = 'x'; There is no output. I would expect to see Setting $this-x to x. Another example: $bar = new foo; $bar-y = 'y'; echo $bar-y; I would expect this to see The value of y is y. but instead I just get 'y' as output. So when do the various setters/getters get used? 2) It seems that getters ignore the visibility of properties. Why is this? For example: $bar = new foo; echo $bar-z; I would expect this to throw an error about accessing a private member, but it outputs The value of z is z. just fine. If I remove the __get() overloader, an error is thrown. I'm guessing that the answer to all of my questions is some how wrapped up in visibility and overloading. Unfortunately I cannot find any resource that documents the interactions. TIA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Questions about overloading and visibility in PHP5
Steve Brown wrote: I've been doing a bunch of reading about objects and overloading in PHP5, but I've got a couple of questions that I can't seem to find the answer to online. Suppose the following code in PHP5.2.4: ?php class foo { public $x; private $z = 'z'; public function __set ($name, $val) { echo Setting \$this-$name to $val...\n; $this-{$name} = $val; } public function __get ($name) { return The value of $name is {$this-{$name}}.\n; } } ? My questions are as follows: 1) It seems that the getter and setter are not called on every single call. For example, if I do the following: $bar = new foo; $bar-x = 'x'; There is no output. I would expect to see Setting $this-x to x. remove public $x and it works. __set() is only called for non-existent variables. Another example: $bar = new foo; $bar-y = 'y'; echo $bar-y; I would expect this to see The value of y is y. but instead I just get 'y' as output. So when do the various setters/getters get used? again, because your code sets $y with $this-{$name} = $value, the variable $y now exists, and so __get() is not called. If you're using normal variables, then you don't need setters/getters. Instead, if you store the values inside an internal array (for instance), then a setter/getter can help to abstract the array contents. For instance, this class: http://svn.pear.php.net/wsvn/PEARSVN/Pyrus/trunk/src/PackageFile/v2/Developer.php?op=filerev=0sc=0 (which is under development currently for the next incarnation of the PEAR installer) allows logical manipulation of maintainers of a package within package.xml. Instead of either direct array manipulation or the old way, which was a complex method call that is easy to mis-order: $pf-addMaintainer('cellog', 'Greg Beaver', '[EMAIL PROTECTED]', 'yes'); One can do: $pf-maintainer['cellog'] -name('Greg Beaver') -email('[EMAIL PROTECTED]') -active('yes'); and then values can be retrieved using normal stuff like: echo $pf-maintainer['cellog']-email; The entire time, the class is abstracting stuff that would be really complex as it is actually accessing the underlying XML of the package.xml directly when making the modifications. The examples you give don't need this kind of complexity. 2) It seems that getters ignore the visibility of properties. Why is this? For example: $bar = new foo; echo $bar-z; I would expect this to throw an error about accessing a private member, but it outputs The value of z is z. just fine. If I remove the __get() overloader, an error is thrown. private properties simply don't exist outside the class, so you can create public properties on external access with impunity. You should open a documentation bug for this at bugs.php.net Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions about overloading and visibility in PHP5
1) It seems that the getter and setter are not called on every single call. For example, if I do the following: $bar = new foo; $bar-x = 'x'; There is no output. I would expect to see Setting $this-x to x. Another example: $bar = new foo; $bar-y = 'y'; echo $bar-y; I would expect this to see The value of y is y. but instead I just get 'y' as output. So when do the various setters/getters get used? 2) It seems that getters ignore the visibility of properties. Why is this? For example: $bar = new foo; echo $bar-z; I would expect this to throw an error about accessing a private member, but it outputs The value of z is z. just fine. If I remove the __get() overloader, an error is thrown. I'm guessing that the answer to all of my questions is some how wrapped up in visibility and overloading. Unfortunately I cannot find any resource that documents the interactions. TIA. As I understand it, the __get and __set do not ignore visibility; rather, they only work for accessing private members. If a property is declared public, it does not need the __get and __set, so they aren't used. Likewise, $bar-y is public since it was added dynamically outside the class. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Job openings in Maryland
My company has the following job openings available: Join in the Adventure. Yakabod, a web software and services company, is located in a beautifully restored facility in Frederick, Maryland's historic district. We've experienced steady growth since starting in 2001. We've set our hearts on building a great company. Now we're looking for some great people to help fuel our growth. We need a skilled Software Test Engineer to join our Application Factory team. We'll expect you to have a combination of solid in-depth knowledge of QA, QA's goals, working with QA and non-QA groups, and extensive background in solid test coverage. You'll be responsible for providing Quality Assurance for the Yakabod KnowledgeWork application. This will include the creation of test suites and test harness for front and backend testing, API testing, automating UI test cases, defining test plans and test specifications, designing tools for automated performance testing, execution of test cases, and reporting product failures. You'll work with development teams to ensure that a product is testable, that it is adequately unit tested, and that it can be automated even further in the test harness. You'll review design documents for adequate testing hooks, and implement mock objects and servers to help developers with their unit testing and to allow for testing of components individually. Following project milestones, you'll design, implement, document, and/or execute tests; evaluate and communicate results; develop API tests; and investigate product features (including ad hoc testing). You'll also work closely with developers in defect resolution and assist troubleshooting issues. You can communicate clearly and effectively. You will also be responsible for setting up the processes required to promote the overall quality of the product. You have the ability to influence, lead, manage and help build QA with excellence, in a fun and fast-paced dynamic team and corporate environment. Software Test Engineer Minimum skills: * 5-6 years of overall IT experience * 3+ years software quality assurance testing * 3+ years experience with automated test tools and load testing packages (especially any PHP related testing tools i.e. PHPUnit) * 2+ years creating and writing test plans and test scripts * 2+ years web based testing * Experience with XML and web services testing * Experience with SQL and data retrieval from a relational database (i.e., MySql, Oracle) * Strong UNIX background especially Linux * Ability to work against extremely tight deadlines * Experience in HTML, Java Script, DHTML Preferred skills: * Bachelors degree with emphasis on CS, CE and EE majors * Familiarity with quality methodologies such as: CMM, ISO or IEEE. * Familiarity with the Agile Development Framework * Experience in PHP, PERL and shell scripting is a strong plus * Strong understanding of all aspects of the QA role and all areas of application testing * Detailed understanding of the entire development cycle * Experience with defect tracking systems and other software life cycle management tools (Bugzilla) * Knowledge of and ability to rapidly learn third party development/QA tools * Capacity for attention to details * Strong organizational and communication skills Web Application Developers We're still small, so you'll do a bit of everything –from integrating and supporting critical customer applications to creating new components in our core software products. Specifically, you can do many of the following with excellence: • Lead, manage, and/or architect knowledge-based dynamic web applications • Develop software using PHP, MySQL, JavaScript, HTML, XML, AJAX and other web application environments (experience with J2EE or MS environments will be considered if you have demonstrated strong lifecycle development and problem solving skills). • Capture requirements, and then create use cases, specs, object-oriented design, user interfaces, and data models • Execute disciplined development practices over a full-lifecycle • Deploy, support, and maintain customer applications, including networks,Linux servers, development tools, and custom applications We'll expect you to reliably get things done – you're a self-motivated, entrepreneurial, problem solver who desires to be part of a team that builds software that works the way it ought to. You thrive as part of a team that's undertaking a bold adventure together. Most important, you resonate with our core values and culture. Experience in an early stage tech firm is desirable, but not required. An active TS/SCI clearance with polygraph is desirable, but not required. If you don't have one, you must be willing to be submitted for clearance processing. We're not looking for bodies, just a few select impact players. We've set pay and benefits accordingly, including participation in our generous stock options plan and plenty of great coffee. Interested? Send your resume to [EMAIL PROTECTED]
RE: [PHP] read the main domain cookie in sub domain
I did it. Still I am not able to access it. Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 19, 2007 12:41 AM To: Sanjeev N Cc: php-general@lists.php.net Subject: Re: [PHP] read the main domain cookie in sub domain Sanjeev N wrote: Assume, I have www.domain.com http://www.domain.com/ in which I wrote the functionality for user authentication and his profile related functionality. Now, when user logs in using http://www.domain.com/users/login.php then after his successful login a session as well as a cookie is getting created. This will creates a cookie called myCookie123 Now I have my subdomain as http://sub.domain.com/index.php . here at the top I am checking whether the user is logged in or not, for that I have to check whether the cookie is created or not.. Here my problem is that, I am not getting the idea about, how to access or read the cookie of http://www.domain.com http://www.domain.com/ from http://sub.domain.com/. can anyone please suggest me how to achieve this. Set the $domain parameter of setcookie to '.domain.com'. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] read the main domain cookie in sub domain
Hey Stut, Thanks.. Now its working fine. Now I am able to access the value. Actually problem was in main domain the cookies path was wrong. It was showing /user/ . I set it to / Thanks Stut. Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 19, 2007 12:46 AM To: Sanjeev N Cc: php-general@lists.php.net Subject: Re: [PHP] read the main domain cookie in sub domain Sanjeev N wrote: I did it. Still I am not able to access it. You'll probably need to delete the existing cookie from your browser and get it set again. -Stut -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 19, 2007 12:41 AM To: Sanjeev N Cc: php-general@lists.php.net Subject: Re: [PHP] read the main domain cookie in sub domain Sanjeev N wrote: Assume, I have www.domain.com http://www.domain.com/ in which I wrote the functionality for user authentication and his profile related functionality. Now, when user logs in using http://www.domain.com/users/login.php then after his successful login a session as well as a cookie is getting created. This will creates a cookie called myCookie123 Now I have my subdomain as http://sub.domain.com/index.php . here at the top I am checking whether the user is logged in or not, for that I have to check whether the cookie is created or not.. Here my problem is that, I am not getting the idea about, how to access or read the cookie of http://www.domain.com http://www.domain.com/ from http://sub.domain.com/. can anyone please suggest me how to achieve this. Set the $domain parameter of setcookie to '.domain.com'. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] read the main domain cookie in sub domain
Sanjeev N wrote: I did it. Still I am not able to access it. You'll probably need to delete the existing cookie from your browser and get it set again. -Stut -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 19, 2007 12:41 AM To: Sanjeev N Cc: php-general@lists.php.net Subject: Re: [PHP] read the main domain cookie in sub domain Sanjeev N wrote: Assume, I have www.domain.com http://www.domain.com/ in which I wrote the functionality for user authentication and his profile related functionality. Now, when user logs in using http://www.domain.com/users/login.php then after his successful login a session as well as a cookie is getting created. This will creates a cookie called myCookie123 Now I have my subdomain as http://sub.domain.com/index.php . here at the top I am checking whether the user is logged in or not, for that I have to check whether the cookie is created or not.. Here my problem is that, I am not getting the idea about, how to access or read the cookie of http://www.domain.com http://www.domain.com/ from http://sub.domain.com/. can anyone please suggest me how to achieve this. Set the $domain parameter of setcookie to '.domain.com'. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] read the main domain cookie in sub domain
Hi, Assume, I have www.domain.com http://www.domain.com/ in which I wrote the functionality for user authentication and his profile related functionality. Now, when user logs in using http://www.domain.com/users/login.php then after his successful login a session as well as a cookie is getting created. This will creates a cookie called myCookie123 Now I have my subdomain as http://sub.domain.com/index.php . here at the top I am checking whether the user is logged in or not, for that I have to check whether the cookie is created or not.. Here my problem is that, I am not getting the idea about, how to access or read the cookie of http://www.domain.com http://www.domain.com/ from http://sub.domain.com/. can anyone please suggest me how to achieve this. Thanks In advance. Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan
Re: [PHP] read the main domain cookie in sub domain
Sanjeev N wrote: Assume, I have www.domain.com http://www.domain.com/ in which I wrote the functionality for user authentication and his profile related functionality. Now, when user logs in using http://www.domain.com/users/login.php then after his successful login a session as well as a cookie is getting created. This will creates a cookie called myCookie123 Now I have my subdomain as http://sub.domain.com/index.php . here at the top I am checking whether the user is logged in or not, for that I have to check whether the cookie is created or not.. Here my problem is that, I am not getting the idea about, how to access or read the cookie of http://www.domain.com http://www.domain.com/ from http://sub.domain.com/. can anyone please suggest me how to achieve this. Set the $domain parameter of setcookie to '.domain.com'. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] date weirdness
I have extracted a small portion of a calendar application I developed recently to show some strange behavior with the date() function. When I run this I get duplicate dates occasionally down the list. I'm seeing 11/4 twice for example. Sometimes dates are missing from the list. The results change from day to day. #!/usr/bin/env php ?php error_reporting( E_ALL ); define( 'SECONDS_IN_A_DAY', 60 * 60 * 24 ); define( 'LAST_SUNDAY', strtotime( 'last Sunday' ) ); echo 'SECONDS_IN_A_DAY = ' . SECONDS_IN_A_DAY . \n; echo 'LAST_SUNDAY = ' . LAST_SUNDAY . \n; for( $x = 0; $x 365; $x++ ) { $seconds = LAST_SUNDAY + ( SECONDS_IN_A_DAY * $x ); $date = date( 'n/j', $seconds ); echo $seconds $date\n; } I get the same results with latest PHP4 and PHP5. -- Greg Donald Cyberfusion Consulting http://cyberfusionconsulting.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date weirdness
I'm seeing 11/4 twice for example. Sometimes dates are missing from the list. The results change from day to day. That would be DST. The number of seconds per day changes on Nov. 4, 2007 in the US local time zones. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Try to find a solution, when restart Apache with PHP Script
On 9/17/07, Rodolfo De Nadai [EMAIL PROTECTED] wrote: Hi all... I'm facing a serious problem with my application. I have a script write in PHP that starts in Internet Explorer, this script keep on running until a varible value change on my MySQL database. The problem is that when i restart Apache, the process child initalized isn't kill... then the apache can't be start because the script is use the port 80. Hi Rodolfo- I think you are going about this the wrong way. You shoud not have the PHP script itself execute the forever running task, it should just trigger the separate starting/stopping of the task. There are several ways to do this, the first two that spring to mind are: 1. Create a custom init-script in /etc/init.d (or wherever your distribution has init scripts) that the PHP process triggers with a start command (/etc/init.d/myprog start). This will require root privileges for the PHP process (or no-password sudo privileges for that command). --or-- 2. Have a cron job running as a user that has appropriate permissions. This cron job should look for the presence of specific files - if it sees them, it takes the appropriate action, and then deletes the trigger file. For example, have the cron job watch for the presence of /tmp/startMyProg.marker - when it sees it, it starts the program and deletes /tmp/startMyProg.marker. Also have it watch for the presence of /tmp/stopMyProg.marker, when it sees that, it would stop the running program, and delete the marker file. At this point, all your PHP script has to do is create the appropriate file in /tmp (could be as simple as a exec(touch /tmp/startMyProg.marker) call). Hope that sends you a workable direction- James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP preg_replace help
Apologies if you already received this message, I tried to send it earlier from my webmail but it doesn't seem to have worked. Al wrote: Just use stripslashes() on your submitted data and forget about testing for magic_quotes. It's good practice anyhow. \ is not legit text regardless. Using stripslashes() on all submitted data is most certainly *not* good practice. If magic_quotes_gpc is later turned off or you're using one of the versions of PHP with buggy magic_quotes_gpc support then you can easily lose data. Reversing the effects of magic_quotes_gpc is far from trivial, there's lots of potential for subtle bugs, let alone completely forgetting about $_COOKIE. See my earlier reply for a real solution. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date weirdness
On Tue, 2007-09-18 at 15:32 -0500, Greg Donald wrote: I have extracted a small portion of a calendar application I developed recently to show some strange behavior with the date() function. When I run this I get duplicate dates occasionally down the list. I'm seeing 11/4 twice for example. Sometimes dates are missing from the list. The results change from day to day. #!/usr/bin/env php ?php error_reporting( E_ALL ); define( 'SECONDS_IN_A_DAY', 60 * 60 * 24 ); define( 'LAST_SUNDAY', strtotime( 'last Sunday' ) ); echo 'SECONDS_IN_A_DAY = ' . SECONDS_IN_A_DAY . \n; echo 'LAST_SUNDAY = ' . LAST_SUNDAY . \n; for( $x = 0; $x 365; $x++ ) { $seconds = LAST_SUNDAY + ( SECONDS_IN_A_DAY * $x ); $date = date( 'n/j', $seconds ); echo $seconds $date\n; } ? I get the same results with latest PHP4 and PHP5. Using seconds is a hack that doesn't account for DST. Use the following instead: ?php error_reporting( E_ALL ); define( 'LAST_SUNDAY', strtotime( 'last Sunday' ) ); echo 'LAST_SUNDAY = ' . LAST_SUNDAY . \n; for( $x = 0; $x 365; $x++ ) { $timestamp = strtotime( +$x days, LAST_SUNDAY ); $date = date( 'n/j', $timestamp ); echo $timestamp $date\n; } ? Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] setup help in IIS6
Hello, I have installed the latest PHP on my windows server 2003 IIS6 machine. From the DOS command line interface (when in the C:\PHP directory) if I type PHP phpinfo.php, the file runs. However I cannot get it to work on the browser on the server our out on the web using my URL. I'm sure it's just an II6 issue, but what am I doing wrong? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] trouble trying to connect to gmail server.
I have a little trouble while trying to connect to gmail server. I already enabled POP on gmail. After experience a lots of errors with the command below, now I'm seeing no more errors, but it still doesn't working, the page stay processing and just is broke after this command. $mbox = imap_open('{pop.gmail.com:995/pop3}INBOX', '[EMAIL PROTECTED]', 'my_pass'); What should I do? Tks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] setup help in IIS6
Have you created the .php file type in the IIS and pointed IIS to the php.exe? Bastien Date: Tue, 18 Sep 2007 22:39:07 -0400 From: [EMAIL PROTECTED] To: php-general@lists.php.net Subject: [PHP] setup help in IIS6 Hello, I have installed the latest PHP on my windows server 2003 IIS6 machine. From the DOS command line interface (when in the C:\PHP directory) if I type PHP phpinfo.php, the file runs. However I cannot get it to work on the browser on the server our out on the web using my URL. I'm sure it's just an II6 issue, but what am I doing wrong? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx
Re: [PHP] trouble trying to connect to gmail server.
Fábio Generoso wrote: I have a little trouble while trying to connect to gmail server. I already enabled POP on gmail. After experience a lots of errors with the command below, now I'm seeing no more errors, but it still doesn't working, the page stay processing and just is broke after this command. $mbox = imap_open('{pop.gmail.com:995/pop3}INBOX', '[EMAIL PROTECTED]', 'my_pass'); What is $mbox at this point? A resource or false? print_r(imap_alerts()); print_r(imap_errors()); anything in those? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php