Re: [PHP] Socket error connecting to mySQL

2003-02-04 Thread Jason Wong
On Friday 21 February 2003 15:49, Bryan Lipscy wrote:
 $db= @mysql_pconnect ( $DB_HOST , $DB_USER , $DB_PASS );
 @mysql_select_db ( $DB_DB )  or die ( DATABASE ERROR!.mysql_error() );

 Returns DATABASE ERROR!Can't connect to local MySQL server through
 socket '/tmp/mysql.sock' (2)

 MySQL server exists on a Win2ksp3 box.
 Apache with PHP 4.3.0 exists on a Slackware 8.1 box.

 All parameters are correct.
 Boxes can see each other.
 All php scripts work when run on the Win2k box.


 Any ideas why connecting to php/mysql would throw this error?

Search the archives or search the mysql list archives.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Loose bits sink chips.
*/


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




Re: [PHP] Socket error connecting to mySQL

2003-02-04 Thread Nick Kordas -: Wildthing Communications
Hi
I think that you mysql server on your Win box is set to only connect from
localhost and not from an outside host which is what its trying to do.



-
Regards
Nick Kordas BE(hons) Ph.D(usyd)
Wildthing Communications
PH:  07 5481 6064
Mob: 0421 556847
ICQ# 64851373
PO Box 1841
SUNSHINE PLAZA
Maroochydore
QLD 4558
http://www.wildcomm.net


~~~
How can a species, that can create machines to communicate, fail to
communicate amongst themselves ?

~~~
This email and any files transmitted with it may be legally privileged and
confidential. If you
are not the intended recipient of this email, you must not disclose or use
the information contained
in it. If you have received this email in error, please notify us by return
email and permanently
delete the document.

~~~

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 6:12 PM
Subject: Re: [PHP] Socket error connecting to mySQL


 On Friday 21 February 2003 15:49, Bryan Lipscy wrote:
  $db= @mysql_pconnect ( $DB_HOST , $DB_USER , $DB_PASS );
  @mysql_select_db ( $DB_DB )  or die ( DATABASE ERROR!.mysql_error() );
 
  Returns DATABASE ERROR!Can't connect to local MySQL server through
  socket '/tmp/mysql.sock' (2)
 
  MySQL server exists on a Win2ksp3 box.
  Apache with PHP 4.3.0 exists on a Slackware 8.1 box.
 
  All parameters are correct.
  Boxes can see each other.
  All php scripts work when run on the Win2k box.
 
 
  Any ideas why connecting to php/mysql would throw this error?

 Search the archives or search the mysql list archives.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Loose bits sink chips.
 */


 --
 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] php3 + HTTP_POST_FILES

2003-02-04 Thread electroteque
is there a way to get this variable in php3 for some reason i cannot acess
it ?



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




Re: [PHP] POST_with_PHP_--_please_help_!

2003-02-04 Thread Krzysztof Dziekiewicz
 That's right, but with curl it's not a true redirection: you just print the content 
of the target page, you don't redirect to the page.

 What I need is automated forms, that send the same data as forms but without user 
interaction.
 I can't use javascript to automatically send a form.


Maybe something like this:

$fs = fsockopen(target.com,80);
fputs($fs, '
POST /index.html HTTP/1.1
Accept: */*
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: target.com
Content-Length: 41

data1=value1data2=value2
');

Your script sends data to http://target.com/index.html

At the end you can do location.
That is all you can do.


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




[PHP] Re: Which link was selected?

2003-02-04 Thread Götz Lohmsnn
Karina S schrieb:
 Hi,
 
 I put pictures from a database ont the page about my products. If the user
 click on a picture I want to give a detailed description about the product.
 But how can I get, which picture was selected?
 
 Thanks
 
 

if your images are named like
PicNr000.png, PicNr001.png, PicNr002.png, ..
and you have about 30 pics, do something like:

?php
  $pic_count=0; $max_pic=30;
  if (isset($picnr)  ($picnr=$pic_count)  ($picnr$max_pic)) {
// print out the info of image number $picnr
?
...
?php
  }
?
...
?php
  while ($pic_count$max_pic) {
?
...
a href=?php echo $PHP_SELF.?picnr=.$pic_count; ?
  img src=PicNr000.png border=0 name=PicNr000
/a
...
?php
  $pic_count++;
  }
?

than the script itself is called with the number of the pic ...
this is not a pretty way but it should work ...




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] Which link was selected?

2003-02-04 Thread Götz Lohmsnn
Leonard Burton schrieb:
 Greetings,
 
 You ought to make your link something like
 www.foo.com/products.php?autoid=105.  and then make a query on your page
 that displays the pics based on an autoincrement number in your table.
 
 You ought to be able to make the code something like:
 
 //Display link for product
 print a href=products.php?autoid=.$row[autoid].;
 print img src=images/.$row[product_pic]./a;
 
 
 ON your products.php page youd want to have code something like;
 
 if ($auto)
 {
   $result = select * from product_info where autoid=$autoid
 
   if ($result)
   {
   while ($row = mysql_fetch_array($result))
   {
   $stuff=$row[stuff];
   $stuff1=$row[stuff1];
   $stuff2=$row[stuff2];
   $stuff3=$row[stuff3];
   }
   mysql_free_result($result);
   print All that stuff here;
   }
   else
   {
   include product_display_page.php;
   }
 
 I hope it helps.
 
 Leonard.
 

ups .. someone was quite faster than me in answering ... and it looks quit
better than my way ... the only thing I want to note ... use  arround values
of HTML tags ;-)

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] How to compare 2 strings

2003-02-04 Thread Krzysztof Dziekiewicz
 How to compare 2 strings in PHP
 I hawe 2 array where I have only string values some values in both arrays
 are same but if command don't send me a good result.
 e.g

 foreach ($array1 as $a1) {
   foreach($array2 as $a2){
if ($a1 == $a2) echo good;   //never system send me a good result
  else echo bad;
   }
 }

If you have in one array test and in the other also test
(not Test nor TEST but test) it must work.

By the way in
   else echo bad;
you have not got a quotation mark after bad.


-- 
Krzysztof Dziekiewicz


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




[PHP] Re: Socket error connecting to mySQL

2003-02-04 Thread Götz Lohmsnn
Bryan Lipscy schrieb:
 $db= @mysql_pconnect ( $DB_HOST , $DB_USER , $DB_PASS );
 @mysql_select_db ( $DB_DB )  or die ( DATABASE ERROR!.mysql_error() );
 
 Returns DATABASE ERROR!Can't connect to local MySQL server through
 socket '/tmp/mysql.sock' (2)
 
 MySQL server exists on a Win2ksp3 box.
 Apache with PHP 4.3.0 exists on a Slackware 8.1 box.
 
 All parameters are correct.
 Boxes can see each other.
 All php scripts work when run on the Win2k box.
 
 
 Any ideas why connecting to php/mysql would throw this error?
 
 Bryan
 

seems that PHP is trying to connect to a mysql database on localhost,
instead it is on the win2k box ... so maybe the $DB_HOST value is wrong ?


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] safe mode problem

2003-02-04 Thread Marek Kilimajer
I recomend you use ftp functions to upload the script to your site (from 
the generating file). If you only use normal filesystem function, the 
newly created file will get the owner of the http server.

gurvinder singh wrote:

and how can i be root from a php script?

i want chown from the script itself which created the page.

-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 03, 2003 12:39 PM
To: Gurvinder Singh
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] safe mode problem


what you did should work (you must be root to change owner). You can use
-R switch to change owner recursively

Gurvinder Singh wrote:

 

hi
i create a php page dynamically in my php script. this page include one of
my other php file. when i run the newly created script i get this error

Warning: SAFE MODE Restriction in effect. The script whose uid is 48 is not
allowed to access file.php owned by uid 831

Is there a way to handle this.

i even tried chown to change the newly created file's owner to be 831 but
   

it
 

doesnt seem to work

Thanks  Regards
Gurvinder





   




 



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




Re: [PHP] Re: Etiquette

2003-02-04 Thread Gtz Lohmsnn
Luke Woollard schrieb:
 Chill out. It's only PHP programming.
 :)
 
 
 -Original Message-
 From: Philip Olson [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, 4 February 2003 2:56 PM
 To: Chris Shiflett
 Cc: Sunfire; Todd Barr; [EMAIL PROTECTED]
 Subject: [PHP] Re: Etiquette
 
 
 On Mon, 3 Feb 2003, Chris Shiflett wrote:
 
 
--- Philip Olson [EMAIL PROTECTED] wrote:

No offense Sunfire but I don't think you're ready to
be answering questions.

Please try to be a little more kind. While his answer does
have problems, his helpful attitude is a good thing.

Whenever someone's answer can potentially do more harm than
good (by misleading the original poster, as was a risk in
this case), it might be better just to help correct the
problems or offer a more proper solution. Degrading the
person who erred does not really add any additional
benefit.
 
 [snip]
 
 I've seen his questions and felt he's not ready to provide
 answers.  Facts are facts, we all start somewhere.  Through
 time Sunfire will learn PHP and provide useful replies. I
 don't feel my reply was degrading.
 
 You have cut-n-pasted my reply to be somewhat out of context.
 At any rate, thanks, but I disagree.  I may have been a
 little harsh but chalk it up as frustration towards some
 of the replies I see on this list.  A lot of PHP newbies try
 too hard to help so Sunfire, I am sorry if I offended you
 but *my opinions* still stand.  Good luck with learning PHP.
 
 Regards,
 Philip

no answer might be realy bad ... maybe it depends on who needs it,
and if it is usefull, but this is just another question.
I by myself be more depressed by questions which lead me to the
answer RTFM or even they seem to be unable to search through the
forums database. Just like I ask to not solve the puzzle by own brain,
and than being unhappy that none is answering ...

but ... we all started somewhere ...


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] restricting acces to files

2003-02-04 Thread Shams
Hi,

i've written a secure PHP login script which will allow users to login to a
directory such as this:

smezone.com/members/index.php

however, how do I restrict people from accessing HTML files in that
directory (which they can easily do so by typing the URL into their
browser), such as:

smezone.com/members/document1.html

?

Since its a regular HTML files (and we have lots), I can't check whether the
user has a valid session as I would do in a PHP file.

Thanks for any help!

Shams



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




Re: [PHP] restricting acces to files

2003-02-04 Thread Jason Wong
On Saturday 01 February 2003 17:28, Shams wrote:
 Hi,

 i've written a secure PHP login script which will allow users to login to a
 directory such as this:

 smezone.com/members/index.php

 however, how do I restrict people from accessing HTML files in that
 directory (which they can easily do so by typing the URL into their
 browser), such as:

 smezone.com/members/document1.html

 ?

 Since its a regular HTML files (and we have lots), I can't check whether
 the user has a valid session as I would do in a PHP file.

You can use HTTP authentication, but that's probably not what you want since 
you went through the trouble of creating a php login system. There are two 
ways you can go about this (there may be more that I'm not aware of):

1) Move your restricted HTML files to outside of the DOCUMENT ROOT of your 
webserver. And have PHP include() those files.

2) Set your webserver to interpret HTML files as PHP and include your 
authentication code using auto_prepend_file directive in php.ini.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
sticktion
*/


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




[PHP] Re: Make an MDB File on the Fly

2003-02-04 Thread hboyce
I have recently been investigating exporting data from MySQL 
database to use with MS Word mail merge.  The mail merge will 
accept a text file with separators of tab or comma - should be easy 
to produce using PHP. 

Hilary


On 3 Feb 2003 at 12:49, Matt Babineau wrote:

 I have a client that currently gets MDB exports of their database to
 run reports and mail merges with. Has anyone heard of or have any idea
 of how to make an MDB (Access Data File) on the file from PHP or any
 other scripting language?
 
 Thx-
 
 Matt
 

--
Hilary Boyce
Enterprise AB Ltd
[EMAIL PROTECTED]
Tel: 01727 751455



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




[PHP] Security question with PHP on Unix / Linux.

2003-02-04 Thread Ananth Kesari
Hi,

I am working on porting PHP onto NetWare.

At this point of time, I am trying to understand the way security is
implemented for PHP on Unix / Linux. I mean, how are the different users
distinguished from Unix / Linux. Do they get to login into the Unix /
Linux system? Do they have separate data space for each user? What is
the API that is used to login to Unix / Linux. User may enter his
username and password on the browser, but how do they get translated
onto the Unix / Linux box?

Your help in this is appreciated.

Thanks,
Ananth.


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




[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Shams schrieb:
 Hi,
 
 i've written a secure PHP login script which will allow users to login to a
 directory such as this:
 
 smezone.com/members/index.php
 
 however, how do I restrict people from accessing HTML files in that
 directory (which they can easily do so by typing the URL into their
 browser), such as:
 
 smezone.com/members/document1.html
 
 ?
 
 Since its a regular HTML files (and we have lots), I can't check whether the
 user has a valid session as I would do in a PHP file.
 

if you are using linux  apache ... just use a .htaccess file like the one below

AuthUserFile /usr/home/.htpasswd
AuthName Secret Area
AuthType Basic
FilesMatch \.(gif|jpe?g|png|htm|html)$
  require valid-user
/FilesMatch

with this you restrict access only to users listet in the /usr/home/.htpasswd
files which look like

user1:668c1d6Hc6yCg
test:85FRBo8cHrAZc

the code after : is a MD5 key
the FilesMatch mean that all files ending with .gif,.html,.. is restricted and
.php is not.

in a php file you now can read the authentications from a user and compare it
with the /usr/home/.htpasswd entrys.

?php
  ...
  if (!isset($PHP_AUTH_USER)) {
// $PHP_AUTH_USER is empty ... no login
header('WWW-Authenticate: Basic realm=My Private Stuff');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
  }
  // If not empty, check authentication ...
  else {
if ($PHP_AUTH_USER==$username  $PHP_AUTH_PW==$mypasswd) {
  echo PYour Login is OK;
?
...
?php
} else {
  echo Pwrong login !;
}
  }
?

note that the the /usr/home/.htpasswd file must include all usernames and
passwords as MD5. You can create a line of this file with:

?php
  echo $username:.md5($mypasswd);
?

maybe you also can use mod_auth_db ... but this is apache specific so
take a look at http://httpd.apache.org/docs/mod/core.html



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] PHP Sessions Not Saving

2003-02-04 Thread Jonathan Wright
At around Tue, Feb 04, 2003 at 02:06:35PM +0800, Jason Wong constructed the following 
notation:
  
   Recompile, why?  How about a link?
  
   ln -s /sbin/sendmail /usr/sbin/sendmail
 
  During the ./configure part of the installation, PHP checks for
  sendmail, but only in /sbin/sendmail. If it doesn't find it, the
  function mail() isn't complied in.
 
  I just get 'call to undefined function mail()' in x/y.php on z.
 
 But according to the manual configure should check both locations?

I can't remember where i saw it (i think it was on a mailing list), but
someone said it'll only check /sbin/sendmail, which seams to be the
case. sendmail.path is set to '/usr/sbin/sendmail' in php.ini, but that
doesn't has an effect.

well, either way it hasn't been compiled in so a recompile will be
needed. it's only a 10 minute job anyway. 

-- 
jonathan wright  [EMAIL PROTECTED] | www.djnauk.co.uk
--
life has no meaning unless we can enjoy what we've been given

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




[PHP] Re: How to check for refresh in PHP

2003-02-04 Thread Goetz Lohmann
Pag schrieb:
 
 Hi,
 
 I have a news site where i want to track how many visits or reads
 each individual news has. I have a main list with all the titles, then
 clicking on them shows the details of the specific news, only then the
 counter for that particular news is increased. The problem is, if the
 user does a refresh while at the details, the counter is increased
 again. How can i prevent this from happening?
 
 I thought it would be something like a unique counter problem, but
 its like having a counter problem for each news i have. :-P
 
 What would be nice, if it exists, is to check if the user is doing a
 refresh or coming from somewhere else. If its a refresh, the counter
 would simply not increase. That would be sufficient to keep the
 i-want-my-news-to-have-the-higher-number-of-visitors author, from having
 his way.
 

maybe store the counter in a mysql database including the IP of the viewer
and the timestamp when he visited this page. If he shows the news the first
time store the IP with timestamp and the viewd news in the database.
If he view it again first check if this IP viewed this news lately.
Remove all IP which been older than maybe 8 hours afterwards.

Another option is to store this info in cookies or sessions ...

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Problem with include PHP 4.3.0

2003-02-04 Thread Jean-Pierre Gallou
	Hi,

I have problems with relative paths and 4.3.0. Include() do not seem to 
work the same way in 4.3.0 and 4.2.1. Consider this test:

test/
 |- testinclude.php   ? include ('inc/inc1.php'); ?
 |- inc/
|- inc1.php   ? include ('inc/inc2.php'); ?
|- inc2.php   OK

With PHP 4.2.1, http//my.server.com/test/testinclude.php works OK.
With 4.3.0, I get:
  Failed opening '/inc/inc2.php' for inclusion \
   include_path='.:..:/usr/local/php-4.3.0/lib/php') in \
   /usr/local/www/htdocs/tests/inc/inc1.php on line 1

With a modified inc1.php:
  ? include ('inc2.php'); ?
this test is OK with 4.3.0, but gives an error with 4.2.1.

It appears that paths are relative
- to the main script in 4.2.1,
- to the including script in 4.3.0
   (but .. in include_path does not work).

I can't seem to be able to write something OK for both versions (except 
 if giving full pathnames). By the way, this is on Solaris, and 
safe_mode if off.

Any suggestion?


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



[PHP] Variable objects?

2003-02-04 Thread Leif K-Brooks
I'm planning to use variable objects in a new project I'm working on. 
The problem is, I can't find one page of documentation on them, so I 
can't be sure if I'm going to be using an accidential feature that will 
disappear.  As an example of them working, the following outputs In 
a_class.:
?php
class a_class{
   function a_class(){
   echo 'In a_class.';
   }
}
$foo = 'a_class';
new $foo();
?

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.



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



[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
 Shams schrieb:
 
Hi,

i've written a secure PHP login script which will allow users to login to a
directory such as this:

smezone.com/members/index.php

however, how do I restrict people from accessing HTML files in that
directory (which they can easily do so by typing the URL into their
browser), such as:

smezone.com/members/document1.html

?

Since its a regular HTML files (and we have lots), I can't check whether the
user has a valid session as I would do in a PHP file.

 

maybe take a look at:

http://hotwired.lycos.com/webmonkey/00/05/index2a_page3.html?tw=programming

but note that normaly $PHP_AUTH_PW is the password in clear text, but the
.htaccess file stores it as a md5 key!



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] include_path problem on RH 8

2003-02-04 Thread Paul
Using RH 8, php 4.2.2, Apache 2.0, I'm getting (from phpinfo) a reported include path 
of .:/usr/share/pear no matter what I put in the include_path in php.ini. The info 
also says it's using /etc/php.ini as the config file.

And, yes, I've restarted Apache many times. I've tried many variations on the path 
syntax, and settled on the simplest possibility, but it still doesn't pick it up. At 
the moment, /usr/share/pear is not in that statement.

Anybody got any good ideas?

TIA,
Paul

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




[PHP] Converting links in strings

2003-02-04 Thread Randum Ian
Hi all,

Please can someone direct me to the correct function that changes 
http://www.foo.com to a href=http://www.foo.com;http://www.foo.com/a 
for any occurence in a string.

Cheers, Ian.


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Goetz Lohmann
Jean-Pierre Gallou schrieb:
 Hi,
 
 I have problems with relative paths and 4.3.0. Include() do not seem to
 work the same way in 4.3.0 and 4.2.1. Consider this test:
 
 test/
  |- testinclude.php   ? include ('inc/inc1.php'); ?
  |- inc/
 |- inc1.php   ? include ('inc/inc2.php'); ?
 |- inc2.php   OK
 
 With PHP 4.2.1, http//my.server.com/test/testinclude.php works OK.
 With 4.3.0, I get:
   Failed opening '/inc/inc2.php' for inclusion \
include_path='.:..:/usr/local/php-4.3.0/lib/php') in \
/usr/local/www/htdocs/tests/inc/inc1.php on line 1
 
 With a modified inc1.php:
   ? include ('inc2.php'); ?
 this test is OK with 4.3.0, but gives an error with 4.2.1.
 
 It appears that paths are relative
 - to the main script in 4.2.1,
 - to the including script in 4.3.0
(but .. in include_path does not work).
 
 I can't seem to be able to write something OK for both versions (except
  if giving full pathnames). By the way, this is on Solaris, and
 safe_mode if off.
 
 Any suggestion?
 

Failed opening '/inc/inc2.php'

looks like that he try an absolute path from the root / ... maybe try something
like

include('./inc/inc1.php');
 ^^

instead. The include_path tells PHP only where to look for the file

.   = same directory
..  = parent directory

if it is a single file or relativ path, but '/inc/inc2.php' is an absolute path
from the root ...


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Variable objects?

2003-02-04 Thread Goetz Lohmann
Leif K-Brooks schrieb:
 I'm planning to use variable objects in a new project I'm working on.
 The problem is, I can't find one page of documentation on them, so I
 can't be sure if I'm going to be using an accidential feature that will
 disappear.  As an example of them working, the following outputs In
 a_class.:
 ?php
 class a_class{
function a_class(){
echo 'In a_class.';
}
 }
 $foo = 'a_class';
 new $foo();
 ?
 

take a look at
http://www.php.net/manual/en/ref.classobj.php

;-)

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Converting links in strings

2003-02-04 Thread Goetz Lohmann
Randum Ian schrieb:
 Hi all,
 
 Please can someone direct me to the correct function that changes 
 http://www.foo.com to a href=http://www.foo.com;http://www.foo.com/a 
 for any occurence in a string.
 
 Cheers, Ian.
 

do you wish convert a string in a link ??? try:

?php
  echo a href=$string1$string1/a;
?

or a link in a string ?

?php
preg_match('/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\//i',
$link, $string)
?

with

$string[1]; // protocol type (http,https,ftp)
$string[2]; // hostname (domain)
$string[3]; // port if available like 80 for http

... please be more precise in your question !



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Getting key of value added to array with []?

2003-02-04 Thread Leif K-Brooks
Is there any way to get the key of an element added to an array with []? 
I need to use this for a reference to it.  The only idea I can think of 
is to foreach through the array and use the last key looped through, but 
that seems very dirty.


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



[PHP] Re: include_path problem on RH 8

2003-02-04 Thread Goetz Lohmann
Paul schrieb:
 Using RH 8, php 4.2.2, Apache 2.0, I'm getting (from phpinfo) a reported include 
path of .:/usr/share/pear no matter what I put in the include_path in php.ini. The 
info also says it's using /etc/php.ini as the config file.
 
 And, yes, I've restarted Apache many times. I've tried many variations on the path 
syntax, and settled on the simplest possibility, but it still doesn't pick it up. At 
the moment, /usr/share/pear is not in that statement.
 
 Anybody got any good ideas?
 
 TIA,
 Paul


don't panic ... the last part /usr/share/pear is the path where the command
line version of PHP resists and is always there also without an include_path
entry of php.ini


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] mail function

2003-02-04 Thread Dale
I am trying to configure the php.ini file so that I can use the mail
function in my code. The problem I am facing is that I get the following
error message when I try to run my code:

Warning: mail() [function.mail]: SMTP server response: 550 Relaying is
prohibited

Any suggestions?

Thanks,
Dale



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




[PHP] Re: include_path problem on RH 8

2003-02-04 Thread Paul
Thanks for the info. But I notice that I didn't really state the essence of my 
problem, which is that I can't get PHP to locate any include directory I put in the 
php.ini, thus no files I want to include get included.

Paul schrieb:

 Using RH 8, php 4.2.2, Apache 2.0, I'm getting (from phpinfo) a reported include 
path of .:/usr/share/pear no matter what I put in the include_path in php.ini. The 
info also says it's using /etc/php.ini as the config file.
 
 And, yes, I've restarted Apache many times. I've tried many variations on the path 
syntax, and settled on the simplest possibility, but it still doesn't pick it up. At 
the moment, /usr/share/pear is not in that statement.
 
 Anybody got any good ideas?
 
 TIA,
 Paul



don't panic ... the last part /usr/share/pear is the path where the command line 
version of PHP resists and is always there also without an include_path entry of 
php.ini

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




[PHP] Re: Getting key of value added to array with []?

2003-02-04 Thread Goetz Lohmann
Leif K-Brooks schrieb:
 Is there any way to get the key of an element added to an array with []?
 I need to use this for a reference to it.  The only idea I can think of
 is to foreach through the array and use the last key looped through, but
 that seems very dirty.
 

$foo[]='bar';

will insert 'bar' as the last item of the array $foo. To get this you might
use

$erg = key($foo); // the key of the current element

or

$erg = pos($foo); // the value of the current element

maybe if something happend between the insertion first head to the last item

$erg = end($foo); // get the last element of array $foo

instead of foreach you can also use array_walk($arr, 'func');




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: mail function

2003-02-04 Thread Goetz Lohmann
Dale schrieb:
 I am trying to configure the php.ini file so that I can use the mail
 function in my code. The problem I am facing is that I get the following
 error message when I try to run my code:
 
 Warning: mail() [function.mail]: SMTP server response: 550 Relaying is
 prohibited
 

this is an error of sendmail not from PHP ! ... take a look at the
/etc/mail/sendmail.cf or /etc/mail/access of your box and enable
relaying for maybe localhost ...


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Jean-Pierre Gallou
Thank you for your reply. Goetz Lohmann wrote :


Failed opening '/inc/inc2.php'


Yes, I don't understand the reason of the leading slash in the error 
message.

... maybe try something like

include('./inc/inc1.php');
 ^^


same thing: Failed opening './inc/inc2.php' for inclusion


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




Re: [PHP] tracking bulk email

2003-02-04 Thread Lowell Allen
 From: Kevin Stone [EMAIL PROTECTED]
 
 - Original Message -
 From: Lowell Allen [EMAIL PROTECTED]
 
 I've added an email feature to a content management system that will send
 plain text email to about 1400 contact addresses. Each contact is sent a
 separate email with the contact name and address in the To: header. It
 works fine to small test lists, but hasn't been tested with a large list.
 
 Although I think list posts should only pose one question, I have two:
 
 (1) My client is nervous about the script failing mid-list and not being
 able to determine which contacts were sent mail. I need to build this
 check into the content management system. I could write a flag to the
 database every time mail() returns true, but that would mean 1400 database
 updates! If I instead append to a variable each time through the mail()
 loop, I'll lose the record if the script times out. Can anyone suggest how
 to record the position in a loop if a time out or failure occurs?
 
 (2) In order to avoid the script timing out, I'm counting the number of
 mail() attempts and calling set_time_limit(30) every 50 attempts to
 provide another 30 seconds of script execution time.

[snip]
 
 In response to your first question.  File stores are something a computer
 does very very fast (might want to add some error catching to this)..
 
 $i=0
 while() {
 count_index($i)
 $i++;
 }
 
 function count_index ($i) {
 $fp = fopen('count.txt', 'w');
 fwrite($fp, $i);
 fclose($fp);
 }

Thanks, Kevin. I've put a counter in place within my mail loop. It seems to
slow the process, but perhaps not too much. And thanks to Mark McCulligh for
describing a system for sending about 1500 messages that's called with a
cron tab and writes to a db after each mail. And thanks to Chris Hayes for
pointing to relevant list archives. My system seems to be working, but it's
so slow that I'm going to look at using a cron tab and saving everything to
a database for easier reference in case of failure mid-list.

--
Lowell Allen


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




Re: [PHP] Getting key of value added to array with []?

2003-02-04 Thread 1LT John W. Holmes
 Is there any way to get the key of an element added to an array with []?
  I need to use this for a reference to it.  The only idea I can think of
 is to foreach through the array and use the last key looped through, but
 that seems very dirty.

If elements are only being added with [], then you should be able to keep a
count as  you go.

Easy way would be to add it like this:

$array[$x++] = $your_value;

Then you'll have ($x-1) as the element just added, if you need it.

---John Holmes...


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




[PHP] Re: include_path problem on RH 8

2003-02-04 Thread Goetz Lohmann
Paul schrieb:
 Thanks for the info. But I notice that I didn't really state the essence of my 
problem, which is that I can't get PHP to locate any include directory I put in the 
php.ini, thus no files I want to include get included.
 
 Paul schrieb:
 
 
Using RH 8, php 4.2.2, Apache 2.0, I'm getting (from phpinfo) a reported include 
path of .:/usr/share/pear no matter what I put in the include_path in php.ini. The 
info also says it's using /etc/php.ini as the config file.

And, yes, I've restarted Apache many times. I've tried many variations on the path 
syntax, and settled on the simplest possibility, but it still doesn't pick it up. At 
the moment, /usr/share/pear is not in that statement.

Anybody got any good ideas?

TIA,
Paul
 


include_path = .:..:/mydir

using  around or left the ; infront ? No I don't think you are stupid but
sometimes someone don't realize the easyest things ...

what is in the error log of apache reported, enable the error_log in php.ini and
take a look at that ... is there any information when apache/php is started ?

maybe did you changed /etc/php.ini or something else ?

are there two lines in /etc/php.ini with include_path ?

at command line type
$ vim /etc/php.ini

search for include_path with
:/include_path/

search twice with
://

quit with
:q



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Goetz Lohmann
Jean-Pierre Gallou schrieb:
 Thank you for your reply. Goetz Lohmann wrote :
 
 Failed opening '/inc/inc2.php'
 
 
 Yes, I don't understand the reason of the leading slash in the error
 message.
 
 ... maybe try something like

 include('./inc/inc1.php');
  ^^
 
 
 same thing: Failed opening './inc/inc2.php' for inclusion
 


mhhh ... wait ... don't you wrote

test/
 |- testinclude.php   ? include ('inc/inc1.php'); ?
 |- inc/
|- inc1.php   ? include ('inc/inc2.php'); ?
|- inc2.php   OK

wich means that testinclude.php includes inc/inc1.php
and inc/inc1.php includes inc/inc2.php ?

the include is like a copy of the code from
inc/inc1.php into testinclude.php so that in the
first sighth it might be correct to call inc/inc2.php
instead of inc2.php.

But maybe the parser of PHP 4.3.0 is rewritten so that it
now parse it bottom up. That means that first the inclusion
of inc/inc2.php into inc/inc1.php will happen which
fails cause its in the same directory.

... I tried it on my server ... all went Ok ... strange ...

insert something like into inc1.php and inc2.php:

?php
   echo inc includedbr\n;
   echo br\n;
   $folder=dir('inc');
   // print out folder inc
   while($datei = $folder-read()) {
  echo $dateibr\n;
   }
   $folder-close();
   echo br\n;
?

maybe did it head anywhere else or did it show something like

inc included
inc included

.
..
inc1.php
inc2.php


.
..
inc1.php
inc2.php


???


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] authentication

2003-02-04 Thread ed

I don't think the process is an extra step at all. In fact, it's just a
trade off using one or the other. You can either login using php and a
database backend or just authenticate using .htaccess directives.

In my case (a few months back) what I was trying to do was offer up a
single login page for 500 or so different companies each having their own
directory on my server. Each directory is password protected via
.htaccess. They would all login using my php interface which would in turn
check the username and password for matching. Their database record would
also contain the URL to their directory on my server. After logging in I
tried to use a header call containing the username, password and URL but
it never quite worked although you can actually do it in the address bar
of the browser with ease. Theoretically it should work like a charm but I
never got the chance to investigate any further because I was rushed off
to the next Big Project.

Ed



On Mon, 3 Feb 2003, Chris Shiflett wrote:

  There is a way to supposedly do this by authenticating
  a username and password through php first through such
  methods as database lookups and then passing the
  username and password through $PHP_AUTH_USER and
  $PHP_AUTH_PW using the header() command to point to the
  URL of the .htaccess protected directory but I have
  never gotten it to work myself.
 
 The variables $PHP_AUTH_USER and $PHP_AUTH_PW are available
 to you when the user authenticates via HTTP basic
 authentication. Thus, the user has already had to type in
 the username and password into a separate window, which is
 what the original poster is trying to avoid.
 
 To then send the user to another URL and supply the
 authentication credentials in the URL itself just creates
 an unnecessary step.
 
  There isnt any PHP pages directed towards teh directory
  itself. Its is just a hard link to the protected areas. 
  Are there any functions that support it?
 
  Im googling now ;)
 
 I'm still having a bit of trouble interpreting your
 question, so Google might have a hard time, too. :-)
 
 If you are protecting static resources such as images and 
 HTML files with your Web server currently, the only way to
 protect these with PHP is to store them outside of the
 document root (so that your Web server cannot serve them
 directly) and serve them with PHP (using
 header(Content-Type: whatever)) once you have determined
 whether the user should be allowed to access the particular
 resource.
 
 Hopefully that can help refine your search.
 
 Chris
 
 -- 
 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] Bi-weekly pay period

2003-02-04 Thread bob parker
On Tue, 4 Feb 2003 11:17, Sarah Heffron wrote:
 I'm writing a quick little thing to act as a time clock since people are
 writing out by hand and it's not so accurate. It's basically click a button
 to clock in and click a button to clock out.

 What I also want to do is create a report (well I've already created the
 report) but I want to limit it to the current pay period. Our pay periods
 are biweekly. I was trying to think of a smart way to have php figure out
 what the current pay period is and I'm having a hard time figuring out if
 this is even possible or should I just tell it a years worth of pay period
 ranges for now.

 I figure something like, if the week # is even, use this past Sunday as the
 start date. If the week # is odd use the Sunday of the week before. Then
 figure out what date is 2 saturdays after whatever Sunday was selected.

 Any assistance appreciated.

 Sarah

Quite commonly back in the days when I wrote the odd payroll system (not in 
php though I have one such started), we used to simply create a table with 
the start and end dates for each fortnight.

Not clever, just a gross kludge, but nothing ever went wrong with it.

It also dealt with the Australian Income Tax complications which go as 
follows:

1. Income tax for employees is levied on the wages earned in cash through the 
year, there is no account of earnings accrued through an incomplete pay 
period at the end of the financial year.

2. Every 11 years a person on fortnightly pay will have 27 pays in the year 
and consequently higher earnings for that year. The ATO require that the 
fortnightly pay as you go deductions be adjusted to take that into account.

Complicated? If bullshit was weaponry the Australian Govt would have disarmed 
Iraq alone years ago.

Bob


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




php-general Digest 4 Feb 2003 13:44:09 -0000 Issue 1863

2003-02-04 Thread php-general-digest-help

php-general Digest 4 Feb 2003 13:44:09 - Issue 1863

Topics (messages 134199 through 134258):

list files in a dictory and its subdirectories
134199 by: Tomas Vorobjov
134202 by: Jason Sheets

Re: Help with classes (oop)
134200 by: Maxim Maletsky

Re: Bi-weekly pay period
134201 by: Jason Sheets
134258 by: bob parker

Re: PHP Sessions Not Saving
134203 by: Greg Donald
134212 by: Jason Wong
134218 by: nick.hostau.net
134236 by: Jonathan Wright

Knowing what page u came from...
134204 by: Mr. BuNgL3
134205 by: Leif K-Brooks

Using 404 instead of mod_rewrite
134206 by: Dennis Gearon
134214 by: Peter Janett
134215 by: Dennis Gearon

Re: php/mysql connection
134207 by: John W. Holmes

exec
134208 by: Nick Kordas  -: Wildthing Communications

Re: Etiquette
134209 by: Philip Olson
134210 by: Luke Woollard
134230 by: Götz Lohmsnn

Delete From Array
134211 by: Remon Redika
134216 by: Remon Redika

Thanks for help with classes
134213 by: Leonard Burton

Which link was selected?
134217 by: Karina S
134219 by: Leonard Burton
134225 by: Götz Lohmsnn
134226 by: Götz Lohmsnn

Socket error connecting to mySQL
134220 by: Bryan Lipscy
134221 by: Jason Wong
134222 by: Nick Kordas  -: Wildthing Communications
134228 by: Götz Lohmsnn

php3 + HTTP_POST_FILES
134223 by: electroteque

Re: POST_with_PHP_--_please_help_!
134224 by: Krzysztof Dziekiewicz

Re: How to compare 2 strings
134227 by: Krzysztof Dziekiewicz

Re: safe mode problem
134229 by: Marek Kilimajer

restricting acces to files
134231 by: Shams
134232 by: Jason Wong
134235 by: Götz Lohmsnn
134240 by: Götz Lohmsnn

Re: Make an MDB File on the Fly
134233 by: hboyce.eab.co.uk

Security question with PHP on Unix / Linux.
134234 by: Ananth Kesari

Re: How to check for refresh in PHP
134237 by: Götz Lohmsnn

Problem with include PHP 4.3.0
134238 by: Jean-Pierre Gallou
134243 by: Götz Lohmsnn
134252 by: Jean-Pierre Gallou
134256 by: Götz Lohmsnn

Variable objects?
134239 by: Leif K-Brooks
134244 by: Götz Lohmsnn

include_path problem on RH 8
134241 by: Paul
134247 by: Götz Lohmsnn
134249 by: Paul
134255 by: Götz Lohmsnn

Converting links in strings
134242 by: Randum Ian
134245 by: Götz Lohmsnn

Getting key of value added to array with []?
134246 by: Leif K-Brooks
134250 by: Götz Lohmsnn
134254 by: John W. Holmes

mail function
134248 by: Dale
134251 by: Götz Lohmsnn

Re: tracking bulk email
134253 by: Lowell Allen

Re: authentication
134257 by: ed.home.homes2see.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---
hey!

this is the code I'm using to get into array all filenames in a directory:


$mydir = mydir //the directory name
$output_file = fopen($data_file, w);
$begin = ?
\$files_name = array(;

fwrite($output_file, $begin);

$output_file = fopen($data_file, w);
if ($handle = opendir('./$mydir/')) {
while (false !== ($filename = readdir($handle))) {
if ($file != .  $filename != ..) { // !is_dir($filename)
can be added
$element = \$filename\,;
fwrite($output_file, $element);
}
}
closedir($handle);
}
fwrite($output_file,\\);\r\n);
fwrite($output_file, ?);
fclose($output_file);

chmod($output_file, 0777); //to preview

echo the list has been succesfully created;


now, how can I make the script to look into subdirectories of ./$mydir/
and output also those filenames into the same or another array?

thank you

---End Message---
---BeginMessage---
An easy way would be to to convert your code to a function and use
recursion with an is_dir conditional.

Here is a quick example, there are also a few examples in the user notes
at the PHP manual for opendir or readdir.

function lsdir($dir) {
if ($handle = opendir($dir)) {
while false !==($filename = readdir($handle)) {
if (is_dir($dir . '/' . $filename)) {
lsdir($dir . '/' . $filename);
} elseif (is_file($dir . '/' . $filename)  $filename != '.' 

$filename != '..') {
// file display code here
}
}

closedir($dir);
}
}   

I 

Re: [PHP] Getting key of value added to array with []?

2003-02-04 Thread Adam Voigt




foreach($counter = 0; $counter  10; $counter++)

{



$array[] = $counter;



}



$lastkey = (count($array)-1);



On Tue, 2003-02-04 at 06:43, Leif K-Brooks wrote:

Is there any way to get the key of an element added to an array with []? 

 I need to use this for a reference to it.  The only idea I can think of 

is to foreach through the array and use the last key looped through, but 

that seems very dirty.





-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP] authentication

2003-02-04 Thread Goetz Lohmann
[EMAIL PROTECTED] schrieb:
 I don't think the process is an extra step at all. In fact, it's just a
 trade off using one or the other. You can either login using php and a
 database backend or just authenticate using .htaccess directives.
 
snip


 On Mon, 3 Feb 2003, Chris Shiflett wrote:
 
 
There is a way to supposedly do this by authenticating
a username and password through php first through such
methods as database lookups and then passing the
username and password through $PHP_AUTH_USER and
$PHP_AUTH_PW using the header() command to point to the
URL of the .htaccess protected directory but I have
never gotten it to work myself.

The variables $PHP_AUTH_USER and $PHP_AUTH_PW are available
to you when the user authenticates via HTTP basic
authentication. Thus, the user has already had to type in
the username and password into a separate window, which is
what the original poster is trying to avoid.

To then send the user to another URL and supply the
authentication credentials in the URL itself just creates
an unnecessary step.


snip

In fact you could combine .htaccess AND $PHP_AUTH cause its
all depending on apache. Apache is looking for the variables
AUTH_USER and AUTH_PW ... not PHP ... PHP just send this via
header() and the Apache result is copyd to PHP_AUTH.

That way you could use an PHP file to build the login page
and an .htacces file to define the restrictions

use something like

FilesMatch \.(gif|jpe?g|png|htm|html)$
  require valid-user
/FilesMatch

to restrict access to the specified files and note that the
data of the .htpasswd must be the same as the user/password
definitions of the database. Maybe you might use mod_auth_db
instead of mod_auth.
With FilesMatch instead of Limit you only protect files
not the way/method how to get them. With the line above
all .html files are protected and .php files are not.
In combination with DirectoryMatch you could also make a
special definition range ...

you only have to beware of the MD5 password ... use

?php
  $password=crypt($PHP_AUTH_PW,substr($PHP_AUTH_PW,0,2));
?

to generate a password valid for an .htacces file



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
 Shams schrieb:
 
Hi,

i've written a secure PHP login script which will allow users to login to a
directory such as this:

smezone.com/members/index.php

however, how do I restrict people from accessing HTML files in that
directory (which they can easily do so by typing the URL into their
browser), such as:

smezone.com/members/document1.html

?

Since its a regular HTML files (and we have lots), I can't check whether the
user has a valid session as I would do in a PHP file.

 
 
 if you are using linux  apache ... just use a .htaccess file like the one below
 
 AuthUserFile /usr/home/.htpasswd
 AuthName Secret Area
 AuthType Basic
 FilesMatch \.(gif|jpe?g|png|htm|html)$
   require valid-user
 /FilesMatch
 
 with this you restrict access only to users listet in the /usr/home/.htpasswd
 files which look like
 
 user1:668c1d6Hc6yCg
 test:85FRBo8cHrAZc
 
 the code after : is a MD5 key
 the FilesMatch mean that all files ending with .gif,.html,.. is restricted and
 .php is not.
 
 in a php file you now can read the authentications from a user and compare it
 with the /usr/home/.htpasswd entrys.
 
 ?php
   ...
   if (!isset($PHP_AUTH_USER)) {
 // $PHP_AUTH_USER is empty ... no login
 header('WWW-Authenticate: Basic realm=My Private Stuff');
 header('HTTP/1.0 401 Unauthorized');
 echo 'Authorization Required.';
 exit;
   }
   // If not empty, check authentication ...
   else {
 if ($PHP_AUTH_USER==$username  $PHP_AUTH_PW==$mypasswd) {
   echo PYour Login is OK;
 ?
 ...
 ?php
 } else {
   echo Pwrong login !;
 }
   }
 ?
 
 note that the the /usr/home/.htpasswd file must include all usernames and
 passwords as MD5. You can create a line of this file with:
 
 ?php
   echo $username:.md5($mypasswd);
 ?
 
 maybe you also can use mod_auth_db ... but this is apache specific so
 take a look at http://httpd.apache.org/docs/mod/core.html


ups ... dont use the default md5() function cause it is not equal to that of
linux in .htpasswd files, use instead:

?php
  $password=crypt($PHP_AUTH_PW,substr($PHP_AUTH_PW,0,2));
?

to generate a MD5 password


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] exec

2003-02-04 Thread Jason Sheets
Hi Nick,

PHP's execution commands like exec will execute the program as the user
your web server is running as (generally someone like nobody or www), in
order to get it to execute as someone else the program needs to be
setuid.

Running programs as Root setuid is generally considered dangerous and
should only be done when absolutely necessary.  If you create a root
setuid program that your web-server can run anyone with the ability to
place scripts on your server can execute this program.

There has been a lot of discussion about this on this list before, if
you search the archives you will find more information.  Additionally
try searching google for setuid.

Jason
On Mon, 2003-02-03 at 20:52, Nick Kordas -: Wildthing Communications
wrote:
 Anyone know how to use shell_exec or exec and execute a shell script as user
 root ?
 
 -
 Regards
 Nick
 Wildthing Communications
 
 
 ~~~
 How can a species, that can create machines to communicate, fail to
 communicate amongst themselves ?
 
 ~~~
 This email and any files transmitted with it may be legally privileged and
 confidential. If you
 are not the intended recipient of this email, you must not disclose or use
 the information contained
 in it. If you have received this email in error, please notify us by return
 email and permanently
 delete the document.
 
 ~~~
 
 
 -- 
 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] authentication

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
 [EMAIL PROTECTED] schrieb:
 
I don't think the process is an extra step at all. In fact, it's just a
trade off using one or the other. You can either login using php and a
database backend or just authenticate using .htaccess directives.

 
 snip
 
 
On Mon, 3 Feb 2003, Chris Shiflett wrote:



There is a way to supposedly do this by authenticating
a username and password through php first through such
methods as database lookups and then passing the
username and password through $PHP_AUTH_USER and
$PHP_AUTH_PW using the header() command to point to the
URL of the .htaccess protected directory but I have
never gotten it to work myself.

The variables $PHP_AUTH_USER and $PHP_AUTH_PW are available
to you when the user authenticates via HTTP basic
authentication. Thus, the user has already had to type in
the username and password into a separate window, which is
what the original poster is trying to avoid.

To then send the user to another URL and supply the
authentication credentials in the URL itself just creates
an unnecessary step.


 
 snip
 
 In fact you could combine .htaccess AND $PHP_AUTH cause its
 all depending on apache. Apache is looking for the variables
 AUTH_USER and AUTH_PW ... not PHP ... PHP just send this via
 header() and the Apache result is copyd to PHP_AUTH.
 
 That way you could use an PHP file to build the login page
 and an .htacces file to define the restrictions
 
 use something like
 
 FilesMatch \.(gif|jpe?g|png|htm|html)$
   require valid-user
 /FilesMatch
 
 to restrict access to the specified files and note that the
 data of the .htpasswd must be the same as the user/password
 definitions of the database. Maybe you might use mod_auth_db
 instead of mod_auth.
 With FilesMatch instead of Limit you only protect files
 not the way/method how to get them. With the line above
 all .html files are protected and .php files are not.
 In combination with DirectoryMatch you could also make a
 special definition range ...
 
 you only have to beware of the MD5 password ... use
 
 ?php
   $password=crypt($PHP_AUTH_PW,substr($PHP_AUTH_PW,0,2));
 ?
 
 to generate a password valid for an .htacces file


maybe take a look at

http://www.diegonet.com/support/mod_auth_mysql.shtml

;-)


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: restricting acces to files

2003-02-04 Thread Goetz Lohmann
Goetz Lohmann schrieb:
 Goetz Lohmann schrieb:
 
Shams schrieb:


Hi,

i've written a secure PHP login script which will allow users to login to a
directory such as this:

smezone.com/members/index.php

however, how do I restrict people from accessing HTML files in that
directory (which they can easily do so by typing the URL into their
browser), such as:

smezone.com/members/document1.html

?

Since its a regular HTML files (and we have lots), I can't check whether the
user has a valid session as I would do in a PHP file.



if you are using linux  apache ... just use a .htaccess file like the one below

AuthUserFile /usr/home/.htpasswd
AuthName Secret Area
AuthType Basic
FilesMatch \.(gif|jpe?g|png|htm|html)$
  require valid-user
/FilesMatch

with this you restrict access only to users listet in the /usr/home/.htpasswd
files which look like

user1:668c1d6Hc6yCg
test:85FRBo8cHrAZc

the code after : is a MD5 key
the FilesMatch mean that all files ending with .gif,.html,.. is restricted and
.php is not.

in a php file you now can read the authentications from a user and compare it
with the /usr/home/.htpasswd entrys.

?php
  ...
  if (!isset($PHP_AUTH_USER)) {
// $PHP_AUTH_USER is empty ... no login
header('WWW-Authenticate: Basic realm=My Private Stuff');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
  }
  // If not empty, check authentication ...
  else {
if ($PHP_AUTH_USER==$username  $PHP_AUTH_PW==$mypasswd) {
  echo PYour Login is OK;
?
...
?php
} else {
  echo Pwrong login !;
}
  }
?

note that the the /usr/home/.htpasswd file must include all usernames and
passwords as MD5. You can create a line of this file with:

?php
  echo $username:.md5($mypasswd);
?

maybe you also can use mod_auth_db ... but this is apache specific so
take a look at http://httpd.apache.org/docs/mod/core.html
 
 
 
 ups ... dont use the default md5() function cause it is not equal to that of
 linux in .htpasswd files, use instead:
 
 ?php
   $password=crypt($PHP_AUTH_PW,substr($PHP_AUTH_PW,0,2));
 ?
 
 to generate a MD5 password

maybe take a look at

http://www.diegonet.com/support/mod_auth_mysql.shtml

;-)


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




RE: [PHP] Which link was selected?

2003-02-04 Thread Leonard Burton
Good Catch,

Be just as an advisement besure to escape those quotes with a backslash \

Leonard.

-Original Message-
From: Götz Lohmsnn [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 04, 2003 4:09 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Which link was selected?


Leonard Burton schrieb:
 Greetings,

 You ought to make your link something like
 www.foo.com/products.php?autoid=105.  and then make a query on your page
 that displays the pics based on an autoincrement number in your table.

 You ought to be able to make the code something like:

 //Display link for product
 print a href=products.php?autoid=.$row[autoid].;
 print img src=images/.$row[product_pic]./a;


 ON your products.php page youd want to have code something like;

 if ($auto)
 {
   $result = select * from product_info where autoid=$autoid

   if ($result)
   {
   while ($row = mysql_fetch_array($result))
   {
   $stuff=$row[stuff];
   $stuff1=$row[stuff1];
   $stuff2=$row[stuff2];
   $stuff3=$row[stuff3];
   }
   mysql_free_result($result);
   print All that stuff here;
   }
   else
   {
   include product_display_page.php;
   }

 I hope it helps.

 Leonard.


ups .. someone was quite faster than me in answering ... and it looks quit
better than my way ... the only thing I want to note ... use  arround
values
of HTML tags ;-)

--
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


--
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] tracking bulk email

2003-02-04 Thread Leonard Burton
What about making the log a .txt file and not a database?  Wouldnt that be
quicker?

Leonard.

-Original Message-
From: Lowell Allen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 04, 2003 7:27 AM
To: PHP
Subject: Re: [PHP] tracking bulk email


 From: Kevin Stone [EMAIL PROTECTED]

 - Original Message -
 From: Lowell Allen [EMAIL PROTECTED]

 I've added an email feature to a content management system that will send
 plain text email to about 1400 contact addresses. Each contact is sent a
 separate email with the contact name and address in the To: header. It
 works fine to small test lists, but hasn't been tested with a large list.

 Although I think list posts should only pose one question, I have two:

 (1) My client is nervous about the script failing mid-list and not being
 able to determine which contacts were sent mail. I need to build this
 check into the content management system. I could write a flag to the
 database every time mail() returns true, but that would mean 1400
database
 updates! If I instead append to a variable each time through the mail()
 loop, I'll lose the record if the script times out. Can anyone suggest
how
 to record the position in a loop if a time out or failure occurs?

 (2) In order to avoid the script timing out, I'm counting the number of
 mail() attempts and calling set_time_limit(30) every 50 attempts to
 provide another 30 seconds of script execution time.

[snip]

 In response to your first question.  File stores are something a computer
 does very very fast (might want to add some error catching to this)..

 $i=0
 while() {
 count_index($i)
 $i++;
 }

 function count_index ($i) {
 $fp = fopen('count.txt', 'w');
 fwrite($fp, $i);
 fclose($fp);
 }

Thanks, Kevin. I've put a counter in place within my mail loop. It seems to
slow the process, but perhaps not too much. And thanks to Mark McCulligh for
describing a system for sending about 1500 messages that's called with a
cron tab and writes to a db after each mail. And thanks to Chris Hayes for
pointing to relevant list archives. My system seems to be working, but it's
so slow that I'm going to look at using a cron tab and saving everything to
a database for easier reference in case of failure mid-list.

--
Lowell Allen


--
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] GET HEADLINES FROM ANOTHER SITE

2003-02-04 Thread The New Source
I´d like to know how to get certain headlines from another site. I already got the 
permission from the site owner, but I'm short on the programing. It would be something 
like, get the source code from the url: www.url.com and then remove all the html, and 
get only the part that I need. Does anybody can give a hand?
Thanx,
Rodrigo.



[PHP] Security question with PHP on Unix / Linux.

2003-02-04 Thread Ananth Kesari
Hi,

I mailed this earlier, but got no response. Maybe it went unnoticed.
So, resending it again. Please read below.

Your help in this is appreciated.

Thanks,
Ananth.


Hi,

I am working on porting PHP onto NetWare.

I am newbie to Unix / Linux systems and at this point of time, I am
trying to understand the way security is implemented for PHP on Unix /
Linux. I mean, how are the different users distinguished from Unix /
Linux. Do they get to login into the Unix / Linux system? Do they have
separate data space for each user? What is the API that is used to login
to Unix / Linux. User may enter his username and password on the
browser, but how do they get translated onto the Unix / Linux box?

Since I am a newbie, I may have misunderstood some concepts here. Can
someone help me in understanding this correctly? Also, can you point me
to any documentation on PHP security on Unix systems. I want some
in-depth technical stuff upto what calls are made etc.

Your help in this is appreciated.

Thanks,
Ananth.


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




RE: [PHP] tracking bulk email

2003-02-04 Thread Matt Schroebel
 -Original Message-
 From: Lowell Allen [mailto:[EMAIL PROTECTED]] 
 Sent: Monday, February 03, 2003 12:38 PM
 To: PHP
 Subject: [PHP] tracking bulk email
 (1) My client is nervous about the script failing mid-list 
 and not being
 able to determine which contacts were sent mail. I need a way 
 to build this
 check into the content management system. I could write a flag to the
 database every time mail() returns true, but that would mean 
 1400 database
 updates! If I instead append to a variable each time through 
 the mail()
 loop, I'll lose the record if the script times out. Can 
 anyone suggest a way
 to record the position in a loop if a time out or failure occurs?

What's wrong with 1,400 database updates?  Seems to me that's the most
straight forward solution, easiest to recover from, easier for someone
following your footsteps to work on later, and is what db's are for..
Have you timed it, and felt pain?  You could email yourself 1,400 times
to test, and see if it hurts.

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




Re: [PHP] php3 + HTTP_POST_FILES

2003-02-04 Thread Maxim Maletsky

No, PHP3 does not support it.

snip from=http://www.php.net/manual/en/features.file-upload.php;

Note: In PHP versions prior 4.1.0 this was named $HTTP_POST_FILES
and it's not an autoglobal variable like $_FILES is. PHP 3 does not
support $HTTP_POST_FILES. 

/snip


--
Maxim Maletsky
[EMAIL PROTECTED]



electroteque [EMAIL PROTECTED] wrote... :

 is there a way to get this variable in php3 for some reason i cannot acess
 it ?
 
 
 
 -- 
 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] Is my syntax wrong?

2003-02-04 Thread Brian Dunning
Hi,
The following code is giving me a parse error, unexpected T_STRING.

$inc_current_ad = WrapMySQLDatabaseResults(macasap, update ads where 
ad_id = '.$current_ad-Value(ad_id).' set 
rotate='.$current_ad-Value(rotate)+1.', 
block=0,inc_current_ad);

It's supposed to increment the value ad_id in the ads table. The 
current_ad action works fine and correctly retrieves the right record. 
I suspect I have a problem with my quotes?

- Brian


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



Re: [PHP] tracking bulk email

2003-02-04 Thread Lowell Allen
 From: Leonard Burton [EMAIL PROTECTED]
 
 What about making the log a .txt file and not a database?  Wouldnt that be
 quicker?

[snip]

 Thanks, Kevin. I've put a counter in place within my mail loop. It seems to
 slow the process, but perhaps not too much. And thanks to Mark McCulligh for
 describing a system for sending about 1500 messages that's called with a
 cron tab and writes to a db after each mail. And thanks to Chris Hayes for
 pointing to relevant list archives. My system seems to be working, but it's
 so slow that I'm going to look at using a cron tab and saving everything to
 a database for easier reference in case of failure mid-list.

I'm not sure how the speed of flat file access compares to MySQL access; I
assume for simple stuff flat file reading/writing is faster. Currently my
system does use .txt files to store/record standard message intro text,
standard exit text, reply-to name, reply-to address, list of addresses that
failed, the actual contact list (which is pulled from a remote MSSQL server
each time email is sent), and a counter of mail attempts generated while
looping through the email list (thanks, Kevin). But if I do a version with a
cron tab I'll store in MySQL instead, since speed really wouldn't be much of
a factor for a process without user involvement, and for me it would be
easier to manage.

--
Lowell Allen


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




Re: [PHP] Security question with PHP on Unix / Linux.

2003-02-04 Thread Maxim Maletsky

Ananth Kesari [EMAIL PROTECTED] wrote... :


 I am working on porting PHP onto NetWare.

What exactly do you mean?

 I am newbie to Unix / Linux systems and at this point of time, I am
 trying to understand the way security is implemented for PHP on Unix /
 Linux. I mean, how are the different users distinguished from Unix /
 Linux. 

From PHP's point of view, every PHP process will run as apache's
process, with apache's user. Most often `nobody' or `apache'.

 Do they get to login into the Unix / Linux system? 

No.

 Do they have
 separate data space for each user? 

No. Only sessions, if you use them. Sessions have their own unique IDs
and are stored in a certain directory by default. A database solution
can also be implemented.

 What is the API that is used to login to Unix / Linux.

There is no login to the Unix / Linux. You might write one on your own,
if you wish, but that would be your thing. PHP as it is, logs nobody to
the Linux, it runs everybody's request as Apache's user.

 User may enter his username and password on the
 browser, but how do they get translated onto the Unix / Linux box?

Whatever inputted to the broswer, is send to your script. Stays up to
you to decide what to do with the user/pass. Basically, you would
usually store the credentials in a database and then authenticate the
users against the database, not Linux Shell itself.

 Since I am a newbie, I may have misunderstood some concepts here. 

Most of them. PHP is a programming language, not a shell interface or
something. Stays up to you what to do once user runs your PHP script.


--
Maxim Maletsky
[EMAIL PROTECTED]



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




Re: [PHP] Is my syntax wrong?

2003-02-04 Thread 1LT John W. Holmes
The following code is giving me a parse error, unexpected T_STRING.

$inc_current_ad = WrapMySQLDatabaseResults(macasap, update ads where
ad_id = '.$current_ad-Value(ad_id).' set
rotate='.$current_ad-Value(rotate)+1.',
block=0,inc_current_ad);

It's supposed to increment the value ad_id in the ads table. The
current_ad action works fine and correctly retrieves the right record.
I suspect I have a problem with my quotes?

Yep. If you want to break out of your string to include you're variables,
then use double quotes.

$string = insert my  . $variable .  here;

not...

$string = insert my ' . $variable . ' here;

The error is being caused because of the double quote in Value(ad_id) is
being seen as the end of the string.

---John Holmes...


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




Re: [PHP] Security question with PHP on Unix / Linux.

2003-02-04 Thread Miles Thompson
Ananth,

For starters, you are probably on the wrong list - the PHP developers list 
is probably where you should be asking this question.

Second, PHP runs through the web server, so the user is the same user the 
web server, usually nobody, although that depends on the how the web 
server is installed. No one is encouraged to all access to the underlying 
system through the web server, although the exec() function allows 
execution of some commands.

I can't help you much more than that, and I believe the other list will be 
more fruitful.

Regards - Miles Thompson


At 07:54 AM 2/4/2003 -0700, Ananth Kesari wrote:
Hi,

I mailed this earlier, but got no response. Maybe it went unnoticed.
So, resending it again. Please read below.

Your help in this is appreciated.

Thanks,
Ananth.


Hi,

I am working on porting PHP onto NetWare.

I am newbie to Unix / Linux systems and at this point of time, I am
trying to understand the way security is implemented for PHP on Unix /
Linux. I mean, how are the different users distinguished from Unix /
Linux. Do they get to login into the Unix / Linux system? Do they have
separate data space for each user? What is the API that is used to login
to Unix / Linux. User may enter his username and password on the
browser, but how do they get translated onto the Unix / Linux box?

Since I am a newbie, I may have misunderstood some concepts here. Can
someone help me in understanding this correctly? Also, can you point me
to any documentation on PHP security on Unix systems. I want some
in-depth technical stuff upto what calls are made etc.

Your help in this is appreciated.

Thanks,
Ananth.


--
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] tracking bulk email

2003-02-04 Thread Miles Thompson
Do the database updates, it's what db's are for!Q
M.

At 09:40 AM 2/4/2003 -0500, Leonard Burton wrote:

What about making the log a .txt file and not a database?  Wouldnt that be
quicker?

Leonard.

-Original Message-
From: Lowell Allen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 04, 2003 7:27 AM
To: PHP
Subject: Re: [PHP] tracking bulk email


 From: Kevin Stone [EMAIL PROTECTED]

 - Original Message -
 From: Lowell Allen [EMAIL PROTECTED]

 I've added an email feature to a content management system that will send
 plain text email to about 1400 contact addresses. Each contact is sent a
 separate email with the contact name and address in the To: header. It
 works fine to small test lists, but hasn't been tested with a large list.

 Although I think list posts should only pose one question, I have two:

 (1) My client is nervous about the script failing mid-list and not being
 able to determine which contacts were sent mail. I need to build this
 check into the content management system. I could write a flag to the
 database every time mail() returns true, but that would mean 1400
database
 updates! If I instead append to a variable each time through the mail()
 loop, I'll lose the record if the script times out. Can anyone suggest
how
 to record the position in a loop if a time out or failure occurs?

 (2) In order to avoid the script timing out, I'm counting the number of
 mail() attempts and calling set_time_limit(30) every 50 attempts to
 provide another 30 seconds of script execution time.

[snip]

 In response to your first question.  File stores are something a computer
 does very very fast (might want to add some error catching to this)..

 $i=0
 while() {
 count_index($i)
 $i++;
 }

 function count_index ($i) {
 $fp = fopen('count.txt', 'w');
 fwrite($fp, $i);
 fclose($fp);
 }

Thanks, Kevin. I've put a counter in place within my mail loop. It seems to
slow the process, but perhaps not too much. And thanks to Mark McCulligh for
describing a system for sending about 1500 messages that's called with a
cron tab and writes to a db after each mail. And thanks to Chris Hayes for
pointing to relevant list archives. My system seems to be working, but it's
so slow that I'm going to look at using a cron tab and saving everything to
a database for easier reference in case of failure mid-list.

--
Lowell Allen


--
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] tracking bulk email

2003-02-04 Thread Lowell Allen
 From: Matt Schroebel [EMAIL PROTECTED]
 
 -Original Message-
 From: Lowell Allen [mailto:[EMAIL PROTECTED]]
 Sent: Monday, February 03, 2003 12:38 PM
 To: PHP
 Subject: [PHP] tracking bulk email
 (1) My client is nervous about the script failing mid-list
 and not being
 able to determine which contacts were sent mail. I need a way
 to build this
 check into the content management system. I could write a flag to the
 database every time mail() returns true, but that would mean
 1400 database
 updates! If I instead append to a variable each time through
 the mail()
 loop, I'll lose the record if the script times out. Can
 anyone suggest a way
 to record the position in a loop if a time out or failure occurs?
 
 What's wrong with 1,400 database updates?  Seems to me that's the most
 straight forward solution, easiest to recover from, easier for someone
 following your footsteps to work on later, and is what db's are for..
 Have you timed it, and felt pain?  You could email yourself 1,400 times
 to test, and see if it hurts.

I haven't tried it from a database, no, and I don't know if the time
requirement would be prohibitive. As it is, the best test time has been
0.186 seconds per email, and the worst has been 0.847 seconds per email
(from about 4-1/2 minutes to about 19-3/4 minutes for 1400 addresses). I
just *assumed* it would take longer to write to a db; I should compare. I
certainly agree it would be easier to manage recovery from mid-list failure
with everything stored in a database.

--
Lowell Allen


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Jean-Pierre Gallou
Goetz Lohmann wrote :


wich means that testinclude.php includes inc/inc1.php
and inc/inc1.php includes inc/inc2.php ?


Right. I'm sorry, I didn't modify testinclude.php as you suggested, but 
inc1.php. With a modified testinclude.php:
  ? include ('./inc/inc1.php'); ?
I get:
  Failed opening './inc/inc1.php' for inclusion \
   (include_path='.:..:/usr/local/php-4.3.0/lib/php')

Seems it doesn't like './' (inc/inc1.php is OK). I think that since 
the name begins with '.', PHP tries to find a file in the working dir, 
which is null (see below).

insert something like into inc1.php and inc2.php:

?php
   echo inc includedbr\n;
   echo br\n;
   $folder=dir('inc');
   // print out folder inc
   while($datei = $folder-read()) {
  echo $dateibr\n;
   }
   $folder-close();
   echo br\n;
?


Unfortunately, this gives nothing. I guess this is because pathnames of 
files are relative to the working dir. There are only two variables, 
PATH and TZ in the environment of my Apache server, but nothing about a 
working dir: cwd() returns an empty string, and so does `pwd` or `ls`.
Relative pathnames of included files are apparently resolved through a 
special way, unless they begin with '.' or '..'. But this is not clearly 
described in the documentation, and it's a bit confusing.


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



Re: [PHP] Converting links in strings

2003-02-04 Thread Chris Shiflett
--- Randum Ian [EMAIL PROTECTED] wrote:
 Please can someone direct me to the correct function
 that changes http://www.foo.com to a
 href=http://www.foo.com;http://www.foo.com/a 
 for any occurence in a string.

Sure

http://www.google.com/search?hl=enlr=ie=UTF-8oe=UTF-8safe=offq=PHP+making+URLs+clickablebtnG=Google+Search

Chris

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




Re: [PHP] Security question with PHP on Unix / Linux.

2003-02-04 Thread Chris Shiflett
--- Miles Thompson [EMAIL PROTECTED] wrote:
 Ananth,
 
 For starters, you are probably on the wrong list -
 the PHP developers list is probably where you should
 be asking this question.

Please do not go around saying this. We have enough
problems with these types of posts winding up on php-dev as
it is.

Chris

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




Re: [PHP] GET HEADLINES FROM ANOTHER SITE

2003-02-04 Thread Chris Shiflett
--- The New Source [EMAIL PROTECTED] wrote:
 I´d like to know how to get certain headlines from
 another site.

Research RSS.

Chris

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




[PHP] Is there a way to retrieve an entire source code from a php file?

2003-02-04 Thread The New Source
What I want to know is if it is possible to retrieve a source code from a url, with a 
php file.

Something like this:

There is a php file that retrieve the source code from the url www.url.com and this 
source is treated and you get content from this file and show it on the response page.

Is this possible? Can anyone show me the right direction?

Rodrigo.



Re: [PHP] Is there a way to retrieve an entire source code from aphp file?

2003-02-04 Thread Adam Voigt




$f = fopen(http://www.download.com/index.html,r);

$data = ""

fclose($f);



echo $data;



On Tue, 2003-02-04 at 11:57, The New Source wrote:

What I want to know is if it is possible to retrieve a source code from a url, with a php file.



Something like this:



There is a php file that retrieve the source code from the url www.url.com and this source is treated and you get content from this file and show it on the response page.



Is this possible? Can anyone show me the right direction?



Rodrigo.




-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP] Is there a way to retrieve an entire source code from a php file?

2003-02-04 Thread 1LT John W. Holmes
No, you can only get the output of the PHP script, not it's source code.

---John Holmes...

- Original Message -
From: The New Source [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 11:57 AM
Subject: [PHP] Is there a way to retrieve an entire source code from a php
file?


What I want to know is if it is possible to retrieve a source code from a
url, with a php file.

Something like this:

There is a php file that retrieve the source code from the url www.url.com
and this source is treated and you get content from this file and show it on
the response page.

Is this possible? Can anyone show me the right direction?

Rodrigo.


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




Re: [PHP] Which link was selected?

2003-02-04 Thread Goetz Lohmann
Leonard Burton schrieb:
 Good Catch,
 
 Be just as an advisement besure to escape those quotes with a backslash \
 
 Leonard.
 
 

yes, you are right, but I also prefer the way of

?php
  // do something here
?
  a href=go somwhereimg src=image.gif name=myname border=0/a
?php
  // do something here
?

instead of

?php
  // do something here
  echo a href=\go somwhere\;
  echo img src=\image.gif\ name=\myname\ border=\0\/a;
  // do something here
?

cause its easyer to change HTML code afterwards without hacking \ everywhere
and you could preview styles in browser if you looking for a file but that's
just freaky to discuss which one might be better ...

;-)




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] Is my syntax wrong?

2003-02-04 Thread 1LT John W. Holmes
Something is still not right. Now I'm getting unexpected
T_CONSTANT_ENCAPSED_STRING when using:

$inc_current_ad = WrapMySQLDatabaseResults(macasap, update ads where
ad_id = .$current_ad-Value(ad_id). set
rotate=.$current_ad-Value(rotate)+1.,
block=0,inc_current_ad);

The problem is your addition, you need another set of paranthesis around the
whole operation.

This will produce your same error:

$test = the value is  . $c+1 .  dollars;

whereas this won't:

$test = the value is  . ($c+1) .  dollars;

---John Holmes...


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




Re: [PHP] Is there a way to retrieve an entire source code from aphp file?

2003-02-04 Thread Adam Voigt




I believe he meant the HTML source of an HTML page.



On Tue, 2003-02-04 at 11:02, 1LT John W. Holmes wrote:

No, you can only get the output of the PHP script, not it's source code.



---John Holmes...



- Original Message -

From: The New Source [EMAIL PROTECTED]

To: [EMAIL PROTECTED]

Sent: Tuesday, February 04, 2003 11:57 AM

Subject: [PHP] Is there a way to retrieve an entire source code from a php

file?





What I want to know is if it is possible to retrieve a source code from a

url, with a php file.



Something like this:



There is a php file that retrieve the source code from the url www.url.com

and this source is treated and you get content from this file and show it on

the response page.



Is this possible? Can anyone show me the right direction?



Rodrigo.





-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


[PHP] iframes and php

2003-02-04 Thread Edward Peloke
there is a php page that uses an iframe...when I view the page at home, I
see all of the contents of the iframe...when I view it at work some of the
contents are wrapped...both of my screen resolutions are the same.  Why
would this be?

Thanks,
Eddie


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




Re: [PHP] Is there a way to retrieve an entire source code from aphp file?

2003-02-04 Thread Philip Olson
On 4 Feb 2003, Adam Voigt wrote:

 I believe he meant the HTML source of an HTML page.

An example in the manual does exactly this:
  http://www.php.net/file

Regards,
Philip


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




[PHP] Re: Problem with include PHP 4.3.0

2003-02-04 Thread Goetz Lohmann
Jean-Pierre Gallou schrieb:
 Goetz Lohmann wrote :
 
 wich means that testinclude.php includes inc/inc1.php
 and inc/inc1.php includes inc/inc2.php ?
 
 
 Right. I'm sorry, I didn't modify testinclude.php as you suggested, but
 inc1.php. With a modified testinclude.php:
   ? include ('./inc/inc1.php'); ?
 I get:
   Failed opening './inc/inc1.php' for inclusion \
(include_path='.:..:/usr/local/php-4.3.0/lib/php')
 
 Seems it doesn't like './' (inc/inc1.php is OK). I think that since
 the name begins with '.', PHP tries to find a file in the working dir,
 which is null (see below).

this is very strange cause I got it working with ./inc/inc1.php and with
inc/inc1.php ... /inc/inc1.php fail cause its searching the file in the
server root ... also inc1.php will fail cause it searches it in the
working dir of testinclude.php ... did you set

doc_root = /usr/local/www/htdocs

than maybe leave this blank !

 insert something like into inc1.php and inc2.php:

 ?php
echo inc includedbr\n;
echo br\n;
$folder=dir('inc');
// print out folder inc
while($datei = $folder-read()) {
   echo $dateibr\n;
}
$folder-close();
echo br\n;
 ?
 
 
 Unfortunately, this gives nothing. I guess this is because pathnames of
 files are relative to the working dir.

yes if the path not start with /

 There are only two variables,
 PATH and TZ in the environment of my Apache server, but nothing about a
 working dir: cwd() returns an empty string, and so does `pwd` or `ls`.
 Relative pathnames of included files are apparently resolved through a
 special way, unless they begin with '.' or '..'. But this is not clearly
 described in the documentation, and it's a bit confusing.

if a file is parsed, all include files a relativ to this parsed file.
with phpinfo() you could read the document root in the PHP Variables
section which might look like

PHP_SELF   /phpinfo.php
_SERVER[DOCUMENT_ROOT]   /usr/local/www/htdocs
...
_SERVER[SCRIPT_FILENAME] /usr/local/www/htdocs/phpinfo.php
_SERVER[SCRIPT_URI]  http://www.yourdomain.com/phpinfo.php
...
_SERVER[PATH_TRANSLATED] /usr/local/www/htdocs/phpinfo.php
...

a . mean working dir and .. mean parent dir

echo exec('ls');

should print out not a empty string but

testinclude.php

and

echo exec('pwd');

should print /usr/local/www/htdocs/tests




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: Is there a way to retrieve an entire source code from a php file?

2003-02-04 Thread Goetz Lohmann
The New Source schrieb:
 What I want to know is if it is possible to retrieve a source code from a url, with 
a php file.
 
 Something like this:
 
 There is a php file that retrieve the source code from the url www.url.com and this 
source is treated and you get content from this file and show it on the response page.
 
 Is this possible? Can anyone show me the right direction?
 
 Rodrigo.
 

if you wish to sniff other peoples code from their web site ... no way by
default ... and thats quite good, cause sometimes there are passwords
stored in plaintext.



-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Re: iframes and php

2003-02-04 Thread Goetz Lohmann
Edward Peloke schrieb:
 there is a php page that uses an iframe...when I view the page at home, I
 see all of the contents of the iframe...when I view it at work some of the
 contents are wrapped...both of my screen resolutions are the same.  Why
 would this be?
 
 Thanks,
 Eddie
 

this depends on your browser ... cause PHP will always do the same thing if
you call it ... maybe you got another charset, another browser version,
another character style at work ... but thats not the fault of PHP ;-)

-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




[PHP] Help Needed

2003-02-04 Thread Pushpinder Singh Garcha
Hello All:

My question is related to authentication. I have made a login system 
using PHP Sessions and MySQL. Once the user gets authenticated on the 
website I want to be able to allow him to see some html pages on the 
website. Only users who have logged in are able to see such a files. I 
have asked this question before , but still I have some doubts.

My code will check for:


  if (session_is_registered($valid_user))
{
  /// display the reqd page
}


else {

DISPLAY ERROR MESSAGE and ASK USER TO LOGIN
}


How should I display the page ... the page has a lot of html code and 
trying to write echoblah  blah blah . ;
will not be a an option. Please suggest a way out .


Many Thanks
Pushpinder




Pushpinder Singh Garcha
_
Web Architect


[PHP] HTML if no PHP

2003-02-04 Thread Bob Lockie

I want to display an HTML page if PHP can't load an include file or 
otherwise has an error or just doesn't work.
How do I do this?


--

Sent from Mozilla and GNU/Linux.
Powered by an AMD processor.


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



RE: [PHP] HTML if no PHP

2003-02-04 Thread Jon Haworth
Hi Bob,

 I want to display an HTML page if PHP can't load an 
 include file or otherwise has an error or just doesn't work.
 How do I do this?

Not sure you can, especially not for the just doesn't work scenario.

FWIW, you can test for the existence of a file before including it:

if (file_exists(file/to/be/included)) {
  include (file/to/be/included);
} else {
  include (backup/plain/HTML/file);
}

but that doesn't cover all the bases you asked about. I'd certainly be
interested to hear any solutions to this one :-)

Cheers
Jon

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




[PHP] Re: HTML if no PHP

2003-02-04 Thread Goetz Lohmann
Bob Lockie schrieb:
 
 I want to display an HTML page if PHP can't load an include file or
 otherwise has an error or just doesn't work.
 How do I do this?


if you using apache you could do this with an ErrorDocument line
which also is usefull to prevent the 404 error page.

take a look at:

http://httpd.apache.org/docs/mod/core.html#errordocument


-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] Help Needed

2003-02-04 Thread Philip Olson
[snip]
 How should I display the page ... the page has a lot of html code and 
 trying to write echoblah  blah blah . ;
 will not be a an option. Please suggest a way out .

Use includes:
 http://www.php.net/include

And write HTML as HTML:

h3Greetings/h3
pHello b?php echo $username ?/b, we hope you 
enjoy this webpage./p

Or a little heredoc:
 
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Regards,
Philip


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




Re: [PHP] HTML if no PHP

2003-02-04 Thread V Dub
Quoting Bob Lockie [EMAIL PROTECTED]:

### 
### I want to display an HTML page if PHP can't load an include file or 
### otherwise has an error or just doesn't work.
### How do I do this?
### 

if (!$variable){print('your html stuff');}

Kinda basic, but it might help.

Cheers!

VW

### 
### -- 
### 
### Sent from Mozilla and GNU/Linux.
### Powered by an AMD processor.
### 
### 
### -- 
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
### 
### 


-- 
Richard Whitney
Transcend Development
Producing the next phase of your internet presence.
[EMAIL PROTECTED]
http://xend.net
602-971-2791

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




Re: [PHP] Is my syntax wrong?

2003-02-04 Thread Brian Dunning
I think we are almost there. This code is not producing an error, but 
it is also not incrementing the database. The value stays at zero. Any 
idea what could be wrong?

$inc_current_ad = WrapMySQLDatabaseResults(macasap, update ads where 
ad_id = .$current_ad-Value(ad_id). set 
rotate=.($current_ad-Value(rotate)+1), block=0,inc_current_ad);

Other queries of the same db on the page are working, so it's probably 
not a configuration/connectivity issue.

- Brian


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



[PHP] Re: Help Needed

2003-02-04 Thread Goetz Lohmann
Pushpinder Singh Garcha schrieb:
 Hello All:
 
 My question is related to authentication. I have made a login system
 using PHP Sessions and MySQL. Once the user gets authenticated on the
 website I want to be able to allow him to see some html pages on the
 website. Only users who have logged in are able to see such a files. I
 have asked this question before , but still I have some doubts.
 
 My code will check for:
 
 
   if (session_is_registered($valid_user))
 {
   /// display the reqd page
 }
 
 
 else {
 
 DISPLAY ERROR MESSAGE and ASK USER TO LOGIN
 }
 
 
 How should I display the page ... the page has a lot of html code and
 trying to write echoblah  blah blah . ;
 will not be a an option. Please suggest a way out .

you could include every page into a php script using

?php
   include('index.htm');
?

this mean, that this page is like being copyed in the php file

also instead of

?php
  echo bla bla bla:
?

you always can do

?php
...
?
   bla bla bla
?php
...
?




-- 
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Re: [PHP] HTML if no PHP

2003-02-04 Thread John Nichel
if ( !@include ( myfile.php ) ) {
// do this if file cannot be included
...code...
...code...
}


Bob Lockie wrote:


I want to display an HTML page if PHP can't load an include file or 
otherwise has an error or just doesn't work.
How do I do this?





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




Re: [PHP] HTML if no PHP

2003-02-04 Thread Philip Olson

 I want to display an HTML page if PHP can't load an include 
 file or otherwise has an error or just doesn't work.
 How do I do this?

include returns false on failure and here's a hack to 
demonstrate.  Once you implement your own error
handling, be sure to set error_reporting accordingly
or supress with @.

if (!include('foo.php')) {
if (!include('static.html')) {
print 'ut oh, this is serious.';
}
}

Be sure to read about PHP's error handling capabilities to
do something more useful and/or create your own error
handling functions/system.

See also:  http://www.php.net/trigger_error
   http://www.php.net/set_error_handler
   http://www.php.net/ref.errorfunc

Regards,
Philip


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




[PHP] Can I see when a file was created?

2003-02-04 Thread Øystein Håland
When last modified, yes. How about when it was created? By using php?



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




[PHP] How to get a certain line from a file

2003-02-04 Thread The New Source
How can I get a certain line from a file?

If I get a file in this way:

$f = fopen(http://www.url.com/index.htm,r;); 

How can I get a certain line of the file index.htm?

I would need to get the line number 232, or lines from 232 to 238. How can I get this 
content?

Thanx.

Rodrigo



[PHP] include

2003-02-04 Thread Bob Lockie
I don't appear to be able to use this variable in an include directive 
because the variable is empty:
include $_SERVER['DOCUMENT_ROOT']

Do I have the syntax incorrect?


--

Sent from Mozilla and GNU/Linux.
Powered by an AMD processor.


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



Re: [PHP] How to get a certain line from a file

2003-02-04 Thread Philip Olson
On Tue, 4 Feb 2003, The New Source wrote:

 How can I get a certain line from a file?
 
 If I get a file in this way:
 
 $f = fopen(http://www.url.com/index.htm,r;); 
 
 How can I get a certain line of the file index.htm?
 
 I would need to get the line number 232, or lines from 232 to 238. How
 can I get this content?

Either loop through it with fgets() or simply use
file() and use the required array elements (lines).  
Most likely using fopen/fgets() will be more efficient 
as you won't need every line but file() is just so easy 
to use.  Although really this problem doesn't sound
very efficient to begin with, you may want to rethink
the logic here or ask your content provider for a RSS
version of the content or something...

See:
  http://www.php.net/file
  http://www.php.net/fgets

Regards,
Philip


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




Re: [PHP] Re: Help Needed

2003-02-04 Thread Pushpinder Singh Garcha
Hello All:

Thanks again... I tried to use this and it is working fine for me.
Please comment:

?
session_start();

  if (session_is_registered(valid_user))
 include 'guest.html';

  else include 'not_logged_in.php';

?

Many Thanks
-Pushpinder


On Tuesday, February 4, 2003, at 12:32 PM, Goetz Lohmann wrote:


Pushpinder Singh Garcha schrieb:

Hello All:

My question is related to authentication. I have made a login system
using PHP Sessions and MySQL. Once the user gets authenticated on the
website I want to be able to allow him to see some html pages on the
website. Only users who have logged in are able to see such a files. I
have asked this question before , but still I have some doubts.

My code will check for:


  if (session_is_registered($valid_user))
{
  /// display the reqd page
}


else {

DISPLAY ERROR MESSAGE and ASK USER TO LOGIN
}


How should I display the page ... the page has a lot of html code and
trying to write echoblah  blah blah . ;
will not be a an option. Please suggest a way out .


you could include every page into a php script using

?php
   include('index.htm');
?

this mean, that this page is like being copyed in the php file

also instead of

?php
  echo bla bla bla:
?

you always can do

?php
...
?
   bla bla bla
?php
...
?




--
 @  Goetz Lohmann, Germany   |   Web-Developer  Sys-Admin
\/  --
()  He's the fellow that people wonder what he does and
||  why the company needs him, until he goes on vacation.


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




Pushpinder Singh Garcha
_
Web Architect




Re: [PHP] How to get a certain line from a file

2003-02-04 Thread Adam Voigt




Real easy. Assuming you've read the data of the page into $data:



$data = ""

$line = $data[36];



Just replace 36 with whatever line number you want.



On Tue, 2003-02-04 at 13:50, The New Source wrote:

How can I get a certain line from a file?



If I get a file in this way:



$f = fopen(http://www.url.com/index.htm,r); 



How can I get a certain line of the file index.htm?



I would need to get the line number 232, or lines from 232 to 238. How can I get this content?



Thanx.



Rodrigo




-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP] include

2003-02-04 Thread Philip Olson
On Tue, 4 Feb 2003, Bob Lockie wrote:

 I don't appear to be able to use this variable in an include directive 
 because the variable is empty:
 include $_SERVER['DOCUMENT_ROOT']
 
 Do I have the syntax incorrect?

Please post the exact syntax as you did not as the
above will provide a serious parse error.  To test
if a value exists, do:

  var_dump($_SERVER['DOCUMENT_ROOT']);

Or phpinfo().  Now, going off a guess, try:

  include $_SERVER['DOCUMENT_ROOT'] . '/foo.php';

The following will NOT work in 4.3.0 as there
is a bug when using the following syntax:

  echo $_SERVER['DOCUMENT_ROOT'];
  echo Er, $iam['inastringand'] buggy in 4.3.0;

Note that the above gives a parse error in 4.2.3,
a bogus E_NOTICE error in 4.3.0, and will work (no
parse error) in 4.3.1.  Now, the following always 
works:

  echo {$_SERVER['DOCUMENT_ROOT']};
  echo So {$i['willalwayswork']} yeah!;

Note: We are specifically talking about using arrays
within strings where the array key is quoted.

Regards,
Philip

P.s. Autoglobals, such a $_SERVER, became available in
PHP in PHP 4.1.0


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




Re: [PHP] Is my syntax wrong?

2003-02-04 Thread Jason Wong
On Wednesday 05 February 2003 01:30, Brian Dunning wrote:
 I think we are almost there. This code is not producing an error, but
 it is also not incrementing the database. The value stays at zero. Any
 idea what could be wrong?

 $inc_current_ad = WrapMySQLDatabaseResults(macasap, update ads where
 ad_id = .$current_ad-Value(ad_id). set
 rotate=.($current_ad-Value(rotate)+1), block=0,inc_current_ad);

Assign your query (update ads where ...) to a variable, print it out, check 
whether it looks good, _then_ plug it into WrapMySQLDatabaseResults().

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Guillotine, n.:
A French chopping center.
*/


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




[PHP] How to remove the html Tags?

2003-02-04 Thread The New Source
Hi guys, is there a function that will remove all the Html tags from a file?

How should I do it?

Thanks for any clues,

Rodrigo



Re: [PHP] How to remove the html Tags?

2003-02-04 Thread John Nichel
SearchGooglethe PHP manual

http://www.php.net/manual/en/function.strip-tags.php

The New Source wrote:

Hi guys, is there a function that will remove all the Html tags from a file?

How should I do it?

Thanks for any clues,

Rodrigo





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




[PHP] testing if a query was successful

2003-02-04 Thread Sunfire
hi..
how would you use an if..else statement to test a query in mysql to see if
it was successfull or not?

would it be something like:
$query=(query here...);
if($query){
statements if successfull??
}else{
statements if not true??
}
or would it be something else..

tnx



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003


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




Re: [PHP] testing if a query was successful

2003-02-04 Thread Chris Shiflett
--- Sunfire [EMAIL PROTECTED] wrote:
 how would you use an if..else statement to test a
 query in mysql to see if it was successfull or not?

Depends on what database server you are using. Here it is
in MySQL:

if (mysql_query($sql))
{
   echo Success;
}
else
{
   echo Failure;
}

Chris

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




Fw: [PHP] Can I see when a file was created?

2003-02-04 Thread Kevin Stone
Hmm... I seem to recall reading that Unix does not store the file creation
date and this is the reason that PHP does not have such a function.  The
only option is to store that information in a database when you create the
file on the server.
-Kevin

- Original Message -
From: Øystein Håland [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 10:38 AM
Subject: [PHP] Can I see when a file was created?


 When last modified, yes. How about when it was created? By using 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] php3 + HTTP_POST_FILES

2003-02-04 Thread Dan Rossi
i looked there i'm sure i didnt see that :| what a pain , another reason to
get them to upgrade ;) what information can i get out of the file then ?

-Original Message-
From: Maxim Maletsky [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 2:06 AM
To: electroteque
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] php3 + HTTP_POST_FILES



No, PHP3 does not support it.

snip from=http://www.php.net/manual/en/features.file-upload.php;

Note: In PHP versions prior 4.1.0 this was named $HTTP_POST_FILES
and it's not an autoglobal variable like $_FILES is. PHP 3 does not
support $HTTP_POST_FILES.

/snip


--
Maxim Maletsky
[EMAIL PROTECTED]



electroteque [EMAIL PROTECTED] wrote... :

 is there a way to get this variable in php3 for some reason i cannot acess
 it ?



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

2003-02-04 Thread Bob Lockie
On 02/04/03 13:16 Philip Olson spoke thusly


On Tue, 4 Feb 2003, Bob Lockie wrote:



I don't appear to be able to use this variable in an include directive 
because the variable is empty:
include $_SERVER['DOCUMENT_ROOT']

Do I have the syntax incorrect?


Please post the exact syntax as you did not as the
above will provide a serious parse error.


include $_SERVER['DOCUMENT_ROOT']/visit_db.php;

I am using 4.3.0, there is no release later.


To test
if a value exists, do:

  var_dump($_SERVER['DOCUMENT_ROOT']);

Or phpinfo().  Now, going off a guess, try:

  include $_SERVER['DOCUMENT_ROOT'] . '/foo.php';

The following will NOT work in 4.3.0 as there
is a bug when using the following syntax:

  echo $_SERVER['DOCUMENT_ROOT'];
  echo Er, $iam['inastringand'] buggy in 4.3.0;

Note that the above gives a parse error in 4.2.3,
a bogus E_NOTICE error in 4.3.0, and will work (no
parse error) in 4.3.1.  Now, the following always 
works:

  echo {$_SERVER['DOCUMENT_ROOT']};
  echo So {$i['willalwayswork']} yeah!;

Note: We are specifically talking about using arrays
within strings where the array key is quoted.

Regards,
Philip

P.s. Autoglobals, such a $_SERVER, became available in
PHP in PHP 4.1.0




--

Sent from Mozilla and GNU/Linux.
Powered by an AMD processor.


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




Re: [PHP] testing if a query was successful

2003-02-04 Thread Kevin Stone
As quoted from the manual:  A non-FALSE return value means that the query
was legal and could be executed by the server. It does not indicate anything
about the number of rows affected or returned. It is perfectly possible for
a query to succeed but affect no rows or return no rows.

Always test your query with the assumption that you will return a non-FALSE
value.  This is an important lesson to learn  as it is more robust and can
save you from quite a bit of frustration.  For example..

$result = mysql_query(SELECT... ) or die(Invalid query:  .
mysql_error());
if (mysql_num_rows($result) == 0)
{
echo Query executed but no rows were selected.;
exit;
}

$result = mysql_query(UPDATE or INSERT or DELETE... ) or die(Invalid
query:  . mysql_error());
if (mysql_affected_rows() == 0)
{
echo Query executed but no rows were affected;
exit;
}

- Kevin

- Original Message -
From: Chris Shiflett [EMAIL PROTECTED]
To: Sunfire [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 11:58 AM
Subject: Re: [PHP] testing if a query was successful


 --- Sunfire [EMAIL PROTECTED] wrote:
  how would you use an if..else statement to test a
  query in mysql to see if it was successfull or not?

 Depends on what database server you are using. Here it is
 in MySQL:

 if (mysql_query($sql))
 {
echo Success;
 }
 else
 {
echo Failure;
 }

 Chris

 --
 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] HTML if no PHP

2003-02-04 Thread Ernest E Vogelsinger
1) Include file not found:
if (file_exists($incfile))
include($incfile);
else
include ($error_html_file);

2) Error in file:
global $php_errormsg;
$php_errormsg = null;
@include($incfile);
$err = $php_errormsg;
if ($err)
echo The include file $incfile has an error: $err;

The trick is to put an @ before the include which will hide the error
(even if it's a critical one).

However, in case of a critical error, your script will silently be aborted.
Thus here's a solution to cature these cases:

3) Include and execute capturing critical errors:

$hf = fopen($incfile, 'r');
if ($hf) {
$buffer = fread($hf, filesize($incfile));
fclose($hf);
}
if ($buffer) {
global $php_errormsg;
$php_errormsg = null;
@eval($buffer);
$err = $php_errormsg;
}

The rest goes as above. The eval statement will gracefully handle any
critical error that would bring your script to an immediate halt in case of
@include.

HTH :)
- Original Message -
From: Bob Lockie [EMAIL PROTECTED]
To: php-general Mailing List [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 6:11 PM
Subject: [PHP] HTML if no PHP



 I want to display an HTML page if PHP can't load an include file or
 otherwise has an error or just doesn't work.
 How do I do this?


 --
 
 Sent from Mozilla and GNU/Linux.
 Powered by an AMD processor.


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




  1   2   >