Session.php文件
/**
* Session class
*/
class Session{
public static function init(){
session_start();
}
public static function set($key, $val){
$SESSION['$key'] = $val;
}
public static function get($key){
if (isset($_SESSION['$key'])) {
return $_SESSION['$key'];
}else{
return false;
}
}
public static function checkSession(){
self::init();
if (self::get('login') == false) {
self::destroy();
header("Location:login.php");
}
}
public static function destroy(){
session_destroy();
header("Location:login.php");
}
}
Format.php文件
public function formatDate($date){
return date('F j, Y, g:i a', strtotime($date));
}
public function textShorten( $text , $limit = 400){
$text = $text . " ";
$text = substr($text, 0, $limit);
$text = substr($text, 0, strrpos($text, ' '));
$text = $text . ".....";
return $text;
}
public function validation($data){
$data = trim($data);
$data = stripcslashes($data);
$data = htmlspecialchars($data);
return $data;
}
}
database.php中
public $link;
public $error;
function __construct()
{
$this->connectDB();
}
private function connectDB(){
$this->link = new mysqli($this->host,
$this->user,$this->pass,$this->dbname);
if(!$this->link){
$this->error = "Connection failed" . $this->link;
}
}
//Insert Data
public function insert($data){
$insert_row = $this->link->query($data) or die($this->link->errror.
__LINE__);
if($insert_row){
return $insert_row;
}else{
return false;
}
}
//Select Data
public function select($data){
$result = $this->link->query($data) or die($this->link->errror.
__LINE__);
if($result->num_rows >0){
return $result;
}else{
return false;
}
}
//Delete Data
public function delete($data){
$delete_row = $this->link->query($data) or die($this->link->errror.
__LINE__);
if($delete_row ){
return $delete_row;
}else{
return false;
}
}
}
?>
管理员index.php的
header.php
管理面板
- >
- >
< / script> - >
< / script> - >