php-general Digest 14 Aug 2006 07:20:57 -0000 Issue 4292
php-general Digest 14 Aug 2006 07:20:57 - Issue 4292 Topics (messages 240601 through 240618): Re: Internet Explorer doesn't display UTF-8 page using UTF-8 encoding 240601 by: Rasmus Lerdorf Re: How to run one php app from another? 240602 by: Gerry D Re: New Large Scale Project. 240603 by: Jay Blanchard Re: Chicago PHP Conference 240604 by: Jay Blanchard I am receiving multiple same emails!!! 240605 by: Karl James 240609 by: Chris 240611 by: Chris Re: How to run one php app from another? RECAP 240606 by: Gerry D Re: page redirecting 240607 by: Gerry D Re: Preventing double-clicks 240608 by: Gerry D Re: Unicode 240610 by: Ligaya Turmelle Re: Functions 240612 by: Gerry D Re: Problem Creating a New SSL Cert in Apache2 240613 by: Chris Re: Compiling and iconv 240614 by: Chris Re: non-text data 240615 by: John Meyer 240616 by: Chris 240617 by: John Meyer 240618 by: Dave Shariff Yadallee - System Administrator a.k.a. The Root of the Problem 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: php-general@lists.php.net -- ---BeginMessage--- tedd wrote: At 6:48 PM -0700 8/12/06, Rasmus Lerdorf wrote: By the way, everyone should be setting a charset. If you don't set it, IE will look at the first 4k of the body of the page and take a wild guess. -Rasmus -Rasmus: Ok, but why doesn't w3c use it? http://validator.w3.org (check source) I'm not sure what to do re charset. I've been told by credible sources to always use it and never use it -- which is correct? Or, is this one of those it depends things? W3C is all about standards. IE is all about not following standards. If you want your site to work in the real world you should always set a charset. If you set it in your response header there is no need to set it in each page, and if you look closely, you will see that this is what w3.org is doing: 9:55am shiny:~ telnet validator.w3.org 80 Trying 133.27.228.132... Connected to validator.w3.org. Escape character is '^]'. HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Sun, 13 Aug 2006 18:42:15 GMT Server: Apache/2.0.54 (Debian GNU/Linux) mod_perl/1.999.21 Perl/v5.8.4 Accept-Ranges: bytes Connection: close Content-Type: text/html; charset=utf-8 -Rasmus ---End Message--- ---BeginMessage--- I don't know if you solved this already, but I use it to redirect to different pages depending on whther the user is logged in or not. Something like header(location:/page/?p=login); works fine. You were on the right track. Gerry On 6/15/06, tedd [EMAIL PROTECTED] wrote: Hi gang: This seems like so obvious a question, I am reluctant to ask. In any event, I simply want my php application to run another, like so: switch (option) { case a: run a.php; exit; break; case b: run b.php; exit; break; case c: run c.php; exit; break; } I know that from within an application I can run another php application via a user click (.e., button), or from javascript event (onclick), or even from cron. But, what if you want to run another application from the results of a calculation inside your main application without a user trigger. How do you do that? I have tried header(Location: http://www.example.com/;); ob_start(), ob_flush() and such, but I can't get anything to work. Is there a way? Thanks. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- [snip] My other problem is even though I'm confident coding I find design very difficult I've a good idea of how the website would work but only in general terms. [/snip] Have you ever sat down wit paper and pencil (or Excel or any number of other tools) and attempted to flowchart a project? It will provide truckloads of insight, you'd be amazed at how you can break down a project into discrete modules that will make things easier to swallow. ---End Message--- ---BeginMessage--- [snip] I'm in the pre-planning phase of organizing a PHP Conference in Chicago. [/snip] Capital idea Richard, thanks for making this more formal. ---End Message--- ---BeginMessage--- Team, I unsubscribe and subscribe later on. I am still receiving multiple emails from the same user. How do I stop this madness. I do not want to unsubscribe from This mailing list. Karl James (TheSaint) mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] www.theufl.com ---End Message--- ---BeginMessage--- Karl
Re: [PHP] RE: non-text data
On Mon, Aug 14, 2006 at 02:40:53PM +1000, Chris wrote: John Meyer wrote: Gd, BTW, came into this late, have we gotten the old store your images in the filesystem and save the file name in the database argument yet? Nope, haven't done that one yet, do you want to start it off or shall I? ;) -- Postgresql php tutorials http://www.designmagick.com/ Careful where you light your match. You may blow up if you are not careful. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: non-text data
Dave Shariff Yadallee - System Administrator a.k.a. The Root of the Problem wrote: On Mon, Aug 14, 2006 at 02:40:53PM +1000, Chris wrote: John Meyer wrote: Gd, BTW, came into this late, have we gotten the old store your images in the filesystem and save the file name in the database argument yet? Nope, haven't done that one yet, do you want to start it off or shall I? ;) -- Postgresql php tutorials http://www.designmagick.com/ Careful where you light your match. You may blow up if you are not careful. Probably very good advice ;) -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] break up variable and put each element in an array
On Sat, 12 Aug 2006 16:36:36 -0500, Richard Lynch wrote: On Fri, August 11, 2006 3:11 am, Ivo F.A.C. Fokkema wrote: Well, if it's true that some browsers on some platforms ignore the W3C standard, I guess we could use: Or perhaps these browsers pre-date W3C standards. :-) Sure, but in newer versions, they might update their code to follow the standards after all... wouldn't they? $datelist = str_replace(array(\r\n,\n,\r),'BR',$_POST['datelist']); Two problems here. This assumes a specific undocumented ordering to the replacement in processing the array argument. If, for some insane reason, the PHP implementation of str_replace chooses to process that input array in reverse order, you would end up with double BR for \r\n input. This is incredibly unlikely, but it's NOT (yet) documented that the arrays are processed in order. True; and I haven't tested the code either, to be honest. I found the basic implementation on a forum somewhere and adapted it to the threadstarter's need. I might try and see if I could submit a documentation bug on this. I think it's a useful feature and you're right to claim that since it's not documented, one should not rely on it. The next problem is that replacing newline (in any form) with BR on the INPUT phase of your program is just a Bad Idea. :-) (...) Because someday you may want to output that same data to RSS, XML, or XYZ, in which case BR is NOT what you want for your newlines. Hey, totally agree here, BUT, the threadstarter doesn't mention it being put in a database. Actually, he just requests it to be written on a new line in the output. I just provided him a way of doing this. I always store the input directly in the database (quoted, then, of course) and replace \r\n with BR when needed (display on screen). I've had no problems by strictly using \r\n yet. But as I have an open source project, I assume someone will (be telling me||submit a bug) if they have problems. In that case, I will implement a non-W3C compliant hack ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Codigo de Captcha en PHP
Hay muchos y muy variados en Internet. En alguna ocasión he usado el que viene en sBlog. Es muy sencillo de implementar y para la mayoría de los casos suficiente para evitarnos problemas de spam. En código es: ?php $key = (array_key_exists('k', $_GET) strlen($_GET['k']) == 4) ? $_GET['k'] : strtolower(substr(md5(rand()), 0, 4)); $im = imagecreatetruecolor(40, 20); $bg = imagecolorallocate($im, 0, 0, 0); $col_text = imagecolorallocate($im, 255, 255, 255); imagestring($im, 4, 4, 1, $key, $col_text); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ? Luego llamas a este archivo desde el que lo necesites. Te generas el código (en este caso de 4 numeros y letras): ?php $k = strtolower(substr(md5(mt_rand()), 0, 4)); ? En el formulario donde lo uses poner un campo oculto como éste: input type=hidden name=h id=h value=?php echo $k; ? / Y llamas a la imagen como: img src=as_img.php?k=?php echo $k; ? / Por último, una vez se a enviado el formulario, compruebas que el valor del campo oculto h es igual que el escrito por el usuario en el formulario. Para más seguridad se podrían haber usado variables de sesión para guardar y pasar los valores de h, pero eso ya te lo dejo a ti. Saludos, Julio Barroso Ricardo Ríos [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] | Hola amigos listeros alguien conoce algun codigo libre de un captcha en php | , gracias por sus comentarios. | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: New Large Scale Project.
Wesley Acheson wrote: Basically the different areas I would need are authentication, galleries (for images), permission levels. Internal messaging (not real time), forums (hopefully I can just plugin an existing one but intregrated with my new so that registering users for the site registers for the forum and vice versa, also I would like each new gallery entry to create a new forum entry for that image). Comments, ratings and such like. Sales (This would have to be a script written elsewhere, I am in no way confident when it comes to dealing with sensitve info like credit card details.) etc. etc. My other problem is even though I'm confident coding I find design very difficult I've a good idea of how the website would work but only in general terms. Out of the box mambo or drupal doesn't seem to do what I want really I use Joomla quite a bit (Mambo by an other name). I've used the bridge components and Menalto Gallery and it works pretty well. THere are various core hacks you can apply too to setup varying permission levels and other stuff. Simple Machine Forums also has a good bridge component (it's what the Joomla forums themselves use). So with a little fiddling you can probably make Joomla do what you need. If you are not confident dealing with CC payments and the like, then I strongly suggest you use a third party service for this. Col. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: New Large Scale Project.
I can strongly recommend Joomla - I have it working with Menalto's Gallery2, and just got a phpBB bridge working as well. Can I also recommend you use Joomla over Mambo? About a year ago the core developers (now at Joomla) fell out with the so called owners of Mambo, about ownership and future developments so they created Joomla. They're in the process of developing v1.5 which is going to have some really cool features, mainly for 3rd party developers, so although you may not experience the features with it's direct release, other components and modules are already being developed that will improve the CMS no end... Hope that helps Nunners -Original Message- From: Colin Guthrie [mailto:[EMAIL PROTECTED] Sent: 14 August 2006 10:06 To: php-general@lists.php.net Subject: [PHP] Re: New Large Scale Project. Wesley Acheson wrote: Basically the different areas I would need are authentication, galleries (for images), permission levels. Internal messaging (not real time), forums (hopefully I can just plugin an existing one but intregrated with my new so that registering users for the site registers for the forum and vice versa, also I would like each new gallery entry to create a new forum entry for that image). Comments, ratings and such like. Sales (This would have to be a script written elsewhere, I am in no way confident when it comes to dealing with sensitve info like credit card details.) etc. etc. My other problem is even though I'm confident coding I find design very difficult I've a good idea of how the website would work but only in general terms. Out of the box mambo or drupal doesn't seem to do what I want really I use Joomla quite a bit (Mambo by an other name). I've used the bridge components and Menalto Gallery and it works pretty well. THere are various core hacks you can apply too to setup varying permission levels and other stuff. Simple Machine Forums also has a good bridge component (it's what the Joomla forums themselves use). So with a little fiddling you can probably make Joomla do what you need. If you are not confident dealing with CC payments and the like, then I strongly suggest you use a third party service for this. Col. -- 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: New Large Scale Project.
I use Joomla quite a bit (Mambo by an other name). How about trying KINKY? http://avoir.uwc.ac.za/ It is customizable and we have a few code generation modules that will write your basic code for you, you just need to fill in the blanks. The new Chisimba framework does the same, and has a more advanced code generation module, but is still in alpha stage. It is a better framework though... http://5ive.uwc.ac.za/ mail me off list for a download or do an anonymous CVS checkout of the code and join our list! :) --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need PHP developer in Thailand
Hi, I am sorry to have to post this on this list. I do not enjoy reading the personals that are posted here on the list. Before this I have been trying to find Thai PHP programmers via some Thai job brokers, but no success. So my hope is that there will be someone from Thailand reading this. I am looking for a PHP developer in Bangkok area. English language is NOT a requirement. However, if you are a member of this list, you probably know some English. If you have a friend that knows PHP and does not speak English, let him know that I am searching for a PHP developer. Or there is maybe a PHP developer from another country that is interested to come to Bangkok for a year, not that great pay, but living standard are great. Best regards, Peter Lauri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need PHP developer in Thailand
On Mon, 2006-08-14 at 16:38 +0700, Peter Lauri wrote: Or there is maybe a PHP developer from another country that is interested to come to Bangkok for a year, not that great pay, but living standard are great. As part of our project, we have a strong internship programme. Would you consider that? Our interns are trained at the highest level of work, and are very good at what they do... --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: non-text data
At 10:35 PM -0600 8/13/06, John Meyer wrote: Gd, BTW, came into this late, have we gotten the old store your images in the filesystem and save the file name in the database argument yet? You can do that?;-) tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] auto_globals_jit breaks $_SERVER var
I have the following in my php.ini: register_globals = Off register_long_arrays = Off register_argc_argv = Off auto_globals_jit = On The following PHP code prints nothing: ?php $webroot = $_SERVER['DOCUMENT_ROOT']; $server = $_SERVER[HOST]; $file = $_SERVER[SCRIPT_FILENAME]; $transport = $_SERVER[REQUEST_TRANSPORT]; $port = $_SERVER[SERVER_PORT]; print $webroot; print $server; print $transport; ? The rest of the php.ini is like php.ini-recommended that comes with the source. Any idea what might be the problem? Thanks, Yoav.
[PHP] header lost session variables.
Hi guys. Anyone here know why in some cases when i use (header(Location: ???); the system lost the session variables? Any tips will be apreciated. Thanks in advantge. -- João Cândido de Souza Neto Curitiba Online [EMAIL PROTECTED] (41) 3324-2294 (41) 9985-6894 http://www.curitibaonline.com.br -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A way to stop spam on this list
Michelle Konzack wrote: Late answer, but I was coming back yesterday from Palestine, after the Israelien Terror Authority had arrest me for making tonns of photos and Videos about Israeli military crime... (shooting children and pregnant women) Plonk Regards, Austin. signature.asc Description: OpenPGP digital signature
Re: [PHP] Compiling and iconv
On Sunday 13 August 2006 22:00, Chris wrote: Ray Hauge wrote: I use Slackware linux, and XMLRPC is not compiled in by default with my distro, so I'm compiling PHP myself. It's always been a simple enough task. First I get and install the required xmlrpc-epi libraries, and then I compile PHP telling it where I just installed them. Now I get this error message: undefined reference to `libiconv' when compiling PHP. I did some searching, and the only thing I've found in reference to this error was a bug in version 4.3.10. Has anyone run into this issue, or have some suggestions? I have checked that /usr/include/iconv.h is there, and it defines all the iconv_* and iconv compiler flags etc. I can also vouch that using iconv on the command line works just fine. Try explicitly telling php where iconv is by adding this option to your configure command: --with-iconv-dir=/usr Thanks for the reply. I enentually got it to comipile by adding -liconv to the LDFLAGS environment variable to tell it to actually link in the iconv code. -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating custom superglobals
Hello, Does the PHP environment (5.1.4) provide a way to define some custom variables as a superglobal? It would be useful for saving certain site preferences and settings that must be referred in many variables and classes, without every time writing global keyword at the beginning of a function definition. Thanks, Ville -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Creating custom superglobals
[snip] Does the PHP environment (5.1.4) provide a way to define some custom variables as a superglobal? It would be useful for saving certain site preferences and settings that must be referred in many variables and classes, without every time writing global keyword at the beginning of a function definition. [/snip] An include file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating custom superglobals
Ville Mattila wrote: Does the PHP environment (5.1.4) provide a way to define some custom variables as a superglobal? It would be useful for saving certain site preferences and settings that must be referred in many variables and classes, without every time writing global keyword at the beginning of a function definition. No, PHP does not allow userland to create superglobals. However, all global variables can be accessed through the $GLOBALS superglobal. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Creating custom superglobals
Hello, You CAN create custom superglobals, but it requires that you have RunKit enabled: http://us3.php.net/runkit HTH, K. Bear -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 10:04 AM To: Ville Mattila Cc: php-general@lists.php.net Subject: Re: [PHP] Creating custom superglobals Ville Mattila wrote: Does the PHP environment (5.1.4) provide a way to define some custom variables as a superglobal? It would be useful for saving certain site preferences and settings that must be referred in many variables and classes, without every time writing global keyword at the beginning of a function definition. No, PHP does not allow userland to create superglobals. However, all global variables can be accessed through the $GLOBALS superglobal. -Stut -- 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] Creating custom superglobals
On Mon, 2006-08-14 at 10:45 -0400, KermodeBear wrote: Hello, You CAN create custom superglobals, but it requires that you have RunKit enabled: http://us3.php.net/runkit Which will make your application incompatible with any distribution where runkit is not enabled :/ Which kinda sucks, I wish more stuff was part of the core. Cheers, Rob. HTH, K. Bear -Original Message- From: Stut [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 10:04 AM To: Ville Mattila Cc: php-general@lists.php.net Subject: Re: [PHP] Creating custom superglobals Ville Mattila wrote: Does the PHP environment (5.1.4) provide a way to define some custom variables as a superglobal? It would be useful for saving certain site preferences and settings that must be referred in many variables and classes, without every time writing global keyword at the beginning of a function definition. No, PHP does not allow userland to create superglobals. However, all global variables can be accessed through the $GLOBALS superglobal. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- .. | 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] system, exec, shell_exec, passthru
Hello, I am trying the run an external application with command line arguments using PHP under linux. ie: $command=myprog $arg1 $arg2 textfile.txt; system(echo \$command\ test.txt); system($command); $handle=fopen(textfile.txt,r); if($handle!=NULL) { while(!feof($handle)) { ... } fclose($handle); } I test my input arguments for the 'system' call by dumping the command into a text file. I can then test the command in the console. The commands work fine when run from the console. The commands don't work when run through the system command. I have tried system, exec, passthru, and shell_exec to no avail. Am I missing some permissions thing in my php.ini file? Thanks for any insight, Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] auto_globals_jit breaks $_SERVER var
Artzi, Yoav (Yoav) wrote: I have the following in my php.ini: register_globals = Off register_long_arrays = Off register_argc_argv = Off auto_globals_jit = On The following PHP code prints nothing: ?php $webroot = $_SERVER['DOCUMENT_ROOT']; $server = $_SERVER[HOST]; $file = $_SERVER[SCRIPT_FILENAME]; $transport = $_SERVER[REQUEST_TRANSPORT]; $port = $_SERVER[SERVER_PORT]; print $webroot; print $server; print $transport; ? The rest of the php.ini is like php.ini-recommended that comes with the source. Any idea what might be the problem? Do you have APC enabled? If so, upgrade to a more recent version. Preferably the CVS one. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating custom superglobals
Robert Cummings wrote: Which will make your application incompatible with any distribution where runkit is not enabled :/ Which kinda sucks, I wish more stuff was part of the core. Cheers, Rob. I agree, this module looks very powerful. The ability to write wrappers around internal functions by renaming the existing functions could come in very handy, and defining new superglobals would help make code more readable (IE, $settings['foo'] rather than $GLOBALS['settings']['foo']). Heck, even runkit_lint_file would be somewhat helpful, since it's save us from having to make a shell call for syntax checking. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: system, exec, shell_exec, passthru
[EMAIL PROTECTED] wrote: Hello, I am trying the run an external application with command line arguments using PHP under linux. ie: $command=myprog $arg1 $arg2 textfile.txt; system(echo \$command\ test.txt); system($command); $handle=fopen(textfile.txt,r); if($handle!=NULL) { while(!feof($handle)) { ... } fclose($handle); } I test my input arguments for the 'system' call by dumping the command into a text file. I can then test the command in the console. The commands work fine when run from the console. The commands don't work when run through the system command. I have tried system, exec, passthru, and shell_exec to no avail. Am I missing some permissions thing in my php.ini file? Thanks for any insight, Peter Looking at your $command, there is no path in front of it. It's likely that PHP's shell doesn't have the program in its PATH. Try manually specifying the full path to the command: $command=/home/peter/myprog $arg1 $arg2 textfile.txt; (or whatever the path is) Keep in mind that under linux, (unlike DOS), you CANNOT execute applications in the same directory without a path. Even if the program is in the same directory as your present working directory (which is usually where the PHP script is located), you'd have to do ./myprog as a relative path. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] requests from 2nd window breaks my program
on rereading your post - your storing session data in a db, why bother; secondly it sounds like you just overwriting the session record with a new transaction id rather than adding a new transaction id [record] and leaving any already existing transactions available. basically pass the transaction id around when you need to keep referring to an existing transactions and maintain a 'stack' of active transactions. Reason I store session info in 'sessions' table CREATE TABLE `sessions` ( `sessID` varchar(45) NOT NULL default '', `last_update` timestamp(14) NOT NULL, `session_values` text NOT NULL, PRIMARY KEY (`sessID`) ) TYPE=MyISAM; instead in $_SESSIONS (something like $_SESSION['session_info']['User'], $_SESSION['session_info']['UserNo'], $_SESSION['session_info']['OrderID, '], $_SESSION['session_info']['PageID'], etc.) is to be able to see who is online, eventually by redoing sessions table, when they started session, how much time they spend on application, what they mostly use from application, etc. (requests from the office). -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Why does count() make copies of arrays?
I was writing a shell script in PHP (4.4.2) that dealt with a rather large array. To figure out what I needed the new memory limit to be, I did a memory_get_usage() at the end of my script, and came up with about 5.5MB. I then set the memory limit to 8MB. When I tried to run it, the script ran out of memory on the line: $numwords = count($words); However, when I switched to simply incrementing $numwords every time I added an element to $words, the memory limit of 8MB was fine. So my question is, if PHP does copy-on-write, why does PHP make a copy of an array when you use count() on it, which should NOT be modifying the array? Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: system, exec, shell_exec, passthru
Hi, I can run any external program like ls, cp, uptime... But if a try to run my shell script a get error. $passwdexe = sudo /usr/bin/webpasswd; $user=$_POST[name]; $passwd=$passwdexe $user 123456; echo $passwd; $result = system($passwd); Resultat from the web, sudo /usr/sbin/webpasswd billy 12345678 and from the error_log, couldn't read file ./usr/sbin/webpasswd.: no such file or directory. .Mike Adam Zey wrote: [EMAIL PROTECTED] wrote: Hello, I am trying the run an external application with command line arguments using PHP under linux. ie: $command=myprog $arg1 $arg2 textfile.txt; system(echo \$command\ test.txt); system($command); $handle=fopen(textfile.txt,r); if($handle!=NULL) { while(!feof($handle)) { ... } fclose($handle); } I test my input arguments for the 'system' call by dumping the command into a text file. I can then test the command in the console. The commands work fine when run from the console. The commands don't work when run through the system command. I have tried system, exec, passthru, and shell_exec to no avail. Am I missing some permissions thing in my php.ini file? Thanks for any insight, Peter Looking at your $command, there is no path in front of it. It's likely that PHP's shell doesn't have the program in its PATH. Try manually specifying the full path to the command: $command=/home/peter/myprog $arg1 $arg2 textfile.txt; (or whatever the path is) Keep in mind that under linux, (unlike DOS), you CANNOT execute applications in the same directory without a path. Even if the program is in the same directory as your present working directory (which is usually where the PHP script is located), you'd have to do ./myprog as a relative path. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Job Opening (Chicago-downtown)
[If you're not in Chicago, or relocating to Chicago within days, hit delete now.] PHP Job Opening I'm leaving a very nice cushy job for an even nicer cushier job. :-) My final task is to find my replacement. The work mostly entails setting up new pages of search results from APIs based around XML feeds for: http://info.com/ There are occasionally some in-house PHP pages to be built/maintained. The Tech environment consists of, and your skill set should include: PHP 4 OOP PEAR XML High-Volume High-Availability stable coding Reading vendor API documentation of XML feeds for RPC, HTTP, REST etc Occasional PHP/HTML Intranet back-end work The work environment is very casual and relaxed, with a stunning view from your desk of Lake Michigan over-looking Millenium Park. This is in Chicago, downtown near the Art Institute, Chicago Cultural Center, etc. There is no shortage of work to do, so it's a solid 40 hours per week, but the hours are very flexible. Pay rate is $23-$28 per hour, based on experience. -- 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: system, exec, shell_exec, passthru
Michael Jonsson wrote: Hi, I can run any external program like ls, cp, uptime... But if a try to run my shell script a get error. $passwdexe = sudo /usr/bin/webpasswd; $user=$_POST[name]; $passwd=$passwdexe $user 123456; echo $passwd; $result = system($passwd); Resultat from the web, sudo /usr/sbin/webpasswd billy 12345678 and from the error_log, couldn't read file ./usr/sbin/webpasswd.: no such file or directory. .Mike Notice that . is being appended before the path, which turns it into a relative path. It looks like safe mode might be on. Create a new PHP script with nothing but the command phpinfo(); in it, and view it in a browser. To see if safe mode is on, look for the setting safe_mode. The line below it is safe_mode_exec_dir. If safe mode is on, you'll need to put your program (webpasswd) into that directory to execute it. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: system, exec, shell_exec, passthru
No, it not on... safe_mode Off Off safe_mode_exec_dir no valueno value safe_mode_gid Off Off safe_mode_include_dir no valueno value .M Adam Zey wrote: Michael Jonsson wrote: Hi, I can run any external program like ls, cp, uptime... But if a try to run my shell script a get error. $passwdexe = sudo /usr/bin/webpasswd; $user=$_POST[name]; $passwd=$passwdexe $user 123456; echo $passwd; $result = system($passwd); Resultat from the web, sudo /usr/sbin/webpasswd billy 12345678 and from the error_log, couldn't read file ./usr/sbin/webpasswd.: no such file or directory. .Mike Notice that . is being appended before the path, which turns it into a relative path. It looks like safe mode might be on. Create a new PHP script with nothing but the command phpinfo(); in it, and view it in a browser. To see if safe mode is on, look for the setting safe_mode. The line below it is safe_mode_exec_dir. If safe mode is on, you'll need to put your program (webpasswd) into that directory to execute it. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: system, exec, shell_exec, passthru
Yes, that is a similar problem and sounds very much like what I am experiencing. Peter Quoting Michael Jonsson [EMAIL PROTECTED]: Hi, I can run any external program like ls, cp, uptime... But if a try to run my shell script a get error. $passwdexe = sudo /usr/bin/webpasswd; $user=$_POST[name]; $passwd=$passwdexe $user 123456; echo $passwd; $result = system($passwd); Resultat from the web, sudo /usr/sbin/webpasswd billy 12345678 and from the error_log, couldn't read file ./usr/sbin/webpasswd.: no such file or directory. .Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: system, exec, shell_exec, passthru
Quoting Adam Zey [EMAIL PROTECTED]: Looking at your $command, there is no path in front of it. It's likely that PHP's shell doesn't have the program in its PATH. Try manually specifying the full path to the command: $command=/home/peter/myprog $arg1 $arg2 textfile.txt; (or whatever the path is) Keep in mind that under linux, (unlike DOS), you CANNOT execute applications in the same directory without a path. Even if the program is in the same directory as your present working directory (which is usually where the PHP script is located), you'd have to do ./myprog as a relative path. Regards, Adam Zey. I have actually tried that and it didn't make any difference. In the actual code I have full paths applied to all input and output files. One of the system calls is in the system path. (ie: /usr/bin) Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] INPUT
Warren Vail wrote: I would be interested to know what might get past the addslashes function that the mysql_escape_string function catches. I wrote an example to demonstrate this: http://shiflett.org/archive/184 The theory behind this type of problem is pretty easy to understand - if your escaping function interprets characters differently than the database, it's possible that it will fail to escape something that needs to be escaped, just because it misinterprets the character. The problem I demonstrate doesn't exist with UTF-8 or ISO-8859-1, but it does with any character encoding where there is a valid multi-byte character that ends in 0x5c. Regardless, it's best to use the right tool for the job, even if you think you won't be punished for using the wrong one. (You might be wrong.) The original question is related to XSS, not SQL injection, and character encoding consistency is even more important in that context: http://shiflett.org/archive/178 Hope that helps. Chris -- Chris Shiflett Principal, OmniTI http://omniti.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IMAGE LOADED...
On Sun, August 13, 2006 8:03 am, tedd wrote: This leads to the opposite problem of IE caching DYNAMIC images when it should not, which is a whole different rant. :-) In that case, I just added a random string to end of the image url like so: images/myimage.jpg?a=adj12k4mfdi If I remember correctly, it seemed to work. Works okay for images on MOST browsers, but not some ancient IE versions. Will also fail as a generalized technique for a PDF if the user has configured Adobe Reader to open in a Adobe rather than as a plug-in. Also fails as a generalized technique for the PDF embedded in an FDF. Basically, IE simply does not deal well with Rich Media (non-HTML) dynamic content. It's quite narrow-minded on what can be dynamic on the Internet. I personally would recommend that folks solve this problem in a generalized way using URL re-writing with $_SERVER['PATH_INFO'] as I have posted in the past (several times, actually) because that solution works well across the board, and means you can re-use the code for Images, PDFs, FDFs, Ming (PHP-generated Flash), MP3s, etc instead of having different code-bases for each. The basic technique for this is posted in a rant here: http://richardlynch.blogspot.com in case anybody cares. -- 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 lost session variables.
Hi guys. Anyone here know why in some cases when i use (header(Location: ???); the system lost the session variables? Any tips will be apreciated. Thanks in advantge. Please tell me the cases you mean..! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OT? XUL XML-RPC Client
We've decided to start using XUL for intranet applications. I've written up my XML-RPC server (php script) and I had found a tutorial showing how to use XML-RPC through XUL/JavaScript, but now I can't find any information on it. Anyone have any experience/links to information about XML-RPC with XUL? Thanks, -- Ray Hauge Programmer/Systems Administrator American Student Loan Services www.americanstudentloan.com 1.800.575.1099 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why does count() make copies of arrays?
On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote: I was writing a shell script in PHP (4.4.2) that dealt with a rather large array. To figure out what I needed the new memory limit to be, I did a memory_get_usage() at the end of my script, and came up with about 5.5MB. I then set the memory limit to 8MB. When I tried to run it, the script ran out of memory on the line: $numwords = count($words); However, when I switched to simply incrementing $numwords every time I added an element to $words, the memory limit of 8MB was fine. So my question is, if PHP does copy-on-write, why does PHP make a copy of an array when you use count() on it, which should NOT be modifying the array? For some reason the memory_get_usage() function wouldn't appear in my PHP compilation even after using the --enable-memory-limit flag, and rather than dig very deep, I whipped up the following script to test your issue (under PHP 4.2.2): ?php //echo 'Mem Usage: '.memory_get_usage().\n; $foo = array(); for( $i = 0; $i 1000; $i++ ) { $foo[$i] = $i; } echo 'Created big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; $numEntries = count( $foo ); echo 'Counted big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; ? Using the following command: watch -n 0 'ps awxu | grep foo.php | grep -v grep' I got the following snapshots during the two sleep steps: rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php Which indicated no change from the 935 megs of memory already allocated before the count(). You've either encountered a bug in your version, or a confounding variable :) 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
Re: [PHP] header lost session variables.
I´m in the follow location: https://www2.../?modulo=seguroacao=identifica And in my script i use header(Location: ./?modulo=seguroacao=novo_cadastro) When it run, my system lost all session variables. BBC [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi guys. Anyone here know why in some cases when i use (header(Location: ???); the system lost the session variables? Any tips will be apreciated. Thanks in advantge. Please tell me the cases you mean..! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Include and require
Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
[PHP] Re: Include and require
Dave Goodchild wrote: Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. I know for a fact that you can define variables in PHP 4 and 5. The idea behind include and require is little more complex than copying and pasting the code. Many of my scripts include a config.php which has various variables created with setting information. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why does count() make copies of arrays?
On Mon, 2006-08-14 at 17:20 -0400, Robert Cummings wrote: On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote: I was writing a shell script in PHP (4.4.2) that dealt with a rather large array. To figure out what I needed the new memory limit to be, I did a memory_get_usage() at the end of my script, and came up with about 5.5MB. I then set the memory limit to 8MB. When I tried to run it, the script ran out of memory on the line: $numwords = count($words); However, when I switched to simply incrementing $numwords every time I added an element to $words, the memory limit of 8MB was fine. So my question is, if PHP does copy-on-write, why does PHP make a copy of an array when you use count() on it, which should NOT be modifying the array? For some reason the memory_get_usage() function wouldn't appear in my PHP compilation even after using the --enable-memory-limit flag, and rather than dig very deep, I whipped up the following script to test your issue (under PHP 4.2.2): That last line should have said 4.4.2 :) 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
Re: [PHP] Why does count() make copies of arrays?
Robert Cummings wrote: On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote: I was writing a shell script in PHP (4.4.2) that dealt with a rather large array. To figure out what I needed the new memory limit to be, I did a memory_get_usage() at the end of my script, and came up with about 5.5MB. I then set the memory limit to 8MB. When I tried to run it, the script ran out of memory on the line: $numwords = count($words); However, when I switched to simply incrementing $numwords every time I added an element to $words, the memory limit of 8MB was fine. So my question is, if PHP does copy-on-write, why does PHP make a copy of an array when you use count() on it, which should NOT be modifying the array? For some reason the memory_get_usage() function wouldn't appear in my PHP compilation even after using the --enable-memory-limit flag, and rather than dig very deep, I whipped up the following script to test your issue (under PHP 4.2.2): ?php //echo 'Mem Usage: '.memory_get_usage().\n; $foo = array(); for( $i = 0; $i 1000; $i++ ) { $foo[$i] = $i; } echo 'Created big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; $numEntries = count( $foo ); echo 'Counted big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; ? Using the following command: watch -n 0 'ps awxu | grep foo.php | grep -v grep' I got the following snapshots during the two sleep steps: rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php Which indicated no change from the 935 megs of memory already allocated before the count(). You've either encountered a bug in your version, or a confounding variable :) Cheers, Rob. That's the thing, count only creates a duplicate of the array (or consumes massive amounts of memory) *during* the call of count(). It frees the memory right after. The problem is that if you've got a 2MB array, you can't call count() on it because the temporarily increased memory usage will break the 4MB memory limit. Here's a better test case: 1) Ensure the memory limit is enabled and set to 4MB 2) Create an array that is 3MB in size 3) Try to call count() on that array With PHP 4.4.2, this will fail, because count will try to copy the array (or do something else that consumes a lot of memory). If you increase the memory limit to compensate, the memory usage goes back down immediately after the count call. For this reason, memory_get_usage() will never show the extra memory usage; it's allocated and freed entirely during the count() call. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include and require
Dave Goodchild wrote: I use a config file too. That was a sanity check. The file extract looked like this: $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); which was called in with require_once. The reference to $months in the calling page, checked with var_dump, was NULL. When I wrapped it like this: function getmonths() { $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); return $months; } it worked. Not sure why the simple variable didn't work. On 14/08/06, *Adam Zey* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dave Goodchild wrote: Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. I know for a fact that you can define variables in PHP 4 and 5. The idea behind include and require is little more complex than copying and pasting the code. Many of my scripts include a config.php which has various variables created with setting information. Regards, Adam Zey. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk Was the $months variable created inside an if statement or something else? PHP's rules of scope say that variables created inside a code block (like an if, a for, a while, a foreach), they stop existing the moment you exit that code block. So this: $foo = bar; if ( $foo == bar ) { $baz = narf; } echo $baz; That code will output nothing, because $baz is empty by the time I try to output it. The solution that I use is this: $foo = bar; $baz = ; if ( $foo == bar ) { $baz = narf; } echo $baz; In which case the output would be narf, because the variable existed before I changed it in the if. This sounds like it might be your problem, though I can't know without seeing the code. Regards, Adam Zey. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why does count() make copies of arrays?
On Mon, 2006-08-14 at 17:24 -0400, Adam Zey wrote: Robert Cummings wrote: On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote: I was writing a shell script in PHP (4.4.2) that dealt with a rather large array. To figure out what I needed the new memory limit to be, I did a memory_get_usage() at the end of my script, and came up with about 5.5MB. I then set the memory limit to 8MB. When I tried to run it, the script ran out of memory on the line: $numwords = count($words); However, when I switched to simply incrementing $numwords every time I added an element to $words, the memory limit of 8MB was fine. So my question is, if PHP does copy-on-write, why does PHP make a copy of an array when you use count() on it, which should NOT be modifying the array? For some reason the memory_get_usage() function wouldn't appear in my PHP compilation even after using the --enable-memory-limit flag, and rather than dig very deep, I whipped up the following script to test your issue (under PHP 4.2.2): ?php //echo 'Mem Usage: '.memory_get_usage().\n; $foo = array(); for( $i = 0; $i 1000; $i++ ) { $foo[$i] = $i; } echo 'Created big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; $numEntries = count( $foo ); echo 'Counted big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; ? Using the following command: watch -n 0 'ps awxu | grep foo.php | grep -v grep' I got the following snapshots during the two sleep steps: rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php Which indicated no change from the 935 megs of memory already allocated before the count(). You've either encountered a bug in your version, or a confounding variable :) Cheers, Rob. That's the thing, count only creates a duplicate of the array (or consumes massive amounts of memory) *during* the call of count(). It frees the memory right after. The problem is that if you've got a 2MB array, you can't call count() on it because the temporarily increased memory usage will break the 4MB memory limit. Here's a better test case: 1) Ensure the memory limit is enabled and set to 4MB 2) Create an array that is 3MB in size 3) Try to call count() on that array With PHP 4.4.2, this will fail, because count will try to copy the array (or do something else that consumes a lot of memory). If you increase the memory limit to compensate, the memory usage goes back down immediately after the count call. For this reason, memory_get_usage() will never show the extra memory usage; it's allocated and freed entirely during the count() call. When I ran the original test I was watching the process, it generally takes more than a second on most system to allocate several hundred megabytes which would have exposed your problem as a spike. At any rate... I figured out my problem with the recompile and then ran the script with appropriate settings. On the first run I determined the memory required and then for the second run I set the memory to an amount very close to what was used. Here is second script: #!/usr/local/bin/php -qC ?php ini_set( 'memory_limit', '627150412' ); echo 'Mem Usage: '.memory_get_usage().\n; $foo = array(); for( $i = 0; $i 1000; $i++ ) { $foo[$i] = $i; } echo 'Created big array!'.\n; echo 'Mem Usage: '.memory_get_usage().\n; $numEntries = count( $foo ); echo 'Counted big array!'.\n; echo 'Mem Usage: '.memory_get_usage().\n; ? Following I the output: Mem Usage: 41296 Created big array! Mem Usage: 627150256 Counted big array! Mem Usage: 627150320 Changing the memory limit from '627150412' to '627150212' result sin the expected memory limit exception: Mem Usage: 41296 br / bFatal error/b: Allowed memory size of 627150212 bytes exhausted (tried to allocate 12 bytes) in b/home/suds/foo.php/b on line b10/bbr / So I'm not experiencing your memory issue since due to the the immense size of the array I'm creating it would certainly show if a copy was performed. That said (and maybe this is related to the recent memory thread on internals that I sort of skipped over), I'm very surprised that while I allowed '627150412' bytes for memory, that the PHP process climbed to 900+ megs. It seems as though it doesn't account for it's own usage of memory, which is extremely misleading. Admittedly this kind of allocation on a production web site would normally be considered ludicrous, it still strikes me that the memory_limit ini setting is somewhat misleading -- in this case by about 30%. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com |
Re: [PHP] Why does count() make copies of arrays?
Robert Cummings wrote: On Mon, 2006-08-14 at 17:24 -0400, Adam Zey wrote: Robert Cummings wrote: On Mon, 2006-08-14 at 13:16 -0400, Adam Zey wrote: I was writing a shell script in PHP (4.4.2) that dealt with a rather large array. To figure out what I needed the new memory limit to be, I did a memory_get_usage() at the end of my script, and came up with about 5.5MB. I then set the memory limit to 8MB. When I tried to run it, the script ran out of memory on the line: $numwords = count($words); However, when I switched to simply incrementing $numwords every time I added an element to $words, the memory limit of 8MB was fine. So my question is, if PHP does copy-on-write, why does PHP make a copy of an array when you use count() on it, which should NOT be modifying the array? For some reason the memory_get_usage() function wouldn't appear in my PHP compilation even after using the --enable-memory-limit flag, and rather than dig very deep, I whipped up the following script to test your issue (under PHP 4.2.2): ?php //echo 'Mem Usage: '.memory_get_usage().\n; $foo = array(); for( $i = 0; $i 1000; $i++ ) { $foo[$i] = $i; } echo 'Created big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; $numEntries = count( $foo ); echo 'Counted big array!'.\n; sleep( 10 ); //echo 'Mem Usage: '.memory_get_usage().\n; ? Using the following command: watch -n 0 'ps awxu | grep foo.php | grep -v grep' I got the following snapshots during the two sleep steps: rob 16018 66.7 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php rob 16018 43.9 44.7 935084 928684 pts/7 S+ 17:11 0:18 /usr/local/bin/php -qC ./foo.php Which indicated no change from the 935 megs of memory already allocated before the count(). You've either encountered a bug in your version, or a confounding variable :) Cheers, Rob. That's the thing, count only creates a duplicate of the array (or consumes massive amounts of memory) *during* the call of count(). It frees the memory right after. The problem is that if you've got a 2MB array, you can't call count() on it because the temporarily increased memory usage will break the 4MB memory limit. Here's a better test case: 1) Ensure the memory limit is enabled and set to 4MB 2) Create an array that is 3MB in size 3) Try to call count() on that array With PHP 4.4.2, this will fail, because count will try to copy the array (or do something else that consumes a lot of memory). If you increase the memory limit to compensate, the memory usage goes back down immediately after the count call. For this reason, memory_get_usage() will never show the extra memory usage; it's allocated and freed entirely during the count() call. When I ran the original test I was watching the process, it generally takes more than a second on most system to allocate several hundred megabytes which would have exposed your problem as a spike. At any rate... I figured out my problem with the recompile and then ran the script with appropriate settings. On the first run I determined the memory required and then for the second run I set the memory to an amount very close to what was used. Here is second script: #!/usr/local/bin/php -qC ?php ini_set( 'memory_limit', '627150412' ); echo 'Mem Usage: '.memory_get_usage().\n; $foo = array(); for( $i = 0; $i 1000; $i++ ) { $foo[$i] = $i; } echo 'Created big array!'.\n; echo 'Mem Usage: '.memory_get_usage().\n; $numEntries = count( $foo ); echo 'Counted big array!'.\n; echo 'Mem Usage: '.memory_get_usage().\n; ? Following I the output: Mem Usage: 41296 Created big array! Mem Usage: 627150256 Counted big array! Mem Usage: 627150320 Changing the memory limit from '627150412' to '627150212' result sin the expected memory limit exception: Mem Usage: 41296 br / bFatal error/b: Allowed memory size of 627150212 bytes exhausted (tried to allocate 12 bytes) in b/home/suds/foo.php/b on line b10/bbr / So I'm not experiencing your memory issue since due to the the immense size of the array I'm creating it would certainly show if a copy was performed. That said (and maybe this is related to the recent memory thread on internals that I sort of skipped over), I'm very surprised that while I allowed '627150412' bytes for memory, that the PHP process climbed to 900+ megs. It seems as though it doesn't account for it's own usage of memory, which is extremely misleading. Admittedly this kind of allocation on a production web site would normally be considered ludicrous, it still strikes me that the memory_limit ini setting is somewhat misleading -- in this case by about 30%. Cheers, Rob. Further experimentation shows that the problem only occurs if the variable being count'd is a static variable inside a function. Of course, the original point still stands, static or no, count shouldn't make a copy. Here is a sample script that
Re: [PHP] Why does count() make copies of arrays?
On Mon, 2006-08-14 at 18:35 -0400, Adam Zey wrote: Further experimentation shows that the problem only occurs if the variable being count'd is a static variable inside a function. Of course, the original point still stands, static or no, count shouldn't make a copy. Here is a sample script that I can confirm reproduces the issue: ?php use_mem(); function use_mem() { static $foo = ; for ( $x=0; $x = 7; $x++ ) $foo[] = BwaHA . mt_rand(0, 100); echo memory_get_usage(); $numrows = count($foo); } ? PHP's default memory limit is 8MB. This script creates an array that's about 5.5MB. That part's fine. But it fails on that last line with the count($foo). I realize that this particular function doesn't need the variable to be static, but it's just a demonstration. My actual script had a function that needed some data to be read in from a file into an array. Rather than reading it in in the main script and passing it to the function, or having the function read the data in every execution, I simply made the variable static and had the function check if the variable was empty to see if it was the first time the function had been called. Sorry for not realizing that the static variable is the key to reproducing this issue. Does the script that I've pasted here give you any better luck in reproducing? Yep looks like a bug or a design choice based on static variables. I'm not sure what the reasoning is, but it sounds like static vars currently take a huge performance hit when containing large chunks of memory :/ I just tested your code using is_array() and got the same failure. 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
Re: [PHP] system, exec, shell_exec, passthru
Use exec() instead of system() and pass in args for output and error number and then you'll get an error number telling you what went wrong. You'll have to look up the error number in a shell with 'perror' (man perror) unless you dig my modest extension to do it from PHP: http://l-i-e.com/perror On Mon, August 14, 2006 10:23 am, [EMAIL PROTECTED] wrote: Hello, I am trying the run an external application with command line arguments using PHP under linux. ie: $command=myprog $arg1 $arg2 textfile.txt; system(echo \$command\ test.txt); system($command); $handle=fopen(textfile.txt,r); if($handle!=NULL) { while(!feof($handle)) { ... } fclose($handle); } I test my input arguments for the 'system' call by dumping the command into a text file. I can then test the command in the console. The commands work fine when run from the console. The commands don't work when run through the system command. I have tried system, exec, passthru, and shell_exec to no avail. Am I missing some permissions thing in my php.ini file? Thanks for any insight, Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 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 lost session variables.
On 8/15/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote: I´m in the follow location: https://www2.../?modulo=seguroacao=identifica And in my script i use header(Location: ./?modulo=seguroacao=novo_cadastro) i normally do header(Location: ?modulo=seguroacao=novo_cadastro); thats with out the ./ but i'm not sure if its has any effect. try it out anyway. i could not think of any reason why your session variables will disappear, unless you don't do session start() :) hehehe...(in which of course you do) if possible could you paste some of your codes so others can take a look at it. When it run, my system lost all session variables. BBC [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi guys. Anyone here know why in some cases when i use (header(Location: ???); the system lost the session variables? Any tips will be apreciated. Thanks in advantge. Please tell me the cases you mean..! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- GMail Rocks!!!
Re: [PHP] Re: system, exec, shell_exec, passthru
On Mon, August 14, 2006 12:25 pm, Michael Jonsson wrote: I can run any external program like ls, cp, uptime... But if a try to run my shell script a get error. $passwdexe = sudo /usr/bin/webpasswd; $user=$_POST[name]; $passwd=$passwdexe $user 123456; echo $passwd; $result = system($passwd); Resultat from the web, sudo /usr/sbin/webpasswd billy 12345678 and from the error_log, couldn't read file ./usr/sbin/webpasswd.: no such file or directory. In addition the the problem you know that you have, you're also blindly passing $_POST['name'] into the shell undo a sudo which is a pretty monstrous security hole... Use a full path to sudo for starters. And use escapeshellarg on $user Plus, given that it is a Un*x username, it almost for sure has a rather simple PCRE you could use on it to validate 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] Creating custom superglobals
On Mon, August 14, 2006 8:40 am, Ville Mattila wrote: Does the PHP environment (5.1.4) provide a way to define some custom variables as a superglobal? It would be useful for saving certain site preferences and settings that must be referred in many variables and classes, without every time writing global keyword at the beginning of a function definition. Not unless you want to install the RunKit extension, which pretty much lets you re-define ANYTHING in PHP... Probably a Bad Idea... $_SESSION might be a reasonable place to store your data, however, depending on what it is... Maybe I'm mis-understanding what you are storing, but it seems like the kind of stuff that belongs in $_SESSION... -- 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] Include and require
On Mon, August 14, 2006 4:20 pm, Dave Goodchild wrote: Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. Be 100% sure that the include_once is not being done inside of another function... If you can't figure it out, one quick test is to put 'global ' in front of the variable. If that fixes the problem, then you know that you DO in fact have a scope issue, whether you know why you have it or not. :-) -- 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] break up variable and put each element in an array
On Mon, August 14, 2006 2:41 am, Ivo F.A.C. Fokkema wrote: On Sat, 12 Aug 2006 16:36:36 -0500, Richard Lynch wrote: On Fri, August 11, 2006 3:11 am, Ivo F.A.C. Fokkema wrote: Well, if it's true that some browsers on some platforms ignore the W3C standard, I guess we could use: Or perhaps these browsers pre-date W3C standards. :-) Sure, but in newer versions, they might update their code to follow the standards after all... wouldn't they? Of course! But are all my users going to run out and upgrade because some W3C weenie (from their persepctive) told them to? No. In fact, *some* of my users are so economically-challenged that their hardware doesn't support a W3C-compliant browser due to memory constraints. So I'm going to provide backwards-compatible code which: does not break anything for W3C-compliant browsers supports ancient browsers costs almost nothing in CPU time for any reasonable-sized GET/POST Do you want to add to the Digital Divide by not supporting ancient hardware/software, or do you want to only provide web services to the wealthy :-) :-) :-) -- 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] Functions
On Sun, August 13, 2006 8:45 pm, Gerry D wrote: On 6/30/06, Richard Lynch [EMAIL PROTECTED] wrote: #2. Don't alter the case of the input data, if at all possible. Accept what the user has given, and take it as it is. You can make your application not care about case, and you can format the case on ouput (maybe even with fancy CSS stuff) but don't mess with their input. Why not clean up crappy input right at the source, Richard? Clean up crappy input, of course. Convert perfectly-valid NEWLINE into a tag BR for browser output, no. The conversion of the data for OUTPUT to a specific medium (browser, RSS, XML, WAP, FUTURE TECH #1*) should be done on OUTPUT, not INPUT. Othewise, to convert your input plain - HTML data to WAP, you first have to UNDO the plain - HTML conversion, then do a plain - WAP conversion. That's just daft. * You should get a warm fuzzy for recognizing this phrase. :-) -- 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] page redirecting
On Sun, August 13, 2006 6:49 pm, Gerry D wrote: On 6/28/06, Richard Lynch [EMAIL PROTECTED] wrote: On Wed, June 28, 2006 5:17 am, kristianto adi widiatmoko wrote: i need to redirecting page, it could be done by using header function like this header(Location : page2.php?var1=foo); Then, the URL should be a full, complete URL, and not just a local reference. Sure you can use a local page, I do it all the time. Allow me to re-phrase: The HTTP RFC Specs require that a Location: be a full complete URL starting with http:// It might work in all the browsers you have tested so far, but that does not make it right... :-) -- 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: Include and require
Adam Zey wrote: Dave Goodchild wrote: I use a config file too. That was a sanity check. The file extract looked like this: $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); which was called in with require_once. The reference to $months in the calling page, checked with var_dump, was NULL. When I wrapped it like this: function getmonths() { $months = array(1 = 'January', 2 = 'February', 3 = 'March', 4 = 'April', 5 = 'May', 6= 'June', 7 = 'July', 8 = 'August', 9 = 'September', 10 = 'October', 11 = 'November', 12 = 'December'); return $months; } it worked. Not sure why the simple variable didn't work. On 14/08/06, *Adam Zey* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dave Goodchild wrote: Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. I know for a fact that you can define variables in PHP 4 and 5. The idea behind include and require is little more complex than copying and pasting the code. Many of my scripts include a config.php which has various variables created with setting information. Regards, Adam Zey. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk Was the $months variable created inside an if statement or something else? PHP's rules of scope say that variables created inside a code block (like an if, a for, a while, a foreach), they stop existing the moment you exit that code block. So this: $foo = bar; if ( $foo == bar ) { $baz = narf; } echo $baz; That code will output nothing, because $baz is empty by the time I try to output it. That's wrong sorry :) $ php -a Interactive mode enabled ?php $foo = bar; if ( $foo == bar ) { $baz = narf; } echo $baz; narf Works fine. If you only create the variable inside the if you won't be able to use it if the code doesn't get into the if (it'll be an undefined variable): $ php -a Interactive mode enabled ?php error_reporting(E_ALL); if (1 == 0) { $foo = blah; } echo $foo; Notice: Undefined variable: foo in - on line 6 -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT? Verifying mail was received
On Sun, August 13, 2006 9:01 am, tedd wrote: Not because of any inherent problem with PayPal itself, but because the sheer volume of phishing/spam claiming to be PayPal made it impossible to find the legitimate PayPal traffic, which made PayPal useless to me. Different strokes for different folks. I've had very good experience with PayPal personally and with selling things via several sites world wide -- it works for me. PayPal worked great until I was getting several hundred bogus emails per day, which were resistant to automated filtering... Maybe I just wasn't smart enough to filter them correctly, or maybe the value of PayPal wasn't high enough for me, as I used it so seldom, but I haven't really felt this big gaping hole in my life without 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] header lost session variables.
On Mon, August 14, 2006 8:04 am, João Cândido de Souza Neto wrote: Anyone here know why in some cases when i use (header(Location: ???); the system lost the session variables? Yes. The browser gets headers such as this: Location: http://example.com Cookie: Example Value *SOME* browsers, as soon as they see that Location: line, will IMMEDIATELY go to the other URL, ignoring the Cookie line. Don't do that. If the Location: is your own PHP code, just include() it and do exit; and call it fixed. You can also try to throw a session_write_close (?) before the header(Location: ) line -- Others have posted some success with that, but I suspect it won't fix things for EVERY browser out there. -- 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] Creating custom superglobals
On 15/08/06, Richard Lynch [EMAIL PROTECTED] wrote: On Mon, August 14, 2006 8:40 am, Ville Mattila wrote: Does the PHP environment (5.1.4) provide a way to define some custom variables as a superglobal? It would be useful for saving certain site preferences and settings that must be referred in many variables and classes, without every time writing global keyword at the beginning of a function definition. ...or why not keep it simple and use include_once/require_once? I generally have a config file for every app that contains constants, variables and so on that are used across the application.
Re: [PHP] header lost session variables.
On Mon, August 14, 2006 6:56 pm, J R wrote: On 8/15/06, João Cândido de Souza Neto [EMAIL PROTECTED] wrote: I´m in the follow location: https://www2.../?modulo=seguroacao=identifica And in my script i use header(Location: ./?modulo=seguroacao=novo_cadastro) i normally do header(Location: ?modulo=seguroacao=novo_cadastro); thats with out the ./ but i'm not sure if its has any effect. try it out anyway. i could not think of any reason why your session variables will disappear, unless you don't do session start() :) hehehe...(in which of course you do) HTTP RFC Specs require that Location be a complete URL starting with http://; so you're pretty much both making a fundamental error here... :-) :-) :-) -- 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] SETCOOKIE
On Sun, August 13, 2006 2:20 am, Peter Lauri wrote: [snip] On Sat, August 12, 2006 8:00 am, Peter Lauri wrote: When you just use time() you tell the cookie to just live until now, so it dies directly. You have to add some seconds to determine how long the cookie will live. Unfortunately, no... The above solution relies on the USER computer clock being set correctly. [/snip] This is interesting. Because you set the time as the Server time, it will then just assume that the time is the same. However, is the system not that smart that it do translate the time when being sent (timestamp and expire time sent the same way, or just the number of seconds that the cookie will be alive from. If this is correct, what will happen if the server is in a different time zone? The time is GMT, so if everybody's computer clock is set correctly, and their BIOS setting for UTC versus GMT or whatever is correct, and ... So, pretty much, it's not something you want to rely on for short time periods... Probably better to set a very long expiration (2 years is max guaranteed to work by spec) and then manage all the expiration issues on the server, using the server clock, which should be self-consistent, if not correct. -- 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: Codigo de Captcha en PHP
On Mon, August 14, 2006 3:32 am, Julio B. wrote: Hay muchos y muy variados en Internet. En alguna ocasión he usado el que viene en sBlog. Es muy sencillo de implementar y para la mayoría de los casos suficiente para evitarnos problemas de spam. En código es: ?php $key = (array_key_exists('k', $_GET) strlen($_GET['k']) == 4) ? $_GET['k'] : strtolower(substr(md5(rand()), 0, 4)); $im = imagecreatetruecolor(40, 20); $bg = imagecolorallocate($im, 0, 0, 0); $col_text = imagecolorallocate($im, 255, 255, 255); imagestring($im, 4, 4, 1, $key, $col_text); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ? I can't read Spanish and am probably not answering your question, but if you are passing in ?k=ABCD and the image just contains ABCD, then the Bad Guy only has to see the URL and figure out how to get ABCD to break your CAPTCHA... Here is a very crude minimalistic example CAPTCHA implementation that you may find useful: http://voodookings.net/eyesonly_example.htm -- 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: Internet Explorer doesn't display UTF-8 page using UTF-8 encoding
My current theory is that IE needs BOTH header() and META charset to agree before it will believe you. :-) On Sat, August 12, 2006 8:05 pm, Jonny Bergström wrote: It's me again. I might have solved it... in a way. Still quite puzzled about why IE don't give a dime about the meta encoding line in the html head tag. Here's what I did. The aforementioned header file now adds a header() statement sending a content-type that also tells the charset, utf-8. : ---snip--- ?php header('Content-Type: text/html; charset=utf-8'); echo '?xml version=1.0 encoding=UTF-8?';? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html head meta name=Content-type content=text/html; charset=UTF-8 / ---snip--- I don't know if it's the best way to solve it but IE seems happy with it, and I haven't seen any sideeffects in FF so far. -- 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] script to check if form is submitted from the same page?
On Sat, August 12, 2006 5:57 pm, Afan Pasalic wrote: You're talking about something like captcha, right? No. FORM PAGE: ?php $token = uniqid(); //the following line is a gross abuse of a lack of error-checking: mysql_query(insert into tokens (token, used) values('$token', 'valid'); ? form ... input type=hidden name=token value=?php echo htmlentities($token);? / /form PROCESSING PAGE: ?php $token = $_POST['token']; //validate token here as 32-char alphanumeric or whatever uniqid() outputs... $used = mysql_query(select used from tokens where token = '$token'); $used = mysql_result($used, 0, 0); if ($used == 'valid'){ //process form (more bad code follows) mysql_query(update tokens set used = 'invalid' where token = '$token'); } else{ //You cannot re-submit this form. Sorry. } ? Richard Lynch wrote:On Sat, August 12, 2006 1:55 pm, Afan Pasalic wrote: could I use this code to check if form is submitted from the same page/same domain if ($_POST['form_submitted'] == 'Yes') { if (preg_match($_SERVER['HTTP_HOST'], $_SERVER[HTTP_REFERER]) == 0) { die ('^amp;[EMAIL PROTECTED]'); } }No. HTTP_REFERER is completely unreliable. If you want to be sure of the source of your POST data coming from your form, you need to send a unique unpredictable token in the FORM, and log it when you send the FORM, and then compare what comes back. -- 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] proxy server
On Sat, August 12, 2006 10:57 pm, John Taylor-Johnston wrote: I have a bulk emailing list to a select group (I never spam, only to those who want it). Sometimes their imap/pop servers block my mail. I know I can assign another smtp over-riding what is in the php.ini file. I can likely find enough code here: http://ca3.php.net/manual/en/ref.mail.php So, where can I find another smtp server that will send my mail (using php) and certify that it comes from me? Is a proxy server the way to go? Costly? Unless you know for 100% certain it is being filtered out based on the IP address being logged as a spammer somewhere, changing SMTP servers won't do diddly-squat... In other words, if the email LOOKS like a spam, and the spam filters are kicking in based on content, then it don't matter where it comes from. If, in fact, the IP you use to send email is in a list of known spammers (which is far too easy to happen) and then the email is getting blocked for that reason, finding another host to run email out is pretty much just finding another webhost. There presumably are specialists who handle bulk email that you can pay just for sending email, but their prices may well be no better than just setting up a different cheap webhost, unless you have SUPER high volume email. -- 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] script to check if form is submitted from the same page?
And I assume that this should be reused to minimize the time spent on this by creating a form class or function, correct? I have been thinking about this too, and it makes a lot sense to do like this. /Peter -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 15, 2006 7:47 AM To: Afan Pasalic Cc: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] script to check if form is submitted from the same page? On Sat, August 12, 2006 5:57 pm, Afan Pasalic wrote: You're talking about something like captcha, right? No. FORM PAGE: ?php $token = uniqid(); //the following line is a gross abuse of a lack of error-checking: mysql_query(insert into tokens (token, used) values('$token', 'valid'); ? form ... input type=hidden name=token value=?php echo htmlentities($token);? / /form PROCESSING PAGE: ?php $token = $_POST['token']; //validate token here as 32-char alphanumeric or whatever uniqid() outputs... $used = mysql_query(select used from tokens where token = '$token'); $used = mysql_result($used, 0, 0); if ($used == 'valid'){ //process form (more bad code follows) mysql_query(update tokens set used = 'invalid' where token = '$token'); } else{ //You cannot re-submit this form. Sorry. } ? Richard Lynch wrote:On Sat, August 12, 2006 1:55 pm, Afan Pasalic wrote: could I use this code to check if form is submitted from the same page/same domain if ($_POST['form_submitted'] == 'Yes') { if (preg_match($_SERVER['HTTP_HOST'], $_SERVER[HTTP_REFERER]) == 0) { die ('^amp;[EMAIL PROTECTED]'); } }No. HTTP_REFERER is completely unreliable. If you want to be sure of the source of your POST data coming from your form, you need to send a unique unpredictable token in the FORM, and log it when you send the FORM, and then compare what comes back. -- 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] Internet Explorer doesn't display UTF-8 page using UTF-8 encoding
IE does some really funky things attempting to guess the charset, because it assumes that web developers and web designers just don't understand this charset stuff... And they may be correct, as a general rule, but it sure makes life tough when you actually send out the correct headers and META tags and it doesn't work... I think one other wrinkle is in the DOCTYPE -- A more current DOCTYPE is assumed by IE, I think, to mean that you know what you are doing, and it pays attention to the META tag. It's still a lot like Voodoo to get IE to do anything, though... I know in at least one instance, IE honored the META tag, but not the header() charset. Sigh. Took me days to track that one down. On Sat, August 12, 2006 7:47 pm, Jonny Bergström wrote: but Firefox does. this is the page: http://shiinaringo.se/guestbook.php You can see that a lot of characters (Swedish, Japanese) are totally garbled when using IE. Works fine in FF. If you try to look at some of the other pages linked to in the menu, they will work with IE as well. So I just don't know what is the problem with this one page. All pages on this site includes a header file which starts with: ---cut--- ?php echo '?xml version=1.0 encoding=UTF-8?';? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html head meta name=Content-type content=text/html; charset=UTF-8 / ---cut--- Which means that in my view I tell the browser through the meta tag which charset is used (UTF-8). However IE doesn't seem to give a damn about this. I'm pulling my hair. :-( -- 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] Chicago PHP Conference
For the US folks, Chicago is centrally-located, and flights to O'Hare and Midway are generally frequent and often go on sale. Global visitors might want to fly to Toronto or some other CA city close to Chicago and drive, though :-) I'm hopeful that by Spring 2007, flying to the US will be a less unpleasant experience than it is currently... On Sat, August 12, 2006 5:23 pm, Gerry D wrote: Richard, Within the US that might be ok, but given latest developments, who wants to fly into the US from elsewhere? I could drive from Canada if I take 2 weeks vacation... I don't want to be a show stopper, but I think you need to explain what your target audience is re global travel, not just weather in Chicago. Having said that, I like your idea. Gerry On 8/12/06, Richard Lynch [EMAIL PROTECTED] wrote: It may have started as a joke on PHP-General, but this just isn't funny anymore. I'm in the pre-planning phase of organizing a PHP Conference in Chicago. Due to Chicago weather patterns, the ideal time would be Spring or Autumn. Given that cheap airfare generally requires significant advance notice, I am pre-emptorily eliminating Autumn 2006 as a viable option. If you are interested in attending please reply OFF-LIST with your name, email, and some basic input for ideal time-frames in the FALL or SPRING of 2007. Suggested Topics would be great, and offers to be a Speaker by well-known responders would also be MOST welcome. -- 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: Internet Explorer doesn't display UTF-8 page using UTF-8 encoding
On Sun, August 13, 2006 1:43 pm, Rasmus Lerdorf wrote: tedd wrote: At 6:48 PM -0700 8/12/06, Rasmus Lerdorf wrote: By the way, everyone should be setting a charset. If you don't set it, IE will look at the first 4k of the body of the page and take a wild guess. -Rasmus -Rasmus: Ok, but why doesn't w3c use it? http://validator.w3.org (check source) I'm not sure what to do re charset. I've been told by credible sources to always use it and never use it -- which is correct? Or, is this one of those it depends things? W3C is all about standards. IE is all about not following standards. If you want your site to work in the real world you should always set a charset. If you set it in your response header there is no need to set it in each page, and if you look closely, you will see that this is what w3.org is doing: 9:55am shiny:~ telnet validator.w3.org 80 Trying 133.27.228.132... Connected to validator.w3.org. Escape character is '^]'. HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Sun, 13 Aug 2006 18:42:15 GMT Server: Apache/2.0.54 (Debian GNU/Linux) mod_perl/1.999.21 Perl/v5.8.4 Accept-Ranges: bytes Connection: close Content-Type: text/html; charset=utf-8 If you want it to actually WORK in IE, you need both header() and META tag... At least in my limited testing so far under UTF-8 and Transition DOCTYPE. YMMV This is no guarantee that IE will work under any other DOCTYPEs, nor in any other versions of IE. Only that I know that's what it took for the current version of IE I was using a month or two ago. It would be interesting if somebody who understood charsets MUCH better than I were to test all the combinations of: IE version X header/meta charset Xmany charsets and see just how many of them actually work, and how many of them open up IE to XSS attacks... What a mess MS makes of things! -- 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] Chicago PHP Conference
-- I'm hopeful that by Spring 2007, flying to the US will be a less unpleasant experience than it is currently... -- As in the border guards would start stocking lubricant as well as rubber gloves? Windsor, Ontario Canada would probably be a better flight destination (you would likely end up hubing through toronto anyways, but would save you 3 hours of driving). Though the Windsor/Detroit border crossing is the busiest, and the guards there take it pretty seriously (ok, so I may have been deported once). paul On 8/14/06, Richard Lynch [EMAIL PROTECTED] wrote: For the US folks, Chicago is centrally-located, and flights to O'Hare and Midway are generally frequent and often go on sale. Global visitors might want to fly to Toronto or some other CA city close to Chicago and drive, though :-) I'm hopeful that by Spring 2007, flying to the US will be a less unpleasant experience than it is currently... On Sat, August 12, 2006 5:23 pm, Gerry D wrote: Richard, Within the US that might be ok, but given latest developments, who wants to fly into the US from elsewhere? I could drive from Canada if I take 2 weeks vacation... I don't want to be a show stopper, but I think you need to explain what your target audience is re global travel, not just weather in Chicago. Having said that, I like your idea. Gerry On 8/12/06, Richard Lynch [EMAIL PROTECTED] wrote: It may have started as a joke on PHP-General, but this just isn't funny anymore. I'm in the pre-planning phase of organizing a PHP Conference in Chicago. Due to Chicago weather patterns, the ideal time would be Spring or Autumn. Given that cheap airfare generally requires significant advance notice, I am pre-emptorily eliminating Autumn 2006 as a viable option. If you are interested in attending please reply OFF-LIST with your name, email, and some basic input for ideal time-frames in the FALL or SPRING of 2007. Suggested Topics would be great, and offers to be a Speaker by well-known responders would also be MOST welcome. -- 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 -- Paul Reinheimer Zend Certified Engineer
Re: [PHP] proxy server
I have a bulk emailing list to a select group (I never spam, only to those who want it). Sometimes their imap/pop servers block my mail. I know I can assign another smtp over-riding what is in the php.ini file. I can likely find enough code here: http://ca3.php.net/manual/en/ref.mail.php So, where can I find another smtp server that will send my mail (using php) and certify that it comes from me? Is a proxy server the way to go? Costly? Unless you know for 100% certain it is being filtered out based on the IP address being logged as a spammer somewhere, changing SMTP servers won't do diddly-squat... I'm sure. CGI proxy I think is the key word I'm looking for. I would even pay $10 per year for an SMTP access account if it fixed my problems. John -- John Taylor-Johnston - If it's not Open Source, it's Murphy's Law. '''Cégep de Sherbrooke: ô¿ôhttp://www.cegepsherbrooke.qc.ca/languesmodernes/ - 819-569-2064 °v° Bibliography of Comparative Studies in Canadian, Québec and Foreign Literatures /(_)\ Université de Sherbrooke ^ ^ http://compcanlit.ca/ T: 819.569.2064
[PHP] php and dynamic forms
Can anyone tell me if this is possible- I currrently have a simple form with a textbox and submit button where a user chooses a number from 1-22 then on submit it opens another page with a table of results within another form. What i need is for the second form to be shown on the same page and just below form 1, then when the second form is submitted it then goes back to just form1. What i am trying to do is get rid of multiple pages and have the user stay on the same page for all admin functions. Bigmark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php and dynamic forms
On Tue, 2006-08-15 at 11:01 +0800, Bigmark wrote: Can anyone tell me if this is possible- Yes it is. I currrently have a simple form with a textbox and submit button where a user chooses a number from 1-22 then on submit it opens another page with a table of results within another form. What i need is for the second form to be shown on the same page and just below form 1, then when the second form is submitted it then goes back to just form1. What i am trying to do is get rid of multiple pages and have the user stay on the same page for all admin functions. Bigmark -- .. | 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] Re: php and dynamic forms
Does anyone have a simple example script. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php