ecms7.0新闻资讯发布带评论
本帖最后由 luring 于 2014-6-29 14:37 编辑演示:http://www.tingu.cn
http://www.tingu.cn/book/42-15188.html<?php
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../data/dbcache/class.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//获取分类列表
foreach($class_r as $kv)
{
if($kv['modid']=='1')
{
$cates[]=array('cname'=>$kv['classname'],'cid'=>$kv['classid'],'pid'=>$kv['bclassid']);
}
}
if(empty($_POST))
{
//这里刷新列表
echo "<select name='list'>";
echo maketree($cates,0,'');
echo '</select>';
exit();
}
$title =addslashes(RepPostStr($_POST['title']));
$newstext =addslashes(RepPostStr($_POST['newstext']));
$username =addslashes(RepPostStr($_POST['username']));
$newstime =$_POST['newstime'];
$smalltext =addslashes(RepPostStr($_POST['smalltext']));
$keyboard =addslashes(RepPostStr($_POST['keyboard']));
$newstext_arr=explode("|||",$_POST);
$max_newstext=sizeof($newstext_arr);
$username_arr=explode("|||",$_POST);
$newstime_arr=explode("|||",$_POST);
$classid=$_POST['classid'];
$plnum=$max_newstext-1;
for ($i=0;$i<$max_newstext;$i++){
if ($i==0){
AddNews($classid,$title,strtotime($newstime_arr),$smalltext,$username_arr,$newstext_arr,$keyboard,$plnum);
}elseif($i>0){
AddPl($username_arr[$i],$newstime_arr[$i],$classid,$newstext_arr[$i]);
}
}
function AddNews($classid,$title,$newstime,$smalltext,$username,$newstext,$keyboard,$plnum){//添加信息
global $empire,$public_r,$dbtbpre,$id,$classid;
$sql=$empire->query("INSERT INTO phome_ecms_news_check(classid,title,newstime,username,userid,havehtml,keyboard,newstext,truetime,lastdotime) VALUES('$classid','$title','$newstime','admin','1','0','$keyboard','$newstext','$newstime','$newstime');");//主表
$id=$empire->lastid();
$sql=$empire->query("update {$dbtbpre}ecms_news_check set filename='$id' where id='$id'");
$sql=$empire->query("INSERT INTO phome_ecms_news_check_data(id,classid,dokey,newstempid) VALUES('$id','$classid','1','0');");//信息副表
$sql=$empire->query("INSERT INTO phome_ecms_news_index(id,classid,checked,newstime,truetime,lastdotime,havehtml) VALUES('$id','$classid','0','$newstime','$newstime','$newstime','0');");
$sql=$empire->query("update phome_enewsclass set allinfos=allinfos+1 where classid='$classid'");
$sql=$empire->query("update {$dbtbpre}ecms_news_check set titleurl='/blogs/$id.html' where id='$id'");
echo "成功";
}
function AddPl($username,$newstime,$classid,$newstext){//添加评论
global $empire,$public_r,$dbtbpre,$id,$classid;
$sql=$empire->query("insert into {$dbtbpre}enewspl(username,saytime,id,checked,classid,stb) values ('$username','$newstime','$id','1','$classid','1');");//主表
$plid=$empire->lastid();
$sql=$empire->query("insert into {$dbtbpre}enewspl_data_1(plid,classid,id,saytext) values ('$plid','$classid','$id','$newstext');");//副表
echo "成功";
}
/*
if(!empty($add)){
AddNews($_POST);
AddPl($_POST);
}else{
AddNews($_POST);
}
*/
db_close();
$empire=null;
/***生成目录的一个遍历算法***/
function maketree($ar,$id,$pre)
{
$ids='';
foreach($ar as $k=>$v){
$pid=$v['pid'];
$cname=$v['cname'];
$cid=$v['cid'];
if($pid==$id)
{
$ids.="<option value='$cid'>{$pre}{$cname}</option>";
foreach($ar as $kk=>$vv)
{
$pp=$vv['pid'];
if($pp==$cid)
{
$ids.=maketree($ar,$cid,$pre." ");
break;
}
}
}
}
return $ids;
}
?>
演示:http://www.tingu.cn
http://www.tingu.cn/book/42-15188.html 不错。支持一下 没有发布模块,自己弄了几个小时没整出来:Q 请问发布模块是什么呢? ecms7.0新闻资讯发布带评论 好东西啊,谢谢分享噢:( 很棒,去测试一下:lol ecms7.0新闻资讯发布带评论
http://bbs.locoy.com/forum.php?mod=viewthread&tid=134805&fromuid=130968
感谢分享了。
页:
[1]