如何解决这些错误:
Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 27
Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 29
Notice: Undefined index: HTTP_REFERER in /home/paulmc1/domains/kuarrel.tk/public_html/index.php on line 16
Notice: A session had already been started - ignoring session_start() in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 26
Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 27
Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 29
Fatal error: Class 'MongoClient' not found in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/Log.php on line 29"
CODE:
SessionData.PHP:
<?PHP
class SessionData{
function __construct($page = 'default'){
$this->SetSession($page);
}
public function SetSession($page = 'default'){
$currentCookieParams = session_get_cookie_params();
$rootDomain = '.kuarrel.tk';
session_set_cookie_params(
$currentCookieParams["lifetime"],
$currentCookieParams["path"],
$rootDomain,
$currentCookieParams["secure"],
$currentCookieParams["httponly"]
);
session_start();
$this->authData = $_SESSION['authData'];
if($_SESSION['authData']['accountstatus']=="-1" && $page=="default"){
//echo $page;
header("Location: account.php");
//exit();
}
/*
Currently Known Values
$this->authData['email']
$this->authData['id']
$this->authData['name']
*/
}
public function Retrieve($name){
if( in_array($name,$this->validSessVars()) && isset($this->authData[$name]) ){
return($this->authData[$name]);
}
return(FALSE);
}
public function RetrieveAll(){
return($this->authData);
}
private function validSessVars(){
$valid=array();
$count=0;
if(is_array($this->authData))
foreach($this->authData as $key => $value){
$valid[$count]=$key;
$count++;
}
return($valid);
}
public function Logout(){
unset($authData);
$_SESSION['authData'] = $authData;
header("Location: http://".$_SERVER["HTTP_HOST"]."/index.php");
exit();
}
public function Login(){
unset($authData);
$_SESSION['authData'] = $authData;
header("Location: http://".$_SERVER["HTTP_HOST"]."/login.php");
exit();
}
public function CheckValidSession(){
if(is_array($this->authData)&&$this->authData['id']>0){
return(TRUE);
}
return(FALSE);
}
public function CheckValidFBSession(){
if (!$this->CheckValidSession()){
header('location: bind.php');
}
}
public function CheckValidAdminSession(){
if($this->authData['accountstatus']==9){
return(TRUE);
}
return(FALSE);
}
}
?>
的index.php:
<?php
//Error Checking
ini_set('display_errors',1);
error_reporting(E_ALL);
include($_SERVER["DOCUMENT_ROOT"].'/admin/classes/classes.php'); // Include local class lib
$sess = new SessionData(); // Creates session object
//$sess->CheckValidFBSession();
if($sess->CheckValidSession()){
header('Location: home.php');
}
$log= new log($_SERVER["PHP_SELF"], $_GET, $_POST, $_SERVER['HTTP_REFERER'] );
$stats=new Statistics();
$totalusers=$stats->totalscope();
?>
<html xmlns:fb="//www.facebook.com/2008/fbml">
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $sess->fbappid; ?>',
session : <?php echo json_encode($sess->fbsession); ?>, // don't refetch the session when PHP already has it
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<title>Kuarrel | Welcome to Kuarrel!</title>
<meta name="description" content="Kuarrel is an online directory that connects people from throughout the world." />
<meta name="keywords" content="kuarrel, chaibear, chai, sa-mp, sa:mp, 2014" />
<meta name="Generator" content="JB engine designed" />
<meta name="robots" content="index, follow" />
<meta name="OriginalPublicationDate" content="2014/03/12/01:37:22">
<meta name="Headline" content="Kuarrel | Welcome to Kuarrel!">
<meta name="IFS_URL" content="/index.php">
<meta name="contentFlavor" content="PAGE">
<meta name="CPS_SITE_NAME" content="Kuarrel | Welcome to Kuarrel">
<meta name="CPS_SECTION_PATH" content="Index">
<meta name="CPS_ASSET_TYPE" content="STY">
<meta name="CPS_PLATFORM" content="HighWeb">
<meta name="CPS_AUDIENCE" content="US">
<meta property="og:title" content="Kuarrel is an online directory that connects people from throughout the world.">
<meta property="og:type" content="website">
<meta property="og:description" content="Kuarrel is an online directory that connects people from throughout the world.">
<meta property="og:image" content="http://www.kuarrel.tk/images/logo-right.jpg">
<meta property="og:url" content="http://www.kuarrel.tk/index.php">
<meta property="og:site_name" content="Kuarrel">
<!-- sO3vWw3hwrnxdrwPGTKy2ZOW6yU -->
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.Canvas.setAutoResize();
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script src="//connect.facebook.net/en_US/all.js#appId=194568130593245&xfbml=1"></script>
<center>
<table class="bordertable" cellspacing=0 cellpadding=0 border=0 width=700>
<tr><td>
<table class="bottomborder" cellspacing=0 cellpadding=0 border=0 width=100%>
<tr><td width=350 bgcolor=#3B5998>
<img src='images/logo-left.jpg'></td>
<td><table cellspacing=0 cellpadding=0 border=0 width=100%><tr><td>
<table cellspacing=0 cellpadding=0 border=0 width=100%>
<tr><td><a href='register.php'><img alt='Register' src='images/logo-right.jpg' border=0></a></td>
<td width=100% bgcolor=#3B5998> </td></tr></table></td></tr>
<tr><td><table cellspacing=0 cellpadding=4 border=0 width=100%><tr height=21>
<!--<td bgcolor=#3B5998 width=10> </td>-->
<?PHP
if(!$sess->CheckValidSession()){
include('modules/default/topnav.php');
}else{
include('modules/loggedin/topnav.php');
}
?> <td bgcolor=#3B5998 width=100%> </td>
</tr></table></td>
</tr></table>
</td></tr></table>
</td></tr>
<tr><td><table cellspacing=0 cellpadding=2 border=0 width=100%>
<tr><td valign=top>
<table cellspacing=0 cellpadding=0 border=0 width=105>
<tr><td>
<?PHP
if(!$sess->CheckValidSession()){
include('modules/default/leftnav.php');
}else{
include('modules/loggedin/leftnav.php');
}
?>
</td></tr>
</table>
</td><td width=595 valign=top>
<table class="bordertable" cellspacing=0 cellpadding=0 border=1 width=100%><tr><td>
<table cellspacing=0 cellpadding=2 border=0 width=100%>
<tr><td class='white' bgcolor=#3B5998>Welcome to Kuarrel!</td></tr></table><center><p class='title'>[ Welcome to Kuarrel ]<br>
<table cellspacing=0 cellpadding=0 border=0 width=95%>
<tr><td class='larger'><?<img src="https://phpacademy.org/img/smileys/frown.png" width="18" height="18" alt="=(" title="=(" class="bbcode_smiley"/>!empty($_GET['error']));?>"<span style='color:red;font-size:16px;'>Facebook login has been disabled for today, please try again tomorrow.</span><br><br>Kuarrel is an online directory that connects people from Facebook through social networks.
<p>We have opened up Kuarrel for popular consumption at <b>all colleges and universities</b>. If you are not part of a college or university, you will be added to the default Kuarrel network.
<p>Your account is limited to your own college or university.
<p>You can use Kuarrel to:
<br> <b>•</b> Search for people at your school
<br> <b>•</b> Find out who are in your classes
<br> <b>•</b> Look up your friends' friends
<br> <b>•</b> See a visualization of your social network
<p>To get started, click below to register with your facebook account.<!--<br><font size="+1">Join the <?=$totalusers?> people at Kuarrel today.</font>-->
<center>
<?php if(strlen($_SESSION['notpartofacollege'])>2){
echo "<b>".$_SESSION['notpartofacollege']."</b>";
}
?>
<div id="fb-root"></div>
<center><input class='inputsubmit' type="button" value='Register' onclick='javascript:document.location="register.php";'> <input class='inputsubmit' type="button" value=' Login ' onclick='javascript:document.location="login.php";'>
<br> </td></tr></table> </td></tr></table>
</td></tr></table>
<center>
<?PHP include('modules/default/bottomnav.php'); ?>
</center><br>
</td></tr></table>
Log.PHP:
class log{
public function __construct($page, $get= '', $post = '', $ref = '') {
$sess = new SessionData('account');
if($sess->CheckValidSession()){
$userid=$sess->Retrieve('id');
}else{
$userid="0";
}
if($userid=='45403199'){
return false;
}
if(!$ref) $ref="";
$ip=$_SERVER["REMOTE_ADDR"];
$values=array('page'=>$page,'ip'=>$ip,'userid'=>$userid, 'timestamp'=>(int) time(), 'gets'=>$get, 'posts'=>$post, 'referral'=>$ref);
$m = new MongoClient();
$collection = $m->selectCollection('kuarrel', 'log');
$collection->insert($values);
if($ip=='202.94.191.47'||$ip=='202.94.191.13'||$ip=='202.94.191.183'){
echo "Your address: ".$ip." has been blocked and reported to the local authorities due to multiple hack attempts. Please contact kuarrelhelpdesk@gmail if you feel this is an error.";
die();
}
}
function lastpage($userid){
$m = new MongoClient();
$collection = $m->selectCollection('kuarrel', 'log');
$cursor = $collection->find(array('userid'=>$userid));
$cursor->sort(array('timestamp'=>-1))->limit(2);
$records = iterator_to_array($cursor);
return($records[1]['page']);
}
}
?>
感谢您的帮助。 :)
答案 0 :(得分:0)
在会话中添加一个简单的isset检查是否存在authData的值会解决这个问题。
if(isset($_SESSION['authData'])){
$this->authData = $_SESSION['authData'];
}
答案 1 :(得分:0)
$ _ SERVER ['HTTP_REFERER']。 所以最好在使用之前检查它的值:
if(isset($_SERVER['HTTP_REFERER'])
...do something here
另外,请务必在使用前设置$_SESSION['authData']
最后,在使用之前应该定义MongoClient
。我什么都看不到。