⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db.class.php

📁 一款文件上传程序
💻 PHP
字号:
<?php
require_once 'constants.inc.php';

class DB
{
	var$_d;var$_f;var$_p;
	function DB(){$this->_d=array();$this->_f='';$p=false;}
	function open($f,$c=false){if(!is_file($f)){return$c?$this->create($f):0;}$p=@fopen($f,'ab+');if(!$p||!flock($p,LOCK_SH))return 0;include$f;$this->_f=$f;$this->_p=&$p;set_file_buffer($this->_p,0);return 1;}
	function create($f){if(!touch($f))return 0;chmod($f,0777);return 1;}
	function remove($f){if(is_file($f)){return@unlink($f);}return 1;}
	function uset($f){unset($this->_d[$f]);}
	function set($f,$v=0){if(is_array($f)){if($v){$this->_d=$f;}else{while(list($k,$v)=each($f))$this->set($k,$v);}}else$this->_d[$f]=$v;}
	function get($f){return isset($this->_d[$f])?$this->_d[$f]:exit("Field '$f' does not exist in ".$this->_f);}
	function all(){return $this->_d;}
	function close(){if($this->_p)fclose($this->_p);$this->DB();}
	function save(){$p=&$this->_p;if(!$p)exit("Can't save, no file opened.");$buf=sprintf("<?php\n\$this->_d=%s;\n?>",var_export($this->_d,1));if($p&&flock($p,LOCK_EX)){ftruncate($p,0);fseek($p,0);fwrite($p,$buf);fflush($p);fclose($p);}else exit ( 'Could not open ' . $this->_f . ' for writting.');}
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -