php-general Digest 13 Jun 2009 09:17:24 -0000 Issue 6173

2009-06-13 Thread php-general-digest-help

php-general Digest 13 Jun 2009 09:17:24 - Issue 6173

Topics (messages 293992 through 294000):

Re: opendir() Question
293992 by: Andrew Ballard
293996 by: Parham Doustdar

Re: Form handling
293993 by: Dajve Green

Re: Dynamic Titles
293994 by: David Robley
293995 by: Austin Caudill

Doubt on why some syntaxis is not used for PHP
293997 by: Manuel Aude

about locale settings
293998 by: Per Jessen

Periodic Actions in PHP?
293999 by: Parham Doustdar
294000 by: Richard Heyes

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---
2009/6/12 Parham Doustdar parha...@gmail.com:
 Hi there,
 I need to create a PHP script that will connect to an  FTP, get a listing of 
 files/directories from it, and displays them in a table. Now, there is only 
 one problem here.
 I tried connecting with opendir(), like this:
 opendir(ftp://...;);
 but it seems it doesn't work with FTP. Now, is there another thing I could 
 use for the same effect?
 Thanks!
 --
 ---
 Contact info:
 Skype: parham-d
 MSN: fire_lizard16 at hotmail dot com
 email: parham90 at GMail dot com

RTM http://www.php.net/ftp

Andrew
---End Message---
---BeginMessage---
Hello there Andrew,
Thank you very much for your help. I didn't know such an extention existed. 
:)

-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com
Andrew Ballard aball...@gmail.com wrote in message 
news:b6023aa40906121312m47034863k9c502e07d66c4...@mail.gmail.com...
2009/6/12 Parham Doustdar parha...@gmail.com:
 Hi there,
 I need to create a PHP script that will connect to an FTP, get a listing 
 of files/directories from it, and displays them in a table. Now, there is 
 only one problem here.
 I tried connecting with opendir(), like this:
 opendir(ftp://...;);
 but it seems it doesn't work with FTP. Now, is there another thing I could 
 use for the same effect?
 Thanks!
 --
 ---
 Contact info:
 Skype: parham-d
 MSN: fire_lizard16 at hotmail dot com
 email: parham90 at GMail dot com

RTM http://www.php.net/ftp

Andrew 


---End Message---
---BeginMessage---

 -Original Message-
 From: Manuel Lemos [mailto:mle...@acm.org]
 Sent: 11 June 2009 07:21
 To: Eddie Drapkin
 Cc: PHP General Mailing List
 Subject: [PHP] Re: Form handling
 
 Hello,
 
 on 06/10/2009 03:10 PM Eddie Drapkin said the following:
  I've been charged with writing a class that handles forms, once they've
 been
  POSTed to.  The idea of the class is to handle the most common use-cases
 of
  POST forms, and any special functionality can be handled with a child
 class
  at a later date, but for our uses, we're going to have mostly pretty
 typical
  POST forms.  Follows is the list of cases I've determined that are the
 most
  common, can anyone think of any that are omitted or that are never going
 to
  be used?
 
  class form_handler {
  public /* bool */ function setRequiredFields(array $fields); //takes
 a
  simple array that corresponds to a $_POST key, verifying that there is
 data
  on required fields but not for optional fields, returns true or false on
  error
  public /* bool */ function setRequiredFieldTypes(array $fieldTypes);
  //array of field names = type a la ('username' = array(regex,
  '/a-zA-Z0-9\-_/'))
  //or 'phone_number' = (array('int', 'min_len' = 7,
  'max_len' = 10)) etc, the exact spec is obviously nowhere near done but
  will probably just wrap a lot of filter_ functions, returns true or
 false on
  error
  public /* string */ function validateAndCaptureError(); //returns
 error
  or empty string
  public /* void */ function validateAndForwardTo($page); //forwards
 to
  page on error, or not
  }
 
  each of the globule setters will have a corresponding appendRequired...
  method, so as not to require handling enormous data structures for
  conditional form building.
  ♦
  As you can see, the class looks pretty barren, but I can't think of any
 more
  functionality than would be required, although I am kickign the idea
 around
  of having very specific validation type methods ie.
  form_handler::requireInt($field, array $options) or
  form_handler::requireRegex($field, $regex), etc.
 
  Thoughts?
 
 You may want consider not reinventing the wheel.
 
 I use this popular forms generation and validation class since about 10
 years now. It can deal with pretty much all you need now and probably
 later.
 
 http://www.phpclasses.org/formsgeneration
 
 Here are some live examples of the class and its plug-ins.
 
 http://www.meta-language.net/forms-examples.html
 
 --
 
 Regards,
 Manuel Lemos

Whilst Manuel's Forms Generation class / Zend Form 

[PHP] about locale settings

2009-06-13 Thread Per Jessen
When I've set LC_ALL before calling php, why do I need to call
setlocale() in the script too:

LC_ALL=de_DE.utf8 php -r print strftime('%B');
June

LC_ALL=de_DE.utf8 php -r setlocale(LC_ALL,''); print strftime('%B');
Juni

What am I missing here?  I have no problem with the setlocale(LC_ALL,'')
call, but I'd like to understand why I need it.


-- 
Per Jessen, Zürich (16.1°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Periodic Actions in PHP?

2009-06-13 Thread Parham Doustdar
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!
-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com

Re: [PHP] Periodic Actions in PHP?

2009-06-13 Thread Sancar Saran
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: ezmlm response

2009-06-13 Thread Ashley Sheridan
On Thu, 2009-06-11 at 13:39 -0400, Daniel Brown wrote:
 On Thu, Jun 11, 2009 at 13:24, Mika Pohjolapohjola.m...@gmail.com wrote:
  It could be arti...@bluemusicgroup.com or m...@bluemusicgroup.com
 
  Please, remove. Thanks.
 
 Mika,
 
 You will need to do this yourself at http://php.net/mailinglists.
 If it's a different address forwarding to your primary that is
 subscribed to the list, you will have to enter that address in the
 (un)subscribe field.
 
 -- 
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1
 
Maybe the instructions for unsubscribing should be on the bottom of
every footer from the list, as this thing seems to come up once a week!

Thanks
Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Preventing XSS Attacks

2009-06-13 Thread Ashley Sheridan
On Thu, 2009-06-11 at 18:27 +0200, Jan G.B. wrote:
 2009/6/11 HallMarc Websites m...@hallmarcwebsites.com
 
 
 
   -Original Message-
   From: tedd [mailto:tedd.sperl...@gmail.com]
   Sent: Thursday, June 11, 2009 9:28 AM
   To: PHP-General List
   Subject: Re: [PHP] Preventing XSS Attacks
  
   At 7:08 PM +0100 6/10/09, Ashley Sheridan wrote:
   
   So something like this would be acceptable?:
   
   $searchTerms = (isset($_REQUEST['q']))?$_REQUEST['q']:'';
   $searchTerms = htmlentities($searchTerms);
   $dbSearchTerms = mysql_real_escape_string($searchTerms);
   
   Giving me two variables, one for display output to user, the other for
   use in the database?
   
   Thanks
   Ash
  
   Ash:
  
   I wouldn't use $_REQUEST.  If you know the request method then use it.
  
   There can be problems using $_REQUEST.
  
   Cheers,
  
   tedd
  
   --
   ---
   http://sperling.com  http://ancientstones.com  http://earthstones.com
  
 
  I agree with tedd whole heartedly and I want to repeat the importance of
  protecting the data coming back from the db as well by using
  safeEscapeString in your queries and again the reason for this is to
  prevent
  malicious code from being executed.
 
  As far as CSRF/XSRF take a read here
  http://shiflett.org/articles/cross-site-request-forgeries
 
  [Marc Hall - HallMarc Websites - http://www.hallmarcwebsites.com
  610.446.3346]
 
 
 
 I'd recommend that you *always* use ENT_QUOTES as the second parameter on
 htmlentities or htmlspecialchars. Otherwise a single ' will not be escaped,
 which may be evil.
 
 Also be sure that you don't code a possibility to include local or even
 remote files: It's so easy to Inject code into logfiles.
 include('whatever'.$_REQUEST['var'].'.whatever') is not a sufficient
 protection.
 
 Also, like someone already mentioned, *always* prefer _POST over _REQUEST,
 when dealing with a FORM with method POST!
 
 Regards

In this case I'm expecting input from both forms and links, so have to
use $_REQUEST, really. As far as I can tell, $_REQUEST is no less safe
than any of the others, as they are all getting their data from the
user, so it's all unsafe until validated/cleaned.

Thanks for the ENT_QUOTES thing, I really haven't had my head screwed on
the last few days!

Thanks
Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-13 Thread Ashley Sheridan
On Thu, 2009-06-11 at 20:52 +0200, Jean-Pierre Arneodo wrote:
 Ashley Sheridan a écrit :
  On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:

  Hi!
  I'm stuck.
  I don't understand why the php CLI dies after 3 hours in my script.
  Any idea to solve?
  Thanks
 
 
  PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
  20:06:36)
  Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
  GNU/Linux
 
  Conf [php.ini]
  max_execution_time=0
 
  ?php
  while (true) {
  sleep(5);
  }
  ?
 
 

  
  The while loop will continue executing until its condition is false. As
  you've got a boolean true as the condition, it will never end.
 
  Thanks
  Ash
  www.ashleysheridan.co.uk

 I don't want to stop, but the process dies.
 
 I've tried the same loop with bash interpretor.
 Same result, it seems to be a ubuntu problem, not a php problem.
 
 Thanks
 
 
 
Why do you want the process to continue indefinitely? Is it for a daemon
of some kind?

Thanks
Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] 3d image rotating

2009-06-13 Thread Ashley Sheridan
On Fri, 2009-06-12 at 11:55 +0300, דניאל דנון 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
 
Are you meaning like rotate it so that at 90° it will appear as a
pixel-wide line on the image?

Thanks
Ash
www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] 3d image rotating

2009-06-13 Thread Nitsan Bin-Nun
He treats the image as width, height and 1 pixel of depth.

It should not be a problem as long as you finished Kita Yud Bet with 5
points of math (trigo  vectors) ;)

Good luck!

On Sat, Jun 13, 2009 at 1:44 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Fri, 2009-06-12 at 11:55 +0300, דניאל דנון 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
 
 Are you meaning like rotate it so that at 90° it will appear as a
 pixel-wide line on the image?

 Thanks
 Ash
 www.ashleysheridan.co.uk


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Periodic Actions in PHP?

2009-06-13 Thread Colin Guthrie

'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/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Periodic Actions in PHP?

2009-06-13 Thread Phpster



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 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/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



If the goal was to push data, the OP could investigate the use of a  
comet server. It holds a long running stream allowing the server to  
push new data to the client.


Bastien

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] truncate a mb-string to a given octet length?

2009-06-13 Thread Tom Worster
eddie,

you were quite right and i was wrong.

after discovering that the longest utf8 varchar column that mysql will allow
is varchar(333), i did some tests. on a varchar(255) column, mysql allows
strings with up to 255 utf8 characters to be inserted. and it truncates at
255 characters observing utf8 character sequences.

now i have to go back to the script that convinced me otherwise and figure
out what i misunderstood in it.

section 10.4.1 of the manual could be explicit about it. when i read it i
got the clear impression the parameter referred to octets.


On 6/12/09 1:22 PM, Tom Worster f...@thefsb.org wrote:

 On 6/12/09 11:52 AM, Eddie Drapkin oorza...@gmail.com wrote:
 
 Correct me if I'm wrong, but should varchar 255 with a utf8 character set
 mean 
 255 unicode characters, not octets?
 
 in mysql, the length refers to the storage space of the string, not the
 decoded character count. i don't know about other dbms.
 
 
 On Fri, Jun 12, 2009 at 11:50 AM, Tom Worster f...@thefsb.org wrote:
 say a table in the db has a varchar(255) column, 255 being the max number of
 octets of strings that can go in the column. now say the php script very
 occasionally has to deal with utf8 input strings with octet length  255 --
 it needs to select rows matching the input string or insert the input
 string.
 
 so what i think i need is a function to truncate a utf8 string to the
 longest valid utf8 string that has octet length = 255.
 
 is this what mb_strcut() is for? i'm having a hard time understanding the
 man page for that function.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Periodic Actions in PHP?

2009-06-13 Thread bruce
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



Re: [PHP] Re: Same Page, Fundamentally Different Behavior OR is Firefox broken?

2009-06-13 Thread Matt Neimeyer
I'd have to check...

But am I to understand that no-cache works with pre-caching? I always
assumed it basically meant when you get this page, don't keep it for
next time?

Thanks!

On Fri, Jun 12, 2009 at 2:04 AM, Manuel C.hippopotam...@gmail.com wrote:
 Matt Neimeyer a écrit :

 I'm at a complete loss... So I'm hoping someone can point me in the
 right direction to even start looking.

 We have an application written in PHP that lets users send out emails.
 The basic process is as follows.

 1. Go to start screen. (This resets anything currently in process
 for the current logged in user)
 2. Upload email addresses and other info (Names, etc)
 3. Build Email
 4. Send

 In Step 3 the user can click a Live Preview button to see what the
 email will look like with the merged data.

 Here's the problem,  this works fine in all versions of IE, versions
 1.5 or less of FireFox and versions 3 or less of Safari. However,
 starting in FireFox 2, and now Safari 4, when you get to step four OR
 click the live preview button in step three there is no more data in
 the merge. In those browsers the system is acting like the end user
 went BACK to the start page (in another window?) and reinitialized all
 the data.

 I immediately thought it might be pre-fetching so I tried using the
 system before and after toggling the network.prefetch-next setting in
 about:config with FireFox 2.0.0.20 and restarting the browser. No
 luck. So I added code to my reset function to email me the output of
 phpinfo() when the reset function is called. Using IE I get 1
 notification. Using FF I get two notifications. This reinforces my
 theory that FireFox is prefetching the menu item to start a new
 mailing (just an a link...) from the top of the composer page. Even
 still... I've disabled prefetch so it SHOULDN'T even be considering
 those links right? I've also tried adding artificial
 ?now=timestamp fakes to the end of all menu links since I read
 somewhere (don't remember where) that FireFox only prefetches pages
 with no query section in the address.

 Has anyone run into this behavior before? Any recommendations on how
 to stop it? Preferably from the server with code of some sort...

 Thanks in advance.

 Matt



 Hi Matt,

 Have you tried to put this two lines in the HEAD section of your HTML pages
 :
        META http-equiv=Cache-Control content=no-cache
        META http-equiv=Pragma content=no-cache

 Hope it helps you.

 BR


 --
 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] 3d image rotating

2009-06-13 Thread PJ
דניאל דנון 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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] High ID (unique, auto increment) causes slow responses on PHP (MySQL)

2009-06-13 Thread דניאל דנון
 I've built a certain system where every time new user enters it creates a
guest row on guests table. he also gets an identifying cookie.

The table contains several fields, one of them is ID which is auto increment
and unique

When he does a certain action it gets recorded in the done_action table
with several fields on it, one of them is guest_id and his ID on it.


Problem is the guests table has about 30,000 rows (which means ID is high).

 I was wondering whether I should somehow change how the system works.

I've thought about couple of options

A weekly cleanup job. opens a table called guests_tmp, *copies* all data
from guests to guests_tmp.

every row it copies it also changes the ID on the table done_action.

What do you  think?


-- 
Use ROT26 for best security


Re: [PHP] High ID (unique, auto increment) causes slow responses on PHP (MySQL)

2009-06-13 Thread Nitsan Bin-Nun
Just use SERIAL id and you will be good ;) (that's an alias for something
like BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY)

It shouldn't bother you as long as it works.

On Sat, Jun 13, 2009 at 9:16 PM, דניאל דנון danondan...@gmail.com wrote:

  I've built a certain system where every time new user enters it creates a
 guest row on guests table. he also gets an identifying cookie.

 The table contains several fields, one of them is ID which is auto
 increment
 and unique

 When he does a certain action it gets recorded in the done_action table
 with several fields on it, one of them is guest_id and his ID on it.


 Problem is the guests table has about 30,000 rows (which means ID is high).

  I was wondering whether I should somehow change how the system works.

 I've thought about couple of options

 A weekly cleanup job. opens a table called guests_tmp, *copies* all
 data
 from guests to guests_tmp.

 every row it copies it also changes the ID on the table done_action.

 What do you  think?


 --
 Use ROT26 for best security



Re: [PHP] High ID (unique, auto increment) causes slow responses on PHP (MySQL)

2009-06-13 Thread Stuart
2009/6/13 דניאל דנון danondan...@gmail.com:
  I've built a certain system where every time new user enters it creates a
 guest row on guests table. he also gets an identifying cookie.

 The table contains several fields, one of them is ID which is auto increment
 and unique

 When he does a certain action it gets recorded in the done_action table
 with several fields on it, one of them is guest_id and his ID on it.


 Problem is the guests table has about 30,000 rows (which means ID is high).

  I was wondering whether I should somehow change how the system works.

 I've thought about couple of options

 A weekly cleanup job. opens a table called guests_tmp, *copies* all data
 from guests to guests_tmp.

 every row it copies it also changes the ID on the table done_action.

 What do you  think?

I think your problem has nothing to do with high IDs. I have tables in
MySQL with primary key IDs that have recently passed 2 billion and
they're still as responsive as they were with 1 row!!

What specific operations are slow, and are you sure it's the MySQL
query that's being slow and not something in the surrounding code? If
it is the MySQL query what is it and what engine are your tables
using?

-Stuart

-- 
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] how to pass a number through href url?

2009-06-13 Thread PJ
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?

-- 
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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how to pass a number through href url?

2009-06-13 Thread Stuart
2009/6/13 PJ af.gour...@videotron.ca:
 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?

Oh dear $DEITY. Please find a beginners tutorial to PHP and complete
it before asking questions on this list.

http://www.example.com/index.php?id=12345

will give you

$_GET['id'] == 12345

-Stuart

-- 
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] preg_replace problem

2009-06-13 Thread Al
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...

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [Bulk] Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-13 Thread Jean-Pierre Arneodo

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 20:52 +0200, Jean-Pierre Arneodo wrote:
  

Ashley Sheridan a écrit :


On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  
  

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}
?


  



The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.

Thanks





Why do you want the process to continue indefinitely? Is it for a daemon
of some kind?

Thanks
Ash
www.ashleysheridan.co.uk

  
No, it isn't a daemon, but it does something and wait the end of 
processing by polling a daemon.


# ulimit -a
core file size  (blocks, -c) 0
data seg size   (kbytes, -d) unlimited
scheduling priority (-e) 0
file size   (blocks, -f) unlimited
pending signals (-i) 38912
max locked memory   (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files  (-n) 1024
pipe size(512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority  (-r) 0
stack size  (kbytes, -s) 8192
cpu time   (seconds, -t) unlimited
max user processes  (-u) 38912
virtual memory  (kbytes, -v) unlimited
file locks  (-x) unlimited




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how to pass a number through href url?

2009-06-13 Thread PJ
Stuart wrote:
 2009/6/13 PJ af.gour...@videotron.ca:
   
 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?
 

 Oh dear $DEITY. Please find a beginners tutorial to PHP and complete
 it before asking questions on this list.

 http://www.example.com/index.php?id=12345

 will give you

 $_GET['id'] == 12345

 -Stuart

 Thank you, Stuart.  ;-) 


-- 
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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: preg_replace problem

2009-06-13 Thread Shawn McKenzie
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...

Your code works for me, unless I'm misunderstanding the problem.  With
the following:

$value = quote;testquote;;

I get:

quote;testquote;br /
amp;quote;testamp;quote;

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: preg_replace problem

2009-06-13 Thread Al



Shawn McKenzie 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...


Your code works for me, unless I'm misunderstanding the problem.  With
the following:

$value = quote;testquote;;

I get:

quote;testquote;br /
amp;quote;testamp;quote;



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 wise, if I give it just a single quote [] I get back [quote;]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: preg_replace problem

2009-06-13 Thread Al



Shawn McKenzie 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...


Your code works for me, unless I'm misunderstanding the problem.  With
the following:

$value = quote;testquote;;

I get:

quote;testquote;br /
amp;quote;testamp;quote;



I tried IE8 thinking it could be a weird browser bug. Same error.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] socket communication programming

2009-06-13 Thread Manuel Lemos
Hello,

on 06/12/2009 11:41 AM HELP! said the following:
 hi
 I can not get the stream_get_contents() to work.  it's returning empty.
 If you have a login details ALOGINPASS 1A cant you just fwrite($ft,
 ALOGINPASS 1A); or do you need to add other things
 
 
 what is the meaning of this string GET / HTTP/1.0\r\nHost:
 www.example.com\r\nAccept http://www.example.com/r/nAccept: */*\r\n\r\n

If that is regular HTTP, why don't you try an HTTP client class that
lets you customize your request parameters like this one?

http://www.phpclasses.org/httpclient

-- 

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



Re: [PHP] socket communication programming

2009-06-13 Thread HELP!
Thanks. I need to access remote data via TCP. Connecting to the given
port has been successful but getting acknowledgement from the remote server
after sending the login packet is a problem. Is there anything wrong sending
the login packet in strings? or what is the best way?

I probably think the server is not detecting the end of the login message.
Is there anyway you can add END of message to login package specified.

Thnaks



On Sat, Jun 13, 2009 at 10:28 PM, Manuel Lemos mle...@acm.org wrote:

 Hello,

 on 06/12/2009 11:41 AM HELP! said the following:
  hi
  I can not get the stream_get_contents() to work.  it's returning empty.
  If you have a login details ALOGINPASS 1A cant you just fwrite($ft,
  ALOGINPASS 1A); or do you need to add other things
 
 
  what is the meaning of this string GET / HTTP/1.0\r\nHost:
  www.example.com\r\nAccept http://www.example.com/r/nAccept:
 */*\r\n\r\n

 If that is regular HTTP, why don't you try an HTTP client class that
 lets you customize your request parameters like this one?

 http://www.phpclasses.org/httpclient

 --

 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/




-- 
www.bemycandy.com


[PHP] Re: preg_replace problem

2009-06-13 Thread Al



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;

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php