[PHP] code generation

2005-08-04 Thread Johan Grobler
is there a way to limit the time a website is available in php?, if you want to 
have a database driven website but you would only like it to be active for 6 
months for instance, i'm doing a project at univirsity and this is part of the 
specs, but i cant think of a good way how to do it...

Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Peninsula University of
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



RE: [PHP] Regex help

2005-08-04 Thread Lizet Pena de Sola
Ok, it's not the regexp for detecting email addresses what I need,
that's widely published, thanks. I'm using ereg to match this regular
expression:

(On)[\s\w\d\W\S\D\n]*(wr[i|o]te[s]?:)

That will match phrases like
On 8/3/05, Carol Swinehart [EMAIL PROTECTED] wrote:
the type On date, name email wrote or writes:

The thing is I tried this regexp with Regex Coach and it matches fine,
but ereg returns no match

ereg($regexpstr, $str, $regs)

I know there are some comments at php.net about how ereg has some bugs,
any idea if this could be one?

Tia, 
Lizet
-Original Message-
From: Marcus Bointon [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 03, 2005 8:57 AM
To: PHP General
Subject: Re: [PHP] Regex help

On 2 Aug 2005, at 15:12, Robin Vickery wrote:

 I don't suppose this is the place for a rant about the futility of
 checking email addresses with a regexp?

Though I will agree with you to some extent, I've had quite a lot of  
success with this, which is pretty thorough:

^(?:[\w\!\#\$\%\\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\\'\*\+\- 
\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61} 
[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)| 
(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4] 
\d|25[0-5])\]))$

Which I got from here:

http://www.hexillion.com/samples/#Regex

Marcus
-- 
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

-- 
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] code generation

2005-08-04 Thread Ligaya Turmelle
Maybe have a cron job that deletes/changes perms to make inaccessible 
the script after the given date.


Johan Grobler wrote:


is there a way to limit the time a website is available in php?, if you want to 
have a database driven website but you would only like it to be active for 6 
months for instance, i'm doing a project at univirsity and this is part of the 
specs, but i cant think of a good way how to do it...

Disclaimer 
This e-mail transmission contains confidential information,

which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Peninsula University of 
Technology or the sender of this e-mail be liable to any party for

any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911




--
Respectfully,
Ligaya Turmelle

Life is a game so have fun

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

Re: [PHP] code generation

2005-08-04 Thread sub
Couldn't you use a date check with date()?

if(todays date  end date)
{
load the site
}
else
{
the site has expired
}

Andrew Darrow
Kronos1 Productions
www.pudlz.com


- Original Message - 
From: Johan Grobler [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Wednesday, August 03, 2005 11:04 PM
Subject: [PHP] code generation


is there a way to limit the time a website is available in php?, if you want
to have a database driven website but you would only like it to be active
for 6 months for instance, i'm doing a project at univirsity and this is
part of the specs, but i cant think of a good way how to do it...

Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Peninsula University of
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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





-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005

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



Re: [PHP] code generation

2005-08-04 Thread Jochem Maas

btw - what has 'code generation' got to do with the question?
a oneliner to check 2 dates is not considered code generation -
I'd call it 'writing a oneliner' or something similiar :-)

[EMAIL PROTECTED] wrote:

Couldn't you use a date check with date()?

if(todays date  end date)
{
load the site
}
else
{
the site has expired
}



indeed, also checkout time(), mktime(), strtotime() etc.
also ...

if ($timeIsUp) {
// delete site files
exit;
}

// show the site...


Andrew Darrow
Kronos1 Productions
www.pudlz.com


- Original Message - 
From: Johan Grobler [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, August 03, 2005 11:04 PM
Subject: [PHP] code generation


is there a way to limit the time a website is available in php?, if you want
to have a database driven website but you would only like it to be active
for 6 months for instance, i'm doing a project at univirsity and this is
part of the specs, but i cant think of a good way how to do it...

Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Peninsula University of
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911



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



[PHP] The Naming of Directories

2005-08-04 Thread Tom Chubb
This may be slightly OT, but I've modified a gallery script that I had
written for me which reads directories and echos the dir name as a
gallery.
Unfortunately, it doesn't look very nice with say picsofsomething so I
renamed the folder 'pics of something'
When this is read, the string inserts %20 for the spaces, which is
fine, but are there any reasons why I shouldn't be doing this?
Many thanks,

Tom

-- 
Tom Chubb
[EMAIL PROTECTED]
07915 053312

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



[PHP] Re: The Naming of Directories

2005-08-04 Thread Mark Rees
Tom Chubb [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
This may be slightly OT, but I've modified a gallery script that I had
written for me which reads directories and echos the dir name as a
gallery.
Unfortunately, it doesn't look very nice with say picsofsomething so I
renamed the folder 'pics of something'
When this is read, the string inserts %20 for the spaces, which is
fine, but are there any reasons why I shouldn't be doing this?
Many thanks,

--

A while back, this would have been liable to cause problems in Netscape
(v3/4). I don't think it makes so much difference these days, but I just
avoid it out of habit. You can get a more readable effect wihout spaces by
using an underscore, say, in the directory name, and when you need to print
it to screen, replace the underscores with spaces
--
Tom

--
Tom Chubb
[EMAIL PROTECTED]
07915 053312

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



[PHP] Knowledge Management

2005-08-04 Thread Roger Thomas
I am trying to find a suitable opensource Knowledge Management System to be 
used in my organisation; at least with document management, project management 
group collaboration capabilities, like http://cortexpro.com/

Any clues ?

--
Roger 



---
Sign Up for free Email at http://ureg.home.net.my/
---

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



Re: [PHP] Knowledge Management

2005-08-04 Thread Rory McKinley
Roger Thomas wrote:
 I am trying to find a suitable opensource Knowledge Management System to be 
 used in my organisation; at least with document management, project 
 management group collaboration capabilities, like http://cortexpro.com/
 
 Any clues ?
 
snip

Hi Roger

KnowledgeTree comes highly recommended - our company was reviewing it,
but needed something that comes with project management stuff as well.
Based on PHP  MySQL:

http://sourceforge.net/projects/kt-dms/

Rory

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



Re: [PHP] Knowledge Management

2005-08-04 Thread Roger Thomas
OK thanks Rory. I will certainly evaluate it.

--
Roger

Quoting Rory McKinley [EMAIL PROTECTED]:

 Roger Thomas wrote:
  I am trying to find a suitable opensource Knowledge Management System to be
 used in my organisation; at least with document management, project
 management group collaboration capabilities, like http://cortexpro.com/
  
  Any clues ?
  
 snip
 
 Hi Roger
 
 KnowledgeTree comes highly recommended - our company was reviewing it,
 but needed something that comes with project management stuff as well.
 Based on PHP  MySQL:
 
 http://sourceforge.net/projects/kt-dms/
 
 Rory
 
 
 
 





---
Sign Up for free Email at http://ureg.home.net.my/
---

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



Re: [PHP] code generation

2005-08-04 Thread Johan Grobler
yes sorry about that, i was going to ask about code generation but then 
rephrased the question without changing the subject...

thanx for the responses, i thought of that but wouldn't changing the system 
date on your machine be a way of getting around that?

 Jochem Maas [EMAIL PROTECTED] 08/04/05 9:34 AM 
btw - what has 'code generation' got to do with the question?
a oneliner to check 2 dates is not considered code generation -
I'd call it 'writing a oneliner' or something similiar :-)

[EMAIL PROTECTED] wrote:
 Couldn't you use a date check with date()?
 
 if(todays date  end date)
 {
 load the site
 }
 else
 {
 the site has expired
 }
 

indeed, also checkout time(), mktime(), strtotime() etc.
also ...

if ($timeIsUp) {
// delete site files
exit;
}

// show the site...

 Andrew Darrow
 Kronos1 Productions
 www.pudlz.com
 
 
 - Original Message - 
 From: Johan Grobler [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Wednesday, August 03, 2005 11:04 PM
 Subject: [PHP] code generation
 
 
 is there a way to limit the time a website is available in php?, if you want
 to have a database driven website but you would only like it to be active
 for 6 months for instance, i'm doing a project at univirsity and this is
 part of the specs, but i cant think of a good way how to do it...
 
 Disclaimer
 This e-mail transmission contains confidential information,
 which is the property of the sender.
 The information in this e-mail or attachments thereto is
 intended for the attention and use only of the addressee.
 Should you have received this e-mail in error, please delete
 and destroy it and any attachments thereto immediately.
 Under no circumstances will the Cape Peninsula University of
 Technology or the sender of this e-mail be liable to any party for
 any direct, indirect, special or other consequential damages for any
 use of this e-mail.
 For the detailed e-mail disclaimer please refer to
 http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
 



Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Peninsula University of
Technology or the sender of this e-mail be liable to any party for
any direct, indirect, special or other consequential damages for any
use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



[PHP] To count number of vists of one particular Website

2005-08-04 Thread suma parakala

Hi
Can anyone tell me how can I count how many times my website has been viewed 
using php

Thanks
Suma

_
Post FREE Classifieds. 
http://www.sulekha.com/classifieds/cllist.aspx?nma=INref=msn Reach out to 
over a million NRIs.


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



RE: [PHP] code generation

2005-08-04 Thread Shaw, Chris - Accenture

snip
thanx for the responses, i thought of that but wouldn't changing the system
date on your machine be a way of getting around that?
/snip

Time and Date functions are dependent on the locale settings of your server.




This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*

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



Re: [PHP] To count number of vists of one particular Website

2005-08-04 Thread Jochem Maas

suma parakala wrote:

Hi
Can anyone tell me how can I count how many times my website has been 
viewed using php


you'd think someone had done this before - try google first - there are
1000's of scripts that do this, have a look at some and see how they do it.

e.g.: http://www.google.com/search?q=website+counter+script+php

or use your fingers - but that could get problematic if you get slashdotted. ;-)


Thanks
Suma

_
Post FREE Classifieds. 
http://www.sulekha.com/classifieds/cllist.aspx?nma=INref=msn Reach out 
to over a million NRIs.




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



[PHP] Re: can't find the parser error

2005-08-04 Thread hope


well u have a parse error in ur TESTARRAY.PHP file



within the foreach loop
u hav writen

 print $day

while here u must also terminate it through semi-colon like this

   print $day;

This wil solve the problem 
Now it wil work










zedleon wrote:


I am having trouble finding the parser error in this small test script. Any
help would be appreciated
I am pulling in an array from this html form.



form action=/testarray.php method=post
pEvent Name: input type=text name=name size=30 //p
pWeek Days/p
input type=checkbox name=weekdays[] value=Sunday /S
input type=checkbox name=weekdays[] value=Monday /M
input type=checkbox name=weekdays[] value=Tuesday /T
input type=checkbox name=weekdays[] value=Wednesday /W
input type=checkbox name=weekdays[] value=Thursday /T
input type=checkbox name=weekdays[] value=Friday /F
input type=checkbox name=weekdays[] value=Saturday /S
/P
input type=submit name=submit value=Add the Event! //form




testarray.php




?php



print pYou want to add an event called
   b{$_POST['name']}/b which takes place on: br /;




if (is_array ($_POST['weekdays'])) {



   foreach ($_POST['weekdays'] as $day) {
   print $day



}



} else {



   print 'Please select at least one weekday for this event!';



}



print '/p';



?


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



[PHP] Using File to count number of lines

2005-08-04 Thread Tom Chubb
I'm having a problem with the following code:

?php 
$file = http://www.mysite.co.uk/mailing_list_database.list;; 
$lines = count(file($file));  
echo $lines ; 
?

I'm trying to show the number of subscribers to my visitors from a
text file, but it returns a value of 1 when it should be 5000.
I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net for the file, fopen  count functions and
can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom

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



[PHP] Do I need to use --with-pic with configure?

2005-08-04 Thread Denis Solovyov

I have a question I can't answer by myself. :)

Do I need to use --with-pic option when configuring php 4?

I'm going to build it as an Apache 1.3 DSO module and going to
run multiple instances of Apache (under different users). I
use Linux (kernel 2.4.30).

Generally, when one may need to use --with-pic?

Denis Solovyov

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



Re: [PHP] Using File to count number of lines

2005-08-04 Thread Sebastian

you sure each is on its own line (\n) ?

if you're only getting a value of 1 it is likely putting everything on a 
single array key..




Tom Chubb wrote:


I'm having a problem with the following code:

?php 
$file = http://www.mysite.co.uk/mailing_list_database.list;; 
$lines = count(file($file));  
echo $lines ; 
?


I'm trying to show the number of subscribers to my visitors from a
text file, but it returns a value of 1 when it should be 5000.
I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net for the file, fopen  count functions and
can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom

 




--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005

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



Re: [PHP] Using File to count number of lines

2005-08-04 Thread Tom Chubb
When I open the list in notepad everything is on one line with a
square box character.
When I open it in wordpad, it's one email address on each line.


On 04/08/05, Sebastian [EMAIL PROTECTED] wrote:
 you sure each is on its own line (\n) ?
 
 if you're only getting a value of 1 it is likely putting everything on a
 single array key..
 
 
 
 Tom Chubb wrote:
 
 I'm having a problem with the following code:
 
 ?php
 $file = http://www.mysite.co.uk/mailing_list_database.list;;
 $lines = count(file($file));
 echo $lines ;
 ?
 
 I'm trying to show the number of subscribers to my visitors from a
 text file, but it returns a value of 1 when it should be 5000.
 I think it's to do with recognising the line break but I don't know
 how to make it work!?!
 
 (I've looked on php.net for the file, fopen  count functions and
 can't find anything, although fopen mentions using the -t mode.
 Any ideas?
 
 Thanks,
 
 Tom
 
 
 
 
 
 --
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005
 
 


-- 
Tom Chubb
[EMAIL PROTECTED]
07915 053312

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



RE: [PHP] Setting up a new box from scratch?

2005-08-04 Thread Jim Moseby
 
 
 Hey all -
 
 I have an unused Pentium box here, recent, well loaded with RAM and  
 HD. I want to turn it into a LAMP box. Never done that before; is  
 there a preferred one-stop-shop installer CD or anything (easy -  
 knock on wood)? It would be nice to end up with some kind of decent  
 web GUI for admin.
 
 Thanks
 

You should be able to set up a LAMP box directly from the distro's install
CD.  Grab the distro of your choice, run the install, and during the phase
of the install where you choose the packages you want, choose Apache, MySQL,
and PHP.  That will get you going with LAMP.

On the other hand, there are real benefits to doing it yourself.  Install a
base Linux system, then go get the latest-greatest from the Apache, MySQL,
and PHP websites, and install them seperately.  You will not only get the
latest versions that way, but you will gain a better understanding of how
they fit together.

JM

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



RE: [PHP] Using File to count number of lines

2005-08-04 Thread Jay Blanchard
[snip]
When I open the list in notepad everything is on one line with a
square box character.
When I open it in wordpad, it's one email address on each line.
[/snip]

Sounds like that there are not any newline characters in the file. You
could do something like this...

$theFile = fopen(http://www.mysite.co.uk/mailing_list_database.list;,
r);
while(!feof($theFile)){
   $theLine = fgets($theFile, 4096);
   $theCount++;
}
fclose($theFile);

echo $theCount;

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



Re: [PHP] Using File to count number of lines

2005-08-04 Thread Sebastian

do this:

$file = 'http://www.mysite.co.uk/mailing_list_database.list';

echo 'pre';
print_r($file);
echo '/pre';

im pretty sure you'll only see 1 key..
if each has its own line, you would see something like:

Array
(
   [0] = foo
   [1] = foo
   [2] = foo
   [3] = foo
)

etc...


Tom Chubb wrote:


When I open the list in notepad everything is on one line with a
square box character.
When I open it in wordpad, it's one email address on each line.


On 04/08/05, Sebastian [EMAIL PROTECTED] wrote:
 


you sure each is on its own line (\n) ?

if you're only getting a value of 1 it is likely putting everything on a
single array key..



Tom Chubb wrote:

   


I'm having a problem with the following code:

?php
$file = http://www.mysite.co.uk/mailing_list_database.list;;
$lines = count(file($file));
echo $lines ;
?

I'm trying to show the number of subscribers to my visitors from a
text file, but it returns a value of 1 when it should be 5000.
I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net for the file, fopen  count functions and
can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom



 


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005


   




 




--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005

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



Re: [PHP] Using File to count number of lines

2005-08-04 Thread Sebastian

sorry, i forgot to put file();

Sebastian wrote:


do this:

$file = 'http://www.mysite.co.uk/mailing_list_database.list';

echo 'pre';
print_r($file);
echo '/pre';

im pretty sure you'll only see 1 key..
if each has its own line, you would see something like:

Array
(
   [0] = foo
   [1] = foo
   [2] = foo
   [3] = foo
)

etc...


Tom Chubb wrote:


When I open the list in notepad everything is on one line with a
square box character.
When I open it in wordpad, it's one email address on each line.


On 04/08/05, Sebastian [EMAIL PROTECTED] wrote:
 


you sure each is on its own line (\n) ?

if you're only getting a value of 1 it is likely putting everything 
on a

single array key..



Tom Chubb wrote:

  


I'm having a problem with the following code:

?php
$file = http://www.mysite.co.uk/mailing_list_database.list;;
$lines = count(file($file));
echo $lines ;
?

I'm trying to show the number of subscribers to my visitors from a
text file, but it returns a value of 1 when it should be 5000.
I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net for the file, fopen  count functions and
can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom






--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005


  




 







--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005

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



[PHP] Re: Using File to count number of lines

2005-08-04 Thread Al

Tom Chubb wrote:

I'm having a problem with the following code:

?php 
$file = http://www.mysite.co.uk/mailing_list_database.list;; 
$lines = count(file($file));  
echo $lines ; 
?


I'm trying to show the number of subscribers to my visitors from a
text file, but it returns a value of 1 when it should be 5000.
I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net for the file, fopen  count functions and
can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom


$count= substr_count($file_str, \n);

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



[PHP] PHP mysql Apache install on FC3

2005-08-04 Thread robert
Hello,

I am not quite sure if this is the correct mailing list to post this
question, but here I go anyway.  I have a vanilla Fedora Core 3
installation, and I am trying to run a php script through a local
website that has calls into a MySQL database.  I can run this script
at the command line using the php PHPScript.php command, and it runs
perfectly.  When I run it through the firefox web browser, I get an
error that says:

[client 127.0.0.1] PHP Warning:  mysql_pconnect(): Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/index.php on line 4

I have checked the socket, it exists.  Again, if I run this script just
using php, it works just fine.  However, when running it through Apache or
httpd it does not.  What am I doing incorrectly?

Thank you for your time,
Robert

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



Re: [PHP] very simple, yet can't think how.

2005-08-04 Thread Jochem Maas

[EMAIL PROTECTED] wrote:
 
Thanks Mark and Sonu... as much as I've learned over the last few months I  
think I'm still a little confused about some of this stuff. I appreciate the  
Help you've given me :-)
 
Would any of you know about any tutorials on something like this? books  with 
tutorials, etc? If I knew what it was called I would google it - I'm just  
not sure exactly what it might be called lol


trying googling for something like 'automated [web]site generation tool'

and/or read up on sites that offer commercials versions of what you want to do
in order in order to determine what terminology they use. e.g.:

http://www.sw-soft.com/en/products/sitebuilder/

 
Thanks again fellas :-D
 
 
In a message dated 8/1/2005 10:45:14 P.M. Central Standard Time,  
[EMAIL PROTECTED] writes:


I have  coded this type of website for many years and have run the gamut of
trying  different things -- originally, 8 years ago, I used perl with flat
files  and physical folders but in the recent past I have used PHP, MySQL  and
dynamic folders.

In my opinion the best way to build this site  is with dynamic folders via
custom 404 error handling.  Here how it  works:

You build the pages for things like contact us my store my  stuff or
whatever.  Then you send someone to the site with an address  like:
mydomain.com/joe which doesn't exist.  A custom 404 error  handler picks up
the error and parses the URL to identify joe as a unique  ID.  The 404
script pulls joe's info from a database and populates  the pages with his
custom contact info then delivers the page.  Joe's  ID usually gets stuffed
into a cookie and then when the person comes back  to the site at a later
date, they are delivered joe's info.

That's  it in a nut shell.  Be sure that you deliver 200 headers and not  404
headers when delivering the dynamic folder.

Now you can do the  physical folders and every  time someone signs up you
can take the  template and populate their pages and store these pages in a
real folder  named joe.  But, be aware using this method.  Success  (if
having lots of users is your goal) will be your downfall because this  system
is not easily scalable.  Just think what happens if you have  500 folders, or
5,000 or 50,000 folders with every folder having a copy of  the files in
them.

Here is a 404 script I  use:

?header(HTTP/1.0 200  OK);
require('/home/pathToLookUp/getinfo.php');
?

And here  is the start of the getinfo.php script:

?
list($blank, $site,  $page) = split(\/, $REDIRECT_URL, 3);
$query = select * from stores  where stores.name = '$site' and stores.active
= 'Y'  ;


?

Be sure to code the handling of an actual 404  just in case you don't have a
user named joe or the surfer miss  types.

There's a ton of work in getting all of the bases covered - but  it's sweet
when it's done and you will know a lot of how a server  works.

Hope this helps.

Mark Cain


 



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



[PHP] strip out too many newlines

2005-08-04 Thread Sebastian
im working on a comment/forum app and when a user enters too many 
carriage returns i want to remove them before insert to db.


example, user input:

-snip-
[quote=user]
foo
[/quote]

bunch of extra lines

more text...
-snip-


I to change to:

[quote=user]foo[/quote]

more text...

i try this regexp:

$message = 
preg_replace('#(\[quote(=(quot;||\'|)([^\]]*)\\3)?\])\s+#i', \\1\n, 
$_POST['message']);


doesn't remove / replace anything.
I need for it to work when they use [quote=xx] or [quote] and ends with 
[/quote]

any help?


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.9/62 - Release Date: 8/2/2005

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



Re: [PHP] strip out too many newlines

2005-08-04 Thread Marco Tabini
Don't know much about the app you're writing, but does this do the trick for
you?

echo preg_replace ('!
 (
  \[quote
  (?:=[^\]]*)?
  \]
 )# Capture the [quote=xxx] part
   
 \n*# Eliminate any extra newlines here
   
 (.+)# Get contents
   
 \n*# Eliminate any extra newlines here
   
 (\[/quote\])# Capture this part
   
 \n*# Eliminate any extra newlines here
   
!x', \$1\$2\$3\n\n, $string);

HTH,


Marco

--
BeebleX - The PHP Search Engine
http://beeblex.com

On 8/4/05 9:44 AM, Sebastian [EMAIL PROTECTED] wrote:

 [quote=user]
 foo
 [/quote]
 
 bunch of extra lines
 
 more text...

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



Re: [PHP] PHP mysql Apache install on FC3

2005-08-04 Thread Vidyut Luther
Look into the SELinux settings for your system, if you have that  
enabled, by default PHP is not allowed to get that file via the user  
nobody.

If you look into /var/log/messages you'll see some selinux messages.

You either need to disable selinux, or set your policy...http:// 
fedora.redhat.com/docs/selinux-faq-fc3/


that url should help.


On Aug 4, 2005, at 9:26 AM, [EMAIL PROTECTED] wrote:


Hello,

I am not quite sure if this is the correct mailing list to post  
this

question, but here I go anyway.  I have a vanilla Fedora Core 3
installation, and I am trying to run a php script through a local
website that has calls into a MySQL database.  I can run this script
at the command line using the php PHPScript.php command, and it runs
perfectly.  When I run it through the firefox web browser, I get an
error that says:

[client 127.0.0.1] PHP Warning:  mysql_pconnect(): Can't connect to  
local

MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in
/var/www/html/index.php on line 4

I have checked the socket, it exists.  Again, if I run this script  
just
using php, it works just fine.  However, when running it through  
Apache or

httpd it does not.  What am I doing incorrectly?

Thank you for your time,
Robert

--
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] strip out too many newlines

2005-08-04 Thread Sebastian
thanx for the reply, but 1 problem. there is not only \n there are \r in 
the POST too (carriage returns) so a string can look like this:


$string = '[quote=xx]\r\nfoo\r\n[/quote]\r\nmore text\r\n\r\n\r\n\r\n';

and your regexp will only catch if there is just \n
any solution for \r\n in combination too?

ty.

Marco Tabini wrote:


Don't know much about the app you're writing, but does this do the trick for
you?

echo preg_replace ('!
(
 \[quote
 (?:=[^\]]*)?
 \]
)# Capture the [quote=xxx] part
  
\n*# Eliminate any extra newlines here
  
(.+)# Get contents
  
\n*# Eliminate any extra newlines here
  
(\[/quote\])# Capture this part
  
\n*# Eliminate any extra newlines here
  
   !x', \$1\$2\$3\n\n, $string);


HTH,


Marco

--
BeebleX - The PHP Search Engine
http://beeblex.com

On 8/4/05 9:44 AM, Sebastian [EMAIL PROTECTED] wrote:

 


[quote=user]
foo
[/quote]

bunch of extra lines

more text...
   








 




--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date: 8/3/2005

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



Re: [PHP] strip out too many newlines

2005-08-04 Thread Marco Tabini
Try changing the 

\n*

patterns to

(?:\r?\n)*

Cheers,


Marco

--
BeebleX - The PHP Search Engine
http://beeblex.com


On 8/4/05 10:39 AM, Sebastian [EMAIL PROTECTED] wrote:

 [quote=user]
 foo
 [/quote]
 
 bunch of extra lines
 
 more text...

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



[PHP] Is gethostbyaddr() slow?

2005-08-04 Thread Dotan Cohen
Hi all, I just discovered the gethostbyaddr() function. By reading the
user contributed notes, I get the impression that either this function
may cause performance problems, or a user-contributed function based
upon it may be slow. So, is gethostbyaddr() slow? Is it dangerous?
Thanks!

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/56/bangles.php
The Bangles Song Lyrics

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



Re: [PHP] Is gethostbyaddr() slow?

2005-08-04 Thread Jochem Maas

Dotan Cohen wrote:

Hi all, I just discovered the gethostbyaddr() function. By reading the
user contributed notes, I get the impression that either this function
may cause performance problems, or a user-contributed function based
upon it may be slow. So, is gethostbyaddr() slow? Is it dangerous?


I'm guessing that the speed is very much dependent on the speed of the
underlying dns query mechanism - so probably yes, it's relatively slow.
and not something you want to be doing many times within a single request.

probably someone will now declare me a retard  ;-)


Thanks!

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/56/bangles.php
The Bangles Song Lyrics



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



Re: [PHP] strip out too many newlines

2005-08-04 Thread Sebastian

that works for my orginal request, but i found something else:

$string = '[quote=xx]foo[/quote]\nmore text\r\n\r\n\r\n\r\nmore text';

now if they enter more carriage returns i get the results from above. 
its no big deal, but you always have someone trying to 'break' the system.


thanks, i really need to learn some regexp.

Marco Tabini wrote:

Try changing the 


\n*

patterns to

(?:\r?\n)*

Cheers,


Marco

--
BeebleX - The PHP Search Engine
http://beeblex.com


On 8/4/05 10:39 AM, Sebastian [EMAIL PROTECTED] wrote:

 


[quote=user]
foo
[/quote]

bunch of extra lines

more text...
   



 




--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date: 8/3/2005

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



Re: [PHP] Is gethostbyaddr() slow?

2005-08-04 Thread Kristen G. Thorson
I can say from personal experience that gethostbyaddr() and 
gethostbyname() can seem almost randomly slow, depending on machine, OS, 
software, who knows.  I'm not smart enough to figure out the reason why 
it can vary so much on machines with nearly the same configuration, but 
I can tell you that it works perfectly fast most of the time.  Then 
there's that other 5% where something makes it slow as molasses.


I have two machines that are so similar it's not funny, but 
gethostbyname() takes 1/10 s on one, and 5 s on the other.  I have yet 
to figure out what's the difference between them that causing this.



kgt



Dotan Cohen wrote:


Hi all, I just discovered the gethostbyaddr() function. By reading the
user contributed notes, I get the impression that either this function
may cause performance problems, or a user-contributed function based
upon it may be slow. So, is gethostbyaddr() slow? Is it dangerous?
Thanks!

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/56/bangles.php
The Bangles Song Lyrics

 



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



[PHP] ICMP Checksum, calculation

2005-08-04 Thread Philip Birk
I've wanted to make a ping 'program' in PHP, so after reading up on 
this, it occured to me that the only difficult thing was to calculate 
the ICMP checksum. So after some heavy reading I could calculate this by 
pen and paper. And after some hours trying to make my calculations into 
PHP code, I discovered this piece of code in the online doc:


(by Khaless [at] bigpond [dot] com)
http://dk2.php.net/manual/en/ref.sockets.php
?PHP
// Computes Internet Checksum for $data
// will return a 16-bit internet checksum for $data
function inetChecksum($data)
{
   // 32-bit accumilator, 16 bits at a time, adds odd bit on at end
   for($i=0;$istrlen($data);$i += 2)
   {
   if($data[$i+1]) $bits = unpack('n*',$data[$i].$data[$i+1]);
   else $bits = unpack('C*',$data[$i]);
   $sum += $bits[1];
   }

   // Fold 32-bit sum to 16 bits
   while ($sum16) $sum = ($sum  0x) + ($sum  16);
   $checksum = pack('n1',~$sum);
   return $checksum;
}
?


Now, after discovering the unpack function it all became a lot easier, 
so I've made my own checksum calculator, which works approximatly 5 
times as fast (and it dosn't have the for loop limitation of data 
length), and all the tests I've done it gives the same result as above:


?php
function myChecksum($data)
{
$bit = unpack('n*', $data);
$sum = array_sum($bit);

if (strlen($data)%2) {
$temp = unpack('C*',$data[strlen($data)-1]);
$sum += $temp[1];
}

// The next 2 lines of code, is stolen from the
// original ping program written in C
// Stolen code start:
$sum = ($sum  16) + ($sum  0x);
$sum += ($sum  16);
// End of stolen code

return pack('n*', ~$sum);
}
?

Can anyone tell me, if there will be any example, where the 2 functions 
wont give the same output? The piece of code I think could be the most 
trouble is the piece I've stolen, in the other function there's a while 
loop, so if I a very long data input, it wouldn't be the same output, 
but I've tried with large strings and they still give the same.



So to sum up, will the 2 functions always calculate the same.


--
Philip Birk-Jensen
URL:  http://birk-jensen.dk
ICQ:  14789099

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



[PHP] Re: Is gethostbyaddr() slow?

2005-08-04 Thread kalinga
On 8/4/05, Kristen G. Thorson [EMAIL PROTECTED] wrote:
 I can say from personal experience that gethostbyaddr() and 
 gethostbyname() can seem almost randomly slow, depending on machine, OS, 
 software, who knows.  I'm not smart enough to figure out the reason why 
 it can vary so much on machines with nearly the same configuration, but 
 I can tell you that it works perfectly fast most of the time.  Then 
 there's that other 5% where something makes it slow as molasses.
 
 I have two machines that are so similar it's not funny, but 
 gethostbyname() takes 1/10 s on one, and 5 s on the other.  I have yet 
 to figure out what's the difference between them that causing this.
 
 
 kgt
 
 
 
 Dotan Cohen wrote:
 
 Hi all, I just discovered the gethostbyaddr() function. By reading the
 user contributed notes, I get the impression that either this function
 may cause performance problems, or a user-contributed function based
 upon it may be slow. So, is gethostbyaddr() slow? Is it dangerous?
 Thanks!
 
 Dotan Cohen
 http://lyricslist.com/lyrics/artist_albums/56/bangles.php
 The Bangles Song Lyrics
 
   
 
 
 -- 
 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] Re: Is gethostbyaddr() slow?

2005-08-04 Thread kalinga
On 8/4/05, kalinga [EMAIL PROTECTED] wrote:
 On 8/4/05, Kristen G. Thorson [EMAIL PROTECTED] wrote:
  I can say from personal experience that gethostbyaddr() and 
  gethostbyname() can seem almost randomly slow, depending on machine, OS, 
  software, who knows.  I'm not smart enough to figure out the reason why 
  it can vary so much on machines with nearly the same configuration, but 
  I can tell you that it works perfectly fast most of the time.  Then 
  there's that other 5% where something makes it slow as molasses.
  
  I have two machines that are so similar it's not funny, but 
  gethostbyname() takes 1/10 s on one, and 5 s on the other.  I have yet 
  to figure out what's the difference between them that causing this.

if you are quering a external host, the bad network conditions may
cause delay in results.

if your server is connected to a heavily loaded hub/ cheap switch, or
the target hosts DNS servers are poorly configured/ slow in responce
it adds further delay to your result.

try dig/ nslookup on your server for the target hostname/address, you
may experience the same delay as with the php function.


~viraj.

  
  
  kgt
  
  
  
  Dotan Cohen wrote:
  
  Hi all, I just discovered the gethostbyaddr() function. By reading the
  user contributed notes, I get the impression that either this function
  may cause performance problems, or a user-contributed function based
  upon it may be slow. So, is gethostbyaddr() slow? Is it dangerous?
  Thanks!
  
  Dotan Cohen
  http://lyricslist.com/lyrics/artist_albums/56/bangles.php
  The Bangles Song Lyrics
  

  
  
  -- 
  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] strip out too many newlines

2005-08-04 Thread Marco Tabini
On 8/4/05 10:56 AM, Sebastian [EMAIL PROTECTED] wrote:

 that works for my orginal request, but i found something else:
 
 $string = '[quote=xx]foo[/quote]\nmore text\r\n\r\n\r\n\r\nmore text';
 

Try removing double-instances of \r\n (or \n) before running the regex.


Marco

 now if they enter more carriage returns i get the results from above.
 its no big deal, but you always have someone trying to 'break' the system.
 
 thanks, i really need to learn some regexp.
 
 Marco Tabini wrote:
 
 Try changing the
 
 \n*
 
 patterns to
 
 (?:\r?\n)*
 
 Cheers,
 
 
 Marco
 
 --
 BeebleX - The PHP Search Engine
 http://beeblex.com
 
 
 On 8/4/05 10:39 AM, Sebastian [EMAIL PROTECTED] wrote:
 
  
 
 [quote=user]
 foo
 [/quote]
 
 bunch of extra lines
 
 more text...

 
 
  
 
 

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



[PHP] Re: Is gethostbyaddr() slow?

2005-08-04 Thread kalinga
i missed another keypoint..

if you are running unix/linux server, you need to have a properly
setup resolv.conf

or if you experience a slowness while you quering your own domains,
check whether you DNS servers are providing authoritative answers to
your domains.


~viraj.

On 8/4/05, kalinga [EMAIL PROTECTED] wrote:
 On 8/4/05, kalinga [EMAIL PROTECTED] wrote:
  On 8/4/05, Kristen G. Thorson [EMAIL PROTECTED] wrote:
   I can say from personal experience that gethostbyaddr() and 
   gethostbyname() can seem almost randomly slow, depending on machine, OS,
 
   software, who knows.  I'm not smart enough to figure out the reason why
 
   it can vary so much on machines with nearly the same configuration, but
 
   I can tell you that it works perfectly fast most of the time.  Then 
   there's that other 5% where something makes it slow as molasses.
   
   I have two machines that are so similar it's not funny, but 
   gethostbyname() takes 1/10 s on one, and 5 s on the other.  I have yet 
   to figure out what's the difference between them that causing this.
 
 if you are quering a external host, the bad network conditions may
 cause delay in results.
 
 if your server is connected to a heavily loaded hub/ cheap switch, or
 the target hosts DNS servers are poorly configured/ slow in responce
 it adds further delay to your result.
 
 try dig/ nslookup on your server for the target hostname/address, you
 may experience the same delay as with the php function.
 
 
 ~viraj.
 
   
   
   kgt
   
   
   
   Dotan Cohen wrote:
   
   Hi all, I just discovered the gethostbyaddr() function. By reading the
   user contributed notes, I get the impression that either this function
   may cause performance problems, or a user-contributed function based
   upon it may be slow. So, is gethostbyaddr() slow? Is it dangerous?
   Thanks!
   
   Dotan Cohen
   http://lyricslist.com/lyrics/artist_albums/56/bangles.php
   The Bangles Song Lyrics
   
 
   
   
   -- 
   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] Interesting Referer behaviour- how to copy it?

2005-08-04 Thread Dotan Cohen
I creating a out.php file that will record clicks, and the redirect
the user to the site that he wanted. I am currently using
header(Location: $url); which works as expected. The only problem
is, that the browser does not send $HTTP_REFERER info to the recieving
site.

However, that particular site is also linking to me via a out.php
file, and the browser DOES set $HTTP_REFERER on my site. So I've been
googleing for two days, and came up with this: There is a site that
displays the server reesponse of any server. So I put both of our
out.php files to the test. First, his server response:
HTTP/1.1 302 Found
Connection: close
Date: Thu, 04 Aug 2005 15:19:01 GMT
Location: http://lyricslist.com
Server: Apache/2.0.50 (FreeBSD) PHP/5.0.0
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Thu, 04 Aug 2005 15:32:32 GMT
Client-Response-Num: 1
X-Powered-By: PHP/5.0.0

This redirects to lyricslist.com and correctly sets the $HTTP_REFERER
variable. Now, my server response:
HTTP/1.1 302 Found
Connection: close
Date: Thu, 04 Aug 2005 15:39:25 GMT
Location: http://lyricslist.com
Server: Apache/1.3.33 (Unix) mod_auth_passthrough/1.8
mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.11 FrontPage/5.0.2.2635
mod_ssl/2.8.22 OpenSSL/0.9.7a
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Thu, 04 Aug 2005 15:39:29 GMT
Client-Response-Num: 1
X-Powered-By: PHP/4.3.11

This just does not set the $HTTP_REFERER variable! The referer
variable is even set to the original page that linked to out.php, and
not out.php itself! I have tried in IE 6.x, Firefox 1.0.6, Pheonix 0.7
(remember that!), and Opera 8.0. What could be the difference?

Thanks to all who rack thier brains on this one! It's been a fruitless
two days for me...

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/118/chumbawamba.php
Chumbawamba Song Lyrics

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



[PHP] Re: Using File to count number of lines

2005-08-04 Thread Brandon Ryan
 Are you running this php code in windows, where a line break is made up of 
a carriage return and a line feed? The file was probably created on 
unix/linux where the line break is just a line feed. If you try to read this 
file in windows, it will think everything is on one line. You either have to 
replace all line feeds with carriage return and then line feed, or read it 
in and parse it. 
 Brandon
 On 8/4/05, Al [EMAIL PROTECTED] wrote: 
 
 Tom Chubb wrote:
  I'm having a problem with the following code:
 
  ?php
  $file =  http://www.mysite.co.uk/mailing_list_database.list;;
  $lines = count(file($file));
  echo $lines ;
  ?
 
  I'm trying to show the number of subscribers to my visitors from a 
  text file, but it returns a value of 1 when it should be 5000.
  I think it's to do with recognising the line break but I don't know
  how to make it work!?!
 
  (I've looked on php.net http://php.net/ for the file, fopen  count 
 functions and
  can't find anything, although fopen mentions using the -t mode.
  Any ideas?
 
  Thanks,
 
  Tom
 
 $count= substr_count($file_str, \n); 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



Re: [PHP] Re: Is gethostbyaddr() slow?

2005-08-04 Thread Kristen G. Thorson

kalinga wrote:


if you are quering a external host, the bad network conditions may

cause delay in results.

if your server is connected to a heavily loaded hub/ cheap switch, or
the target hosts DNS servers are poorly configured/ slow in responce
it adds further delay to your result.

try dig/ nslookup on your server for the target hostname/address, you
may experience the same delay as with the php function.

 



Thanks for the reply.  The problem I had - and that I was trying to 
briefly describe - is not quite explained by slow DNS lookup, at least 
not so far.  I have one script, run on the same machine:


takes less than 1 second on CLI:

# php gethostbyname.php
Content-type: text/html
X-Powered-By: PHP/4.3.2

gethostbyname(www.imakenews.com) took 0.0010 s and resolved to 
208.254.39.65br
gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 
63.87.252.162br
gethostbyname(itpapers.zdnet.com) took 0.1922 s and resolved to 
216.239.113.159br
gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 
63.87.252.162br



Running CLI again, host names are apparently cached, because then they 
all return in .0005 seconds.


takes 20 seconds under Apache 2.0.46:

gethostbyname(www.imakenews.com) took 5.0071 s and resolved to 
208.254.39.65
gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 
63.87.252.162
gethostbyname(itpapers.zdnet.com) took 5.0097 s and resolved to 
216.239.113.159
gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 
63.87.252.162



This will happen consistently, with less than 1/100 s variation in time 
for each lookup.



Any DNS lookup tools are perfectly fast when run from the command line.  
Also, other machines in the same subnet, using the same DNS servers, 
using 99% same apache config files (I diff'ed 'em) run just as fast 
under same apache/php version as they do command line.  It's hard to 
imagine what external DNS problem could exist that would affect only one 
of our servers, and on that one, only apache/php and nothing command 
line.  Something else is going on, but my initial tries of 
downgrading/upgrading both php and apache haven't made a different yet.  
Perhaps you have another suggestion?



Thanks,

kgt

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



[PHP] Re: shell_exec(zip.. ?

2005-08-04 Thread Matthew Weier O'Phinney
* Sam Smith [EMAIL PROTECTED]:

 shell_exec(zip -r ddd ddd); // don't work

Many version of zip won't append the .zip extension. In such a case,
what you have above will try to name the zip file the same as the
existing directory, which obviously won't work. Try:

shell_exec(zip -r ddd.zip ddd);

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

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



[PHP] Re: syntax highlighting your php code on a web page

2005-08-04 Thread Matthew Weier O'Phinney
* Steve Turnbull [EMAIL PROTECTED]:
 Is there a class or some code out there which enables you to print your
 PHP code to a web page and make it appear with syntax highlighting?

 As an example of what I am after, have a look here;

 http://www.phpfreaks.com/phpmanual/page/function.ldap-add.html

 Please note this is just an example page which highlights what I am after...

There's a few ways. highlight_file() and highlight_string() will do it.
Another way is to symlink to the .php file as extension .phps -- and
provide a link to the .phps file.

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

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



[PHP] Re: Is gethostbyaddr() slow?

2005-08-04 Thread kalinga
On 8/4/05, Kristen G. Thorson [EMAIL PROTECTED] wrote:
 kalinga wrote:
 
  if you are quering a external host, the bad network conditions may
 
 cause delay in results.
 
 if your server is connected to a heavily loaded hub/ cheap switch, or
 the target hosts DNS servers are poorly configured/ slow in responce
 it adds further delay to your result.
 
 try dig/ nslookup on your server for the target hostname/address, you
 may experience the same delay as with the php function.
 
   
 
 
 Thanks for the reply.  The problem I had - and that I was trying to 
 briefly describe - is not quite explained by slow DNS lookup, at least 
 not so far.  I have one script, run on the same machine:
 
 takes less than 1 second on CLI:
 
 # php gethostbyname.php
 Content-type: text/html
 X-Powered-By: PHP/4.3.2
 
 gethostbyname(www.imakenews.com) took 0.0010 s and resolved to 
 208.254.39.65br
 gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 
 63.87.252.162br
 gethostbyname(itpapers.zdnet.com) took 0.1922 s and resolved to 
 216.239.113.159br
 gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 
 63.87.252.162br
 
 
 Running CLI again, host names are apparently cached, because then they 
 all return in .0005 seconds.
 
 takes 20 seconds under Apache 2.0.46:
 
 gethostbyname(www.imakenews.com) took 5.0071 s and resolved to 
 208.254.39.65
 gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 
 63.87.252.162
 gethostbyname(itpapers.zdnet.com) took 5.0097 s and resolved to 
 216.239.113.159
 gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 
 63.87.252.162
 
 
 This will happen consistently, with less than 1/100 s variation in time 
 for each lookup.
 
 
 Any DNS lookup tools are perfectly fast when run from the command line.  
 Also, other machines in the same subnet, using the same DNS servers, 
 using 99% same apache config files (I diff'ed 'em) run just as fast 
 under same apache/php version as they do command line.  It's hard to 
 imagine what external DNS problem could exist that would affect only one 
 of our servers, and on that one, only apache/php and nothing command 
 line.  Something else is going on, but my initial tries of 
 downgrading/upgrading both php and apache haven't made a different yet.  
 Perhaps you have another suggestion?

could you please mention the environment, i mean, the os, and the
versions of php? is it binary install or a compile?

 
 
 Thanks,
 
 kgt
 
 
 
 


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



Re: [PHP] To count number of vists of one particular Website

2005-08-04 Thread Dotan Cohen
On 8/4/05, suma parakala [EMAIL PROTECTED] wrote:
 Hi
 Can anyone tell me how can I count how many times my website has been viewed
 using php
 Thanks
 Suma

Suma,
I am working on that now. I will soon have a script ready under GPL.
There are two versions, one with mysql and one with flat files. Do you
have mysql?

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/119/clapton_eric.php
Clapton, Eric Song Lyrics

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



Re: [PHP] Re: Using File to count number of lines

2005-08-04 Thread Al

Brandon Ryan wrote:
 Are you running this php code in windows, where a line break is made up of 
a carriage return and a line feed? The file was probably created on 
unix/linux where the line break is just a line feed. If you try to read this 
file in windows, it will think everything is on one line. You either have to 
replace all line feeds with carriage return and then line feed, or read it 
in and parse it. 
 Brandon
 On 8/4/05, Al [EMAIL PROTECTED] wrote: 


Tom Chubb wrote:


I'm having a problem with the following code:

?php
$file =  http://www.mysite.co.uk/mailing_list_database.list;;
$lines = count(file($file));
echo $lines ;
?

I'm trying to show the number of subscribers to my visitors from a 
text file, but it returns a value of 1 when it should be 5000.

I think it's to do with recognising the line break but I don't know
how to make it work!?!

(I've looked on php.net http://php.net/ for the file, fopen  count 


functions and


can't find anything, although fopen mentions using the -t mode.
Any ideas?

Thanks,

Tom


$count= substr_count($file_str, \n); 


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






Windows is \r\n; unix/linux \n; MAC \r.  So the \n gets Windows and Unix/linux/ 
 If it's MAC or can be. then replace all

\r with \n first.

e.g., $str= preg_replace(%(\r\n|\r|\n)%, \n, $str);

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



[PHP] Re: The Naming of Directories

2005-08-04 Thread Satyam

Mark Rees [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Tom Chubb [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 This may be slightly OT, but I've modified a gallery script that I had
 written for me which reads directories and echos the dir name as a
 gallery.
 Unfortunately, it doesn't look very nice with say picsofsomething so I
 renamed the folder 'pics of something'
 When this is read, the string inserts %20 for the spaces, which is
 fine, but are there any reasons why I shouldn't be doing this?
 Many thanks,

 --

 A while back, this would have been liable to cause problems in Netscape
 (v3/4). I don't think it makes so much difference these days, but I just
 avoid it out of habit. You can get a more readable effect wihout spaces by
 using an underscore, say, in the directory name, and when you need to 
 print
 it to screen, replace the underscores with spaces
 --
 Tom
Wasn't the plus sign the replacement for a space?  Pics+of+something is more 
readable.

Satyam

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



RE: [PHP] Re: The Naming of Directories

2005-08-04 Thread Shaw, Chris - Accenture

I believe %20 and + are used to replace spaces.

See RFC 1738 - Uniform Resource Locators (URL)

http://www.faqs.org/rfcs/rfc1738.html

C.

-Original Message-
From: Satyam [mailto:[EMAIL PROTECTED]
Sent: 04 August 2005 18:07
To: php-general@lists.php.net
Subject: [PHP] Re: The Naming of Directories


*

This e-mail has been received by the Revenue Internet e-mail service.

*


Mark Rees [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Tom Chubb [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 This may be slightly OT, but I've modified a gallery script that I had
 written for me which reads directories and echos the dir name as a
 gallery.
 Unfortunately, it doesn't look very nice with say picsofsomething so I
 renamed the folder 'pics of something'
 When this is read, the string inserts %20 for the spaces, which is
 fine, but are there any reasons why I shouldn't be doing this?
 Many thanks,

 --

 A while back, this would have been liable to cause problems in Netscape
 (v3/4). I don't think it makes so much difference these days, but I just
 avoid it out of habit. You can get a more readable effect wihout spaces by
 using an underscore, say, in the directory name, and when you need to
 print
 it to screen, replace the underscores with spaces
 --
 Tom
Wasn't the plus sign the replacement for a space?  Pics+of+something is more
readable.

Satyam

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







This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*

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



Re: [PHP] How to determine if a script instance is already running?

2005-08-04 Thread Matthew Weier O'Phinney
* Matt [EMAIL PROTECTED] :
 Perhaps svscan and its associated daemontools programs could be
 used to monitor the script instead of relying on cron.

Just a note: The above suggestion would assume you control the box, and
that you're running on a *nix system (i.e., you've got root on a linux,
bsd, solaris, AIX, etc. server).

 On 8/2/05, André Medeiros [EMAIL PROTECTED] wrote:
  On Tue, 2005-08-02 at 15:09 +0100, Stut wrote:
   André Medeiros wrote:
Do like some services do:
   
1) Check if script.pid exists
2) If it doesn't
2.1) Write the process's PID onto the file
(http://pt.php.net/manual/en/function.getmypid.php)
3) If it does
3.1) Die gracefully :)
  
   Personally I'd extend that slightly to have the process touch the PID
   file every so often and to check that it's been touched recently when it
   starts up. Alternatively use the ps shell command to check that a
   process with that PID is still running, but that tends to be less 
   reliable.
  
   If the process does decide to continue in spite of the PID file existing
   it should issue a a shell kill command to kill that PID in case it's
   hung or a zombie.
  
   -Stut
  
  Excelent point!

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

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



[PHP] Re: Performace and segfault errors with Php5 + Apache 1.3.x + linux-2.6.x

2005-08-04 Thread Matthew Weier O'Phinney
* Edwin Barrios [EMAIL PROTECTED]:
 i'am developing  a web framework SifEngine (Secure Web Inteface
 framework) that implement MVC applaying the security ideas from
 http://phpsec.org. I'am using DomXML, Sqlite, Mcrypt and PostgreSql.

 After  of post my development on the internet ( i have been thinking
 to post on PEAR ), i made simple tests of aplications with my
 framework. During the implementation, i used Slackware 10.1 with
 kernel 2.4.29 + php5.0.4 + Apache 1.3.2, with no problems. I didn't
 detect  performace problems or segfaults by apache.  Then i decided to
 do the same test but with kernel 2.6.10, wating that no problems
 occur. However my expectation, on this new configuration all the
 aplications develped with my framework, had performance issues or in
 the worst situation produce apache forks  to be restarted, or a lot of
 apache forks.

 i don't undestand why this occur, i try to use valigrand to verify
 memorie lacks without results.

Are you using __call() or any of the other overloading methods? I had a
situation several months ago where __call() was going into an infinite
loop and causing segfaults. Once I tracked that down and fixed it,
everything worked fine.

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

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



Re: [PHP] Do I need to use --with-pic with configure?

2005-08-04 Thread Rasmus Lerdorf
Denis Solovyov wrote:
 I have a question I can't answer by myself. :)
 
 Do I need to use --with-pic option when configuring php 4?
 
 I'm going to build it as an Apache 1.3 DSO module and going to
 run multiple instances of Apache (under different users). I
 use Linux (kernel 2.4.30).
 
 Generally, when one may need to use --with-pic?

--with-pic is the default, so you don't need to add it.

-Rasmus

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



[PHP] Re: overwrite private class members in php5?

2005-08-04 Thread Matthew Weier O'Phinney
* Norbert Wenzel [EMAIL PROTECTED]:
 Hi, I've done something like this:

 class MyClass {

private $var;

function __construct($value) {
  $this-var = $value;
}

public function printVar() {
  echo($this-var);
}

 }

 $object = new MyClass('1');
 $object-printVar(); // prints 1
 $object-var = 3; // Fatal Error as expected
 $object-$var = 2; // no error msg

$var is empty, so this is setting a non-existent class property to 2.

 $object-printVar(); // prints 2

I got 1 when running this -- just as I would expect. Are you sure it
printed 2?

Basically, if a property is undeclared, it is assumed public, so you can
set undefined properties without issue. If defined private or protected,
the calling script will not be able to alter the value.

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

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



[PHP] Re: Class constants

2005-08-04 Thread Matthew Weier O'Phinney
* Marcus Bointon [EMAIL PROTECTED]:
 I'm not sure if this is a bug or a feature, but it seems you can't  
 use class constants to set default values for class properties. You  
 can, however, use them for default values for method params, e.g.:

 class foo {}
const BAR = 100;
private $thing = self::BAR;
function wibble($a = self::BAR) {
  echo $a;
}
 }

 In this case $this-thing will be undefined, but wibble() will get  
 the correct default value for $a.

 Comments?

This has been the case since PHP4. From http://php.net/oop:

 In PHP 4, only constant initializers for var variables are allowed. To
 initialize variables with non-constant values, you need an
 initialization function which is called automatically when an object is
 being constructed from the class.

What is meant by 'constant initializers' is that you cannot define class
variables based on variables, constants, or globals -- defined in the
class or otherwise. So, the following is okay:

private $thing = 100;

But, as you saw, the following will barf:

private $thing = self::BAR;
private $thing = BAR;
private $thing = $_SERVER['SCRIPT_NAME'];
// etc.

So, in other words, the issues you're seeing are consistent with the
documentation.

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

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



[PHP] Sessions again....

2005-08-04 Thread Suhas
Hello,
 I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.

I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.

This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)


ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter(nocache);
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();

if(!session_is_registered('count'))
  session_register('count');

echo ++$_SESSION['count'];

Any help will be appriciated!

Thanks
SP

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



Re: [PHP] Sessions again....

2005-08-04 Thread James

So what is your question...?

- Original Message - 
From: Suhas [EMAIL PROTECTED]

To: php-general php-general@lists.php.net
Sent: Thursday, August 04, 2005 4:13 PM
Subject: [PHP] Sessions again


Hello,
I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.

I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.

This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)


ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter(nocache);
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();

if(!session_is_registered('count'))
 session_register('count');

echo ++$_SESSION['count'];

Any help will be appriciated!

Thanks
SP

--
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] Sessions again....

2005-08-04 Thread Suhas
Hello,
I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.

I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.

This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)


ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter(nocache);
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();

if(!session_is_registered('count'))
 session_register('count');

echo ++$_SESSION['count'];

Any help will be appriciated!

Thanks
SP

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



Re: [PHP] Sessions again....

2005-08-04 Thread James

session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds 
which is sent to the browser. The value 0 means until the browser is 
closed. Defaults to 0. See also session_get_cookie_params() and 
session_set_cookie_params().



- Original Message - 
From: Suhas [EMAIL PROTECTED]
To: James [EMAIL PROTECTED]; php-general 
php-general@lists.php.net

Sent: Thursday, August 04, 2005 4:35 PM
Subject: Re: [PHP] Sessions again


Well script is not working as it is supposed to be. Even after 2 hrs I
visit the page the count variable increases by 1 than prevois value.

Any reason why is that so? If my understanding is not correct please correct 
me.


Thanks
SP


On 8/4/05, James [EMAIL PROTECTED] wrote:

So what is your question...?

- Original Message -
From: Suhas [EMAIL PROTECTED]
To: php-general php-general@lists.php.net
Sent: Thursday, August 04, 2005 4:13 PM
Subject: [PHP] Sessions again


Hello,
 I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.

I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.

This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)


ini_set('session.auto_start', '0');
session_id('SSP');
session_cache_limiter(nocache);
ini_set('session.cookie_lifetime', '0');
ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');
session_start();

if(!session_is_registered('count'))
  session_register('count');

echo ++$_SESSION['count'];

Any help will be appriciated!

Thanks
SP

--
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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Sessions again....

2005-08-04 Thread Suhas
Well script is not working as it is supposed to be. Even after 2 hrs I
visit the page the count variable increases by 1 than prevois value.

Any reason why is that so? If my understanding is not correct please correct me.

Thanks
SP


On 8/4/05, James [EMAIL PROTECTED] wrote:
 So what is your question...?
 
 - Original Message -
 From: Suhas [EMAIL PROTECTED]
 To: php-general php-general@lists.php.net
 Sent: Thursday, August 04, 2005 4:13 PM
 Subject: [PHP] Sessions again
 
 
 Hello,
  I am trying to understand how sessions work. I have this code. My
 understanding is after 1 sec of script completion, (may be little
 after that), the session should destroy.
 
 I understand that it is huge overhead for server, not planning to do
 this but want to understand how it really works.
 
 This server uses cookie to store session. Setings in php.ini file are
 defaut (1440 and probility is 1)
 
 
 ini_set('session.auto_start', '0');
 session_id('SSP');
 session_cache_limiter(nocache);
 ini_set('session.cookie_lifetime', '0');
 ini_set('session.gc_probability', '100');
 ini_set('session.gc_divisor', '100');
 ini_set('session.gc_maxlifetime', '1');
 session_start();
 
 if(!session_is_registered('count'))
   session_register('count');
 
 echo ++$_SESSION['count'];
 
 Any help will be appriciated!
 
 Thanks
 SP
 
 --
 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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] very simple, yet can't think how.

2005-08-04 Thread Esteamedpw
Thanks! tried googling - only found using ruby to automatically generate  
php sites...
 
the SW-Soft Site Builder program is a great program - looking all through  
it now.
 
Thanks!


[PHP] Timing out a remote call

2005-08-04 Thread Brian Dunning
For one project, I'm required to access a web service for every page.  
Basically it returns a little bit of random text. I have no control  
over the web service, and there is no possibility of cacheing or  
bringing it locally: the requirements are that it be accessed live  
across the Internet every time.


Most times it's instantaneous, but sometimes it can hang. I want to  
give it a half-second timeout, which we're allowed to do, but there's  
no documentation provided. Here is how we call it now (really simple):


  include('http://04planet.info/kfc/grab_one.php');

I have STFW and RTFM and could only find vague references like use  
fsockopen instead or stream_set_timeout() but I can't find an  
actual complete working example anywhere. Any pointers?


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



Re: [PHP] Timing out a remote call

2005-08-04 Thread Torgny Bjers
Brian Dunning wrote:

 For one project, I'm required to access a web service for every page. 
 Basically it returns a little bit of random text. I have no control 
 over the web service, and there is no possibility of cacheing or 
 bringing it locally: the requirements are that it be accessed live 
 across the Internet every time.

 Most times it's instantaneous, but sometimes it can hang. I want to 
 give it a half-second timeout, which we're allowed to do, but there's 
 no documentation provided. Here is how we call it now (really simple):

   include('http://04planet.info/kfc/grab_one.php');

 I have STFW and RTFM and could only find vague references like use 
 fsockopen instead or stream_set_timeout() but I can't find an 
 actual complete working example anywhere. Any pointers?

Generally, using include or file_get_contents() for a remote call is a
Bad Idea. Perhaps if you used curl instead? You have a lot more control
over the entire call that way. Of course, the curl code might be a bit
bulkier in PHP, but I find it works quite well.

As for fsockopen(), it works just like a file pointer.

http://www.php.net/manual/en/function.fsockopen.php

That manual page gives a pretty good description of how to use it.

Idea: The socket will by default be opened in blocking mode. You can
switch it to non-blocking mode by using stream_set_blocking().

The last parameter to fsockopen() is the timeout for connecting to the
socket, and the manual describes it as such:

Note:  If you need to set a timeout for reading/writing data over the
socket, use stream_set_timeout(), as the timeout  parameter to
fsockopen() only applies while connecting the socket.

Regards,
Torgny

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



Re: [PHP] Sessions again....

2005-08-04 Thread Jochem Maas

Suhas wrote:

Hello,
 I am trying to understand how sessions work. I have this code. My
understanding is after 1 sec of script completion, (may be little
after that), the session should destroy.

I understand that it is huge overhead for server, not planning to do
this but want to understand how it really works.

This server uses cookie to store session. Setings in php.ini file are
defaut (1440 and probility is 1)


ini_set('session.auto_start', '0');


this ini setting can onyl be set before php
starts - setting inside your script does nothing. I THINK.


session_id('SSP');


I wouldn't make the call to session_id() - not like that
anyway - insecure springs to mind - read more here:
http://php.net/session_id

IHMO you should just let php handle session id generation.


session_cache_limiter(nocache);


this function call determine the kind of
caching headers that will be sent.
yuor pages should not be cached by the browser
or any intermediary proxy.


ini_set('session.cookie_lifetime', '0');


this sets you session cookie to last for as long as you
keep the browser open.


ini_set('session.gc_probability', '100');
ini_set('session.gc_divisor', '100');
ini_set('session.gc_maxlifetime', '1');


these 3 ini setting have to do with garbage collection
(gc) of stale session data (files) - the numbers you use
100  100 mean that the garbage collector will be run
at the end of every request - thats very bad for performance.

session.gc_maxlifetime doesn't seem to be being honored ..
this may be down to your version of php, your OS, a combination
thereof - or it may even be that the value is too small to
be meaningful. or the session.cookie_lifetime may be
interfering - I just don't know but seems _like_ incorrect behaviour

bare in mind that although you are calling ini_set() on all these
setting that does not mean that any of the values you give are actually
being set successfully - use ini_get() after your call to session_start()
and echo out the results to determine what values are actually in
affect.


session_start();


indeed - you must call session_start() before trying to
use $_SESSION


if(!session_is_registered('count'))
  session_register('count');

echo ++$_SESSION['count'];


don't mix the use session_register() and the $_SESSION
superglobal - in fact just use the $_SESSION superglobal
and forget session_reigster completely i.e.
you can just do:

if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
}

$_SESSION['count']++;



Any help will be appriciated!


HTH (I might need correcting on some of the details - anyone
care to chip in?)



Thanks
SP



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



[PHP] Re: WAMP Performance Tuning

2005-08-04 Thread JM
I'm quoting out a system for a Windows/Apache/PHP/MySQL
database-driven web application I've written. I've never gotten too
deep into determining what is the actual performance bottleneck in
this scenario. Is it the disk or the RAM?

I expect about 75-100 users during business hours. 90% will be in the
LAN and 10% will go over the WAN.

I'm wondering if I can get good performance out of a small system with
2GB RAM, 1GBps NIC, and a SATA disk or three spanned.

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



Re: [PHP] Interesting Referer behaviour- how to copy it?

2005-08-04 Thread Jochem Maas

Dotan Cohen wrote:

I creating a out.php file that will record clicks, and the redirect
the user to the site that he wanted. I am currently using
header(Location: $url); which works as expected. The only problem
is, that the browser does not send $HTTP_REFERER info to the recieving
site.

However, that particular site is also linking to me via a out.php
file, and the browser DOES set $HTTP_REFERER on my site. So I've been
googleing for two days, and came up with this: There is a site that
displays the server reesponse of any server. So I put both of our
out.php files to the test. First, his server response:
HTTP/1.1 302 Found
Connection: close
Date: Thu, 04 Aug 2005 15:19:01 GMT
Location: http://lyricslist.com
Server: Apache/2.0.50 (FreeBSD) PHP/5.0.0
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Thu, 04 Aug 2005 15:32:32 GMT
Client-Response-Num: 1
X-Powered-By: PHP/5.0.0


he runs php5, you run php4 - is the following set on his server perchance?:

echo $_SERVER['HTTP_REFERER'];
//or
echo getenv(HTTP_REFERER);

note that $HTTP_REFERER is depreciated in php5.
also the freeBSD box may have a firewall that is stripping the referer header
- freeBSD is the paranoid man's *nix of choice after all - at least all the
security freaks I know prefer it.

actually I did a bit of googling and there is a slim possiblity that the
firewall software on your PC is munging the referer header - try turning it off

also proxy servers may be stripping the header.



This redirects to lyricslist.com and correctly sets the $HTTP_REFERER
variable. Now, my server response:
HTTP/1.1 302 Found
Connection: close
Date: Thu, 04 Aug 2005 15:39:25 GMT
Location: http://lyricslist.com
Server: Apache/1.3.33 (Unix) mod_auth_passthrough/1.8
mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.11 FrontPage/5.0.2.2635
mod_ssl/2.8.22 OpenSSL/0.9.7a
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Thu, 04 Aug 2005 15:39:29 GMT
Client-Response-Num: 1
X-Powered-By: PHP/4.3.11

This just does not set the $HTTP_REFERER variable! The referer
variable is even set to the original page that linked to out.php, and
not out.php itself! I have tried in IE 6.x, Firefox 1.0.6, Pheonix 0.7
(remember that!), and Opera 8.0. What could be the difference?

Thanks to all who rack thier brains on this one! It's been a fruitless
two days for me...

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/118/chumbawamba.php
Chumbawamba Song Lyrics



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



Re: [PHP] Interesting Referer behaviour- how to copy it?

2005-08-04 Thread Dotan Cohen
On 8/5/05, Jochem Maas [EMAIL PROTECTED] wrote:
 he runs php5, you run php4 - is the following set on his server perchance?:
 
 echo $_SERVER['HTTP_REFERER'];
 //or
 echo getenv(HTTP_REFERER);
 
 note that $HTTP_REFERER is depreciated in php5.
 also the freeBSD box may have a firewall that is stripping the referer header
 - freeBSD is the paranoid man's *nix of choice after all - at least all the
 security freaks I know prefer it.
 
 actually I did a bit of googling and there is a slim possiblity that the
 firewall software on your PC is munging the referer header - try turning it 
 off
 
 also proxy servers may be stripping the header.
 

Thanks, Jochem, for looking into this. I just this minute figured out
my mistake- I was typing in the address out.php into the browser,
because I was expecting the referer to be out.php. But, the referer
that is sent is the page that LINKS to out.php!!  As there was nothing
linking to it, there was no referer! I'm now digging a deep hole to
bury myself in...

Dotan
http://lyricslist.com/lyrics/artist_albums/137/crosby_stills_and_nash.php
Crosby, Stills And Nash Song Lyrics

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



Re: [PHP] Interesting Referer behaviour- how to copy it?

2005-08-04 Thread Jochem Maas

Dotan Cohen wrote:

On 8/5/05, Jochem Maas [EMAIL PROTECTED] wrote:


he runs php5, you run php4 - is the following set on his server perchance?:

echo $_SERVER['HTTP_REFERER'];
//or
echo getenv(HTTP_REFERER);

note that $HTTP_REFERER is depreciated in php5.
also the freeBSD box may have a firewall that is stripping the referer header
- freeBSD is the paranoid man's *nix of choice after all - at least all the
security freaks I know prefer it.

actually I did a bit of googling and there is a slim possiblity that the
firewall software on your PC is munging the referer header - try turning it off

also proxy servers may be stripping the header.




Thanks, Jochem, for looking into this. I just this minute figured out
my mistake- I was typing in the address out.php into the browser,
because I was expecting the referer to be out.php. But, the referer
that is sent is the page that LINKS to out.php!!  As there was nothing
linking to it, there was no referer! I'm now digging a deep hole to
bury myself in...


have a spade on me my friend ;-)



Dotan
http://lyricslist.com/lyrics/artist_albums/137/crosby_stills_and_nash.php
Crosby, Stills And Nash Song Lyrics



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



[PHP] Re: strip out too many newlines

2005-08-04 Thread Al

Sebastian wrote:
im working on a comment/forum app and when a user enters too many 
carriage returns i want to remove them before insert to db.


example, user input:

-snip-
[quote=user]
foo
[/quote]

bunch of extra lines

more text...
-snip-


I to change to:

[quote=user]foo[/quote]

more text...

i try this regexp:

$message = 
preg_replace('#(\[quote(=(quot;||\'|)([^\]]*)\\3)?\])\s+#i', \\1\n, 
$_POST['message']);


doesn't remove / replace anything.
I need for it to work when they use [quote=xx] or [quote] and ends with 
[/quote]

any help?




$str= preg_replace(%(\r\n|\r|\n)%, \n, $str);

$str= preg_replace(%\n\n+%, \n\n, $str);//max 2 \n

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



[PHP] Re: WAMP Performance Tuning

2005-08-04 Thread Matthew Weier O'Phinney
* JM [EMAIL PROTECTED]:
 I'm quoting out a system for a Windows/Apache/PHP/MySQL
 database-driven web application I've written. I've never gotten too
 deep into determining what is the actual performance bottleneck in
 this scenario. Is it the disk or the RAM?

 I expect about 75-100 users during business hours. 90% will be in the
 LAN and 10% will go over the WAN.

 I'm wondering if I can get good performance out of a small system with
 2GB RAM, 1GBps NIC, and a SATA disk or three spanned.

You don't indicate how many queries are made on a given page, how much
data is handled, etc., Without seeing some code, it's hard to say what
the bottleneck for performance will be.

I've done some fairly critical stuff that, because I took the time to
optimize the database, optimize how much data gets displayed at a given
time (pagination is a *good* thing), streamlined the code to minimize
file and database calls, and setup the box to only run what was
necessary for serving pages, I was able to get away with using a
sub-400Mhz box with 384MB of RAM and a 20GB drive (this was a LAMP
setup). And it performed well, even with decent user load.

Disk calls are always more expensive than RAM calls -- but if you're
hitting a database, you're hitting the disk anyways (unless the queries
are getting cached). Run benchmarks, and try to minimize the number of
file calls and database calls to what is absolutely necessary.

Consider dumping Windows for a Linux flavor, or one of the BSDs. You can
tune these better to only run the services needed for the web stack
(Apache, MySQL, cron, firewall, formail/msmtp/sendmail). 

Because of the shared-nothing architecture of PHP, you really don't need
heavy hitting boxes in order to get good performance. They don't hurt,
but they're not necessary.

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

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