[PHP] base64 encode question

2008-04-03 Thread Sn!per
Hi all, I have a short script that I want to store the last login time  
and the host IP number (harcoded for the moment). Those two variables  
are stored in $last_login, which is an array.


[EMAIL PROTECTED] test]# cat lt.php
?
$last_login = array('time' = time(), 'host' = 192.168.10.100);
$serialize_last_login = serialize($last_login);
print $serialize_last_login\n;

$encoded_serialize_last_login = base64_encode($serialize_last_login);
print encoded value is: $encoded_serialize_last_login\n\n;

?
[EMAIL PROTECTED] test]#

When I ran the script, I can see that $serialize_last_login have  
different value for 'time'. But why does $encoded_serialize_last_login  
always show the same value? Below is the output after running the  
script for 3 times:


[EMAIL PROTECTED] test]# php lt.php
a:2:{s:4:time;i:1207208982;s:4:host;s:14:192.168.10.100;}
encoded value is:  
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4MjtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9


[EMAIL PROTECTED] test]# php lt.php
a:2:{s:4:time;i:1207208984;s:4:host;s:14:192.168.10.100;}
encoded value is:  
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NDtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9


[EMAIL PROTECTED] test]# php lt.php
a:2:{s:4:time;i:1207208985;s:4:host;s:14:192.168.10.100;}
encoded value is:  
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NTtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9


Please help

--
Roger




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


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



Re: [PHP] base64 encode question

2008-04-03 Thread Aschwin Wesselius

Sn!per wrote:
encoded value is: 
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4MjtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9 

encoded value is: 
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NDtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9 

encoded value is: 
YToyOntzOjQ6InRpbWUiO2k6MTIwNzIwODk4NTtzOjQ6Imhvc3QiO3M6MTQ6IjE5Mi4xNjguMTAuMTAwIjt9 



Hi,

They are not the same!

If you look closely enough, only one digit in the value is different. So 
the base64 encoded value has to differ only some values, not the whole 
string.


4MjtzO is different than
4NDtzO is different than
4NTtzO

You see?

So, the whole string is different and thus unique.

Hope this helps!
--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] Base64 Encode

2003-02-02 Thread Stephen
I have register globals off, and am using both $HTTP_GET_VARS['goto'] and
$_GET['goto']. The problem is not with receiving it, the problem is sending
it. Forexample, a sample URL would look something like this after
redirecting:

http://whatever.com/index.php?goto=


- Original Message -
From: Evan Nemerson [EMAIL PROTECTED]
To: Stephen [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Sunday, February 02, 2003 2:24 AM
Subject: Re: [PHP] Base64 Encode


: What about $_GET['goto']??? Sounds like another register_globals issue.
Also,
: instead of base64 encoding, you may want to use the rawurlencode and
: rawurldecode functions.
:
:
:
: On Saturday 01 February 2003 07:02 pm, Stephen wrote:
:  I have a PHP script that works on older versions of PHP but on 4.3, it
:  outputs nothing. Here's my code:
: 
:  ?php
:  echo 'SCRIPT language=JavaScript type=text/javascript'.\n
:  .\n.'if (document.location == top.location)'.\n
:  .'  top.location=home.php?goto='
: .base64_encode($_SERVER[REQUEST_URI]).';'.\n
:  .'/SCRIPT';
:  ?
: 
:  The problem is, when it redirects, the URL variable goto is empty. I'm
:  assuming this has something to do with base64_encode. Since this code
:  snipet is on every page of my site, it'd be a hard hassle to change it
so
:  is there a setting in PHP I need to tweak or should I set aside a few
hours
:  to edit this code? If the latter, what should I change it to?
: 
:  Thanks,
:  Stephen Craton
:  http://www.melchior.us
: 
:  What's the point in appearance if your true love, doesn't care about
:  it? -- http://www.melchior.us
:
: --
: If anyone can show me, and prove to me, that I am wrong in thought or
deed, I
: will gladly change. I seek the truth, hich never yet hurt anybody. It is
only
: persistence in elf-delusion and ignorance which does harm.
:
: -Marcus Aurelius
:
:
: --
: 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] Base64 Encode

2003-02-02 Thread Lowell Allen
 From: Stephen [EMAIL PROTECTED]
 
 I have a PHP script that works on older versions of PHP but on 4.3, it
 outputs nothing. Here's my code:
 
 ?php
 echo 'SCRIPT language=JavaScript type=text/javascript'.\n
 .\n.'if (document.location == top.location)'.\n
 .'  top.location=home.php?goto='
 .base64_encode($_SERVER[REQUEST_URI]).';'.\n
 .'/SCRIPT';
 ?
 
 The problem is, when it redirects, the URL variable goto is empty. I'm
 assuming this has something to do with base64_encode. Since this code snipet
 is on every page of my site, it'd be a hard hassle to change it so is there
 a setting in PHP I need to tweak or should I set aside a few hours to edit
 this code? If the latter, what should I change it to?

I hope this relates -- I use the code below as a force frame, placing it
at the top of all content pages as an include. (In my case info.php posts to
index.php, which allows any content page that's called directly to be
returned in a frameset.)

?
$path_array = explode(/, $REQUEST_URI);
$page_name = array_pop($path_array);
?
script language=JavaScript
!--
if (top.location == self.location) {
top.location.href = info.php?contents= + ?=$page_name?
}
// --
/script

--
Lowell Allen


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




[PHP] Base64 Encode

2003-02-01 Thread Stephen
I have a PHP script that works on older versions of PHP but on 4.3, it
outputs nothing. Here's my code:

?php
echo 'SCRIPT language=JavaScript type=text/javascript'.\n
.\n.'if (document.location == top.location)'.\n
.'  top.location=home.php?goto='
   .base64_encode($_SERVER[REQUEST_URI]).';'.\n
.'/SCRIPT';
?

The problem is, when it redirects, the URL variable goto is empty. I'm
assuming this has something to do with base64_encode. Since this code snipet
is on every page of my site, it'd be a hard hassle to change it so is there
a setting in PHP I need to tweak or should I set aside a few hours to edit
this code? If the latter, what should I change it to?

Thanks,
Stephen Craton
http://www.melchior.us

What's the point in appearance if your true love, doesn't care about
it? -- http://www.melchior.us


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


Re: [PHP] Base64 Encode

2003-02-01 Thread Evan Nemerson
What about $_GET['goto']??? Sounds like another register_globals issue. Also, 
instead of base64 encoding, you may want to use the rawurlencode and 
rawurldecode functions.



On Saturday 01 February 2003 07:02 pm, Stephen wrote:
 I have a PHP script that works on older versions of PHP but on 4.3, it
 outputs nothing. Here's my code:

 ?php
 echo 'SCRIPT language=JavaScript type=text/javascript'.\n
 .\n.'if (document.location == top.location)'.\n
 .'  top.location=home.php?goto='
.base64_encode($_SERVER[REQUEST_URI]).';'.\n
 .'/SCRIPT';
 ?

 The problem is, when it redirects, the URL variable goto is empty. I'm
 assuming this has something to do with base64_encode. Since this code
 snipet is on every page of my site, it'd be a hard hassle to change it so
 is there a setting in PHP I need to tweak or should I set aside a few hours
 to edit this code? If the latter, what should I change it to?

 Thanks,
 Stephen Craton
 http://www.melchior.us

 What's the point in appearance if your true love, doesn't care about
 it? -- http://www.melchior.us

-- 
If anyone can show me, and prove to me, that I am wrong in thought or deed, I 
will gladly change. I seek the truth, hich never yet hurt anybody. It is only 
persistence in elf-delusion and ignorance which does harm.

-Marcus Aurelius


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