php-general Digest 1 Sep 2008 13:56:08 -0000 Issue 5657
php-general Digest 1 Sep 2008 13:56:08 - Issue 5657 Topics (messages 279185 through 279216): [HS] Howto answer Was: [PHP] casting static property 279185 by: Lupus Michaelis Re: ASCII Captcha 279186 by: Ross McKay 279204 by: Nisse Engström 279206 by: Nisse Engström Re: switch case - to require the break statements seems strange to me 279187 by: Diogo Neves 279190 by: Jochem Maas 279192 by: Lupus Michaelis Re: casting static property 279188 by: Micah Gersten Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM 279189 by: Jochem Maas 279191 by: Diogo Neves 279195 by: Maciek Sokolewicz Creating single row for multiple items. 279193 by: Tom Shaw 279194 by: Diogo Neves Re: skinning a cat (was: Individual bulk e-mails - performance question) 279196 by: Per Jessen Re: skinning a cat 279197 by: Jochem Maas 279198 by: Colin Guthrie 279200 by: Jochem Maas 279202 by: Per Jessen 279203 by: Per Jessen 279214 by: Jochem Maas 279215 by: Per Jessen newbie - how to receive/iterate posted arrays 279199 by: Govinda 279201 by: Diogo Neves 279207 by: David Robley 279208 by: Carlos Medina uploading file outside WEB Root 279205 by: Angelo Zanetti 279210 by: Carlos Medina Shared memory, mutex functionality and spawning threads. Is it possible using PHP? 279209 by: Kent Larsson Re: What's with the Rx symbol? 279211 by: Robin Vickery Job opening in Leiden, Netherlands: PHP/MySQL developer 279212 by: Ivo F.A.C. Fokkema Re: Individual bulk e-mails - performance question (was skinning a cat) :-) 279213 by: Merlin Morgenstern Re: how to write good code 279216 by: Shiplu Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- Govinda a écrit : does top post mean to puts one's reply text at the top of the email? People prefer it to be at the bottom? Yes, because the regular way is to read top to bottom. Personally I like the new text to be at the top so I don't have to scroll down to see the new part You don't have to scroll if everybody clean as it must. expect/prefer so I can maximize my chance to get help when I need it ;-) Yeah, because morron like me autoscroll ;) If I see nothing, I don't answer and stroke n key to reach the next message :) -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org ---End Message--- ---BeginMessage--- Jochem Maas wrote: figures, no blooming good to us then :-) No, I wouldn't bother! (It actually p!sses me off when I have to type my email address into a form because they've decided to pick some unique name for the field!) makes me think of another trick to block spam/cruft/etc from form submissions (including double POSTs) ... set a hidden field to a random value that session bound and usable only once ... if the value is not present in the POST or it's not set in the session as being valid and usable then don't accept the POST ... if the POST is accepted then remove the value from the session. Yes, your Honey Pots idea intrigues me, and I'll be stealing it, thanks! cake is a metaphor. let's imagine it means 'girls' for instance ... you with me now? ;-) Um... nope, no idea what you mean (nodding!). [She's about to come over and demand her coffee, must fetch ;) ] -- Ross McKay, Toronto, NSW Australia Such a pretty girl, happy in an ugly place, watching all the pretty people doing lots of ugly things - Everclear ---End Message--- ---BeginMessage--- On Fri, 29 Aug 2008 16:11:01 -0400, tedd wrote: http://webbytedd.com/aa/assorted-captcha/ Some of these are really cool. Assuming they are actually working, that is... Graphic CAPTCHA: Error! Reload the page! Audio CAPTCHA: -- There is nothing to click and no indication that I should enable Flash. And when I enter the number, I get Sorry, you didn't make it Performance CAPTCHA: This one actually works. Well, sort of... Notice: Undefined index: x in /var/www/vhosts/webbytedd.com/httpdocs/aa/assorted-captcha/index.php on line 153 Notice: Undefined index: y in /var/www/vhosts/webbytedd.com/httpdocs/aa/assorted-captcha/index.php on line 154 Congratulations, you made it via Performance CAPTCHA ! Question CAPTCHA: - Sorry, you didn't make it... Arrow CAPTCHA: -- I like this one! Except... Notice: Undefined index: 0 in /var/www/vhosts/webbytedd.com/httpdocs/aa/assorted-captcha/index.php on line 190 Sorry, you didn't make it... I also get a 404 for /aa/assorted-captcha/a.js. I managed 1 out of 5. What do I
[PHP] Re: [PHP-DEV] T_PAAMAYIM_NEKUDOTAYIM
Jochem Maas wrote: redirecting to generals mailing list ... Diogo Neves schreef: php -r 'class B { private static function a() {} public function __callStatic($method, $parms) { echo $method, \n; } } $a = new B; $a::a();' Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in Command line code on line 1 Ok, i found the error, but anyway... a what? it's hebrew for 'double colon' (::), google could have told you this. please note, the internals mailing is for php engine development/developers, I don't think they look forward to this kind of question (t)here. ...we're lucky enough that they tolerate lurkers (*cough*) :-) It's even in the manual [1]: Paamayim Nekudotayim would, at first, seem like a strange choice for naming a double-colon. However, while writing the Zend Engine 0.5 (which powers PHP 3), that's what the Zend team decided to call it. It actually does mean double-colon - in Hebrew! - Tul [1] http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)
Robert Cummings wrote: #!/bin/sh while true do yourscript sleep 300 done I accomplish the same with cron scripts by using locks with expiry. got an example? my cat skinning skills need to be improved, the cat won't like it but screw the cat, right? [snip code] I implemented my own lock class which uses directory creation and the return value to determine if the lock was successful. Unlike file creation (or so I read several years ago) directory creation is atomic and works across NFS. As an added benefit, I'm able to store lock related data into the lock directory as files. I'm probably old fashioned, but to me all that stuff is way overkill. I also tend to think that synchronizing scripts is a job for the shell, not PHP. lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Per Jessen schreef: Robert Cummings wrote: #!/bin/sh while true do yourscript sleep 300 done I accomplish the same with cron scripts by using locks with expiry. got an example? my cat skinning skills need to be improved, the cat won't like it but screw the cat, right? [snip code] I implemented my own lock class which uses directory creation and the return value to determine if the lock was successful. Unlike file creation (or so I read several years ago) directory creation is atomic and works across NFS. As an added benefit, I'm able to store lock related data into the lock directory as files. I'm probably old fashioned, but to me all that stuff is way overkill. I also tend to think that synchronizing scripts is a job for the shell, not PHP. either way, I've just learn't something new as far as shellscripting goes :-) apart from the xargs command ... that still does my head in (don't worry I'll look it up ... for the umpteenth time). lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) wouldn't creating a dir be better here? (with regard to atomicity) /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: skinning a cat
Jochem Maas wrote: either way, I've just learn't something new as far as shellscripting goes :-) apart from the xargs command ... that still does my head in (don't worry I'll look it up ... for the umpteenth time). find $lockfile -cmin +60 | xargs rm FWIW, it's nicer to do: $ find $lockfine -cmin +60 -exec rm {} \; This method handles files with spaces in them, where are the xargs method does not (not that it matters in this case). HTHs Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie - how to receive/iterate posted arrays
Hello early birds, I am going round and round the docs and list posts I saved on this topic... but I am still stumped. Kindly show me what I am missing. I want to simply send an array of vars via a post form to my receiving script. I've got simple inputs like this: input name=tmbsToiterate[muir_beach_tmb] type=hidden value=muir_beach_tmb / input name=tmbsToiterate[ruby_mountain_tmb] type=hidden value=ruby_mountain_tmb / they post to the script with this: (and this is the line giving the error)- foreach($_POST['$tmbsToiterate'] as $value) { The error is Warning: Invalid argument supplied for foreach() Seems so simple, but I can't get it... What am I doing wrong? -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Colin Guthrie wrote: Jochem Maas wrote: either way, I've just learn't something new as far as shellscripting goes :-) apart from the xargs command ... that still does my head in (don't worry I'll look it up ... for the umpteenth time). find $lockfile -cmin +60 | xargs rm FWIW, it's nicer to do: $ find $lockfine -cmin +60 -exec rm {} \; This method handles files with spaces in them, where are the xargs method does not (not that it matters in this case). That could also be taken care of by: find $lockfile -cmin +60 -print0 | xargs -0 rm IMO, the syntax of the -exec argument is too cumbersome. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Jochem Maas wrote: lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) wouldn't creating a dir be better here? (with regard to atomicity) I haven't thought it through, but I don't think it would change anything. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Colin Guthrie schreef: Jochem Maas wrote: either way, I've just learn't something new as far as shellscripting goes :-) apart from the xargs command ... that still does my head in (don't worry I'll look it up ... for the umpteenth time). find $lockfile -cmin +60 | xargs rm FWIW, it's nicer to do: $ find $lockfine -cmin +60 -exec rm {} \; This method handles files with spaces in them, where are the xargs method does not (not that it matters in this case). righto, good to know. -exec option of a find is one I still have to look up every time I use it (although I think I guess the syntax correctly ... once) HTHs Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - how to receive/iterate posted arrays
Hi, On Mon, Sep 1, 2008 at 9:25 AM, Govinda [EMAIL PROTECTED] wrote: Hello early birds, I am going round and round the docs and list posts I saved on this topic... but I am still stumped. Kindly show me what I am missing. I want to simply send an array of vars via a post form to my receiving script. I've got simple inputs like this: input name=tmbsToiterate[muir_beach_tmb] type=hidden value=muir_beach_tmb / input name=tmbsToiterate[ruby_mountain_tmb] type=hidden value=ruby_mountain_tmb / they post to the script with this: (and this is the line giving the error)- foreach($_POST['$tmbsToiterate'] as $value) { // Maybe like this, but i'm not sure, try to do a var_dump( $_POST ) and see what is inside ;) foreach($_POST['tmbsToiterate'] as $value) { The error is Warning: Invalid argument supplied for foreach() Seems so simple, but I can't get it... What am I doing wrong? -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Thanks for your attention, Diogo Neves Web Developer @ SAPO.pt by PrimeIT.pt
[PHP] uploading file outside WEB Root
Hi All, For security purposes I would like to upload a file outside the webroot. I have got this to work on my local dev machine but it doesn't seem to work on the live server. I have tried both the relative path and also the full path (from the $_SERVER[DOCUMENT_ROOT] variable). Now I can't get the upload to work and have no idea what the problem could be. I have also set the permissions of the folder, so that can't be a problem. Could it be a problem with server hosting restrictions? Or maybe the server is setup for virtual hosting? Thanks Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ASCII Captcha
On Fri, 29 Aug 2008 16:11:01 -0400, tedd wrote: http://webbytedd.com/aa/assorted-captcha/ Some of these are really cool. Assuming they are actually working, that is... Graphic CAPTCHA: Error! Reload the page! Audio CAPTCHA: -- There is nothing to click and no indication that I should enable Flash. And when I enter the number, I get Sorry, you didn't make it Performance CAPTCHA: This one actually works. Well, sort of... Notice: Undefined index: x in /var/www/vhosts/webbytedd.com/httpdocs/aa/assorted-captcha/index.php on line 153 Notice: Undefined index: y in /var/www/vhosts/webbytedd.com/httpdocs/aa/assorted-captcha/index.php on line 154 Congratulations, you made it via Performance CAPTCHA ! Question CAPTCHA: - Sorry, you didn't make it... Arrow CAPTCHA: -- I like this one! Except... Notice: Undefined index: 0 in /var/www/vhosts/webbytedd.com/httpdocs/aa/assorted-captcha/index.php on line 190 Sorry, you didn't make it... I also get a 404 for /aa/assorted-captcha/a.js. I managed 1 out of 5. What do I win? /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ASCII Captcha
On Mon, 1 Sep 2008 11:14:39 +0200, Nisse Engström wrote: On Fri, 29 Aug 2008 16:11:01 -0400, tedd wrote: http://webbytedd.com/aa/assorted-captcha/ Performance CAPTCHA: This one actually works. Well, sort of... And maybe your code should check for a circle rather than a square, or am I picking nits? /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newbie - how to receive/iterate posted arrays
Govinda wrote: Hello early birds, I am going round and round the docs and list posts I saved on this topic... but I am still stumped. Kindly show me what I am missing. I want to simply send an array of vars via a post form to my receiving script. I've got simple inputs like this: input name=tmbsToiterate[muir_beach_tmb] type=hidden value=muir_beach_tmb / input name=tmbsToiterate[ruby_mountain_tmb] type=hidden value=ruby_mountain_tmb / they post to the script with this: (and this is the line giving the error)- foreach($_POST['$tmbsToiterate'] as $value) { The error is Warning: Invalid argument supplied for foreach() Seems so simple, but I can't get it... What am I doing wrong? -Govinda foreach($_POST['tmbsToiterate'] as $value) { Remove the $ Cheers -- David Robley Our field is arthritis research, Tom and his room mate said jointly. Today is Prickle-Prickle, the 25th day of Bureaucracy in the YOLD 3174. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newbie - how to receive/iterate posted arrays
Govinda schrieb: Hello early birds, I am going round and round the docs and list posts I saved on this topic... but I am still stumped. Kindly show me what I am missing. I want to simply send an array of vars via a post form to my receiving script. I've got simple inputs like this: input name=tmbsToiterate[muir_beach_tmb] type=hidden value=muir_beach_tmb / input name=tmbsToiterate[ruby_mountain_tmb] type=hidden value=ruby_mountain_tmb / they post to the script with this: (and this is the line giving the error)- foreach($_POST['$tmbsToiterate'] as $value) { The error is Warning: Invalid argument supplied for foreach() Seems so simple, but I can't get it... What am I doing wrong? -Govinda Hi Govinda, delte the $ from the foreach '$tmbsToiterate'! Regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?
Hi, Is it possible to have shared memory in the form of shared global variables in PHP? Or any other form of shared memory? And if that is the case, is there any form of mutex functionality which may be used to assure syncronized access to this memory? My next question is related to the first one. Is it possible to have a thread running for processing of information. This thread should be accessed from all the session instances, and it would also need to be syncronized. I would like to have something like: jobProcessorThread.addJob(aJobClassInstance) The job processor thread should work with the jobs in its queue until the queue is empty. Then it should idle until more requests are received. And my last question. Is it possible to let any code run and perform its work after PHP has sent the page to the user? This could be an alternative to having a worker thread in if it's also possible to have mutexes and shared memory. Then the worker thread jobs could be processed after a page has been sent inside a critical block protected by mutex functionality. Best regards, Kent
[PHP] Re: uploading file outside WEB Root
Angelo Zanetti schrieb: Hi All, For security purposes I would like to upload a file outside the webroot. I have got this to work on my local dev machine but it doesn't seem to work on the live server. I have tried both the relative path and also the full path (from the $_SERVER[DOCUMENT_ROOT] variable). Now I can't get the upload to work and have no idea what the problem could be. I have also set the permissions of the folder, so that can't be a problem. Could it be a problem with server hosting restrictions? Or maybe the server is setup for virtual hosting? Thanks Angelo Hi Angelo, dev and live are the same Server/Machine type? Restrictions on the Folder? ( Group restrictions, User Restrictions, etc) Exists the Folder on the Live System? Regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What's with the Rx symbol?
2008/8/30 Per Jessen [EMAIL PROTECTED]: tedd wrote: What some browser developers did was to NOT make the conversion from PUNYCODE to the correct code-points but rather show the PUNYCODE as-is, which was never the intent of the IDNS WG. This act defeated the entire process of allowing non-English people to have non-English domain names. This like throwing the baby out with the bath water. But that's not what FF does though - it has no problem with other domain names with international characters. For instance, the normal Danish, German, French, Spanish and Icelandic characters work just fine. I have a testing domain which contains an 'ë' - also no problem. It seems to be just somewhat limited to those (and others I'm sure). True... Firefox holds a whitelist of toplevel domains that are allowed to display unicode (to see the list go to about:config and enter IDN.whitelist into the filter box). It does not allow .com domains to contain unicode for obvious phishing reasons, but if I temporarily add it to the whitelist, I can see tedds yin-yang domain in all its glory. Although not, for some reason which I can't be bothered investigating, the rx-2 domain. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Job opening in Leiden, Netherlands: PHP/MySQL developer
Dear all, We have an immediate job opening available to work in our team of bio-informaticians on extending the LOVD software (www.LOVD.nl). Even if you're still a beginner with PHP you're welcome to respond. Affinity to biology is a big plus. LOVD (Leiden Open Variation Database) is webbased software used by hospitals and clinics worldwide to store patient and DNA mutation information. For more information, see our website or these two PDF files: http://www.lovd.nl/Vac08_G2P_LSDBs.pdf http://www.lovd.nl/LUMC_E.08.GJ.16HG.pdf If you're interested, please let me know as soon as possible since we've already started selecting candidates. Ivo Fokkema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Individual bulk e-mails - performance question (was skinning a cat) :-)
Per Jessen schrieb: Jochem Maas wrote: lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) wouldn't creating a dir be better here? (with regard to atomicity) I haven't thought it through, but I don't think it would change anything. /Per Jessen, Zürich Hello everybody, thank you for the huge amount of replies on my question. I believe I quite lost a bit track on how to solve the problem hands on. To summerize, there are aparently two ways of skinning the cat :-) 1. Run a deamon I admit I have never wrote one, and that seems therefore to be the harder option for me. Well... perhaps not. I assume it is simply creating a shell script like Jochem wrote, however I guess it would just take longer for me to get it running as I have never done that before. 2. Create a PHP file that holds some lock code which is triggered by CRON every 5 minutes. Taking the example from Robert. 3. Following idea which I am now actually implementing :-) - Add all emails into a mysql db with one insert command. - Run a php script by cron every 5 min that does the following: - update table, set session_id = x on all entries without session id - get all entries with that session ID - send email to those with that session ID - remove all entries with that session ID Looks like easies sollution on how to skimm the cat. DB might not be the most performing sollution, but sufficient considering the hard ware power. Thanks for your help! Regards, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Per Jessen schreef: Jochem Maas wrote: lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) wouldn't creating a dir be better here? (with regard to atomicity) I haven't thought it through, but I don't think it would change anything. directory creation is garanteed to be atomic, even across NFS, or so Rob said. additionally his idea of being able to dump lock-process related data in said directory is quite nifty. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Jochem Maas wrote: Per Jessen schreef: Jochem Maas wrote: lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) wouldn't creating a dir be better here? (with regard to atomicity) I haven't thought it through, but I don't think it would change anything. directory creation is garanteed to be atomic, even across NFS, or so Rob said. Maybe so, but to avoid a race-condition, you need the test+touch sequence to be atomic. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to write good code
Thanks Eric, Diogo, Ross and specially Christopher for this long article. I have started reading those articles. And I hope to collect those books too. -- Blog: http://talk.cmyweb.net/ Follow me: http://twitter.com/shiplu
Re: [PHP] newbie - how to receive/iterate posted arrays
Thanks Diogo! , and other who replied! You nailed it (Of course! you would say.) I didn't reply sooner as we had a power out (just enough to get me to go to bed already ;-) -G On Sep 1, 2008, at 2:31 AM, Diogo Neves wrote: foreach($_POST['$tmbsToiterate'] as $value) { foreach($_POST['tmbsToiterate'] as $value) { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to write good code
Hi Shiplu, For all that you mentioned, and if you want to get a quite good suggestion, I will highly recommend that you read through McConnell's Code Complete (2nd Edition). Specifically: Chapter 31: Layout and Style Chapter 32: Self-Documenting Code (Commenting Techniques) It won't disappoint you. 2008/8/31 Shiplu [EMAIL PROTECTED] I wanna know how to write good code in php. Not oop stuff. I wanna know how to write a good php code file. documentation, comments. indentation etc. what are the good practices?? -- Blog: http://talk.cmyweb.net/ Follow me: http://twitter.com/shiplu -- With best regards, Shelley Shyan http://phparch.cn
[PHP] Google Maps Distance Between UK Postcodes
Has anyone tried to work this out? All I'm trying to get is the rough distance in miles between two UK postcodes using Google Maps API for a basic auto quote script based on mileage travelled. I thought it would be easy but it seems that I need to convert each postcode to Lat/Long using Geocoding and then work it out from there. I can't find any examples so before I find another way of 'skinning the cat' has anyone had experience of this and able to point me the right way? TIA
[PHP] Re: Google Maps Distance Between UK Postcodes
Tom Chubb wrote: I thought it would be easy but it seems that I need to convert each postcode to Lat/Long using Geocoding and then work it out from there. That's the best way: then just do something like: Here's how I do it in SQL, but the principle is the same in PHP, so I'm sure you'll be able to convert it. HTHs Col snip public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles = false) { $multiplier = 6371; if ($blnMiles) $multiplier *= 1.609344; $rv = ESQL (ACOS( SIN(RADIANS($latA)) * SIN(RADIANS($latB)) + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) - RADIANS($lngA))) * $multiplier) ESQL; return $rv; } /snip -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Google Maps Distance Between UK Postcodes
Has anyone tried to work this out? All I'm trying to get is the rough distance in miles between two UK postcodes using Google Maps API for a basic auto quote script based on mileage travelled. I thought it would be easy but it seems that I need to convert each postcode to Lat/Long using Geocoding and then work it out from there. I can't find any examples so before I find another way of 'skinning the cat' has anyone had experience of this and able to point me the right way? If it's straight line distance you might well be able to use peter gorous on the coords. If it's distance by road, then not. -- Richard Heyes HTML5 Graphing for IE7, FF, Opera and Safari: http://www.phpguru.org/RGraph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Google Maps Distance Between UK Postcodes
On 01/09/2008, Colin Guthrie [EMAIL PROTECTED] wrote: Tom Chubb wrote: I thought it would be easy but it seems that I need to convert each postcode to Lat/Long using Geocoding and then work it out from there. That's the best way: then just do something like: Here's how I do it in SQL, but the principle is the same in PHP, so I'm sure you'll be able to convert it. HTHs Col snip public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles = false) { $multiplier = 6371; if ($blnMiles) $multiplier *= 1.609344; $rv = ESQL (ACOS( SIN(RADIANS($latA)) * SIN(RADIANS($latB)) + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) - RADIANS($lngA))) * $multiplier) ESQL; return $rv; } /snip -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks Colin, That's all way above my head, but I think I'll be able to understand it after a strong coffee! Any idea how you get the co-ords from the UK Postcode though? There seems to be a privacy factor with UK postcodes, but I'm only after the first section: eg SW11 6**
Re: [PHP] Re: Google Maps Distance Between UK Postcodes
2008/9/1 Tom Chubb [EMAIL PROTECTED] On 01/09/2008, Colin Guthrie [EMAIL PROTECTED] wrote: Tom Chubb wrote: I thought it would be easy but it seems that I need to convert each postcode to Lat/Long using Geocoding and then work it out from there. That's the best way: then just do something like: Here's how I do it in SQL, but the principle is the same in PHP, so I'm sure you'll be able to convert it. HTHs Col snip public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles = false) { $multiplier = 6371; if ($blnMiles) $multiplier *= 1.609344; $rv = ESQL (ACOS( SIN(RADIANS($latA)) * SIN(RADIANS($latB)) + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) - RADIANS($lngA))) * $multiplier) ESQL; return $rv; } /snip -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks Colin, That's all way above my head, but I think I'll be able to understand it after a strong coffee! Any idea how you get the co-ords from the UK Postcode though? There seems to be a privacy factor with UK postcodes, but I'm only after the first section: eg SW11 6** This address should help you. Thay have distance calculator on the page but also you can download database with postcodes and their co-ords - http://www.pc-i.co.uk/postcode-distance.php
Re: [PHP] Re: Google Maps Distance Between UK Postcodes
This is what I have: $distance = number_format(ceil(69*rad2deg(acos(sin(deg2rad($ulat)) * sin(deg2rad($vlat)) + cos(deg2rad($ulat)) * cos(deg2rad($vlat)) * cos(deg2rad($ulong - $vlong)); where: $ulat = latitude of user #1 $ulong = longitude of user #1 $vlat = latitude of user #2 $vlong = longitude of user #2 it seems to work properly at least with US data. I assume any longitude/latitude date will work fine with it. If anyone has links to other countries' zipcode mappings I'd love to be able to add that to my site :) (I basically took a MySQL query and mapped it to the PHP functions) On 9/1/08, Tom Chubb [EMAIL PROTECTED] wrote: snip public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles = false) { $multiplier = 6371; if ($blnMiles) $multiplier *= 1.609344; $rv = ESQL (ACOS( SIN(RADIANS($latA)) * SIN(RADIANS($latB)) + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) - RADIANS($lngA))) * $multiplier) ESQL; return $rv; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Google Maps Distance Between UK Postcodes
Tom Chubb wrote: That's all way above my head, but I think I'll be able to understand it after a strong coffee! I should point out that this is really just trig and is only an approximate distance as the crow flies. Not even sure if it takes the curvature of the earth into consideration, but it's probably good enough for most things. Any idea how you get the co-ords from the UK Postcode though? Well that's tricky. It depends on how google do it's geodata service now. In the past they did not offer a postcode lookup service for the UK, but I've not looked for a while and this may now be possible. When I had to solve this problem a few years ago we bought in a database of UK postcodes. IIRC it's about £1k/annum via Bartholomew but there are plenty people offering this now. Col. -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Google Maps Distance Between UK Postcodes
On 01/09/2008, Michal Sokolowski [EMAIL PROTECTED] wrote: 2008/9/1 Tom Chubb [EMAIL PROTECTED] On 01/09/2008, Colin Guthrie [EMAIL PROTECTED] wrote: Tom Chubb wrote: I thought it would be easy but it seems that I need to convert each postcode to Lat/Long using Geocoding and then work it out from there. That's the best way: then just do something like: Here's how I do it in SQL, but the principle is the same in PHP, so I'm sure you'll be able to convert it. HTHs Col snip public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles = false) { $multiplier = 6371; if ($blnMiles) $multiplier *= 1.609344; $rv = ESQL (ACOS( SIN(RADIANS($latA)) * SIN(RADIANS($latB)) + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) - RADIANS($lngA))) * $multiplier) ESQL; return $rv; } /snip -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks Colin, That's all way above my head, but I think I'll be able to understand it after a strong coffee! Any idea how you get the co-ords from the UK Postcode though? There seems to be a privacy factor with UK postcodes, but I'm only after the first section: eg SW11 6** This address should help you. Thay have distance calculator on the page but also you can download database with postcodes and their co-ords - http://www.pc-i.co.uk/postcode-distance.php That's perfect for what I need! Thanks very much Michal Tom
Re: [PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)
On Mon, 2008-09-01 at 09:44 +0200, Per Jessen wrote: Robert Cummings wrote: #!/bin/sh while true do yourscript sleep 300 done I accomplish the same with cron scripts by using locks with expiry. got an example? my cat skinning skills need to be improved, the cat won't like it but screw the cat, right? [snip code] I implemented my own lock class which uses directory creation and the return value to determine if the lock was successful. Unlike file creation (or so I read several years ago) directory creation is atomic and works across NFS. As an added benefit, I'm able to store lock related data into the lock directory as files. I'm probably old fashioned, but to me all that stuff is way overkill. I also tend to think that synchronizing scripts is a job for the shell, not PHP. lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) Try running that on windows. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Individual bulk e-mails - performance question (was skinning a cat) :-)
On Mon, 2008-09-01 at 14:34 +0200, Merlin Morgenstern wrote: Per Jessen schrieb: Jochem Maas wrote: lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) wouldn't creating a dir be better here? (with regard to atomicity) I haven't thought it through, but I don't think it would change anything. /Per Jessen, Zürich Hello everybody, thank you for the huge amount of replies on my question. I believe I quite lost a bit track on how to solve the problem hands on. To summerize, there are aparently two ways of skinning the cat :-) 1. Run a deamon I admit I have never wrote one, and that seems therefore to be the harder option for me. Well... perhaps not. I assume it is simply creating a shell script like Jochem wrote, however I guess it would just take longer for me to get it running as I have never done that before. 2. Create a PHP file that holds some lock code which is triggered by CRON every 5 minutes. Taking the example from Robert. 3. Following idea which I am now actually implementing :-) - Add all emails into a mysql db with one insert command. - Run a php script by cron every 5 min that does the following: - update table, set session_id = x on all entries without session id - get all entries with that session ID - send email to those with that session ID - remove all entries with that session ID Looks like easies sollution on how to skimm the cat. DB might not be the most performing sollution, but sufficient considering the hard ware power. Actually 3 was what I suggested with a lock mechanism to ensure that if your script run by cron takes longer than 5 minutes that you don't have two scritps stepping on each others' toes. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
On Mon, 2008-09-01 at 14:51 +0200, Per Jessen wrote: Jochem Maas wrote: Per Jessen schreef: Jochem Maas wrote: lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) wouldn't creating a dir be better here? (with regard to atomicity) I haven't thought it through, but I don't think it would change anything. directory creation is garanteed to be atomic, even across NFS, or so Rob said. Maybe so, but to avoid a race-condition, you need the test+touch sequence to be atomic. The return value of creating the directory is either true for it having been made or false for it having not been made. Therein lies the atomicity. The OS will not return success if it was not made and will not return failure if it was made. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to write good code
Ross McKay [EMAIL PROTECTED] wrote: Find out what bad is by reading this: http://thedailywtf.com/Series/CodeSOD.aspx Then, don't do it like that! What I enjoyed most on that page was this comment: One day, after a code review by one of our 'senior' developers this little beauty showed up... #define NUMBER_OF_BITS_IN_BYTE 8 The justification was... that the byte might change and no 'magic' numbers should appear in the code... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)
Robert Cummings wrote: I'm probably old fashioned, but to me all that stuff is way overkill. I also tend to think that synchronizing scripts is a job for the shell, not PHP. lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) Try running that on windows. Why? - we don't use Windows. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Robert Cummings wrote: The return value of creating the directory is either true for it having been made or false for it having not been made. Therein lies the atomicity. The OS will not return success if it was not made and will not return failure if it was made. Ah, interesting. Thanks. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?
Kent Larsson wrote: Hi, Is it possible to have shared memory in the form of shared global variables in PHP? Or any other form of shared memory? And if that is the case, is there any form of mutex functionality which may be used to assure syncronized access to this memory? My next question is related to the first one. I can't answer any of your questions, but if you need shared memory, mutexes and threading, I would advice against using PHP. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)
On Mon, 2008-09-01 at 20:22 +0200, Per Jessen wrote: Robert Cummings wrote: I'm probably old fashioned, but to me all that stuff is way overkill. I also tend to think that synchronizing scripts is a job for the shell, not PHP. lockfile=/var/lock//file # clear out a lock older than 60mins find $lockfile -cmin +60 | xargs rm test ! -f $lockfile ( touch $lockfile run some php rm -f $lockfile ) Try running that on windows. Why? - we don't use Windows. I get requests from time to time to do windows work. My scripts just happen to work in windows or linux. I guess that's because I don't punt to shell scripts what is easily implemented in PHP ;) 99% of what I do is linux based. But knowing what to do for the other 1% is pure gold to my clients. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: What's with the Rx symbol?
Robin Vickery wrote: Firefox holds a whitelist of toplevel domains that are allowed to display unicode (to see the list go to about:config and enter IDN.whitelist into the filter box). It does not allow .com domains to contain unicode for obvious phishing reasons, Very interesting, I had no idea. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?
Hi, Thank you for your answer. I was hoping there were a solution. :-/ It would have been nice as PHP has a large install base and is a quite common element in cheap web hosting solutions. Has anyone else got any more comments or suggestions? In absence of shared memory and threads. What I really must have is some kind of mutex functionality. I will be manipulating files on disk and I don't want two instances to be able to touch the disk at the same time. Is there something I could use for mutual exclusion? If there aren't any dedicated methods, are there 100% reliable workarounds? On Mon, Sep 1, 2008 at 8:27 PM, Per Jessen [EMAIL PROTECTED] wrote: Kent Larsson wrote: Hi, Is it possible to have shared memory in the form of shared global variables in PHP? Or any other form of shared memory? And if that is the case, is there any form of mutex functionality which may be used to assure syncronized access to this memory? My next question is related to the first one. I can't answer any of your questions, but if you need shared memory, mutexes and threading, I would advice against using PHP. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Job opening in Leiden, Netherlands: PHP/MySQL developer
Hello, on 09/01/2008 09:15 AM Ivo F.A.C. Fokkema said the following: Dear all, We have an immediate job opening available to work in our team of bio-informaticians on extending the LOVD software (www.LOVD.nl). Even if you're still a beginner with PHP you're welcome to respond. Affinity to biology is a big plus. LOVD (Leiden Open Variation Database) is webbased software used by hospitals and clinics worldwide to store patient and DNA mutation information. For more information, see our website or these two PDF files: http://www.lovd.nl/Vac08_G2P_LSDBs.pdf http://www.lovd.nl/LUMC_E.08.GJ.16HG.pdf If you're interested, please let me know as soon as possible since we've already started selecting candidates. You may want to try posting it here: http://www.phpclasses.org/jobs/ Also here you will find many qualified PHP professionals from The Netherlands: http://www.phpclasses.org/professionals/country/nl/ -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to write good code
On Mon, 1 Sep 2008 08:50:45 -0700 (PDT), larry wrote: Write a lot of code, rewrite code you think is messy (we can always do better). The more you do the better you should get. Here is some inspiration on that: http://www.codinghorror.com/blog/archives/001160.html NB: the message of that blog post isn't valid at the most simplistic level (just write lots of code), and the comments to the post explain why. Don't just read the guy's blog, read the comments! As an extreme example, consider the latest repost of a classic at TheDailyWTF: http://thedailywtf.com/Articles/Classic-WTF-To-the-Hexth-Degree.aspx 5,000+ LOC that misses the point, and can be easily replaced by a one-line framework call. Clearly, just writing lots of code wasn't this coder's greatest challenge. Practice makes perfect, but only if you review your output with an eye to pick up faults. On rewriting messy code, I've always approached a bug fix on legacy code with the view that tidy code breaks less, or at least breaks where you can see it. More often than not, tidying up some rat's nest of code will magically fix the problem anyway, and if it doesn't, it can make the bug very clear to see. This even has a name: refactoring. I would posit that writing lots of code is good practice, but learning good from bad comes from reading code. Read your old code (if you can!) Read other people's code. Read sites that make fun of bad code (great way to learn what bad code looks like!) Read what makes code good and what makes it bad. Then write some more code :) -- Ross McKay, Toronto, NSW Australia Before enlightenment: chop wood, carry water; After enlightenment: chop wood, carry water - Wu Li -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?
On Mon, Sep 1, 2008 at 5:45 PM, Kent Larsson [EMAIL PROTECTED] wrote: Hi, Thank you for your answer. I was hoping there were a solution. :-/ It would have been nice as PHP has a large install base and is a quite common element in cheap web hosting solutions. Has anyone else got any more comments or suggestions? In absence of shared memory and threads. What I really must have is some kind of mutex functionality. I will be manipulating files on disk and I don't want two instances to be able to touch the disk at the same time. Is there something I could use for mutual exclusion? If there aren't any dedicated methods, are there 100% reliable workarounds? On Mon, Sep 1, 2008 at 8:27 PM, Per Jessen [EMAIL PROTECTED] wrote: Kent Larsson wrote: Hi, Is it possible to have shared memory in the form of shared global variables in PHP? Or any other form of shared memory? And if that is the case, is there any form of mutex functionality which may be used to assure syncronized access to this memory? My next question is related to the first one. I can't answer any of your questions, but if you need shared memory, mutexes and threading, I would advice against using PHP. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Perhaps these may be of interest: http://us.php.net/manual/en/ref.shmop.php http://us3.php.net/pcntl_fork http://us3.php.net/manual/en/book.sem.php
Re: [PHP] Re: skinning a cat
Robert Cummings a écrit : Try running that on windows. No problem http://technet.microsoft.com/en-us/interopmigration/bb380242.aspx -- Mickaël Wolff aka Lupus Michaelis http://lupusmic.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Shared memory, mutex functionality and spawning threads. Is it possible using PHP?
Kent Larsson wrote: Hi, Is it possible to have shared memory in the form of shared global variables in PHP? Or any other form of shared memory? And if that is the case, is there any form of mutex functionality which may be used to assure syncronized access to this memory? My next question is related to the first one. Is it possible to have a thread running for processing of information. This thread should be accessed from all the session instances, and it would also need to be syncronized. I would like to have something like: jobProcessorThread.addJob(aJobClassInstance) The job processor thread should work with the jobs in its queue until the queue is empty. Then it should idle until more requests are received. And my last question. Is it possible to let any code run and perform its work after PHP has sent the page to the user? This could be an alternative to having a worker thread in if it's also possible to have mutexes and shared memory. Then the worker thread jobs could be processed after a page has been sent inside a critical block protected by mutex functionality. Best regards, Kent You may find the PEAR Cache_Lite::Cache_Lite() helpful. It has memory caching, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] newbie - PHP escaping trigger happy
Just a quick Q, which I know has to be in the docs somewhere, but I haven't come across it yet- PHP automatically escaping single and double quotes... how to turn it off? I.e.- in a form text input, someone inputs love's influence grows and on the posted page I get: love\'s \influence\ WHen I wrap that with htmlspecialchars , then I get: love\#039;s \quot;influence\quot; lt;growsgt; What I want is: love#039;s quot;influencequot; lt;growsgt; ...in this case anyway. Probably if I understood why PHP was escaping the quotes, then I likely would want that behavior in those circumstances it was designed for... but not now, and I don't know how to turn it off. Thanks, -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie - PHP escaping trigger happy
On Mon, Sep 1, 2008 at 10:21 PM, Govinda [EMAIL PROTECTED] wrote: Just a quick Q, which I know has to be in the docs somewhere, but I haven't come across it yet- PHP automatically escaping single and double quotes... how to turn it off? I.e.- in a form text input, someone inputs love's influence grows and on the posted page I get: love\'s \influence\ WHen I wrap that with htmlspecialchars , then I get: love\#039;s \quot;influence\quot; lt;growsgt; What I want is: love#039;s quot;influencequot; lt;growsgt; ...in this case anyway. Probably if I understood why PHP was escaping the quotes, then I likely would want that behavior in those circumstances it was designed for... but not now, and I don't know how to turn it off. Thanks, -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://us.php.net/magicquotes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?
http://us2.php.net/apc Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Kent Larsson wrote: Hi, Is it possible to have shared memory in the form of shared global variables in PHP? Or any other form of shared memory? And if that is the case, is there any form of mutex functionality which may be used to assure syncronized access to this memory? My next question is related to the first one. Is it possible to have a thread running for processing of information. This thread should be accessed from all the session instances, and it would also need to be syncronized. I would like to have something like: jobProcessorThread.addJob(aJobClassInstance) The job processor thread should work with the jobs in its queue until the queue is empty. Then it should idle until more requests are received. And my last question. Is it possible to let any code run and perform its work after PHP has sent the page to the user? This could be an alternative to having a worker thread in if it's also possible to have mutexes and shared memory. Then the worker thread jobs could be processed after a page has been sent inside a critical block protected by mutex functionality. Best regards, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mozilla user agent escapes detection
PHP List, I have a script, part of which is taken from a script I found on the 'net, which tries to detect the user agent of the browser accessing the site. One of the reasons I'm doing this is to find out if the browser is a desktop or mobile. Part of the code looks like this: $ua = strtolower($_SERVER['HTTP_USER_AGENT']); $isDesktop = (strpos($ua, 'firefox') !== false) || (strpos($ua,'mosaic') !== false) || (strpos($ua,'msie') !== false) || (strpos($ua,'opera') !== false) || (strpos($ua,'mozilla') !== false) || (strpos($ua,'w3c_css_validator') !== false) || (strpos($ua,'w3c_validator') !== false); What's driving me crazy is that it successfully determines all the browsers listed there, *except* mozilla. I have a log file which alerts me when an unknown browser comes through my site, and it's chock full of messages telling me that a Mozilla based browser has come by. There are a *lot* of Mozilla based browsers. Some examples from my logs of the browsers slipping by my test: HTTP_USER_AGENT: Mozilla/5.0 compatible; Yahoo! Slurp HTTP_USER_AGENT: Mozilla/5.0 compatible; Googlebot/2.1 HTTP_USER_AGENT: Mozilla/5.0 X11; U; Linux i686 In each case, the strpos() should have seen the mozilla agent and not bothered logging it. It's not complicated code, especially considering it's successfully finding msie and firefox. I can't imagine why Mozilla would be different. Any suggestions? Is there something about my code right in front of my face that I'm not seeing? Any suggestions would be greatly appreciated. Thanks. -- Dave M G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shared memory, mutex functionality and spawning threads. Is it possible using PHP?
Kent Larsson wrote: In absence of shared memory and threads. What I really must have is some kind of mutex functionality. I will be manipulating files on disk and I don't want two instances to be able to touch the disk at the same time. Touch the disk or touch the file? I assume you meant the latter, i.e. you don't want two instances to operate on the same file concurrently. Is there something I could use for mutual exclusion? If there aren't any dedicated methods, are there 100% reliable workarounds? Look up file locking. In fact, this was the topic of a very recent thread. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: skinning a cat
Lupus Michaelis wrote: Robert Cummings a écrit : Try running that on windows. No problem http://technet.microsoft.com/en-us/interopmigration/bb380242.aspx And of course, there's also Cygwin. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php