php 设置cookie高级用法
function getvis(&$pagesid,&$retime) {
global $err,$conf,$HTTP_COOKIE_VARS,$_COOKIE;
if(isset($_COOKIE['ant'])) $cot=$_COOKIE['ant'];
elseif(isset($HTTP_COOKIE_VARS['ant'])) $cot=$HTTP_COOKIE_VARS['ant'];
else $cot='';
$cos=preg_split("/x/",$cot);
$max=sizeof($cos);
for($c=0;$c
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$anct[$id]=$cos[$c];
}
}
if(isset($_COOKIE['anm'])) $com=$_COOKIE['anm'];
elseif(isset($HTTP_COOKIE_VARS['anm'])) $com=$HTTP_COOKIE_VARS['anm'];
else $com='';
$cos=preg_split("/x/",$com);
$max=sizeof($cos);
for($c=0;$c
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->mtime) $ancm[$id]=$cos[$c];
}
}
if(isset($_COOKIE['anw'])) $cow=$_COOKIE['anw'];
elseif(isset($HTTP_COOKIE_VARS['anw'])) $cow=$HTTP_COOKIE_VARS['anw'];
else $cow='';
$cos=preg_split("/x/",$cow);
$max=sizeof($cos);
for($c=0;$c
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->wtime) $ancw[$id]=$cos[$c];
}
}
if(isset($_COOKIE['an1'])) $co1=$_COOKIE['an1'];
elseif(isset($HTTP_COOKIE_VARS['an1'])) $co1=$HTTP_COOKIE_VARS['an1'];
else $co1='';
$cos=preg_split("/x/",$co1);
$max=sizeof($cos);
for($c=0;$c
if(strlen($cos[$c])==10) {
$id=substr($cos[$c],0,2);
eval("$id=0x$id;");
$tim=substr($cos[$c],2,8);
eval("$tim=0x$tim;");
if($tim>=$conf->dtime) $anc1[$id]=$cos[$c];
}
}
//current time in HEX
if($conf->ctime>0x7FFFFFFF) {
$t1=$conf->ctime/16;
$t2=$conf->ctime&0xF;
$ctimestr=sprintf("%07X%01X",$t1,$t2);
}
else {
$ctimestr=sprintf("%08X",$conf->ctime);
}
reset($pagesid);
while($e=each($pagesid)) {
$k=$e[0];
if(isset($anct[$k])) {
$pagesid[$k].='|0';
if(strlen($anct[$k])==10) {
$tim=substr($anct[$k],2,8);
eval("$tim=0x$tim;");
$retime[$k]=$tim;
}
}
else {
$pagesid[$k].='|1';
$anct[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($ancm[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$ancm[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($ancw[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$ancw[$k]=sprintf("%02X%s",$k,$ctimestr);
}
if(isset($anc1[$k])) $pagesid[$k].='|0';
else {
$pagesid[$k].='|1';
$anc1[$k]=sprintf("%02X%s",$k,$ctimestr);
}
}
$cot=join('x',$anct);
$com=join('x',$ancm);
$cow=join('x',$ancw);
$co1=join('x',$anc1);
//get path
$path=$conf->url;
$path=preg_replace("/^(http://)([^/]+)/i",'',$path);
$path.='aa.php';
//set cookie
SetCookie('ant',$cot,time()+($conf->time1*3000),$path);
SetCookie('anm',$com,time()+($conf->time1*31),$path);
SetCookie('anw',$cow,time()+($conf->time1*7),$path);
SetCookie('an1',$co1,time()+$conf->time1,$path);
}