|
----------------------------------------------------------------
index.php
-----------------------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#one{width: 700px; height:200px; margin:auto; padding:0px;}
#main{ background-color: yellow;margin:auto; padding:0px;}
</style>
<script language="javascript">
function check()
{
if (document.form1.username.value=="")
{
alert("标题未填写");
}
else if (document.form1.value.value=="")
{
alert("内容未写");
}
}
</script>
</head>
<body>
<div id="one">
<div id="main">
<?php
/*
新闻发布系统每发布一个新闻就新建一个文本,用来记录新闻内容
copyr@徐跃建2012年6月11号,合肥
*/
//写数据模块
$name=$_POST['name'];
$main=$_POST['value'];
$go=$_POST['who'];
$delet=$_GET['delet'];//获取要删除的文件名
$date=date('YmdHis');//获取日期,做为文本标题
$date1=date('Y-m-d');
$dir="manythink/";
$fonddelet=$dir.$delet;
if(!is_dir($dir))
{
mkdir($dir);
}else{
if(isset($delet))//判断变量时否设置,如果存在,删除文件;
{
unlink($fonddelet);
}
if(strlen($name)>0){
$f=fopen($dir.$date.".txt",'w+');//判断有没有文件
fwrite($f,$name."\r\n");
fwrite($f,$date1."\r\n");
fwrite($f,$go."\r\n");
fwrite($f,$main."\r\n");
}
}
?>
<?php
//读数据模块
$dir="manythink/";
if(is_dir($dir))
{
$read=opendir($dir);
$i=1;
echo "<h4>-------新闻发布系统 ----</h4>";
echo "<ol>";
while (false !== ($file = readdir($read))) {
if ($file != "." && $file != "..")
{//过滤。和。。如果$file不等于。或。。就输出
$look=fopen($dir.$file,r);//打开目录中的文件
$see=fgets($look);//读取地有条记录;
echo "<li><a href='read.php?book=".$file."'>".$see."<a/></li><br>";
echo "-----<a href='mincms.php?delet=".$file."'>删除<a/>";
$i++;
}
}
}
echo "</ol>";
echo "共有".$i=($i-1)."记录";//显示记录跳数
?>
</div>
发布--
<fieldset>
<form action="mincms.php" method="post" name="form1">
<br/>
标题:<input type="text" name="name" size="39"/>
<br/>
内容;
<label for="textarea"></label>
<textarea name="value" id="textarea" cols="50" rows="8" ></textarea>
<br/>
作者:<input type="text" name="who"/>
<br />
<br />
<input type="submit" value="提交"/>
</form>
</fieldset>
</div>
</body>
</html>
------------------------------------------------------------------
read.php
-------------------------------------------------------------------
#main{ background-color:#FF9 ;width:500px ; margin:auto; padding:0px; font:"微软雅黑";}
</style>
</head>
<body>
<div id="main">
<?php
/**
* @author Www.288sx.Com
* @copyright 2012
*/
$read=$_GET[book];
$dir="manythink/".$read;
$file=fopen($dir,"r");
echo "<center>".fgets($file)."</center>";
echo "<br>";
echo "<center>时间:".fgets($file)."</center>";
echo "<br>";
echo "<center>作者:".fgets($file)."</center>";
$see=fread($file,filesize($dir));
echo nl2br($see);
fclose($file);
?>
</div>
</body>
</html> |
|