|
本帖最后由 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[newstext]);
- $max_newstext=sizeof($newstext_arr);
- $username_arr=explode("|||",$_POST[username]);
- $newstime_arr=explode("|||",$_POST[newstime]);
- $classid=$_POST['classid'];
- $plnum=$max_newstext-1;
- for ($i=0;$i<$max_newstext;$i++){
- if ($i==0){
- AddNews($classid,$title,strtotime($newstime_arr[0]),$smalltext,$username_arr[0],$newstext_arr[0],$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[saytext])){
- 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 |
|