php-general Digest 23 Jun 2002 11:45:02 -0000 Issue 1422

Topics (messages 103432 through 103452):

Re: Very slow pg access
        103432 by: Frank
        103436 by: Uros Gruber

Re: cookies
        103433 by: Chris Shiflett
        103434 by: Paul O'Neil

PHP 4.2.1 reading PAM/Shadowed passwords?
        103435 by: Matthew Nock

Error(Newbie)
        103437 by: webmaster.tececo.com
        103438 by: 1LT John W. Holmes
        103441 by: 1LT John W. Holmes
        103443 by: Leif K-Brooks
        103448 by: webmaster.tececo.com
        103451 by: 1LT John W. Holmes

getaddrinfo failed
        103439 by: Pag
        103440 by: 1LT John W. Holmes

Re: UPDATE mysql
        103442 by: 1LT John W. Holmes

Re: Get difference between strings.
        103444 by: Jason Wong

Re: PLEASE HELP-Unable to get off this list
        103445 by: Jason Wong

Re: Nested Menu Help
        103446 by: Jason Wong

Re: is there a function like javascript's window.open in PHP
        103447 by: Jason Wong

netscape 4.x problem
        103449 by: Thomas E. Ruth

Re: emailing html file
        103450 by: Andy

PHP 4.2
        103452 by: Simon Troup

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]


----------------------------------------------------------------------
--- Begin Message ---

I find it impossible that PHP should be "slow". PHP's Pg functions are - 
and shouldn't be - nothing more or else than a frontend to the Pg API.

The problem is most likely that you are not comparing the same values. I 
think the analyze values are calculated "internal" values that has little 
to do with real life through an API.

Postgres is very fast - but a connect and 3 queries in 0.002 ms? Hmmm!

The 0.1 s looks more like a "real" value to me.

Best

Frank


At 00:51 22/6/2002 +0200, you wrote:
>Hi!
>
>i made some benchmarks because my script is somehow very
>slow. In this script i execute 3 queries to PostgreSQL server
>and one connect string. I connect to socket.
>
>I check this queries in pg with explain analyze and i have
>result 1.18ms so i add a little and let say that for those 3
>queries need 2ms. (1 simple select, 1 delete, 1 insert)
>
>
>When i check from PHP i use microtime() to check times.
>
>Here is results
>
>0.0443  for connect
>0.0343  1 query    delete
>0.0034  2 query    select
>0.0049  3 query    THIS ONE is INSERT OR UPDATE
>
>0.087 TOTAL
>
>so complete time is about 0.090 s this is 90ms against 2ms. I
>thik that this is not normal. or is PHP so slow or there is
>something wrong with libraries
>
>I use PHP 4.1.2 and pg 7.2.1
>
>Any thoughts.
>
>--
>tia,
>  Uros                          mailto:[EMAIL PROTECTED]
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hi!

Sunday, June 23, 2002, 1:21:07 AM, you wrote:


F> I find it impossible that PHP should be "slow". PHP's Pg functions are - 
F> and shouldn't be - nothing more or else than a frontend to the Pg API.

F> The problem is most likely that you are not comparing the same values. I 
F> think the analyze values are calculated "internal" values that has little 
F> to do with real life through an API.

F> Postgres is very fast - but a connect and 3 queries in 0.002 ms? Hmmm!
i didn't say 0.002 ms i say 0.002 s this is 2ms, but from php
that time was 90ms

I also use one patch for realtimer in pg, it say max 10ms.
without connect, but i don't thik that for connection is user
like 80ms,

I thik that here must be something wrong, or with some lib,
I realy don't know, so i'm asking on that list for help to
solve this.

Btw computer is PII300MHz with 128MB RAM, but in this table
is for now from 0 to 15 entries.


-- 
lp,
 Uros                            mailto:[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
This is sometimes a confusing issue for people, but remember that 
cookies work like this:

1) client requests a resource from a Web server
2) Web server returns a response to the client including a request to 
set cookies ("Set-Cookie" header)
3) client requests another page from the Web server and includes the 
cookies ("Cookie" header) in the request

Some people want to know how they can tell whether the client accepts 
cookies after step 1 (during the processing that results in step 2). 
This is simply impossible.

However, you can adequately tell whether someone has cookies enabled 
after you receive a second HTTP request from that person. On this 
"second" page, simply test to see whether the cookie that you previously 
set exists (isset is a good function for this). If it doesn't exist, the 
client does not accept cookies. Some developers want this "check" to 
appear as if it were performed on a single transaction and force the 
client to make the second request.

Chris

Paul O'Neil wrote:

>If a browser has cookies blocked , anyone have code if unable to set cookie
>then  goto another page.
>

--- End Message ---
--- Begin Message ---
isset worked for me thanks.

-----Original Message-----
From: Chris Shiflett [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 22, 2002 4:37 PM
To: Paul O'Neil
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] cookies


This is sometimes a confusing issue for people, but remember that
cookies work like this:

1) client requests a resource from a Web server
2) Web server returns a response to the client including a request to
set cookies ("Set-Cookie" header)
3) client requests another page from the Web server and includes the
cookies ("Cookie" header) in the request

Some people want to know how they can tell whether the client accepts
cookies after step 1 (during the processing that results in step 2).
This is simply impossible.

However, you can adequately tell whether someone has cookies enabled
after you receive a second HTTP request from that person. On this
"second" page, simply test to see whether the cookie that you previously
set exists (isset is a good function for this). If it doesn't exist, the
client does not accept cookies. Some developers want this "check" to
appear as if it were performed on a single transaction and force the
client to make the second request.

Chris

Paul O'Neil wrote:

>If a browser has cookies blocked , anyone have code if unable to set cookie
>then  goto another page.
>


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

--- End Message ---
--- Begin Message ---
Hi All,

I am trying to build a "client interface" for each of my web-hosting
customers, and would like to have them log into the system using the same
username/password combinations that are used for FTP, email etc.

ie: those stored in the Unix system's passwd and shadow passwd files.

I have seen a number of different methods for doing this, all of which seem
a little messy.

Obviously, the system allows you to do it - i have seen apache work with
this file for example.  Any tips on where to look for info/help etc?
--- End Message ---
--- Begin Message ---
Both the below are in the same dir.
 
The meta.array_create.php file works fine elsewhere
 
when I try and view stat.php I get this error:
 
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\TecEco(Converting To PHP)\includes\stat.php on line 7
 
What does the error mean and how can I correct my code?
 
File meta.array_create.php
-----------------------------------
<?
  $fn = explode("/", $_SERVER['PHP_SELF']);
  $num_of_s = count($fn) - 1;
  $fn = "$fn[$num_of_s]";
  $query = "SELECT * FROM meta_data WHERE page_name = '$fn'";
  $result = mysql_query($query);
  $num_results = mysql_num_rows($result);
  $row = mysql_fetch_array($result);
  $id = $row['id'];
  $pid = $row['pid'];
  $title = $row['title'];
  $description = $row['description'];
  $keywords = $row['keywords'];
?>
 
file stat.php
-------------------------
 
<?
include "meta.array_create.php";
if(!isset($_COOKIE['tececo_stats']))
{
setcookie ("tececo_stats", 1);
}
$query = "INSERT INTO `stats` (`vid`, `id`, `vn`, `time`, `host`, `referrer`, `browser`) VALUES ('', '$id', '$_COOKIE['tececo_stats']', '$time', '$_SERVER['REMOTE_HOST']', '$_SERVER['HTTP_REFERER']', '$_SERVER['HTTP_USER_AGENT']'); ";
$insert = mysql_query($query);
?>
--- End Message ---
--- Begin Message ---
>$query = "INSERT INTO `stats` (`vid`, `id`, `vn`, `time`, `host`, `referrer`, 
>`browser`) VALUES ('', '$id', '$_COOKIE
>['tececo_stats']', '$time', '$_SERVER['REMOTE_HOST']', '$_SERVER['HTTP_REFERER']', 
>'$_SERVER
>['HTTP_USER_AGENT']'); ";

Try using $_COOKIE[tececo_stats] instead...without the single quotes (for the other 
vars, too). 

You don't need all of those backticks in your query, either...

---John Holmes...
  ----- Original Message ----- 
  From: [EMAIL PROTECTED] 
  To: [EMAIL PROTECTED] 
  Sent: Saturday, June 22, 2002 10:19 AM
  Subject: [PHP] Error(Newbie)


  Both the below are in the same dir.

  The meta.array_create.php file works fine elsewhere

  when I try and view stat.php I get this error:

  Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in 
C:\TecEco(Converting To PHP)\includes\stat.php on line 7

  What does the error mean and how can I correct my code?

  File meta.array_create.php
  -----------------------------------
  <?
    $fn = explode("/", $_SERVER['PHP_SELF']);
    $num_of_s = count($fn) - 1;
    $fn = "$fn[$num_of_s]";
    $query = "SELECT * FROM meta_data WHERE page_name = '$fn'";
    $result = mysql_query($query);
    $num_results = mysql_num_rows($result);
    $row = mysql_fetch_array($result);
    $id = $row['id'];
    $pid = $row['pid'];
    $title = $row['title'];
    $description = $row['description'];
    $keywords = $row['keywords'];
  ?>

  file stat.php
  -------------------------

  <?
  include "meta.array_create.php";
  if(!isset($_COOKIE['tececo_stats']))
  {
  setcookie ("tececo_stats", 1);
  }
  $query = "INSERT INTO `stats` (`vid`, `id`, `vn`, `time`, `host`, `referrer`, 
`browser`) VALUES ('', '$id', '$_COOKIE['tececo_stats']', '$time', 
'$_SERVER['REMOTE_HOST']', '$_SERVER['HTTP_REFERER']', '$_SERVER['HTTP_USER_AGENT']'); 
";
  $insert = mysql_query($query);
  ?>


------------------------------------------------------------------------------


  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
>$query = "INSERT INTO `stats` (`vid`, `id`, `vn`, `time`, `host`, `referrer`, 
>`browser`) VALUES ('', '$id', '$_COOKIE
>['tececo_stats']', '$time', '$_SERVER['REMOTE_HOST']', '$_SERVER['HTTP_REFERER']', 
>'$_SERVER
>['HTTP_USER_AGENT']'); ";

I hope you are using addslashes on your $_COOKIE and $_SERVER vars, too, otherwise 
your query is wide open to some attacks...

---John Holmes...
--- End Message ---
--- Begin Message ---
Do NOT do it that way!  That may work now, but it may not in the future! 
 The correct way is to append.  Like ".$_COOKIE['tececo_stats']." 
 (include the quotes).  Do it the same way for the others.
1LT John W. Holmes wrote

>
>Try using $_COOKIE[tececo_stats] instead...without the single quotes (for the other 
>vars, too). 
>  
>

--- End Message ---
--- Begin Message ---
I got that auto add slashes thing on. is it enough?

If not how should I go about adding them?

like this?

$_SERVER['REMOTE_HOST'] = addslashes($_SERVER['REMOTE_HOST']);

What sort of effects could an attack have?

I am intergrating stats into a site. What other vars could I gather info
from?

Thanks,

JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

BTW I have fixed the error now.

----- Original Message -----
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, June 23, 2002 2:11 PM
Subject: Re: [PHP] Error(Newbie)


>$query = "INSERT INTO `stats` (`vid`, `id`, `vn`, `time`, `host`,
`referrer`, `browser`) VALUES ('', '$id', '$_COOKIE
>['tececo_stats']', '$time', '$_SERVER['REMOTE_HOST']',
'$_SERVER['HTTP_REFERER']', '$_SERVER
>['HTTP_USER_AGENT']'); ";

I hope you are using addslashes on your $_COOKIE and $_SERVER vars, too,
otherwise your query is wide open to some attacks...

---John Holmes...


--- End Message ---
--- Begin Message ---
Yeah, magic_quotes will be enough, but it only handles GET, POST, and COOKIE
data. I'm not sure what SERVER variables can be trusted, so it wouldn't hurt
to addslash them...

There isn't much of a risk to your query, but someone could still mess
things up. If they formatted a cookie like

$_COOKIE['tececo_stats'] =
"bad_data','bad_time','bad_host','bad_referrer','bad_agent')#";

it would allow them to insert bad data into your table...

---John Holmes...

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 23, 2002 2:50 AM
Subject: Re: [PHP] Error(Newbie)


> I got that auto add slashes thing on. is it enough?
>
> If not how should I go about adding them?
>
> like this?
>
> $_SERVER['REMOTE_HOST'] = addslashes($_SERVER['REMOTE_HOST']);
>
> What sort of effects could an attack have?
>
> I am intergrating stats into a site. What other vars could I gather info
> from?
>
> Thanks,
>
> JJ Harrison
> [EMAIL PROTECTED]
> www.tececo.com
>
> BTW I have fixed the error now.
>
> ----- Original Message -----
> From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Sunday, June 23, 2002 2:11 PM
> Subject: Re: [PHP] Error(Newbie)
>
>
> >$query = "INSERT INTO `stats` (`vid`, `id`, `vn`, `time`, `host`,
> `referrer`, `browser`) VALUES ('', '$id', '$_COOKIE
> >['tececo_stats']', '$time', '$_SERVER['REMOTE_HOST']',
> '$_SERVER['HTTP_REFERER']', '$_SERVER
> >['HTTP_USER_AGENT']'); ";
>
> I hope you are using addslashes on your $_COOKIE and $_SERVER vars, too,
> otherwise your query is wide open to some attacks...
>
> ---John Holmes...
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---

        Sorry, i sent this to the list a few days ago, but i dont think it got 
there. heres my problem:

         Hi, i have this script that simply reads lines from a txt files 
and displays them on my site, itlists the first 4 entries of a txt file 
with the files that exist on a download page:

         <?
$linha=file('downs.txt');
$t=count($linha);
$l = $t - 1;
$fim = $l - 3;

if ($l > 3)
{
$fim=$l - 3;
}
else {
$fim = 0;
}
for ($i = $l; $i >= $fim ; $i--) {
     $array=explode("|",$linha[$i]);
         print("<div align=\"left\">");
         print("<span class=\"data\">$array[0]</span>");
         print("<br>$array[1]<br>");
         print("</div><img src=\"spacer.gif\" height=\"3\">");
         }
?>


         But from time to time, and with absolutely no visible reason, i 
get this error:

         Warning: php_network_getaddresses: getaddrinfo failed: No address 
associated with hostname in /usr/home/pagon/www/index.php on line 497

Warning: file("downs.txt") - Bad file descriptor in 
/usr/home/pagon/www/index.php on line 497


         I tried everything, but i cant figure out why i get this error, 
the paths are ok (otherwise it wouldnt work in the first place) what could 
possibly cause it? The script is so small and simple, is there something 
wrong in it? But if it is, why does the error only appears randomly?
         I get this error on a different script on my site, also of the 
same type, reading a few lines from a txt file and displaying them.
         Thanks.

         Pag



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


--- End Message ---
--- Begin Message ---
So what's on "/usr/home/pagon/www/index.php on line 497" at a few lines
before it?

---John Holmes...

----- Original Message -----
From: "Pag" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 22, 2002 9:50 PM
Subject: [PHP] getaddrinfo failed


>
> Sorry, i sent this to the list a few days ago, but i dont think it got
> there. heres my problem:
>
>          Hi, i have this script that simply reads lines from a txt files
> and displays them on my site, itlists the first 4 entries of a txt file
> with the files that exist on a download page:
>
>          <?
> $linha=file('downs.txt');
> $t=count($linha);
> $l = $t - 1;
> $fim = $l - 3;
>
> if ($l > 3)
> {
> $fim=$l - 3;
> }
> else {
> $fim = 0;
> }
> for ($i = $l; $i >= $fim ; $i--) {
>      $array=explode("|",$linha[$i]);
>          print("<div align=\"left\">");
>          print("<span class=\"data\">$array[0]</span>");
>          print("<br>$array[1]<br>");
>          print("</div><img src=\"spacer.gif\" height=\"3\">");
>          }
> ?>
>
>
>          But from time to time, and with absolutely no visible reason, i
> get this error:
>
>          Warning: php_network_getaddresses: getaddrinfo failed: No address
> associated with hostname in /usr/home/pagon/www/index.php on line 497
>
> Warning: file("downs.txt") - Bad file descriptor in
> /usr/home/pagon/www/index.php on line 497
>
>
>          I tried everything, but i cant figure out why i get this error,
> the paths are ok (otherwise it wouldnt work in the first place) what could
> possibly cause it? The script is so small and simple, is there something
> wrong in it? But if it is, why does the error only appears randomly?
>          I get this error on a different script on my site, also of the
> same type, reading a few lines from a txt file and displaying them.
>          Thanks.
>
>          Pag
>
>
>
> --
> 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
>

--- End Message ---
--- Begin Message ---
> $query = "UPDATE $table SET field1='$var1' WHERE id='$id'";

I really hope you don't have register_globals on, or you are validating the
value of $table before you run this kind of query, otherwise your query is
open up to an attack to update any table in the database...

$table = "admin SET admin='Yes' WHERE username='John' #";

The # will make the remainder of your query a comment and it'll be ignored
by MySQL...

---John Holmes...

--- End Message ---
--- Begin Message ---
On Sunday 23 June 2002 07:05, David Duong wrote:
> How would I get the difference between strings?
>
> Example:
> ViewCVS can browse directories, change logs, and revisions of files. It can
> display diffs between versions and show selections of files based on tags
> or branches...
>
> This was word for word from sourceforge project ViewCVS, however ViewCVS
> was written in Python.

Obviously someone had to write that program, in Python, to be able to do that.

> Is their a way for PHP to Display the 'diffs' between two submitted text?

Likewise, someone would have to write a program in PHP to do that. There is 
nothing in PHP that would prevent you from writing such a program, so the 
answer to your question is YES.

> I just need to be pointed in the right direction.

For starters, have a look at the string functions, then the array functions.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
White dwarf seeks red giant for binary relationship.
*/

--- End Message ---
--- Begin Message ---
On Sunday 23 June 2002 05:40, [EMAIL PROTECTED] wrote:

> I still do have to welcome email, the problem like I mentioned in my first
> email is that I have been blocked by the admin/s and cannot send the owner
> a letter or send the unsubscribe email, it just bounces back :-(

Have you tried using your new email address?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Look into my eyes and try to forget that you have a Macy's charge card!
*/

--- End Message ---
--- Begin Message ---
On Friday 21 June 2002 17:12, [EMAIL PROTECTED] wrote:
> When I am in page A (or one of it's children) I wish to show it's one level
> of children like so:
>
> Page A
>   Child 1
>   Child 2
>   etc...
> Page B
>
> When I am in page B (or one of it's children) I wish to show it's one level
> of children like so:
>
> Page A
> Page B
>   Child 1
>   Child 2
>   etc...
>
> Do you get the picture?
>
> I have a db with link url, id, parent id and title
>
> does any one know of a simple function or something to do this for one
> level?

Have a look here:

http://phpclasses.gremlins.com.hk

There are a number of classes which deals with these tree menus.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
I do not fear computers.  I fear the lack of them.
                -- Isaac Asimov
*/

--- End Message ---
--- Begin Message ---
On Sunday 23 June 2002 07:21, Burak Delice wrote:
> hi,
>
> I wonder that is there a PHP function like window.open() into Javascript?

No.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
One thought driven home is better than three left on base.
*/

--- End Message ---
--- Begin Message ---
Hi, 

I'm having trouble getting a script working right in netscape 4.x and
was wondering if anybody knew a workaround, or fix.

If I have a script called "sendheader.php" with the following:

<?
if (! isset($GLOBALS[sendheader])) {
        header("Location: http://blah.com/sendheader.php";);
        exit;
}

echo "blah";
?>

Load the script in netscape 4.x with
http://blah.com/sendheader.php?sendheader=0. Then load the script like
http://blah.com/sendheader.php and netscape returns "Document contains
no data". It seems to break netscape 4.x if the Location header ==
current script name. Does anyone know how to get around this?

Tom
--- End Message ---
--- Begin Message ---
you can do this with the regular mailfunction.

Take a look at http://www.php.net/mail

Andy

--
----------------------------------------------------
http://www.globosapiens.net
Global Travellers Network!



"M.E. Suliman" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
000b01c219b8$afb448e0$13b81fc4@b1s0n2">news:000b01c219b8$afb448e0$13b81fc4@b1s0n2...
> Hi
>
> I've created a form and a bit of code that processes the form and directs
to
> a confirmation page asking the user to confirm if the details they entered
> are correct.  Once they hit the confirm button how would I send that
> confirmation page as an html file attached to their email.  I know its got
> something to do with MIME email but not too sure.
>
> Thanks in advance
>
> Mohamed
>
>


--- End Message ---
--- Begin Message ---
I've written a small freeware script that gets installed on a variety of
different platforms running various PHP versions.

I've read through the manual about the super global arrays and how post and
get vars are no longer registered by default, but am confused about when it
would be a good idea to "upgrade" the script.

If I change everything in the script and use $_GET and $_POST etc. then
those people who are still using earlier versions won't be able to upgrade.

Does anyone know what the uptake of the latest version is? What is everyone
else doing about this? If I were developing for one client it wouldn't be a
problem as obviously you'd know what you were developing for.

I'd just like some feedback on when would be a good time to upgrade the
scripts while causing the minimum disruption and maintaining maximum happy
users.

Thanks

Zim

--- End Message ---

Reply via email to