[PHP]代码
<?php /**
* session类
* @author 角度 QQ:1286522207
*
*/
class session extends Action{
private $session_db;
private $session_Overdue;
private $db_tablename;//数据库名称
function __construct(){
$this->session_Overdue=3600;
$this->session_db= $this->db();
}
/**
* 打开
*/
public function open() {
return true;
}
/**
* 关闭
*/
public function close() {
return true;
}
/**
* 读取
*/
public function read($id) {
$where['id']=$id;
$this->session_db->M('session');
$value=$this->session_db->find($where);
if ($value) {
return $value['data'];
} else {
return "";
}
}
/**
* 写入
*/
public function write($id, $datas) {
$where['id']=$id;
$date['data']=$datas;
$date['time']=time()+$this->session_Overdue;
$date['ip']=$this->session_db->get_client_ip();
if (empty($_SESSION['user_id'])){
$date['user']=0;
}else {
$date['user']=$_SESSION['user_id'];
}
$this->session_db->M('session');
$up=$this->session_db->Update($date, $where);
if ($up){
return true;
}else {
$date['id']=$id;
$this->session_db->Insert($date);
return true;
}
}
/**
* 摧毁
*/
public function destroy($id) {
$where['id']=$id;
return $this->session_db->Delete($where);
}
/**
* 回收
*/
public function gc($max) {
return true;
}
function __destruct(){
$this->session_db->Delete("`time`<p> </p><p></p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill13222" title="Build MCP servers and clients for PHP applications with the official PHP SDK"><img
src="https://img.php.cn/upload/skill/001/246/273/6adaf20e352aa140.jpg" alt="Build MCP servers and clients for PHP applications with the official PHP SDK" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/skill13222" title="Build MCP servers and clients for PHP applications with the official PHP SDK" class="overflowclass">Build MCP servers and clients for PHP applications with the official PHP SDK</a>
<p class="overflowclass">使用官方Model Context Protocol PHP SDK将PHP应用程序功能暴露为MCP工具、资源和提示,用于代理工作流。</p>
</div>
<a rel="nofollow" href="/xiazai/skill13222" title="Build MCP servers and clients for PHP applications with the official PHP SDK" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div><p> </p>