Re: [PHP] Better way to store data in memory?

2007-07-23 Thread Nicolas Quirin
Perhaps, you can use Zend Cache which comes with Zend Framework to store 
your data, without sharing them, allowing to store them in files or memory 
(shared or not)
in an easy way...I'm intersting on Zend cache for its roadmap and because 
its a Zend product, like php...best quality and best support.


I'm using it to cache various php objects, build the first time from 
database query...later from cache...really good...


- Original Message - 
From: Richard Davey [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Monday, July 23, 2007 6:50 PM
Subject: [PHP] Better way to store data in memory?



Hi php-general collective,

I'm building up some image data in my PHP script (ready for output to
the browser). Having to do some complex per pixel manipulation, which
is fine - but I'm just wondering is there a quicker / more efficient
way of storing the pixel data than in an array?

At the moment I hold it in $array[$x][$y], which makes the drawing
loop painless, but it's creating an array with 307,200 elements which
is proving to be quite slow. As I'm only storing fixed width byte
values is there an alternative method? For example the ability to
read/write to a chunk of memory instead? (so I can read out whole
strips of data rather than one by one?)

I was looking at the Shared Memory functions, but that isn't exactly
what I need (I don't want it shared, I want it process specific)

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

Never trust a computer you can't throw out of a window

--
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] regular expression and forbidden words

2007-07-18 Thread Nicolas Quirin
Hi,

i'm french, i'm using regular expressions in php in order to rewrite hyperlink 
tags in a specific way before apache output is beeing sent to client.

Purpose is to replace href attribute of any A html tag by a javascript function 
calling an ajax loader.

Currently I have wrote that:

  $pattern = '/a 
href=(http:\/\/dev.netdoor.fr|(\.))\/index.php\?page=(.*?)(.*?)\\/a/i';
  $replacement = 'a href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=$4\');$5/a';
  $html_mark = preg_replace($pattern, $replacement, $html_mark);

it works, but it's too permissive, it replaces too much links (some links with 
some get parameters must stay unchanged)

I don't really understand my pattern...it's a little strange for me...lol

I wouldn't like to rewrite links that contains any of the following words in 
get parameters (query string):

  noLoader
  noLeftCol
  skipallbutpage
  skipservice

i would like to rewrite only link that begin with 'http://dev.netdoor.fr' or '.'

examples:

a 
href=http://dev.netdoor.fr/index.php?page=./comptes/index.phpnoLoadernoLeftColidx=6bdx=423skipservice;test/a
 

=must be not rewritted!

a class=myclass 
href=./index.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7name/a

=must be rewritted like this :

a class=myclass href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7\');name/a


Please help me...:0)

best regards

nicolas


[PHP] regular expression and forbidden words

2007-07-18 Thread Nicolas Quirin

Hi,

i'm french, i'm using regular expressions in php in order to rewrite 
hyperlink tags in a specific way before apache output is beeing sent to 
client.


Purpose is to replace href attribute of any A html tag by a javascript 
function calling an ajax loader.


Currently I have wrote that:

 $pattern = '/a 
href=(http:\/\/dev.netdoor.fr|(\.))\/index.php\?page=(.*?)(.*?)\\/a/i';
 $replacement = 'a href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=$4\');$5/a';

 $html_mark = preg_replace($pattern, $replacement, $html_mark);

it works, but it's too permissive, it replaces too much links (some links 
with some get parameters must stay unchanged)


I don't really understand my pattern...it's a little strange for me...lol

I wouldn't like to rewrite links that contains any of the following words in 
get parameters (query string):


 noLoader
 noLeftCol
 skipallbutpage
 skipservice

i would like to rewrite only link that begin with 'http://dev.netdoor.fr' or 
'.'


examples:

a 
href=http://dev.netdoor.fr/index.php?page=./comptes/index.phpnoLoadernoLeftColidx=6bdx=423skipservice;test/a


=must be not rewritted!

a class=myclass 
href=./index.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7name/a


=must be rewritted like this :

a class=myclass href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7\');name/a



Please help me...:0)

best regards

nicolas

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



[PHP] rewrite hyperlink tags with a regular expression containing forbidden words

2007-07-17 Thread Nicolas Quirin
Hi,

i'm french, i'm using regular expressions in php in order to rewrite hyperlink 
tags in a specific way before apache output is beeing sent to client.

Purpose is to replace href attribute of any A html tag by a javascript function 
calling an ajax loader.

Currently I have wrote that:

  $pattern = '/a 
href=(http:\/\/dev.netdoor.fr|(\.))\/index.php\?page=(.*?)(.*?)\\/a/i';
  $replacement = 'a href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=$4\');$5/a';
  $html_mark = preg_replace($pattern, $replacement, $html_mark);

it works, but it's too permissive, it replaces too much links (some links with 
some get parameters must stay unchanged)

I don't really understand my pattern...it's a little strange for me...lol

I wouldn't like to rewrite links that contains any of the following words in 
get parameters (query string):

  noLoader
  noLeftCol
  skipallbutpage
  skipservice

i would like to rewrite only link that begin with 'http://dev.netdoor.fr' or '.'

examples:

a 
href=http://dev.netdoor.fr/index.php?page=./comptes/index.phpnoLoadernoLeftColidx=6bdx=423skipservice;test/a
 

=must be not rewritted!

a class=myclass 
href=./index.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7name/a

=must be rewritted like this :

a class=myclass href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7\');name/a


Please help me...:0)

best regards

nicolas


[PHP] regular expression and forbidden words

2007-07-17 Thread Nicolas Quirin
Hi,

i'm french, i'm using regular expressions in php in order to rewrite hyperlink 
tags in a specific way before apache output is beeing sent to client.

Purpose is to replace href attribute of any A html tag by a javascript function 
calling an ajax loader.

Currently I have wrote that:

  $pattern = '/a 
href=(http:\/\/dev.netdoor.fr|(\.))\/index.php\?page=(.*?)(.*?)\\/a/i';
  $replacement = 'a href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=$4\');$5/a';
  $html_mark = preg_replace($pattern, $replacement, $html_mark);

it works, but it's too permissive, it replaces too much links (some links with 
some get parameters must stay unchanged)

I don't really understand my pattern...it's a little strange for me...lol

I wouldn't like to rewrite links that contains any of the following words in 
get parameters (query string):

  noLoader
  noLeftCol
  skipallbutpage
  skipservice

i would like to rewrite only link that begin with 'http://dev.netdoor.fr' or '.'

examples:

a 
href=http://dev.netdoor.fr/index.php?page=./comptes/index.phpnoLoadernoLeftColidx=6bdx=423skipservice;test/a
 

=must be not rewritted!

a class=myclass 
href=./index.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7name/a

=must be rewritted like this :

a class=myclass href=javascript:void(0); 
OnClick=javascript:yui_fastLoader(\'./systeme/chargeur.php?page=./comptes/mediatheque/index.phpfilter=mov;flv;mpegidx=7\');name/a


Please help me...:0)

best regards

nicolas


Re: [PHP] Custom database session handler and data concurrent access from ajax request

2007-05-03 Thread Nicolas Quirin

Nobody could help me???

THX
- Original Message - 
From: [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Thursday, May 03, 2007 11:45 AM
Subject: [PHP] Custom database session handler and data concurrent access 
from ajax request





Hi,

i'm currently working on a web site that use AJAX requests to load a web 
page by
part. So, my apache server gives quickly an answer and current client must 
wait
a little bit in order to have the entire web page, but while this loading 
step,

he can already see my partially displayed web page and use it!

This web site uses php session, based on cookies, but not only cookies 
(cookies

are just prefered). session.auto_start is false in order to allow object
declarations before session starts (so I can stored little object in 
session)

There is no session handler defined in php.ini, line has been commented).

In each php script, i start manually the session with session_start and i 
use
register_shutdown to register session_write_close in order to write 
current

session when the current script is finished.

Sessions are managed in a mysql database, with autocommit enabled. I'm 
using

mysql_pconnect in my handler to read/write session data (same user, same
password, same host, always).

Read/write session into database works...but not fine.

Scenario: scripts are parts of a main page, scripts are called by ASYNC 
AJAX GET
Script 1 modifies an object A from session and re-serializes it into 
session,
Script 2 is launched when client is receiving a response from the server 
for

script 1(php output buffering is enabled),
Script 2 displayed object A content from session and flush object A 
content,
re-serializes it into session, but sometime Script 2 doesn't displayed 
object A
modification by script 1. More terrible, reloading the entire page 
displays all
the content of the modified object A (but script 2 has flushed its 
content!)


I'm asking if custom session handler must implement mutex system or 
anything to
prevent concurrent access and terrible random errors of session 
writing/reading
and moreConcurrent access does'nt seems to be safely managed 
natively...


Any idea? comment? I can sent my session handler php class

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



Fw: [PHP] Custom database session handler and data concurrent access from ajax request

2007-05-03 Thread Nicolas Quirin


- Original Message - 
From: Nicolas Quirin [EMAIL PROTECTED]

To: [EMAIL PROTECTED]
Sent: Thursday, May 03, 2007 6:22 PM
Subject: Re: [PHP] Custom database session handler and data concurrent 
access from ajax request




Ok thanks a lot to confirm my problem.
I have partially implemented a write/read session class handler (not the 
customized session save handler wich read/write data from database)
This class is only a semaphore manager for read/write object in the 
current session. Semaphore is created if not existent, semaphore is 
acquired if free, blocking if process must wait for this ressource.


From my first tests of it, less error occured...

But having a semaphore by safe object stored in the current session is 
cost memory issue: a created semaphore must have a time to live equal to 
the life time of the current session since i could'nt know which script is 
executed before another and which script could remove the semaphore...


So semaphore are removed by session garbage collector. :-s.

This issue cannot support 1 connected users...I think:

1 * (nbsafeobjet * semaphore memory size) = ARGH

To finish, I must create a file per semaphore since sem_get require an id 
generated with ftock()!!!

Heavy issue

Is this solution really bad?

I have search and find another solution : flock() and create a file per 
safe objet in the session.


- Original Message - 
From: Richard Lynch [EMAIL PROTECTED]

To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Thursday, May 03, 2007 5:59 PM
Subject: Re: [PHP] Custom database session handler and data concurrent 
access from ajax request




On Thu, May 3, 2007 4:45 am, [EMAIL PROTECTED] wrote:

Sessions are managed in a mysql database, with autocommit enabled. I'm
using
mysql_pconnect in my handler to read/write session data (same user,
same
password, same host, always).


As noted in the user comments of the on-line manual, the sample code
in the manual does not (last I checked) handle the race condition of
multiple AJAX (or other) requests.

Several work-arounds are proposed, I believe.


I'm asking if custom session handler must implement mutex system or
anything to
prevent concurrent access and terrible random errors of session
writing/reading
and moreConcurrent access does'nt seems to be safely managed
natively...


Yes.

You *do* need to deal with this, and the sample code on php.net
doesn't do that.  It only works for the Web 1.0 (?) idea of
interaction with serial requests to alter session.


Any idea? comment? I can sent my session handler php class


Some kind of lock/mutex/whatever will be needed -- which will make
your AJAX calls serial, not parallel.

So you want to MINIMIZE your session writing section of code, call
session_write_close at the end of it, and do that as soon as possible
at the tip-top of the script, to make the serial-ness of the scripts
as low-impact as possible.

Also re-consider if you really really need to cram as much stuff
into a session as you originally architected.  Often-times I've seen
folks putting an awful lot of stuff in session data, and they don't
NEED to, it was just convenient -- Once you start down the AJAX
road, it seems to me like you want to re-think that convenience and
go for minimalism of what you write into a session.  But I ain't been
down that road, so maybe I'm full of it. :-)

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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