modifying a script that previously used register_globals

This is a discussion on modifying a script that previously used register_globals within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I have this script that previously stayed on a server that had register_globals on. I've switched servers that ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-04-2006
echelon3@yahoo.com
 
Posts: n/a
Default modifying a script that previously used register_globals

Hi, I have this script that previously stayed on a server that had
register_globals on. I've switched servers that understandably has it
off.

I've read up on php.net and other variables like $_SERVER[], but I
can't seem to modify it to a workable state. This form was used in
conjunction with flash... any help would be greatly appreciated!


<?php

$adminaddress = "info@ZZZZZZ.com";

$siteaddress ="http://www. ZZZZZZ.com";

$sitename = "ZZZZZZ";

$date = date("m/d/Y H:i:s");

if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

if ($action != ""):
mail("$adminaddress","Form: $subject",
"A visitor at $sitename has left the following information\n
Name: $name
Subject: $subject
Email: $email
Message:
------------------------------
$message

Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$adminaddress");

//confirmation email
mail("$email","Thank You for visiting $sitename",
"Hi $name,\n
We should receive your message shortly. If we do not give a reasonable
and timely response,
please send an email to info@ ZZZZZZ.com
\n
Thank you for your interest in $sitename!\n
Cheers,
$sitename
$siteaddress","FROM:$adminaddress");

//confirmation flash
$sendresult = "Thank you for visiting. You should receive a
confirmation email shortly. ";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo "$send_answer";

endif;

?>

Reply With Quote
  #2 (permalink)  
Old 04-04-2006
Arjen
 
Posts: n/a
Default Re: modifying a script that previously used register_globals

echelon3@yahoo.com wrote:
> Hi, I have this script that previously stayed on a server that had
> register_globals on. I've switched servers that understandably has it
> off.
>
> I've read up on php.net and other variables like $_SERVER[], but I
> can't seem to modify it to a workable state. This form was used in
> conjunction with flash... any help would be greatly appreciated!


One easy way is to add a few lines on top

$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];

and all the other vars

$somavar = (isset($_POST['somevar'])) ? $_POST['somevar'] :
$_GET['somevar'];
Reply With Quote
  #3 (permalink)  
Old 04-11-2006
Rik
 
Posts: n/a
Default Re: modifying a script that previously used register_globals

Arjen wrote:
> echelon3@yahoo.com wrote:
>> Hi, I have this script that previously stayed on a server that had
>> register_globals on. I've switched servers that understandably has it
>> off.
>>
>> I've read up on php.net and other variables like $_SERVER[], but I
>> can't seem to modify it to a workable state. This form was used in
>> conjunction with flash... any help would be greatly appreciated!

>
> One easy way is to add a few lines on top
>
> $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
>
> and all the other vars
>
> $somavar = (isset($_POST['somevar'])) ? $_POST['somevar'] :
> $_GET['somevar'];


Or, if you're lazy, which you shouldn't be:
foreach($_POST as $key => $value){
$$key = $value;
}
(same can be applied to $_SERVER, $_GET etc.)

Fast & dirty, with a lot more processing then necessary, but a quick
solution when stressed for time, or to get things working again while
working on a better solution.

Assigning values one by one is safer, yet somewhat unnecessary too.

Why not replace all your values like $REMOTE_ADDR with the likes of
$_SERVER['REMOTE_ADDR']? It's somewhat more work, but a good editor (I like
UltraEdit) can replace all occurances in different files of the variables
with a few clicks. I've been told some editors can even list your used
variables so you can quickly check wether you've missed one, but that's
something I've never used.

Grtz,

Rik


Reply With Quote
Reply


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

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



All times are GMT +1. The time now is 11:18 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0