PageRenderTime 101ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/e/class/cjfun.php

https://github.com/westeast/xwdede
PHP | 2136 lines | 2024 code | 14 blank | 98 comment | 80 complexity | ac8cd67aaad44377d8f7dc32319fb1a5 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. //修改采集信息
  3. function EditCjNews($add,$newstext,$userid,$username){
  4. global $empire,$class_r,$dbtbpre;
  5. $add[classid]=(int)$add[classid];
  6. $add[id]=(int)$add[id];
  7. if(empty($add[classid])||empty($add[id])||empty($add[title]))
  8. {printerror("EmptyCjTitle","history.go(-1)");}
  9. //验证权限
  10. CheckLevel($userid,$username,$classid,"cj");
  11. //取得采集字段
  12. $record="<!--record-->";
  13. $field="<!--field--->";
  14. $cr=$empire->fetch1("select newsclassid,tbname from {$dbtbpre}enewsinfoclass where classid='$add[classid]'");
  15. $r=$empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='".$class_r[$cr[newsclassid]][modid]."'");
  16. $cjr=explode($record,$r[cj]);
  17. $count=count($cjr);
  18. $update="";
  19. for($i=0;$i<$count-1;$i++)
  20. {
  21. $cjr1=explode($field,$cjr[$i]);
  22. $dofield=$cjr1[1];
  23. //图片集
  24. if($dofield=="morepic")
  25. {
  26. $add[$dofield]=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],1);
  27. }
  28. //下载地址
  29. if($dofield=="downpath")
  30. {
  31. $add[$dofield]=ReturnDownpath($add['downname'],$add['downpath'],$add['delpathid'],$add['pathid'],$add['downuser'],$add['fen'],$add['thedownqz'],$add,$add['foruser'],$add['downurl'],0);
  32. }
  33. //在线地址
  34. if($dofield=="onlinepath")
  35. {
  36. $add[$dofield]=ReturnDownpath($add['odownname'],$add['odownpath'],$add['odelpathid'],$add['opathid'],$add['odownuser'],$add['ofen'],$add['othedownqz'],$add,$add['oforuser'],$add['onlineurl_qz'],1);
  37. }
  38. //发布时间
  39. if($dofield=="newstime")
  40. {continue;}
  41. $update.=",".$dofield."='".addslashes($add[$dofield])."'";
  42. }
  43. $sql=$empire->query("update {$dbtbpre}ecms_infotmp_".$cr[tbname]." set keyboard='".addslashes($add[keyboard])."',newstime='$add[newstime]'".$update." where id='$add[id]'");
  44. if($sql)
  45. {
  46. //操作日志
  47. insert_dolog("id=".$add[id]."<br>title=".$add[title]);
  48. printerror("EditCjNewsSuccess","CheckCj.php?classid=$add[classid]&from=$_POST[from]");
  49. }
  50. else
  51. {printerror("DbError","history.go(-1)");}
  52. }
  53. //删除采集信息
  54. function DelCjNews($classid,$id,$userid,$username){
  55. global $empire,$dbtbpre;
  56. $classid=(int)$classid;
  57. $id=(int)$id;
  58. if(empty($classid)||empty($id))
  59. {printerror("NotDelCjNewsid","history.go(-1)");}
  60. //验证权限
  61. CheckLevel($userid,$username,$classid,"cj");
  62. $cr=$empire->fetch1("select newsclassid,tbname from {$dbtbpre}enewsinfoclass where classid='$classid'");
  63. $r=$empire->fetch1("select title from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where id='$id'");
  64. $sql=$empire->query("delete from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where id='$id'");
  65. if($sql)
  66. {
  67. //操作日志
  68. insert_dolog("id=".$id."<br>title=".$r[title]);
  69. printerror("DelCjNewsSuccess","CheckCj.php?classid=$classid&from=$_GET[from]");
  70. }
  71. else
  72. {printerror("DbError","history.go(-1)");}
  73. }
  74. //批量删除采集信息
  75. function DelCjNews_all($classid,$id,$userid,$username){
  76. global $empire,$dbtbpre;
  77. //操作权限
  78. CheckLevel($userid,$username,$classid,"cj");
  79. $count=count($id);
  80. if(!$count)
  81. {printerror("NotDelCjNewsid","history.go(-1)");}
  82. $cr=$empire->fetch1("select newsclassid,tbname,classname from {$dbtbpre}enewsinfoclass where classid='$classid'");
  83. for($i=0;$i<count($id);$i++)
  84. {
  85. $add.="id='".$id[$i]."' or ";
  86. }
  87. //去掉最后一个 or
  88. $add=substr($add,0,strlen($add)-4);
  89. $sql=$empire->query("delete from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where ".$add);
  90. if($sql)
  91. {
  92. //操作日志
  93. insert_dolog("classid=".$classid."<br>classname=".$cr[classname]);
  94. printerror("DelCjNewsAllSuccess",$_SERVER['HTTP_REFERER']);
  95. }
  96. else
  97. {
  98. printerror("DbError","history.go(-1)");
  99. }
  100. }
  101. //清除简介字符
  102. function DoClearSmalltextVal($value){
  103. $value=str_replace(array("\r\n","<br />","<br>","&nbsp;","[!--empirenews.page--]","[/!--empirenews.page--]"),array("","\r\n","\r\n"," ","",""),$value);
  104. $value=strip_tags($value);
  105. $value=trim($value,"\r\n");
  106. return $value;
  107. }
  108. //采集入库
  109. function CjNewsIn($classid,$id,$checked,$uptime,$userid,$username){
  110. global $class_r,$empire,$public_r,$dbtbpre,$emod_r;
  111. $checked=(int)$checked;
  112. $classid=(int)$classid;
  113. if(empty($classid))
  114. {
  115. printerror("ErrorUrl","history.go(-1)");
  116. }
  117. CheckLevel($userid,$username,$classid,"cj");//操作权限
  118. $count=count($id);
  119. if(empty($count))
  120. {
  121. printerror("NotCjNewsIn","history.go(-1)");
  122. }
  123. $cr=$empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='$classid'");
  124. //副表
  125. $cra=$empire->fetch1("select * from {$dbtbpre}ecms_infoclass_".$cr[tbname]." where classid='$classid'");
  126. //组合两数组
  127. $cr=TogTwoArray($cr,$cra);
  128. //导入gd处理文件
  129. if($cr['mark']||$cr['getfirstspic'])
  130. {
  131. @include_once("gd.php");
  132. }
  133. $mid=$class_r[$cr[newsclassid]][modid];
  134. $savetxtf=$emod_r[$mid]['savetxtf'];
  135. $stb=$emod_r[$mid]['deftb'];
  136. //取得采集字段
  137. $record="<!--record-->";
  138. $field="<!--field--->";
  139. $mr=$empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='".$class_r[$cr[newsclassid]][modid]."'");
  140. $cjr=explode($record,$mr[cj]);
  141. $ccount=count($cjr);
  142. //取得优化字段
  143. for($ci=0;$ci<$ccount-1;$ci++)
  144. {
  145. $cir=explode($field,$cjr[$ci]);
  146. $cifield=$cir[1];
  147. if($cifield=="title")
  148. {
  149. continue;
  150. }
  151. $updatefield.=",".$cifield."=''";
  152. }
  153. for($i=0;$i<count($id);$i++)
  154. {
  155. $a.="id='".$id[$i]."' or ";
  156. }
  157. //去掉最后一个 or
  158. $a=substr($a,0,strlen($a)-4);
  159. $sql=$empire->query("select * from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where ".$a." and checked=0 order by id desc");
  160. $filetime=date("Y-m-d H:i:s");
  161. $todaytime=time();
  162. while($r=$empire->fetch($sql))
  163. {
  164. $ivalue='';
  165. $ifield='';
  166. $dataivalue='';
  167. $dataifield='';
  168. $titlepicnoval=0;
  169. for($j=0;$j<$ccount-1;$j++)
  170. {
  171. $cjr1=explode($field,$cjr[$j]);
  172. $dofield=$cjr1[1];
  173. $var="zz_".$dofield;
  174. $var1="z_".$dofield;
  175. $var2="qz_".$dofield;
  176. $var3="save_".$dofield;
  177. $value=$r[$dofield];
  178. //自身链接
  179. if($dofield=="empireselfurl")
  180. {
  181. $value=$r['oldurl'];
  182. }
  183. //内容
  184. if($dofield=="newstext")
  185. {
  186. if($cr[copyimg]||$cr[copyflash])
  187. {
  188. $GLOBALS['cjnewsurl']=$r[oldurl];
  189. $value=addslashes(CopyImg(stripSlashes($value),$cr[copyimg],$cr[copyflash],$cr[newsclassid],$cr[imgurl],$username,0,$r['id'],$cr['mark']));
  190. }
  191. //替换关键字和字符
  192. $value=DoReplaceKeyAndWord($value,1);
  193. }
  194. //简介
  195. if($dofield=="smalltext")
  196. {
  197. if(empty($value))
  198. {
  199. $value=SubSmalltextVal($r[newstext],$cr[smalltextlen]);
  200. }
  201. else
  202. {
  203. $value=DoClearSmalltextVal($value);
  204. }
  205. }
  206. //图片集
  207. if($dofield=="morepic")
  208. {
  209. if($cr[$var3]==" checked")
  210. {
  211. $msavepic=1;
  212. $r['filepass']=$r['id'];
  213. $value=LoadInSaveMorepicFile($value,$msavepic,$cr[newsclassid],0,$r);
  214. }
  215. }
  216. //信息时间
  217. if($dofield=="newstime")
  218. {continue;}
  219. //图片标题
  220. if($dofield=="titlepic"&&$cr[zz_titlepicl])
  221. {
  222. $cr[$var]=$cr[zz_titlepicl];
  223. $cr[$var1]=$cr[z_titlepicl];
  224. $cr[$var2]=$cr[qz_titlepicl];
  225. $cr[$var3]=$cr[save_titlepicl];
  226. }
  227. if($dofield=="titlepic"&&empty($value))
  228. {
  229. $titlepicnoval=1;
  230. }
  231. //是否远程保存
  232. if($value&&!$cr[$var1]&&$cr[$var3]==" checked"&&$dofield!="morepic")
  233. {
  234. $tranr=DoTranUrl($value,$cr[newsclassid]);
  235. if($tranr[tran])
  236. {
  237. $tranr[filesize]=(int)$tranr[filesize];
  238. $tranr[type]=(int)$tranr[type];
  239. $r[id]=(int)$r[id];
  240. //记录数据库
  241. $usql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('$tranr[filename]',$tranr[filesize],'$username','$tranr[filepath]','$filetime',$cr[newsclassid],'[URL]".$tranr[filename]."',$tranr[type],0,$r[id],0,'$public_r[fpath]');");
  242. $value=$tranr[url];
  243. }
  244. }
  245. //存放文本
  246. if($savetxtf==$dofield)
  247. {
  248. //建立目录
  249. $thetxtfile=GetFileMd5();
  250. $truevalue=MkDirTxtFile(date("Y/md"),$thetxtfile);
  251. //写放文件
  252. EditTxtFieldText($truevalue,$value);
  253. $value=$truevalue;
  254. }
  255. $value=RepDyh($value);
  256. if(strstr($emod_r[$mid]['tbdataf'],','.$dofield.','))//副表
  257. {
  258. $dataifield.=",".$dofield;
  259. $dataivalue.=",'".$value."'";
  260. }
  261. else
  262. {
  263. $ifield.=",".$dofield;
  264. $ivalue.=",'".$value."'";
  265. }
  266. }
  267. $r[keyboard]=RepDyh($r[keyboard]);
  268. //时间
  269. if($uptime)//当前时间
  270. {
  271. $r[newstime]=$todaytime;
  272. $r[truetime]=$todaytime;
  273. }
  274. else
  275. {
  276. if($r[newstime]=="0000-00-00 00:00:00")
  277. {
  278. $r[newstime]=$todaytime;
  279. }
  280. else
  281. {
  282. $r[newstime]=to_time($r[newstime]);
  283. }
  284. }
  285. //查看目录是否存在,不存在则建立
  286. $newspath=FormatPath($cr[newsclassid],"",0);
  287. //强制签发
  288. if($class_r[$cr[newsclassid]][wfid])
  289. {
  290. $checked=0;
  291. $isqf=1;
  292. }
  293. else
  294. {
  295. $checked=$checked;
  296. $isqf=0;
  297. }
  298. //变量处理
  299. $newstempid=0;
  300. $ispic=$r[titlepic]?1:0;
  301. //取得返回关键字
  302. $keyid=GetKeyid($r[keyboard],$cr[newsclassid],0,$class_r[$cr[newsclassid]][link_num]);
  303. $isql=$empire->query("insert into {$dbtbpre}ecms_".$cr[tbname]."(classid,onclick,newspath,keyboard,keyid,userid,username,ztid,checked,truetime,ismember,dokey,isgood,titlefont,titleurl,filename,groupid,newstempid,plnum,firsttitle,isqf,userfen,totaldown,closepl,havehtml,lastdotime,haveaddfen,infopfen,infopfennum,votenum,stb,ttid,newstime,ispic".$ifield.") values($cr[newsclassid],0,'$newspath','$r[keyboard]','$keyid',$r[userid],'$r[username]','$cr[newsztid]','$checked','$r[truetime]',0,1,0,'$r[titlefont]','$r[titleurl]','$filename',0,'".$newstempid."',0,0,'$isqf',0,0,0,0,'$r[truetime]',0,0,0,0,'$stb',0,'$r[newstime]','$ispic'".$ivalue.");");
  304. $id=$empire->lastid();
  305. //副表
  306. $fisql=$empire->query("insert into {$dbtbpre}ecms_".$cr[tbname]."_data_".$stb."(id,classid".$dataifield.") values('$id','$cr[newsclassid]'".$dataivalue.");");
  307. //签发
  308. if($isqf==1)
  309. {
  310. InfoInsertToWorkflow($id,$cr[newsclassid],$class_r[$cr[newsclassid]][wfid],$userid,$username);
  311. }
  312. //更新附件
  313. UpdateTheFile($id,$r['id']);
  314. //取第一张图片为标题图片
  315. $addtitlepic="";
  316. if($cr['getfirstpic']&&$titlepicnoval)
  317. {
  318. $firsttitlepic=GetFpicToTpic($cr[newsclassid],$id,$cr['getfirstpic'],$cr['getfirstspic'],$cr['getfirstspicw'],$cr['getfirstspich']);
  319. if($firsttitlepic)
  320. {
  321. $addtitlepic=",titlepic='".addslashes($firsttitlepic)."',ispic=1";
  322. }
  323. }
  324. //文件命名
  325. $filename=ReturnInfoFilename($cr[newsclassid],$id,$r[filenameqz]);
  326. $usql=$empire->query("update {$dbtbpre}ecms_".$cr[tbname]." set filename='$filename'".$addtitlepic." where id='$id'");
  327. }
  328. //状态原记录
  329. if($cr['delloadinfo'])//删除
  330. {
  331. $del=$empire->query("delete from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where ".$a);
  332. }
  333. else
  334. {
  335. $del=$empire->query("update {$dbtbpre}ecms_infotmp_".$cr[tbname]." set checked=1,keyboard=''".$updatefield." where ".$a);
  336. }
  337. //操作日志
  338. insert_dolog("classid=".$classid);
  339. printerror("CjLoadDbSuccess","CheckCj.php?classid=$classid&from=$_POST[from]");
  340. }
  341. //全部采集入库
  342. function CjNewsIn_all($classid,$checked,$uptime,$start,$userid,$username){
  343. global $class_r,$empire,$public_r,$dbtbpre,$fun_r,$emod_r;
  344. $checked=(int)$checked;
  345. $classid=(int)$classid;
  346. $start=(int)$start;
  347. if(empty($classid))
  348. {
  349. printerror("ErrorUrl","history.go(-1)");
  350. }
  351. //操作权限
  352. CheckLevel($userid,$username,$classid,"cj");
  353. $cr=$empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='$classid'");
  354. //副表
  355. $cra=$empire->fetch1("select * from {$dbtbpre}ecms_infoclass_".$cr[tbname]." where classid='$classid'");
  356. //组合两数组
  357. $cr=TogTwoArray($cr,$cra);
  358. //导入gd处理文件
  359. if($cr['mark']||$cr['getfirstspic'])
  360. {
  361. @include_once("gd.php");
  362. }
  363. if(empty($cr[insertnum]))
  364. {$cr[insertnum]=10;}
  365. $mid=$class_r[$cr[newsclassid]][modid];
  366. $savetxtf=$emod_r[$mid]['savetxtf'];
  367. $stb=$emod_r[$mid]['deftb'];
  368. //取得采集字段
  369. $record="<!--record-->";
  370. $field="<!--field--->";
  371. $mr=$empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='".$class_r[$cr[newsclassid]][modid]."'");
  372. $cjr=explode($record,$mr[cj]);
  373. $ccount=count($cjr);
  374. $sql=$empire->query("select * from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where classid='$classid' and checked=0 and id>$start order by id limit ".$cr[insertnum]);
  375. $filetime=date("Y-m-d H:i:s");
  376. $todaytime=time();
  377. $b=0;
  378. while($r=$empire->fetch($sql))
  379. {
  380. $b=1;
  381. $newstart=$r[id];
  382. $ivalue='';
  383. $ifield='';
  384. $dataivalue='';
  385. $dataifield='';
  386. $titlepicnoval=0;
  387. for($j=0;$j<$ccount-1;$j++)
  388. {
  389. $cjr1=explode($field,$cjr[$j]);
  390. $dofield=$cjr1[1];
  391. $var="zz_".$dofield;
  392. $var1="z_".$dofield;
  393. $var2="qz_".$dofield;
  394. $var3="save_".$dofield;
  395. $value=$r[$dofield];
  396. //自身链接
  397. if($dofield=="empireselfurl")
  398. {
  399. $value=$r['oldurl'];
  400. }
  401. //内容
  402. if($dofield=="newstext")
  403. {
  404. if($cr[copyimg]||$cr[copyflash])
  405. {
  406. $GLOBALS['cjnewsurl']=$r[oldurl];
  407. $value=addslashes(CopyImg(stripSlashes($value),$cr[copyimg],$cr[copyflash],$cr[newsclassid],$cr[imgurl],$username,0,$r['id'],$cr['mark']));
  408. }
  409. //替换关键字和字符
  410. $value=DoReplaceKeyAndWord($value,1);
  411. }
  412. //简介
  413. if($dofield=="smalltext")
  414. {
  415. if(empty($value))
  416. {
  417. $value=SubSmalltextVal($r[newstext],$cr[smalltextlen]);
  418. }
  419. else
  420. {
  421. $value=DoClearSmalltextVal($value);
  422. }
  423. }
  424. //图片集
  425. if($dofield=="morepic")
  426. {
  427. if($cr[$var3]==" checked")
  428. {
  429. $msavepic=1;
  430. $r['filepass']=$r['id'];
  431. $value=LoadInSaveMorepicFile($value,$msavepic,$cr[newsclassid],0,$r);
  432. }
  433. }
  434. //时间
  435. if($dofield=="newstime")
  436. {continue;}
  437. //图片标题
  438. if($dofield=="titlepic"&&$cr[zz_titlepicl])
  439. {
  440. $cr[$var]=$cr[zz_titlepicl];
  441. $cr[$var1]=$cr[z_titlepicl];
  442. $cr[$var2]=$cr[qz_titlepicl];
  443. $cr[$var3]=$cr[save_titlepicl];
  444. }
  445. if($dofield=="titlepic"&&empty($value))
  446. {
  447. $titlepicnoval=1;
  448. }
  449. //是否远程保存
  450. if($value&&!$cr[$var1]&&$cr[$var3]==" checked"&&$dofield!="morepic")
  451. {
  452. $tranr=DoTranUrl($value,$cr[newsclassid]);
  453. if($tranr[tran])
  454. {
  455. $tranr[filesize]=(int)$tranr[filesize];
  456. $tranr[type]=(int)$tranr[type];
  457. $r[id]=(int)$r[id];
  458. //记录数据库
  459. $usql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,onclick,fpath) values('$tranr[filename]',$tranr[filesize],'$username','$tranr[filepath]','$filetime',$cr[newsclassid],'[URL]".$tranr[filename]."',$tranr[type],0,$r[id],0,'$public_r[fpath]');");
  460. $value=$tranr[url];
  461. }
  462. }
  463. //存放文本
  464. if($savetxtf==$dofield)
  465. {
  466. //建立目录
  467. $thetxtfile=GetFileMd5();
  468. $truevalue=MkDirTxtFile(date("Y/md"),$thetxtfile);
  469. //写放文件
  470. EditTxtFieldText($truevalue,$value);
  471. $value=$truevalue;
  472. }
  473. $value=RepDyh($value);
  474. if(strstr($emod_r[$mid]['tbdataf'],','.$dofield.','))//副表
  475. {
  476. $dataifield.=",".$dofield;
  477. $dataivalue.=",'".$value."'";
  478. }
  479. else
  480. {
  481. $ifield.=",".$dofield;
  482. $ivalue.=",'".$value."'";
  483. }
  484. }
  485. $r[keyboard]=RepDyh($r[keyboard]);
  486. //时间
  487. if($uptime)//当前时间
  488. {
  489. $r[newstime]=$todaytime;
  490. $r[truetime]=$todaytime;
  491. }
  492. else
  493. {
  494. if($r[newstime]=="0000-00-00 00:00:00")
  495. {
  496. $r[newstime]=$todaytime;
  497. }
  498. else
  499. {
  500. $r[newstime]=to_time($r[newstime]);
  501. }
  502. }
  503. //查看目录是否存在,不存在则建立
  504. $newspath=FormatPath($cr[newsclassid],"",0);
  505. //强制签发
  506. if($class_r[$cr[newsclassid]][wfid])
  507. {
  508. $checked=0;
  509. $isqf=1;
  510. }
  511. else
  512. {
  513. $checked=$checked;
  514. $isqf=0;
  515. }
  516. //变量处理
  517. $newstempid=0;
  518. $ispic=$r[titlepic]?1:0;
  519. //返回关键字
  520. $keyid=GetKeyid($r[keyboard],$cr[newsclassid],0,$class_r[$cr[newsclassid]][link_num]);
  521. $isql=$empire->query("insert into {$dbtbpre}ecms_".$cr[tbname]."(classid,onclick,newspath,keyboard,keyid,userid,username,ztid,checked,truetime,ismember,dokey,isgood,titlefont,titleurl,filename,groupid,newstempid,plnum,firsttitle,isqf,userfen,totaldown,closepl,havehtml,lastdotime,haveaddfen,infopfen,infopfennum,votenum,stb,ttid,newstime,ispic".$ifield.") values($cr[newsclassid],0,'$newspath','$r[keyboard]','$keyid',$r[userid],'$r[username]','$cr[newsztid]','$checked','$r[truetime]',0,1,0,'$r[titlefont]','$r[titleurl]','$filename',0,'".$newstempid."',0,0,'$isqf',0,0,0,0,'$r[truetime]',0,0,0,0,'$stb',0,'$r[newstime]','$ispic'".$ivalue.");");
  522. $id=$empire->lastid();
  523. //副表
  524. $fisql=$empire->query("insert into {$dbtbpre}ecms_".$cr[tbname]."_data_".$stb."(id,classid".$dataifield.") values('$id','$cr[newsclassid]'".$dataivalue.");");
  525. //签发
  526. if($isqf==1)
  527. {
  528. InfoInsertToWorkflow($id,$cr[newsclassid],$class_r[$cr[newsclassid]][wfid],$userid,$username);
  529. }
  530. //更新附件
  531. UpdateTheFile($id,$r['id']);
  532. //取第一张图片为标题图片
  533. $addtitlepic="";
  534. if($cr['getfirstpic']&&$titlepicnoval)
  535. {
  536. $firsttitlepic=GetFpicToTpic($cr[newsclassid],$id,$cr['getfirstpic'],$cr['getfirstspic'],$cr['getfirstspicw'],$cr['getfirstspich']);
  537. if($firsttitlepic)
  538. {
  539. $addtitlepic=",titlepic='".addslashes($firsttitlepic)."',ispic=1";
  540. }
  541. }
  542. //文件命名
  543. $filename=ReturnInfoFilename($cr[newsclassid],$id,$r[filenameqz]);
  544. $usql=$empire->query("update {$dbtbpre}ecms_".$cr[tbname]." set filename='$filename'".$addtitlepic." where id='$id'");
  545. }
  546. $fm=$_GET['fm'];
  547. //全部入库完毕
  548. if(empty($b))
  549. {
  550. //取得忧化字段
  551. for($ci=0;$ci<$ccount-1;$ci++)
  552. {
  553. $cir=explode($field,$cjr[$ci]);
  554. $cifield=$cir[1];
  555. if($cifield=="title")
  556. {
  557. continue;
  558. }
  559. $updatefield.=",".$cifield."=''";
  560. }
  561. //状态原记录
  562. if($cr['delloadinfo'])//删除
  563. {
  564. $del=$empire->query("delete from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where classid='$classid'");
  565. }
  566. else
  567. {
  568. $del=$empire->query("update {$dbtbpre}ecms_infotmp_".$cr[tbname]." set checked=1,keyboard=''".$updatefield." where classid='$classid'");
  569. }
  570. if($fm)
  571. {
  572. echo"<link rel=\"stylesheet\" href=\"../data/images/css.css\" type=\"text/css\"><body topmargin=0><font color=red>".$cr[classname]." ".$fun_r['CjLoadInInfosSuccess']."</font>, <input type=button name=button value='".$fun_r['OnlickLoadInCj']."' onclick=\"window.open('CheckCj.php?classid=$classid&from=$_GET[from]');\"></body>";
  573. exit();
  574. }
  575. else
  576. {
  577. printerror("CjLoadDbSuccess","CheckCj.php?classid=$classid&from=$_GET[from]");
  578. }
  579. }
  580. echo "<b>$cr[classname]</b>&nbsp;&nbsp;".$fun_r['OneCjLoadDbSuccess']."(ID:<font color=red><b>".$newstart."</b></font>)<script>self.location.href='ecmscj.php?enews=CjNewsIn_all&checked=$checked&uptime=$uptime&classid=$classid&start=$newstart&fm=$fm&from=$_GET[from]';</script>";
  581. exit();
  582. }
  583. //##############################采集功能开始###############################
  584. //替换回车
  585. function ReplaceFc($text){
  586. $text=str_replace("\n","",$text);
  587. $text=str_replace("\r","",$text);
  588. return $text;
  589. }
  590. //返回字符正则
  591. function GetInfoStr($text,$exp,$enews=0){
  592. $e1="[phome-".$exp."]";
  593. $e2="[/phome-".$exp."]";
  594. $rep="[!--".$exp."--]";
  595. $mode="*";
  596. //匹配多个
  597. if($enews==1)
  598. {
  599. $cr=explode($rep,$text);
  600. $cer=explode($mode,$cr[0]);
  601. $num=count($cer)-1;
  602. }
  603. //转换字符
  604. $text=str_replace($rep,$mode,$text);
  605. $er=explode($mode,$text);
  606. $newtext="";
  607. for($i=0;$i<count($er);$i++)
  608. {
  609. $j=$i+1;
  610. //加标签
  611. if($enews==1)
  612. {
  613. if($i==$num)
  614. {
  615. $newtext.=$er[$i].$e1."\\".$j.$e2;
  616. }
  617. else
  618. {
  619. $newtext.=$er[$i]."\\".$j;
  620. }
  621. }
  622. //过滤广告
  623. elseif($enews==2)
  624. {
  625. if($i==$num)
  626. {
  627. $newtext.=$er[$i]."";
  628. }
  629. else
  630. {
  631. $newtext.=$er[$i]."\\".$j;
  632. }
  633. }
  634. else
  635. {
  636. $newtext.=$er[$i]."\\".$j;
  637. }
  638. }
  639. //去掉最后一个//
  640. $newtext=substr($newtext,0,strlen($newtext)-2);
  641. return $newtext;
  642. }
  643. //过滤广告
  644. function RepAd($repad,$text){
  645. if(empty($repad))
  646. {return $text;}
  647. $repad=stripSlashes($repad);
  648. //替换回车
  649. $repad=ReplaceFc($repad);
  650. $r=explode(",",$repad);
  651. $exp="ad";
  652. for($i=0;$i<count($r);$i++)
  653. {
  654. $zztext=RepInfoZZ($r[$i],$exp,0);
  655. //$strtext=GetInfoStr($r[$i],$exp,2);
  656. $strtext="";
  657. $text=stripSlashes(preg_replace($zztext,$strtext,$text));
  658. }
  659. return $text;
  660. }
  661. //过滤整个页面广告
  662. function RepPageAd($repad,$text){
  663. if(empty($repad))
  664. {return $text;}
  665. $repad=stripSlashes($repad);
  666. //替换回车
  667. $repad=ReplaceFc($repad);
  668. $r=explode(",",$repad);
  669. $exp="pad";
  670. for($i=0;$i<count($r);$i++)
  671. {
  672. $zztext=RepInfoZZ($r[$i],$exp,0);
  673. //$strtext=GetInfoStr($r[$i],$exp,2);
  674. $strtext="";
  675. $text=stripSlashes(preg_replace($zztext,$strtext,$text));
  676. }
  677. return $text;
  678. }
  679. //地址
  680. function eCheckCjUrl($url,$ecms=0){
  681. if(!strstr($url,'://'))
  682. {
  683. if($ecms)
  684. {
  685. return false;
  686. }
  687. else
  688. {
  689. printerror('ErrorUrl','history.go(-1)');
  690. }
  691. }
  692. return true;
  693. }
  694. //取得符号位置
  695. function CountCJ_site($text,$exp){
  696. $rep="[!--".$exp."--]";
  697. $mode="*";
  698. $cr=explode($rep,$text);
  699. $cer=explode($mode,$cr[0]);
  700. $num=count($cer);
  701. return $num;
  702. }
  703. //取得替换空余出来的值
  704. function ReturnCJ_str($text,$exp,$info){
  705. $e1="[phome-".$exp."]";
  706. $e2="[/phome-".$exp."]";
  707. $text=stripSlashes(stripSlashes($text));
  708. //替换回车
  709. $text=ReplaceFc($text);
  710. $rep="[!--".$exp."--]";
  711. //替换
  712. $num=CountCJ_site($text,$exp);//取得符号位置
  713. $zztext=RepInfoZZ($text,$exp,0);
  714. $text1=stripSlashes(preg_replace($zztext,$e1."\\".$num.$e2,$info));
  715. $r=explode($e1,$text1);
  716. $r1=explode($e2,$r[1]);
  717. $text1=$r1[0];
  718. return $text1;
  719. }
  720. //替换链接
  721. function RepCjUrlStr($url){
  722. $url=strip_tags($url);
  723. $url=str_replace("\"","",$url);
  724. $url=str_replace("'","",$url);
  725. $url=str_replace("&amp;","&",$url);
  726. return $url;
  727. }
  728. //编码转换
  729. function doCjUtfAndGbk($str,$phome=0){
  730. //正常编码
  731. if($phome==0)
  732. {
  733. return $str;
  734. }
  735. if($phome==1)//UTF8->GB2312
  736. {
  737. $str=DoIconvVal("UTF8","GB2312",$str);
  738. }
  739. elseif($phome==2)//UTF8->BIG5
  740. {
  741. $str=DoIconvVal("UTF8","BIG5",$str);
  742. }
  743. elseif($phome==3)//BIG5->GB2312
  744. {
  745. $str=DoIconvVal("BIG5","GB2312",$str);
  746. }
  747. elseif($phome==4)//GB2312->BIG5
  748. {
  749. $str=DoIconvVal("GB2312","BIG5",$str);
  750. }
  751. elseif($phome==5)//UNICODE->GB2312
  752. {
  753. $str=DoIconvVal("UNICODE","GB2312",$str);
  754. }
  755. elseif($phome==6)//UNICODE->BIG5
  756. {
  757. $str=DoIconvVal("UNICODE","BIG5",$str);
  758. }
  759. elseif($phome==7)//GB2312->UTF8
  760. {
  761. $str=DoIconvVal("GB2312","UTF8",$str);
  762. }
  763. elseif($phome==8)//BIG5->UTF8
  764. {
  765. $str=DoIconvVal("BIG5","UTF8",$str);
  766. }
  767. elseif($phome==9)//UNICODE->UTF8
  768. {
  769. $str=DoIconvVal("UNICODE","UTF8",$str);
  770. }
  771. else
  772. {}
  773. return $str;
  774. }
  775. //替换采集页面内容
  776. function RepCjPagetextStr($text,$r){
  777. $text=str_replace("\\","/",$text);
  778. //编码转换
  779. $text=doCjUtfAndGbk($text,$r['enpagecode']);
  780. //替换
  781. $text=RepInfoWord($text,$r['oldpagerep'],$r['newpagerep']);
  782. //替换页面过滤正则
  783. $text=RepPageAd($r['pagerepad'],$text);
  784. return $text;
  785. }
  786. //取得地址
  787. function EchoUrl($text,$exp,$exp1,$dr,$url,$classid,$num,$checkrnd){
  788. global $empire,$fun_r,$dbtbpre;
  789. $e1="[phome-".$exp."]";
  790. $e2="[/phome-".$exp."]";
  791. $ep1="[phome-".$exp1."]";
  792. $ep2="[/phome-".$exp1."]";
  793. $r=explode($e1,$text);
  794. //图片链接
  795. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  796. {
  797. $rp=explode($ep1,$text);
  798. }
  799. else
  800. {
  801. $titlepic=$dr[z_titlepicl];
  802. }
  803. for($i=1;$i<count($r)&&$i<=$num;$i++)
  804. {
  805. $r1=explode($e2,$r[$i]);
  806. $dourl=trim($r1[0]);
  807. //是否有http
  808. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  809. {}
  810. else
  811. {
  812. $dourl=$url.$dourl;
  813. }
  814. //替换地址
  815. $dourl=RepCjUrlStr($dourl);
  816. if(empty($dourl))
  817. {continue;}
  818. $dourl=addslashes($dourl);
  819. //---------------检查数据库是否有记录
  820. if(empty($dr[recjtheurl]))//重复采集
  821. {
  822. $dbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$dr[tbname]." where oldurl='$dourl' limit 1");
  823. if($dbnum)
  824. {continue;}
  825. }
  826. //图片链接
  827. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  828. {
  829. $rp1=explode($ep2,$rp[$i]);
  830. $titlepic=trim($rp1[0]);
  831. //是否有http
  832. if(strstr($titlepic,"http://")||strstr($titlepic,"https://"))
  833. {}
  834. else
  835. {$titlepic=$dr[qz_titlepicl].$titlepic;}
  836. //替换地址
  837. $titlepic=RepCjUrlStr($titlepic);
  838. $titlepic=addslashes($titlepic);
  839. }
  840. //将地址写入数据库
  841. $sql=$empire->query("insert into {$dbtbpre}enewslinktmp(newsurl,checkrnd,titlepic) values('$dourl','$checkrnd','$titlepic');");
  842. echo $dourl."<br>";
  843. }
  844. }
  845. //采集直接内容页地址
  846. function PageEchoUrl($classid,$cr,$userid,$username){
  847. global $empire,$fun_r,$dbtbpre;
  848. //取得条数
  849. if(empty($cr[num]))
  850. {$cr[num]=10000;}
  851. //生成检测值
  852. $checkrnd=md5(uniqid(microtime()));
  853. $url_r=explode("\r\n",$cr[infourl]);
  854. $count=count($url_r);
  855. if($count>$cr[num])
  856. {
  857. $count=$cr[num];
  858. }
  859. for($i=0;$i<$count;$i++)
  860. {
  861. $dourl=trim($url_r[$i]);
  862. if(empty($dourl))
  863. {
  864. continue;
  865. }
  866. //是否有http
  867. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  868. {}
  869. else
  870. {
  871. $dourl=$cr[httpurl].$dourl;
  872. }
  873. //替换地址
  874. $dourl=RepCjUrlStr($dourl);
  875. if(empty($dourl))
  876. {continue;}
  877. $dourl=addslashes($dourl);
  878. //---------------检查数据库是否有记录
  879. if(empty($cr[recjtheurl]))//重复采集
  880. {
  881. $dbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where oldurl='$dourl' limit 1");
  882. if($dbnum)
  883. {continue;}
  884. }
  885. //将地址写入数据库
  886. $sql=$empire->query("insert into {$dbtbpre}enewslinktmp(newsurl,checkrnd,titlepic) values('$dourl','$checkrnd','');");
  887. echo $dourl."<br>";
  888. }
  889. echo $fun_r['GetUrlOver']."<script>self.location.href='ecmscj.php?enews=GetNewsInfo&classid=$classid&start=0&checkrnd=$checkrnd';</script>";
  890. exit();
  891. }
  892. //开始采集远程地址
  893. function CJUrl($classid,$start,$checkrnd,$userid,$username){
  894. global $empire,$fun_r,$dbtbpre;
  895. $classid=(int)$classid;
  896. if(empty($classid))
  897. {printerror("NotChangeCjid","history.go(-1)");}
  898. //验证权限
  899. CheckLevel($userid,$username,$classid,"cj");
  900. $r=$empire->fetch1("select endday,num,zz_smallurl,zz_newsurl,httpurl,infourl,newsclassid,relistnum,zz_titlepicl,z_titlepicl,qz_titlepicl,save_titlepicl,tbname,recjtheurl,enpagecode,pagerepad,oldpagerep,newpagerep,keeptime,infourlispage from {$dbtbpre}enewsinfoclass where classid='$classid'");
  901. if(empty($r[newsclassid]))
  902. {printerror("NotCjid","history.go(-1)");}
  903. //直接内容页链接列表
  904. if($r['infourlispage'])
  905. {
  906. PageEchoUrl($classid,$r,$userid,$username);
  907. }
  908. //导入编码文件
  909. if($r['enpagecode'])
  910. {
  911. @include_once("doiconv.php");
  912. }
  913. //取得条数
  914. if(empty($r[num]))
  915. {$r[num]=10000;}
  916. if(empty($r[relistnum]))
  917. {$r[relistnum]=1;}
  918. if(empty($start))
  919. {
  920. $start=0;
  921. //生成检测值
  922. $checkrnd=md5(uniqid(microtime()));
  923. }
  924. $exp="newsurl";
  925. $exp1="titlepic";
  926. //查看是否过期
  927. $b=0;
  928. $p=0;
  929. $url_r=explode("\r\n",$r[infourl]);
  930. $j=count($url_r);
  931. for($i=$start;$i<$j&&$p<$r[relistnum];$i++)
  932. {
  933. $p++;
  934. $b=1;
  935. $dourl=trim($url_r[$i]);
  936. if(empty($dourl)||!eCheckCjUrl($dourl,1))
  937. {continue;}
  938. //读取页面
  939. for($readnum=0;$readnum<3;$readnum++)
  940. {
  941. $text1=ReadFiletext($dourl);
  942. if(!empty($text1))
  943. {break;}
  944. }
  945. if(empty($text1))
  946. {continue;}
  947. //替换回车
  948. $text1=ReplaceFc($text1);
  949. //替换网页变量
  950. $text1=RepCjPagetextStr($text1,$r);
  951. //区域块
  952. if($r[zz_smallurl])
  953. {
  954. $text1=ReturnCJ_str($r[zz_smallurl],"smallurl",$text1);
  955. if(empty($text1))
  956. {
  957. continue;
  958. }
  959. }
  960. //替换内容链接
  961. $text=stripSlashes(stripSlashes($r[zz_newsurl]));
  962. //替换回车
  963. $text=ReplaceFc($text);
  964. $zztext=RepInfoZZ($text,$exp,0);
  965. $strtext=GetInfoStr($text,$exp,1);
  966. if($text)
  967. {
  968. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  969. }
  970. //替换标题图片地址
  971. if($r[zz_titlepicl]&&!$r[z_titlepicl])
  972. {
  973. $text=stripSlashes(stripSlashes($r[zz_titlepicl]));
  974. //替换回车
  975. $text=ReplaceFc($text);
  976. $zztext=RepInfoZZ($text,$exp1,0);
  977. $strtext=GetInfoStr($text,$exp1,1);
  978. if($text)
  979. {
  980. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  981. }
  982. }
  983. //链接写入数据库
  984. EchoUrl($text1,$exp,$exp1,$r,$r[httpurl],$classid,$r[num],$checkrnd);
  985. }
  986. $newstart=$i;
  987. //采集链接完毕
  988. if(empty($b))
  989. {
  990. echo $fun_r['GetUrlOver']."<script>self.location.href='ecmscj.php?enews=GetNewsInfo&classid=$classid&start=0&checkrnd=$checkrnd';</script>";
  991. exit();
  992. }
  993. //echo $fun_r['GetOneListUrl']."<script>self.location.href='ecmscj.php?enews=CjUrl&classid=$classid&start=$newstart&checkrnd=$checkrnd';</script>";
  994. echo"<meta http-equiv=\"refresh\" content=\"".$r['keeptime'].";url=ecmscj.php?enews=CjUrl&classid=$classid&start=$newstart&checkrnd=$checkrnd\">".$fun_r['GetOneListUrl'];
  995. exit();
  996. }
  997. //###################采集页面列表##################
  998. function ViewCjList($classid,$userid,$username){
  999. global $empire,$fun_r,$dbtbpre;
  1000. $classid=(int)$classid;
  1001. if(empty($classid))
  1002. {printerror("NotChangeCjid","history.go(-1)");}
  1003. //验证权限
  1004. CheckLevel($userid,$username,$classid,"cj");
  1005. $r=$empire->fetch1("select endday,num,zz_smallurl,zz_newsurl,httpurl,infourl,newsclassid,relistnum,zz_titlepicl,z_titlepicl,qz_titlepicl,save_titlepicl,infourlispage from {$dbtbpre}enewsinfoclass where classid='$classid'");
  1006. if(empty($r[newsclassid]))
  1007. {printerror("NotCjid","history.go(-1)");}
  1008. //直接内容页列表
  1009. if($r[infourlispage])
  1010. {
  1011. PageViewCjList($classid,$r,$userid,$username);
  1012. }
  1013. $url_r=explode("\r\n",$r[infourl]);
  1014. $j=count($url_r);
  1015. for($i=0;$i<$j;$i++)
  1016. {
  1017. if(empty($url_r[$i]))
  1018. {continue;}
  1019. $dourl=urlencode($url_r[$i]);
  1020. $data.="<tr><td><a href='".$url_r[$i]."' target=_blank>".$url_r[$i]."</a></td><td align=center>[<a href='ecmscj.php?enews=ViewCjUrl&classid=$classid&listpage=".$dourl."' target=_blank>".$fun_r['view']."</a>]</td></tr>";
  1021. }
  1022. $data="<p align=center><b>".$fun_r['CjListUrl']."</b></p><table width='96%' border=1 align=center cellpadding=3 cellspacing=0>
  1023. <tr><td width=70% align=center><b>URL</b></td><td align=center><b>VIEW</b></td></tr>".$data."</table>";
  1024. echo $data;
  1025. exit();
  1026. }
  1027. //###################采集内容页面列表##################
  1028. function PageViewCjList($classid,$cr,$userid,$username){
  1029. global $empire,$fun_r,$dbtbpre;
  1030. //取得条数
  1031. if(empty($cr[num]))
  1032. {$cr[num]=10000;}
  1033. $url_r=explode("\r\n",$cr[infourl]);
  1034. $count=count($url_r);
  1035. if($count>$cr[num])
  1036. {
  1037. $count=$cr[num];
  1038. }
  1039. for($i=0;$i<$count;$i++)
  1040. {
  1041. $dourl=trim($url_r[$i]);
  1042. if(empty($dourl))
  1043. {
  1044. continue;
  1045. }
  1046. //是否有http
  1047. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  1048. {}
  1049. else
  1050. {
  1051. $dourl=$cr[httpurl].$dourl;
  1052. }
  1053. //替换地址
  1054. $dourl=RepCjUrlStr($dourl);
  1055. if(empty($dourl))
  1056. {continue;}
  1057. $dourl=urlencode($dourl);
  1058. $data.="<tr><td><a href='".$url_r[$i]."' target=_blank>".$url_r[$i]."</a></td><td align=center>[<a href='ecmscj.php?enews=ViewGetNewsInfo&classid=$classid&newspage=".$dourl."' target=_blank>".$fun_r['view']."</a>]</td></tr>";
  1059. }
  1060. $data="<p align=center><b>".$fun_r['CjListUrl']."</b></p><table width='96%' border=1 align=center cellpadding=3 cellspacing=0>
  1061. <tr><td width=70% align=center><b>URL</b></td><td align=center><b>VIEW</b></td></tr>".$data."</table>";
  1062. echo $data;
  1063. exit();
  1064. }
  1065. //#################预览采集列表
  1066. function ViewCjUrl($classid,$listpage,$userid,$username){
  1067. global $empire,$fun_r,$dbtbpre;
  1068. $classid=(int)$classid;
  1069. if(empty($classid)||empty($listpage))
  1070. {printerror("NotChangeCjid","history.go(-1)");}
  1071. //验证权限
  1072. CheckLevel($userid,$username,$classid,"cj");
  1073. $r=$empire->fetch1("select endday,num,zz_smallurl,zz_newsurl,httpurl,infourl,newsclassid,relistnum,zz_titlepicl,z_titlepicl,qz_titlepicl,save_titlepicl,tbname,recjtheurl,enpagecode,pagerepad,oldpagerep,newpagerep from {$dbtbpre}enewsinfoclass where classid='$classid'");
  1074. if(empty($r[newsclassid]))
  1075. {printerror("NotCjid","history.go(-1)");}
  1076. //导入编码文件
  1077. if($r['enpagecode'])
  1078. {
  1079. @include_once("doiconv.php");
  1080. }
  1081. //取得条数
  1082. if(empty($r[num]))
  1083. {$r[num]=10000;}
  1084. $exp="newsurl";
  1085. $exp1="titlepic";
  1086. $dourl=$listpage;
  1087. eCheckCjUrl($dourl,0);
  1088. //读取页面
  1089. for($readnum=0;$readnum<3;$readnum++)
  1090. {
  1091. $text1=ReadFiletext($dourl);
  1092. if(!empty($text1))
  1093. {break;}
  1094. }
  1095. if(empty($text1))
  1096. {
  1097. printerror("FailCjUrl","history.go(-1)");
  1098. }
  1099. //替换回车
  1100. $text1=ReplaceFc($text1);
  1101. //替换网页变量
  1102. $text1=RepCjPagetextStr($text1,$r);
  1103. //区域块
  1104. if($r[zz_smallurl])
  1105. {
  1106. $text1=ReturnCJ_str($r[zz_smallurl],"smallurl",$text1);
  1107. if(empty($text1))
  1108. {
  1109. printerror("EmptyCjSmallUrl","history.go(-1)");
  1110. }
  1111. }
  1112. //替换内容链接
  1113. $text=stripSlashes(stripSlashes($r[zz_newsurl]));
  1114. //替换回车
  1115. $text=ReplaceFc($text);
  1116. $zztext=RepInfoZZ($text,$exp,0);
  1117. $strtext=GetInfoStr($text,$exp,1);
  1118. if($text)
  1119. {
  1120. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  1121. }
  1122. //替换标题图片地址
  1123. if($r[zz_titlepicl]&&!$r[z_titlepicl])
  1124. {
  1125. $text=stripSlashes(stripSlashes($r[zz_titlepicl]));
  1126. //替换回车
  1127. $text=ReplaceFc($text);
  1128. $zztext=RepInfoZZ($text,$exp1,0);
  1129. $strtext=GetInfoStr($text,$exp1,1);
  1130. if($text)
  1131. {
  1132. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  1133. }
  1134. }
  1135. //输出地址
  1136. echo"<p align=center><b>".$fun_r['CjListPageUrl']."</b></p><table width='96%' border=1 align=center cellpadding=3 cellspacing=0>
  1137. <tr><td width=70% align=center><b>URL</b></td><td align=center><b>VIEW</b></td></tr>";
  1138. ViewEchoUrl($text1,$exp,$exp1,$r,$r[httpurl],$classid,$r[num],$checkrnd);
  1139. echo"</table>";
  1140. exit();
  1141. }
  1142. //################输入采集页面
  1143. function ViewEchoUrl($text,$exp,$exp1,$dr,$url,$classid,$num,$checkrnd){
  1144. global $empire,$fun_r,$dbtbpre;
  1145. $e1="[phome-".$exp."]";
  1146. $e2="[/phome-".$exp."]";
  1147. $ep1="[phome-".$exp1."]";
  1148. $ep2="[/phome-".$exp1."]";
  1149. $r=explode($e1,$text);
  1150. //图片链接
  1151. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  1152. {
  1153. $rp=explode($ep1,$text);
  1154. }
  1155. else
  1156. {
  1157. $titlepic=$dr[z_titlepicl];
  1158. }
  1159. for($i=1;$i<count($r)&&$i<=$num;$i++)
  1160. {
  1161. $r1=explode($e2,$r[$i]);
  1162. $dourl=trim($r1[0]);
  1163. //是否有http
  1164. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  1165. {}
  1166. else
  1167. {
  1168. $dourl=$url.$dourl;
  1169. }
  1170. //替换地址
  1171. $dourl=RepCjUrlStr($dourl);
  1172. if(empty($dourl))
  1173. {continue;}
  1174. $dourl=addslashes($dourl);
  1175. //检查数据库是否有记录
  1176. if(empty($dr[recjtheurl]))
  1177. {
  1178. $dbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$dr[tbname]." where oldurl='$dourl' limit 1");
  1179. if($dbnum)
  1180. {continue;}
  1181. }
  1182. //图片链接
  1183. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  1184. {
  1185. $rp1=explode($ep2,$rp[$i]);
  1186. $titlepic=trim($rp1[0]);
  1187. //是否有http
  1188. if(strstr($titlepic,"http://")||strstr($titlepic,"https://"))
  1189. {}
  1190. else
  1191. {$titlepic=$dr[qz_titlepicl].$titlepic;}
  1192. //替换地址
  1193. $titlepic=RepCjUrlStr($titlepic);
  1194. $titlepic=addslashes($titlepic);
  1195. }
  1196. if($titlepic)
  1197. {$a="<br>(PIC:<a href='".$titlepic."' target=_blank>".$titlepic."</a>)";}
  1198. echo "<tr><td><a href='".$dourl."' target=_blank>".$dourl."</a>".$a."</td><td align=center>[<a href='ecmscj.php?enews=ViewGetNewsInfo&classid=$classid&newspage=".urlencode($dourl)."' target=_blank>".$fun_r['view']."</a>]</td></tr>";
  1199. }
  1200. }
  1201. //#################################
  1202. //取得下载地址
  1203. function GetCjDownpath($text,$text1,$exp,$exp1,$url,$online=0){
  1204. global $empire,$fun_r;
  1205. if($online)
  1206. {
  1207. $fun_r[DownPath]="";
  1208. }
  1209. $e1="[phome-".$exp."]";
  1210. $e2="[/phome-".$exp."]";
  1211. $ep1="[phome-".$exp1."]";
  1212. $ep2="[/phome-".$exp1."]";
  1213. $r=explode($e1,$text);
  1214. //名称
  1215. if($text1)
  1216. {
  1217. $rp=explode($ep1,$text1);
  1218. }
  1219. $p=0;
  1220. for($i=1;$i<count($r);$i++)
  1221. {
  1222. $r1=explode($e2,$r[$i]);
  1223. $dourl=trim($r1[0]);
  1224. if(empty($dourl))
  1225. {continue;}
  1226. if(!strstr($dourl,"://"))
  1227. {
  1228. $dourl=$url.$dourl;
  1229. }
  1230. if($text1)
  1231. {
  1232. $rp1=explode($ep2,$rp[$i]);
  1233. $doname=trim($rp1[0]);
  1234. if(empty($doname))
  1235. {
  1236. $doname=$fun_r[DownPath].($p+1);
  1237. }
  1238. }
  1239. else
  1240. {
  1241. $doname=$fun_r[DownPath].($p+1);
  1242. }
  1243. $downname[$p]=$doname;
  1244. $downpath[$p]=$dourl;
  1245. $p++;
  1246. }
  1247. $down=ReturnDownpath($downname,$downpath,$delpathid,$pathid,$downuser,$fen,$thedownqz,$add,$foruser,$downurl,0);
  1248. return $down;
  1249. }
  1250. //取得图片集地址
  1251. function GetCjMorepicpath($text,$text1,$text2,$exp,$exp1,$exp2,$url){
  1252. global $empire;
  1253. $e1="[phome-".$exp."]";
  1254. $e2="[/phome-".$exp."]";
  1255. $ep1="[phome-".$exp1."]";
  1256. $ep2="[/phome-".$exp1."]";
  1257. $epp1="[phome-".$exp2."]";
  1258. $epp2="[/phome-".$exp2."]";
  1259. $r=explode($e1,$text);
  1260. //大图
  1261. if($text1)
  1262. {
  1263. $rp=explode($ep1,$text1);
  1264. }
  1265. //名称
  1266. if($text2)
  1267. {
  1268. $rpp=explode($epp1,$text2);
  1269. }
  1270. $p=0;
  1271. for($i=1;$i<count($r);$i++)
  1272. {
  1273. $r1=explode($e2,$r[$i]);
  1274. $dourl=trim($r1[0]);
  1275. if(empty($dourl))
  1276. {continue;}
  1277. if(!strstr($dourl,"://"))
  1278. {
  1279. $dourl=$url.$dourl;
  1280. }
  1281. //大图
  1282. if($text1)
  1283. {
  1284. $rp1=explode($ep2,$rp[$i]);
  1285. $dobigurl=trim($rp1[0]);
  1286. if(!empty($dobigurl))
  1287. {
  1288. if(!strstr($dobigurl,"://"))
  1289. {
  1290. $dobigurl=$url.$dobigurl;
  1291. }
  1292. }
  1293. }
  1294. else
  1295. {
  1296. $dobigurl="";
  1297. }
  1298. //图片名称
  1299. if($text2)
  1300. {
  1301. $rpp1=explode($epp2,$rpp[$i]);
  1302. $doname=trim($rpp1[0]);
  1303. }
  1304. else
  1305. {
  1306. $doname="";
  1307. }
  1308. $smallpic[$p]=$dourl;
  1309. $bigpic[$p]=$dobigurl;
  1310. $picname[$p]=$doname;
  1311. $p++;
  1312. }
  1313. $down=ReturnMorepicpath($smallpic,$bigpic,$picname,$delpicid,$picid,$add,$downurl,0);
  1314. return $down;
  1315. }
  1316. //内容页分页处理-下一页式
  1317. function GetMoreCjPagetext($self,$newstextzz,$smallpagezz,$pagezz,$pagetype,$firsttext,$the_r){
  1318. if(empty($pagezz)||empty($newstextzz))
  1319. {return "";}
  1320. //是否保留分页
  1321. $addpagetag=empty($the_r['doaddtextpage'])?'[!--empirenews.page--]':'';
  1322. //取得地址前缀
  1323. $sr=GetPageurlQz($self);
  1324. $pagetext=$firsttext;
  1325. $allpagetext="";
  1326. for($i=0;$i<100;$i++)
  1327. {
  1328. //区域正则
  1329. if($smallpagezz)
  1330. {
  1331. $pagetext=ReturnCJ_str($smallpagezz,"smallpagezz",$pagetext);
  1332. }
  1333. $nextlink=ReturnCJ_str($pagezz,"pagezz",$pagetext);
  1334. if(empty($nextlink))
  1335. {
  1336. break;
  1337. }
  1338. if(!strstr($nextlink,"http://"))
  1339. {
  1340. //根目录开始
  1341. if(strstr($nextlink,"/"))
  1342. {
  1343. $nextlink=$sr[domain].$nextlink;
  1344. }
  1345. else
  1346. {
  1347. $nextlink=$sr[selfqz].$nextlink;
  1348. }
  1349. }
  1350. $nextlink=RepCjUrlStr($nextlink);
  1351. if($nextlink==$self||!eCheckCjUrl($nextlink,1))
  1352. {continue;}
  1353. //取得远程数据
  1354. for($j=0;$j<3;$j++)
  1355. {
  1356. $pagetext=ReadFiletext($nextlink);
  1357. if($pagetext)
  1358. {
  1359. break;
  1360. }
  1361. }
  1362. //页面不存在
  1363. if(empty($pagetext))
  1364. {
  1365. break;
  1366. }
  1367. //替换网页变量
  1368. $pagetext=RepCjPagetextStr($pagetext,$the_r);
  1369. //替换回车
  1370. $pagetext=ReplaceFc($pagetext);
  1371. $newstext=ReturnCJ_str($newstextzz,"newstext",$pagetext);
  1372. if($newstext)
  1373. {
  1374. $allpagetext.=$addpagetag.$newstext;
  1375. }
  1376. }
  1377. return $allpagetext;
  1378. }
  1379. //内容页分页处理-全部列表式
  1380. function GetMoreCjPagetextall($self,$newstextzz,$smallpagezz,$pagezz,$pagetype,$firsttext,$the_r){
  1381. if(empty($pagezz)||empty($newstextzz))
  1382. {return "";}
  1383. //是否保留分页
  1384. $addpagetag=empty($the_r['doaddtextpage'])?'[!--empirenews.page--]':'';
  1385. $exp="pageallzz";
  1386. //取得地址前缀
  1387. $sr=GetPageurlQz($self);
  1388. $pagetext=$firsttext;
  1389. $allpagetext="";
  1390. //区域正则
  1391. if($smallpagezz)
  1392. {
  1393. $pagetext=ReturnCJ_str($smallpagezz,"smallpageallzz",$pagetext);
  1394. }
  1395. //分页
  1396. $text=stripSlashes(stripSlashes($pagezz));
  1397. //替换回车
  1398. $text=ReplaceFc($text);
  1399. $zztext=RepInfoZZ($text,$exp,0);
  1400. $strtext=GetInfoStr($text,$exp,1);
  1401. $pagetext=stripSlashes(preg_replace($zztext,$strtext,$pagetext));
  1402. $e1="[phome-".$exp."]";
  1403. $e2="[/phome-".$exp."]";
  1404. $r=explode($e1,$pagetext);
  1405. $count=count($r);
  1406. for($i=1;$i<$count;$i++)
  1407. {
  1408. $r1=explode($e2,$r[$i]);
  1409. $nextlink=trim($r1[0]);
  1410. if(empty($nextlink))
  1411. {continue;}
  1412. if(!strstr($nextlink,"http://"))
  1413. {
  1414. //根目录开始
  1415. if(strstr($nextlink,"/"))
  1416. {
  1417. $nextlink=$sr[domain].$nextlink;
  1418. }
  1419. else
  1420. {
  1421. $nextlink=$sr[selfqz].$nextlink;
  1422. }
  1423. }
  1424. $nextlink=RepCjUrlStr($nextlink);
  1425. if($nextlink==$self||!eCheckCjUrl($nextlink,1))
  1426. {continue;}
  1427. //取得远程数据
  1428. for($j=0;$j<3;$j++)
  1429. {
  1430. $pagetext=ReadFiletext($nextlink);
  1431. if($pagetext)
  1432. {
  1433. break;
  1434. }
  1435. }
  1436. //页面不存在
  1437. if(empty($pagetext))
  1438. {
  1439. continue;
  1440. }
  1441. //替换网页变量
  1442. $pagetext=RepCjPagetextStr($pagetext,$the_r);
  1443. //替换回车
  1444. $pagetext=ReplaceFc($pagetext);
  1445. $newstext=ReturnCJ_str($newstextzz,"newstext",$pagetext);
  1446. if($newstext)
  1447. {
  1448. $allpagetext.=$addpagetag.$newstext;
  1449. }
  1450. }
  1451. return $allpagetext;
  1452. }
  1453. //采集时间格式转换
  1454. function CjFormatNewstime($newstime){
  1455. $newstime=str_replace(array('年','月','日','.','时','分','秒','/'),array('-','-','','-',':',':','','-'),$newstime);
  1456. return $newstime;
  1457. }
  1458. //采集信息文件
  1459. function GetNewsInfo($classid,$checkrnd,$start,$userid,$username){
  1460. global $empire,$class_r,$fun_r,$dbtbpre;
  1461. $userid=(int)$userid;
  1462. $classid=(int)$classid;
  1463. $start=(int)$start;
  1464. $checkrnd=RepPostVar($checkrnd);
  1465. if(empty($classid)||empty($checkrnd))
  1466. {printerror("FailCX","ListInfoClass.php");}
  1467. //验证权限
  1468. CheckLevel($userid,$username,$classid,"cj");
  1469. $r=$empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='$classid'");
  1470. //副表
  1471. $ra=$empire->fetch1("select * from {$dbtbpre}ecms_infoclass_".$r[tbname]." where classid='$classid'");
  1472. //组合两数组
  1473. $r=TogTwoArray($r,$ra);
  1474. //导入编码文件
  1475. if($r['enpagecode'])
  1476. {
  1477. @include_once(ECMS_PATH."e/class/doiconv.php");
  1478. }
  1479. //取得模型
  1480. $record="<!--record-->";
  1481. $field="<!--field--->";
  1482. $mr=$empire->fetch1("select cj,tid,tbname from {$dbtbpre}enewsmod where mid='".$class_r[$r[newsclassid]][modid]."'");
  1483. $cjr=explode($record,$mr[cj]);
  1484. $count=count($cjr);
  1485. if(empty($start))
  1486. {$start=0;}
  1487. $b=0;
  1488. $sql=$empire->query("select linkid,newsurl,titlepic from {$dbtbpre}enewslinktmp where checkrnd='$checkrnd' and linkid>".$start." order by linkid limit ".$r[renum]);
  1489. //采集时间
  1490. $newstime=date("Y-m-d H:i:s");
  1491. $truetime=time();
  1492. $tmptime=$newstime;
  1493. while($nr=$empire->fetch($sql))
  1494. {
  1495. $b=1;
  1496. $newstart=$nr[linkid];
  1497. if(!eCheckCjUrl($nr[newsurl],1))
  1498. {
  1499. continue;
  1500. }
  1501. //入库数据库是否有记录
  1502. if(empty($r[recjtheurl]))
  1503. {
  1504. $tmpnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$r[tbname]." where oldurl='$nr[newsurl]' limit 1");
  1505. if($tmpnum)
  1506. {continue;}
  1507. }
  1508. //取得远程页面,三次取不到值的将不取值
  1509. for($i=1;$i<=3;$i++)
  1510. {
  1511. $info=ReadFiletext($nr[newsurl]);
  1512. if(!empty($info))
  1513. {
  1514. break;
  1515. }
  1516. }
  1517. if(empty($info))
  1518. {continue;}
  1519. //替换网页变量
  1520. $info=RepCjPagetextStr($info,$r);
  1521. //替换回车
  1522. $info=ReplaceFc($info);
  1523. //-----------------
  1524. $ifield="";
  1525. $ivalue="";
  1526. $next=0;
  1527. for($c=0;$c<$count-1;$c++)
  1528. {
  1529. $zzvalue="";
  1530. $cjr1=explode($field,$cjr[$c]);
  1531. $dofield=$cjr1[1];
  1532. $var="zz_".$dofield;
  1533. $var1="z_".$dofield;
  1534. $var2="qz_".$dofield;
  1535. $var3="save_".$dofield;
  1536. //标题图片
  1537. if($dofield=="titlepic")
  1538. {
  1539. if($nr[titlepic])
  1540. {
  1541. $zzvalue=$nr[titlepic];
  1542. $ifield.=",".$dofield;
  1543. $ivalue.=",'".addslashes($zzvalue)."'";
  1544. continue;
  1545. }
  1546. }
  1547. //图片集
  1548. if($dofield=="morepic"&&$r[$var])
  1549. {
  1550. //替换下载链接
  1551. $text=stripSlashes(stripSlashes($r[$var]));
  1552. //替换回车
  1553. $text=ReplaceFc($text);
  1554. $down=explode("[!empirecms!]",$text);
  1555. //小图
  1556. $zztext=RepInfoZZ($down[0],"ecmsspicurl",0);
  1557. $strtext=GetInfoStr($down[0],"ecmsspicurl",1);
  1558. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1559. //大图
  1560. if($down[1])
  1561. {
  1562. $zztext=RepInfoZZ($down[1],"ecmsbpicurl",0);
  1563. $strtext=GetInfoStr($down[1],"ecmsbpicurl",1);
  1564. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1565. }
  1566. //名称
  1567. if($down[2])
  1568. {
  1569. $zztext=RepInfoZZ($down[2],"ecmspicname",0);
  1570. $strtext=GetInfoStr($down[2],"ecmspicname",1);
  1571. $text3=stripSlashes(preg_replace($zztext,$strtext,$info));
  1572. }
  1573. $zzvalue=GetCjMorepicpath($text1,$text2,$text3,"ecmsspicurl","ecmsbpicurl","ecmspicname",$r[$var2]);
  1574. $ifield.=",".$dofield;
  1575. $ivalue.=",'".addslashes($zzvalue)."'";
  1576. continue;
  1577. }
  1578. //下载地址
  1579. if($dofield=="downpath"&&$r[$var])
  1580. {
  1581. //替换下载链接
  1582. $text=stripSlashes(stripSlashes($r[$var]));
  1583. //替换回车
  1584. $text=ReplaceFc($text);
  1585. $down=explode("[!empirecms!]",$text);
  1586. //地址
  1587. $zztext=RepInfoZZ($down[0],"ecmsdownpathurl",0);
  1588. $strtext=GetInfoStr($down[0],"ecmsdownpathurl",1);
  1589. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1590. //名称
  1591. if($down[1])
  1592. {
  1593. $zztext=RepInfoZZ($down[1],"ecmsdownpathname",0);
  1594. $strtext=GetInfoStr($down[1],"ecmsdownpathname",1);
  1595. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1596. }
  1597. $zzvalue=GetCjDownpath($text1,$text2,"ecmsdownpathurl","ecmsdownpathname",$r[$var2],0);
  1598. $ifield.=",".$dofield;
  1599. $ivalue.=",'".addslashes($zzvalue)."'";
  1600. continue;
  1601. }
  1602. //在线地址
  1603. if($dofield=="onlinepath"&&$r[$var])
  1604. {
  1605. //替换下载链接
  1606. $text=stripSlashes(stripSlashes($r[$var]));
  1607. //替换回车
  1608. $text=ReplaceFc($text);
  1609. $down=explode("[!empirecms!]",$text);
  1610. //地址
  1611. $zztext=RepInfoZZ($down[0],"ecmsonlinepathurl",0);
  1612. $strtext=GetInfoStr($down[0],"ecmsonlinepathurl",1);
  1613. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1614. //名称
  1615. if($down[1])
  1616. {
  1617. $zztext=RepInfoZZ($down[1],"ecmsonlinepathname",0);
  1618. $strtext=GetInfoStr($down[1],"ecmsonlinepathname",1);
  1619. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1620. }
  1621. $zzvalue=GetCjDownpath($text1,$text2,"ecmsonlinepathurl","ecmsonlinepathname",$r[$var2],1);
  1622. $ifield.=",".$dofield;
  1623. $ivalue.=",'".addslashes($zzvalue)."'";
  1624. continue;
  1625. }
  1626. if(empty($r[$var1]))
  1627. {
  1628. if($r[$var])
  1629. {
  1630. $zzvalue=ReturnCJ_str($r[$var],$dofield,$info);
  1631. if($zzvalue)
  1632. {
  1633. $zzvalue=$r[$var2].$zzvalue;
  1634. }
  1635. }
  1636. }
  1637. else
  1638. {$zzvalue=$r[$var1];}
  1639. //------------------------------信息时间
  1640. if($dofield=="newstime")
  1641. {
  1642. $newstime=$zzvalue;
  1643. if(empty($newstime))
  1644. {
  1645. $newstime=$tmptime;
  1646. }
  1647. else
  1648. {
  1649. $newstime=CjFormatNewstime($newstime);//时间转换
  1650. }
  1651. continue;
  1652. }
  1653. //------------------------------信息来源
  1654. if($dofield=="befrom"||$dofield=="writer")
  1655. {
  1656. //标题去除html代码
  1657. $zzvalue=strip_tags(str_replace("\r\n","",$zzvalue));
  1658. }
  1659. //------------------------------标题
  1660. if($dofield=="title")
  1661. {
  1662. //标题去除html代码
  1663. $zzvalue=htmlspecialchars(strip_tags(str_replace("\r\n","",$zzvalue)));
  1664. if(empty($zzvalue))
  1665. {
  1666. $next=1;
  1667. break;
  1668. }
  1669. $keyboard=sub($zzvalue,0,$r[keynum],false);
  1670. //标题是否包含关键字
  1671. if($r[keyboard])
  1672. {
  1673. $t=HaveKeyboard($zzvalue,$r[keyboard]);
  1674. if(empty($t))
  1675. {
  1676. $next=1;
  1677. break;
  1678. }
  1679. }
  1680. if($r[retitlewriter])//标题完全一样
  1681. {
  1682. //入库比较
  1683. $onum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$class_r[$r[newsclassid]][tbname]." where title='".addslashes($zzvalue)."' and classid='$r[newsclassid]' limit 1");
  1684. if($onum)
  1685. {
  1686. $next=1;
  1687. break;
  1688. }
  1689. /*采集库比较
  1690. $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title='".addslashes($zzvalue)."' limit 1");
  1691. if($onum)
  1692. {
  1693. $next=1;
  1694. break;
  1695. }
  1696. */
  1697. }
  1698. if($r[titlelen])//标题相似
  1699. {
  1700. //入库比较
  1701. $c_title=addslashes(sub($zzvalue,0,$r[titlelen],false));
  1702. $onum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$class_r[$r[newsclassid]][tbname]." where title like '%$c_title%' and classid='$r[newsclassid]' limit 1");
  1703. if($onum)
  1704. {
  1705. $next=1;
  1706. break;
  1707. }
  1708. /*采集比较
  1709. $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title like '%$c_title%' limit 1");
  1710. if($onum)
  1711. {
  1712. $next=1;
  1713. break;
  1714. }
  1715. */
  1716. }
  1717. }
  1718. //新闻内容分页
  1719. if($dofield=="newstext")
  1720. {
  1721. //是否有分页
  1722. if($r[pagezz]||$r[pageallzz])
  1723. {
  1724. //上下页式
  1725. if(empty($r[pagetype]))
  1726. {
  1727. $zzvalue.=GetMoreCjPagetext($nr[newsurl],$r[$var],$r[smallpagezz],$r[pagezz],$r[pagetype],$info,$r);
  1728. }
  1729. //全部列表式
  1730. else
  1731. {
  1732. $zzvalue.=GetMoreCjPagetextall($nr[newsurl],$r[$var],$r[smallpageallzz],$r[pageallzz],$r[pagetype],$info,$r);
  1733. }
  1734. }
  1735. }
  1736. //替换关键字
  1737. if($dofie

Large files files are truncated, but you can click here to view the full file