#
// 说明:
# 本系统全部用文本文件实现,具有动态添加删除分类和文章功能。
# 这个版本只是一个代码片断,但是作为一般的文章系统已经够用了(你可以自己建立分类目录)。
# 如果要引用,请改动版面。但是希望您保留最下方的作者标示。这也是对作者劳动的一种尊重。
// 如何使用:
# 在你可以运行 php 的目录下面建立一个子目录。然后不用改动任何东西把本程序全部上传到刚
# 建立的子目录下面。并且把 file 目录属性设置为 766。
// 技巧:
# 由于这个版本不带动态添加删除分类和文章功能,如果您需要建立分类,可以建立不同的目录,
# 然后将本程序界面改动后上传到类别目录下面
// 文件说明:
# index.php : 主题索引
# read.php : 文章显示
# config.php : 配置文件
# login.php : 管理登陆文件
# manage.pho : 管理主界面
# func.php : Functions
#
#----------------------
#
#根据需要修改下面参数
#
$big="さθ"; #索引分割符
$small="そβ"; #内容分割符
$pagesize=15; #每页显示个数
$admin_name="admin"; #管理员名称
$admin_password="admin"; #管理员密码
?>
// end of config.php
// func.php
<?php
######################################
# 文本文章发布系统代码片断
# 作者:晓风残月([email protected])
# 主页: http://safebase.yeah.net
######################################
require "config.php";
function add_doc() {
global $title, $cont, $big, $small;
$filename=time(); #用时间戳作为文件名
$ctime=$filename;
$filename="./file/".$filename.".dat";
$time=date("Y年m月d日");
$title=htmlspecialchars($title);
$cont=htmlspecialchars($cont);
$cont=nl2br($cont);
$total[0]=$title;
$total[1]=$cont;
$total[2]=$time;
$str=join($total,$small);
$fp=fopen ($filename,"w");
fputs ($fp,$str); #写入文件
fclose ($fp);
$total[0]=$title;
$total[1]=$time;
$total[2]=$ctime;
$str=join($total,$small);
$filename="./file/title.dat";
$fp=fopen ($filename,"r");
$temp=fread ($fp,filesize($filename));
$str=$big.$str.$temp;
fclose($fp);
$fp=fopen($filename,"w"); #写入索引
fputs ($fp,$str);
fclose ($fp);
}
function check_user($name,$password) {
global $admin_name,$admin_password;
if ($name==$admin_name and $password==$admin_password) {
return 1;
}
else {
return 0;
}
}
function redirect2($url) {
Header ("Location:$url");
}
?>
|