php-general Digest 17 Sep 2007 11:46:14 -0000 Issue 5023

2007-09-17 Thread php-general-digest-help

php-general Digest 17 Sep 2007 11:46:14 - Issue 5023

Topics (messages 262150 through 262160):

Re: Finding next recored in a array
262150 by: brian
262151 by: Richard Kurth
262152 by: Rick Pasotto
262153 by: Richard Kurth
262154 by: Richard Kurth
262155 by: Rick Pasotto
262157 by: M. Sokolewicz

Parsing Poor XML into to PHP
262156 by: John Taylor-Johnston
262160 by: Gavin M. Roy

Re: Configure mail to use Gmail smtp
262158 by: dcastillo.tsanalytics.com
262159 by: dcastillo.tsanalytics.com

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

Richard Kurth wrote:

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I do 
not understand is if I know the last number was say 5 how do I tell the 
script that that is the current number so I can select the next  record

||



I think you'll need your own function for this. Pass in the array and 
loop through it until you find the key, increment that, ensure that 
there is another value with that key, and return the key (or the value).


(untested)

function nextInArray($arr, $val)
{
$next_key = NULL;

for ($i = 0; $i  sizeof($arr);$i++)
{
if ($arr[$i] == $val)
{
$next_key = ++$i;
break;
}
}

// return the key:
return (array_key_exists($next_key) ? $next_key : NULL);

// or the value:
return (array_key_exists($next_key) ? $arr[$next_key] : NULL);

}

However, in your example, you're searching for the key that points to 
the value '5'. What if the value '5' occurs more than once?


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

brian wrote:

Richard Kurth wrote:

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I 
do not understand is if I know the last number was say 5 how do I 
tell the script that that is the current number so I can select the 
next  record

||



I think you'll need your own function for this. Pass in the array and 
loop through it until you find the key, increment that, ensure that 
there is another value with that key, and return the key (or the value).


(untested)

function nextInArray($arr, $val)
{
$next_key = NULL;

for ($i = 0; $i  sizeof($arr);$i++)
{
if ($arr[$i] == $val)
{
$next_key = ++$i;
break;
}
}

// return the key:
return (array_key_exists($next_key) ? $next_key : NULL);

// or the value:
return (array_key_exists($next_key) ? $arr[$next_key] : NULL);

}

However, in your example, you're searching for the key that points to 
the value '5'. What if the value '5' occurs more than once?


brian

In my script the value of  5 will not reoccur the numbers are number of 
days from 0 up to 30 days.


Thanks for the function
---End Message---
---BeginMessage---
On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote:
 Richard Kurth wrote:
 $Campaign_array| = array('0','1','3','5','8','15','25');|
 I know that I can find the next recored in a array using next. What I do 
 not understand is if I know the last number was say 5 how do I tell the 
 script that that is the current number so I can select the next  record
 ||

 I think you'll need your own function for this.

Nope. Just use array_search().

$k = array_search('5',$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

 Pass in the array and loop 
 through it until you find the key, increment that, ensure that there is 
 another value with that key, and return the key (or the value).

 (untested)

 function nextInArray($arr, $val)
 {
   $next_key = NULL;

   for ($i = 0; $i  sizeof($arr);$i++)
   {
   if ($arr[$i] == $val)
   {
   $next_key = ++$i;
   break;
   }
   }

   // return the key:
   return (array_key_exists($next_key) ? $next_key : NULL);

   // or the value:
   return (array_key_exists($next_key) ? $arr[$next_key] : NULL);

 }

 However, in your example, you're searching for the key that points to the 
 value '5'. What if the value '5' occurs more than once?

From the docs:

If needle is found in haystack more than once, the first matching key
is returned. To return the keys for all matching values, use
array_keys() with the optional search_value parameter instead.

-- 
Now what liberty can there be where property is taken without consent??
--  Samuel Adams
Rick Pasotto[EMAIL PROTECTED]

Re: [PHP] Finding next recored in a array

2007-09-17 Thread M. Sokolewicz

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 06:04:45PM -0700, Richard Kurth wrote:

Richard Kurth wrote:

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote:
 

Richard Kurth wrote:
   

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I 
do not understand is if I know the last number was say 5 how do I tell 
the script that that is the current number so I can select the next  
record

||
  

I think you'll need your own function for this.


Nope. Just use array_search().

$k = array_search('5',$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

  

I tried this and it gives me nothing back. It should give me a 8

$Campaign_array= array('0','1','3','5','8','15','25');
$val=5;

$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

I figured out way it was not working  $k + 1  count  needed to be $k + 1  
count


Yup. Sorry 'bout that.


But now it works perfect




if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

is very over-the-top. What's wrong with
if (isset($Campaign_array[$k+1]) { echo $Campaign_array[$k + 1]; }

Not to mention I don't really like the whole way this has been handled, 
I'm sure there are better ways, but for this we'd need to know more 
about what you're doing and what you're trying to achieve, which we 
obviously don't.


- Tul

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



Re: [PHP] Configure mail to use Gmail smtp

2007-09-17 Thread dcastillo
the only possible problem is that with Gmail you cant send too many mails at
once, more than 30 or so and it gives you an error .  so if you are going to
be doing mass mailing you may not be able to use it.
- Original Message - 
From: Thomas Bachmann [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Sunday, September 16, 2007 12:39 PM
Subject: Re: [PHP] Configure mail to use Gmail smtp


 ZF rocks ;)

 debussy007 schrieb:
  I succeeded using the Zend Framework.
 
 
 
  debussy007 wrote:
  Hello,
 
  I have read here : http://www.geekzone.co.nz/tonyhughes/599
  that I can use Gmail as a free SMTP server.
 
  Is it possible to change the php.ini in order to have this running ?
 
  I need to specify in some way the following :
 
  Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use
  authentication)
  Use Authentication: Yes
  Use STARTTLS: Yes (some clients call this SSL)
  Port: 465 or 587
  Account Name: your Gmail username (including '@gmail.com')
  Email Address: your original isp address ([EMAIL PROTECTED])
  Password: your Gmail password
 
 
 
  I can see in the php.ini that I can specify the port, smtp server and
the
  from.
 
  But how do I do for he other parameters ?
 
  Thank you !!
 
 

 -- 
 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] Configure mail to use Gmail smtp

2007-09-17 Thread dcastillo
what do you mean using the zend framework.  What did you do exactly?
- Original Message - 
From: debussy007 [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Sunday, September 16, 2007 12:24 PM
Subject: Re: [PHP] Configure mail to use Gmail smtp



 I succeeded using the Zend Framework.



 debussy007 wrote:
 
  Hello,
 
  I have read here : http://www.geekzone.co.nz/tonyhughes/599
  that I can use Gmail as a free SMTP server.
 
  Is it possible to change the php.ini in order to have this running ?
 
  I need to specify in some way the following :
 
  Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use
  authentication)
  Use Authentication: Yes
  Use STARTTLS: Yes (some clients call this SSL)
  Port: 465 or 587
  Account Name: your Gmail username (including '@gmail.com')
  Email Address: your original isp address ([EMAIL PROTECTED])
  Password: your Gmail password
 
 
 
  I can see in the php.ini that I can specify the port, smtp server and
the
  from.
 
  But how do I do for he other parameters ?
 
  Thank you !!
 

 -- 
 View this message in context:
http://www.nabble.com/Configure-mail-to-use-Gmail-smtp-tf4450311.html#a12698490
 Sent from the PHP - General mailing list archive at Nabble.com.

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


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




Re: [PHP] Parsing Poor XML into to PHP

2007-09-17 Thread Gavin M. Roy
I'm not sure, but perhaps tidy can fix the broken elements of the xml
file... I don't remember if it will close your quotes or just drop the
element from the tag.

On 9/17/07, John Taylor-Johnston [EMAIL PROTECTED] wrote:

 Pour examples of xml, but this is what I want to do. I have a quiz.

 BASICALLY How do EXTRACT THE Contents and Values of these tags into
 strings and arrays I can work with.

 Depending upon the students answer, compared to the criterion below, I
 need to calculate a value = x/1. The score could very well be rounded
 down to 1/1, but at least each student will get the feedback, if a
 particular piece of feedback applies to the, If not, it will not appear
 on their evaluation sheet.
 I can pseudo cod ehtis in my head, but am wondering where to get
 started. Can someone help me take Instructions/Instrudtions into a
 string for example?
 Then take Criterion[0] through nmax = [5] into two arrays:
 CriterionValue and CriterionComment, as well as feedback 0=5 and
 organised the into arrays.

 The rest, I think I can do.

 John

 InstructionsTake the sentence below and transform it into a
 Information Question./Instructions
 QuestionHarry Potter went to Hogwarts School of Wizardry./Question
 AnswerWhere did Harry Potter go? /Answer



 Criterion name=Criterion[0] value=1Where did Harry Potter go to
 school?Criterion
 FeedbackThe answer was the exact answer we expected.)/Feedback
 Criterion name=Criterion[1] value=.9Where did Harry Potter go to
 school ?Criterion
 FeedbackThere was a syntax error using the ? question
 mark.)/Feedback
 Criterion name=Criterion[2] value=.2Where Criterion
 FeedbackThe answer contained the correct Question word.
 $Criterion[2]./Feedback
 Criterion name=Criterion[3] value=.2Where didCriterion
 FeedbackThe answer contained in $Criterion[3]./Feedback
 Criterion name=Criterion[4] value=.2Where did HarryCriterion
 FeedbackThe answer contained in $Criterion[4]./Feedback
 Criterion name=Criterion[5] value=.2Where did Harry goCriterion
 FeedbackThe answer contained in $Criterion[5]./Feedback



 Unforgivable stuff:



 Criterion name=Criterion[6] value=-.2Hogwarts School of
 WizardryCriterion

 FeedbackNo need to include the complement in a question that requires
 a complement./Feedback

 Criterion name=Criterion[7] value=-.2go at schoolCriterion

 FeedbackGo to school not go at school/Feedback








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




[PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Rodolfo De Nadai

Hi all...

I'm facing a serious problem with my application. I have a script write
in PHP that starts in Internet Explorer, this script keep on running
until a varible value change on my MySQL database.
The problem is that when i restart Apache, the process child initalized
isn't kill... then the apache can't be start because the script is use
the port 80.

To solve my problem, without change anything, the best would be that
when i execute the script, it run on other port than the default 80...
so this way apache could start...
The is a way to redirect through php, so the script run on a diferent
port?? Like change some line, or add on php.ini files?? or even in
programming??

thanks ... for any info

--
* Rodolfo De Nadai *
* Analista de Sistema Jr. - Desenvolvimento *




*Informática de Municípios Associados S.A.*
Seu governo mais inteligente
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  -
www.ima.sp.gov.br http://www.ima.sp.gov.br/
Fone: (19) 3739-6000 / Ramal: 1307

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



RE: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Edward Kay
 I'm facing a serious problem with my application. I have a script write
 in PHP that starts in Internet Explorer, this script keep on running
 until a varible value change on my MySQL database.
 The problem is that when i restart Apache, the process child initalized
 isn't kill... then the apache can't be start because the script is use
 the port 80.

 To solve my problem, without change anything, the best would be that
 when i execute the script, it run on other port than the default 80...
 so this way apache could start...
 The is a way to redirect through php, so the script run on a diferent
 port?? Like change some line, or add on php.ini files?? or even in
 programming??

The TCP port used is configured by Apache. You can't change this in PHP. In
any case, I very much doubt it would solve your problem since it will still
be blocking on whatever port you use.

To resolve this issue, you need to work on why IE is holding the connection
open. Perhaps a better solution is to simply have the client poll a PHP
script to determine when desired condtion occurs.

Edward

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



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Rodolfo De Nadai
Edward , my best guess is that not IE is holding the connection but the 
apache user... because the process is related to the apache user... and 
there's more i can close IE, bacause i use the directive 2 log.log  on 
the call of system.

Example:
system(php myscript.php 2 log.log );
This why IE will not wait until the script is finish...

One thing i can't understand is why this child process of the apache 
user is not killed when i restart apache... that's the real deal...


thanks

Edward Kay escreveu:

I'm facing a serious problem with my application. I have a script write
in PHP that starts in Internet Explorer, this script keep on running
until a varible value change on my MySQL database.
The problem is that when i restart Apache, the process child initalized
isn't kill... then the apache can't be start because the script is use
the port 80.

To solve my problem, without change anything, the best would be that
when i execute the script, it run on other port than the default 80...
so this way apache could start...
The is a way to redirect through php, so the script run on a diferent
port?? Like change some line, or add on php.ini files?? or even in
programming??



The TCP port used is configured by Apache. You can't change this in PHP. In
any case, I very much doubt it would solve your problem since it will still
be blocking on whatever port you use.

To resolve this issue, you need to work on why IE is holding the connection
open. Perhaps a better solution is to simply have the client poll a PHP
script to determine when desired condtion occurs.

Edward



  


--
* Rodolfo De Nadai *
* Analista de Sistema Jr. - Desenvolvimento *




*Informática de Municípios Associados S.A.*
Seu governo mais inteligente
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  - 
www.ima.sp.gov.br http://www.ima.sp.gov.br/
Fone: (19) 3739-6000 / Ramal: 1307 


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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread tedd

Richard Kurth wrote:


$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What 
I do not understand is if I know the last number was say 5 how do I 
tell the script that that is the current number so I can select the 
next  record


What the next record?

Try:

$array = array('0','1','3','5','8','15','25');
$val = 5;

echo($array[array_search($val, $array)+1]);

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] Finding next recored in a array

2007-09-17 Thread brian

tedd wrote:

Richard Kurth wrote:


$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I 
do not understand is if I know the last number was say 5 how do I tell 
the script that that is the current number so I can select the next  
record



What the next record?

Try:

$array = array('0','1','3','5','8','15','25');
$val = 5;

echo($array[array_search($val, $array)+1]);

Cheers,

tedd


Not quite:

$array = array('0','1','3','5','8','15','25');
$val = 25;

echo($array[array_search($val, $array)+1]);

Notice: Undefined offset: 7 ...

brian

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



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Rodolfo De Nadai
Jim, i've already look for pcntl... but the support server guys, tell me 
that they can't install php modules that are not pre-compiled... so, 
pcntl is not an alternative...


I think you are right... i have to make this script a daemon... but how 
can i do that with php??... the problem is that this daemon should be 
started in web interface... see the problem...???


thanks

Jim Lucas escreveu:

Rodolfo De Nadai wrote:
Edward , my best guess is that not IE is holding the connection but 
the apache user... because the process is related to the apache 
user... and there's more i can close IE, bacause i use the directive 
2 log.log  on the call of system.

Example:
system(php myscript.php 2 log.log );
This why IE will not wait until the script is finish...

One thing i can't understand is why this child process of the apache 
user is not killed when i restart apache... that's the real deal...


thanks



This doesn't actually start a new process of PHP seperate from 
Apache.  What you are doing is starting a child process of the child 
process or the root process of Apache.


What you might want to look in to is 
http://us2.php.net/manual/en/ref.pcntl.php


This will help you fork your processes, but I think you are still 
going to run into the same problem even if you fork it within the php 
process of apache.


What you are probably going to need to do is create your own custom 
script that will act as a daemon, and replace apache altogether.


This way it is completely separate from apache.  It can run on its own 
port and only answer to you.




--
* Rodolfo De Nadai *
* Analista de Sistema Jr. - Desenvolvimento *




*Informática de Municípios Associados S.A.*
Seu governo mais inteligente
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  - 
www.ima.sp.gov.br http://www.ima.sp.gov.br/
Fone: (19) 3739-6000 / Ramal: 1307 


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



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Jim Lucas

Rodolfo De Nadai wrote:
Edward , my best guess is that not IE is holding the connection but the 
apache user... because the process is related to the apache user... and 
there's more i can close IE, bacause i use the directive 2 log.log  on 
the call of system.

Example:
system(php myscript.php 2 log.log );
This why IE will not wait until the script is finish...

One thing i can't understand is why this child process of the apache 
user is not killed when i restart apache... that's the real deal...


thanks



This doesn't actually start a new process of PHP seperate from Apache.  What you are doing is 
starting a child process of the child process or the root process of Apache.


What you might want to look in to is http://us2.php.net/manual/en/ref.pcntl.php

This will help you fork your processes, but I think you are still going to run into the same problem 
even if you fork it within the php process of apache.


What you are probably going to need to do is create your own custom script that will act as a 
daemon, and replace apache altogether.


This way it is completely separate from apache.  It can run on its own port and 
only answer to you.

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Rodolfo De Nadai
No... it not should only run when i'm connected to it throught a web 
server...
it means that when i go to specific IE page and press a button named 
'Enable' the daemon should be called and start to run indefinitly, and 
i'm able to close IE session and the daemon keep working as well...


That's what i mean...


Jim Lucas escreveu:

Rodolfo De Nadai wrote:
Jim, i've already look for pcntl... but the support server guys, tell 
me that they can't install php modules that are not pre-compiled... 
so, pcntl is not an alternative...




Bummer, get new support server guys...   no, but really

I think you are right... i have to make this script a daemon... but 
how can i do that with php??... the problem is that this daemon 
should be started in web interface... see the problem...???


Well, both windows and *nix have ways of running different apps as a 
daemon.


I actually wrote a little daemon that listens for UDP connections on a 
given port and takes care of all incoming connections.


What do you mean should be started in web interface ?  Does this 
mean that it should only be running when you connect to it with a web 
browser?




thanks


np



--
* Rodolfo De Nadai *
* Analista de Sistema Jr. - Desenvolvimento *




*Informática de Municípios Associados S.A.*
Seu governo mais inteligente
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  - 
www.ima.sp.gov.br http://www.ima.sp.gov.br/
Fone: (19) 3739-6000 / Ramal: 1307 


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



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Jim Lucas

Rodolfo De Nadai wrote:
No... it not should only run when i'm connected to it throught a web 
server...
it means that when i go to specific IE page and press a button named 
'Enable' the daemon should be called and start to run indefinitly, and 
i'm able to close IE session and the daemon keep working as well...


That's what i mean...


Well, in that case, what you could do is have a cron job, or if on windows some form of scheduled 
task, that looks for a file that indicates that it should be running.


Then from apache, you could setup a page that has your enable button.  When submitted, it creates a 
file that indicates to the above scheduled task that it needs to run.


Then, when that scheduled task starts, it looks at the file and sees that it needs to be running, 
then it stays running.  It checks to see if it has a pid file already created. if it cannot find a 
pid file, it creates a pid file to indicate that it is running.  It checks every once in a while to 
see if the file that tells it that it needs to be running it still there, once that file goes away, 
it kills the pid file and kills itself too.


Then the scheduled jobs keeps checking...

You might find that you need to do a little refinement to this process.  But, this is where I would 
start.



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Rodolfo De Nadai
Right on the moment this process is not a option... because the project 
should end in 4 weeks... perhaps after a while i could try use this 
ideia of yours...

But right now i have to find a diferent solution...

But thanks Jim... that open new horizons...



Jim Lucas escreveu:

Rodolfo De Nadai wrote:
No... it not should only run when i'm connected to it throught a web 
server...
it means that when i go to specific IE page and press a button named 
'Enable' the daemon should be called and start to run indefinitly, 
and i'm able to close IE session and the daemon keep working as well...


That's what i mean...


Well, in that case, what you could do is have a cron job, or if on 
windows some form of scheduled task, that looks for a file that 
indicates that it should be running.


Then from apache, you could setup a page that has your enable button.  
When submitted, it creates a file that indicates to the above 
scheduled task that it needs to run.


Then, when that scheduled task starts, it looks at the file and sees 
that it needs to be running, then it stays running.  It checks to see 
if it has a pid file already created. if it cannot find a pid file, it 
creates a pid file to indicate that it is running.  It checks every 
once in a while to see if the file that tells it that it needs to be 
running it still there, once that file goes away, it kills the pid 
file and kills itself too.


Then the scheduled jobs keeps checking...

You might find that you need to do a little refinement to this 
process.  But, this is where I would start.





--
* Rodolfo De Nadai *
* Analista de Sistema Jr. - Desenvolvimento *




*Informática de Municípios Associados S.A.*
Seu governo mais inteligente
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  - 
www.ima.sp.gov.br http://www.ima.sp.gov.br/
Fone: (19) 3739-6000 / Ramal: 1307 


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



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Jim Lucas

Rodolfo De Nadai wrote:
Jim, i've already look for pcntl... but the support server guys, tell me 
that they can't install php modules that are not pre-compiled... so, 
pcntl is not an alternative...




Bummer, get new support server guys...   no, but really

I think you are right... i have to make this script a daemon... but how 
can i do that with php??... the problem is that this daemon should be 
started in web interface... see the problem...???


Well, both windows and *nix have ways of running different apps as a daemon.

I actually wrote a little daemon that listens for UDP connections on a given port and takes care of 
all incoming connections.


What do you mean should be started in web interface ?  Does this mean that it should only be 
running when you connect to it with a web browser?




thanks


np

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Jim Lucas

Richard Kurth wrote:


$query =  SELECT  day
FROMemailcampaign
where   campaign_id = '$emailcampaign'
AND member_id = '$members_id'
;
$DB_Change_Campaign_Results = safe_query($query);

while ( $row = mysql_fetch_array($DB_Change_Campaign_Results) ) {
$Campaign_array[$row['day']] = $row;
}

# At this point you have arrays as values for your $Campaign_array
# So, unless $k is an array that matches a sub array of $Campaign_array
# you're never going to get a match

$k = array_search($val,$Campaign_array);

# What is $k at this point?  An int (1, 2, 3, etc...) , string (Sunday, Monday, 
etc...)
# Before I go any further I will need to know the above information.

if ( ($k + 1)  count($Campaign_array) ) {
echo $Campaign_array[$k + 1];
}


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] PHP preg_replace help

2007-09-17 Thread Jim Lucas

Chaim Chaikin wrote:

Hello,

 


I am a beginner in PHP. I need help with the function preg_replace.

I am trying to remove the backslashes ( \ ) from a string that is submitted
by the user.

It is submitted in a form but it adds \ before the quotation marks (  ).

Will this change if I use the GET method instead of POST.

If not can you please tell me how to use preg_replace to remove the
backslashes.


Don't, use stripslashes() instead.

http://us.php.net/stripslashes

Here is a nice little hack that I use.

plaintext?php

print_r($_REQUEST);

function stripInput($ar) {
$ar = stripslashes($ar);
}
if ( get_magic_quotes_gpc() ) {
array_walk_recursive($_REQUEST, 'stripInput');
array_walk_recursive($_POST,'stripInput');
array_walk_recursive($_GET, 'stripInput');
}

print_r($_REQUEST);

?

you should see the difference
--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

M. Sokolewicz wrote:

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 06:04:45PM -0700, Richard Kurth wrote:

Richard Kurth wrote:

Rick Pasotto wrote:

On Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote:
 

Richard Kurth wrote:
  

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. 
What I do not understand is if I know the last number was say 5 
how do I tell the script that that is the current number so I 
can select the next  record

||
  

I think you'll need your own function for this.


Nope. Just use array_search().

$k = array_search('5',$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 
1]; }


  

I tried this and it gives me nothing back. It should give me a 8

$Campaign_array= array('0','1','3','5','8','15','25');
$val=5;

$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

I figured out way it was not working  $k + 1  count  needed to be 
$k + 1  count


Yup. Sorry 'bout that.


But now it works perfect




if ($k + 1  count($Campaign_array)) { echo $Campaign_array[$k + 1]; }

is very over-the-top. What's wrong with
if (isset($Campaign_array[$k+1]) { echo $Campaign_array[$k + 1]; }

Not to mention I don't really like the whole way this has been 
handled, I'm sure there are better ways, but for this we'd need to 
know more about what you're doing and what you're trying to achieve, 
which we obviously don't.
What I am trying to is get all the days from a table where email 
campaign =  number. and then look at the last day that was sent and find 
it in the list and get the next day that follows that day. At this point 
the script below is not working. So if you have any Ideas that would be 
a better way of doing this please let me know.



$query = SELECT day FROM emailcampaign where campaign_id = 
'$emailcampaign' AND member_id = '$members_id';

$DB_Change_Campaign_Results = safe_query($query);
for ($i=0; $i  mysql_num_rows($DB_Change_Campaign_Results); $i++) {
$Change_Campaign_row = mysql_fetch_array($DB_Change_Campaign_Results);
$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;
}
$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)){ echo $Campaign_array[$k + 1]; }

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



RE: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Daevid Vincent
 

 -Original Message-
 From: Rodolfo De Nadai [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 17, 2007 5:25 AM
 To: php-general@lists.php.net
 Subject: [PHP] Try to find a solution, when restart Apache 
 with PHP Script
 
 Hi all...
 
 I'm facing a serious problem with my application. I have a 
 script write
 in PHP that starts in Internet Explorer, this script keep on running
 until a varible value change on my MySQL database.
 The problem is that when i restart Apache, the process child 
 initalized
 isn't kill... then the apache can't be start because the script is use
 the port 80.
 
 To solve my problem, without change anything, the best would be that
 when i execute the script, it run on other port than the default 80...
 so this way apache could start...
 The is a way to redirect through php, so the script run on a diferent
 port?? Like change some line, or add on php.ini files?? or even in
 programming??
 
 thanks ... for any info

We do something like this, wherein sometimes we have to force a restart of
Apache, so in order to not kill the web page for the GUI, we use AJAX to
continually poll the server. Then when the server is back, we can issue a
page refresh to whatever page we want...


---8 snip
8

?php
$request_interval = 1;  // 10 seconds.
$type = intval( $_GET[ 'type' ] );
if ( 1 == $type )
{
$initial_wait = 6;  // 1 minute.
$title = translate('Rebooting Appliance');
$text = translate('This may take several minutes. If this
page does not redirect you, click A HREF=home_start_main.phphere/A.');
}
else
{
$initial_wait = 2;  // 20 seconds.
$title = translate('Rebuilding Web Certificates');
$text = translate('If this page does not redirect you in a
few seconds, click A HREF=home_start_main.phphere/A.');
}
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
HTML
HEAD
TITLE?= translate('%1$s :: Loading...', PRODUCT_fENF) ?/TITLE
META HTTP-EQUIV=Content-Type CONTENT=text/html;
LINK REL=STYLESHEET TYPE=text/css
HREF=includes/default.css?version=1
/HEAD
BODY
TABLE WIDTH=100% HEIGHT=100%
TR
TD ALIGN=center VALIGN=middle HEIGHT=100%
WIDTH=100%
TABLE BORDER=0 CLASS=componentBox
TR VALIGN=middle
TD COLSPAN=3
CLASS=tableHeadline?=$title?/TD
/TR
TR VALIGN=MIDDLE
TDIMG
SRC=images/icons/paper_time.gif/TD
TD
TABLE
TR

TD?=$text?/TD
/TR
TR
TD
ALIGN=CENTERDIV ID=status STYLE=color:gray?=
translate('Waiting...') ?/DIV/TD
/TR
/TABLE
/TD
/TR
/TABLE
/TD
/TR
/TABLE
SCRIPT LANGUAGE=JavaScript TYPE=text/javascript
!--
var xmlhttp=false;
var id, state = 0;
var initial_wait = ?=$initial_wait?;

// JScript gives us Conditional compilation, we can cope
with old IE versions.
// and security blocked creation of the objects.
try
{
xmlhttp = new ActiveXObject( Msxml2.XMLHTTP );
}
catch ( e )
{
try
{
xmlhttp = new ActiveXObject(
Microsoft.XMLHTTP );
}
catch ( E )
{
xmlhttp = false;
}
}
if ( !xmlhttp  typeof XMLHttpRequest != 'undefined' )
{
xmlhttp = new XMLHttpRequest();
}

function try_url()
{
if ( 0 == state )
{
document.getElementById( status
).innerHTML = ?= translate('Requesting page...') ?;
xmlhttp.open( HEAD, home_start_main.php,
true );
 

Re: [PHP] Finding next recored in a array

2007-09-17 Thread brian

Richard Kurth wrote:


What I am trying to is get all the days from a table where email 
campaign =  number. and then look at the last day that was sent and find 
it in the list and get the next day that follows that day. At this point 
the script below is not working. So if you have any Ideas that would be 
a better way of doing this please let me know.



$query = SELECT day FROM emailcampaign where campaign_id = 
'$emailcampaign' AND member_id = '$members_id';

$DB_Change_Campaign_Results = safe_query($query);
for ($i=0; $i  mysql_num_rows($DB_Change_Campaign_Results); $i++) {
$Change_Campaign_row = mysql_fetch_array($DB_Change_Campaign_Results);
$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;
}
$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)){ echo $Campaign_array[$k + 1]; }




You can simplify this greatly:

$Campaign_array = Array();

$DB_Change_Campaign_Results = safe_query($query);

while ($row = mysql_fetch_array($DB_Change_Campaign_Results))
{
  array_push($Campaign_array, $row['day']);
}

Because you're only selecting day from the table, your row data consists 
of only one column. You're repeating stuff unnecessarily by doing this:


$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;

IOW, for the row that contains '5', you'd end up with $Campaign_array[5] 
== an array that essentially just points to the value '5'.


I also noticed that your dump shows that the days begin with 0. If these 
are calendar days you're adding a further layer of complexity.


brian

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



[PHP] PHP preg_replace help

2007-09-17 Thread Chaim Chaikin
Hello,

 

I am a beginner in PHP. I need help with the function preg_replace.

I am trying to remove the backslashes ( \ ) from a string that is submitted
by the user.

It is submitted in a form but it adds \ before the quotation marks (  ).

Will this change if I use the GET method instead of POST.

If not can you please tell me how to use preg_replace to remove the
backslashes.

 

Thank You,

Chaim Chaikin

Novice PHP programmer

Hotwire Band Website Administrator

http://hotwire.totalh.com



Re: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Rodolfo De Nadai

Hi Daevid,
This app keep alive forever as well?
When you restart apache what happend to your app?

Daevid Vincent escreveu:
 

  

-Original Message-
From: Rodolfo De Nadai [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 17, 2007 5:25 AM

To: php-general@lists.php.net
Subject: [PHP] Try to find a solution, when restart Apache 
with PHP Script


Hi all...

I'm facing a serious problem with my application. I have a 
script write

in PHP that starts in Internet Explorer, this script keep on running
until a varible value change on my MySQL database.
The problem is that when i restart Apache, the process child 
initalized

isn't kill... then the apache can't be start because the script is use
the port 80.

To solve my problem, without change anything, the best would be that
when i execute the script, it run on other port than the default 80...
so this way apache could start...
The is a way to redirect through php, so the script run on a diferent
port?? Like change some line, or add on php.ini files?? or even in
programming??

thanks ... for any info



We do something like this, wherein sometimes we have to force a restart of
Apache, so in order to not kill the web page for the GUI, we use AJAX to
continually poll the server. Then when the server is back, we can issue a
page refresh to whatever page we want...


---8 snip
  

8



?php
$request_interval = 1;  // 10 seconds.
$type = intval( $_GET[ 'type' ] );
if ( 1 == $type )
{
$initial_wait = 6;  // 1 minute.
$title = translate('Rebooting Appliance');
$text = translate('This may take several minutes. If this
page does not redirect you, click A HREF=home_start_main.phphere/A.');
}
else
{
$initial_wait = 2;  // 20 seconds.
$title = translate('Rebuilding Web Certificates');
$text = translate('If this page does not redirect you in a
few seconds, click A HREF=home_start_main.phphere/A.');
}
?
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
HTML
HEAD
TITLE?= translate('%1$s :: Loading...', PRODUCT_fENF) ?/TITLE
META HTTP-EQUIV=Content-Type CONTENT=text/html;
LINK REL=STYLESHEET TYPE=text/css
HREF=includes/default.css?version=1
/HEAD
BODY
TABLE WIDTH=100% HEIGHT=100%
TR
TD ALIGN=center VALIGN=middle HEIGHT=100%
WIDTH=100%
TABLE BORDER=0 CLASS=componentBox
TR VALIGN=middle
TD COLSPAN=3
CLASS=tableHeadline?=$title?/TD
/TR
TR VALIGN=MIDDLE
TDIMG
SRC=images/icons/paper_time.gif/TD
TD
TABLE
TR

TD?=$text?/TD
/TR
TR
TD
ALIGN=CENTERDIV ID=status STYLE=color:gray?=
translate('Waiting...') ?/DIV/TD
/TR
/TABLE
/TD
/TR
/TABLE
/TD
/TR
/TABLE
SCRIPT LANGUAGE=JavaScript TYPE=text/javascript
!--
var xmlhttp=false;
var id, state = 0;
var initial_wait = ?=$initial_wait?;

// JScript gives us Conditional compilation, we can cope
with old IE versions.
// and security blocked creation of the objects.
try
{
xmlhttp = new ActiveXObject( Msxml2.XMLHTTP );
}
catch ( e )
{
try
{
xmlhttp = new ActiveXObject(
Microsoft.XMLHTTP );
}
catch ( E )
{
xmlhttp = false;
}
}
if ( !xmlhttp  typeof XMLHttpRequest != 'undefined' )
{
xmlhttp = new XMLHttpRequest();
}

function try_url()
{
if ( 0 == state )
{
document.getElementById( status
).innerHTML = ?= translate('Requesting 

Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

brian wrote:

Richard Kurth wrote:


What I am trying to is get all the days from a table where email 
campaign =  number. and then look at the last day that was sent and 
find it in the list and get the next day that follows that day. At 
this point the script below is not working. So if you have any Ideas 
that would be a better way of doing this please let me know.



$query = SELECT day FROM emailcampaign where campaign_id = 
'$emailcampaign' AND member_id = '$members_id';

$DB_Change_Campaign_Results = safe_query($query);
for ($i=0; $i  mysql_num_rows($DB_Change_Campaign_Results); $i++) {
$Change_Campaign_row = mysql_fetch_array($DB_Change_Campaign_Results);
$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;
}
$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)){ echo $Campaign_array[$k + 1]; }




You can simplify this greatly:

$Campaign_array = Array();

$DB_Change_Campaign_Results = safe_query($query);

while ($row = mysql_fetch_array($DB_Change_Campaign_Results))
{
  array_push($Campaign_array, $row['day']);
}

Because you're only selecting day from the table, your row data 
consists of only one column. You're repeating stuff unnecessarily by 
doing this:


$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;

IOW, for the row that contains '5', you'd end up with 
$Campaign_array[5] == an array that essentially just points to the 
value '5'.


I also noticed that your dump shows that the days begin with 0. If 
these are calendar days you're adding a further layer of complexity.




0 represents the email campain to send 0 mens send the one that gois out 
the day the campain starts. the next number in the list is the next day 
a email is sent out  would represent 5 day after the starting day


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



[PHP] PHPSESSID in links

2007-09-17 Thread Kevin Murphy
I've got a site (password protected, sorry) where I have this in the  
top of my template:


session_start();
$iSessionId = session_id();
$iSessionName = session_name();

Then I have a bunch of links like this in the site:

echo a href=\/departments/\Departments/a;

The first time, and only the first time you load the page, that link  
is transformed in the HTML output to be this:


a href=/departments/? 
PHPSESSID=4aec641b497131493b1c4bf489def723Departments/a


But if I reload the page, or go to any other page, I will get this:

a href=/departments/Departments/a

which is what I want. Obviously I could do something where if it  
detects the PHPSESSID in the URL, it forces the page to reload, but I  
was thinking that there would be another way to do this without  
adding another page load into the mix. Is there?


--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada College
www.wnc.edu
775-445-3326

P.S. Please note that my e-mail and website address have changed from  
wncc.edu to wnc.edu. 

Re: [PHP] Finding next recored in a array

2007-09-17 Thread Jim Lucas

REVISED

Try this

?php

$query =  SELECT  day
FROMemailcampaign
WHERE   campaign_id = '$emailcampaign'
AND member_id = '$members_id'
;

$DB_Change_Campaign_Results = safe_query($query);

##
## NOTICE: changed from array to assoc
##
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
## Switched to an indexed array with the day as the value instead of the key
$Campaign_array[] = $row['day'];
}

# At this point you have arrays as values for your $Campaign_array
# So, unless $k is an array that matches a sub array of $Campaign_array
# you're never going to get a match

$k = array_search($val,$Campaign_array);

# What is $k at this point?  An int (1, 2, 3, etc...) , string (Sunday, Monday, 
etc...)
# Before I go any further I will need to know the above information.
if ( isset($Campaign_array[($k + 1)])) {
echo $Campaign_array[($k + 1)];
} else {
echo 'Not found';
}


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Jim Lucas

Richard Kurth wrote:

include (includes/location.php);
$query = SELECTday
   FROMemailcampaign
   wherecampaign_id = '1'
   ANDmember_id = '8'
   ;
$DB_Change_Campaign_Results = safe_query($query);
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
  $Campaign_array[] = $row['day'];
}
if ( isset($Campaign_array[($k + 1)])) {
   echo $Campaign_array[($k + 1)];
} else {
   echo 'Not found';
}
var_dump($Campaign_array);


This is what I get now when I run this

1

*array*
 0 = string '0' /(length=1)/
 1 = string '1' /(length=1)/
 2 = string '3' /(length=1)/
 3 = string '6' /(length=1)/
 4 = string '9' /(length=1)/
 5 = string '12' /(length=2)/
 6 = string '15' /(length=2)/
 7 = string '20' /(length=2)/
 8 = string '25' /(length=2)/
 9 = string '30' /(length=2)/





Are there going to be wholes in the date range?

if so, you will have to do that last bit like this.


?php

include (includes/location.php);

#
# Setting $k
# Make sure that $k is an integer, not a string.
# hence, no quotes
$k = 5;

$query =  SELECT  day
FROMemailcampaign
WHERE   campaign_id = '1'
AND member_id = '8'
;
$DB_Change_Campaign_Results = safe_query($query);
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
$Campaign_array[] = $row['day'];
}

sort($Campaign_array);

foreach ( $Campaign_array AS $day ) {
if ( $day = $k ) {
$day = next($Campaign_array);
break;
}
}

echo $day;

var_dump($Campaign_array);

?



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



RE: [PHP] Try to find a solution, when restart Apache with PHP Script

2007-09-17 Thread Daevid Vincent
We put a timeout at the top and show an error if the server never comes
back. You could do whatever you want. As long as the user doesn't try to
refresh the page or go somewhere else on your server, the ajax will just
keep trying in the background. That's all client-side JS / AJAX. 

 -Original Message-
 From: Rodolfo De Nadai [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 17, 2007 1:00 PM
 To: Daevid Vincent
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Try to find a solution, when restart 
 Apache with PHP Script
 
 Hi Daevid,
 This app keep alive forever as well?
 When you restart apache what happend to your app?
 
 Daevid Vincent escreveu:
   
 

  -Original Message-
  From: Rodolfo De Nadai [mailto:[EMAIL PROTECTED] 
  Sent: Monday, September 17, 2007 5:25 AM
  To: php-general@lists.php.net
  Subject: [PHP] Try to find a solution, when restart Apache 
  with PHP Script
 
  Hi all...
 
  I'm facing a serious problem with my application. I have a 
  script write
  in PHP that starts in Internet Explorer, this script keep 
 on running
  until a varible value change on my MySQL database.
  The problem is that when i restart Apache, the process child 
  initalized
  isn't kill... then the apache can't be start because the 
 script is use
  the port 80.
 
  To solve my problem, without change anything, the best 
 would be that
  when i execute the script, it run on other port than the 
 default 80...
  so this way apache could start...
  The is a way to redirect through php, so the script run on 
 a diferent
  port?? Like change some line, or add on php.ini files?? or even in
  programming??
 
  thanks ... for any info
  
 
  We do something like this, wherein sometimes we have to 
 force a restart of
  Apache, so in order to not kill the web page for the GUI, 
 we use AJAX to
  continually poll the server. Then when the server is back, 
 we can issue a
  page refresh to whatever page we want...
 
 
  ---8 snip

  8
  
 
  ?php
  $request_interval = 1;  // 10 seconds.
  $type = intval( $_GET[ 'type' ] );
  if ( 1 == $type )
  {
  $initial_wait = 6;  // 1 minute.
  $title = translate('Rebooting Appliance');
  $text = translate('This may take several 
 minutes. If this
  page does not redirect you, click A 
 HREF=home_start_main.phphere/A.');
  }
  else
  {
  $initial_wait = 2;  // 20 seconds.
  $title = translate('Rebuilding Web Certificates');
  $text = translate('If this page does not 
 redirect you in a
  few seconds, click A HREF=home_start_main.phphere/A.');
  }
  ?
  !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  HTML
  HEAD
  TITLE?= translate('%1$s :: Loading...', 
 PRODUCT_fENF) ?/TITLE
  META HTTP-EQUIV=Content-Type CONTENT=text/html;
  LINK REL=STYLESHEET TYPE=text/css
  HREF=includes/default.css?version=1
  /HEAD
  BODY
  TABLE WIDTH=100% HEIGHT=100%
  TR
  TD ALIGN=center VALIGN=middle HEIGHT=100%
  WIDTH=100%
  TABLE BORDER=0 CLASS=componentBox
  TR VALIGN=middle
  TD COLSPAN=3
  CLASS=tableHeadline?=$title?/TD
  /TR
  TR VALIGN=MIDDLE
  TDIMG
  SRC=images/icons/paper_time.gif/TD
  TD
  TABLE
  TR
  
  TD?=$text?/TD
  /TR
  TR
  
   TD
  ALIGN=CENTERDIV ID=status STYLE=color:gray?=
  translate('Waiting...') ?/DIV/TD
  /TR
  /TABLE
  /TD
  /TR
  /TABLE
  /TD
  /TR
  /TABLE
  SCRIPT LANGUAGE=JavaScript TYPE=text/javascript
  !--
  var xmlhttp=false;
  var id, state = 0;
  var initial_wait = ?=$initial_wait?;
 
  // JScript gives us Conditional compilation, we can cope
  with old IE versions.
  // and security blocked creation of the objects.
  try
  {
  xmlhttp = new ActiveXObject( Msxml2.XMLHTTP );
  }
  catch ( e )
  {
  try
  {
  xmlhttp = new ActiveXObject(
  Microsoft.XMLHTTP );
 

[PHP] back-button question

2007-09-17 Thread Πρεκατές Αλέξανδρος
I'a writing first time so sorry if i reapeat but
i wanted to say this in my own words and angle.

My question is : 
   
Lets assume that we'r going throught  php/html files
  
a- b -- c 
||


1)From a to b through a link

2)from b to c through a submit button (post method)

3) c is a php script which does some mysql queries and changes
some session variables and outputs a location header to 
return to b.


While back in b we press the back button
when back button is pressed 
my icewiesel browser gets me to 'a'  page.

Trying to find some sense i postulated
that a browser holds in its history (for back/forward)
only requests made explicitly by the user and not the ones
made from withing php files (with header commands) .
Is my theory right..

I'm searching in the broader context of trying to control
how my bookstore website will react to random events from 
the user (back/forward, links etc) while in a middle of 
a series of php files that i want to act as a transaction.


Any help- recommendations  for study on the subject would be very
welcomed. I have 3 books on mysql/php but that issues
r not examined,



Prekates Alexandros
Trikala Greece

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



Re: [PHP] PHP preg_replace help

2007-09-17 Thread Arpad Ray

Jim Lucas wrote:

Here is a nice little hack that I use.



Little hack it is, nice it isn't.
Ideally just turn off magic_quotes_gpc - you can do so in php.ini, or 
perhaps your web server configuration files (httpd.conf, .htaccess etc.).


If you don't have access to any of the above then install the latest 
version of PHP_Compat (http://pear.php.net/package/PHP_Compat) and 
include 'PHP/Compat/Environment/magic_quotes_gpc_off.php'. Reversing the 
effects of magic_quotes_gpc at runtime is far from trivial, there's lots 
of potential for subtle bugs, let alone completely forgetting about 
$_COOKIE.


If you're unable to install PHP_Compat, you can grab the relevant files 
from CVS:

http://cvs.php.net/viewvc.cgi/pear/PHP_Compat/Compat/Environment/_magic_quotes_inputs.php?revision=1.3view=markup
http://cvs.php.net/viewvc.cgi/pear/PHP_Compat/Compat/Environment/magic_quotes_gpc_off.php?revision=1.7view=markup

Arpad

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



Re: [PHP] PHPSESSID in links

2007-09-17 Thread Stut

Kevin Murphy wrote:
I've got a site (password protected, sorry) where I have this in the top 
of my template:


session_start();
$iSessionId = session_id();
$iSessionName = session_name();

Then I have a bunch of links like this in the site:

echo a href=\/departments/\Departments/a;

The first time, and only the first time you load the page, that link is 
transformed in the HTML output to be this:


a 
href=/departments/?PHPSESSID=4aec641b497131493b1c4bf489def723Departments/a 



But if I reload the page, or go to any other page, I will get this:

a href=/departments/Departments/a

which is what I want. Obviously I could do something where if it detects 
the PHPSESSID in the URL, it forces the page to reload, but I was 
thinking that there would be another way to do this without adding 
another page load into the mix. Is there?


These are caused by the php.ini setting session.use_trans_sid being on. 
This setting allows sessions to work when cookies are disabled.


http://php.net/ref.session#ini.session.use-trans-sid

I'm not sure why you have such a problem with it. Why is it important 
that the URL does not contain the session ID?


Anyway, the way to fix it is to disable that php.ini setting.

-Stut

--
http://stut.net/

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread M. Sokolewicz

Richard Kurth wrote:
What I am trying to is get all the days from a table where email 
campaign =  number. and then look at the last day that was sent and find 
it in the list and get the next day that follows that day. At this point 
the script below is not working. So if you have any Ideas that would be 
a better way of doing this please let me know.



$query = SELECT day FROM emailcampaign where campaign_id = 
'$emailcampaign' AND member_id = '$members_id';

$DB_Change_Campaign_Results = safe_query($query);
for ($i=0; $i  mysql_num_rows($DB_Change_Campaign_Results); $i++) {
$Change_Campaign_row = mysql_fetch_array($DB_Change_Campaign_Results);
$Campaign = $Change_Campaign_row['day'];
$Campaign_array[$Campaign] = $Change_Campaign_row;
}
$k = array_search($val,$Campaign_array);
if ($k + 1  count($Campaign_array)){ echo $Campaign_array[$k + 1]; }


Ok, so just to recap (because I'm very confused now, even more after the 
many tries on the list since):
You have table in your database called 'emailcampaign'. This table has a 
column called 'day'.
Now, your table holds 1 row per campaign and the 'day' column 
signifies when the last mail has been sent.


-- am I correct on this so far ? --

Next, you have an array which contains a FIXED collection of days on 
which an email should be sent, which looks like so:

$days_to_send_email_on = array('0','1','3','5','8','15','25');

-- am I correct on this so far [2] ? --

You know the 'day' the last mail was sent, and you wish to check your 
FIXED array to find out when the next email should be sent.


-- am I correct on this so far [3] ? --

If so, then there are a few things I'm wondering:
1. How did you come up with that fixed array? Is it the result of some 
kind of calculation?

  1.1 If so, it'd be easier to solve it the mathematical way.
  1.2 If #1 is a random result (ie. user-input, or different), then 
how about storing it in a table and doing:

SELECT day WHERE day  $last_day_it_was_sent_on ORDER BY day ASC LIMIT 1

2. Actually, that's all I'm wondering :)

- Tul

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

Jim Lucas wrote:

Richard Kurth wrote:


$query = SELECTday
FROMemailcampaign
wherecampaign_id = '$emailcampaign'
ANDmember_id = '$members_id'
;
$DB_Change_Campaign_Results = safe_query($query);

while ( $row = mysql_fetch_array($DB_Change_Campaign_Results) ) {
$Campaign_array[$row['day']] = $row;
}

# At this point you have arrays as values for your $Campaign_array
# So, unless $k is an array that matches a sub array of $Campaign_array
# you're never going to get a match

$k = array_search($val,$Campaign_array);

# What is $k at this point?  An int (1, 2, 3, etc...) , string 
(Sunday, Monday, etc...)

# Before I go any further I will need to know the above information.

if ( ($k + 1)  count($Campaign_array) ) {
echo $Campaign_array[$k + 1];
}



This is what I get if I run the above script.
From a var_dump($Campaign_array); I get

*array*
 0 = 
   *array*

 0 = string '0' /(length=1)/
 'day' = string '0' /(length=1)/
 1 = 
   *array*

 0 = string '1' /(length=1)/
 'day' = string '1' /(length=1)/
 3 = 
   *array*

 0 = string '3' /(length=1)/
 'day' = string '3' /(length=1)/
 6 = 
   *array*

 0 = string '6' /(length=1)/
 'day' = string '6' /(length=1)/
 9 = 
   *array*

 0 = string '9' /(length=1)/
 'day' = string '9' /(length=1)/
 12 = 
   *array*

 0 = string '12' /(length=2)/
 'day' = string '12' /(length=2)/
 15 = 
   *array*

 0 = string '15' /(length=2)/
 'day' = string '15' /(length=2)/
 20 = 
   *array*

 0 = string '20' /(length=2)/
 'day' = string '20' /(length=2)/
 25 = 
   *array*

 0 = string '25' /(length=2)/
 'day' = string '25' /(length=2)/
 30 = 



   *array*
 0 = string '30' /(length=2)/
 'day' = string '30' /(length=2)/

From a $val=5;
$k = array_search($val,$Campaign_array);
var_dump($k); I get

boolean false

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



Re: [PHP] Finding next recored in a array

2007-09-17 Thread Richard Kurth

Jim Lucas wrote:

REVISED

Try this

?php

$query = SELECTday
FROMemailcampaign
WHEREcampaign_id = '$emailcampaign'
ANDmember_id = '$members_id'
;

$DB_Change_Campaign_Results = safe_query($query);

##
## NOTICE: changed from array to assoc
##
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
## Switched to an indexed array with the day as the value instead of 
the key

$Campaign_array[] = $row['day'];
}

# At this point you have arrays as values for your $Campaign_array
# So, unless $k is an array that matches a sub array of $Campaign_array
# you're never going to get a match

$k = array_search($val,$Campaign_array);

# What is $k at this point?  An int (1, 2, 3, etc...) , string 
(Sunday, Monday, etc...)

# Before I go any further I will need to know the above information.
if ( isset($Campaign_array[($k + 1)])) {
echo $Campaign_array[($k + 1)];
} else {
echo 'Not found';
}



include (includes/location.php);
$query = SELECTday
   FROMemailcampaign
   wherecampaign_id = '1'
   ANDmember_id = '8'
   ;
$DB_Change_Campaign_Results = safe_query($query);
$Campaign_array = array();
while ( $row = mysql_fetch_assoc($DB_Change_Campaign_Results) ) {
  $Campaign_array[] = $row['day'];
}
if ( isset($Campaign_array[($k + 1)])) {
   echo $Campaign_array[($k + 1)];
} else {
   echo 'Not found';
}
var_dump($Campaign_array);


This is what I get now when I run this

1

*array*
 0 = string '0' /(length=1)/
 1 = string '1' /(length=1)/
 2 = string '3' /(length=1)/
 3 = string '6' /(length=1)/
 4 = string '9' /(length=1)/
 5 = string '12' /(length=2)/
 6 = string '15' /(length=2)/
 7 = string '20' /(length=2)/
 8 = string '25' /(length=2)/
 9 = string '30' /(length=2)/

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



Re: [PHP] back-button question

2007-09-17 Thread Eric Butera
On 9/17/07, Πρεκατές Αλέξανδρος [EMAIL PROTECTED] wrote:
 I'a writing first time so sorry if i reapeat but
 i wanted to say this in my own words and angle.

 My question is :

 Lets assume that we'r going throught  php/html files

 a- b -- c
 ||


 1)From a to b through a link

 2)from b to c through a submit button (post method)

 3) c is a php script which does some mysql queries and changes
 some session variables and outputs a location header to
 return to b.


 While back in b we press the back button
 when back button is pressed
 my icewiesel browser gets me to 'a'  page.

 Trying to find some sense i postulated
 that a browser holds in its history (for back/forward)
 only requests made explicitly by the user and not the ones
 made from withing php files (with header commands) .
 Is my theory right..

 I'm searching in the broader context of trying to control
 how my bookstore website will react to random events from
 the user (back/forward, links etc) while in a middle of
 a series of php files that i want to act as a transaction.


 Any help- recommendations  for study on the subject would be very
 welcomed. I have 3 books on mysql/php but that issues
 r not examined,



 Prekates Alexandros
 Trikala Greece

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



Browsers will not store a page that contains a header redirect in the
history.  In fact what you're talking about even has a name for it:
http://en.wikipedia.org/wiki/Post/Redirect/Get


Re: [PHP] dir_object-read() on different platform

2007-09-17 Thread Jim Lucas

news.php.net wrote:

Hi! I have some text and JPEG files inside a directory like:
1992-7-11.txt
1992-7-11_pic1.jpg
2000-4-10.txt
2000-4-10_pic1.jpg
2004-5-2.txt
2004-5-2_pic1.jpg
On a Windows box (XP + Apache), if I do a dir_object-read() for the 
directory, read() reads the files above in order (eg. 
1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on these 
files are different.
However, after I ftp them to a Linux box and load the php script from the 
Linux box, the order is gone. The time stamps on those files on the Linux 
box are the same since they were all ftp and cp at the same time.

Does anyone know why? Can anyone suggest a simple solution?

Thanks.
Davis 


Use glob() instead and then use sort() on the returned array.

That should put things back in order

?php

$ar = glob('/dir/');
sort($ar);

# This should display the files in order
foreach ( $ar AS $file ) {
echo $file;
}

?

Hope that helps

Jim

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



[PHP] dir_object-read() on different platform

2007-09-17 Thread news.php.net
Hi! I have some text and JPEG files inside a directory like:
1992-7-11.txt
1992-7-11_pic1.jpg
2000-4-10.txt
2000-4-10_pic1.jpg
2004-5-2.txt
2004-5-2_pic1.jpg
On a Windows box (XP + Apache), if I do a dir_object-read() for the 
directory, read() reads the files above in order (eg. 
1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on these 
files are different.
However, after I ftp them to a Linux box and load the php script from the 
Linux box, the order is gone. The time stamps on those files on the Linux 
box are the same since they were all ftp and cp at the same time.
Does anyone know why? Can anyone suggest a simple solution?

Thanks.
Davis 

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



Re: [PHP] dir_object-read() on different platform

2007-09-17 Thread Jim Lucas

Jim Lucas wrote:

news.php.net wrote:

Hi! I have some text and JPEG files inside a directory like:
1992-7-11.txt
1992-7-11_pic1.jpg
2000-4-10.txt
2000-4-10_pic1.jpg
2004-5-2.txt
2004-5-2_pic1.jpg
On a Windows box (XP + Apache), if I do a dir_object-read() for the 
directory, read() reads the files above in order (eg. 
1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on 
these files are different.
However, after I ftp them to a Linux box and load the php script from 
the Linux box, the order is gone. The time stamps on those files on 
the Linux box are the same since they were all ftp and cp at the same 
time.

Does anyone know why? Can anyone suggest a simple solution?

Thanks.
Davis

Use glob() instead and then use sort() on the returned array.

That should put things back in order

?php

$ar = glob('/dir/');
sort($ar);

# This should display the files in order
foreach ( $ar AS $file ) {
echo $file;
}

?

Hope that helps

Jim


forgot, you might need to use the extension, like so.
glob('/path/to/files/*.txt');

glob() does recognize '*'  '?' as multi  single char replacements.

Jim

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



Re: [PHP] dir_object-read() on different platform

2007-09-17 Thread Jim Lucas

news.php.net wrote:

Hi! I have some text and JPEG files inside a directory like:
1992-7-11.txt
1992-7-11_pic1.jpg
2000-4-10.txt
2000-4-10_pic1.jpg
2004-5-2.txt
2004-5-2_pic1.jpg
On a Windows box (XP + Apache), if I do a dir_object-read() for the 
directory, read() reads the files above in order (eg. 
1992-7-11.txt...2000-4-10.txt...2004-5-2.txt) even the time stamps on these 
files are different.
However, after I ftp them to a Linux box and load the php script from the 
Linux box, the order is gone. The time stamps on those files on the Linux 
box are the same since they were all ftp and cp at the same time.

Does anyone know why? Can anyone suggest a simple solution?

Thanks.
Davis 

but, to explain why it happens, it going to be like describing the 
differences between *nix and windows.


Simply put, internally, they store file information differently and by 
doing this differently, they display the file list differently.


Also, *nix file names are case sensitive and windows is not.  Be careful 
with this one, it will bite you at some point.


Jim

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