📄 page.php
字号:
<?php
/*
*######################################
* PHPCMS v2.00 - Advanced Content Manage System.
* Copyright (c) 2004-2005 phpcms.cn
*
* For further information go to http://www.phpcms.cn/
* This copyright notice MUST stay intact for use.
*######################################
*/
if(!defined('IN_PHPCMS')) {
exit('Access Denied');
}
$action = $action ? $action : 'manage' ;
switch($action){
case 'add':
if($submit){
if(!trim($title) || !trim($content)) {
showmessage('您必须输入标题和内容,请返回修改。');
}
$db->query("INSERT INTO $table_page (title,meta_title,meta_keywords,meta_description,content,tpl,updatetime) VALUES ('$title','$meta_title','$meta_keywords','$meta_description', '$content','$tpl','$timestamp')");
$id=$db->insert_id();
cache_update('page');
html("page");
showmessage('操作成功!','?dir=plugin&file=page');
}else{
$tpldir = $phpcms_root."/templates/".$template;
$d=opendir($tpldir);
while($f=readdir($d)){
if(preg_match('/^page_(.*)(\.htm)/i',$f)){
$tpl = str_replace(".htm","",$f);
$tpls[$tpl] = $f;
}
}
include template('page_add',1);
}
break;
case 'edit':
if($submit){
if(!trim($title) || !trim($content)){
showmessage('您必须输入标题和内容,请返回修改。');
}else{
$db->query("UPDATE $table_page SET title='$title',meta_title='$meta_title',meta_keywords='$meta_keywords',meta_description='$meta_description',content='$content',tpl='$tpl',updatetime='$timestamp' WHERE id='$id'");
cache_update('page');
html("page");
showmessage('操作成功!','?dir=plugin&file=page');
}
}else{
$tpldir = $phpcms_root."/templates/".$template;
$d=opendir($tpldir);
while($f=readdir($d)){
if(preg_match('/^page_(.*)(\.htm)/i',$f)){
$tpl = str_replace(".htm","",$f);
$tpls[$tpl] = $f;
}
}
$result=$db->query("select * from $table_page where id='$id'");
extract($db->fetch_array($result));
include template('page_edit',1);
}
break;
case 'manage':
$pages = '';
$query = $db->query("SELECT * FROM $table_page ORDER BY id DESC");
while($page=$db->fetch_array($query)){
$page[updatetime]=date('Y-m-d',$page[updatetime]);
$pages[]=$page;
}
include template('page_manage',1);
break;
case 'createhtml':
if(empty($id)){
showmessage('非法参数!请返回!');
}
if(is_array($id)){
$ids=$id;
foreach($ids as $id){
html("page");
}
}else{
html("page");
}
showmessage('操作成功!','?dir=plugin&file=page');
break;
case 'delete':
if(empty($id)){
showmessage('非法参数!请返回!');
}
$ids=is_array($id) ? implode(',',$id) : $id;
$db->query("DELETE FROM $table_page WHERE id IN ($ids)");
$filedir=$phpcms_root.'/page/';
if(is_array($id)){
foreach($id as $i){
@unlink($filedir.'/'.$i.$fileext);
}
}else{
@unlink($filedir.'/'.$id.$fileext);
}
cache_update('page');
showmessage('操作成功!','?dir=plugin&file=page');
break;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -