php实现不登录不能访问,要怎么去实现不登录可以直接访问页面,或者要怎么去除登陆功能...

要怎么去实现不登录可以直接访问页面,或者要怎么去除登陆功能

47d507a036d4dd65488c445c0974b649.png

Keevi2021-03-09 07:41:25 0 1 156

/**

* 前台页面基类

*/

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 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 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) 

//使用缓存中的结果

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 guestsetCoin({$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 where parentId=?", intval($uid));

}

}

166014.html

回答

1

0

分享

全部回复 (1)

bd3505c5ae60e060253a5461bf58d7f4.png

欧阳2021-03-15 09:52:181楼

不登陆直接访问,会不安全。你是想做所有人进入等不需要登陆,还是做只对你个人进行不登陆。给你个思路:    1、所有人不登陆,直接去掉用户判断就可以了。    2、对你个人进行不登陆有2种:                 一、如果你的ip地址是固定的,可以判断ip地址 是你的地址,直接进入。                二、可以专门做个页面,自己使用的,进入这个页面,自动登陆进入。

166014.html

回复

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值