php-general Digest 1 Dec 2004 09:28:51 -0000 Issue 3144
php-general Digest 1 Dec 2004 09:28:51 - Issue 3144 Topics (messages 203183 through 203216): Using PHP to change Linux IP address 203183 by: AndyO 203185 by: John Nichel 203186 by: AndyO 203188 by: Greg Donald 203192 by: John Nichel My session.c doesnt work! 203184 by: Colin 203187 by: Greg Donald Header's download 203189 by: Christian Johansson Re: echo 203190 by: Christopher Weaver echo string with question mark in it 203191 by: Brent Clements 203193 by: Chris W. Parker Spawning new pages 203194 by: Christopher Weaver 203196 by: Brent Clements 203197 by: Chris W. Parker 203198 by: Greg Donald 203201 by: Chris W. Parker 203207 by: Christopher Weaver 203210 by: Jason Wong regex issue 203195 by: nate.savingadvice.com 203199 by: Greg Donald 203200 by: nate.savingadvice.com 203208 by: Rick Fletcher Date Manipulation 203202 by: Christopher Weaver 203203 by: John Holmes Very fresh to php 203204 by: suneel 203205 by: Ryan King 203206 by: Santa Re: print_r() and SimpleXML 203209 by: Rick Fletcher Upload is not working ( Permission Problem), I tried a number of ways , still no success! 203211 by: Michael Leung 203212 by: Gareth Williams Re: php editor or php IDE for linux with autocompletion 203213 by: Christophe Chisogne Redirect after download 203214 by: Justin England 203215 by: Thomas Munz 203216 by: Minuk Choi 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--- I'm working on a project where an engineer/user has to be able to log in to a device locally and change the IP address. The OS is Linux. We want to make the interface simple and so we thought of using a webpage that allows the engineer/user to change the address without having to use the Linux tools netconfig or ifconfig. Is it possible to use a PHP script to change the IP address? ---End Message--- ---BeginMessage--- AndyO wrote: I'm working on a project where an engineer/user has to be able to log in to a device locally and change the IP address. The OS is Linux. We want to make the interface simple and so we thought of using a webpage that allows the engineer/user to change the address without having to use the Linux tools netconfig or ifconfig. Is it possible to use a PHP script to change the IP address? PHP (the webserver) would have to have permission to edit the ifcfg-eth0 (eth1, eth2, etc) file, and have permission to restart the network. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] ---End Message--- ---BeginMessage--- John Nichel wrote: AndyO wrote: I'm working on a project where an engineer/user has to be able to log in to a device locally and change the IP address. The OS is Linux. We want to make the interface simple and so we thought of using a webpage that allows the engineer/user to change the address without having to use the Linux tools netconfig or ifconfig. Is it possible to use a PHP script to change the IP address? PHP (the webserver) would have to have permission to edit the ifcfg-eth0 (eth1, eth2, etc) file, and have permission to restart the network. Thanks I will look in to this. Seems like a sound enough idea. ---End Message--- ---BeginMessage--- On Tue, 30 Nov 2004 16:50:27 -0500, John Nichel [EMAIL PROTECTED] wrote: PHP (the webserver) would have to have permission to edit the ifcfg-eth0 (eth1, eth2, etc) file, and have permission to restart the network. sudo would probably help with the permissions requirements. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ ---End Message--- ---BeginMessage--- Greg Donald wrote: On Tue, 30 Nov 2004 16:50:27 -0500, John Nichel [EMAIL PROTECTED] wrote: PHP (the webserver) would have to have permission to edit the ifcfg-eth0 (eth1, eth2, etc) file, and have permission to restart the network. sudo would probably help with the permissions requirements. Greg's right, but if you go the sudo route (in fact any route giving your webserver this type of permission), read and understand the docs completely. Editing the ifcfg-ethX file is one thing, but giving it the permission level to restart the network could lead to serious security issues if it's not done properly. I'll stop now, as this can easily go waaay off topic, and can become an extremely long, involved thread. ;) -- By-Tor.com ...it's all about the Rush http://www.by-tor.com ---End Message--- ---BeginMessage--- Hi, I dont know if this is the correct group, but anyway. As part of a school project I decided to
[PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!
Hi all, I am still solving my upload script problems. Here is the error Msg: Warning: copy(/var/www/html/upload_files/Default.bk1) [function.copy]: failed to open stream: Permission denied in /var/www/html/simple_upload.php on line 77 My Upload Code: $result = move_uploaded_file($temp_name, $file_path); I started to think this is not only PHP , may be Apache problem too. Anyone has some ideas? I have tried to set my upload directory into 777. Even I tried to use sudo , giving apache as root permission and running system command copy the file from the tmp directory to upload_files. but still no success!! I have done some research on web, no one can suggest a solution rather than chmod 777( I did that!) yours, michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!
You could try chown user:group, where user and group are those apache runs in. Is this script running on your own machine, or on a web server hosted somewhere? On 1 Dec 2004, at 09:03, Michael Leung wrote: Hi all, I am still solving my upload script problems. Here is the error Msg: Warning: copy(/var/www/html/upload_files/Default.bk1) [function.copy]: failed to open stream: Permission denied in /var/www/html/simple_upload.php on line 77 My Upload Code: $result = move_uploaded_file($temp_name, $file_path); I started to think this is not only PHP , may be Apache problem too. Anyone has some ideas? I have tried to set my upload directory into 777. Even I tried to use sudo , giving apache as root permission and running system command copy the file from the tmp directory to upload_files. but still no success!! I have done some research on web, no one can suggest a solution rather than chmod 777( I did that!) yours, michael -- 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] Re: php editor or php IDE for linux with autocompletion
M. Sokolewicz wrote: http://vim.sourceforge.net/tips/tip.php?tip_id=91 Thanks. It's a dictionary based completion. Is there some way to get completion for user-defined functions, variables etc, say in php files from/below current working directory? Perhaps based on ctags? Some editors do it (PHPed I think) is a HOW, can't find the dictionary file anymore, and don't have it locally either (I don't use auto-completion with PHP). But it shouldn't be too hard to make ;) Rasmus vim php dictionary from Google -- looks authoritative ;-) http://lerdorf.com/funclist.txt Christophe -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Redirect after download
I am writing a file download system and I need to be able to do a redirect after the download is finished. Basically, the user will be presented with a simple HTML page that contains a link to download the file (href=/download.php?fileid=143). I have the code to send the file working just fine, but I can not figure out how to do a redirect after the download is complete. I have spent the last hour searching the archives, and the closest I have found is: http://marc.theaimsgroup.com/?l=php-generalm=106128750620349w=2 But I can't seem to find a way to actually do a Location style redirect. Even static HTML does not display the way one would expect. Using a small text file to download, I can view source from NS and see the everything that was sent to the browser, and everything is there (the ---Boundary(s), the text file, and the simple HTML line). So my question is: How can I perform a redirect after the file has been sent. Thanks, Justin Here is a snippit of download.php (send_file() was found reading the comments to the fread function in the PHP documention): header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\); if(!send_file($file)) { die(File transfer failed!); exit; }else{ print(\n); print(---Boundary-12399\r\n); print(Content-Type: text/html\r\n); print(\r\n); print htmlheadtitleSuccess/title/headbodybFile transfer s uccessful!/b/body/html; print(\r\n---Boundary-12399\r\n); print(\r\n); exit; } function send_file($file) { // read file and send to user $status = FALSE; if ( (!is_file($file['filelocation'])) or (connection_status()!=0) ) return(FALSE); print(---Boundary-12399\r\n); print(Content-type: application/octet-stream\r\n); print(Content-Disposition: inline; filename=\ . $file['filename'] . \\r\n); print(Content-length: . $file['filesize'] . \r\n); print(Expires: . gmdate(D, d M Y H:i:s, mktime(date(H)+2, date(i), date(s), date(m), date(d), date(Y) ) ) . GMT\r\n); print(Last-Modified: . gmdate(D, d M Y H:i:s). GMT\r\n); //print(Cache-Control: no-cache, must-revalidate\r\n); //print(Pragma: no-cache\r\n); if ($fh = fopen($file['filelocation'], 'rb')) { while(!feof($fh) and (connection_status()==0)) { print(fread($fh, 1024*8)); flush(); } $status = (connection_status()==0); fclose($fh); } return($status); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect after download
I am writing a file download system and I need to be able to do a redirect after the download is finished. Basically, the user will be presented with a simple HTML page that contains a link to download the file (href=/download.php?fileid=143). I have the code to send the file working just fine, but I can not figure out how to do a redirect after the download is complete. I have spent the last hour searching the archives, and the closest I have found is: http://marc.theaimsgroup.com/?l=php-generalm=106128750620349w=2 But I can't seem to find a way to actually do a Location style redirect. Even static HTML does not display the way one would expect. Using a small text file to download, I can view source from NS and see the everything that was sent to the browser, and everything is there (the ---Boundary(s), the text file, and the simple HTML line). So my question is: How can I perform a redirect after the file has been sent. Thanks, Justin Here is a snippit of download.php (send_file() was found reading the comments to the fread function in the PHP documention): header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\); if(!send_file($file)) { die(File transfer failed!); exit; }else{ print(\n); print(---Boundary-12399\r\n); print(Content-Type: text/html\r\n); print(\r\n); print htmlheadtitleSuccess/title/headbodybFile transfer s uccessful!/b/body/html; print(\r\n---Boundary-12399\r\n); print(\r\n); exit; } function send_file($file) { // read file and send to user $status = FALSE; if ( (!is_file($file['filelocation'])) or (connection_status()!=0) ) return(FALSE); print(---Boundary-12399\r\n); print(Content-type: application/octet-stream\r\n); print(Content-Disposition: inline; filename=\ . $file['filename'] . \\r\n); print(Content-length: . $file['filesize'] . \r\n); print(Expires: . gmdate(D, d M Y H:i:s, mktime(date(H)+2, date(i), date(s), date(m), date(d), date(Y) ) ) . GMT\r\n); print(Last-Modified: . gmdate(D, d M Y H:i:s). GMT\r\n); //print(Cache-Control: no-cache, must-revalidate\r\n); //print(Pragma: no-cache\r\n); if ($fh = fopen($file['filelocation'], 'rb')) { while(!feof($fh) and (connection_status()==0)) { print(fread($fh, 1024*8)); flush(); } $status = (connection_status()==0); fclose($fh); } return($status); } How about go directly to the site where you want to locate and make there the file downloadable... ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect after download
have you considered attempting to use header(Location: .$URL); where $URL contains the URL AFTER putting ob_start(); at the top of the php file? - Original Message - From: Justin England [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 4:07 AM Subject: [PHP] Redirect after download I am writing a file download system and I need to be able to do a redirect after the download is finished. Basically, the user will be presented with a simple HTML page that contains a link to download the file (href=/download.php?fileid=143). I have the code to send the file working just fine, but I can not figure out how to do a redirect after the download is complete. I have spent the last hour searching the archives, and the closest I have found is: http://marc.theaimsgroup.com/?l=php-generalm=106128750620349w=2 But I can't seem to find a way to actually do a Location style redirect. Even static HTML does not display the way one would expect. Using a small text file to download, I can view source from NS and see the everything that was sent to the browser, and everything is there (the ---Boundary(s), the text file, and the simple HTML line). So my question is: How can I perform a redirect after the file has been sent. Thanks, Justin Here is a snippit of download.php (send_file() was found reading the comments to the fread function in the PHP documention): header(Content-Type: multipart/mixed; boundary=\-Boundary-12399\); if(!send_file($file)) { die(File transfer failed!); exit; }else{ print(\n); print(---Boundary-12399\r\n); print(Content-Type: text/html\r\n); print(\r\n); print htmlheadtitleSuccess/title/headbodybFile transfer s uccessful!/b/body/html; print(\r\n---Boundary-12399\r\n); print(\r\n); exit; } function send_file($file) { // read file and send to user $status = FALSE; if ( (!is_file($file['filelocation'])) or (connection_status()!=0) ) return(FALSE); print(---Boundary-12399\r\n); print(Content-type: application/octet-stream\r\n); print(Content-Disposition: inline; filename=\ . $file['filename'] . \\r\n); print(Content-length: . $file['filesize'] . \r\n); print(Expires: . gmdate(D, d M Y H:i:s, mktime(date(H)+2, date(i), date(s), date(m), date(d), date(Y) ) ) . GMT\r\n); print(Last-Modified: . gmdate(D, d M Y H:i:s). GMT\r\n); //print(Cache-Control: no-cache, must-revalidate\r\n); //print(Pragma: no-cache\r\n); if ($fh = fopen($file['filelocation'], 'rb')) { while(!feof($fh) and (connection_status()==0)) { print(fread($fh, 1024*8)); flush(); } $status = (connection_status()==0); fclose($fh); } return($status); } -- 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] uploading 'large' files (e.g. 6MB) - tmp_name is empty?..
Hi, When uploading 'large' files of (for example 6MB) I have a problem that after uploading to the tmp folder on the server (so when the php script is called), the tmp_name in the FILES global is empty. So this means I can't do a move uploaded file because I don't know where the tmp file is. Any idea why php 'resets' the tmp_name when uploading large files (aka when uploading just takes a minute or two). Thanks in advance!! Regards, Nico -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading 'large' files (e.g. 6MB) - tmp_name is empty?..
Nico Veenman wrote: Hi, When uploading 'large' files of (for example 6MB) I have a problem that after uploading to the tmp folder on the server (so when the php script is called), the tmp_name in the FILES global is empty. So this means I can't do a move uploaded file because I don't know where the tmp file is. Any idea why php 'resets' the tmp_name when uploading large files (aka when uploading just takes a minute or two). Did you check these php settings? * upload_max_filesize * post_max_size * max_input_time -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Exec() command on UNIX
Dear PHP support, I have a question on an exec() command, if I would like to switch user right on Unix server, what command should I use? example: on the UNIX shell will be like below $su root Password:'password' but when I tried running exec() command on PHP, I couldn't do that exec(su root); I can't sent a password thru the exec() command, any way to do that? Thank you very much Sitthipong Thuetham [EMAIL PROTECTED]mailto:[EMAIL PROTECTED]
[PHP] PHP Heap
Hi, I searched the web but couldn't find an implementation class of HEAP in PHP. If someone has anything that is like, please let me know. Thanks in advance :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Heap implementation
Hi, I searched the web but couldn't find an implementation class of HEAP in PHP. If someone has anything that is like, please let me know. Thanks in advance :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Header's download
Hello. I use: Header(Content-Type: application/download); Header(Content-Disposition: attachment; filename=export.txt); Then after this is done I know that I can write stuff to the file like this: Echo This will be a line in my file\n; I am standing in a GUI containing frames. So I want to give an administrator the rights to choose what to export. My problem is that when I include the php file download.php, the HTML\JAVA code are written to the file. download.php are containing the headers. All the export data are written to the file, but also HTML\JAVA. How can I get around this problem? I would be very happy if someone has a solution. Regards Christian Johansson The solution: Use ob_clean()to emty the buffer, Before you use the headers: ob_clean(); Header(Content-Type: application/download); Header(Content-Disposition: attachment; filename=export.txt); http://no2.php.net/manual/en/function.ob-clean.php That's it! Regards Christian Johansson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Software patents
Will the adoption and legalization of software patents actually threaten the activity of PHP software developers? I see some people quite worried about this, e.g. at http://www.knoppix.org and http://swpat.ffii.org/index.en.html Alberto Brea
RE: [PHP] Very fresh to php
I think it was Darth Moeder PHP, I am your mother, *heavely breathing* (for those who don't speak dutch: Vader is 'father' and Moeder is 'mother') -Original Message- From: Santa [mailto:[EMAIL PROTECTED] Sent: woensdag 1 december 2004 9:29 To: [EMAIL PROTECTED] Subject: Re: [PHP] Very fresh to php 01 2004 07:45 suneel (a): Hi...guys, I'm a new bee to php. Could any one tell me that who is the father of php? take care guys, and who is mother? 8) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Software patents
No On 1 Dec 2004, at 15:37, abrea wrote: Will the adoption and legalization of software patents actually threaten the activity of PHP software developers? I see some people quite worried about this, e.g. at http://www.knoppix.org and http://swpat.ffii.org/index.en.html Alberto Brea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] transparant session propagation and headers
hi all, If a client doen't accept cookies and transparant session propagation is enabled, links are changed to include the SID. But this is not the case while redirecting clients. This results in session loss unless you manually add the session id to the redirect url. Not really transparant... I was wondering if this is correct behavior or a bug in php. currently this happens for sure with os x server php 4.3.2 - 4.3.9, but i have seen it before... bas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exec() command on UNIX
On Wed, 1 Dec 2004 16:18:01 +0700, Sitthipong Thuetham [EMAIL PROTECTED] wrote: Dear PHP support, I have a question on an exec() command, if I would like to switch user right on Unix server, what command should I use? example: on the UNIX shell will be like below $su root Password:'password' but when I tried running exec() command on PHP, I couldn't do that exec(su root); I can't sent a password thru the exec() command, any way to do that? You might want to look at sudo, you can provide temporary root access with no password. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] constructing class
Hi, I want to create an instance of a class and construct it with different params. The class name is a variable and the params change in each class. Is there a way to pass params to the constructor of a class like you pass params in the function call_user_func_array() ? BTW, there's a solution for it using eval, but looking for a better cleaner way... With eval: $cls=MyClass; $construct_params=array(10,true); $eval_str=return new $cls(; for ($i=0; $icount($construct_params); $i++) $eval_str.=\$construct_params[$i],; $eval_str=substr($eval_str,-1).);; $obj=eval($eval_str); thanks in advance, Lorderon. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: constructing class
* Lorderon [EMAIL PROTECTED]: I want to create an instance of a class and construct it with different params. The class name is a variable and the params change in each class. Is there a way to pass params to the constructor of a class like you pass params in the function call_user_func_array() ? Why don't you just pass an associative array as the second argument? Then you can have each class' constructor figure out what it needs from the array. -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] constructing class
Hi, I want to create an instance of a class and construct it with different params. The class name is a variable and the params change in each class. Is there a way to pass params to the constructor of a class like you pass params in the function call_user_func_array() ? BTW, there's a solution for it using eval, but looking for a better cleaner way... With eval: $cls=MyClass; $construct_params=array(10,true); $eval_str=return new $cls(; for ($i=0; $icount($construct_params); $i++) $eval_str.=\$construct_params[$i],; $eval_str=substr($eval_str,-1).);; $obj=eval($eval_str); thanks in advance, Lorderon. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Referencing Multi Dimensional Arrays
Hi, I've kind of solved this question already using recursion but I recon (in the grand tradition) that someone has a better solution! I have an multi dimensional array that is of variable depth, a snippet is shown below. The problem is that I don't know how deep the array goes as any entry can contain further entries which can contain further entries and as the array grows the data is increasingly unknown. My first thought was to use variable variables but the following doesn't work: $Network = array(--as-below--); $MyKey = [allocations][network][0]; print $Network[$$MyKey]; Now the obvious use of print $Network[$$key1][$$key2]; won't work for me as sometimes I need to be two layers deep and other times five. As I mentioned I've solved this problem using recursive functions but it's all a bit nasty. I've knicked various functions from the php site to search multi-dimensional arrays and can return myself an array of keys leading to the item I'm after but I can't seem to use that array to reference the data! All/any solutions or pointers (no pun intended) welcome. Kind regards Matthew Array ( [allocations] = Array ( [network] = Array ( [0] = Array ( [address] = 10.0.0.0 [netbits] = 8 [name] = TEST [creationdate] = 20041124 [description] = Test Address Space [security] = Array ( [alloc] = intech [subnet] = intech [unalloc] = intech ) [free] = Array ( [0] = Array ( [netbits] = 9 [address] = 10.128.0.0 [creationdate] = 20041125 ) [1] = Array ( [netbits] = 10 [address] = 10.64.0.0 [creationdate] = 20041125 ) ) [network] = Array ( [0] = Array ( [address] = 10.0.0.0 [netbits] = 24 [name] = MAFFNET [creationdate] = 20041125 [security] = Array ( [alloc] = intech [subnet] = intech [unalloc] = intech ) [description] = A Test network [free] = Array ( [address] = 10.0.0.0 [netbits] = 24 [creationdate] = 20041125 ) ) ) ) ) ) This message has been checked for all known viruses by the CitC Virus Scanning Service powered by SkyLabs. For further information visit http://www.citc.it ___ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Referencing Multi Dimensional Arrays
On Thursday 02 December 2004 01:14, Robinson, Matthew wrote: I've kind of solved this question already using recursion but I recon (in the grand tradition) that someone has a better solution! I have an multi dimensional array that is of variable depth, a snippet is shown below. The problem is that I don't know how deep the array goes as any entry can contain further entries which can contain further entries and as the array grows the data is increasingly unknown. My first thought was to use variable variables but the following doesn't work: Sorry if I missed it, what was the question? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* If we all work together, we can totally disrupt the system. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Referencing Multi Dimensional Arrays
On Wed, 1 Dec 2004 17:14:56 -, Robinson, Matthew [EMAIL PROTECTED] wrote: I've kind of solved this question already using recursion but I recon (in the grand tradition) that someone has a better solution! Recursion and is_array() is the way I'd parse through it. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parse error: parse error, expecting `']'' in
Parse error: parse error, expecting `']'' in file.php I've been working on this script, and can't see why it fails here, but I have another page that uses the same coding and it works correctly. OK, here's the code: $cart1 = ; $cart1 = '$_POST[nutrition_program_assistant]','$_POST[County]','$_POST[ERS_entry_date]','$_POST[ERS_exit_date]','$_POST[Group_ID]','$_POST[wname_of_group]','$_POST[select]','$_POST[Contact_person]','$_POST[Telephone]','$_POST[Group_Address]','$_POST[city]','$_POST[zip]','$_POST[Volunteer_1]','$_POST[Volunteer_2]','$_POST[Volunteer_3]','$_POST[Volunteer_4]','$_POST[Program_start_date]','$_POST[Projected_end_date]','$_POST[Actual_end_date]','$_POST[Eval_Pre_test]','$_POST[Eval_post_test]','$_POST[number_meetings]','$_POST[number_contact_hours]','$_POST[wname_1]','$_POST[sex_1]','$_POST[race_1]','$_POST[res_1]','$_POST[bday_mo_1]','$_POST[bday_day_1]','$_POST[bday_yr_1]','$_POST[grade_1]','$_POST[4_h_1]','$_POST[wname_2]','$_POST[sex_2]','$_POST[race_2]','$_POST[res_2]','$_POST[bday_mo_2]','$_POST[bday_day_2]','$_POST[bday_yr_2]','$_POST[grade_2]','$_POST[4_h_2]','$_POST[wname_3]','$_POST[sex_3]','$_POST[race_3]','$_POST[res_3]','$_POST[bday_mo_3]','$_POST[bday_day_3]','$_POST[bday_yr _3]','$_POST[grade_3]','$_POST[4_h_3]','$_POST[wname_4]','$_POST[sex_4]','$_POST[race_4]','$_POST[res_4]','$_POST[bday_mo_4]','$_POST[bday_day_4]','$_POST[bday_yr_4]','$_POST[grade_4]','$_POST[4_h_4]','$_POST[wname_5]','$_POST[sex_5]','$_POST[race_5]','$_POST[res_5]','$_POST[bday_mo_5]','$_POST[bday_day_5]','$_POST[bday_yr_5]','$_POST[grade_5]','$_POST[4_h_5]','$_POST[wname_6]','$_POST[sex_6]','$_POST[race_6]','$_POST[res_6]','$_POST[bday_mo_6]','$_POST[bday_day_6]','$_POST[bday_yr_6]'; $cart2 = ; $cart2 = '$_POST[grade_6]','$_POST[4_h_6]','$_POST[wname_7]','$_POST[sex_7]','$_POST[race_7]','$_POST[res_7]','$_POST[bday_mo_7]','$_POST[bday_day_7]','$_POST[bday_yr_7]','$_POST[grade_7]','$_POST[4_h_7]','$_POST[wname_8]','$_POST[sex_8]','$_POST[race_8]','$_POST[res_8]','$_POST[bday_mo_8]','$_POST[bday_day_8]','$_POST[bday_yr_8]','$_POST[grade_8]','$_POST[4_h_8]','$_POST[wname_9]','$_POST[sex_9]','$_POST[race_9]','$_POST[res_9]','$_POST[bday_mo_9]','$_POST[bday_day_9]','$_POST[bday_yr_9]','$_POST[grade_9]','$_POST[4_h_9]','$_POST[wname_10]','$_POST[sex_10]','$_POST[race_10]','$_POST[res_10]','$_POST[bday_mo_10]','$_POST[bday_day_10]','$_POST[bday_yr_10]','$_POST[grade_10]','$_POST[4_h_10]','$_POST[Attend_1_1]','$_POST[Attend_2_1]','$_POST[Attend_3_1]','$_POST[Attend_4_1]','$_POST[Attend_5_1]','$_POST[Attend_6_1]','$_POST[Attend_7_1]','$_POST[Attend_8_1]','$_POST[Attend_9_1]','$_POST[Attend_10_1]','$_POST[Attend_1_2]','$_POST[Attend_2_2]','$_POST[Attend_3_2]','$_POST[Attend_4_2]','$ _POST[Attend_5_2]','$_POST[Attend_6_2]','$_POST[Attend_7_2]','$_POST[Attend_8_2]','$_POST[Attend_9_2]','$_POST[Attend_10_2]','$_POST[Attend_1_3]','$_POST[Attend_2_3]','$_POST[Attend_3_3]','$_POST[Attend_4_3]','$_POST[Attend_5_3]','$_POST[Attend_6_3]','$_POST[Attend_7_3]','$_POST[Attend_8_3]','$_POST[Attend_9_3]','$_POST[Attend_10_3]','$_POST[Attend_1_4]','$_POST[Attend_2_4]','$_POST[Attend_3_4]','$_POST[Attend_4_4]','$_POST[Attend_5_4]','$_POST[Attend_6_4]','$_POST[Attend_7_4]','$_POST[Attend_8_4]','$_POST[Attend_9_4]','$_POST[Attend_10_4]','$_POST[Attend_1_5]','$_POST[Attend_2_5]','$_POST[Attend_3_5]','$_POST[Attend_4_5]','$_POST[Attend_5_5]','$_POST[Attend_6_5]','$_POST[Attend_7_5]','$_POST[Attend_8_5]','$_POST[Attend_9_5]','$_POST[Attend_10_5]','$_POST[Attend_1_6]','$_POST[Attend_2_6]','$_POST[Attend_3_6]','$_POST[Attend_4_6]','$_POST[Attend_5_6]','$_POST[Attend_6_6]','$_POST[Attend_7_6]','$_POST[Attend_8_6]','$_POST[Attend_9_6]','$_POST[Attend_10_6]','$_POST[Attend_1_7]', '$_POST[Attend_2_7]','$_POST[Attend_3_7]','$_POST[Attend_4_7]','$_POST[Attend_5_7]','$_POST[Attend_6_7]','$_POST[Attend_7_7]','$_POST[Attend_8_7]','$_POST[Attend_9_7]','$_POST[Attend_10_7]','$_POST[Attend_1_8]','$_POST[Attend_2_8]','$_POST[Attend_3_8]','$_POST[Attend_4_8]','$_POST[Attend_5_8]','$_POST[Attend_6_8]','$_POST[Attend_7_8]','$_POST[Attend_8_8]','$_POST[Attend_9_8]','$_POST[Attend_10_8]','$_POST[Attend_1_9]','$_POST[Attend_2_9]','$_POST[Attend_3_9]','$_POST[Attend_4_9]','$_POST[Attend_5_9]','$_POST[Attend_6_9]','$_POST[Attend_7_9]','$_POST[Attend_8_9]','$_POST[Attend_9_9]','$_POST[Attend_10_9]','$_POST[Attend_1_10]','$_POST[Attend_2_10]','$_POST[Attend_3_10]','$_POST[Attend_4_10]','$_POST[Attend_5_10]','$_POST[Attend_6_10]','$_POST[Attend_7_10]','$_POST[Attend_8_10]','$_POST[Attend_9_10]','$_POST[Attend_10_10]','$_POST[TE_CT_1]','$_POST[TE_CTL_1]','$_POST[TE_CT_2]','$_POST[TE_CTL_2]','$_POST[TE_CT_3]','$_POST[TE_CTL_3]','$_POST[TE_D_1]','$_POST[TE_LT_1]','$_POST[TE_ A_1]','$_POST[TE_FA_1]','$_POST[TE_H_1]'; $cart3 = ; $cart3 =
RE: [PHP] Referencing Multi Dimensional Arrays
lol, perhaps embedded a bit too deep in my pre-amble. My question is simply what's a good way to reference a given array entry when you don't know where it is or how deep the array is. I can do a multi dimensional array search and return an array of keys to locate the item, I then want to use that array of keys to be able to reference the data to perhaps do work on it ie: The array is a collection of network data that can consist of address allocation entries or other networks which can contain either more networks or allocations. I call my search function to locate a particular network which returns me an array of keys to locate that entry. I then want to pass that to another function to actually work on the data. I have a search function: $search_result = multi_array_search($net_array,needle); now search_result equals an array of keys to locate the needle, this is variable in count. Sometimes the array of keys is 3 entries other times 5, I want a way of taking those entries and being able to do something like: $net_array[multi-dimensional-key] = value; where sometimes it might be in longhand: $net_array[net1][net2][address1] or other times: $net_array[net1][address1] but you don't know how deep you're going until the search returns you the keys. Hope that clears things a bit! Kind regards Matthew -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: 01 December 2004 17:23 To: [EMAIL PROTECTED] Subject: Re: [PHP] Referencing Multi Dimensional Arrays Sorry if I missed it, what was the question? This message has been checked for all known viruses by the CitC Virus Scanning Service powered by SkyLabs. For further information visit http://www.citc.it ___ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Errors
I am very new to PHP been working on a script to access MySql have got it down pretty good, but, being lazy I like to copy code to not have to re-write it, I am now getting a constant flood of errors. I have looked in my book I have searched on the php site and have had no luck. WHAT IN THE HECK IS A T_ error. I get T_Else, T_Variable, T_what ever. What does it mean Very frustrated old man. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse error: parse error, expecting `']'' in
Parse error: parse error, expecting `']'' in file.php I've been working on this script, and can't see why it fails here, but I have another page that uses the same coding and it works correctly. OK, here's the code: $cart1 = ; $cart1 = '$_POST[nutrition_program_assistant]','$_POST[County]','$_POST[ERS_entry_d ate]','$_POST[ERS_exit_date]','$_POST[Group_ID]','$_POST[wname_of_group]','$ _POST[select]','$_POST[Contact_person]','$_POST[Telephone]','$_POST[Group_Ad dress]','$_POST[city]','$_POST[zip]','$_POST[Volunteer_1]','$_POST[Volunteer _2]','$_POST[Volunteer_3]','$_POST[Volunteer_4]','$_POST[Program_start_date] ','$_POST[Projected_end_date]','$_POST[Actual_end_date]','$_POST[Eval_Pre_te st]','$_POST[Eval_post_test]','$_POST[number_meetings]','$_POST[number_conta ct_hours]','$_POST[wname_1]','$_POST[sex_1]','$_POST[race_1]','$_POST[res_1] ','$_POST[bday_mo_1]','$_POST[bday_day_1]','$_POST[bday_yr_1]','$_POST[grade _1]','$_POST[4_h_1]','$_POST[wname_2]','$_POST[sex_2]','$_POST[race_2]','$_P OST[res_2]','$_POST[bday_mo_2]','$_POST[bday_day_2]','$_POST[bday_yr_2]','$_ POST[grade_2]','$_POST[4_h_2]','$_POST[wname_3]','$_POST[sex_3]','$_POST[rac e_3]','$_POST[res_3]','$_POST[bday_mo_3]','$_POST[bday_day_3]','$_POST[bday_ yr _3]','$_POST[grade_3]','$_POST[4_h_3]','$_POST[wname_4]','$_POST[sex_4]','$ _POST[race_4]','$_POST[res_4]','$_POST[bday_mo_4]','$_POST[bday_day_4]','$_P OST[bday_yr_4]','$_POST[grade_4]','$_POST[4_h_4]','$_POST[wname_5]','$_POST[ sex_5]','$_POST[race_5]','$_POST[res_5]','$_POST[bday_mo_5]','$_POST[bday_da y_5]','$_POST[bday_yr_5]','$_POST[grade_5]','$_POST[4_h_5]','$_POST[wname_6] ','$_POST[sex_6]','$_POST[race_6]','$_POST[res_6]','$_POST[bday_mo_6]','$_PO ST[bday_day_6]','$_POST[bday_yr_6]'; $cart2 = ; $cart2 = '$_POST[grade_6]','$_POST[4_h_6]','$_POST[wname_7]','$_POST[sex_7]','$_POS T[race_7]','$_POST[res_7]','$_POST[bday_mo_7]','$_POST[bday_day_7]','$_POST[ bday_yr_7]','$_POST[grade_7]','$_POST[4_h_7]','$_POST[wname_8]','$_POST[sex_ 8]','$_POST[race_8]','$_POST[res_8]','$_POST[bday_mo_8]','$_POST[bday_day_8] ','$_POST[bday_yr_8]','$_POST[grade_8]','$_POST[4_h_8]','$_POST[wname_9]','$ _POST[sex_9]','$_POST[race_9]','$_POST[res_9]','$_POST[bday_mo_9]','$_POST[b day_day_9]','$_POST[bday_yr_9]','$_POST[grade_9]','$_POST[4_h_9]','$_POST[wn ame_10]','$_POST[sex_10]','$_POST[race_10]','$_POST[res_10]','$_POST[bday_mo _10]','$_POST[bday_day_10]','$_POST[bday_yr_10]','$_POST[grade_10]','$_POST[ 4_h_10]','$_POST[Attend_1_1]','$_POST[Attend_2_1]','$_POST[Attend_3_1]','$_P OST[Attend_4_1]','$_POST[Attend_5_1]','$_POST[Attend_6_1]','$_POST[Attend_7_ 1]','$_POST[Attend_8_1]','$_POST[Attend_9_1]','$_POST[Attend_10_1]','$_POST[ Attend_1_2]','$_POST[Attend_2_2]','$_POST[Attend_3_2]','$_POST[Attend_4_2]', '$ _POST[Attend_5_2]','$_POST[Attend_6_2]','$_POST[Attend_7_2]','$_POST[Attend _8_2]','$_POST[Attend_9_2]','$_POST[Attend_10_2]','$_POST[Attend_1_3]','$_PO ST[Attend_2_3]','$_POST[Attend_3_3]','$_POST[Attend_4_3]','$_POST[Attend_5_3 ]','$_POST[Attend_6_3]','$_POST[Attend_7_3]','$_POST[Attend_8_3]','$_POST[At tend_9_3]','$_POST[Attend_10_3]','$_POST[Attend_1_4]','$_POST[Attend_2_4]',' $_POST[Attend_3_4]','$_POST[Attend_4_4]','$_POST[Attend_5_4]','$_POST[Attend _6_4]','$_POST[Attend_7_4]','$_POST[Attend_8_4]','$_POST[Attend_9_4]','$_POS T[Attend_10_4]','$_POST[Attend_1_5]','$_POST[Attend_2_5]','$_POST[Attend_3_5 ]','$_POST[Attend_4_5]','$_POST[Attend_5_5]','$_POST[Attend_6_5]','$_POST[At tend_7_5]','$_POST[Attend_8_5]','$_POST[Attend_9_5]','$_POST[Attend_10_5]',' $_POST[Attend_1_6]','$_POST[Attend_2_6]','$_POST[Attend_3_6]','$_POST[Attend _4_6]','$_POST[Attend_5_6]','$_POST[Attend_6_6]','$_POST[Attend_7_6]','$_POS T[Attend_8_6]','$_POST[Attend_9_6]','$_POST[Attend_10_6]','$_POST[Attend_1_7 ]', '$_POST[Attend_2_7]','$_POST[Attend_3_7]','$_POST[Attend_4_7]','$_POST[Atte nd_5_7]','$_POST[Attend_6_7]','$_POST[Attend_7_7]','$_POST[Attend_8_7]','$_P OST[Attend_9_7]','$_POST[Attend_10_7]','$_POST[Attend_1_8]','$_POST[Attend_2 _8]','$_POST[Attend_3_8]','$_POST[Attend_4_8]','$_POST[Attend_5_8]','$_POST[ Attend_6_8]','$_POST[Attend_7_8]','$_POST[Attend_8_8]','$_POST[Attend_9_8]', '$_POST[Attend_10_8]','$_POST[Attend_1_9]','$_POST[Attend_2_9]','$_POST[Atte nd_3_9]','$_POST[Attend_4_9]','$_POST[Attend_5_9]','$_POST[Attend_6_9]','$_P OST[Attend_7_9]','$_POST[Attend_8_9]','$_POST[Attend_9_9]','$_POST[Attend_10 _9]','$_POST[Attend_1_10]','$_POST[Attend_2_10]','$_POST[Attend_3_10]','$_PO ST[Attend_4_10]','$_POST[Attend_5_10]','$_POST[Attend_6_10]','$_POST[Attend_ 7_10]','$_POST[Attend_8_10]','$_POST[Attend_9_10]','$_POST[Attend_10_10]','$ _POST[TE_CT_1]','$_POST[TE_CTL_1]','$_POST[TE_CT_2]','$_POST[TE_CTL_2]','$_P OST[TE_CT_3]','$_POST[TE_CTL_3]','$_POST[TE_D_1]','$_POST[TE_LT_1]','$_POST[ TE_ A_1]','$_POST[TE_FA_1]','$_POST[TE_H_1]'; $cart3 = ; $cart3 = '$_POST[TE_D_2]','$_POST[TE_LT_2]','$_POST[TE_A_2]','$_POST[TE_FA_2]','$_P OST[TE_H_2]','$_POST[TE_D_3]','$_POST[TE_LT_3]','$_POST[TE_A_3]','$_POST[TE_
Re: [PHP] Errors
On Wed, 1 Dec 2004 10:44:00 -0700, olsofty [EMAIL PROTECTED] wrote: I am very new to PHP been working on a script to access MySql have got it down pretty good, but, being lazy I like to copy code to not have to re-write it, I am now getting a constant flood of errors. I have looked in my book I have searched on the php site and have had no luck. WHAT IN THE HECK IS A T_ error. I get T_Else, T_Variable, T_what ever. What does it mean Very frustrated old man. Where's the code? -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Errors
Greg Donald wrote: On Wed, 1 Dec 2004 10:44:00 -0700, olsofty [EMAIL PROTECTED] wrote: I am very new to PHP been working on a script to access MySql have got it down pretty good, but, being lazy I like to copy code to not have to re-write it, I am now getting a constant flood of errors. I have looked in my book I have searched on the php site and have had no luck. WHAT IN THE HECK IS A T_ error. I get T_Else, T_Variable, T_what ever. What does it mean Very frustrated old man. Where's the code? T_* errors are parse-errors. Basically, the parser checks (parses) the syntax before running the script, during this parsing, the parser might find a syntax error. All those T_* parts stand for specific keywords/parts of the PHP syntax. When the parser tells you it found an unexpected T_STRING, it means that the parser found a string where it doesn't expect one. Same thing for eg T_ELSE (an else statement where one shouldn't be). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Referencing Multi Dimensional Arrays
On Thursday 02 December 2004 01:31, Robinson, Matthew wrote: lol, perhaps embedded a bit too deep in my pre-amble. My question is simply what's a good way to reference a given array entry when you don't know where it is or how deep the array is. I can do a multi dimensional array search and return an array of keys to locate the item, I then want to use that array of keys to be able to reference the data to perhaps do work on it ie: The array is a collection of network data that can consist of address allocation entries or other networks which can contain either more networks or allocations. I call my search function to locate a particular network which returns me an array of keys to locate that entry. I then want to pass that to another function to actually work on the data. I have a search function: $search_result = multi_array_search($net_array,needle); now search_result equals an array of keys to locate the needle, this is variable in count. Sometimes the array of keys is 3 entries other times 5, I want a way of taking those entries and being able to do something like: $net_array[multi-dimensional-key] = value; where sometimes it might be in longhand: $net_array[net1][net2][address1] or other times: $net_array[net1][address1] but you don't know how deep you're going until the search returns you the keys. Hope that clears things a bit! Certainly a lot clearer. The only (easy) method I can think of is to use eval(), something like: $MyKey = [allocations][network][0]; $MyKey = '$net_array' . $MyKey; eval(\$val = $MyKey;); print_r($val); Another more messy method would be to use something like preg_match_all() to grab the individual array keys, ie 'allocations', 'network', '0' then: switch (number of indices) { case 1 : $val = $net_array[$idx1]; break; case 2 : $val = $net_array[$idx1][$idx2]; break; ... } -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Is this the line for the latest whimsical YUGOSLAVIAN drama which also makes you want to CRY and reconsider the VIETNAM WAR? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Errors
On Thursday 02 December 2004 01:44, olsofty wrote: I am very new to PHP been working on a script to access MySql have got it down pretty good, but, being lazy I like to copy code to not have to re-write it, I am now getting a constant flood of errors. I have looked in my book I have searched on the php site and have had no luck. WHAT IN THE HECK IS A T_ error. I get T_Else, T_Variable, T_what ever. What does it mean Very frustrated old man. manual Appendix P. List of Parser Tokens -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* love, n.: Love ties in a knot in the end of the rope. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Errors
Incorrect syntax. You likely have a set a variable and not ended it with ';' For example, $some_variable = some_value; is the proper syntax. Or, post the code as recommended. Best, Thomas S. Crum -Original Message- From: Greg Donald [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 1:25 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Errors On Wed, 1 Dec 2004 10:44:00 -0700, olsofty [EMAIL PROTECTED] wrote: I am very new to PHP been working on a script to access MySql have got it down pretty good, but, being lazy I like to copy code to not have to re-write it, I am now getting a constant flood of errors. I have looked in my book I have searched on the php site and have had no luck. WHAT IN THE HECK IS A T_ error. I get T_Else, T_Variable, T_what ever. What does it mean Very frustrated old man. Where's the code? -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.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] protecting class/include files
Hello All, I am looking for some advice on how to keep my class files protected. Here is the situation. We have a web system we have built that all of our clients use. Now each client has php files that include our classes. The classes are stored in a common folder. This folder is read accessible by all our clients so that their php files can include the classes. However our problem is that while we want to give our clients php include access to our classes, we do NOT want to them to be able to actually have access to our source code. For most of our clients this isn't a problem as they are not technical enough. However we do have a few savvy clients who might just decide to do a show_source or an fopen of the include files and steal our source code. I have looked around at a few of the encoders on the market and was wondering if that was my only option? Am I missing something simply with permissions or what not that would prevent users from viewing the source code of our class files? Thanks for your help! Stefan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse error: parse error, expecting `']'' in
Parse error: parse error, expecting `']'' in file.php I've been working on this script, and can't see why it fails here, but I have another page that uses the same coding and it works correctly. OK, here's the code: $cart1 = ; $cart1 = '$_POST[nutrition_program_assistant]','$_POST[County]','$_POST[ERS_entry_date]','$_POST[ERS_exit_date]','$_POST[Group_ID]','$_POST[wname_of_group]','$_POST[select]','$_POST[Contact_person]','$_POST[Telephone]','$_POST[Group_Address]','$_POST[city]','$_POST[zip]','$_POST[Volunteer_1]','$_POST[Volunteer_2]','$_POST[Volunteer_3]','$_POST[Volunteer_4]','$_POST[Program_start_date]','$_POST[Projected_end_date]','$_POST[Actual_end_date]','$_POST[Eval_Pre_test]','$_POST[Eval_post_test]','$_POST[number_meetings]','$_POST[number_contact_hours]','$_POST[wname_1]','$_POST[sex_1]','$_POST[race_1]','$_POST[res_1]','$_POST[bday_mo_1]','$_POST[bday_day_1]','$_POST[bday_yr_1]','$_POST[grade_1]','$_POST[4_h_1]','$_POST[wname_2]','$_POST[sex_2]','$_POST[race_2]','$_POST[res_2]','$_POST[bday_mo_2]','$_POST[bday_day_2]','$_POST[bday_yr_2]','$_POST[grade_2]','$_POST[4_h_2]','$_POST[wname_3]','$_POST[sex_3]','$_POST[race_3]','$_POST[res_3]','$_POST[bday_mo_3]','$_POST[bday_day_3]','$_POST[bday_yr _3]','$_POST[grade_3]','$_POST[4_h_3]','$_POST[wname_4]','$_POST[sex_4]','$_POST[race_4]','$_POST[res_4]','$_POST[bday_mo_4]','$_POST[bday_day_4]','$_POST[bday_yr_4]','$_POST[grade_4]','$_POST[4_h_4]','$_POST[wname_5]','$_POST[sex_5]','$_POST[race_5]','$_POST[res_5]','$_POST[bday_mo_5]','$_POST[bday_day_5]','$_POST[bday_yr_5]','$_POST[grade_5]','$_POST[4_h_5]','$_POST[wname_6]','$_POST[sex_6]','$_POST[race_6]','$_POST[res_6]','$_POST[bday_mo_6]','$_POST[bday_day_6]','$_POST[bday_yr_6]'; $cart2 = ; $cart2 = '$_POST[grade_6]','$_POST[4_h_6]','$_POST[wname_7]','$_POST[sex_7]','$_POST[race_7]','$_POST[res_7]','$_POST[bday_mo_7]','$_POST[bday_day_7]','$_POST[bday_yr_7]','$_POST[grade_7]','$_POST[4_h_7]','$_POST[wname_8]','$_POST[sex_8]','$_POST[race_8]','$_POST[res_8]','$_POST[bday_mo_8]','$_POST[bday_day_8]','$_POST[bday_yr_8]','$_POST[grade_8]','$_POST[4_h_8]','$_POST[wname_9]','$_POST[sex_9]','$_POST[race_9]','$_POST[res_9]','$_POST[bday_mo_9]','$_POST[bday_day_9]','$_POST[bday_yr_9]','$_POST[grade_9]','$_POST[4_h_9]','$_POST[wname_10]','$_POST[sex_10]','$_POST[race_10]','$_POST[res_10]','$_POST[bday_mo_10]','$_POST[bday_day_10]','$_POST[bday_yr_10]','$_POST[grade_10]','$_POST[4_h_10]','$_POST[Attend_1_1]','$_POST[Attend_2_1]','$_POST[Attend_3_1]','$_POST[Attend_4_1]','$_POST[Attend_5_1]','$_POST[Attend_6_1]','$_POST[Attend_7_1]','$_POST[Attend_8_1]','$_POST[Attend_9_1]','$_POST[Attend_10_1]','$_POST[Attend_1_2]','$_POST[Attend_2_2]','$_POST[Attend_3_2]','$_POST[Attend_4_2]','$ _POST[Attend_5_2]','$_POST[Attend_6_2]','$_POST[Attend_7_2]','$_POST[Attend_8_2]','$_POST[Attend_9_2]','$_POST[Attend_10_2]','$_POST[Attend_1_3]','$_POST[Attend_2_3]','$_POST[Attend_3_3]','$_POST[Attend_4_3]','$_POST[Attend_5_3]','$_POST[Attend_6_3]','$_POST[Attend_7_3]','$_POST[Attend_8_3]','$_POST[Attend_9_3]','$_POST[Attend_10_3]','$_POST[Attend_1_4]','$_POST[Attend_2_4]','$_POST[Attend_3_4]','$_POST[Attend_4_4]','$_POST[Attend_5_4]','$_POST[Attend_6_4]','$_POST[Attend_7_4]','$_POST[Attend_8_4]','$_POST[Attend_9_4]','$_POST[Attend_10_4]','$_POST[Attend_1_5]','$_POST[Attend_2_5]','$_POST[Attend_3_5]','$_POST[Attend_4_5]','$_POST[Attend_5_5]','$_POST[Attend_6_5]','$_POST[Attend_7_5]','$_POST[Attend_8_5]','$_POST[Attend_9_5]','$_POST[Attend_10_5]','$_POST[Attend_1_6]','$_POST[Attend_2_6]','$_POST[Attend_3_6]','$_POST[Attend_4_6]','$_POST[Attend_5_6]','$_POST[Attend_6_6]','$_POST[Attend_7_6]','$_POST[Attend_8_6]','$_POST[Attend_9_6]','$_POST[Attend_10_6]','$_POST[Attend_1_7]', '$_POST[Attend_2_7]','$_POST[Attend_3_7]','$_POST[Attend_4_7]','$_POST[Attend_5_7]','$_POST[Attend_6_7]','$_POST[Attend_7_7]','$_POST[Attend_8_7]','$_POST[Attend_9_7]','$_POST[Attend_10_7]','$_POST[Attend_1_8]','$_POST[Attend_2_8]','$_POST[Attend_3_8]','$_POST[Attend_4_8]','$_POST[Attend_5_8]','$_POST[Attend_6_8]','$_POST[Attend_7_8]','$_POST[Attend_8_8]','$_POST[Attend_9_8]','$_POST[Attend_10_8]','$_POST[Attend_1_9]','$_POST[Attend_2_9]','$_POST[Attend_3_9]','$_POST[Attend_4_9]','$_POST[Attend_5_9]','$_POST[Attend_6_9]','$_POST[Attend_7_9]','$_POST[Attend_8_9]','$_POST[Attend_9_9]','$_POST[Attend_10_9]','$_POST[Attend_1_10]','$_POST[Attend_2_10]','$_POST[Attend_3_10]','$_POST[Attend_4_10]','$_POST[Attend_5_10]','$_POST[Attend_6_10]','$_POST[Attend_7_10]','$_POST[Attend_8_10]','$_POST[Attend_9_10]','$_POST[Attend_10_10]','$_POST[TE_CT_1]','$_POST[TE_CTL_1]','$_POST[TE_CT_2]','$_POST[TE_CTL_2]','$_POST[TE_CT_3]','$_POST[TE_CTL_3]','$_POST[TE_D_1]','$_POST[TE_LT_1]','$_POST[TE_ A_1]','$_POST[TE_FA_1]','$_POST[TE_H_1]'; $cart3 = ; $cart3 =
[PHP] ScreenHeight?
Hi Is there any way of getting the clients screenheight in PHP? (or do I have to do it in Javascript) /Gustav Wiberg @varupiraten.se --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.802 / Virus Database: 545 - Release Date: 2004-11-26 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ScreenHeight?
Is there any way of getting the clients screenheight in PHP? (or do I have to do it in Javascript) You have to do it with JavaScript. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to tell if the filepath exist or not before attempting to create a directory??
I'm wondering how to tell if the filepath exist or not, that way, I don't create the directory if the filepath exist. I thought that the is_dir() is the way to go but found that it is not reliable. Thanks, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] protecting class/include files
Stefan Klopp wrote: show_source or an fopen of the include files and steal our source code. I have looked around at a few of the encoders on the market and was wondering if that was my only option? Am I missing something simply with permissions or what not that would prevent users from viewing the source code of our class files? You have not missed anything. If PHP can read the files, then PHP can read the files. That is a tautology. Thus, by definition, they can show_source or fopen the files. You can encode the files with one of the products you found, but you should also copyright your work, and have your clients sign an agreement that makes it VERY clear they should not use your proprietary code. History tells us that locking down source code with technological means will raise the bar but simply will not stop a deteremined person. A clear contractual agreement will also not necessarily stop all deteremined people either. It will, however, serve notice of your intent, and stop far more than one might think. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!
The directory folder where you upload the file(s) and folder(s) inito must have the ownership of Apache and the permission of 755. Then you'll have no trouble uploading file(s)/folder(s) into it since Apache would have the permission to create the file(s)/folder(s) where none exist or update them only if the file(s)/folder(s) was created by Apache in the past. If those file(s)/folder(s) weren't created by Apache but by you or someone then it wouldn't work because the ownership would be different, you'll need to change the ownership and permission to what Apache can use. This is from what I had noticed and had no trouble with them since then. When I move the files from 1 webserver to another, I alway check the ownership and correct it if it is wrong the first time. Scott Gareth Williams [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] You could try chown user:group, where user and group are those apache runs in. Is this script running on your own machine, or on a web server hosted somewhere? On 1 Dec 2004, at 09:03, Michael Leung wrote: Hi all, I am still solving my upload script problems. Here is the error Msg: Warning: copy(/var/www/html/upload_files/Default.bk1) [function.copy]: failed to open stream: Permission denied in /var/www/html/simple_upload.php on line 77 My Upload Code: $result = move_uploaded_file($temp_name, $file_path); I started to think this is not only PHP , may be Apache problem too. Anyone has some ideas? I have tried to set my upload directory into 777. Even I tried to use sudo , giving apache as root permission and running system command copy the file from the tmp directory to upload_files. but still no success!! I have done some research on web, no one can suggest a solution rather than chmod 777( I did that!) yours, michael -- 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] Errors
olsofty wrote: I am very new to PHP been working on a script to access MySql have got it down pretty good, but, being lazy I like to copy code to not have to re-write it, I am now getting a constant flood of errors. I have looked in my book I have searched on the php site and have had no luck. WHAT IN THE HECK IS A T_ error. I get T_Else, T_Variable, T_what ever. What does it mean Very frustrated old man. That's Geek for you typed something so wrong, I don't even know what you're trying to do Generally the line number is helpful. You know it is usually on that line, or the line before. But sometimes it's before that, maybe *WAY* before that, if the real problem is you are missing a quote mark somewhere. For sure, the problem CANNOT be *after* the line number PHP is complaining about. It reads the file line by line, and works out what you mean as it goes. You should probably invest time/money in finding a color-coded PHP syntax editor. There are so many of them, I won't even try to recommend one. Odds are good the editor you use right now has a PHP syntax color-coding plugin or feature, and you just haven't turned it on yet. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Errors
On Wed, 1 Dec 2004 11:51:33 -0800 (PST), Richard Lynch [EMAIL PROTECTED] wrote: That's Geek for you typed something so wrong, I don't even know what you're trying to do Man.. they let just about anyone post to php-general lately. :) How you doing Richard? -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parse error: parse error, expecting `']'' in
Robert Sossomon wrote: Parse error: parse error, expecting `']'' in file.php First, some minor nits with other posters :-) 1. While it's true that integer and string keys are handled differently in some cases, it has absolutely no bearing when the array reference is buried in a string. 2. The code formatting provided by another poster doesn't seem all that better to me than the original. YMMV. Then, a minor nit with the original poster: Dude, you chopped out the line number from the error message. That would pretty much have made it possible to determine what was going wrong, maybe. You probably left out a ']' somewhere, which is exactly what PHP is complaining about. It's also possible a missing quote or apostrophe in an EARLIER line is the real problem, and the code you posted, on its own, is 100% correct. Finally, to all newbie PHP coders. If syntax errors are giving you problems, then get a color-coding editor, or plug-in for the editor you are using. I'm too old to change my ways and use one, but I'm long past the day of wondering what any given syntax error could mean. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [PHP-WIN] filectime problems
I'm running PHP 5.0.2 on IIS 6/Windows Server 2003. Below is a snippet of the code from a script that looks into the news directory for files ending in .txt. After it finds the files, I want to get the creation time of each file. The script finds all the files (in this case blah.txt, but filectime gives me an error: Warning: filectime() [function.filectime]: stat failed for blah.txt in... (snip)... $dir = ../news/; $dh = opendir($dir); while (($filename = readdir($dh)) !== false) { if (strpos($filename, .txt)) { $time = filectime($filename); ... Any ideas why? The user that the webserver runs as, has full permissions to the news directory, and all the files in it. Kevin Glick ITS Manager Sterling Business Forms [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Referencing Multi Dimensional Arrays
Robinson, Matthew wrote: I've kind of solved this question already using recursion but I recon (in the grand tradition) that someone has a better solution! Recursion and http://php.net/is_array is probably the most clear-cut solution. If you are concerned that the arrays could become *S* deep and huge that rrecursion will blow up the stack, then most times you can take your straight-forward recursive algorithm, and convert it to an almost-as-straight-forward iterative algorithm. In fact, it's been proven that any tail recursion can be converted to iteration. Some terminology that may be meaningless to the Reader, loosely translated into English, partly for the amusement of Readers who do understand this terminology: blow up the stack - a function that calls itself so often that it ends up eating up the whole computer in a fit of self-indulgent gorging on its own beautiful voice. tail recursion - recursion where the function call to recurse is at the tail end of the function -- the last line, not counting closing brackets. iterative - a simple for or while loop PS The real solution may be to not store your data in that manner, as it clearly is giving you trouble... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] classes and variable scope
Hi all, If I have the following code: $some_global_variable; Class foo { Function test() { set_global(); echo $some_global_variable; } Function set_global () { $some_global_variable = abcd; echo $some_global_variable; } } The first echo statement (the one inside the set_global function) prints abcd, but the second prints nothing. How can I set the value of $some_global_variable inside the set_global function so that it sticks? I'm using PHP 4.3.3. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] constructing class
Lorderon wrote: I want to create an instance of a class and construct it with different params. The class name is a variable and the params change in each class. Is there a way to pass params to the constructor of a class like you pass params in the function call_user_func_array() ? PHP has built-in functions for constructor (and destructor in 5 (4.x?)). I don't think they take any arguments, however. You could write your own function, such as: $object = build('className', array('var1'='val1', 'var2'='val2')); function build($class, $fields){ $result = new $class(); while (list($k, $v) = each($fields)){ $result-$k = $v; } } There are also, in PHP 5, some nifty new setter and getter functions, so that you can write $result-$k($v) if that makes you feel better, or if you *NEED* to have the object call complex functions when the values are initialized. Hope that helps. For sure, the eval solution is pretty grungy and will give you headaches sooner or later. Or both sooner and later. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to tell if the filepath exist or not before attempting to create a directory??
Never mind that.. I found a different way to use it. It would be so cool if there is such a feature as directory_exists() to check for partical filepath... Scott Scott Fletcher [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm wondering how to tell if the filepath exist or not, that way, I don't create the directory if the filepath exist. I thought that the is_dir() is the way to go but found that it is not reliable. Thanks, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] transparant session propagation and headers
If a client doen't accept cookies and transparant session propagation is enabled, links are changed to include the SID. But this is not the case while redirecting clients. This results in session loss unless you manually add the session id to the redirect url. Not really transparant... I was wondering if this is correct behavior or a bug in php. Feature. There's no way PHP can know if you are re-directing to something where you want the sesssion propogated or not. [soapbox] Onee really shouldn't have *THAT* many redirects in one's code. Redirects were designed as part of the HTTP protocol for documents which *moved* from one Universal Resource Locater (URL) to another, to allow for the fact that sometimes documents have to be moved, and that Universal is not really really really Universal for all time. Using Redirect as a programming construct, in place of if/else/require etc is just Bad Programming. I realize a zillion programmers do it. I even was guilty of it myself in my early days of PHP programming. Because it worked. But it really makes code hard to read, hard to debug, and hard to follow in its logic. If you are using header(Location: ) as an error-trapping mechanism, or instead of if/else and a require to factor your code, re-think your Design. The hair you save may be your own. Or it might be mine, and I ain't got enough any more as it is. :-) [/soapbox] -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ScreenHeight?
Wiberg wrote: Hi Is there any way of getting the clients screenheight in PHP? (or do I have to do it in Javascript) PHP is serverside. JavaScript is your answer. -- John C. Nichel berGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exec() command on UNIX
Sitthipong Thuetham wrote: I have a question on an exec() command, if I would like to switch user right on Unix server, what command should I use? example: on the UNIX shell will be like below $su root Password:'password' but when I tried running exec() command on PHP, I couldn't do that exec(su root); I can't sent a password thru the exec() command, any way to do that? Probably best to use 'sudo' in the shell to make the script run with the rights of the user you want, or some similar shell-action. You may also want to examine the Apache 2 directives that let a Module (EG PHP) run as a specific user under certain circumstances. I have not investigated this avenue myself, but would surmise that you could restrict this to a specific script in a specific directory, and could give over the PHP thread to be run by some special user. While I'm not certain, I'd be willing to bet cold hard cash that doing this and using root as that special user is a REALLY BAD IDEA. You'd need to set up a new user with *JUST* enough permission on the system to do the bare minimum of what you need that user to do to get the task accomplished. If, however, you are stuck on a server where you don't HAVE access to a shell and/or httpd.conf... Well, first, start looking for a new host where you DO have access to a shell, at least. In the meantime, you can sometimes do like this: exec(echo _password_ | command $arg1 $arg2); Note, however, that su itself specifically prohibits doing this from a non TTY shell (EG from PHP) to prevent you from doing this inherently very dangerous action. Also note that depending on the version of PHP and other factors I never quite figured out back in the day (PHP 3 PHP 4) sometimes stdout/stdin were bound up by PHP and sometimes not, so that the shell echo and | trick would only work on some versions/servers. Some PHP Developers claimed this was simply not true, however, despite my experience. YMMV. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading 'large' files (e.g. 6MB) - tmp_name is empty?..
Nico Veenman wrote: Hi, When uploading 'large' files of (for example 6MB) I have a problem that after uploading to the tmp folder on the server (so when the php script is called), the tmp_name in the FILES global is empty. So this means I can't do a move uploaded file because I don't know where the tmp file is. Any idea why php 'resets' the tmp_name when uploading large files (aka when uploading just takes a minute or two). Note that you also get slightly/subtly different results between: Successful file upload. File too large (or too many) from php.ini settings. User canceled upload. User did not fill in upload box before submission. I forget the exact differences, and I'm not even certain this is documented behaviour, but you can write your script to behave differently if you're willing to risk maybe using an undocumented feature. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploading 'large' files (e.g. 6MB) - tmp_name is empty?..
On Wed, 1 Dec 2004 12:32:07 -0800 (PST), Richard Lynch [EMAIL PROTECTED] wrote: Note that you also get slightly/subtly different results between: Successful file upload. File too large (or too many) from php.ini settings. User canceled upload. User did not fill in upload box before submission. I forget the exact differences Here's a snippet of code I have to handle the errors you get back: switch($_FILES['newImage']['error']){ case 0: $submitSuccess = true; break; case 1: $submitError = true; $sizeError = 'Image exceeds the php.ini maximum size of ' . ini_get('upload_max_filesize') . 'br /'; break; case 2: $submitError = true; $sizeError = 'Image must be ' . IMAGE_MAX_IMAGE_SIZE . ' bytes or lessbr /'; break; case 3: $submitError = true; $uploadError = 'The uploaded file was only partially uploadedbr /'; case 4: $submitError = true; $uploadError = 'No file was uploadedbr /'; } -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirect after download
Justin England wrote: I am writing a file download system and I need to be able to do a redirect after the download is finished. The Redirect is sent as a header, before your download content. The browser is free to act on that Redirect header and IGNORE the file download content as soon as it sees the Redirect header. The assumption by the browser for a Redirect header is that you are using it for what it was desgined to mean: This document has moved. It should come as no surprise, then, that when you try to use the Redirect header to get the browser to do something entirely different from what the Redirect header was intended for, it doesn't work. :-) If you control both the page you are coming from and Redirecting to, you could have the destination page do the actual download, at least in theory. There again, not all browsers will work correctly when you try to cram a download into HTML output all in one response to a single HTTP request. So for those of use who use such browsers, *PLEASE* for the love of God, give us a normal friggin' link to click on to get what we want. Users with the fancy browsers will get their nifty download-and-transition-to-new-page experience. If you do not control the destination page, and can't make it do the download (along with a link for us Luddites) then you are pretty much stuck: You can't do that (Not reliably, anyway) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!
Hi all, I am still solving my upload script problems. Here is the error Msg: Warning: copy(/var/www/html/upload_files/Default.bk1) [function.copy]: failed to open stream: Permission denied in /var/www/html/simple_upload.php on line 77 My Upload Code: $result = move_uploaded_file($temp_name, $file_path); I started to think this is not only PHP , may be Apache problem too. Anyone has some ideas? I have tried to set my upload directory into 777. Even I tried to use sudo , giving apache as root permission and running system command copy the file from the tmp directory to upload_files. but still no success!! I have done some research on web, no one can suggest a solution rather than chmod 777( I did that!) Does the PHP user (aka the Apache user) have permission to *READ* from and *WRITE* to the TMP directory? You may be attacking the wrong side of the equation. I believe PHP will complain the same way whether it can't read/write /tmp, or it can't read/write to your destination directory. PS For God's sake change your permissions back to something reasonable, and stop running Apache as root, *NOW*. Actually, from a more practical stand-point, *change* your upload destination to some place *outside* the web tree, so that when PHP dumps stuff in there, possibly some stuff you don't *want* in there, possibly because some user is playing games with your site, then you can write some code to examine the content before doing anything with it -- Specifically *before* it ends up living on your public web-server. Example: Bad guy decides your server would be a nice place to upload not a worksheet, but his latest cracked video game or highly-popular software package or, ahem, graphic images. Then *your* server becomes a free source of illegal content, or content you are not in the business of hosting. That's bad. Real bad. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Manipulation
As was already mentioned, mktime() and strtotime() both return a serial date. I use mktime() a lot to add/subtract days and such. It automatically compensates for leap days and all that. Example: ?php $month = 1; $day = 31; $year = 2004; $serialdate = mktime(0,0,0,$month,$day + 1,$year); echo date(m/d/Y, $serialdate); ? This should output 2/1/2004 (unless I made a typo). The initial 0,0,0 are the hour, minute, second. It works equally well with any numbers you give it for any of those values and if you throw it back into the date() function, you can format the outputted date however you want. I know mktime and strtotime were already mentioned, but I think examples help too so pardon me for expanding on it. -TG -Original Message- From: Christopher Weaver [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 30, 2004 9:19 PM To: [EMAIL PROTECTED] Subject: [PHP] Date Manipulation I've looked at the date functions in the manual but can't find what I need. All I want to do is add and subtract days without ending up with bogus date values. IOW, Nov. 29 + 7 days shouldn't be Nov. 36. Just a nod in the write direction would be great. Thanks. -- 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] echo string with question mark in it
Brent Clements wrote: I have the following string variable $string = 'test.php?id=' . $id; but when I echo out the string it looks like this test.php? id=# ### is the $id variable value btw. How do I make the ? part of the string instead of php evaluating that question mark? I've tried adding \ before the ? but it doesn't work. PHP ain't doing nuthin' with that ?... Are you looking at this in a browser? Is ### realy long? Is it possible that the browser (or email client) seeing a realy long string, has no choice to break it in half *somewhere* and puts it on two lines. And, of course, given that string, the most natural (from a persepctive of the English language) break would be at the ? TIP: Use View Source in your browser to see what PHP is *really* sending. Similar functionality exists in some email clients, in differing names/menus. Oh, and if the break is messing you up in sending a link via email, put and around the link like so: echo http://test.php?id=; In *email* the and are supposed to tell the email client *not* to break that stuff up into multiple lines. Of course, there are many broken email clients out there (shocking, I know, but true) so you also want to provide the link without the link bits for those clients. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Header's download
Christian Johansson wrote: Header(Content-Type: application/download); Header(Content-Disposition: attachment; filename=export.txt); Then after this is done I know that I can write stuff to the file like this: Echo This will be a line in my file\n; I am standing in a GUI containing frames. So I want to give an administrator the rights to choose what to export. My problem is that when I include the php file download.php, the HTML\JAVA code are written to the file. The root cause of this is that *somewhere* in your scripts and PHP and HTML, you are forcing PHP to send those headers and your HTML and JavaScript out before you send out the headers and/or the content. While output buffering may allow you to gather all that content, and then throw it away, and then you can send your download... Wouldn't it make more sense to re-structure your code so that none of that crap (HTML and JavaScript) is being parsed by PHP? What if someday you decide to do something more interesting in PHP in the code that does the HTML and JavaScript output? Your downloads will maybe stop working, or you'll be executing the PHP script, but not even realizing it, because all the HTML and JavaScript output is thrown away, so you never see it, so you don't remember it's there... This is going to take a bit more work than just throwing in an ob_start() and whatever you call to throw away the output buffer, but you'll have cleaner and more clear code in the end. Up to you, really, as you're probably the one that has to maintain it... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo
Christopher Weaver wrote: I can't get this code, pasted from the documentation, to work properly. The new lines don't occur where they should. You may also want to check out: http://php.net/nl2br if you were trying to get newlines in your HTML. Another option is to consider the HTML PRE tag, though that does a lot more to your look than just newlines. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imagesx(): supplied argument is not a valid Image resource (CODE)
Robert Sossomon wrote: Chris is quoted as saying on 11/30/2004 2:53 PM: imagesx() requires an image resource , not a file path. so you'd need to use one of the imagecreatefrom* functions to create the resource. But it looks like all you want is the width and height of an image If so use get imagesize() ( which *does* except a pathname, not a resource) Chris http://www.php.net/image http://www.php.net/getimagesize SNIP I had looked at get image size, but thought the other would be quicker... ARGH. imagesx() is probably quicker once you have loaded in the entire image to your GD resource... But assuming the image could be *HUGE* and that getimagesize only has to read the first N bytes to determine the size of the image, getimagesize will win any speed race for an otherwise un-opened image file, I should think. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Custom Open Tags
Hi folks Does anybody know whether there's a way to tell PHP to accept an alternative open tag like for instance ?mytag or ?mc along with the normal ?php tag? I'm looking for a way to have two kinds of PHP code in a page. The first kind tagged ?mc ... ? contains the PHP code to manage page elements (like includes, menus etc) while the second kind tagged ?php ... ? contains normal PHP code for dynamic pages (like DB stuff). A page resides on the Staging (Virtual) Host and contains both kind of tags. When viewing the page on the Staging Host, both open tags are executed. Yet when publishing a page to the Production (Virtual) Host, the mc-tags are executed (and thus complete the page design) while the php-tags are left untouched (as they contain the dynamic stuff). Sounds more complicated than it is :-) Thanks for your hints,-sven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] transparant session propagation and headers
Bas Kamer wrote: On Dec 1, 2004, at 21:17, Richard Lynch wrote: If a client doen't accept cookies and transparant session propagation is enabled, links are changed to include the SID. But this is not the case while redirecting clients. This results in session loss unless you manually add the session id to the redirect url. Not really transparant... I was wondering if this is correct behavior or a bug in php. Feature. There's no way PHP can know if you are re-directing to something where you want the sesssion propogated or not. thanks for your answer... shouldn't the following tell php whether session propagation is needed. php.ini strlen(SID) redirect url is within the same domain i mean, anchors do get SID added when within the same domain and transparant propagation is ON. H. I can see your point... Too many people (who shouldn't be using Redirect in the first place) are doing so with the expectation that a Redirect will nuke the session data. So you'd have a Legacy issue to work with on this one. Worth a try, though, if you really think it's important. Note that you can append the SID by hand to your URL in the Redirect. It's also really hard to say for sure that that's what most people *want* PHP to do. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to tell if the filepath exist or not before attempting to create a directory??
Scott Fletcher wrote: Never mind that.. I found a different way to use it. It would be so cool if there is such a feature as directory_exists() to check for partical filepath... http://php.net/file_exists You'll need to use @ in front, because it generates an error message when it doesn't find the file you're not sure exists. :-( I've always thought that was a pretty stupid error message myself... Be kinda like isset() issuing a NOTICE for a variable that's not set. Well, duh. That's why I asked. :-) Oh, and I'm pretty sure file_exists works just fine for directories. Maybe even on Windoze. :-^ -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] classes and variable scope
Josh Howe wrote: Hi all, If I have the following code: $some_global_variable; Class foo { Function test() { set_global(); echo $some_global_variable; } Function set_global () { $some_global_variable = abcd; echo $some_global_variable; } } The first echo statement (the one inside the set_global function) prints abcd, but the second prints nothing. How can I set the value of $some_global_variable inside the set_global function so that it sticks? I'm using PHP 4.3.3. Choice 1: Declare it global in both functions. function test() { global $some_global_variable; } function set_global() { global $some_global_variable; } Choice 2: Use a member variable instead. function test(){ echo $this-some_global_variable; } function set_global() { $this-some_global_variable = 'abcd'; } Choice 3: Spend more time figuring out why you need a global variable, who needs this variable, why they need this variable, and re-structure your code so that you don't really need a global variable. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP-WIN] filectime problems
Kevin Glick wrote: I'm running PHP 5.0.2 on IIS 6/Windows Server 2003. Below is a snippet of the code from a script that looks into the news directory for files ending in .txt. After it finds the files, I want to get the creation time of each file. The script finds all the files (in this case blah.txt, but filectime gives me an error: Warning: filectime() [function.filectime]: stat failed for blah.txt in... (snip)... $dir = ../news/; $dh = opendir($dir); while (($filename = readdir($dh)) !== false) { if (strpos($filename, .txt)) { $time = filectime($filename); ... Any ideas why? The user that the webserver runs as, has full permissions to the news directory, and all the files in it. $filename only has blah.txt in it. filectime has NO IDEA what directory you are messing around with. You need something not unlike: filectime($dir/$filename); Maybe someday somebody will add an optional argument to readdir() to return the files as a full pathname... That would be nifty. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Custom Open Tags
I think there's a way to redefine what tag PHP uses, but I think it globally resets it. I don't think you can say use !blah ! and also use ?php ?. I think that setting is in PHP.INI somewhere. It might be easier to change your to be executed later php tags to something else and before it's sent to it's final destination, do a string replace to change the tags. If you have two different servers, you might go into PHP.INI and set the following tag on the last server and turn it OFF on the first server: ; Allow ASP-style % % tags. asp_tags = Off I'm not sure, but that may allow you to use ?php ? AND % % tags at the same time. All in all, I think I'd try to find a better way than using two kinds of tags and trying to jury-rig PHP to only execute some of it. Even if it meant using a conditional on the tags to be executed later if (!$finalexecute) ... and just change that value at the top of your code or something. Sounds messy all around, but there seem to be a number of ways you could possibly do this. -TG -Original Message- From: Sven Schwyn [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 4:16 PM To: [EMAIL PROTECTED] Subject: [PHP] Custom Open Tags Hi folks Does anybody know whether there's a way to tell PHP to accept an alternative open tag like for instance ?mytag or ?mc along with the normal ?php tag? I'm looking for a way to have two kinds of PHP code in a page. The first kind tagged ?mc ... ? contains the PHP code to manage page elements (like includes, menus etc) while the second kind tagged ?php ... ? contains normal PHP code for dynamic pages (like DB stuff). A page resides on the Staging (Virtual) Host and contains both kind of tags. When viewing the page on the Staging Host, both open tags are executed. Yet when publishing a page to the Production (Virtual) Host, the mc-tags are executed (and thus complete the page design) while the php-tags are left untouched (as they contain the dynamic stuff). Sounds more complicated than it is :-) Thanks for your hints,-sven -- 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] Header's download
Hello Richard. I totally agree with you. And I have tried to comment this to my employer. But as a consultant, my short stay has one purpose. Make it work, and then leave us alone. We have employees who keep track of the spaghetti :-) This is a very good example, how not to design systems.. I will of course comment this in the code. Thanks for your comment. Regards Christian Fra: Richard Lynch [mailto:[EMAIL PROTECTED] Sendt: 1. desember 2004 22:06 Til: [EMAIL PROTECTED] Emne: Re: [PHP] Header's download Christian Johansson wrote: Header(Content-Type: application/download); Header(Content-Disposition: attachment; filename=export.txt); Then after this is done I know that I can write stuff to the file like this: Echo This will be a line in my file\n; I am standing in a GUI containing frames. So I want to give an administrator the rights to choose what to export. My problem is that when I include the php file download.php, the HTML\JAVA code are written to the file. The root cause of this is that *somewhere* in your scripts and PHP and HTML, you are forcing PHP to send those headers and your HTML and JavaScript out before you send out the headers and/or the content. While output buffering may allow you to gather all that content, and then throw it away, and then you can send your download... Wouldn't it make more sense to re-structure your code so that none of that crap (HTML and JavaScript) is being parsed by PHP? What if someday you decide to do something more interesting in PHP in the code that does the HTML and JavaScript output? Your downloads will maybe stop working, or you'll be executing the PHP script, but not even realizing it, because all the HTML and JavaScript output is thrown away, so you never see it, so you don't remember it's there... This is going to take a bit more work than just throwing in an ob_start() and whatever you call to throw away the output buffer, but you'll have cleaner and more clear code in the end. Up to you, really, as you're probably the one that has to maintain it... -- Like Music? http://l-i-e.com/artists.htm -- 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] Custom Open Tags
Sven Schwyn wrote: Hi folks Does anybody know whether there's a way to tell PHP to accept an alternative open tag like for instance ?mytag or ?mc along with the normal ?php tag? I'm looking for a way to have two kinds of PHP code in a page. The first kind tagged ?mc ... ? contains the PHP code to manage page elements (like includes, menus etc) while the second kind tagged ?php ... ? contains normal PHP code for dynamic pages (like DB stuff). A page resides on the Staging (Virtual) Host and contains both kind of tags. When viewing the page on the Staging Host, both open tags are executed. Yet when publishing a page to the Production (Virtual) Host, the mc-tags are executed (and thus complete the page design) while the php-tags are left untouched (as they contain the dynamic stuff). Sounds more complicated than it is :-) I don't think you can do that in any efficient way with just tweaking PHP settings, or even PHP source... What you *COULD* do is write a PHP script to read your PHP script and http://php.net/eval the stuff inside of ?mytag tags, and leave the rest alone for the real PHP server to handle... ?php //Untested code: $file = implode('', file($php_source)); $parts = explode('?mytag', $file); $result = $part[0]; unset($parts[0]); while (list(, $part) = each($parts)){ $phphtml = explode('mytag?', $part); $php = $phphtml[0]; $html = @$phphtml[1]; //File may end with mytag? so squash error $result .= eval($php); $result .= $html; } //Dump $result into some file somewhere... ? Sounds like you inventing yet another Template language, though, to tell you the truth, and there's already too many of them. :-) I happen to think PHP all by itself is more than sufficient, and if Graphic Designers can't cope with ignore the PHP tags, just hire different Graphic Designers. :-) You may want to look at Smarty and phplip (?) and some of the dozens of other PHP-based template solutions. Just cuz I hate them doesn't mean you will. :-P -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to tell if the filepath exist or not before attempting to create a directory??
Richard Lynch wrote: Be kinda like isset() issuing a NOTICE for a variable that's not set. Well, duh. That's why I asked. :-) isset() doesn't issue a notice...at least not in php 4.3.9. It just returns true or false. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
Hi Trevor I'm not sure, but that may allow you to use ?php ? AND % % tags at the same time. Thought about that, it would actually be very elegant if it was the other way round. ASP tags would be great instead of a ?mc ... ? custom tag, however, that won't do the trick as the execution of the ?php ... ? tags can't be switched off (or can it?) when using % ... % tags. Thanks for your thoughts though! -sven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
On Wed, 1 Dec 2004 22:16:25 +0100, Sven Schwyn [EMAIL PROTECTED] wrote: Does anybody know whether there's a way to tell PHP to accept an alternative open tag like for instance ?mytag or ?mc along with the normal ?php tag? Patch zend_language_scanner.c and add you own custom tags. Isn't open source great? :) -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions
Hello everyone; Could someone tell me how to control the life span of a session? I understand that a session can last for the time a browser is running or something less. It seems like the sessions on my website have a finite life span and I would like to be able to control it. Thanks in advance, Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
you could edit the parser rules manually, recompile PHP and it should work Sven Schwyn wrote: Hi Trevor I'm not sure, but that may allow you to use ?php ? AND % % tags at the same time. Thought about that, it would actually be very elegant if it was the other way round. ASP tags would be great instead of a ?mc ... ? custom tag, however, that won't do the trick as the execution of the ?php ... ? tags can't be switched off (or can it?) when using % ... % tags. Thanks for your thoughts though! -sven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
You could always patch zend_language_scanner.c and add your own custom tags. Isn't open source great? :) -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Open Tags
Greg Donald wrote: You could always patch zend_language_scanner.c and add your own custom tags. Isn't open source great? :) I think patching zend_language_scanner.l would be easier actually ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to tell if the filepath exist or not before
John Nichel wrote: Richard Lynch wrote: Be kinda like isset() issuing a NOTICE for a variable that's not set. Well, duh. That's why I asked. :-) isset() doesn't issue a notice...at least not in php 4.3.9. It just returns true or false. it did for a while in PHP 5.1, for about a day, before it was fixed ;) isset is defined to specifically check these cases, and thus should *never* issue notices about unset variables -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Browsing while downloading?
Hello, I have this problem and maybe smbdy can give me a hint. I have a script which has to pack some server files into a tar created on the fly and then output this archive to the browser via headers. All is grea, the download works BUT, i am speaking of big archives, over 50M and i noticed that while i am downloading i cannot browse anymore. I tried the operation also via a opened window and it is the same. If i try to click on the link or smth the browser does nothing. In the moment the download finishes, the browser follows that clicked link and resumes it's activity. Any ideeas how can i keep browsing while dowloading? Thanks Adrian Zaharia -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Browsing while downloading?
Adrian Zaharia wrote: Hello, I have this problem and maybe smbdy can give me a hint. I have a script which has to pack some server files into a tar created on the fly and then output this archive to the browser via headers. All is grea, the download works BUT, i am speaking of big archives, over 50M and i noticed that while i am downloading i cannot browse anymore. I tried the operation also via a opened window and it is the same. If i try to click on the link or smth the browser does nothing. In the moment the download finishes, the browser follows that clicked link and resumes it's activity. Any ideeas how can i keep browsing while dowloading? Thanks Adrian Zaharia get a different browser. This is a 100% browser issue where the browser allocated 100% available bandwidth for your download, and doesn't take in extra requests. Notice, this has *nothing* whatsoever to do with php though :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Browsing while downloading?
Hi, Thanks for reply, yet: 1. i know has nothing to do with php but since now i am doing it in php i thought would be a good solution to post here 2. bad browser? hmm... i tried: IE, MozillaFirefox (Win+Linux), Opera(Win+Linux), Konqueror maybe there is still one better out there :P Thanks, Adrian M. Sokolewicz wrote: Adrian Zaharia wrote: Hello, I have this problem and maybe smbdy can give me a hint. I have a script which has to pack some server files into a tar created on the fly and then output this archive to the browser via headers. All is grea, the download works BUT, i am speaking of big archives, over 50M and i noticed that while i am downloading i cannot browse anymore. I tried the operation also via a opened window and it is the same. If i try to click on the link or smth the browser does nothing. In the moment the download finishes, the browser follows that clicked link and resumes it's activity. Any ideeas how can i keep browsing while dowloading? Thanks Adrian Zaharia get a different browser. This is a 100% browser issue where the browser allocated 100% available bandwidth for your download, and doesn't take in extra requests. Notice, this has *nothing* whatsoever to do with php though :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!
Hi Scott, Thank you for your help, but I have tried to user chown -r apache:apache upload_files. this is not working. yours, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Spawning new pages
Of all the correct answers that you received you had to pick and use the wrong answer! What?! I only see one answer, Brent Clements. How is it that I could miss some of the messages? I'm reading these through MS Outlook Express with 'Show All Messages' selected. Anyway, is there any way that I can 'imitate' the effect of a user clicking on a link that would open another page? Maybe this is a javascript thing? Thanks. Jason Wong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Wednesday 01 December 2004 15:02, Christopher Weaver wrote: Here's what I've got In first php file include second.php; createPage(withThis); createPage(withThat); ... Of all the correct answers that you received you had to pick and use the wrong answer! PHP can't spawn new pages. Read your other responses. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Carson's Observation on Footwear: If the shoe fits, buy the other one too. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Manipulation
This code: echo strtotime(now); echo mktime(Ymd, strtotime(now)); is producing this result: 1101945775 Warning: mktime(): Windows does not support negative values for this function ... -1 What am I doing wrong? Thanks again. John Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christopher Weaver wrote: I've looked at the date functions in the manual but can't find what I need. All I want to do is add and subtract days without ending up with bogus date values. IOW, Nov. 29 + 7 days shouldn't be Nov. 36. Just a nod in the write direction would be great. mktime() or strtotime() -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Page that checks if a user exists on a remote system
I have two servers: ServerA and ServerB. One server serves web pages, the other serves mail. I am making a web page on ServerA that will access ServerB to find out if a users exists and if not then add that user to ServerB with information collected from the web page on ServerA. I have this in a php file: $idResults = `ssh [EMAIL PROTECTED] id bigbob 21`; echo id: (.$idResults.)\r\n.\r\n; if (ereg(no such user, $idResults)) { echo 'username is available!'; } When I access the page I get: Could not create directory '/nonexistent/.ssh'. Host key verification failed. This, of course, is because the script is being run as www who has no place to put ssl keys. Could this be solved by having www su to a user who has remote access privileges? Something like this: $idResults = `su admin | ssh [EMAIL PROTECTED] id bigbob 21`; echo id: (.$idResults.)\r\n.\r\n; if (ereg(no such user, $idResults)) { echo 'username is available!'; // function addUserToServerB(vars); } Anyone else doing or done something like this? Thanks, -- Jonathan Duncan http://www.nacnud.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Spawning new pages
Christopher Weaver mailto:[EMAIL PROTECTED] on Wednesday, December 01, 2004 3:58 PM said: Of all the correct answers that you received you had to pick and use the wrong answer! What?! I only see one answer, Brent Clements. How is it that I could miss some of the messages? I'm reading these through MS Outlook Express with 'Show All Messages' selected. I got all the other emails. In fact I was one of the people that responded. Anyway, is there any way that I can 'imitate' the effect of a user clicking on a link that would open another page? Maybe this is a javascript thing? Missing emails aside, this is *not* a PHP issue. Use plain HTML (which PHP is used to create) or Javascript (which PHP can also creates). Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Manipulation
* Christopher Weaver [EMAIL PROTECTED]: This code: echo strtotime(now); echo mktime(Ymd, strtotime(now)); is producing this result: 1101945775 Warning: mktime(): Windows does not support negative values for this function ... -1 What am I doing wrong? Using the wrong function, or providing the wrong arguments. From the arguments you're giving mktime, I suspect you actually want date(), which would yield a string in the format 'YYYMMDD'. However, if you really want to use mktime, you should be be using it as follows: int mktime ( [int $hour], [int $minute], [int $second], [int $month], [int $day], [int $year], [int $is_dst] ) Please read the manual entries for the functions you're using before posting to the list. John Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Christopher Weaver wrote: I've looked at the date functions in the manual but can't find what I need. All I want to do is add and subtract days without ending up with bogus date values. IOW, Nov. 29 + 7 days shouldn't be Nov. 36. Just a nod in the write direction would be great. mktime() or strtotime() -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Go Back Problem
Dear All, I have a problem of back to the previous page in php. I need to create a form let people to fill in .It can let user to preview the form, if information is not correct , user can back to previous page and correct it, I have used the javascript : OnClick='history.go(-1)' and OnClick='history.back()' in php , but it can not workspls help me. Thanks and Regards, Cyrus Chan
Re: [PHP] Sessions
On Wed, 1 Dec 2004 16:01:07 -0600, Gary Reimer [EMAIL PROTECTED] wrote: Could someone tell me how to control the life span of a session? I understand that a session can last for the time a browser is running or something less. It seems like the sessions on my website have a finite life span and I would like to be able to control it. ini_set( 'session.gc_maxlifetime', 3600 ); http://us2.php.net/manual/en/ref.session.php#ini.session.gc-maxlifetime -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Go Back Problem
On Thu, 2 Dec 2004 09:58:46 +0800, Cyrus [EMAIL PROTECTED] wrote: Dear All, I have a problem of back to the previous page in php. I need to create a form let people to fill in .It can let user to preview the form, if information is not correct , user can back to previous page and correct it, I have used the javascript : OnClick='history.go(-1)' and OnClick='history.back()' in php , but it can not workspls help me. The only way I've ever found was to change the form method to GET instead of POST, but that's not always desirable. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Page that checks if a user exists on a remote system
On Wed, 1 Dec 2004 17:57:28 -0700, news.php.net [EMAIL PROTECTED] wrote: Anyone else doing or done something like this? I use sudo when my web server needs temporary elevated permissions. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Go Back Problem
If your php form is entered via a post, my experience is that most browsers do not save post information, therefore, clicking back to a page that was entered via a form using the post method, the browser complains that it does not have enough information to display the form, and that you must retry or something like that. I have found that the simplest way to avoid this is divide each page into two php routines. Displaypage.php will check in session data for contents for the form, or fetch the information from the database, then it will format the html for the page with values from session variables or from the database. The action field of this form will specify the postform.php routine below. Postform.php will perform all validations and echo nothing to the browser. It will then either update session data or post the valid data to the database. The only output of this routine is a header sending the browser back to the previous module displaypage.php when it has done all it can. Notice that anytime you use a header to redirect the browser you can send variables if you need to via the URL parameter list ?var1=1var2=2 string (they show up in the $_GET array). These variables are saved by all browsers that I know about, which means your displaypage.php program is never entered via a post (and always via a get), and because the redirect comes from the postform.php page, the postform.php module is removed from the browser history list by the redirect. This means that every click of the back button, or JavaScript history reference (-1) will take you back to the previous entry in the history list and if you are consistent, none of them will have been entered via a form post (i.e. no complaints). Hope this was clearer than mud, good luck. Warren Vail -Original Message- From: Cyrus [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 5:59 PM To: [EMAIL PROTECTED] Subject: [PHP] Go Back Problem Dear All, I have a problem of back to the previous page in php. I need to create a form let people to fill in .It can let user to preview the form, if information is not correct , user can back to previous page and correct it, I have used the javascript : OnClick='history.go(-1)' and OnClick='history.back()' in php , but it can not workspls help me. Thanks and Regards, Cyrus Chan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Organisation of classes
Best groupmember, For the moment I have all my classes saved in a file called classes.php in a subdirectory /classes/. I have started to get to many classes in the same file. In java I do this the default way, just naming them myclass.class. Is there a similar way to do this so that I do not need to include every file as a .php class in every php that I want to use the class? -- - Best Of Times /Peter Lauri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Organisation of classes
Peter Lauri wrote: For the moment I have all my classes saved in a file called classes.php in a subdirectory /classes/. I have started to get to many classes in the same file. In java I do this the default way, just naming them myclass.class. Is there a similar way to do this so that I do not need to include every file as a .php class in every php that I want to use the class? Save each class into its own name.class.php file. As for the includes, if there are a lot of classes and you actually need _all_ of them loaded, then just make one include.php that includes all of the class files and then just add include('include.php') into each script that needs these classes. You should really take a look at what classes need to be loaded in each page, though. If you have 10 classes, but a page only uses 3 of them, then it's a waste of time to load those other 7 classes. That's basically what you're doing now with everything in one file. Think about using extra classes that load the others that are needed for specific functios. Load a show class that'll load 4 of the 10 classes needed for showing records, load an edit class that'll load 7 of the 10 classes needed for editing, etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Organisation of classes
I have considered that, but I do not like that idéa :) I want php to recognise what classes it needs to load. Have there been any improvment in this area to PHP5? I use PHP4 for the moment, but will migrate to PHP5 soon. As an old java programmer I feel that PHP is not that well deveolped. Was hoping that it would be some sort of library system that could be used for classes. Package? /Peter John Holmes [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] Peter Lauri wrote: For the moment I have all my classes saved in a file called classes.php in a subdirectory /classes/. I have started to get to many classes in the same file. In java I do this the default way, just naming them myclass.class. Is there a similar way to do this so that I do not need to include every file as a .php class in every php that I want to use the class? Save each class into its own name.class.php file. As for the includes, if there are a lot of classes and you actually need _all_ of them loaded, then just make one include.php that includes all of the class files and then just add include('include.php') into each script that needs these classes. You should really take a look at what classes need to be loaded in each page, though. If you have 10 classes, but a page only uses 3 of them, then it's a waste of time to load those other 7 classes. That's basically what you're doing now with everything in one file. Think about using extra classes that load the others that are needed for specific functios. Load a show class that'll load 4 of the 10 classes needed for showing records, load an edit class that'll load 7 of the 10 classes needed for editing, etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Organisation of classes
On Wed, 2004-12-01 at 21:53, Peter Lauri wrote: I have considered that, but I do not like that idéa :) I want php to recognise what classes it needs to load. Have there been any improvment in this area to PHP5? I use PHP4 for the moment, but will migrate to PHP5 soon. As an old java programmer I feel that PHP is not that well deveolped. Was hoping that it would be some sort of library system that could be used for classes. Package? /Peter PHP is plenty well developed, but PHP != Java and nor would most want it to be. Java *ACK PTHEEWY*. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Execution time?
Best groupmember, How do I find the execution time for a php-script on a webserver? ms? -- - Best Of Times /Peter Lauri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Organisation of classes
* Peter Lauri [EMAIL PROTECTED]: I have considered that, but I do not like that idéa :) I want php to recognise what classes it needs to load. Have there been any improvment in this area to PHP5? I use PHP4 for the moment, but will migrate to PHP5 soon. Yes. In PHP5, you can register an '__autoload()' function at the beginning of your script, and in there map class names to files. To further automate things, you could always put the __autoload() function into a file and then set the php.ini 'auto_prepend_file' directive to load this file -- that way you wouldn't need to worry about defining it at the beginning of each script. As an old java programmer I feel that PHP is not that well deveolped. Was hoping that it would be some sort of library system that could be used for classes. Package? PHP and Java are very different beasts. PHP is dynamically typed and has a very flexible, dynamic runtime environment. One reason is to allow scripts to define their own environment -- doing so makes it very easy to drastically change the behaviour of a script simply by placing it in a different location. (This can also open a can of worms, but if developed right, this can be very powerful.) However, if you're looking for consistency of behaviour, it's possible to do that with PHP as well; you simply have to be a little more rigorous about setting up your environment. John Holmes [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] Peter Lauri wrote: For the moment I have all my classes saved in a file called classes.php in a subdirectory /classes/. I have started to get to many classes in the same file. In java I do this the default way, just naming them myclass.class. Is there a similar way to do this so that I do not need to include every file as a .php class in every php that I want to use the class? Save each class into its own name.class.php file. As for the includes, if there are a lot of classes and you actually need _all_ of them loaded, then just make one include.php that includes all of the class files and then just add include('include.php') into each script that needs these classes. You should really take a look at what classes need to be loaded in each page, though. If you have 10 classes, but a page only uses 3 of them, then it's a waste of time to load those other 7 classes. That's basically what you're doing now with everything in one file. Think about using extra classes that load the others that are needed for specific functios. Load a show class that'll load 4 of the 10 classes needed for showing records, load an edit class that'll load 7 of the 10 classes needed for editing, etc... -- Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED] Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Execution time?
Take a timestamp at the beginning or your script and at the end (subtract) and you have the execution time (reasonably precisely) plus or minus a few microseconds. http://www.php.net/manual/en/function.microtime.php Warren Vail -Original Message- From: Peter Lauri [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 7:02 PM To: [EMAIL PROTECTED] Subject: [PHP] Execution time? Best groupmember, How do I find the execution time for a php-script on a webserver? ms? -- - Best Of Times /Peter Lauri -- 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] PHP mail redirect ??
Hello, I have been playing around with a web mail app called NOCC (http://nocc.sourceforge.net/) It has some nice features and is quick. I want to add in a redirect button for mail, there is a forward button but it forwards mail just like a regular client for ... as expected. But I want a redirect button so I could send the exact same message to the same user and from the same person just but to another mail box on a different machine. Is there a easy to do this with out having to create some thing from scratch. Thanks .. Michael. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Organisation of classes
On Wed, 01 Dec 2004 21:59:25 -0500, Robert Cummings [EMAIL PROTECTED] wrote: PHP is plenty well developed, but PHP != Java and nor would most want it to be. Java *ACK PTHEEWY*. I see alot of Java influence in PHP5 myself. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Organisation of classes
On Thu, 2 Dec 2004 09:53:41 +0700, Peter Lauri [EMAIL PROTECTED] wrote: As an old java programmer I feel that PHP is not that well deveolped. Was hoping that it would be some sort of library system that could be used for classes. Package? pear.php.net has lots of classes. And if you really miss Java, check out Mojavi.org. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php