php-general Digest 2 Jan 2004 05:52:28 -0000 Issue 2507

Topics (messages 173604 through 173622):

Re: PHP New Year
        173604 by: Alex

Re: Having problems with a while loop
        173605 by: Richard Kurth
        173606 by: Richard Davey
        173616 by: Tom Rogers

Re: No COOKIE Set?
        173607 by: Jim & Sara Feldman
        173608 by: Cesar Aracena

A simple instruction
        173609 by: Dino Costantini
        173610 by: Leif K-Brooks
        173611 by: Philip J. Newman
        173613 by: John W. Holmes
        173614 by: Mike Migurski

Class Accessor methods??
        173612 by: Robin Kopetzky

Please help on session_destroy error...
        173615 by: Tim Meader
        173617 by: Tim Meader
        173618 by: Jeremy Johnstone
        173620 by: Tim Meader

.htaccess problem
        173619 by: Ryan A
        173622 by: Andrew Séguin

Apologies for multiple posts.
        173621 by: Tim Meader

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 --- Larry Brown wrote:

Happy New year all!

Looking forward to bigger better things this year.

Larry
yep, like php5 :)
--- End Message ---
--- Begin Message ---

Ok I changed it to look this way but it still is not working
$filenum="test";
$fpHt = fopen($filenum, "r");
while(feof($fpHt)) {
$fpLine = fgets($fpHt,512);
$fpLine = trim($fpLine);
$fpData = explode(":", $fpLine);
$fpData[0] = trim($fpData[0]);
echo $fpData[0];
}

And no I am just reading a .htpasswd file to get the user name out of
it



RD> your fgets should be inside the loop. else you are in an infite loop.

RD> ps: are you brute forcing password file ;-)



>>Way does this while loop not work.
>>It does not read anything in  the file. If I add ! in front of feof it
>>will just loop forever but still it will not read the next line in the
>>file. The file has two lines in it that look like this.
>>tester3:$1$09BZpdge$b7TQcsYSsAP1hgiCuCWtS1
>>tester5:$1$5eq3i75D$XK9QzaS.7bHyWVf4bdyJs/
>>
>>
>>$filenum="test";
>>$fpHt = fopen($filenum, "r");
>>$fpLine = fgets($fpHt,512);
>>while(feof($fpHt)) {
>>$fpLine = trim($fpLine);
>>$fpData = explode(":", $fpLine);
>>$fpData[0] = trim($fpData[0]);
>>echo $fpData[0];
>>}

--- End Message ---
--- Begin Message ---
Hello Richard,

Thursday, January 1, 2004, 5:56:35 PM, you wrote:

RK> Ok I changed it to look this way but it still is not working
RK> $filenum="test";
RK> $fpHt = fopen($filenum, "r");
RK> while(feof($fpHt)) {
RK> $fpLine = fgets($fpHt,512);
RK> $fpLine = trim($fpLine);
RK> $fpData = explode(":", $fpLine);
RK> $fpData[0] = trim($fpData[0]);
RK> echo $fpData[0];
RK> }

>>>tester3:$1$09BZpdge$b7TQcsYSsAP1hgiCuCWtS1
>>>tester5:$1$5eq3i75D$XK9QzaS.7bHyWVf4bdyJs/

Save yourself some grief and use the file() function instead.

$filename = "test";
$fileData = file($filename);

for ($i = 0; $i < count($fileData); $i++)
{
    $output = substr($fileData[$i], 0, strpos($fileData[$i], ":"));
    echo $output;
}

strpos will work fine for this assuming the users don't have a : in
their username! Otherwise it'll return the first occurrence of it
within the string.

If it doesn't echo anything out, the file() function failed.

Warning: above not tested, just typed direct into this email. But
baring obvious syntax errors I might have typo'd, it should work.

-- 
Best regards,
 Richard                            mailto:[EMAIL PROTECTED]

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

Friday, January 2, 2004, 3:56:35 AM, you wrote:


RK> Ok I changed it to look this way but it still is not working
RK> $filenum="test";
RK> $fpHt = fopen($filenum, "r");
RK> while(feof($fpHt)) {
RK> $fpLine = fgets($fpHt,512);
RK> $fpLine = trim($fpLine);
RK> $fpData = explode(":", $fpLine);
RK> $fpData[0] = trim($fpData[0]);
RK> echo $fpData[0];
RK> }

RK> And no I am just reading a .htpasswd file to get the user name out of
RK> it


should be while(!eof.....

-- 
regards,
Tom

--- End Message ---
--- Begin Message --- Cesar:

I think that the problem is the array in the "echo" statement. I have found that I have to do something
like:


$simple = $_COOKIE["MemberId"];
echo "Member ID = $simple";

Hope that helps.

Jim


Hi all,

My head is about to explode here... I am trying to setup a cookie for every
new user that registers in my site and right after that, to send them to the
home page... is that so difficult? apparently yes... It does redirect, but
when I try to "echo" the $MemberId cookie with:

echo $_COOKIE["MemberId"];

Nothing happens... nothing is displayed... also, I can't find where these
cookies are being stored. I am developing under WinXP, latest PHP and latest
MySQL... other cookies are being stored very well, but I don-t know where...
I'm displaying at http://localhost/..... øøø???

Here's my script:

   if ($use_same_data == "yes") // One kind of information stored
   {
   $query = "INSERT INTO members_info ....... )";
   $result = mysql_query($query);
   $id = mysql_insert_id();
   }

   elseif ($use_same_data == "") // Other kind of choice of information for
shipping address
   {
    $query = "INSERT INTO members_info .......)";
    $result = mysql_query($query);
    $id = mysql_insert_id();
   }

   if (!$result)
   {
    echo "Error code here";
   }
   else
   {
    setcookie ("MemberId", $id, time()+31536000);
    header ("Location: $CFG->wwwroot");
    exit();
   }

Thax in advanced,

Cesar


--
Jim Feldman
14 Linda Lane
Newton, MA 02461

617-527-0509
--- End Message ---
--- Begin Message ---
It worked but not at all. I placed the setcookie() function in a folder
that's under the main one. When displaying the cookie like you told me, now
appears right just in the .php files under the same folder of the
setcookie() function, but not in the other (like the site's main pages)...
¿?¿?¿?

I didn't put any path or domain argument... just the name, value and time...

Thanks, Cesar

"Jim & Sara Feldman" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
Cesar:

I think that the problem is the array in the
"echo" statement. I have found that I have to do
something
like:

$simple = $_COOKIE["MemberId"];
echo "Member ID = $simple";

Hope that helps.

Jim


>Hi all,
>
>My head is about to explode here... I am trying to setup a cookie for every
>new user that registers in my site and right after that, to send them to
the
>home page... is that so difficult? apparently yes... It does redirect, but
>when I try to "echo" the $MemberId cookie with:
>
>echo $_COOKIE["MemberId"];
>
>Nothing happens... nothing is displayed... also, I can't find where these
>cookies are being stored. I am developing under WinXP, latest PHP and
latest
>MySQL... other cookies are being stored very well, but I don-t know
where...
>I'm displaying at http://localhost/..... øøø???
>
>Here's my script:
>
>    if ($use_same_data == "yes") // One kind of information stored
>    {
>    $query = "INSERT INTO members_info ....... )";
>    $result = mysql_query($query);
>    $id = mysql_insert_id();
>    }
>
>    elseif ($use_same_data == "") // Other kind of choice of information
for
>shipping address
>    {
>     $query = "INSERT INTO members_info .......)";
>     $result = mysql_query($query);
>     $id = mysql_insert_id();
>    }
>
>    if (!$result)
>    {
>     echo "Error code here";
>    }
>    else
>    {
>     setcookie ("MemberId", $id, time()+31536000);
>     header ("Location: $CFG->wwwroot");
>     exit();
>    }
>
>Thax in advanced,
>
>Cesar


--
Jim Feldman
14 Linda Lane
Newton, MA 02461

617-527-0509

--- End Message ---
--- Begin Message ---
i have a file name with the path ex food/italy/pizza/margherita.php. how can i obtain 
the name of the file in this case "margherita.php" i know there is a function, but i 
don't remember it.
thx

--- End Message ---
--- Begin Message --- Dino Costantini wrote:

i have a file name with the path ex food/italy/pizza/margherita.php. how can i obtain the name of the file in this case "margherita.php" i know there is a function, but i don't remember it.

$_SERVER['PHP_SELF']
--- End Message ---
--- Begin Message ---
echo"$PHP_SELF";

maybe?

----- Original Message ----- 
From: "Dino Costantini" <>
To: "PHP Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, January 02, 2004 11:30 AM
Subject: [PHP] A simple instruction


i have a file name with the path ex food/italy/pizza/margherita.php. how can i obtain 
the name of
the file in this case "margherita.php" i know there is a function, but i don't 
remember it.
thx

--- End Message ---
--- Begin Message --- Dino Costantini wrote:
i have a file name with the path ex food/italy/pizza/margherita.php. how can i obtain the name of the file in this case "margherita.php" i know there is a function, but i don't remember it.

basename()


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
>i have a file name with the path ex food/italy/pizza/margherita.php. how
>can i obtain the name of the file in this case "margherita.php" i know
>there is a function, but i don't remember it.

basename(__FILE__) may work.

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

--- End Message ---
--- Begin Message ---
Happy New Year!!

        Is there a more efficient type of class accessor than using Get/Set like
this?

        function GetValue()
        {
                return $this->value;
        }
        function SetValue($value)
        {
                $this->value = $value;
        }

Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020

--- End Message ---
--- Begin Message --- I'm looking for help trying to do away with an error I get from time to time in my access control session logic. Here is my session setup from the php.ini:

session.save_handler = files
session.save_path = /tmp
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = gsfc.nasa.gov
session.cookie_secure = On
session.serialize_handler = php
session.gc_probability = 100
session.gc_maxlifetime = 1800
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 32
session.entropy_file = /dev/urandom
session.cache_limiter =
session.cache_expire = 180
session.use_trans_sid = 0

Now, to my understanding, with this setup, the session cookie should be good for as long as the browser is open, the garbage collector will be run on any session startup, and a session should be considered garbage after 3 hours. My problem is that these settings don't always seem to be followed. Even after sitting for only 60 minutes sometimes, if I click on the logout button in my interface (which executes the following code), I get a session_destroy error, about it the session being called for destruction not being found....

    if ((!empty($_GET['action'])) && ($_GET['action'] == "logout")) {
        session_unset();
        if (!empty($_SESSION['logged_in'])) {
            session_destroy();
        }
     }

The only other code is simple HTML output. The session variable "logged_in" is set upon successful login initially. My rationale for that variable is that if the session file gets removed via the garbage collector, then that check above should fail, and the session_destroy function won't be called. But this doesn't seem to ever work. Is there anything I'm missing here? Any help would be appreciated. This is all running on Apache 1.3.29, using Redhat 8 with all current updates, and PHP 4.3.4.

Thanks in advance for any help you may have.




---
Tim Meader
CNE ODIN Unix Group
Lockheed Martin Information Technologies
[EMAIL PROTECTED]
(301) 286-8013

--- End Message ---
--- Begin Message --- I'm looking for help trying to do away with an error I get from time to time in my access control session logic. Here is my session setup from the php.ini:

session.save_handler = files
session.save_path = /tmp
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = gsfc.nasa.gov
session.cookie_secure = On
session.serialize_handler = php
session.gc_probability = 100
session.gc_maxlifetime = 1800
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 32
session.entropy_file = /dev/urandom
session.cache_limiter =
session.cache_expire = 180
session.use_trans_sid = 0

Now, to my understanding, with this setup, the session cookie should be good for as long as the browser is open, the garbage collector will be run on any session startup, and a session should be considered garbage after 3 hours. My problem is that these settings don't always seem to be followed. Even after sitting for only 60 minutes sometimes, if I click on the logout button in my interface (which executes the following code), I get a session_destroy error, about it the session being called for destruction not being found....

    if ((!empty($_GET['action'])) && ($_GET['action'] == "logout")) {
        session_unset();
        if (!empty($_SESSION['logged_in'])) {
            session_destroy();
        }
     }

The only other code is simple HTML output. The session variable "logged_in" is set upon successful login initially. My rationale for that variable is that if the session file gets removed via the garbage collector, then that check above should fail, and the session_destroy function won't be called. But this doesn't seem to ever work. Is there anything I'm missing here? Any help would be appreciated. This is all running on Apache 1.3.29, using Redhat 8 with all current updates, and PHP 4.3.4.

Thanks in advance for any help you may have.




---
Tim Meader
CNE ODIN Unix Group
Lockheed Martin Information Technologies
[EMAIL PROTECTED]
(301) 286-8013

--- End Message ---
--- Begin Message ---
You problem is probably right here:

session.gc_maxlifetime = 1800

That sets the garbage collection timeout to 30 minutes... 

Per the manual:

session.gc_maxlifetime specifies the number of seconds after which data
will be seen as 'garbage' and cleaned up.

It is not "strictly" followed, but PHP does it's best to destroy data
after that timeout elapses. This would explain why sometimes you can
last an hour without getting the error. If you want your timeout to be 3
hours, then I would set that value to something like 11,000 (which is
just a little over 3 hours).

-Jeremy

On Thu, 2004-01-01 at 19:30, Tim Meader wrote:
> I'm looking for help trying to do away with an error I get from time to 
> time in my access control session logic. Here is my session setup from the 
> php.ini:
> 
> session.save_handler = files
> session.save_path = /tmp
> session.use_cookies = 1
> session.use_only_cookies = 1
> session.name = PHPSESSID
> session.auto_start = 0
> session.cookie_lifetime = 0
> session.cookie_path = /
> session.cookie_domain = gsfc.nasa.gov
> session.cookie_secure = On
> session.serialize_handler = php
> session.gc_probability = 100
> session.gc_maxlifetime = 1800
> session.bug_compat_42 = 0
> session.bug_compat_warn = 1
> session.referer_check =
> session.entropy_length = 32
> session.entropy_file = /dev/urandom
> session.cache_limiter =
> session.cache_expire = 180
> session.use_trans_sid = 0
> 
> Now, to my understanding, with this setup, the session cookie should be 
> good for as long as the browser is open, the garbage collector will be run 
> on any session startup, and a session should be considered garbage after 3 
> hours.  My problem is that these settings don't always seem to be followed. 
> Even after sitting for only 60 minutes sometimes, if I click on the logout 
> button in my interface (which executes the following code), I get a 
> session_destroy error, about it the session being called for destruction 
> not being found....
> 
>      if ((!empty($_GET['action'])) && ($_GET['action'] == "logout")) {
>          session_unset();
>          if (!empty($_SESSION['logged_in'])) {
>              session_destroy();
>          }
>       }
> 
> The only other code is simple HTML output. The session variable "logged_in" 
> is set upon successful login initially. My rationale for that variable is 
> that if the session file gets removed via the garbage collector, then that 
> check above should fail, and the session_destroy function won't be called. 
> But this doesn't seem to ever work. Is there anything I'm missing here? Any 
> help would be appreciated. This is all running on Apache 1.3.29, using 
> Redhat 8 with all current updates, and PHP 4.3.4.
> 
> Thanks in advance for any help you may have.
> 
> 
> 
> 
> ---
> Tim Meader
> CNE ODIN Unix Group
> Lockheed Martin Information Technologies
> [EMAIL PROTECTED]
> (301) 286-8013  

--- End Message ---
--- Begin Message ---
I'm looking for help trying to do away with an error I get from time to
time in my access control session logic. Here is my session setup from the
php.ini:

session.save_handler = files
session.save_path = /tmp
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = gsfc.nasa.gov
session.cookie_secure = On
session.serialize_handler = php
session.gc_probability = 100
session.gc_maxlifetime = 1800
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 32
session.entropy_file = /dev/urandom
session.cache_limiter =
session.cache_expire = 180
session.use_trans_sid = 0

Now, to my understanding, with this setup, the session cookie should be
good for as long as the browser is open, the garbage collector will be run
on any session startup, and a session should be considered garbage after 3
hours.  My problem is that these settings don't always seem to be followed.
Even after sitting for only 60 minutes sometimes, if I click on the logout
button in my interface (which executes the following code), I get a
session_destroy error, about it the session being called for destruction
not being found....

     if ((!empty($_GET['action'])) && ($_GET['action'] == "logout")) {
         session_unset();
         if (!empty($_SESSION['logged_in'])) {
             session_destroy();
         }
      }

The only other code is simple HTML output. The session variable "logged_in"
is set upon successful login initially. My rationale for that variable is
that if the session file gets removed via the garbage collector, then that
check above should fail, and the session_destroy function won't be called.
But this doesn't seem to ever work. Is there anything I'm missing here? Any
help would be appreciated. This is all running on Apache 1.3.29, using
Redhat 8 with all current updates, and PHP 4.3.4.

Thanks in advance for any help you may have.



-------
Tim
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Hi,
I dont know if this is really a PHP problem but am wondering if I can
perhaps use php to solve this problem...

I dont know if this is just a problem on my server or if you have noticed
this too but...

heres my present setup:

/root/protected_files/
/root/protected_files/one/
/root/protected_files/two/
/root/protected_files/three/
/root/protected_files/four/

Each of the protected folders have their own .htaccess and their own
password file, but if some successfully comes into folder "one" they are not
being asked for their login details again if they go to two,three or
four...Why is that and anyway I can force them?

Thanks,
-Ryan

--- End Message ---
--- Begin Message ---
That would be based on 'realms'.

see : http://httpd.apache.org/docs-2.0/mod/core.html#authname for more
info on how to set that.

Basicaly, most browsers cache the userid and password as long as the page
you are viewing is within the same realm (don't ask for userid and
password again).

Your solution would therefore be to define your realm as (or anything
else) "mysite's protected content" in protected_files/ and then "mysite's
protected content part one" in protected_files/one/ , "mysite's protected
content part two" in protected_files/two/ .. within your htaccess files.
As long as it's different, the browser will ask for the user name and
password again.

Hope that helps,
Andrew

> Hi,
> I dont know if this is really a PHP problem but am wondering if I can
> perhaps use php to solve this problem...
>
> I dont know if this is just a problem on my server or if you have noticed
> this too but...
>
> heres my present setup:
>
> /root/protected_files/
> /root/protected_files/one/
> /root/protected_files/two/
> /root/protected_files/three/
> /root/protected_files/four/
>
> Each of the protected folders have their own .htaccess and their own
> password file, but if some successfully comes into folder "one" they are
> not
> being asked for their login details again if they go to two,three or
> four...Why is that and anyway I can force them?
>
> Thanks,
> -Ryan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--- End Message ---
--- Begin Message --- I was getting a posting failure message from this listserv's auto-responder, but they appear to have posted anyway.


-------
Tim
[EMAIL PROTECTED]

--- End Message ---

Reply via email to