搜尋

首頁  >  問答  >  主體

要怎麼去實現不登入可以直接存取頁面,或是怎麼去除登陸功能

<?php

/**

 * 前台頁面基類

 */

class WebLoginBase extends WebBase{

public $type;

public $ groupId;

public $played;

public $NO;

# public $gameFanDian;

# function __construct($dsn, $user='', $password=''){

session_start();

if(!$_SESSION[$this->memberSessionName]){

header('location: /user/logout');

exit('您沒有登入');

## }

# try{

parent::__construct($dsn, $user, $password);

//$this->gameFanDian=$this->getValue("select fanDian from {$this->prename}members where uid=?", $GLOBALS['SUPER-ADMIN-UID']);

// 限制同一個使用者只能在一個地方登入

if(!$this->getValue("select isOnLine from ssc_member_session where uid={$this->user['uid']} and session_key=? order by id desc limit 1", session_id()) ){

session_unset();

session_destroy();

header('location: /user/logout');

exit('您已經登出登錄,請重新登入');

}

/*$session_key=$this->getValue("select session_key from ssc_member_session where uid={$this->user ['uid']} and isOnLine=1 order by id desc limit 1");

if($session_key != session_id()){

header('location: /user/ logout');

exit('您已經登出登錄,請重新登入');

# }*/

}catch(Exception $ e){

}

}

public function freshSession(){

if(!$this->user ) return false;

$sessionId=$this->user['sessionId'];

if($this->user['testFlag']==1){

$sql="select * from {$this->prename}guestmembers where uid=?";

}else{

$sql="select * from { $this->prename}members where uid=?";

}

# $user=$this->getRow($sql, $this->user['uid' ]);

$user['sessionId']=$sessionId;

$user['_gameFanDian']=$this->getGameFanDian();

# $ _SESSION[$this->memberSessionName]=serialize($user);

$this->user=$user;

return true;

}

public function getGameFanDian(){

if($this->gameFanDian) return $this->gameFanDian;

# $this-> getSystemSettings();

return $this->gameFanDian=$this->settings['fanDianMax'];

}

public

# }

public function getSystemSettings($expire=null){

if($expire===null) $expire=$this->expire;

### $file=$this->cacheDir . 'systemSettings';###### if($expire && is_file($file) && filemtime($file) $expire>$this->time){####### return $this->settings =unserialize(file_get_contents($file));###

}

$sql="select * from {$this->prename}params";

$this->settings=array() ;

if($data=$this->getRows($sql)){

foreach($data as $var){

$this-> settings[$var['name']]=$var['value'];

}

}

file_put_contents($file, serialize($this-> ;settings));

return $this->settings;

# }

# public function getSystemCache($cacheFile,$getvalue='',$expire=null){

if($expire < 30) $expire=$this->expire;

## $ abbl=$cacheFile=='staticdata/gamedatas.php';

$file=$abbl?$this->cacheDir.'/partNameList.dump':($this->cacheDir. '/ systemplayed'.$getvalue.'_'.md5($cacheFile));

//快取檔案存在且時間不超過10小時,則直接使用快取的結果集,沒有進行任何的MySQL查詢了  

if($expire && is_file($file) && time()-filemtime($file) < $expire) {  

//使用快取中的結果  

if($abbl){

$parts=file_get_contents($this->cacheDir.'/partNameList.dump');

# $cached='';

foreach(json_decode($parts,1) as $part){

$cached.=file_get_contents ($part).';';

}

echo $cached;

}else{

echo file_get_contents($file);

}

}else{

//將結果集快取

ob_start();

$this ->display($cacheFile);

$ob=ob_get_contents();

# if($abbl){

$obs=explode(';',$ob);

array_pop($obs);

$partNameList=array( );

foreach($obs as $cached){

$part=explode('=',str_replace('var','',$cached) );

$partNameList[]=$this->cacheDir.'/'.trim($part[0]);

# file_put_contents(end($partNameList),$cached); 

}

file_put_contents($this->cacheDir.'/partNameList.dump',json_encode( $partNameList));

}else{

file_put_contents($file,$ob); 

## }

ob_end_flush();

##################################” ## }   ###### } ###### ######/* public function delete_file($str){###### $dir=$this->cacheDir;## #### $list = scandir($dir); // 得到該檔案下的所有檔案和資料夾###### foreach($list as $file){//遍歷###### $ file_location=$dir."/".$file;//生成路徑###### if(is_dir($file_location) && $file!="." &&$file!=".."){ //判斷是不是資料夾###### //echo "------------------------sign in $file_location------- -----------";###### //delete_file($file_location); //繼續遍歷###

}else if($file!="."&&$file!=".."){

if(substr_count($file,$str)>0){//如果文件名包含該字串

unlink($dir."/".$file);

# }

## }

## }

}

public function setcachefile($cacheFile, $getvalue){

$file=$this->cacheDir. '/'.md5($getvalue.$cacheFile);

$actionTime=$this->getGameCachetime($getvalue);

$cachefiletime=strtotime($actionTime);

## $file=$file.'_'.$ cachefiletime;

if(is_file($file)) {  

echo file_get_contents($file);

}else{   

# //刪除過期快取

$this->delete_file(md5($getvalue.$cacheFile));  

//將結果集快取

ob_start();

$this->display($cacheFile);

file_put_contents($file,ob_get_contents()); 

ob_end_flush();

# }  

}*/

/**

* 使用者資金變動

*

* 請在一個交易中使用

*/

public function addCoin($log){

# if(!isset($log['uid'])) $log['uid']=$this->user['uid'];

if(!isset($log['info '])) $log['info']='';

if(!isset($log['coin'])) $log['coin']=0;

if(!isset($log['type'])) $log['type']=0;

if(!isset($log['fcoin'])) $log['fcoin ']=0;

if(!isset($log['extfield0'])) $log['extfield0']=0;

if(!isset($log[' extfield1'])) $log['extfield1']='';

if(!isset($log['extfield2'])) $log['extfield2']='';

$sql="call setCoin({$log['coin']}, {$log['fcoin']}, {$log['uid']}, {$log[ 'liqType']}, {$log['type']}, '{$log['info']}', {$log['extfield0']}, '{$log['extfield1']}', '{$log['extfield2']}')";

//echo $sql;exit;

$this->insert($sql) ;

}

public function guestaddCoin($log){

if(!isset($log['uid'])) $log ['uid']=$this->user['uid'];

if(!isset($log['info'])) $log['info']='';

if(!isset($log['coin'])) $log['coin']=0;

if(!isset($log['type'])) $ log['type']=0;

if(!isset($log['fcoin'])) $log['fcoin']=0;

if(!isset( $log['extfield0'])) $log['extfield0']=0;

if(!isset($log['extfield1'])) $log['extfield1']='';

if(!isset($log['extfield2'])) $log['extfield2']='';

$sql="call guestetCoin({$log['coin']}, {$log['fcoin']}, {$log['uid']}, {$log['liqType']}, {$log['type']}, '{$log['info']}', {$log['extfield0']}, '{$log['extfield1']}', '{$log[' extfield2']}')";

//echo $sql;exit;

$this->insert($sql);

}

/**

* 讀取可用返點

*/

public function getFanDian($uid=null){

if($uid===null){

if(!$uid=$this->user['parentId']){

return $this->params['basePl'];

## }

}

return $this->getValue("select fanDian from {$this->prename}members whereparentId=?", intval($uid));

}

#}

#

KeeviKeevi1345 天前2149

全部回覆(1)我來回復

  • 查无此人

    查无此人2021-03-15 09:51:34

    不登陸直接訪問,會不安全。

    你是想做所有人進入等不需要登陸,還是做只對你個人進行不登陸。

    給你個想法:

        1、所有人不登陸,直接去掉使用者判斷就可以了。

        2、對你個人進行不登陸有2種: 

                    

                    二、以專屬於一個頁面,並且自己使用的,進入此頁面,自動登陸進入。

    回覆
    0
  • 取消回覆