[PHP] Re: Alternatives to Flush()
Ron Stagg wrote on 24/03/04 22:02: I have a particular PHP web page that can take over an hour to process. When visitors come to this page, I want the code to redirect them to a separate page at my site. After the redirection, I want the PHP script to continue operating on its own until the process is complete. I am attempting to implement this is by sending a Location header to the client. This header is sent out near the top of the script. After sending the header, I call Flush(), then the script continues into the heavy lifting. Finally, the script quietly terminates with an exit call. Neither the flush() or ob_flush() calls are working (I even tried calling them both). Regardless of what I do, the server will not send the Location header until the script has completely terminated. It appears that my hosting provider has Flush() disabled. I have thought about using Chron to accomplish this. However, the smallest Chron resolution is minutes. This could cause the visitor to wait for up to a minute before Chron wakes up and starts working on the process. There has got to be a better way. Does anybody have any recommendations? Thanks, Ron I could be completely misreading the issue here, but it is perfectly possible to use a Location header redirect in combination with further script execution in the background using PHP's register_shutdown_function(). The specifics and complexity of your actual script are unknown to the list, so I can only refer you to the manual (and the user contributed notes) for further inspiration and investigation: http://www.php.net/manual/en/function.register-shutdown-function.php HTH, Dirk Maetens PHP hobbyist -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mcrypt win32 install problem ?
Tom Rogers wrote: Hi, Wednesday, January 21, 2004, 9:09:40 PM, you wrote: VD Hi, VD I want to use the mcrypt module and I followed the VD instructions to install the dll for Win32 users : VD I copied the libmcrypt.dll file under c:\winnt\system32 VD I uncommented the extension=php_mcrypt.dll in the php.ini VD I restarted the computer VD I tried many examples available in the Net. The result is always the same : VD I can crypt a plain text but I cannot Uncrypt that text. Do VD you see any potential reason to this? VD I guess this problem is related to my computer / configuration... VD current config VD PHP 4.3.4 VD Win 2000 VD PEAR VD php in fo seems correct about mcrypt It seems they changed the name of the deinit function in windows, use mcrypt_generic_end($td); instead of mcrypt_generic_deinit($td); -- regards, Tom Hi Tom, Vincent, list, Tom, your response caused some confusion here. I have mcrypt running on win32 (Win98, Apache 1.3.29 2.0.48, PHP 4.3.4 PHP 5beta3) and am in fact using mcrypt_generic_deinit() succesfully to encrypt/decrypt... This in accordance to the most recent PHP documentation, which exactly opposes your statement: mcrypt_generic_end (PHP 4 = 4.0.2) mcrypt_generic_end -- This function terminates encryption Description bool mcrypt_generic_end ( resource td) Warning This function is deprecated, use mcrypt_generic_deinit() instead. It can cause crashes when used with mcrypt_module_close() due to multiple buffer frees. So maybe something else is causing Vincent's problem to decrypt. Without further code snippets it is very hard to pin it down... Regards, speedfreak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] internally stored binary image
In order to distribute a single script I would like to store a small image internally. Is this at all possible with PHP? How would I go about it? Please feel free to rtfm me to the relevant sections. Thx in advance, [EMAIL PROTECTED] PS: CC me please, as I'm on the digest... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] internally stored binary image
Ernest E Vogelsinger wrote: At 15:57 20.03.2003, [EMAIL PROTECTED] spoke out and said: [snip] In order to distribute a single script I would like to store a small image internally. Is this at all possible with PHP? How would I go about it? Please feel free to rtfm me to the relevant sections. [snip] You could make some script to retrieve the hex values of the image byte by byte, then create a source file like $imgdata = '\xff\x19\x00\x12 etc...; Then when you're about to send the image simply transmit the correct header() and echo out the data. This little sample works just perfectly: // use one of your files here, of course... $file = 'images/dart.gif'; $hf = fopen($file, 'r') or die(Can't open $file for reading); $bin = fread($hf, filesize($file)); fclose($hf); $asc = '$img_data = '; for ($i = 0, $len = strlen($bin); $i $len; ++$i) { if ($i !($i % 16)) $asc .= \ .\n\t\; $asc .= '\\x' . bin2hex(substr($bin, $i, 1)); } $asc .= ';'; // $asc now contains the hex-coded binary file. // Example (a real gif - try it) $img_data = \x47\x49\x46\x38\x39\x61\x20\x00\x20\x00\xa2\xff\x00\x00\x00\x00 . \xff\x00\x00\xff\xff\x00\x00\x00\xff\xc0\xc0\xc0\x00\x00\x00\x00 . \x00\x00\x00\x00\x00\x21\xf9\x04\x01\x00\x00\x04\x00\x2c\x00\x00 . \x00\x00\x20\x00\x20\x00\x40\x03\xae\x48\xba\xac\xf0\x10\x34\x36 . \x06\x83\x21\x87\xc8\xa3\xd0\xd0\x82\x65\xe3\xd6\x81\x0f\x2a\x89 . \x25\x79\x6a\xe6\x33\xb1\x29\x6c\xab\x80\xd0\x94\x11\x8c\x7d\x31 . \x80\xca\x51\x0b\xde\x70\xc3\x19\xa1\xc3\x8c\x28\x67\xcd\xe8\xa2 . \x52\xb9\xb4\x82\x57\x41\xc8\x2a\x74\x15\x6f\xda\xe2\x96\x27\x7e . \x0c\x04\x5a\xd5\x90\xfc\x6d\xf5\xbc\x34\x5f\xd4\x2d\x83\x5e\x8f . \xc1\xe7\x93\xa9\xef\x2f\xe7\x75\x53\x54\x76\x6f\x36\x1d\x0a\x02 . \x55\x3b\x77\x78\x26\x5a\x84\x5d\x5e\x4d\x19\x1f\x4e\x71\x38\x91 . \x5e\x69\x49\x7f\x91\x8c\x94\x31\x49\x6c\x72\x39\x40\x5e\x6b\x65 . \x9e\x66\x03\xa9\xa8\xaa\x99\x1c\xa4\xa2\xad\x8d\xa1\x70\x44\xb0 . \x85\x92\xb9\x2b\xb8\xbc\x93\x38\x90\xb5\x86\x5b\x7b\xb1\x37\x87 . \x7e\x34\x73\xca\xcd\xce\x09\x00\x3b; // Now write the stuff to a file $hf = fopen($file.asc, 'w') or die(Can't open $file.asc for writing); fwrite($hf, $asc); fclose($hf); // Here you may either include the file, or copy/paste its contents into your own code. // The next lines are just to test the stuff - adjust the Content-Type header to your needs: header('Content-Type: image/gif'); eval($asc); // this will render the binary content into $img_data echo $img_data; // send it exit;// and voila Note that reading the file is only needed once as a tool to create the ascii version of the binary file. -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ BullsEye indeed! After adjusting for win32 (added 'b' to fopen's) this script is a little gem. You really saved me quite some headaches. Thanks! -speedfreak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] contact list re-ordering (php/mySQL CMS design)
Dear guru's, Hit a problem while developing a CMS with php/mySQL. Part of this is a contact list and this works ok (add/edit/delete with insert/update/delete queries). Now the client has requested a new feature: ability to change the order in which the contacts are being presented in the public part of this CMS (don't ask me why). I've added a field 'show_pos' to the contacts table and am able to change its value when I edit an existing record or add a new one. What I can't wrap my head around at the moment is how one deals with updating 'show_pos' for the OTHER records (while editing/deleting present record (WHERE id='$id')? Could anyone give me some pointers as to how this could be done in php and/or SQL (preferable). I sure hope anyone understands what I mean ... Cheers! newbie@a_loss -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Euro symbol [textarea/e-mail]
Hi PHP guru's, I've got a working script that picks up a msg from a textarea and (after validation etc.) mails out a plain text confirmation e-mail (using fsockopen). So far, so good. Only problem is when the textarea contains the Euro symbol, it is replaced in the plain mail (replaced by ¤). Does anyone have any hints on how to solve this? PS: I am aware of the $euro = htmlentities(¤,ENT_QUOTES,iso-8859-15); way of outputting the Euro symbol in HTML... Dev: PHP 4.1.2/Apache 1.3.24/Win98 Prod: PHP 4.1.2/Apache 1.3.24/Unix TIA, DirkOS -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] store file using socket/fopen
Hello list, Simple Enough Objective: store file remotely (wu-ftp); MinorSnag: PHP's ftp-functions unavailable at localhost; BelowWorkaround: works fine for deleting remote file; MajorSnag: how to STORE a file remotely using socket? ?php $ftp=fsockopen(ftp.server.com, 21, $errno, $errstr, 60); if (!$ftp) { echo Connection failed: $errstr ($errno); exit; } else { socket_set_blocking($ftp, true); echo fgets($ftp,255); fputs($ftp,USER ftp_username\r\n); echo fgets($ftp,255); fputs($ftp,PASS ftp_passw\r\n); echo fgets($ftp,255); fputs($ftp,DELE /home/httpd/html/test.htm\r\n); echo fgets($ftp,255); fputs($ftp,QUIT\r\n); echo fgets($ftp,255); fclose($ftp); } ? BTW: I also messed with fopen(ftp://user:pass@...;) but failed miserably (although it seemed possible before my mind wandered off). ANY HELP IS APPRECIATED (using socket, fopen, ...) -- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] upload file using socket/fopen
Hello list, Simple Enough Objective: store file remotely (wu-ftp); MinorSnag: PHP's ftp-functions unavailable at localhost; BelowWorkaround: works fine for deleting remote file; MajorSnag: how to STORE a file remotely using socket? ?php $ftp=fsockopen(ftp.server.com, 21, $errno, $errstr, 60); if (!$ftp) { echo Connection failed: $errstr ($errno); exit; } else { socket_set_blocking($ftp, true); echo fgets($ftp,255); fputs($ftp,USER ftp_username\r\n); echo fgets($ftp,255); fputs($ftp,PASS ftp_passw\r\n); echo fgets($ftp,255); fputs($ftp,DELE /home/httpd/html/test.htm\r\n); echo fgets($ftp,255); fputs($ftp,QUIT\r\n); echo fgets($ftp,255); fclose($ftp); } ? BTW: I also messed with fopen(ftp://user:pass@...;) but failed miserably (although it seemed possible before my mind wandered off). ANY HELP IS APPRECIATED (using socket, fopen, ...) -- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]