发布新闻,实现新闻页面静态化,真静态
前台功能介绍:1、网页首页显示有高级会员推荐,精品推荐,商业机会分类列表,最新供求信息,网站动态,推荐企业,行业动态等;2、商业机会栏目功能有:二级分类,已经带有详细分类的数据库,后台可以更改增加操作,并可以推荐公司,栏目分为分类显示信息,最新的采购、供应、合作和代理信息,搜索时同样按分类,信息,时间,交易类型等搜索;3、展厅展品栏目功能:二级分类,已经带有详细分类的数据库,后台可以更改增加操作,
0
<html> <head>添加新闻</head> <body> <form method="post"action="doadd.php"> 新闻标题:<input type="text"name="title"size="100"><br> 新闻内容:<textarea name="content"cols="100"rows="25"></textarea><br> <input type="submit"name="提交"> </form> </body> </html>
<?php
define("HOST","localhost");
define("USER","justfan");
define("PWD","justfan");
define("DB","justfanDB");
define("PORT","3360");
?><?php
class DB
{
private $host = '';
private $uname = '';
private $pwd = '';
private $port = '';
private $db = '';
public static $instance = null;
private function __construct($host , $uname , $pwd , $port , $db)
{
$this->host = $host;
$this->uname = $uname;
$this->port = $port;
$this->pwd = $pwd;
$this->db = $db;
mysql_connect($host,$uname,$pwd);
mysql_select_db($this->db);
}
public static function Instance()
{
if(Db::$instance==null){
include 'config.php';
return Db::$instance = new DB(HOST, USER, PWD, PORT, DB);
}
else
return Db::$instance;
}
public function query($sql)
{
mysql_query("SET NAMES UTF8");
$query = mysql_query($sql) or die($sql."error");
if(!$query) return false;
else return $query;
}
public function getAll($sql)
{
$query = $this->query($sql);
if($query)
{
while($ret = mysql_fetch_assoc($query))
{
$result[] = $ret;
}
}
return $result;
}
}
?><?php
include 'DB_class.php';
$db = DB::Instance();
$title=$_POST["title"];
$content=$_POST["content"];
$num = uniqid();
$houzui=".html";
$filename=date('Ymd').'/'.$num.$houzui;
$sql="insert into news(title,content,path) values ('{$title}' , '{$content}' , '{$filename}')";
$query = $db->query($sql);
$fp=fopen("model.htm","r");
$str=fread($fp,filesize("model.htm"));
$str=str_replace("{title}",$title,$str);
$str=str_replace("{content}",$content,$str);
fclose($fp);
$dir = dirname($filename);
if(!is_dir($dir)){
mkdir($dir);
}
$handle=fopen($filename,"w");
fwrite($handle,$str);
fclose($handle);
echo"<a href={$filename} target=_blank>查看刚才添加的新闻</a>";
echo"<a href='add.php'>添加新闻</a>";
?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号