我有以下PHP4脚本。 session_register
是否存在替代方案,因为这似乎在PHP5中已被弃用。请参阅下面的代码。
是否有一种简单的方法可以将其重写为有效的PHP5代码,因为它目前仅适用于PHP4平台。
<?php
Error_Reporting(E_ALL & ~E_NOTICE);
unset($l);
session_start();
session_register($l);
include ("includes/config.php");
include ("dbcon.php");
include ("includes/functions.php");
// CHECK AND UPDATE TRAFFIC STATS
$date=date("d/m/y");
$user_ip_address = $HTTP_SERVER_VARS["REMOTE_ADDR"]; /*Fetch the user's IP Address */
$traffic_stats=mysql_fetch_array(mysql_query("select * from jsgamingcenter_traffic WHERE date='$date'", $casdb));
if ($traffic_stats[1]!=$date){
mysql_query("INSERT INTO `jsgamingcenter_traffic` VALUES('', '$date', '0', '0')", $casdb);
}
$tuserip=mysql_fetch_array(mysql_query("select * from jsgamingcenter_users WHERE ip_reg='$user_ip_address'", $casdb));
if ($tuserip[ip_reg]==$user_ip_address){
mysql_query("UPDATE jsgamingcenter_traffic set visitors_re=visitors_re+'1' where date='$date'", $casdb);
}
if ($tuserip[ip_reg]!=$user_ip_address){
mysql_query("UPDATE jsgamingcenter_traffic set visitors_new=visitors_new+'1' where date='$date'", $casdb);
}
/***********************************************************************
Check if user is logged on and display the appropriate page
************************************************************************/
if($page=="" or $page==" "){
header("Location: casino_start.php");
}
if($page!="" && $page!=" "){
if(!isset($l)){
include ("templates/template_$page.php");
}
else{
include ("templates/template_$page.php");
}
}
?>
答案 0 :(得分:1)
正如documentation中所述,直接写入$_SESSION
:
您也可以通过简单设置来创建会话变量 $ _SESSION或$ HTTP_SESSION_VARS的适当成员(PHP&lt; 4.1.0)数组。
正如@ tyteen4a03已经提到的那样,你可能会更好地重写那段代码,因为你使用了很多其他被弃用的东西(乍一看):
$HTTP_SERVER_VARS
mysql_*()
函数