error_log : $_COOKIE "Undefined index" "PHP Notice"
am 07.12.2007 15:51:49 von Pseudonyme
Dear All :
Ever had an httpd error_log bigger than the httpd access log ?
We are using Linux-Apache-Fedora-Httpd 2006 configuration.
The PHP lines code that lead too tons of errors are :
$http_ref= $HTTP_REFERER;
$prog = $_COOKIE['cpm'."$j"];
$redirect .='Location:'.$uploadpath;
We believe HTTPD does not understand environement variables.
We had to put that : error_reporting(0); in the top of the file to get
the errors stop to be reported.
An expert said to insert an isset funtion :
http://www.experts-exchange.com/Web_Development/Web_Language s-Standards/PHP/PHP_Installation/Q_21354370.html
But that doeas lead to a success.
From your background and experience, how do you think we can fix up
the code ?
Regards;
Gle Cougloff
Re: error_log : $_COOKIE "Undefined index" "PHP Notice"
am 07.12.2007 16:15:14 von Jerry Stuckle
Pseudonyme wrote:
> Dear All :
>
> Ever had an httpd error_log bigger than the httpd access log ?
>
> We are using Linux-Apache-Fedora-Httpd 2006 configuration.
>
> The PHP lines code that lead too tons of errors are :
>
> $http_ref= $HTTP_REFERER;
> $prog = $_COOKIE['cpm'."$j"];
> $redirect .='Location:'.$uploadpath;
>
> We believe HTTPD does not understand environement variables.
>
> We had to put that : error_reporting(0); in the top of the file to get
> the errors stop to be reported.
>
> An expert said to insert an isset funtion :
> http://www.experts-exchange.com/Web_Development/Web_Language s-Standards/PHP/PHP_Installation/Q_21354370.html
>
> But that doeas lead to a success.
>
> From your background and experience, how do you think we can fix up
> the code ?
>
> Regards;
> Gle Cougloff
>
>
>
>
>
>
Check to see if $_COOKIE['cpm'."$j"] exists before trying to use it.
Never use a variable (or in this case an array element) unless either
you have set it ourself, or have checked to see if it has been
previously set.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: error_log : $_COOKIE "Undefined index" "PHP Notice"
am 07.12.2007 16:58:30 von Michael Fesser
..oO(Pseudonyme)
>We are using Linux-Apache-Fedora-Httpd 2006 configuration.
>
>The PHP lines code that lead too tons of errors are :
>
>$http_ref= $HTTP_REFERER;
Should be
$http_ref = $_SERVER['HTTP_REFERER'];
Also remember that the referrer might be empty or faked.
>$prog = $_COOKIE['cpm'."$j"];
>$redirect .='Location:'.$uploadpath;
>
>We believe HTTPD does not understand environement variables.
This has nothing to do with environment variables.
>We had to put that : error_reporting(0); in the top of the file to get
>the errors stop to be reported.
>
>An expert said to insert an isset funtion :
>http://www.experts-exchange.com/Web_Development/Web_Languag es-Standards/PHP/PHP_Installation/Q_21354370.html
>
>But that doeas lead to a success.
>
>From your background and experience, how do you think we can fix up
>the code ?
First you should post the _exact_ and _complete_ error messages. Your
message subject says nothing really helpful.
Micha
Re: error_log : $_COOKIE "Undefined index" "PHP Notice"
am 07.12.2007 17:51:56 von Pseudonyme
error log =3D 130% access_log in terms of weight !
Dear Sirs,
We thank you for your advise and answer your request. We prey to be as
clear as possible.
1. error log (130% the weight of the access_log)
PHP Notice: Undefined index: HTTP_REFERER in /home/virtual/site3/fst/
var/www/html/cpm_cost.php on line 8
[client 83.155.157.238]
PHP Notice: Undefined index: cpm9 in /home/virtual/site3/fst/var/www/
html/cpm_cost.php on line 45
[client 83.155.157.238]
PHP Notice: Undefined variable: redirect in /home/virtual/site3/fst/
var/www/html/cpm_cost.php on line 106
line 8 : $http_ref=3D $_SERVER['HTTP_REFERER'];
line 45 :
42. for($j=3D0; $j <=3D $i;$j++)
43.{
44.
45. $prog =3D $_COOKIE['cpm'."$j"];
line 106 :
$redirect .=3D'Location:'.$uploadpath;
2. Extract from cpm_cost. php
error_reporting(0);
include_once("...");
header("P3P: policyref=3D\"http://www.gle-mosco.com/adveruser/p3p.xml
\",CP=3D\"NON DSP COR CURa PSA PSD OUR BUS NAV STA\"");
$http_ref=3D $_SERVER['HTTP_REFERER'];
$affsite=3D$_REQUEST['affsite'];
$banner=3D$_REQUEST['banner'];
$date =3D time();
$capping =3D 300*60;
$i=3D0;
$cookieok=3D0;
while(isset($_COOKIE['cpm'."$i"]) )
{
$i++;
}
for($j=3D0; $j <=3D $i;$j++)
{
$prog =3D $_COOKIE['cpm'."$j"];
$array =3D preg_split('/#/',$prog);
if ($array[0] ==$affsite && $array[1] == $banner && (($array[2] +
$capping) > $date) )
{
$cookieok =3D 1;
}
else if ($array[0] ==$affsite && $array[1] == $banner && (($array[2=
]
+ $capping) < $date) )
{
$cookieok =3D 2;
setcookie("cpm".$j,$affsite."#".$banner."#".$date,time()
+24*60*60*365*10);
}
}
if($cookieok == 0)
{
setcookie("cpm".$i,$affsite."#".$banner."#".$date,time()
+24*60*60*365*10);
}
if($cookieok == 2)
{
$cookieok=3D0;
}
$qryStatus=3D"Select a.status as status, pi.status as prog_status from
Tbl_Affiliate_Program_Status a,Tbl_Creative_Information b,
Tbl_Program_Information pi where a.website_id=3D$affsite and b.banner_id
=3D $banner and b.program_id =3D a.program_id and pi.program_id =3D
b.program_id";
$rsStatus=3Dselect_query($qryStatus);
$site=3D$affsite;
if($rsStatus['0']['status']=='a' && $rsStatus['0']
['prog_status']=='e' )//only for accepted affiliates
{
$sqlup =3D "select upload_path,append_type from
Tbl_Creative_Information where banner_id =3D $banner";
$rsup =3D select_query($sqlup);
if($rsup['0']['append_type'] !=3D 'h')
{
$uploadpath =3D $rsup[0]['upload_path'];
}
if(count($uploadpath)!=3D0)
{
$str =3D split("#",$uploadpath);
if(count($str) !=3D 0)
{
if(preg_match("/data/", $str[0], $matches)!=3D'')
{
$redirect .=3D'Location:'.$str[0].$affsite;
}
else
{
$redirect .=3D'Location:'.$uploadpath;
}
}
}
if($rsup['0']['append_type'] !=3D 'h') //²²=B2 imagegif($im);
header ($redirect);
$gi =3D geoip_open("gle-mosco_global/geoIP/GeoIP.dat",
GEOIP_STANDARD);
{
if (!((geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="United
States") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Canada") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Switzerland")
||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Belgium") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="France") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="United Kingdom")
||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Luxembourg")))
{} else {
if($cookieok == 0)
{
$qryInsert=3D"insert into CPM_TEMP_1H (banner_id,affsite_id)
values($banner,$site)";
update_query($qryInsert);
}
}
}
}
?>
Re: error_log : $_COOKIE "Undefined index" "PHP Notice"
am 07.12.2007 18:07:18 von Michael Fesser
..oO(Pseudonyme)
>We thank you for your advise and answer your request. We prey to be as
>clear as possible.
>
>1. error log (130% the weight of the access_log)
>
>PHP Notice: Undefined index: HTTP_REFERER in /home/virtual/site3/fst/
>var/www/html/cpm_cost.php on line 8
>[client 83.155.157.238]
As said earlier, the referrer can be empty, which causes this message.
Before you want to use it (if you want to use it at all, because it's
completely unreliable), check with isset() or empty() if it exists:
if (isset($_SERVER['HTTP_REFERER'])) {
...
}
>PHP Notice: Undefined index: cpm9 in /home/virtual/site3/fst/var/www/
>html/cpm_cost.php on line 45
>[client 83.155.157.238]
Same thing with the cookie value. Obviously it's not set. isset() or
empty() should be used more often.
>PHP Notice: Undefined variable: redirect in /home/virtual/site3/fst/
>var/www/html/cpm_cost.php on line 106
This code:
>line 106 :
>$redirect .='Location:'.$uploadpath;
tries to append a value to $redirect, which is equivalent to
$redirect = $redirect.'Location:'.$uploadpath;
If $redirect doesn't exist yet, you'll get the notice. You could simply
remove the dot to make this an assignment rather than an appending:
$redirect = 'Location:'.$uploadpath;
or
$redirect = "Location: $uploadpath";
Also note that $uploadpath _must_ contain an absolute URL, including the
scheme (http:) and host name. This is required by the HTTP spec.
>
This should be
disabled on the server.
>error_reporting(0);
>include_once("...");
>header("P3P: policyref=\"http://www.gle-mosco.com/adveruser/p3p.xml
>\",CP=\"NON DSP COR CURa PSA PSD OUR BUS NAV STA\"");
>$http_ref= $_SERVER['HTTP_REFERER'];
>$affsite=$_REQUEST['affsite'];
>$banner=$_REQUEST['banner'];
$_REQUEST is usually bad as well, since you don't know where the data is
actually coming from. If you expect a URL parameter, use $_GET.
I didn't go through the rest of the code.
Micha