|
楼主 |
发表于 2014-10-2 23:26:47
|
显示全部楼层
以下为帝国ECMS结合火车头的文件,类似于自定义API工具吧,相关信息需要自己去修改。- <?php
- /**
- 1、本接口基本上全部是数据库操作,因此所采集的数据一定要对应数据库字段,否则内容就不是自己想要的了。
- 2、本接口只适合帝国CMS7.0系统,如果您用的是7.0以下系统请自行修改文件。
- 3、此接口经过差不多1个月的测试,没有问题。可以正常的更新和添加文章,因此如果您觉得不好用可以找其他接口。
- 4、由于根据自己的需要做的接口,因此如果你想自己用可能得自己修改了,这个接口只是做一个参考,如果你懂一点点代码改起来应该不难。
- **/
- header('conten-type:text/html;charset=gb2312');
- $password='stock'; // 验证密码所用, 发表地址后缀: /e/admin/stock.php?pw=stock
- if($password!=$_GET['pw']) exit('验证密码错误'); //安全检测,密码不符则退出
- define('InEmpireCMS',TRUE);
- include("e/config/config.php");
- define('DB_HOST',$ecms_config['db']['dbserver']); //数据库登录地址
- define('DB_PASSWORD',$ecms_config['db']['dbpassword']);//数据库密码
- define('DB_USER',$ecms_config['db']['dbusername']);//数据库用户名
- define('DB_NAME',$ecms_config['db']['dbname']);////数据库名
- $db = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) ;
- mysql_select_db(DB_NAME,$db) ;
- mysql_query("set names gb2312");
- mysql_query("SET character_set_results=gb2312");
- /////////////////////////////////////////////初始化配置
- $times = time();
- $times2 = time(); //对应自动发布时间
- $id = $_POST['stock_id'];//ID必须有
- /////////////////////////////////////////////主表phome_ecms_stock
- $stock = ''; //这个为分类,你采集的文章肯定有分类,每个分类对应一个栏目
- $title = $_POST['title'] ;
- $subtitle = $_POST['subtitle'] ;
- $stock_id = $_POST['stock_id'] ; //ID必须有
- $titlepic = $_POST['titlepic'] ;
- $smalltext = $_POST['smalltext'] ;
- $newstime = $times ; //
- $diggtop = $_POST['diggtop'] ; //顶
- $diggdown = $_POST['diggdown'] ; //踩,如果自己没有加这个字段可以自己加也可放着
- $infopfen = $_POST['infopfen'] ; //评分数
- $infopfennum = $_POST['infopfennum'] ; //评分人数
- $onclick = $_POST['onclick'] ; //浏览人数
- $filename= $id ;
- $ttid='0';
- $plnum=0;
- $totaldown=0;
- $newspath='';
- $userid=1; //管理员ID
- $username='admin'; //发布账号
- $firsttitle=0;
- $isgood=0;
- $ispic=0;
- $istop=0;
- $isqf='0';
- $ismember=0;
- $isurl=0;
- $truetime=$times;
- $lastdotime=$times;
- $havehtml=1;
- $groupid=0;
- $userfen=0;
- $titlefont='';
- $stb=0;
- $fstb=1;
- $restb=1;
- $keyboard='';
- $goods=$_POST['goods'];
- $moq=$_POST['moq'];
- $spq=$_POST['spq'];
- $box=$_POST['box'];
- $Description=$_POST['Description'];
- $stock=$_POST['stock'];
- $leadtime=$_POST['leadtime'];
- $RMB=$_POST['RMB'];
- $qq=$_POST['qq'];
- $com=$_POST['com'];
- $Brand=$_POST['Brand'];
- /////////////////////////////////////////////副表phome_ecms_stock_data_1
- $writer = $_POST['writer'] ;
- $befrom = $_POST['befrom'] ;
- $newstext = $_POST['newstext'] ;
- $stock_pf = $_POST['stock_pf'] ;
- $keyid='';
- $dokey=0;
- $newstempid=0;
- $closepl=0;
- $haveaddfen=0;
- $infotags='';
- /////////////////////////////////////////////索引表phome_ecms_stock_index
- $checked=0; //信息属性:审核 1 为审核 0为非审核,只有为0的时候才能延迟发布文章
- /////////////////////////////////////////////phome_enewsinfovote
- $id3 = 1000010000000000 + $id ;
- $pubid = number_format($id3,'','','') ;
- $votenum = 0 ;
- $voteip = '';
- $votetext ='';
- $voteclass = 0;
- $doip = 0;
- $dotime ='0000-00-00';
- $tempid =1 ;
- $width = 500 ;
- $height = 300 ;
- $diyotherlink = '';
- $infouptime = $times2 ;
- $infodowntime = 0;
- $copyids = '';
- ?>
- <?php
- $enews=$_POST['enews'];
- if(empty($enews))
- {
- $enews=$_GET['enews'];
- }
- if(!$_POST){
- // 列出终极栏目
- $qbrand = mysql_query("SELECT classid,classname,bclassid FROM `".$dbtbpre."enewsclass` where islast=1 order by myorder,classid desc ");
- echo '<select name="classid">';
- while($row = mysql_fetch_array($qbrand)){
- $qbrand2 = mysql_query("SELECT classid,classname,bclassid FROM `".$dbtbpre."enewsclass` where classid='".$row['bclassid']."'");
- while($row2 = mysql_fetch_array($qbrand2)){
- echo '<option value="'.$row['classid'].'">'.$row2['classname'].$row['classname'].'</option>';
- }
- }
- echo '</select><br />';
- }else{
- if ( get_magic_quotes_gpc ()) {
- stripslashes ( $_POST );
- }
- @extract($_POST);
- ?>
- <?php
- $qbrand3 = mysql_query("SELECT classid , classpath FROM `".$dbtbpre."enewsclass` where classname='".$stock."' and bclassid='".$bclassid."' ");
- while($row3 = mysql_fetch_array($qbrand3)){
- $classid = $row3['classid'] ; //该栏目的ID
- $classpath = $row3['classpath'] ;
- }
- if(!$classpath){
- $classid = 709;
- $classpath = 'lingshi';
- }
- $titleurl = '/' . $classpath . '/' . $id . '.html'; //外部链接
-
- $qbrand4 = mysql_query("SELECT stock_id FROM `".$dbtbpre."ecms_stock` where id='".$id."' ");
- while($row4 = mysql_fetch_array($qbrand4)){
- $id_4 = $row4['stock_id'] ; //
- }
- $qbrand5 = mysql_query("SELECT stock_id FROM `".$dbtbpre."ecms_stock_check` where id='".$id."' ");
- while($row5 = mysql_fetch_array($qbrand5)){
- $id_5 = $row5['stock_id'] ; //
- }
- ?>
- <?php
- mysql_query("BEGIN");
- if($enews=="AddNews"){
- if($id_4)
- {
- $checked=1;
- $phome_ecms_stock = mysql_query(" UPDATE ".$dbtbpre."ecms_stock SET classid='$classid' , ttid='$ttid' , onclick='$onclick' , plnum='$plnum' , totaldown='$totaldown' , newspath='$newspath' , filename='$filename' , userid='$userid' , username='$username' , firsttitle='$firsttitle' , isgood='$isgood' , ispic='$ispic' , istop='$istop' , isqf='$isqf' , ismember='$ismember' , isurl='$isurl' , truetime='$truetime' , lastdotime='$lastdotime' , havehtml='$havehtml' , groupid='$groupid' , userfen='$userfen' , titlefont='$titlefont' , titleurl='$titleurl' , stb='$stb' , fstb='$fstb' , restb='$restb' , keyboard='$keyboard' , title='$title' , newstime='$newstime' , titlepic='$titlepic' , subtitle='$subtitle' , smalltext='$smalltext' , diggtop='$diggtop' , infopfen='$infopfen' , infopfennum='$infopfennum' , diggdown='$diggdown' , stock='$stock' , stock_tel='$stock_tel' , stock_xy='$stock_xy' , stock_xyurl='$stock_xyurl' , stock_rz='$stock_rz' , stock_tg='$stock_tg' , stock_jt='$stock_jt' , stock_rel='$stock_rel' , stock_30yj='$stock_30yj' , stock_dq='$stock_dq' WHERE id = '$id_4'goods=goods',moq=moq',spq=spq',box=box',Description=Description',stock=stock',leadtime=leadtime',RMB=RMB',qq=qq',com=com',Brand=Brand'");
- echo '$phome_ecms_stock ' . mysql_errno() . ": " . mysql_error() ;
- $phome_ecms_stock_data_1 = mysql_query(" UPDATE ".$dbtbpre."ecms_stock_data_1 SET classid='$classid' , keyid='$keyid' , dokey='$dokey' , newstempid='$newstempid' , closepl='$closepl' , haveaddfen='$haveaddfen' , infotags='$infotags' , writer='$writer' , befrom='$befrom' , newstext='$newstext' , stock_pf='$stock_pf' WHERE id = '$id_4' ");
- echo '$phome_ecms_stock_data_1 ' . mysql_errno() . ": " . mysql_error() ;
- $phome_ecms_stock_index = mysql_query(" UPDATE ".$dbtbpre."ecms_stock_index SET classid='$classid' , checked='$checked' , newstime='$newstime' , truetime='$truetime' , lastdotime='$lastdotime' , havehtml='$havehtml' WHERE id = '$id_4' ");
- echo '$phome_ecms_stock_index ' . mysql_errno() . ": " . mysql_error() ;
- $phome_enewsinfovote = mysql_query(" UPDATE ".$dbtbpre."enewsinfovote SET pubid='$pubid' , classid='$classid' , title='$title' , votenum='$votenum' , voteip='$voteip' , votetext='$votetext' , voteclass='$voteclass' , doip='$doip' , dotime='$dotime' , tempid='$tempid' , width='$width' , height='$height' , diyotherlink='$diyotherlink' , infouptime='$infouptime' , infodowntime='$infodowntime' , copyids='$copyids' WHERE id = '$id_4' ");
- echo '$phome_enewsinfovote ' . mysql_errno() . ": " . mysql_error() ;
- echo "id_4已审核产品发布成功!" ;
- mysql_query("END");
- mysql_close($db);
- }
- elseif($id_5)
- {
- $phome_ecms_stock_check = mysql_query(" UPDATE ".$dbtbpre."ecms_stock_check SET classid='$classid' , ttid='$ttid' , onclick='$onclick' , plnum='$plnum' , totaldown='$totaldown' , newspath='$newspath' , filename='$filename' , userid='$userid' , username='$username' , firsttitle='$firsttitle' , isgood='$isgood' , ispic='$ispic' , istop='$istop' , isqf='$isqf' , ismember='$ismember' , isurl='$isurl' , truetime='$truetime' , lastdotime='$lastdotime' , havehtml='$havehtml' , groupid='$groupid' , userfen='$userfen' , titlefont='$titlefont' , titleurl='$titleurl' , stb='$stb' , fstb='$fstb' , restb='$restb' , keyboard='$keyboard' , title='$title' , newstime='$newstime' , titlepic='$titlepic' , subtitle='$subtitle' , smalltext='$smalltext' , diggtop='$diggtop' , infopfen='$infopfen' , infopfennum='$infopfennum' , diggdown='$diggdown' , stock='$stock' , stock_id='$stock_id' , stock_tel='$stock_tel' , stock_xy='$stock_xy' , stock_xyurl='$stock_xyurl' , stock_rz='$stock_rz' , stock_tg='$stock_tg' , stock_jt='$stock_jt' , stock_rel='$stock_rel', stock_30yj='$stock_30yj', stock_dq='$stock_dq' WHERE id = '$id_5'goods=goods',moq=moq',spq=spq',box=box',Description=Description',stock=stock',leadtime=leadtime',RMB=RMB',qq=qq',com=com',Brand=Brand' ");
- echo '$phome_ecms_stock_check ' . mysql_errno() . ": " . mysql_error() ;
- $phome_ecms_stock_check_data = mysql_query(" UPDATE ".$dbtbpre."ecms_stock_check_data SET classid='$classid' , keyid='$keyid' , dokey='$dokey' , newstempid='$newstempid' , closepl='$closepl' , haveaddfen='$haveaddfen' , infotags='$infotags' , writer='$writer' , befrom='$befrom' , newstext='$newstext' , stock_pf='$stock_pf' WHERE id = '$id_5' ");
- echo '$phome_ecms_stock_check_data ' . mysql_errno() . ": " . mysql_error() ;
- $phome_ecms_stock_index = mysql_query(" UPDATE ".$dbtbpre."ecms_stock_index SET classid='$classid' , checked='$checked' , newstime='$newstime' , truetime='$truetime' , lastdotime='$lastdotime' , havehtml='$havehtml' WHERE id = '$id_5' ");
- echo '$phome_ecms_stock_index ' . mysql_errno() . ": " . mysql_error() ;
- $phome_enewsinfovote = mysql_query(" UPDATE ".$dbtbpre."enewsinfovote SET pubid='$pubid' , classid='$classid' , title='$title' , votenum='$votenum' , voteip='$voteip' , votetext='$votetext' , voteclass='$voteclass' , doip='$doip' , dotime='$dotime' , tempid='$tempid' , width='$width' , height='$height' , diyotherlink='$diyotherlink' , infouptime='$infouptime' , infodowntime='$infodowntime' , copyids='$copyids' WHERE id = '$id_5' ");
- echo '$phome_enewsinfovote ' . mysql_errno() . ": " . mysql_error() ;
- echo $id_5 . "id_5未审核产品发布成功!";
-
- mysql_query("END");
- mysql_close($db);
- }
- else{
- ?>
- <?php
- if($checked==0){
- $phome_ecms_stock_check = mysql_query("INSERT INTO ".$dbtbpre."ecms_stock_check (id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,ispic,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard,title,newstime,titlepic,subtitle,smalltext,diggtop,infopfen,infopfennum,diggdown,stock,stock_id,stock_tel,stock_xy,stock_xyurl,stock_rz,stock_tg,stock_jt,stock_rel,stock_30yj,stock_dq) VALUES ('$id','$classid','$ttid','$onclick','$plnum','$totaldown','$newspath','$filename','$userid','$username','$firsttitle','$isgood','$ispic','$istop','$isqf','$ismember','$isurl','$truetime','$lastdotime','$havehtml','$groupid','$userfen','$titlefont','$titleurl','$stb','$fstb','$restb','$keyboard','$title','$newstime','$titlepic','$subtitle','$smalltext','$diggtop','$infopfen','$infopfennum','$diggdown','$stock','$stock_id','$stock_tel','$stock_xy','$stock_xyurl','$stock_rz','$stock_tg','$stock_jt','$stock_rel','$stock_30yj','$stock_dq')");
- echo '$phome_ecms_stock_check ' . mysql_errno() . ": " . mysql_error() ;
- $phome_ecms_stock_check_data = mysql_query("INSERT INTO ".$dbtbpre."ecms_stock_check_data (id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags,writer,befrom,newstext,stock_pf) VALUES ('$id','$classid','$keyid','$dokey','$newstempid','$closepl','$haveaddfen','$infotags','$writer','$befrom','$newstext','$stock_pf')");
- echo '$phome_ecms_stock_check_data ' . mysql_errno() . ": " . mysql_error() ;
- }
- else{
- $phome_ecms_stock = mysql_query("INSERT INTO ".$dbtbpre."ecms_stock (id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,ispic,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard,title,newstime,titlepic,subtitle,smalltext,diggtop,infopfen,infopfennum,diggdown,stock,stock_id,stock_tel,stock_xy,stock_xyurl,stock_rz,stock_tg,stock_jt,stock_rel,stock_30yj,stock_dq,'goods','moq','spq','box','Description','stock','leadtime','RMB','qq','com','Brand') VALUES ('$id','$classid','$ttid','$onclick','$plnum','$totaldown','$newspath','$filename','$userid','$username','$firsttitle','$isgood','$ispic','$istop','$isqf','$ismember','$isurl','$truetime','$lastdotime','$havehtml','$groupid','$userfen','$titlefont','$titleurl','$stb','$fstb','$restb','$keyboard','$title','$newstime','$titlepic','$subtitle','$smalltext','$diggtop','$infopfen','$infopfennum','$diggdown','$stock','$stock_id','$stock_tel','$stock_xy','$stock_xyurl','$stock_rz','$stock_tg','$stock_jt','$stock_rel','$stock_30yj','$stock_dq','$goods','$moq','$spq','$box','$Description','$stock','$leadtime','$RMB','$qq','$com','$Brand')");
- echo '$phome_ecms_stock ' . mysql_errno() . ": " . mysql_error() ;
- $phome_ecms_stock_data_1 = mysql_query("INSERT INTO ".$dbtbpre."ecms_stock_data_1 (id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags,writer,befrom,newstext,stock_pf) VALUES ('$id','$classid','$keyid','$dokey','$newstempid','$closepl','$haveaddfen','$infotags','$writer','$befrom','$newstext','$stock_pf')");
- echo '$phome_ecms_stock_data_1 ' . mysql_errno() . ": " . mysql_error() ;
- }
- $phome_ecms_stock_index = mysql_query("INSERT INTO ".$dbtbpre."ecms_stock_index (id,classid,checked,newstime,truetime,lastdotime,havehtml) VALUES ('$id','$classid','$checked','$newstime','$truetime','$lastdotime','$havehtml')");
- echo '$phome_ecms_stock_index ' . mysql_errno() . ": " . mysql_error() ;
- $phome_enewsinfovote = mysql_query("INSERT INTO ".$dbtbpre."enewsinfovote (pubid,id,classid,title,votenum,voteip,votetext,voteclass,doip,dotime,tempid,width,height,diyotherlink,infouptime,infodowntime,copyids) VALUES ('$pubid','$id','$classid','$title','$votenum','$voteip','$votetext','$voteclass','$doip','$dotime','$tempid','$width','$height','$diyotherlink','$infouptime','$infodowntime','$copyids')");
- echo '$phome_enewsinfovote ' . mysql_errno() . ": " . mysql_error() ;
- echo "产品发布成功!";
- mysql_query("END");
- mysql_close($db);
- }
- }
- ?>
- <?php
- }
- ?>
复制代码 |
|