[PHP] Re: php-general Digest 1 Jan 2007 20:15:42 -0000 Issue 4545
-- Forwarded message -- From: "Philip W." <[EMAIL PROTECTED]> To: php-general@lists.php.net Date: Mon, 01 Jan 2007 15:15:07 -0500 Subject: Writing Binary Hello Everyone, I'm trying to write a PHP script that opens a binary file, reads the binary in chunks, checks those chunks for a certain binary string, and then if the string is found, it replaces the string with another binary string. The script should then a copy of the file, including the changed bits. But for some reason, the script is not replacing the binary string. Here's the source code: The resulting file is not changed at all, the size, md5 sums, and contents are the same as the original file. The original file is only 40,960 bytes on the disk, so the script reads the file in one pass. I am sure the binary string is in the original file, and I have tried reading the file into chunks as small as 64 bytes. I am at a loss as to what is happening, so I would appreciate any help. Sincerely, Philip W. This article might help you out http://www.onlamp.com/pub/a/php/2002/12/12/php_foundations.html -- Regards Fahad Pervaiz www.ecommerce-xperts.com
Re: [PHP] Javascript detection , working version
At 4:54 PM -0800 1/1/07, =?UTF-8?Q?J=C3=BCrgen_Wind?= wrote: well, no cute css, but (hopefully) working - here is my quick & dirty version : http://149.222.235.16/public/ -- Well, it's cute enough for me ! It works on every browser that BrowserCam has -- hell, I can't even get my web site to do that. Much thanks. tedd PS: Too bad my email doesn't translate your name right. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript detection , working version
well, no cute css, but (hopefully) working - here is my quick & dirty version : http://149.222.235.16/public/ -- View this message in context: http://www.nabble.com/Javascript-detection-tf2905451.html#a8118787 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Basic question - Starting a background task without waiting for its end.
2006/12/31, Michel <[EMAIL PROTECTED]>: I (very simply) try to open a "notepad" on a simple text file in a simplistic PHP script, and would like to go on and display the next page without waiting for this notepad to be shut. After various attempts, I have used an : exec ('bash -c cmd /C start /MAX notepad "my_file" > NUL'); ... but it still wait for the shutting of the notepad ..! Could anybody help me ? For clarification : 1) I use this script on a machine which is in the same time "server" and "client", which gives "meaning" to this operation. 2) I use "bash -c" because I have the cygwin platform which can easily initiate tasks in background, but it could be suppressed, because it "de facto" changes nothing... Thank's for help. Michel. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Have you tried the following? exec ('bash -c cmd /C start /MAX notepad "my_file" > NUL &');
Re: [PHP] Javascript detection
On Mon, 2007-01-01 at 16:14 -0500, tedd wrote: > Hi gang: > > I've asked this request on a couple of other list, but considering > that I've done this with a mixture of php and javascript, perhaps > some of you might check this out for me. > > Try this: > > http://sperling.com/js_detect > > Does this technique work to detect your browser's javascript setting? > > Also, if you change your browser's javascript setting, please restart > your browser before rechecking the link. > > If this works well enough, I'll post the code. It doesn't seem to be working for anyone (me neither btw)... why not use a simpler approach? Here's an example that doesn't use a redirect. Due to using the onload mechanism we can be certain that the order of the updates to the session occurs in expected order (if javascript is enabled) which is as we want. Feel free to use as you please... Javascript NOT detected! 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] Javascript detection
does not work on SeaMonkey and Opera (IE not tested). -- View this message in context: http://www.nabble.com/Javascript-detection-tf2905451.html#a8117266 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing Binary
# [EMAIL PROTECTED] / 2007-01-01 15:15:07 -0500: > Hello Everyone, >I'm trying to write a PHP script that opens a binary file, reads the > binary in chunks, checks those chunks for a certain binary string, and > then if the string is found, it replaces the string with another binary > string. The script should then a copy of the file, including the > changed bits. But for some reason, the script is not replacing the > binary string. > > Here's the source code: > > > $in = fopen("C:\NeighborhoodManager.package", "rb"); > $out = fopen("C:\NeighborhoodManager2.package", "w"); > $count = 0; > > while (!feof($in)) { > $count++; > $buffer = fread($in,5); > if > (eregi("01010011011101000111001001110110111001100111011001010111010001100111011101101110",$buffer)) Binary mode ("rb") doesn't mean PHP will translate each bit of the data into a 7-bit (or longer) textual representation. http://www.php.net/manual/en/function.pack.php http://www.php.net/manual/en/function.unpack.php -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Javascript detection
I do have javascript enabled, but it does not detect it... Best regards, Peter Lauri www.dwsasia.com - company web site www.lauri.se - personal web site www.carbonfree.org.uk - become Carbon Free -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Monday, January 01, 2007 11:14 PM To: php-general@lists.php.net Subject: [PHP] Javascript detection Hi gang: I've asked this request on a couple of other list, but considering that I've done this with a mixture of php and javascript, perhaps some of you might check this out for me. Try this: http://sperling.com/js_detect Does this technique work to detect your browser's javascript setting? Also, if you change your browser's javascript setting, please restart your browser before rechecking the link. If this works well enough, I'll post the code. Thanks. tedd PS: I wrote this simply because I couldn't find an acceptable PHP "Javascript detection" solution. If anyone knows of something better, please let me know. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript detection
On Mon, 1 Jan 2007 16:14:06 -0500, tedd <[EMAIL PROTECTED]> wrote: > Does this technique work to detect your browser's javascript setting? Not for me, it says "Javascript has not been detected on the client." when in fact I've got JavaScript enabled (Firefox 1.5.0.8 on Ubuntu Linux). Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Javascript detection
Hi gang: I've asked this request on a couple of other list, but considering that I've done this with a mixture of php and javascript, perhaps some of you might check this out for me. Try this: http://sperling.com/js_detect Does this technique work to detect your browser's javascript setting? Also, if you change your browser's javascript setting, please restart your browser before rechecking the link. If this works well enough, I'll post the code. Thanks. tedd PS: I wrote this simply because I couldn't find an acceptable PHP "Javascript detection" solution. If anyone knows of something better, please let me know. -- --- 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] Writing Binary
Hello Everyone, I'm trying to write a PHP script that opens a binary file, reads the binary in chunks, checks those chunks for a certain binary string, and then if the string is found, it replaces the string with another binary string. The script should then a copy of the file, including the changed bits. But for some reason, the script is not replacing the binary string. Here's the source code: if (eregi("01010011011101000111001001110110111001100111011001010111010001100111011101101110",$buffer)) { $buffer2=eregi_replace("01010011011101000111001001110110111001100111011001010111010001100111011101101110","01010110011010010110001101110100011001110010011010010111",$buffer); } else { $buffer2 = $buffer; } fwrite($out,$buffer2); } fclose($out); fclose($in); print("About ".($count*5)." bytes read.\n"); ?> The resulting file is not changed at all, the size, md5 sums, and contents are the same as the original file. The original file is only 40,960 bytes on the disk, so the script reads the file in one pass. I am sure the binary string is in the original file, and I have tried reading the file into chunks as small as 64 bytes. I am at a loss as to what is happening, so I would appreciate any help. Sincerely, Philip W. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Snow on the logo
On Mon, 1 Jan 2007 10:50:04 -0500, tedd <[EMAIL PROTECTED]> wrote: > However, does the php logo change for those in the southern > hemisphere? In other words, for oz programmers, do they see a > different logo? If so, how does one (or can) detect the user's > hemisphere? Detecting a user's geographical location is a bit hit and miss, but there are some databases (both free and paid for) that you can use to map an IP address to a country and at that level it's usually fairly accurate (the further you try to narrow it down, the less accurate your results will be). Have a look at these databases, and a search for 'geoip' or 'libgeoip' on Google should get you some more results: http://www.hostip.info/ http://www.maxmind.com/app/geoip_country Hope this helps. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Snow on the logo
Hi gang: I've just noticed that the php.net logo changes with the seasons -- I think that's neat, in fact, I do a similar season change with my site. However, does the php logo change for those in the southern hemisphere? In other words, for oz programmers, do they see a different logo? If so, how does one (or can) detect the user's hemisphere? 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
Re: [PHP] Best way to manage open slots for download
At 10:15 AM -0500 12/31/06, Rasmus Lerdorf wrote: > What other ways can you recommend to me for the situtation? Read through this: http://www.php.net/manual/en/features.connection-handling.php -Rasmus -Rasmus: Just want to express my gratitude for your attendance to this list. 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
Re: [PHP] Temporary Emails - Your Recommendations - An Appeal to the PHP Community
At 5:26 AM -0500 1/1/07, Jason Paschal wrote: i realize this isn't the appropriate mailing list and i risk being black-listed (flame, defamed, ignored, etc.). i occasionally use temporary emails when registering for forums or to get some shareware (we've all done it, don't give me that look, i have given what i could, when i could) and while i like the way mytrashmail.com works, i don't like having mytrashmail.com as part of the temp addy. does anyone know of a similar service that uses a more enticing domain? thank you, jason jason: A couple ideas: 1. I've used the same email address (my name) for almost 12 years. It's on more spam list than I care to count, but that doesn't brother me because I filter all my email through spamcop.net. My spam count is below 5% of total email received BY ME. You might consider their services for $35US pr year. 2. You can always buy domains (<$10 per year), set them up via cheap hosting (<$10 per year), and have as many addresses as you want. tedd PS: I've never used temporary emails for anything other than testing. -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Request of php5
Roman Neuhauser wrote: ># [EMAIL PROTECTED] / 2007-01-01 14:40:14 +0800: > > >>Dear All, >> >>Happy New Year, >> >>How much mem ( Ram ) does the php5 need ? >> >> > >As much as you make it use. > > > Sorry, pardon me !
[PHP] [PHP-DEV] Semaphores - feature request
It's impossible to correct remove semaphores with sem_remove function when I use them to provide execution of concurrent processes. When the last process releases the semaphore I should be able to remove it. But I don't know if another process haven't acquired the semaphore. For safety reasons I don't remove released semaphores from system. Now, If I get 128 semaphores and I execute sem_get one more time I will get warning. So, I can't remove semaphores (because I don't know if another process is using it) and I can't get next semaphore. I will try to tell about my sugestion. I assume that I have a function my_sem_remove($sem_id): function my_sem_remove($id) { if(Semaphore $id isn't acquired and its FIFO is empty) sem_remove($id); } None of instructions in this function can be interrupted. So, now the problem is simple to resolve: $id = sem_get(ID); sem_acquire($id); CRITICAL REGION sem_release($id); my_sem_remove($id); But now, two instructions: sem_release and my_sem_remove are not needed. It's simple to replace them by one function my_sem_release: function my_sem_release($id) { sem_release($id); my_sem_remove($id); } For reasons which about I will write later those instructions can't be interrupted. So, my example look like this: $id = sem_get(ID); sem_acquire($id); CRITICAL REGION my_sem_release($id); But let's imagine two concurrent processes executing code above: PROC1: $id = sem_get(ID); <--- interrupt PROC2: $id = sem_get(ID); sem_acquire($id); CRITICAL REGION my_sem_release($id); <--- interrupt PROC1: sem_acquire($id); <--- Uuups!! Error: semaphore doesn't exists, PROC2 has removed it. My solution: Instructions sem_get and sem_acquire can't be interrupted. So, I assume that there is a function my_sem_acquire: function my_sem_acquire($key, $max_acquire = 1, $perm = 0666, $auto_release = true) { $id = sem_get($key, $max_acquire, $perm, $auto_release); sem_acquire(); return $id; } None of instructions in function above can be interrupted. And finally correct example: $id = my_sem_acquire(SEMKEY); CRITICAL REGION my_sem_release($id); It's the best solution, without danger of operating on not existing semaphores. Also, unused semaphores are automaticcally removed. The problem is, that functions my_sem_acquire and my_sem_release can't be witten in PHP so it must be done in C inside source of PHP.Wojciech Malota -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Temporary Emails - Your Recommendations - An Appeal to the PHP Community
# [EMAIL PROTECTED] / 2007-01-01 05:26:43 -0500: > i realize this isn't the appropriate mailing list and i risk being > black-listed (flame, defamed, ignored, etc.). > > i occasionally use temporary emails when registering for forums or to get > some shareware (we've all done it, don't give me that look, i have given > what i could, when i could) and while i like the way mytrashmail.com works, > i don't like having mytrashmail.com as part of the temp addy. > > does anyone know of a similar service that uses a more enticing domain? you-can.diy a domain costs pennies and all the required software is free. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Request of php5
# [EMAIL PROTECTED] / 2007-01-01 14:40:14 +0800: > Dear All, > > Happy New Year, > > How much mem ( Ram ) does the php5 need ? As much as you make it use. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Temporary Emails - Your Recommendations - An Appeal to the PHP Community
i realize this isn't the appropriate mailing list and i risk being black-listed (flame, defamed, ignored, etc.). i occasionally use temporary emails when registering for forums or to get some shareware (we've all done it, don't give me that look, i have given what i could, when i could) and while i like the way mytrashmail.com works, i don't like having mytrashmail.com as part of the temp addy. does anyone know of a similar service that uses a more enticing domain? thank you, jason
[PHP] Happy new year!
Happy new year everyone :)