Current location: Hot Scripts Forums » Programming Languages » PHP » CGI Code Converting to PHP - need help


CGI Code Converting to PHP - need help

Reply
  #1 (permalink)  
Old 03-29-06, 04:52 AM
PHP Warner PHP Warner is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
CGI Code Converting to PHP - need help

Hello,

I need to convert cgi code to php.

Here is the code in cgi:

Code:
$serial = time . $$ . $ENV{REMOTE_ADDR} . $ENV{HTTP_USER_AGENT};
$serial =~ s/[^\d]//g;
This returns: 1142860071370361951741986650511801200601111501

I want to use similar code as php.

Many thanks for your advise and help.

Last edited by PHP Warner; 03-29-06 at 04:55 AM.
Reply With Quote
  #2 (permalink)  
Old 03-29-06, 05:22 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Maybe something like this?

PHP Code:



<?php

$serial 
time() . $_SERVER["REMOTE_ADDR"] . $_SERVER["HTTP_USER_AGENT"];
$serial md5($serial);

echo 
$serial;

?>
Returns: 849724ef97bdb0c1a171381c5577dbaf

It's a bit shorter and contains letters as well. Is that a problem?
Reply With Quote
  #3 (permalink)  
Old 03-29-06, 05:27 AM
PHP Warner PHP Warner is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Well, thanks nico but I need the value as numeric. Md5 is not a good solution right now.
Reply With Quote
  #4 (permalink)  
Old 03-29-06, 06:38 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Ok. Got this from php.net, modified it a bit though.

PHP Code:

<?php


$length 
46;

while (
count($nums) < 9)
{
    
$nums[rand(0,9)] = NULL;
}

while (
strlen($serial) < $length)
{
    
$serial .= array_rand($nums);
}

echo 
$serial;

?>
Returns a 46 chars long random number. Like: 6499624330599873995573033607660027940755633378
Reply With Quote
  #5 (permalink)  
Old 03-29-06, 07:32 AM
PHP Warner PHP Warner is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Very nice code nico thanks so much, I will try this.

But if you or some other people can find the code that I wanted please inform me : ).

Thanks anyway : ).
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code 2 convert .doc file into .pdf file jeephp PHP 7 11-03-10 04:31 AM
Can I insert PHP code into HTML ?? cc79 HTML/XHTML/XML 5 04-12-08 11:00 AM
problem with php code for website djengineer PHP 3 02-13-06 07:25 PM
Trying to echo PHP code from SQL and run it. And failing. Sheldon PHP 4 08-01-05 11:22 AM
Need help with PHP code rodman PHP 0 05-21-04 09:28 AM


All times are GMT -5. The time now is 07:06 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.