php-general Digest 14 Jun 2009 12:21:21 -0000 Issue 6174
php-general Digest 14 Jun 2009 12:21:21 - Issue 6174 Topics (messages 294001 through 294027): Re: Periodic Actions in PHP? 294001 by: Sancar Saran 294007 by: Colin Guthrie 294008 by: Phpster 294010 by: bruce Re: ezmlm response 294002 by: Ashley Sheridan Re: Preventing XSS Attacks 294003 by: Ashley Sheridan Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI? 294004 by: Ashley Sheridan Re: 3d image rotating 294005 by: Ashley Sheridan 294006 by: Nitsan Bin-Nun 294012 by: PJ Re: truncate a mb-string to a given octet length? 294009 by: Tom Worster Re: Same Page, Fundamentally Different Behavior OR is Firefox broken? 294011 by: Matt Neimeyer High ID (unique, auto increment) causes slow responses on PHP (MySQL) 294013 by: ×× ××× ×× ×× 294014 by: Nitsan Bin-Nun 294015 by: Stuart how to pass a number through href url? 294016 by: PJ 294017 by: Stuart 294020 by: PJ 294027 by: tedd preg_replace problem 294018 by: Al 294021 by: Shawn McKenzie 294022 by: Al 294023 by: Al 294026 by: Al Re: [Bulk] Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI? 294019 by: Jean-Pierre Arneodo Re: socket communication programming 294024 by: Manuel Lemos 294025 by: HELP! Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Saturday 13 June 2009 11:42:49 am Parham Doustdar wrote: Hi there, I'm going to create a small chat script with PHP. The messages you want others to see will be added to a flat file (I.E. TXT file), and read and displayed by PHP. However, I want this reading and displaying to be periodic. This means that I want PHP to check the file for new lines every,say, fifteen seconds. How may I do that? I have been unable to find any function that acts like a timer. Thanks! Please search google daemonized php Regards ---End Message--- ---BeginMessage--- 'Twas brillig, and Parham Doustdar at 13/06/09 09:42 did gyre and gimble: Hi there, I'm going to create a small chat script with PHP. The messages you want others to see will be added to a flat file (I.E. TXT file), and read and displayed by PHP. However, I want this reading and displaying to be periodic. This means that I want PHP to check the file for new lines every,say, fifteen seconds. How may I do that? I have been unable to find any function that acts like a timer. For handling periodic tasks in a web environement, I use a little persistent object (stored using APC) that has it's process() method called on every request. Internally it knows when it was last run and will actually only do work in it's process() method if it's not been called for a while. When this work is done, the user's request is obviously slowed down slightly, but not in a noticeable way. If you don't need something this self contained, then a normal cron job is needed. All that asside, I'm not sure you're asking the right question. If you've got a chat system, then the client side is presumable a web server. You can't really push information from the server side to the client, so you really need to pull it from the client side. Usually you'd have a javascript timeout that submits an ajax request to the server and displays any new messages to the user. In this case, PHP doesn't need to be timed, the client is pulling periodically so it's the client that sets the timer. 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/] ---End Message--- ---BeginMessage--- On Jun 13, 2009, at 9:11, Colin Guthrie gm...@colin.guthr.ie wrote: 'Twas brillig, and Parham Doustdar at 13/06/09 09:42 did gyre and gimble: Hi there, I'm going to create a small chat script with PHP. The messages you want others to see will be added to a flat file (I.E. TXT file), and read and displayed by PHP. However, I want this reading and displaying to be periodic. This means that I want PHP to check the file for new lines every,say, fifteen seconds. How may I do that? I have been unable to find any function that acts like a timer. For handling periodic tasks in a web environement, I use a little persistent object (stored using APC) that has it's process() method called on every request. Internally it knows when it was last run and will actually only do work in it's process() method
php-general Digest 15 Jun 2009 01:31:19 -0000 Issue 6175
php-general Digest 15 Jun 2009 01:31:19 - Issue 6175 Topics (messages 294028 through 294036): Re: preg_replace problem 294028 by: Mark Kelly Re: 3d image rotating 294029 by: ×× ××× ×× ×× 294032 by: Nitsan Bin-Nun include file in a class with global/parent scope? 294030 by: Daniel Kolbo Re: Periodic Actions in PHP? 294031 by: Parham Doustdar 294033 by: Phpster Uniquely identifying an array... as a key to another array 294034 by: Eddie Drapkin Issues with APC, cache corruption? 294035 by: James McLean Re: High ID (unique, auto increment) causes slow responses on PHP (MySQL) 294036 by: Andrew Ballard Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Hi. On Saturday 13 June 2009, Al wrote: I may not have been very clear. Feed it just test with the quotes. You should get back, test the same as you gave it. Instead, I get back quote;testquote; Like Shawn, I have tried your code in isolation and only get the expected results. I looped it over a few test values: ?php $valueList = array('','test','testtest','testamp;test'); echo pre\n\n; foreach ($valueList as $value) { echo Before: $value\n; $value=preg_replace(%(?!amp;)%i, amp;, $value); echo After: $value\n\n; } echo '/pre'; ? outputs (ignoring pre as that was just to remove the br / for easy reading): Before: After: Before: test After: test Before: testtest After: testamp;test Before: testamp;test After: testamp;test The only conclusion is that something else in your code is converting the quotes. Have a look around. HTH Mark ---End Message--- ---BeginMessage--- That not what I meant, but I found a solution with (sadly, wanted pure GD, but it would've required going over the WHOLE image) imagemagick. Anyway, I even found more then I wanted http://www.imagemagick.org/discourse-server/viewtopic.php?f=1t=10830start=0 Thanks (especially for nitsan that suggested me imagemagick might have it), Ashley and PJ. Daniel On Sat, Jun 13, 2009 at 10:15 PM, PJ af.gour...@videotron.ca wrote: דניאל דנון wrote: Hello. I'm looking for way to rotate normal images, but not x/y, but with Z also. I get a source image (png, jpg, gif...) and I want to rotate it. assuming the depth of the image is 1 pixel for example... I'm looking for a way to do it without using imagemagick - only GD. I know it might be slower, but its need to run on a server without imagemagick. I've searched information about it, also in PEAR, but I couldn't find anything that takes a normal image and rotate it.. Thanks, Daniel Hi Daniel, I had the same question a short while ago and the only answer I could find was to redo the image with either gimp or PhotoShop an save it as png 8 with transparency. The only downside is that this seems to leave the angled frame (if you use one) a bit scuzzy; but you dont need Z. The other downside is that you can't dynamically rotate the image. Of course, I am assuming that by rotate you mean turn it at an angle and not replace by other images. HTH Phil -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- Use ROT26 for best security ---End Message--- ---BeginMessage--- As I have already mentioned, you can read the whole derivation of this 3d perspective engine and write it down using GD. It should not be such a big issue. Good luck! On Sun, Jun 14, 2009 at 3:07 PM, דניאל דנון danondan...@gmail.com wrote: That not what I meant, but I found a solution with (sadly, wanted pure GD, but it would've required going over the WHOLE image) imagemagick. Anyway, I even found more then I wanted http://www.imagemagick.org/discourse-server/viewtopic.php?f=1t=10830start=0 Thanks (especially for nitsan that suggested me imagemagick might have it), Ashley and PJ. Daniel On Sat, Jun 13, 2009 at 10:15 PM, PJ af.gour...@videotron.ca wrote: דניאל דנון wrote: Hello. I'm looking for way to rotate normal images, but not x/y, but with Z also. I get a source image (png, jpg, gif...) and I want to rotate it. assuming the depth of the image is 1 pixel for example... I'm looking for a way to do it without using imagemagick - only GD. I know it might be slower, but its need to run on a server without imagemagick. I've searched information about it, also in PEAR, but I couldn't find anything that takes a normal image and rotate it.. Thanks, Daniel Hi Daniel, I
Re: [PHP] how to pass a number through href url?
At 3:36 PM -0400 6/13/09, PJ wrote: I wish to be able to edit db field that is displayed in a page by calling up another page to handle the editing. The problem is how to pass the id (number) through an href. In other words, can the number be included in the uri and then filter the uri to leave just the number? Is something like this at all possible? I stopper answering your questions because of questions like this. Please understand that this question is so trivial that it clearly demonstrates you have no interest in solving problems yourself through even the most cursory glance at the php manuals. Instead, you would rather add to the noise of this list than look. That's unfortunate. If you're not going to try to help yourself, then why should anyone help you? Cheers, 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] Re: preg_replace problem
Hi. On Saturday 13 June 2009, Al wrote: I may not have been very clear. Feed it just test with the quotes. You should get back, test the same as you gave it. Instead, I get back quote;testquote; Like Shawn, I have tried your code in isolation and only get the expected results. I looped it over a few test values: ?php $valueList = array('','test','testtest','testamp;test'); echo pre\n\n; foreach ($valueList as $value) { echo Before: $value\n; $value=preg_replace(%(?!amp;)%i, amp;, $value); echo After: $value\n\n; } echo '/pre'; ? outputs (ignoring pre as that was just to remove the br / for easy reading): Before: After: Before: test After: test Before: testtest After: testamp;test Before: testamp;test After: testamp;test The only conclusion is that something else in your code is converting the quotes. Have a look around. HTH Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 3d image rotating
That not what I meant, but I found a solution with (sadly, wanted pure GD, but it would've required going over the WHOLE image) imagemagick. Anyway, I even found more then I wanted http://www.imagemagick.org/discourse-server/viewtopic.php?f=1t=10830start=0 Thanks (especially for nitsan that suggested me imagemagick might have it), Ashley and PJ. Daniel On Sat, Jun 13, 2009 at 10:15 PM, PJ af.gour...@videotron.ca wrote: דניאל דנון wrote: Hello. I'm looking for way to rotate normal images, but not x/y, but with Z also. I get a source image (png, jpg, gif...) and I want to rotate it. assuming the depth of the image is 1 pixel for example... I'm looking for a way to do it without using imagemagick - only GD. I know it might be slower, but its need to run on a server without imagemagick. I've searched information about it, also in PEAR, but I couldn't find anything that takes a normal image and rotate it.. Thanks, Daniel Hi Daniel, I had the same question a short while ago and the only answer I could find was to redo the image with either gimp or PhotoShop an save it as png 8 with transparency. The only downside is that this seems to leave the angled frame (if you use one) a bit scuzzy; but you dont need Z. The other downside is that you can't dynamically rotate the image. Of course, I am assuming that by rotate you mean turn it at an angle and not replace by other images. HTH Phil -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- Use ROT26 for best security
[PHP] include file in a class with global/parent scope?
Hello, I understand the why $vars is not in the global scope, but i was wondering if there was a way from within the class file to include a file in the parent's scope? i tried ::include('vars.php'), parent::include('vars.php'), but this breaks syntax... Please consider the following three files: 'scope.class.inc' ?php class CScope { public $var = 'class scope\n'; function cinclude($filename) { include('vars.php'); echo In class $vars\n; } } ? 'vars.php' ?php //global $vars;//if this line is uncommented then the desired result is achieved however, i don't want to change all the variables to global scope (this file is includeded in other files where global scoped variables is not desireable). $vars = 'vars.php scope\n'; ? 'scope.php' ?php include('scope.class.inc'); $object = new CScope; $object-cinclude('vars.php'); echo In original $vars\n;//$vars is not defined*** ? Thanks, dK -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Periodic Actions in PHP?
Actually, your message sparked an idea in my [slow] mind. :) I can put the PHP code in a java script, and tell javascript to call it every fifteen seconds. Best option, I think. :) Any ideas? Thanks! -- --- Contact info: Skype: parham-d MSN: fire_lizard16 at hotmail dot com email: parham90 at GMail dot com bruce bedoug...@earthlink.net wrote in message news:1528701c9ec4d$322e6cb0$0301a...@tmesa.com... hi... is this a php/web based app... are the users using the chat function via the browser.. if this is a browser/web app, are you looking for a way for the php web app to refetch the textfile... i would assume so... have you figured out a rough architecture/design for your app.. in your design, you're going to need to figure out how to accomplish updates to the text file, and when you do, you'll also have figured out how to do the reads... i'm assuming that you don't want a continuously running thread for your php/web app.. ie one continuously, never ending loop... -so you'll have the user add some text, the app will write this to a file.. the user will either select a refresh kind of btn, or your app will have to implement a refresh process, which will then fetch new/updated data from your files.. etc... -Original Message- From: richard.he...@gmail.com [mailto:richard.he...@gmail.com]on Behalf Of Richard Heyes Sent: Saturday, June 13, 2009 2:17 AM To: Parham Doustdar Cc: php-general@lists.php.net Subject: Re: [PHP] Periodic Actions in PHP? Hi, I'm going to create a small chat script with PHP. The messages you want others to see will be added to a flat file (I.E. TXT file), and read and displayed by PHP. However, I want this reading and displaying to be periodic. This means that I want PHP to check the file for new lines every,say, fifteen seconds. How may I do that? I have been unable to find any function that acts like a timer. If you're on Unix then look into using cron. Type the following at the command prompt to get info on cron: man 5 crontab Cron tasks can be scheduled at most once per minute. And if you're using Windows then I believe the equivalent would be task scheduler, but I've no idea how you would go about using it. -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net - updated 6th June) PHP mail: RMail (www.phpguru.org/rmail) PHP datagrid: RGrid (www.phpguru.org/rgrid) PHP Template: RTemplate (www.phpguru.org/rtemplate) PHP SMTP: http://www.phpguru.org/smtp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Uniquely identifying an array... as a key to another array
Alright, here's the situation. I'm wrapping memcached, which takes a list of several servers, into a quasi-singleton. In other words, I want only one instance per set of servers, not per server. Assuming I had three memcached servers at localhost, 192.168.1.1 and 192.168.1.2, I wouldn't want one instance per server, but given that there are seven possible permutations of combinations / only one server configuration, MemcacheConnector::$instances could be an array with seven objects. I'm expecting MemcacheConnector::getInstance($array) to take an array formatted like 'server' = 'port'. Thusly, the question then becomes, what's the lightest possible way to store a unique-ish array as the key for MemcacheConnector::$instances? Having MemcacheConnector::getInstance() check for self::$instances[serialize($serverArray)] seems a huge waste of both ram and CPU time. Is there a better way? Thanks, Eddie
Re: [PHP] Re: preg_replace problem
On Sat, Jun 13, 2009 at 5:16 PM, Aln...@ridersite.org wrote: Al wrote: This preg_replace() should simply replace all with amp; unless the value is already amp; But; if $value is simple a quote character [] I get quote. e.g., test = quote;testquote; Search string and replace works as it should in Regex_Coach. echo $value.'br /'; $value=preg_replace(%(?!amp;)%i, amp;, $value); echo $value; I tried using \x26 for the in the search string; didn't help. This seems too obvious to be a bug. Using php5.2.9 Al... I erred when I keyed this message. The But, should be as, without the e on quote. Which is an HTML entity for quote. But; if $value is simple a quote character [] I get quot. e.g., test = quot;testquot; The regex that you posted won't replace an actual quote character at all. Are you sure you aren't running the value through something like htmlspecialchars() before it's getting into your regexp? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sorting mySQL query - one order from multiple fields
Hi all. Am trying to sort baseball games by time, where there can be up to 3 times listed per game. Each game has an original date and time field, plus fields for 2 rain-out dates/times (rodate1 rotime1, rodate2, rotime2), to use if the game gets rained out. Note that rotime1 and rotime2 are NULL if no time has been entered. Also note that the original date and time fields are not changed - they are kept for posterity. Usually, the rain-out date is set to a day that the teams were already going to play each other again, with the rain-out game going first. So need to sort those 2 games in order: rain-out first, then normally-scheduled. But, I can't just sort on the time field, as the rain-out game could now have a different time. I need to use the rotime2 (if it exists), else use the rotime1 (if it exists), else use the time. Can not get my query order to work. One of the variations I've tried: $theQuery = mysql_query(select variousFields from theTable where date = '$currDate' ORDER BY CASE WHEN rotime2 THEN rotime2 WHEN rotime1 THEN rotime1 ELSE time); Is there a query sort that will work in this case? Is not the usual sort by last name, then sort by first name scenario! Thanks for any pointers. George Langley Multimedia Developer, Audio/Video Editor, Musician, Arranger, Composer http://www.georgelangley.ca -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Search/Replace in entire database?
Hi everyone, I am in the middle of creating an editor where you can search and replace on an individual column in a single table then I came across something I need to be able to do but not sure how. Is it posible (And if so please how :-) to search an entire database and all tables within a database and do a find/replace on keywords without having to specify each table/column within that table? The people I am working for have made some big changes and one of them is changing the names of one of their products, but this product name appears EVERYWHERE in many tables and in lots of different column names, and it would save so much time if I could do a single query that would just search EVERYTHING within the database. Thanks for any advice you can give me. Regards Chris Payne -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php