cjfun.php 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442
  1. <?php
  2. //修改采集信息
  3. function EditCjNews($add,$newstext,$userid,$username){
  4. global $empire,$class_r,$dbtbpre,$public_r;
  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,0,$public_r['filedeftb']);
  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."='".eaddslashes2($add[$dofield])."'";
  42. }
  43. $sql=$empire->query("update {$dbtbpre}ecms_infotmp_".$cr[tbname]." set keyboard='".eaddslashes2($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=".ehtmlspecialchars($_POST[from]).hReturnEcmsHashStrHref2(0));
  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=".ehtmlspecialchars($_GET[from]).hReturnEcmsHashStrHref2(0));
  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",EcmsGetReturnUrl());
  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,$lur;
  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. $userisqf=EcmsReturnDoIsqf($userid,$username,$lur['groupid'],0);
  134. $mid=$class_r[$cr[newsclassid]][modid];
  135. $savetxtf=$emod_r[$mid]['savetxtf'];
  136. $stb=$emod_r[$mid]['deftb'];
  137. //取得采集字段
  138. $record="<!--record-->";
  139. $field="<!--field--->";
  140. $mr=$empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='".$class_r[$cr[newsclassid]][modid]."'");
  141. $cjr=explode($record,$mr[cj]);
  142. $ccount=count($cjr);
  143. //取得优化字段
  144. for($ci=0;$ci<$ccount-1;$ci++)
  145. {
  146. $cir=explode($field,$cjr[$ci]);
  147. $cifield=$cir[1];
  148. if($cifield=="title")
  149. {
  150. continue;
  151. }
  152. $updatefield.=",".$cifield."=''";
  153. }
  154. for($i=0;$i<count($id);$i++)
  155. {
  156. $a.="id='".$id[$i]."' or ";
  157. }
  158. //去掉最后一个 or
  159. $a=substr($a,0,strlen($a)-4);
  160. $sql=$empire->query("select * from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where ".$a." and checked=0 order by id desc");
  161. $todaytime=time();
  162. $filetime=$todaytime;
  163. while($r=$empire->fetch($sql))
  164. {
  165. $ivalue='';
  166. $ifield='';
  167. $dataivalue='';
  168. $dataifield='';
  169. $titlepicnoval=0;
  170. for($j=0;$j<$ccount-1;$j++)
  171. {
  172. $cjr1=explode($field,$cjr[$j]);
  173. $dofield=$cjr1[1];
  174. $var="zz_".$dofield;
  175. $var1="z_".$dofield;
  176. $var2="qz_".$dofield;
  177. $var3="save_".$dofield;
  178. $value=$r[$dofield];
  179. //自身链接
  180. if($dofield=="empireselfurl")
  181. {
  182. $value=$r['oldurl'];
  183. }
  184. //内容
  185. if($dofield=="newstext")
  186. {
  187. if($cr[copyimg]||$cr[copyflash])
  188. {
  189. $GLOBALS['cjnewsurl']=$r[oldurl];
  190. $value=addslashes(CopyImg(stripSlashes($value),$cr[copyimg],$cr[copyflash],$cr[newsclassid],$cr[imgurl],$username,0,$r['id'],$cr['mark'],$public_r['filedeftb']));
  191. }
  192. //替换关键字和字符
  193. $value=DoReplaceKeyAndWord($value,1,$cr[newsclassid]);
  194. }
  195. //简介
  196. if($dofield=="smalltext")
  197. {
  198. if(empty($value))
  199. {
  200. $value=SubSmalltextVal($r[newstext],$cr[smalltextlen]);
  201. }
  202. else
  203. {
  204. $value=DoClearSmalltextVal($value);
  205. }
  206. }
  207. //图片集
  208. if($dofield=="morepic")
  209. {
  210. if($cr[$var3]==" checked")
  211. {
  212. $msavepic=1;
  213. $r['filepass']=$r['id'];
  214. $value=LoadInSaveMorepicFile($value,$msavepic,$cr[newsclassid],0,$r,0,$public_r['filedeftb']);
  215. }
  216. }
  217. //信息时间
  218. if($dofield=="newstime")
  219. {continue;}
  220. //图片标题
  221. if($dofield=="titlepic"&&$cr[zz_titlepicl])
  222. {
  223. $cr[$var]=$cr[zz_titlepicl];
  224. $cr[$var1]=$cr[z_titlepicl];
  225. $cr[$var2]=$cr[qz_titlepicl];
  226. $cr[$var3]=$cr[save_titlepicl];
  227. }
  228. if($dofield=="titlepic"&&empty($value))
  229. {
  230. $titlepicnoval=1;
  231. }
  232. //是否远程保存
  233. if($value&&!$cr[$var1]&&$cr[$var3]==" checked"&&$dofield!="morepic")
  234. {
  235. $tranr=DoTranUrl($value,$cr[newsclassid]);
  236. if($tranr[tran])
  237. {
  238. $tranr[filesize]=(int)$tranr[filesize];
  239. $tranr[type]=(int)$tranr[type];
  240. $r[id]=(int)$r[id];
  241. //记录数据库
  242. eInsertFileTable($tranr[filename],$tranr[filesize],$tranr[filepath],$username,$cr[newsclassid],'[URL]'.$tranr[filename],$tranr[type],0,$r[id],$public_r[fpath],0,0,$public_r['filedeftb']);
  243. $value=$tranr[url];
  244. }
  245. }
  246. //存放文本
  247. if($savetxtf==$dofield)
  248. {
  249. //建立目录
  250. $thetxtfile=GetFileMd5();
  251. $truevalue=MkDirTxtFile(date("Y/md"),$thetxtfile);
  252. //写放文件
  253. EditTxtFieldText($truevalue,$value);
  254. $value=$truevalue;
  255. }
  256. $value=addslashes($value);
  257. if(strstr($emod_r[$mid]['tbdataf'],','.$dofield.','))//副表
  258. {
  259. $dataifield.=",".$dofield;
  260. $dataivalue.=",'".$value."'";
  261. }
  262. else
  263. {
  264. $ifield.=",".$dofield;
  265. $ivalue.=",'".$value."'";
  266. }
  267. }
  268. $r[keyboard]=addslashes($r[keyboard]);
  269. //时间
  270. if($uptime)//当前时间
  271. {
  272. $r[newstime]=$todaytime;
  273. $r[truetime]=$todaytime;
  274. }
  275. else
  276. {
  277. if($r[newstime]=="0000-00-00 00:00:00")
  278. {
  279. $r[newstime]=$todaytime;
  280. }
  281. else
  282. {
  283. $r[newstime]=to_time($r[newstime]);
  284. }
  285. }
  286. //查看目录是否存在,不存在则建立
  287. $newspath=FormatPath($cr[newsclassid],"",0);
  288. //强制签发
  289. if($class_r[$cr[newsclassid]][wfid])
  290. {
  291. if($userisqf)
  292. {
  293. $checked=$checked;
  294. $isqf=0;
  295. }
  296. else
  297. {
  298. $checked=0;
  299. $isqf=1;
  300. }
  301. }
  302. else
  303. {
  304. $checked=$checked;
  305. $isqf=0;
  306. }
  307. //变量处理
  308. $newstempid=0;
  309. $ispic=$r[titlepic]?1:0;
  310. //取得返回关键字
  311. $keyid=GetKeyid($r[keyboard],$cr[newsclassid],0,$class_r[$cr[newsclassid]][link_num]);
  312. //索引表
  313. $havehtml=0;
  314. $indexsql=$empire->query("insert into {$dbtbpre}ecms_".$class_r[$cr[newsclassid]][tbname]."_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('$cr[newsclassid]','$checked','$r[newstime]','$r[truetime]','$r[truetime]','$havehtml');");
  315. $id=$empire->lastid();
  316. $infotbr=ReturnInfoTbname($class_r[$cr[newsclassid]][tbname],$checked,$stb);
  317. //主表
  318. $isurl=$r['titleurl']?1:0;
  319. $isql=$empire->query("insert into ".$infotbr['tbname']."(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,newstime".$ifield.") values('$id','$cr[newsclassid]',0,0,0,0,'$newspath','$filename','$r[userid]','$r[username]',0,0,'$ispic',0,'$isqf',0,'$isurl','$r[truetime]','$r[truetime]','$havehtml',0,0,'$r[titlefont]','$r[titleurl]','$stb','$public_r[filedeftb]','$public_r[pldeftb]','$r[keyboard]','$r[newstime]'".$ivalue.");");
  320. //副表
  321. $fisql=$empire->query("insert into ".$infotbr['datatbname']."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$dataifield.") values('$id','$cr[newsclassid]','$keyid',1,'$newstempid',0,0,''".$dataivalue.");");
  322. //更新栏目信息数
  323. AddClassInfos($cr['newsclassid'],'+1','+1',$checked);
  324. //更新新信息数
  325. DoUpdateAddDataNum('info',$class_r[$cr['newsclassid']]['tid'],1);
  326. //签发
  327. if($isqf==1)
  328. {
  329. InfoInsertToWorkflow($id,$cr[newsclassid],$class_r[$cr[newsclassid]][wfid],$userid,$username);
  330. }
  331. //更新附件
  332. UpdateTheFile($id,$r['id'],$cr['newsclassid'],$public_r['filedeftb']);
  333. //取第一张图片为标题图片
  334. $addtitlepic="";
  335. if($cr['getfirstpic']&&$titlepicnoval)
  336. {
  337. $firsttitlepic=GetFpicToTpic($cr[newsclassid],$id,$cr['getfirstpic'],$cr['getfirstspic'],$cr['getfirstspicw'],$cr['getfirstspich'],$public_r['filedeftb']);
  338. if($firsttitlepic)
  339. {
  340. $addtitlepic=",titlepic='".addslashes($firsttitlepic)."',ispic=1";
  341. }
  342. }
  343. //文件命名
  344. $filename=ReturnInfoFilename($cr[newsclassid],$id,$r[filenameqz]);
  345. //信息地址
  346. $updateinfourl='';
  347. if(!$isurl)
  348. {
  349. $infourl=GotoGetTitleUrl($cr['newsclassid'],$id,$newspath,$filename,0,$isurl,'');
  350. $updateinfourl=",titleurl='$infourl'";
  351. }
  352. $usql=$empire->query("update ".$infotbr['tbname']." set filename='$filename'".$updateinfourl.$addtitlepic." where id='$id'");
  353. }
  354. //状态原记录
  355. if($cr['delloadinfo'])//删除
  356. {
  357. $del=$empire->query("delete from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where ".$a);
  358. }
  359. else
  360. {
  361. $del=$empire->query("update {$dbtbpre}ecms_infotmp_".$cr[tbname]." set checked=1,keyboard=''".$updatefield." where ".$a);
  362. }
  363. //操作日志
  364. insert_dolog("classid=".$classid);
  365. printerror("CjLoadDbSuccess","CheckCj.php?classid=$classid&from=".ehtmlspecialchars($_POST[from]).hReturnEcmsHashStrHref2(0));
  366. }
  367. //全部采集入库
  368. function CjNewsIn_all($classid,$checked,$uptime,$start,$userid,$username){
  369. global $class_r,$empire,$public_r,$dbtbpre,$fun_r,$emod_r,$lur;
  370. $checked=(int)$checked;
  371. $classid=(int)$classid;
  372. $start=(int)$start;
  373. if(empty($classid))
  374. {
  375. printerror("ErrorUrl","history.go(-1)");
  376. }
  377. //操作权限
  378. CheckLevel($userid,$username,$classid,"cj");
  379. $cr=$empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='$classid'");
  380. //副表
  381. $cra=$empire->fetch1("select * from {$dbtbpre}ecms_infoclass_".$cr[tbname]." where classid='$classid'");
  382. //组合两数组
  383. $cr=TogTwoArray($cr,$cra);
  384. //导入gd处理文件
  385. if($cr['mark']||$cr['getfirstspic'])
  386. {
  387. @include_once("gd.php");
  388. }
  389. $userisqf=EcmsReturnDoIsqf($userid,$username,$lur['groupid'],0);
  390. if(empty($cr[insertnum]))
  391. {$cr[insertnum]=10;}
  392. $mid=$class_r[$cr[newsclassid]][modid];
  393. $savetxtf=$emod_r[$mid]['savetxtf'];
  394. $stb=$emod_r[$mid]['deftb'];
  395. //取得采集字段
  396. $record="<!--record-->";
  397. $field="<!--field--->";
  398. $mr=$empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='".$class_r[$cr[newsclassid]][modid]."'");
  399. $cjr=explode($record,$mr[cj]);
  400. $ccount=count($cjr);
  401. $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]);
  402. $todaytime=time();
  403. $filetime=$todaytime;
  404. $b=0;
  405. while($r=$empire->fetch($sql))
  406. {
  407. $b=1;
  408. $newstart=$r[id];
  409. $ivalue='';
  410. $ifield='';
  411. $dataivalue='';
  412. $dataifield='';
  413. $titlepicnoval=0;
  414. for($j=0;$j<$ccount-1;$j++)
  415. {
  416. $cjr1=explode($field,$cjr[$j]);
  417. $dofield=$cjr1[1];
  418. $var="zz_".$dofield;
  419. $var1="z_".$dofield;
  420. $var2="qz_".$dofield;
  421. $var3="save_".$dofield;
  422. $value=$r[$dofield];
  423. //自身链接
  424. if($dofield=="empireselfurl")
  425. {
  426. $value=$r['oldurl'];
  427. }
  428. //内容
  429. if($dofield=="newstext")
  430. {
  431. if($cr[copyimg]||$cr[copyflash])
  432. {
  433. $GLOBALS['cjnewsurl']=$r[oldurl];
  434. $value=addslashes(CopyImg(stripSlashes($value),$cr[copyimg],$cr[copyflash],$cr[newsclassid],$cr[imgurl],$username,0,$r['id'],$cr['mark'],$public_r['filedeftb']));
  435. }
  436. //替换关键字和字符
  437. $value=DoReplaceKeyAndWord($value,1,$cr[newsclassid]);
  438. }
  439. //简介
  440. if($dofield=="smalltext")
  441. {
  442. if(empty($value))
  443. {
  444. $value=SubSmalltextVal($r[newstext],$cr[smalltextlen]);
  445. }
  446. else
  447. {
  448. $value=DoClearSmalltextVal($value);
  449. }
  450. }
  451. //图片集
  452. if($dofield=="morepic")
  453. {
  454. if($cr[$var3]==" checked")
  455. {
  456. $msavepic=1;
  457. $r['filepass']=$r['id'];
  458. $value=LoadInSaveMorepicFile($value,$msavepic,$cr[newsclassid],0,$r,0,$public_r['filedeftb']);
  459. }
  460. }
  461. //时间
  462. if($dofield=="newstime")
  463. {continue;}
  464. //图片标题
  465. if($dofield=="titlepic"&&$cr[zz_titlepicl])
  466. {
  467. $cr[$var]=$cr[zz_titlepicl];
  468. $cr[$var1]=$cr[z_titlepicl];
  469. $cr[$var2]=$cr[qz_titlepicl];
  470. $cr[$var3]=$cr[save_titlepicl];
  471. }
  472. if($dofield=="titlepic"&&empty($value))
  473. {
  474. $titlepicnoval=1;
  475. }
  476. //是否远程保存
  477. if($value&&!$cr[$var1]&&$cr[$var3]==" checked"&&$dofield!="morepic")
  478. {
  479. $tranr=DoTranUrl($value,$cr[newsclassid]);
  480. if($tranr[tran])
  481. {
  482. $tranr[filesize]=(int)$tranr[filesize];
  483. $tranr[type]=(int)$tranr[type];
  484. $r[id]=(int)$r[id];
  485. //记录数据库
  486. eInsertFileTable($tranr[filename],$tranr[filesize],$tranr[filepath],$username,$cr[newsclassid],'[URL]'.$tranr[filename],$tranr[type],0,$r[id],$public_r[fpath],0,0,$public_r['filedeftb']);
  487. $value=$tranr[url];
  488. }
  489. }
  490. //存放文本
  491. if($savetxtf==$dofield)
  492. {
  493. //建立目录
  494. $thetxtfile=GetFileMd5();
  495. $truevalue=MkDirTxtFile(date("Y/md"),$thetxtfile);
  496. //写放文件
  497. EditTxtFieldText($truevalue,$value);
  498. $value=$truevalue;
  499. }
  500. $value=addslashes($value);
  501. if(strstr($emod_r[$mid]['tbdataf'],','.$dofield.','))//副表
  502. {
  503. $dataifield.=",".$dofield;
  504. $dataivalue.=",'".$value."'";
  505. }
  506. else
  507. {
  508. $ifield.=",".$dofield;
  509. $ivalue.=",'".$value."'";
  510. }
  511. }
  512. $r[keyboard]=addslashes($r[keyboard]);
  513. //时间
  514. if($uptime)//当前时间
  515. {
  516. $r[newstime]=$todaytime;
  517. $r[truetime]=$todaytime;
  518. }
  519. else
  520. {
  521. if($r[newstime]=="0000-00-00 00:00:00")
  522. {
  523. $r[newstime]=$todaytime;
  524. }
  525. else
  526. {
  527. $r[newstime]=to_time($r[newstime]);
  528. }
  529. }
  530. //查看目录是否存在,不存在则建立
  531. $newspath=FormatPath($cr[newsclassid],"",0);
  532. //强制签发
  533. if($class_r[$cr[newsclassid]][wfid])
  534. {
  535. if($userisqf)
  536. {
  537. $checked=$checked;
  538. $isqf=0;
  539. }
  540. else
  541. {
  542. $checked=0;
  543. $isqf=1;
  544. }
  545. }
  546. else
  547. {
  548. $checked=$checked;
  549. $isqf=0;
  550. }
  551. //变量处理
  552. $newstempid=0;
  553. $ispic=$r[titlepic]?1:0;
  554. //返回关键字
  555. $keyid=GetKeyid($r[keyboard],$cr[newsclassid],0,$class_r[$cr[newsclassid]][link_num]);
  556. //索引表
  557. $havehtml=0;
  558. $indexsql=$empire->query("insert into {$dbtbpre}ecms_".$class_r[$cr[newsclassid]][tbname]."_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('$cr[newsclassid]','$checked','$r[newstime]','$r[truetime]','$r[truetime]','$havehtml');");
  559. $id=$empire->lastid();
  560. $infotbr=ReturnInfoTbname($class_r[$cr[newsclassid]][tbname],$checked,$stb);
  561. //主表
  562. $isurl=$r['titleurl']?1:0;
  563. $isql=$empire->query("insert into ".$infotbr['tbname']."(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,newstime".$ifield.") values('$id','$cr[newsclassid]',0,0,0,0,'$newspath','$filename','$r[userid]','$r[username]',0,0,'$ispic',0,'$isqf',0,'$isurl','$r[truetime]','$r[truetime]','$havehtml',0,0,'$r[titlefont]','$r[titleurl]','$stb','$public_r[filedeftb]','$public_r[pldeftb]','$r[keyboard]','$r[newstime]'".$ivalue.");");
  564. //副表
  565. $fisql=$empire->query("insert into ".$infotbr['datatbname']."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$dataifield.") values('$id','$cr[newsclassid]','$keyid',1,'$newstempid',0,0,''".$dataivalue.");");
  566. //更新栏目信息数
  567. AddClassInfos($cr['newsclassid'],'+1','+1',$checked);
  568. //更新新信息数
  569. DoUpdateAddDataNum('info',$class_r[$cr['newsclassid']]['tid'],1);
  570. //签发
  571. if($isqf==1)
  572. {
  573. InfoInsertToWorkflow($id,$cr[newsclassid],$class_r[$cr[newsclassid]][wfid],$userid,$username);
  574. }
  575. //更新附件
  576. UpdateTheFile($id,$r['id'],$cr[newsclassid],$public_r['filedeftb']);
  577. //取第一张图片为标题图片
  578. $addtitlepic="";
  579. if($cr['getfirstpic']&&$titlepicnoval)
  580. {
  581. $firsttitlepic=GetFpicToTpic($cr[newsclassid],$id,$cr['getfirstpic'],$cr['getfirstspic'],$cr['getfirstspicw'],$cr['getfirstspich'],$public_r['filedeftb']);
  582. if($firsttitlepic)
  583. {
  584. $addtitlepic=",titlepic='".addslashes($firsttitlepic)."',ispic=1";
  585. }
  586. }
  587. //文件命名
  588. $filename=ReturnInfoFilename($cr[newsclassid],$id,$r[filenameqz]);
  589. //信息地址
  590. $updateinfourl='';
  591. if(!$isurl)
  592. {
  593. $infourl=GotoGetTitleUrl($cr['newsclassid'],$id,$newspath,$filename,0,$isurl,'');
  594. $updateinfourl=",titleurl='$infourl'";
  595. }
  596. $usql=$empire->query("update ".$infotbr['tbname']." set filename='$filename'".$updateinfourl.$addtitlepic." where id='$id'");
  597. }
  598. $fm=ehtmlspecialchars($_GET['fm']);
  599. //全部入库完毕
  600. if(empty($b))
  601. {
  602. //取得忧化字段
  603. for($ci=0;$ci<$ccount-1;$ci++)
  604. {
  605. $cir=explode($field,$cjr[$ci]);
  606. $cifield=$cir[1];
  607. if($cifield=="title")
  608. {
  609. continue;
  610. }
  611. $updatefield.=",".$cifield."=''";
  612. }
  613. //状态原记录
  614. if($cr['delloadinfo'])//删除
  615. {
  616. $del=$empire->query("delete from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where classid='$classid'");
  617. }
  618. else
  619. {
  620. $del=$empire->query("update {$dbtbpre}ecms_infotmp_".$cr[tbname]." set checked=1,keyboard=''".$updatefield." where classid='$classid'");
  621. }
  622. if($fm)
  623. {
  624. 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=".ehtmlspecialchars($_GET[from]).hReturnEcmsHashStrHref2(0)."');\"></body>";
  625. exit();
  626. }
  627. else
  628. {
  629. printerror("CjLoadDbSuccess","CheckCj.php?classid=$classid&from=".ehtmlspecialchars($_GET[from]).hReturnEcmsHashStrHref2(0));
  630. }
  631. }
  632. //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=".ehtmlspecialchars($_GET[from]).hReturnEcmsHashStrHref(0)."';</script>";
  633. echo"<meta http-equiv=\"refresh\" content=\"".$cr['loadkeeptime'].";url=ecmscj.php?enews=CjNewsIn_all&checked=$checked&uptime=$uptime&classid=$classid&start=$newstart&fm=$fm&from=".ehtmlspecialchars($_GET[from]).hReturnEcmsHashStrHref(0)."\"><b>".$cr['classname']."</b>&nbsp;&nbsp;".$fun_r['OneCjLoadDbSuccess']."(ID:<font color=red><b>".$newstart."</b></font>)";
  634. exit();
  635. }
  636. //##############################采集功能开始###############################
  637. //替换回车
  638. function ReplaceFc($text){
  639. $text=str_replace("\n","",$text);
  640. $text=str_replace("\r","",$text);
  641. return $text;
  642. }
  643. //返回字符正则
  644. function GetInfoStr($text,$exp,$enews=0){
  645. $e1="[phome-".$exp."]";
  646. $e2="[/phome-".$exp."]";
  647. $rep="[!--".$exp."--]";
  648. $mode="*";
  649. //匹配多个
  650. if($enews==1)
  651. {
  652. $cr=explode($rep,$text);
  653. $cer=explode($mode,$cr[0]);
  654. $num=count($cer)-1;
  655. }
  656. //转换字符
  657. $text=str_replace($rep,$mode,$text);
  658. $er=explode($mode,$text);
  659. $newtext="";
  660. for($i=0;$i<count($er);$i++)
  661. {
  662. $j=$i+1;
  663. //加标签
  664. if($enews==1)
  665. {
  666. if($i==$num)
  667. {
  668. $newtext.=$er[$i].$e1."\\".$j.$e2;
  669. }
  670. else
  671. {
  672. $newtext.=$er[$i]."\\".$j;
  673. }
  674. }
  675. //过滤广告
  676. elseif($enews==2)
  677. {
  678. if($i==$num)
  679. {
  680. $newtext.=$er[$i]."";
  681. }
  682. else
  683. {
  684. $newtext.=$er[$i]."\\".$j;
  685. }
  686. }
  687. else
  688. {
  689. $newtext.=$er[$i]."\\".$j;
  690. }
  691. }
  692. //去掉最后一个//
  693. $newtext=substr($newtext,0,strlen($newtext)-2);
  694. return $newtext;
  695. }
  696. //过滤广告
  697. function RepAd($repad,$text){
  698. if(empty($repad))
  699. {return $text;}
  700. $repad=stripSlashes($repad);
  701. //替换回车
  702. $repad=ReplaceFc($repad);
  703. $r=explode(",",$repad);
  704. $exp="ad";
  705. for($i=0;$i<count($r);$i++)
  706. {
  707. $zztext=RepInfoZZ($r[$i],$exp,0);
  708. //$strtext=GetInfoStr($r[$i],$exp,2);
  709. $strtext="";
  710. $text=stripSlashes(preg_replace($zztext,$strtext,$text));
  711. }
  712. return $text;
  713. }
  714. //过滤整个页面广告
  715. function RepPageAd($repad,$text){
  716. if(empty($repad))
  717. {return $text;}
  718. $repad=stripSlashes($repad);
  719. //替换回车
  720. $repad=ReplaceFc($repad);
  721. $r=explode(",",$repad);
  722. $exp="pad";
  723. for($i=0;$i<count($r);$i++)
  724. {
  725. $zztext=RepInfoZZ($r[$i],$exp,0);
  726. //$strtext=GetInfoStr($r[$i],$exp,2);
  727. $strtext="";
  728. $text=stripSlashes(preg_replace($zztext,$strtext,$text));
  729. }
  730. return $text;
  731. }
  732. //地址
  733. function eCheckCjUrl($url,$ecms=0){
  734. if(!strstr($url,'://'))
  735. {
  736. if($ecms)
  737. {
  738. return false;
  739. }
  740. else
  741. {
  742. printerror('ErrorUrl','history.go(-1)');
  743. }
  744. }
  745. return true;
  746. }
  747. //取得符号位置
  748. function CountCJ_site($text,$exp){
  749. $rep="[!--".$exp."--]";
  750. $mode="*";
  751. $cr=explode($rep,$text);
  752. $cer=explode($mode,$cr[0]);
  753. $num=count($cer);
  754. return $num;
  755. }
  756. //取得替换空余出来的值
  757. function ReturnCJ_str($text,$exp,$info){
  758. $e1="[phome-".$exp."]";
  759. $e2="[/phome-".$exp."]";
  760. $text=stripSlashes(stripSlashes($text));
  761. //替换回车
  762. $text=ReplaceFc($text);
  763. $rep="[!--".$exp."--]";
  764. //替换
  765. $num=CountCJ_site($text,$exp);//取得符号位置
  766. $zztext=RepInfoZZ($text,$exp,0);
  767. $text1=stripSlashes(preg_replace($zztext,$e1."\\".$num.$e2,$info));
  768. $r=explode($e1,$text1);
  769. $r1=explode($e2,$r[1]);
  770. $text1=$r1[0];
  771. return $text1;
  772. }
  773. //替换链接
  774. function RepCjUrlStr($url){
  775. $url=strip_tags($url);
  776. $url=str_replace("\"","",$url);
  777. $url=str_replace("'","",$url);
  778. $url=str_replace("&amp;","&",$url);
  779. return $url;
  780. }
  781. //编码转换
  782. function doCjUtfAndGbk($str,$phome=0){
  783. //正常编码
  784. if($phome==0)
  785. {
  786. return $str;
  787. }
  788. if($phome==1)//UTF8->GB2312
  789. {
  790. $str=DoIconvVal("UTF8","GB2312",$str);
  791. }
  792. elseif($phome==2)//UTF8->BIG5
  793. {
  794. $str=DoIconvVal("UTF8","BIG5",$str);
  795. }
  796. elseif($phome==3)//BIG5->GB2312
  797. {
  798. $str=DoIconvVal("BIG5","GB2312",$str);
  799. }
  800. elseif($phome==4)//GB2312->BIG5
  801. {
  802. $str=DoIconvVal("GB2312","BIG5",$str);
  803. }
  804. elseif($phome==5)//UNICODE->GB2312
  805. {
  806. $str=DoIconvVal("UNICODE","GB2312",$str);
  807. }
  808. elseif($phome==6)//UNICODE->BIG5
  809. {
  810. $str=DoIconvVal("UNICODE","BIG5",$str);
  811. }
  812. elseif($phome==7)//GB2312->UTF8
  813. {
  814. $str=DoIconvVal("GB2312","UTF8",$str);
  815. }
  816. elseif($phome==8)//BIG5->UTF8
  817. {
  818. $str=DoIconvVal("BIG5","UTF8",$str);
  819. }
  820. elseif($phome==9)//UNICODE->UTF8
  821. {
  822. $str=DoIconvVal("UNICODE","UTF8",$str);
  823. }
  824. else
  825. {}
  826. return $str;
  827. }
  828. //替换采集页面内容
  829. function RepCjPagetextStr($text,$r){
  830. $text=str_replace("\\","/",$text);
  831. //编码转换
  832. $text=doCjUtfAndGbk($text,$r['enpagecode']);
  833. //替换
  834. $text=RepInfoWord($text,$r['oldpagerep'],$r['newpagerep']);
  835. //替换页面过滤正则
  836. $text=RepPageAd($r['pagerepad'],$text);
  837. return $text;
  838. }
  839. //取得地址
  840. function EchoUrl($text,$exp,$exp1,$dr,$url,$classid,$num,$checkrnd){
  841. global $empire,$fun_r,$dbtbpre;
  842. $e1="[phome-".$exp."]";
  843. $e2="[/phome-".$exp."]";
  844. $ep1="[phome-".$exp1."]";
  845. $ep2="[/phome-".$exp1."]";
  846. $r=explode($e1,$text);
  847. //图片链接
  848. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  849. {
  850. $rp=explode($ep1,$text);
  851. }
  852. else
  853. {
  854. $titlepic=$dr[z_titlepicl];
  855. }
  856. for($i=1;$i<count($r)&&$i<=$num;$i++)
  857. {
  858. $r1=explode($e2,$r[$i]);
  859. $dourl=trim($r1[0]);
  860. //是否有http
  861. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  862. {}
  863. else
  864. {
  865. $dourl=$url.$dourl;
  866. }
  867. //替换地址
  868. $dourl=RepCjUrlStr($dourl);
  869. if(empty($dourl))
  870. {continue;}
  871. $dourl=addslashes($dourl);
  872. //---------------检查数据库是否有记录
  873. if(empty($dr[recjtheurl]))//重复采集
  874. {
  875. $dbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$dr[tbname]." where oldurl='$dourl' limit 1");
  876. if($dbnum)
  877. {continue;}
  878. }
  879. //图片链接
  880. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  881. {
  882. $rp1=explode($ep2,$rp[$i]);
  883. $titlepic=trim($rp1[0]);
  884. //是否有http
  885. if(strstr($titlepic,"http://")||strstr($titlepic,"https://"))
  886. {}
  887. else
  888. {$titlepic=$dr[qz_titlepicl].$titlepic;}
  889. //替换地址
  890. $titlepic=RepCjUrlStr($titlepic);
  891. $titlepic=addslashes($titlepic);
  892. }
  893. //将地址写入数据库
  894. $sql=$empire->query("insert into {$dbtbpre}enewslinktmp(newsurl,checkrnd,titlepic) values('$dourl','$checkrnd','$titlepic');");
  895. echo $dourl."<br>";
  896. }
  897. }
  898. //采集直接内容页地址
  899. function PageEchoUrl($classid,$cr,$userid,$username){
  900. global $empire,$fun_r,$dbtbpre;
  901. //取得条数
  902. if(empty($cr[num]))
  903. {$cr[num]=10000;}
  904. //生成检测值
  905. $checkrnd=md5(uniqid(microtime()).EcmsRandInt());
  906. $url_r=explode("\r\n",$cr[infourl]);
  907. $count=count($url_r);
  908. if($count>$cr[num])
  909. {
  910. $count=$cr[num];
  911. }
  912. for($i=0;$i<$count;$i++)
  913. {
  914. $dourl=trim($url_r[$i]);
  915. if(empty($dourl))
  916. {
  917. continue;
  918. }
  919. //是否有http
  920. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  921. {}
  922. else
  923. {
  924. $dourl=$cr[httpurl].$dourl;
  925. }
  926. //替换地址
  927. $dourl=RepCjUrlStr($dourl);
  928. if(empty($dourl))
  929. {continue;}
  930. $dourl=addslashes($dourl);
  931. //---------------检查数据库是否有记录
  932. if(empty($cr[recjtheurl]))//重复采集
  933. {
  934. $dbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$cr[tbname]." where oldurl='$dourl' limit 1");
  935. if($dbnum)
  936. {continue;}
  937. }
  938. //将地址写入数据库
  939. $sql=$empire->query("insert into {$dbtbpre}enewslinktmp(newsurl,checkrnd,titlepic) values('$dourl','$checkrnd','');");
  940. echo $dourl."<br>";
  941. }
  942. echo $fun_r['GetUrlOver']."<script>self.location.href='ecmscj.php?enews=GetNewsInfo&classid=$classid&start=0&checkrnd=$checkrnd".hReturnEcmsHashStrHref(0)."';</script>";
  943. exit();
  944. }
  945. //开始采集远程地址
  946. function CJUrl($classid,$start,$checkrnd,$userid,$username){
  947. global $empire,$fun_r,$dbtbpre;
  948. $classid=(int)$classid;
  949. if(empty($classid))
  950. {printerror("NotChangeCjid","history.go(-1)");}
  951. //验证权限
  952. CheckLevel($userid,$username,$classid,"cj");
  953. $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'");
  954. if(empty($r[newsclassid]))
  955. {printerror("NotCjid","history.go(-1)");}
  956. //直接内容页链接列表
  957. if($r['infourlispage'])
  958. {
  959. PageEchoUrl($classid,$r,$userid,$username);
  960. }
  961. //导入编码文件
  962. if($r['enpagecode'])
  963. {
  964. @include_once("doiconv.php");
  965. }
  966. //取得条数
  967. if(empty($r[num]))
  968. {$r[num]=10000;}
  969. if(empty($r[relistnum]))
  970. {$r[relistnum]=1;}
  971. if(empty($start))
  972. {
  973. $start=0;
  974. //生成检测值
  975. $checkrnd=md5(uniqid(microtime()).EcmsRandInt());
  976. }
  977. $exp="newsurl";
  978. $exp1="titlepic";
  979. //查看是否过期
  980. $b=0;
  981. $p=0;
  982. $url_r=explode("\r\n",$r[infourl]);
  983. $j=count($url_r);
  984. for($i=$start;$i<$j&&$p<$r[relistnum];$i++)
  985. {
  986. $p++;
  987. $b=1;
  988. $dourl=trim($url_r[$i]);
  989. if(empty($dourl)||!eCheckCjUrl($dourl,1))
  990. {continue;}
  991. //读取页面
  992. for($readnum=0;$readnum<3;$readnum++)
  993. {
  994. $text1=ReadFiletext($dourl);
  995. if(!empty($text1))
  996. {break;}
  997. }
  998. if(empty($text1))
  999. {continue;}
  1000. //替换回车
  1001. $text1=ReplaceFc($text1);
  1002. //替换网页变量
  1003. $text1=RepCjPagetextStr($text1,$r);
  1004. //区域块
  1005. if($r[zz_smallurl])
  1006. {
  1007. $text1=ReturnCJ_str($r[zz_smallurl],"smallurl",$text1);
  1008. if(empty($text1))
  1009. {
  1010. continue;
  1011. }
  1012. }
  1013. //替换内容链接
  1014. $text=stripSlashes(stripSlashes($r[zz_newsurl]));
  1015. //替换回车
  1016. $text=ReplaceFc($text);
  1017. $zztext=RepInfoZZ($text,$exp,0);
  1018. $strtext=GetInfoStr($text,$exp,1);
  1019. if($text)
  1020. {
  1021. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  1022. }
  1023. //替换标题图片地址
  1024. if($r[zz_titlepicl]&&!$r[z_titlepicl])
  1025. {
  1026. $text=stripSlashes(stripSlashes($r[zz_titlepicl]));
  1027. //替换回车
  1028. $text=ReplaceFc($text);
  1029. $zztext=RepInfoZZ($text,$exp1,0);
  1030. $strtext=GetInfoStr($text,$exp1,1);
  1031. if($text)
  1032. {
  1033. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  1034. }
  1035. }
  1036. //链接写入数据库
  1037. EchoUrl($text1,$exp,$exp1,$r,$r[httpurl],$classid,$r[num],$checkrnd);
  1038. }
  1039. $newstart=$i;
  1040. //采集链接完毕
  1041. if(empty($b))
  1042. {
  1043. echo $fun_r['GetUrlOver']."<script>self.location.href='ecmscj.php?enews=GetNewsInfo&classid=$classid&start=0&checkrnd=$checkrnd".hReturnEcmsHashStrHref(0)."';</script>";
  1044. exit();
  1045. }
  1046. //echo $fun_r['GetOneListUrl']."<script>self.location.href='ecmscj.php?enews=CjUrl&classid=$classid&start=$newstart&checkrnd=$checkrnd".hReturnEcmsHashStrHref(0)."';</script>";
  1047. echo"<meta http-equiv=\"refresh\" content=\"".$r['keeptime'].";url=ecmscj.php?enews=CjUrl&classid=$classid&start=$newstart&checkrnd=$checkrnd".hReturnEcmsHashStrHref(0)."\">".$fun_r['GetOneListUrl'];
  1048. exit();
  1049. }
  1050. //###################采集页面列表##################
  1051. function ViewCjList($classid,$userid,$username){
  1052. global $empire,$fun_r,$dbtbpre;
  1053. $classid=(int)$classid;
  1054. if(empty($classid))
  1055. {printerror("NotChangeCjid","history.go(-1)");}
  1056. //验证权限
  1057. CheckLevel($userid,$username,$classid,"cj");
  1058. $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'");
  1059. if(empty($r[newsclassid]))
  1060. {printerror("NotCjid","history.go(-1)");}
  1061. //直接内容页列表
  1062. if($r[infourlispage])
  1063. {
  1064. PageViewCjList($classid,$r,$userid,$username);
  1065. }
  1066. $url_r=explode("\r\n",$r[infourl]);
  1067. $j=count($url_r);
  1068. $ecmshashhref=hReturnEcmsHashStrHref(0);
  1069. for($i=0;$i<$j;$i++)
  1070. {
  1071. if(empty($url_r[$i]))
  1072. {continue;}
  1073. $dourl=urlencode($url_r[$i]);
  1074. $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".$ecmshashhref."&listpage=".$dourl."' target=_blank>".$fun_r['view']."</a>]</td></tr>";
  1075. }
  1076. $data="<p align=center><b>".$fun_r['CjListUrl']."</b></p><table width='96%' border=1 align=center cellpadding=3 cellspacing=0>
  1077. <tr><td width=70% align=center><b>URL</b></td><td align=center><b>VIEW</b></td></tr>".$data."</table>";
  1078. echo $data;
  1079. exit();
  1080. }
  1081. //###################采集内容页面列表##################
  1082. function PageViewCjList($classid,$cr,$userid,$username){
  1083. global $empire,$fun_r,$dbtbpre;
  1084. //取得条数
  1085. if(empty($cr[num]))
  1086. {$cr[num]=10000;}
  1087. $url_r=explode("\r\n",$cr[infourl]);
  1088. $count=count($url_r);
  1089. if($count>$cr[num])
  1090. {
  1091. $count=$cr[num];
  1092. }
  1093. $ecmshashhref=hReturnEcmsHashStrHref(0);
  1094. for($i=0;$i<$count;$i++)
  1095. {
  1096. $dourl=trim($url_r[$i]);
  1097. if(empty($dourl))
  1098. {
  1099. continue;
  1100. }
  1101. //是否有http
  1102. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  1103. {}
  1104. else
  1105. {
  1106. $dourl=$cr[httpurl].$dourl;
  1107. }
  1108. //替换地址
  1109. $dourl=RepCjUrlStr($dourl);
  1110. if(empty($dourl))
  1111. {continue;}
  1112. $dourl=urlencode($dourl);
  1113. $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".$ecmshashhref."&newspage=".$dourl."' target=_blank>".$fun_r['view']."</a>]</td></tr>";
  1114. }
  1115. $data="<p align=center><b>".$fun_r['CjListUrl']."</b></p><table width='96%' border=1 align=center cellpadding=3 cellspacing=0>
  1116. <tr><td width=70% align=center><b>URL</b></td><td align=center><b>VIEW</b></td></tr>".$data."</table>";
  1117. echo $data;
  1118. exit();
  1119. }
  1120. //#################预览采集列表
  1121. function ViewCjUrl($classid,$listpage,$userid,$username){
  1122. global $empire,$fun_r,$dbtbpre;
  1123. $classid=(int)$classid;
  1124. if(empty($classid)||empty($listpage))
  1125. {printerror("NotChangeCjid","history.go(-1)");}
  1126. //验证权限
  1127. CheckLevel($userid,$username,$classid,"cj");
  1128. $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'");
  1129. if(empty($r[newsclassid]))
  1130. {printerror("NotCjid","history.go(-1)");}
  1131. //导入编码文件
  1132. if($r['enpagecode'])
  1133. {
  1134. @include_once("doiconv.php");
  1135. }
  1136. //取得条数
  1137. if(empty($r[num]))
  1138. {$r[num]=10000;}
  1139. $exp="newsurl";
  1140. $exp1="titlepic";
  1141. $dourl=$listpage;
  1142. eCheckCjUrl($dourl,0);
  1143. //读取页面
  1144. for($readnum=0;$readnum<3;$readnum++)
  1145. {
  1146. $text1=ReadFiletext($dourl);
  1147. if(!empty($text1))
  1148. {break;}
  1149. }
  1150. if(empty($text1))
  1151. {
  1152. printerror("FailCjUrl","history.go(-1)");
  1153. }
  1154. //替换回车
  1155. $text1=ReplaceFc($text1);
  1156. //替换网页变量
  1157. $text1=RepCjPagetextStr($text1,$r);
  1158. //区域块
  1159. if($r[zz_smallurl])
  1160. {
  1161. $text1=ReturnCJ_str($r[zz_smallurl],"smallurl",$text1);
  1162. if(empty($text1))
  1163. {
  1164. printerror("EmptyCjSmallUrl","history.go(-1)");
  1165. }
  1166. }
  1167. //替换内容链接
  1168. $text=stripSlashes(stripSlashes($r[zz_newsurl]));
  1169. //替换回车
  1170. $text=ReplaceFc($text);
  1171. $zztext=RepInfoZZ($text,$exp,0);
  1172. $strtext=GetInfoStr($text,$exp,1);
  1173. if($text)
  1174. {
  1175. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  1176. }
  1177. //替换标题图片地址
  1178. if($r[zz_titlepicl]&&!$r[z_titlepicl])
  1179. {
  1180. $text=stripSlashes(stripSlashes($r[zz_titlepicl]));
  1181. //替换回车
  1182. $text=ReplaceFc($text);
  1183. $zztext=RepInfoZZ($text,$exp1,0);
  1184. $strtext=GetInfoStr($text,$exp1,1);
  1185. if($text)
  1186. {
  1187. $text1=stripSlashes(preg_replace($zztext,$strtext,$text1));
  1188. }
  1189. }
  1190. //输出地址
  1191. echo"<p align=center><b>".$fun_r['CjListPageUrl']."</b></p><table width='96%' border=1 align=center cellpadding=3 cellspacing=0>
  1192. <tr><td width=70% align=center><b>URL</b></td><td align=center><b>VIEW</b></td></tr>";
  1193. ViewEchoUrl($text1,$exp,$exp1,$r,$r[httpurl],$classid,$r[num],$checkrnd);
  1194. echo"</table>";
  1195. exit();
  1196. }
  1197. //################输入采集页面
  1198. function ViewEchoUrl($text,$exp,$exp1,$dr,$url,$classid,$num,$checkrnd){
  1199. global $empire,$fun_r,$dbtbpre;
  1200. $e1="[phome-".$exp."]";
  1201. $e2="[/phome-".$exp."]";
  1202. $ep1="[phome-".$exp1."]";
  1203. $ep2="[/phome-".$exp1."]";
  1204. $r=explode($e1,$text);
  1205. //图片链接
  1206. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  1207. {
  1208. $rp=explode($ep1,$text);
  1209. }
  1210. else
  1211. {
  1212. $titlepic=$dr[z_titlepicl];
  1213. }
  1214. $ecmshashhref=hReturnEcmsHashStrHref(0);
  1215. for($i=1;$i<count($r)&&$i<=$num;$i++)
  1216. {
  1217. $r1=explode($e2,$r[$i]);
  1218. $dourl=trim($r1[0]);
  1219. //是否有http
  1220. if(strstr($dourl,"http://")||strstr($dourl,"https://"))
  1221. {}
  1222. else
  1223. {
  1224. $dourl=$url.$dourl;
  1225. }
  1226. //替换地址
  1227. $dourl=RepCjUrlStr($dourl);
  1228. if(empty($dourl))
  1229. {continue;}
  1230. $dourl=addslashes($dourl);
  1231. //检查数据库是否有记录
  1232. if(empty($dr[recjtheurl]))
  1233. {
  1234. $dbnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$dr[tbname]." where oldurl='$dourl' limit 1");
  1235. if($dbnum)
  1236. {continue;}
  1237. }
  1238. //图片链接
  1239. if(!$dr[z_titlepicl]&&$dr[zz_titlepicl])
  1240. {
  1241. $rp1=explode($ep2,$rp[$i]);
  1242. $titlepic=trim($rp1[0]);
  1243. //是否有http
  1244. if(strstr($titlepic,"http://")||strstr($titlepic,"https://"))
  1245. {}
  1246. else
  1247. {$titlepic=$dr[qz_titlepicl].$titlepic;}
  1248. //替换地址
  1249. $titlepic=RepCjUrlStr($titlepic);
  1250. $titlepic=addslashes($titlepic);
  1251. }
  1252. if($titlepic)
  1253. {$a="<br>(PIC:<a href='".$titlepic."' target=_blank>".$titlepic."</a>)";}
  1254. echo "<tr><td><a href='".$dourl."' target=_blank>".$dourl."</a>".$a."</td><td align=center>[<a href='ecmscj.php?enews=ViewGetNewsInfo&classid=$classid".$ecmshashhref."&newspage=".urlencode($dourl)."' target=_blank>".$fun_r['view']."</a>]</td></tr>";
  1255. }
  1256. }
  1257. //#################################
  1258. //取得下载地址
  1259. function GetCjDownpath($text,$text1,$exp,$exp1,$url,$online=0){
  1260. global $empire,$fun_r;
  1261. if($online)
  1262. {
  1263. $fun_r[DownPath]="";
  1264. }
  1265. $e1="[phome-".$exp."]";
  1266. $e2="[/phome-".$exp."]";
  1267. $ep1="[phome-".$exp1."]";
  1268. $ep2="[/phome-".$exp1."]";
  1269. $r=explode($e1,$text);
  1270. //名称
  1271. if($text1)
  1272. {
  1273. $rp=explode($ep1,$text1);
  1274. }
  1275. $p=0;
  1276. for($i=1;$i<count($r);$i++)
  1277. {
  1278. $r1=explode($e2,$r[$i]);
  1279. $dourl=trim($r1[0]);
  1280. if(empty($dourl))
  1281. {continue;}
  1282. if(!strstr($dourl,"://"))
  1283. {
  1284. $dourl=$url.$dourl;
  1285. }
  1286. if($text1)
  1287. {
  1288. $rp1=explode($ep2,$rp[$i]);
  1289. $doname=trim($rp1[0]);
  1290. if(empty($doname))
  1291. {
  1292. $doname=$fun_r[DownPath].($p+1);
  1293. }
  1294. }
  1295. else
  1296. {
  1297. $doname=$fun_r[DownPath].($p+1);
  1298. }
  1299. $downname[$p]=$doname;
  1300. $downpath[$p]=$dourl;
  1301. $p++;
  1302. }
  1303. $down=ReturnDownpath($downname,$downpath,$delpathid,$pathid,$downuser,$fen,$thedownqz,$add,$foruser,$downurl,0);
  1304. return $down;
  1305. }
  1306. //取得图片集地址
  1307. function GetCjMorepicpath($text,$text1,$text2,$exp,$exp1,$exp2,$url){
  1308. global $empire,$public_r;
  1309. $e1="[phome-".$exp."]";
  1310. $e2="[/phome-".$exp."]";
  1311. $ep1="[phome-".$exp1."]";
  1312. $ep2="[/phome-".$exp1."]";
  1313. $epp1="[phome-".$exp2."]";
  1314. $epp2="[/phome-".$exp2."]";
  1315. $r=explode($e1,$text);
  1316. //大图
  1317. if($text1)
  1318. {
  1319. $rp=explode($ep1,$text1);
  1320. }
  1321. //名称
  1322. if($text2)
  1323. {
  1324. $rpp=explode($epp1,$text2);
  1325. }
  1326. $p=0;
  1327. for($i=1;$i<count($r);$i++)
  1328. {
  1329. $r1=explode($e2,$r[$i]);
  1330. $dourl=trim($r1[0]);
  1331. if(empty($dourl))
  1332. {continue;}
  1333. if(!strstr($dourl,"://"))
  1334. {
  1335. $dourl=$url.$dourl;
  1336. }
  1337. //大图
  1338. if($text1)
  1339. {
  1340. $rp1=explode($ep2,$rp[$i]);
  1341. $dobigurl=trim($rp1[0]);
  1342. if(!empty($dobigurl))
  1343. {
  1344. if(!strstr($dobigurl,"://"))
  1345. {
  1346. $dobigurl=$url.$dobigurl;
  1347. }
  1348. }
  1349. }
  1350. else
  1351. {
  1352. $dobigurl="";
  1353. }
  1354. //图片名称
  1355. if($text2)
  1356. {
  1357. $rpp1=explode($epp2,$rpp[$i]);
  1358. $doname=trim($rpp1[0]);
  1359. }
  1360. else
  1361. {
  1362. $doname="";
  1363. }
  1364. $smallpic[$p]=$dourl;
  1365. $bigpic[$p]=$dobigurl;
  1366. $picname[$p]=$doname;
  1367. $p++;
  1368. }
  1369. $down=ReturnMorepicpath($smallpic,$bigpic,$picname,$delpicid,$picid,$add,$downurl,0,0,$public_r['filedeftb']);
  1370. return $down;
  1371. }
  1372. //内容页分页处理-下一页式
  1373. function GetMoreCjPagetext($self,$newstextzz,$smallpagezz,$pagezz,$pagetype,$firsttext,$the_r){
  1374. if(empty($pagezz)||empty($newstextzz))
  1375. {return "";}
  1376. //是否保留分页
  1377. $addpagetag=empty($the_r['doaddtextpage'])?'[!--empirenews.page--]':'';
  1378. //取得地址前缀
  1379. $sr=GetPageurlQz($self);
  1380. $pagetext=$firsttext;
  1381. $allpagetext="";
  1382. for($i=0;$i<100;$i++)
  1383. {
  1384. //区域正则
  1385. if($smallpagezz)
  1386. {
  1387. $pagetext=ReturnCJ_str($smallpagezz,"smallpagezz",$pagetext);
  1388. }
  1389. $nextlink=ReturnCJ_str($pagezz,"pagezz",$pagetext);
  1390. if(empty($nextlink))
  1391. {
  1392. break;
  1393. }
  1394. if(!strstr($nextlink,"://"))
  1395. {
  1396. //根目录开始
  1397. if(strstr($nextlink,"/"))
  1398. {
  1399. $nextlink=$sr[domain].$nextlink;
  1400. }
  1401. else
  1402. {
  1403. $nextlink=$sr[selfqz].$nextlink;
  1404. }
  1405. }
  1406. $nextlink=RepCjUrlStr($nextlink);
  1407. if($nextlink==$self||!eCheckCjUrl($nextlink,1))
  1408. {continue;}
  1409. //取得远程数据
  1410. for($j=0;$j<3;$j++)
  1411. {
  1412. $pagetext=ReadFiletext($nextlink);
  1413. if($pagetext)
  1414. {
  1415. break;
  1416. }
  1417. }
  1418. //页面不存在
  1419. if(empty($pagetext))
  1420. {
  1421. break;
  1422. }
  1423. //替换网页变量
  1424. $pagetext=RepCjPagetextStr($pagetext,$the_r);
  1425. //替换回车
  1426. $pagetext=ReplaceFc($pagetext);
  1427. $newstext=ReturnCJ_str($newstextzz,"newstext",$pagetext);
  1428. if($newstext)
  1429. {
  1430. $allpagetext.=$addpagetag.$newstext;
  1431. }
  1432. }
  1433. return $allpagetext;
  1434. }
  1435. //内容页分页处理-全部列表式
  1436. function GetMoreCjPagetextall($self,$newstextzz,$smallpagezz,$pagezz,$pagetype,$firsttext,$the_r){
  1437. if(empty($pagezz)||empty($newstextzz))
  1438. {return "";}
  1439. //是否保留分页
  1440. $addpagetag=empty($the_r['doaddtextpage'])?'[!--empirenews.page--]':'';
  1441. $exp="pageallzz";
  1442. //取得地址前缀
  1443. $sr=GetPageurlQz($self);
  1444. $pagetext=$firsttext;
  1445. $allpagetext="";
  1446. //区域正则
  1447. if($smallpagezz)
  1448. {
  1449. $pagetext=ReturnCJ_str($smallpagezz,"smallpageallzz",$pagetext);
  1450. }
  1451. //分页
  1452. $text=stripSlashes(stripSlashes($pagezz));
  1453. //替换回车
  1454. $text=ReplaceFc($text);
  1455. $zztext=RepInfoZZ($text,$exp,0);
  1456. $strtext=GetInfoStr($text,$exp,1);
  1457. $pagetext=stripSlashes(preg_replace($zztext,$strtext,$pagetext));
  1458. $e1="[phome-".$exp."]";
  1459. $e2="[/phome-".$exp."]";
  1460. $r=explode($e1,$pagetext);
  1461. $count=count($r);
  1462. for($i=1;$i<$count;$i++)
  1463. {
  1464. $r1=explode($e2,$r[$i]);
  1465. $nextlink=trim($r1[0]);
  1466. if(empty($nextlink))
  1467. {continue;}
  1468. if(!strstr($nextlink,"://"))
  1469. {
  1470. //根目录开始
  1471. if(strstr($nextlink,"/"))
  1472. {
  1473. $nextlink=$sr[domain].$nextlink;
  1474. }
  1475. else
  1476. {
  1477. $nextlink=$sr[selfqz].$nextlink;
  1478. }
  1479. }
  1480. $nextlink=RepCjUrlStr($nextlink);
  1481. if($nextlink==$self||!eCheckCjUrl($nextlink,1))
  1482. {continue;}
  1483. //取得远程数据
  1484. for($j=0;$j<3;$j++)
  1485. {
  1486. $pagetext=ReadFiletext($nextlink);
  1487. if($pagetext)
  1488. {
  1489. break;
  1490. }
  1491. }
  1492. //页面不存在
  1493. if(empty($pagetext))
  1494. {
  1495. continue;
  1496. }
  1497. //替换网页变量
  1498. $pagetext=RepCjPagetextStr($pagetext,$the_r);
  1499. //替换回车
  1500. $pagetext=ReplaceFc($pagetext);
  1501. $newstext=ReturnCJ_str($newstextzz,"newstext",$pagetext);
  1502. if($newstext)
  1503. {
  1504. $allpagetext.=$addpagetag.$newstext;
  1505. }
  1506. }
  1507. return $allpagetext;
  1508. }
  1509. //采集时间格式转换
  1510. function CjFormatNewstime($newstime){
  1511. $newstime=str_replace(array('年','月','日','.','时','分','秒','/'),array('-','-','','-',':',':','','-'),$newstime);
  1512. return $newstime;
  1513. }
  1514. //采集信息文件
  1515. function GetNewsInfo($classid,$checkrnd,$start,$userid,$username){
  1516. global $empire,$class_r,$fun_r,$dbtbpre;
  1517. $userid=(int)$userid;
  1518. $classid=(int)$classid;
  1519. $start=(int)$start;
  1520. $checkrnd=RepPostVar($checkrnd);
  1521. if(empty($classid)||empty($checkrnd))
  1522. {printerror("FailCX","ListInfoClass.php".hReturnEcmsHashStrHref2(1));}
  1523. //验证权限
  1524. CheckLevel($userid,$username,$classid,"cj");
  1525. $r=$empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='$classid'");
  1526. //副表
  1527. $ra=$empire->fetch1("select * from {$dbtbpre}ecms_infoclass_".$r[tbname]." where classid='$classid'");
  1528. //组合两数组
  1529. $r=TogTwoArray($r,$ra);
  1530. //导入编码文件
  1531. if($r['enpagecode'])
  1532. {
  1533. @include_once(ECMS_PATH."e/class/doiconv.php");
  1534. }
  1535. //取得模型
  1536. $record="<!--record-->";
  1537. $field="<!--field--->";
  1538. $mr=$empire->fetch1("select cj,tid,tbname from {$dbtbpre}enewsmod where mid='".$class_r[$r[newsclassid]][modid]."'");
  1539. $cjr=explode($record,$mr[cj]);
  1540. $count=count($cjr);
  1541. if(empty($start))
  1542. {$start=0;}
  1543. $b=0;
  1544. $sql=$empire->query("select linkid,newsurl,titlepic from {$dbtbpre}enewslinktmp where checkrnd='$checkrnd' and linkid>".$start." order by linkid limit ".$r[renum]);
  1545. //采集时间
  1546. $newstime=date("Y-m-d H:i:s");
  1547. $truetime=time();
  1548. $tmptime=$newstime;
  1549. while($nr=$empire->fetch($sql))
  1550. {
  1551. $b=1;
  1552. $newstart=$nr[linkid];
  1553. if(!eCheckCjUrl($nr[newsurl],1))
  1554. {
  1555. continue;
  1556. }
  1557. //入库数据库是否有记录
  1558. if(empty($r[recjtheurl]))
  1559. {
  1560. $tmpnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$r[tbname]." where oldurl='$nr[newsurl]' limit 1");
  1561. if($tmpnum)
  1562. {continue;}
  1563. }
  1564. //取得远程页面,三次取不到值的将不取值
  1565. for($i=1;$i<=3;$i++)
  1566. {
  1567. $info=ReadFiletext($nr[newsurl]);
  1568. if(!empty($info))
  1569. {
  1570. break;
  1571. }
  1572. }
  1573. if(empty($info))
  1574. {continue;}
  1575. //替换网页变量
  1576. $info=RepCjPagetextStr($info,$r);
  1577. //替换回车
  1578. $info=ReplaceFc($info);
  1579. //-----------------
  1580. $ifield="";
  1581. $ivalue="";
  1582. $next=0;
  1583. for($c=0;$c<$count-1;$c++)
  1584. {
  1585. $zzvalue="";
  1586. $cjr1=explode($field,$cjr[$c]);
  1587. $dofield=$cjr1[1];
  1588. $var="zz_".$dofield;
  1589. $var1="z_".$dofield;
  1590. $var2="qz_".$dofield;
  1591. $var3="save_".$dofield;
  1592. //标题图片
  1593. if($dofield=="titlepic")
  1594. {
  1595. if($nr[titlepic])
  1596. {
  1597. $zzvalue=$nr[titlepic];
  1598. $ifield.=",".$dofield;
  1599. $ivalue.=",'".addslashes($zzvalue)."'";
  1600. continue;
  1601. }
  1602. }
  1603. //图片集
  1604. if($dofield=="morepic"&&$r[$var])
  1605. {
  1606. //替换下载链接
  1607. $text=$r[$var];
  1608. //替换回车
  1609. $text=ReplaceFc($text);
  1610. $down=explode("[!empirecms!]",$text);
  1611. //小图
  1612. $zztext=RepInfoZZ($down[0],"ecmsspicurl",0);
  1613. $strtext=GetInfoStr($down[0],"ecmsspicurl",1);
  1614. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1615. //大图
  1616. if($down[1])
  1617. {
  1618. $zztext=RepInfoZZ($down[1],"ecmsbpicurl",0);
  1619. $strtext=GetInfoStr($down[1],"ecmsbpicurl",1);
  1620. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1621. }
  1622. //名称
  1623. if($down[2])
  1624. {
  1625. $zztext=RepInfoZZ($down[2],"ecmspicname",0);
  1626. $strtext=GetInfoStr($down[2],"ecmspicname",1);
  1627. $text3=stripSlashes(preg_replace($zztext,$strtext,$info));
  1628. }
  1629. $zzvalue=GetCjMorepicpath($text1,$text2,$text3,"ecmsspicurl","ecmsbpicurl","ecmspicname",$r[$var2]);
  1630. $ifield.=",".$dofield;
  1631. $ivalue.=",'".addslashes($zzvalue)."'";
  1632. continue;
  1633. }
  1634. //下载地址
  1635. if($dofield=="downpath"&&$r[$var])
  1636. {
  1637. //替换下载链接
  1638. $text=$r[$var];
  1639. //替换回车
  1640. $text=ReplaceFc($text);
  1641. $down=explode("[!empirecms!]",$text);
  1642. //地址
  1643. $zztext=RepInfoZZ($down[0],"ecmsdownpathurl",0);
  1644. $strtext=GetInfoStr($down[0],"ecmsdownpathurl",1);
  1645. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1646. //名称
  1647. if($down[1])
  1648. {
  1649. $zztext=RepInfoZZ($down[1],"ecmsdownpathname",0);
  1650. $strtext=GetInfoStr($down[1],"ecmsdownpathname",1);
  1651. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1652. }
  1653. $zzvalue=GetCjDownpath($text1,$text2,"ecmsdownpathurl","ecmsdownpathname",$r[$var2],0);
  1654. $ifield.=",".$dofield;
  1655. $ivalue.=",'".addslashes($zzvalue)."'";
  1656. continue;
  1657. }
  1658. //在线地址
  1659. if($dofield=="onlinepath"&&$r[$var])
  1660. {
  1661. //替换下载链接
  1662. $text=$r[$var];
  1663. //替换回车
  1664. $text=ReplaceFc($text);
  1665. $down=explode("[!empirecms!]",$text);
  1666. //地址
  1667. $zztext=RepInfoZZ($down[0],"ecmsonlinepathurl",0);
  1668. $strtext=GetInfoStr($down[0],"ecmsonlinepathurl",1);
  1669. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1670. //名称
  1671. if($down[1])
  1672. {
  1673. $zztext=RepInfoZZ($down[1],"ecmsonlinepathname",0);
  1674. $strtext=GetInfoStr($down[1],"ecmsonlinepathname",1);
  1675. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1676. }
  1677. $zzvalue=GetCjDownpath($text1,$text2,"ecmsonlinepathurl","ecmsonlinepathname",$r[$var2],1);
  1678. $ifield.=",".$dofield;
  1679. $ivalue.=",'".addslashes($zzvalue)."'";
  1680. continue;
  1681. }
  1682. if(empty($r[$var1]))
  1683. {
  1684. if($r[$var])
  1685. {
  1686. $zzvalue=ReturnCJ_str($r[$var],$dofield,$info);
  1687. if($zzvalue)
  1688. {
  1689. $zzvalue=$r[$var2].$zzvalue;
  1690. }
  1691. }
  1692. }
  1693. else
  1694. {$zzvalue=$r[$var1];}
  1695. //------------------------------信息时间
  1696. if($dofield=="newstime")
  1697. {
  1698. $newstime=$zzvalue;
  1699. if(empty($newstime))
  1700. {
  1701. $newstime=$tmptime;
  1702. }
  1703. else
  1704. {
  1705. $newstime=CjFormatNewstime($newstime);//时间转换
  1706. }
  1707. continue;
  1708. }
  1709. //------------------------------信息来源
  1710. if($dofield=="befrom"||$dofield=="writer")
  1711. {
  1712. //标题去除html代码
  1713. $zzvalue=strip_tags(str_replace("\r\n","",$zzvalue));
  1714. }
  1715. //------------------------------标题
  1716. if($dofield=="title")
  1717. {
  1718. //标题去除html代码
  1719. $zzvalue=ehtmlspecialchars(strip_tags(str_replace("\r\n","",$zzvalue)));
  1720. if(empty($zzvalue))
  1721. {
  1722. $next=1;
  1723. break;
  1724. }
  1725. $keyboard=sub($zzvalue,0,$r[keynum],false);
  1726. //标题是否包含关键字
  1727. if($r[keyboard])
  1728. {
  1729. $t=HaveKeyboard($zzvalue,$r[keyboard]);
  1730. if(empty($t))
  1731. {
  1732. $next=1;
  1733. break;
  1734. }
  1735. }
  1736. if($r[retitlewriter])//标题完全一样
  1737. {
  1738. //入库比较
  1739. $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");
  1740. if($onum)
  1741. {
  1742. $next=1;
  1743. break;
  1744. }
  1745. /*采集库比较
  1746. $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title='".addslashes($zzvalue)."' limit 1");
  1747. if($onum)
  1748. {
  1749. $next=1;
  1750. break;
  1751. }
  1752. */
  1753. }
  1754. if($r[titlelen])//标题相似
  1755. {
  1756. //入库比较
  1757. $c_title=addslashes(sub($zzvalue,0,$r[titlelen],false));
  1758. $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");
  1759. if($onum)
  1760. {
  1761. $next=1;
  1762. break;
  1763. }
  1764. /*采集比较
  1765. $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title like '%$c_title%' limit 1");
  1766. if($onum)
  1767. {
  1768. $next=1;
  1769. break;
  1770. }
  1771. */
  1772. }
  1773. }
  1774. //新闻内容分页
  1775. if($dofield=="newstext")
  1776. {
  1777. //是否有分页
  1778. if($r[pagezz]||$r[pageallzz])
  1779. {
  1780. //上下页式
  1781. if(empty($r[pagetype]))
  1782. {
  1783. $zzvalue.=GetMoreCjPagetext($nr[newsurl],$r[$var],$r[smallpagezz],$r[pagezz],$r[pagetype],$info,$r);
  1784. }
  1785. //全部列表式
  1786. else
  1787. {
  1788. $zzvalue.=GetMoreCjPagetextall($nr[newsurl],$r[$var],$r[smallpageallzz],$r[pageallzz],$r[pagetype],$info,$r);
  1789. }
  1790. }
  1791. }
  1792. //替换关键字
  1793. if(stristr($r['repf'],','.$dofield.','))
  1794. {
  1795. $zzvalue=RepInfoWord($zzvalue,$r[oldword],$r[newword]);
  1796. }
  1797. //广告过滤
  1798. if(stristr($r['repadf'],','.$dofield.','))
  1799. {
  1800. $zzvalue=RepAd($r[repad],$zzvalue);
  1801. }
  1802. //新闻内容
  1803. if(stristr($r['isnullf'],','.$dofield.','))
  1804. {
  1805. $ckzzvalue=trim($zzvalue);
  1806. if($r['newstextisnull']==1&&empty($ckzzvalue))
  1807. {
  1808. $next=1;
  1809. break;
  1810. }
  1811. }
  1812. $ifield.=",".$dofield;
  1813. $ivalue.=",'".addslashes($zzvalue)."'";
  1814. }
  1815. if($next)
  1816. {continue;}
  1817. //入临时库
  1818. $isql=$empire->query("insert into {$dbtbpre}ecms_infotmp_".$r[tbname]."(classid,oldurl,checked,keyboard,newstime,truetime,tmptime,userid,username".$ifield.") values($classid,'$nr[newsurl]',0,'".addslashes($keyboard)."','$newstime',$truetime,'$tmptime',$userid,'".addslashes($username)."'".$ivalue.");");
  1819. }
  1820. //采集结束
  1821. if(empty($b))
  1822. {
  1823. //删除记录
  1824. $del=$empire->query("delete from {$dbtbpre}enewslinktmp where checkrnd='$checkrnd'");
  1825. //更新最后时间
  1826. $ucjsql=$empire->query("update {$dbtbpre}enewsinfoclass set lasttime='".time()."' where classid='$classid'");
  1827. //自动入库
  1828. if($r['justloadin'])
  1829. {
  1830. echo $fun_r['cjLoadInInfos']."<script>self.location.href='ecmscj.php?enews=CjNewsIn_all&classid=$classid&checked=$r[justloadcheck]&fm=1".hReturnEcmsHashStrHref(0)."';</script>";
  1831. exit();
  1832. }
  1833. //单个节点
  1834. if(getcvar('recjnum',1)==1)
  1835. {
  1836. echo"<link rel=\"stylesheet\" href=\"../data/images/css.css\" type=\"text/css\"><font color=red>".$fun_r['CjSuccess']."</font><script>parent.location.href='CheckCj.php?classid=$classid".hReturnEcmsHashStrHref2(0)."';</script>";
  1837. }
  1838. else
  1839. {
  1840. echo"<link rel=\"stylesheet\" href=\"../data/images/css.css\" type=\"text/css\"><body topmargin=0><font color=red>".$r[classname]." ".$fun_r['CjSuccess']."</font>, <input type=button name=button value='".$fun_r['OnlickLoadInCj']."' onclick=\"window.open('CheckCj.php?classid=$classid".hReturnEcmsHashStrHref2(0)."');\">";
  1841. echo"<script>parent.checkrecj.location.href='CheckReCj.php".hReturnEcmsHashStrHref2(1)."';</script></body>";
  1842. }
  1843. exit();
  1844. }
  1845. //echo"(ID:<font color=red><b>".$newstart."</b></font>)<script>self.location.href='ecmscj.php?enews=GetNewsInfo&checkrnd=$checkrnd&classid=$classid&start=$newstart".hReturnEcmsHashStrHref(0)."';</script>";
  1846. echo"<meta http-equiv=\"refresh\" content=\"".$r['keeptime'].";url=ecmscj.php?enews=GetNewsInfo&checkrnd=$checkrnd&classid=$classid&start=$newstart".hReturnEcmsHashStrHref(0)."\">".$r[classname]." (ID:<font color=red><b>".$newstart."</b></font>)";
  1847. exit();
  1848. }
  1849. //#################单个采集文件预览################
  1850. function ViewGetNewsInfo($classid,$newspage,$userid,$username){
  1851. global $empire,$class_r,$fun_r,$dbtbpre;
  1852. $classid=(int)$classid;
  1853. if(empty($classid)||empty($newspage))
  1854. {printerror("FailCX","history.go(-1)");}
  1855. //验证权限
  1856. CheckLevel($userid,$username,$classid,"cj");
  1857. $r=$empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='$classid'");
  1858. if(empty($r[classid]))
  1859. {printerror("FailCX","history.go(-1)");}
  1860. //副表
  1861. $ra=$empire->fetch1("select * from {$dbtbpre}ecms_infoclass_".$r[tbname]." where classid='$classid'");
  1862. //组合两数组
  1863. $r=TogTwoArray($r,$ra);
  1864. //导入编码文件
  1865. if($r['enpagecode'])
  1866. {
  1867. @include_once("doiconv.php");
  1868. }
  1869. //取得模型
  1870. $record="<!--record-->";
  1871. $field="<!--field--->";
  1872. $mr=$empire->fetch1("select cj from {$dbtbpre}enewsmod where mid='".$class_r[$r[newsclassid]][modid]."'");
  1873. $cjr=explode($record,$mr[cj]);
  1874. $count=count($cjr);
  1875. //采集时间
  1876. $newstime=date("Y-m-d H:i:s");
  1877. eCheckCjUrl($newspage,0);
  1878. //入库数据库是否有记录
  1879. if(empty($r[recjtheurl]))
  1880. {
  1881. $tmpnum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_infotmp_".$r[tbname]." where oldurl='$newspage' limit 1");
  1882. if($tmpnum)
  1883. {
  1884. echo $fun_r['ReCj'];
  1885. exit();
  1886. }
  1887. }
  1888. //取得远程页面,三次取不到值的将不取值
  1889. for($i=1;$i<=3;$i++)
  1890. {
  1891. $info=ReadFiletext($newspage);
  1892. if(!empty($info))
  1893. {
  1894. break;
  1895. }
  1896. }
  1897. if(empty($info))
  1898. {
  1899. echo $fun_r['CanNotOpenUrl'];
  1900. exit();
  1901. }
  1902. //替换网页变量
  1903. $info=RepCjPagetextStr($info,$r);
  1904. //替换回车
  1905. $info=ReplaceFc($info);
  1906. //-----------------
  1907. $ifield="";
  1908. $ivalue="";
  1909. $next=0;
  1910. for($c=0;$c<$count-1;$c++)
  1911. {
  1912. $zzvalue="";
  1913. $cjr1=explode($field,$cjr[$c]);
  1914. $dofield=$cjr1[1];
  1915. $dofieldname=$cjr1[0];
  1916. $var="zz_".$dofield;
  1917. $var1="z_".$dofield;
  1918. $var2="qz_".$dofield;
  1919. $var3="save_".$dofield;
  1920. //图片集
  1921. if($dofield=="morepic"&&$r[$var])
  1922. {
  1923. //替换下载链接
  1924. $text=stripSlashes(stripSlashes($r[$var]));
  1925. //替换回车
  1926. $text=ReplaceFc($text);
  1927. $down=explode("[!empirecms!]",$text);
  1928. //小图
  1929. $zztext=RepInfoZZ($down[0],"ecmsspicurl",0);
  1930. $strtext=GetInfoStr($down[0],"ecmsspicurl",1);
  1931. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1932. //大图
  1933. if($down[1])
  1934. {
  1935. $zztext=RepInfoZZ($down[1],"ecmsbpicurl",0);
  1936. $strtext=GetInfoStr($down[1],"ecmsbpicurl",1);
  1937. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1938. }
  1939. //名称
  1940. if($down[2])
  1941. {
  1942. $zztext=RepInfoZZ($down[2],"ecmspicname",0);
  1943. $strtext=GetInfoStr($down[2],"ecmspicname",1);
  1944. $text3=stripSlashes(preg_replace($zztext,$strtext,$info));
  1945. }
  1946. $zzvalue=GetCjMorepicpath($text1,$text2,$text3,"ecmsspicurl","ecmsbpicurl","ecmspicname",$r[$var2]);
  1947. $data.="<tr><td><b>".$dofieldname."<br>(".$dofield.")</b></td><td>".$zzvalue."</td></tr>";
  1948. continue;
  1949. }
  1950. //下载地址
  1951. if($dofield=="downpath"&&$r[$var])
  1952. {
  1953. //替换下载链接
  1954. $text=stripSlashes(stripSlashes($r[$var]));
  1955. //替换回车
  1956. $text=ReplaceFc($text);
  1957. $down=explode("[!empirecms!]",$text);
  1958. //地址
  1959. $zztext=RepInfoZZ($down[0],"ecmsdownpathurl",0);
  1960. $strtext=GetInfoStr($down[0],"ecmsdownpathurl",1);
  1961. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1962. //名称
  1963. if($down[1])
  1964. {
  1965. $zztext=RepInfoZZ($down[1],"ecmsdownpathname",0);
  1966. $strtext=GetInfoStr($down[1],"ecmsdownpathname",1);
  1967. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1968. }
  1969. $zzvalue=GetCjDownpath($text1,$text2,"ecmsdownpathurl","ecmsdownpathname",$r[$var2],0);
  1970. $data.="<tr><td><b>".$dofieldname."<br>(".$dofield.")</b></td><td>".$zzvalue."</td></tr>";
  1971. continue;
  1972. }
  1973. //在线地址
  1974. if($dofield=="onlinepath"&&$r[$var])
  1975. {
  1976. //替换下载链接
  1977. $text=stripSlashes(stripSlashes($r[$var]));
  1978. //替换回车
  1979. $text=ReplaceFc($text);
  1980. $down=explode("[!empirecms!]",$text);
  1981. //地址
  1982. $zztext=RepInfoZZ($down[0],"ecmsonlinepathurl",0);
  1983. $strtext=GetInfoStr($down[0],"ecmsonlinepathurl",1);
  1984. $text1=stripSlashes(preg_replace($zztext,$strtext,$info));
  1985. //名称
  1986. if($down[1])
  1987. {
  1988. $zztext=RepInfoZZ($down[1],"ecmsonlinepathname",0);
  1989. $strtext=GetInfoStr($down[1],"ecmsonlinepathname",1);
  1990. $text2=stripSlashes(preg_replace($zztext,$strtext,$info));
  1991. }
  1992. $zzvalue=GetCjDownpath($text1,$text2,"ecmsonlinepathurl","ecmsonlinepathname",$r[$var2],1);
  1993. $data.="<tr><td><b>".$dofieldname."<br>(".$dofield.")</b></td><td>".$zzvalue."</td></tr>";
  1994. continue;
  1995. }
  1996. if(empty($r[$var1]))
  1997. {
  1998. if($r[$var])
  1999. {
  2000. $zzvalue=ReturnCJ_str($r[$var],$dofield,$info);
  2001. if($zzvalue)
  2002. {
  2003. $zzvalue=$r[$var2].$zzvalue;
  2004. }
  2005. }
  2006. }
  2007. else
  2008. {$zzvalue=$r[$var1];}
  2009. //------------------------------信息来源
  2010. if($dofield=="befrom"||$dofield=="writer")
  2011. {
  2012. //标题去除html代码
  2013. $zzvalue=strip_tags(str_replace("\r\n","",$zzvalue));
  2014. }
  2015. //------------------------------标题
  2016. if($dofield=="title")
  2017. {
  2018. //标题去除html代码
  2019. $zzvalue=ehtmlspecialchars(strip_tags(str_replace("\r\n","",$zzvalue)));
  2020. if(empty($zzvalue))
  2021. {
  2022. echo $fun_r['CjEmptyTitle'];
  2023. exit();
  2024. }
  2025. //标题是否包含关键字
  2026. if($r[keyboard])
  2027. {
  2028. $t=HaveKeyboard($zzvalue,$r[keyboard]);
  2029. if(empty($t))
  2030. {
  2031. echo $fun_r['CjTitleKey'];
  2032. exit();
  2033. }
  2034. }
  2035. if($r[retitlewriter])//标题完全一样
  2036. {
  2037. //入库比较
  2038. $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");
  2039. if($onum)
  2040. {
  2041. echo $fun_r['CjReTitleWriter'];
  2042. exit();
  2043. }
  2044. /*采集库比较
  2045. $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title='".addslashes($zzvalue)."' limit 1");
  2046. if($onum)
  2047. {
  2048. echo $fun_r['CjReTitleWriter'];
  2049. exit();
  2050. }
  2051. */
  2052. }
  2053. if($r[titlelen])//标题相似
  2054. {
  2055. //入库比较
  2056. $c_title=addslashes(sub($zzvalue,0,$r[titlelen],false));
  2057. $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");
  2058. if($onum)
  2059. {
  2060. echo $fun_r['CjSingTitlelen'].$r[titlelen].$fun_r['CjSingTitlelenL'];
  2061. exit();
  2062. }
  2063. /*采集比较
  2064. $onum=$empire->num("select id from {$dbtbpre}ecms_infotmp_".$r[tbname]." where title like '%$c_title%' limit 1");
  2065. if($onum)
  2066. {
  2067. echo $fun_r['CjSingTitlelen'].$r[titlelen].$fun_r['CjSingTitlelenL'];
  2068. exit();
  2069. }
  2070. */
  2071. }
  2072. }
  2073. //新闻内容分页
  2074. if($dofield=="newstext")
  2075. {
  2076. //是否有分页
  2077. if($r[pagezz]||$r[pageallzz])
  2078. {
  2079. //上下页式
  2080. if(empty($r[pagetype]))
  2081. {
  2082. $zzvalue.=GetMoreCjPagetext($newspage,$r[$var],$r[smallpagezz],$r[pagezz],$r[pagetype],$info,$r);
  2083. }
  2084. //全部列表式
  2085. else
  2086. {
  2087. $zzvalue.=GetMoreCjPagetextall($newspage,$r[$var],$r[smallpageallzz],$r[pageallzz],$r[pagetype],$info,$r);
  2088. }
  2089. }
  2090. }
  2091. //替换关键字
  2092. if(stristr($r['repf'],','.$dofield.','))
  2093. {
  2094. $zzvalue=RepInfoWord($zzvalue,$r[oldword],$r[newword]);
  2095. }
  2096. //替换广告
  2097. if(stristr($r['repadf'],','.$dofield.','))
  2098. {
  2099. $zzvalue=RepAd($r[repad],$zzvalue);
  2100. }
  2101. //新闻内容
  2102. if(stristr($r['isnullf'],','.$dofield.','))
  2103. {
  2104. $ckzzvalue=trim($zzvalue);
  2105. if($r['newstextisnull']==1&&empty($ckzzvalue))
  2106. {
  2107. echo $dofield.$fun_r['CjEmptyNewstext'];
  2108. exit();
  2109. }
  2110. }
  2111. $data.="<tr><td><b>".$dofieldname."<br>(".$dofield.")</b></td><td>".$zzvalue."</td></tr>";
  2112. }
  2113. //输出数据
  2114. $data="<table width='96%' border=1 align=center cellpadding=3 cellspacing=0>
  2115. <tr><td width=30% align=center><b>VAR</b></td><td align=center><b>GET</b></td></tr><tr><td><b>".$fun_r['ViewCjPage']."</b></td><td><a href='".$newspage."' target=_blank>".$newspage."</a></td></tr>".$data."</table>";
  2116. echo $data;
  2117. exit();
  2118. }
  2119. //是否有关键字
  2120. function HaveKeyboard($title,$keyboard) {
  2121. $r=explode(",",$keyboard);
  2122. $b=0;
  2123. for($i=0;$i<count($r);$i++)
  2124. {
  2125. $cr=explode($r[$i],$title);
  2126. if(count($cr)<>1)
  2127. {
  2128. $b=1;
  2129. break;
  2130. }
  2131. }
  2132. return $b;
  2133. }
  2134. //替换关键字
  2135. function RepInfoWord($title,$oldword,$newword){
  2136. if(empty($oldword))
  2137. {
  2138. return $title;
  2139. }
  2140. $oldword=stripSlashes($oldword);
  2141. $newword=stripSlashes($newword);
  2142. //替换回车
  2143. $oldword=ReplaceFc($oldword);
  2144. $newword=ReplaceFc($newword);
  2145. $repmore=0;
  2146. if(strstr($newword,","))
  2147. {
  2148. $repmore=1;
  2149. $nr=explode(",",$newword);
  2150. }
  2151. $r=explode(",",$oldword);
  2152. for($i=0;$i<count($r);$i++)
  2153. {
  2154. //替换多项
  2155. if($repmore)
  2156. {
  2157. $title=str_replace($r[$i],$nr[$i],$title);
  2158. }
  2159. else
  2160. {
  2161. $title=str_replace($r[$i],$newword,$title);
  2162. }
  2163. }
  2164. return $title;
  2165. }
  2166. //导出采集规则
  2167. function LoadOutCj($classid,$userid,$username){
  2168. global $empire,$dbtbpre;
  2169. $lineexp='<!-#-|-line-|-#-!>';
  2170. $recordexp='<!-#-|-record-|-#-!>';
  2171. $fieldexp='<!-#-|-field-|-#-!>';
  2172. $sfieldexp='<!-#-|-smallfield-|-#-!>';
  2173. CheckLevel($userid,$username,$classid,"loadcj");//验证权限
  2174. $classid=(int)$classid;
  2175. if(!$classid)
  2176. {
  2177. printerror('LoadOutCjEmptyClassid','');
  2178. }
  2179. $cr=$empire->fetch1("select * from {$dbtbpre}enewsinfoclass where classid='$classid'");
  2180. if(!$cr['classid'])
  2181. {
  2182. printerror('LoadOutCjEmptyClassid','');
  2183. }
  2184. if(!$cr['newsclassid'])//非采集节点
  2185. {
  2186. printerror('LoadOutCjMustNewsclassid','');
  2187. }
  2188. //主表
  2189. $mainfield=LoadOutCjMainField();
  2190. $mainstr=LoadOutCjMainstr($cr,$mainfield,$fieldexp,$sfieldexp);
  2191. //副表
  2192. $infocr=$empire->fetch1("select * from {$dbtbpre}ecms_infoclass_".$cr[tbname]." where classid='$classid'");
  2193. $datafield=LoadOutCjDataField($cr['tid'],$cr['tbname']);
  2194. $datastr=LoadOutCjDatastr($infocr,$datafield,$fieldexp,$sfieldexp);
  2195. @include('../class/EmpireCMS_version.php');
  2196. $cjstr=EmpireCMS_VERSION.$recordexp.$mainstr.$recordexp.$datafield.$recordexp.$datastr;
  2197. $file=$cr['tbname'].time().".cj";
  2198. $filepath=ECMS_PATH."e/data/tmp/cj/".$file;
  2199. WriteFiletext_n($filepath,$cjstr);
  2200. DownLoadFile($file,$filepath,1);
  2201. //操作日志
  2202. insert_dolog("classid=$classid&classname=$cr[classname]");
  2203. exit();
  2204. }
  2205. //返回主表字段列表
  2206. function LoadOutCjMainField(){
  2207. $field='classname,infourl,bz,num,copyimg,renum,keyboard,oldword,newword,titlelen,retitlewriter,smalltextlen,zz_smallurl,zz_newsurl,httpurl,repad,imgurl,relistnum,zz_titlepicl,z_titlepicl,qz_titlepicl,save_titlepicl,keynum,insertnum,copyflash,pagetype,smallpagezz,pagezz,smallpageallzz,pageallzz,mark,enpagecode,recjtheurl,hiddenload,justloadin,justloadcheck,delloadinfo,pagerepad,getfirstpic,oldpagerep,newpagerep,keeptime,newstextisnull,getfirstspic,getfirstspicw,getfirstspich,doaddtextpage,infourlispage,repf,repadf,loadkeeptime,isnullf';
  2208. return $field;
  2209. }
  2210. //返回主表组合
  2211. function LoadOutCjMainstr($r,$field,$fieldexp,$sfieldexp){
  2212. $mainstr='';
  2213. $addexp='';
  2214. $fr=explode(',',$field);
  2215. $fcount=count($fr);
  2216. for($i=0;$i<$fcount;$i++)
  2217. {
  2218. $f=$fr[$i];
  2219. $mainstr.=$addexp.$r[$f];
  2220. $addexp=$fieldexp;
  2221. }
  2222. return $mainstr;
  2223. }
  2224. //返回副表字段列表
  2225. function LoadOutCjDataField($tid,$tbname){
  2226. global $empire,$dbtbpre;
  2227. $field='';
  2228. $dh='';
  2229. $fsql=$empire->query("select f from {$dbtbpre}enewsf where tid='$tid' and iscj=1");
  2230. while($fr=$empire->fetch($fsql))
  2231. {
  2232. $field.=$dh.$fr['f'];
  2233. $dh=',';
  2234. }
  2235. return $field;
  2236. }
  2237. //返回副表组合
  2238. function LoadOutCjDatastr($r,$field,$fieldexp,$sfieldexp){
  2239. if(empty($field))
  2240. {
  2241. return '';
  2242. }
  2243. $datastr='';
  2244. $addexp='';
  2245. $fr=explode(',',$field);
  2246. $fcount=count($fr);
  2247. for($i=0;$i<$fcount;$i++)
  2248. {
  2249. $f=$fr[$i];
  2250. $zzf='zz_'.$f;
  2251. $zf='z_'.$f;
  2252. $qzf='qz_'.$f;
  2253. $savef='save_'.$f;
  2254. $datastr.=$addexp.$r[$zzf].$sfieldexp.$r[$zf].$sfieldexp.$r[$qzf].$sfieldexp.$r[$savef];
  2255. $addexp=$fieldexp;
  2256. }
  2257. return $datastr;
  2258. }
  2259. //导入采集规则
  2260. function LoadInCj($add,$file,$file_name,$file_type,$file_size,$userid,$username){
  2261. global $empire,$dbtbpre;
  2262. $lineexp='<!-#-|-line-|-#-!>';
  2263. $recordexp='<!-#-|-record-|-#-!>';
  2264. $fieldexp='<!-#-|-field-|-#-!>';
  2265. $sfieldexp='<!-#-|-smallfield-|-#-!>';
  2266. //验证权限
  2267. CheckLevel($userid,$username,$classid,"loadcj");
  2268. $classid=(int)$add['classid'];
  2269. if(!$classid)
  2270. {
  2271. printerror("EmptyLoadInCjFile","history.go(-1)");
  2272. }
  2273. $cr=$empire->fetch1("select classid,islast,tid,tbname from {$dbtbpre}enewsclass where classid='$classid' and islast=1");
  2274. if(!$cr['classid'])
  2275. {
  2276. printerror("LoadInCjMustLastClass","history.go(-1)");
  2277. }
  2278. if(!$file_name||!$file_size)
  2279. {
  2280. printerror("EmptyLoadInCjFile","history.go(-1)");
  2281. }
  2282. //扩展名
  2283. $filetype=GetFiletype($file_name);
  2284. if($filetype!=".cj")
  2285. {
  2286. printerror("LoadInCjErrorfiletype","history.go(-1)");
  2287. }
  2288. $path=ECMS_PATH.'e/data/tmp/cj/uploadcj'.time().'.cj';
  2289. //上传文件
  2290. $cp=@move_uploaded_file($file,$path);
  2291. DoChmodFile($path);
  2292. $data=ReadFiletext($path);
  2293. DelFiletext($path);
  2294. $r=explode($recordexp,$data);
  2295. $empirecmsver=$r[0];
  2296. $mainstr=$r[1];
  2297. $datafield=$r[2];
  2298. $datastr=$r[3];
  2299. if(empty($mainstr))
  2300. {
  2301. printerror("EmptyLoadInCjFile","history.go(-1)");
  2302. }
  2303. //主表
  2304. $infoclassid=LoadInCjInsertMainstr($classid,$cr['tid'],$cr['tbname'],$mainstr,$fieldexp,$sfieldexp);
  2305. //副表
  2306. LoadInCjInsertDatastr($classid,$cr['tid'],$cr['tbname'],$infoclassid,$datafield,$datastr,$fieldexp,$sfieldexp);
  2307. $cjr=$empire->fetch1("select classname from {$dbtbpre}enewsinfoclass where classid='$infoclassid'");
  2308. //操作日志
  2309. insert_dolog("classid=".$infoclassid."<br>classname=".$cjr[classname]);
  2310. printerror("LoadInCjSuccess","cj/LoadInCj.php?from=".ehtmlspecialchars($_POST[from]).hReturnEcmsHashStrHref2(0));
  2311. }
  2312. //写入主表组合
  2313. function LoadInCjInsertMainstr($classid,$tid,$tbname,$mainstr,$fieldexp,$sfieldexp){
  2314. global $empire,$dbtbpre;
  2315. $mainfield=LoadOutCjMainField();
  2316. $mainfieldr=explode(',',$mainfield);
  2317. $fcount=count($mainfieldr);
  2318. $mainr=explode($fieldexp,$mainstr);
  2319. $mainvalues='';
  2320. $count=count($mainr);
  2321. if($fcount<$count)
  2322. {
  2323. $count=$fcount;
  2324. }
  2325. for($i=0;$i<$count;$i++)
  2326. {
  2327. if($i==0)
  2328. {
  2329. $mainr[$i]=ehtmlspecialchars($mainr[$i],ENT_QUOTES);
  2330. }
  2331. $mainvalues.=",'".addslashes($mainr[$i])."'";
  2332. }
  2333. //字段不一致
  2334. if($fcount>$count)
  2335. {
  2336. $addcount=$fcount-$count;
  2337. for($addi=0;$addi<$addcount;$addi++)
  2338. {
  2339. if($addi==0)
  2340. {
  2341. $addval=',title,newstext,';
  2342. }
  2343. elseif($addi==1)
  2344. {
  2345. $addval=',newstext,';
  2346. }
  2347. elseif($addi==2)
  2348. {
  2349. $addval='0';
  2350. }
  2351. elseif($addi==3)
  2352. {
  2353. $addval=',newstext,';
  2354. }
  2355. else
  2356. {
  2357. $addval='';
  2358. }
  2359. $mainvalues.=",'$addval'";
  2360. }
  2361. }
  2362. $empire->query("insert into {$dbtbpre}enewsinfoclass(classid,bclassid,newsclassid,tid,tbname,".$mainfield.") values(NULL,'0','$classid','$tid','$tbname'".$mainvalues.");");
  2363. $lastid=$empire->lastid();
  2364. return $lastid;
  2365. }
  2366. //写入副表组合
  2367. function LoadInCjInsertDatastr($classid,$tid,$tbname,$infoclassid,$dataf,$datastr,$fieldexp,$sfieldexp){
  2368. global $empire,$dbtbpre;
  2369. if(empty($dataf))
  2370. {
  2371. $empire->query("insert into {$dbtbpre}ecms_infoclass_".$tbname."(classid) values('$infoclassid');");
  2372. return '';
  2373. }
  2374. //返回表字段
  2375. $tbfield=LoadOutCjDataField($tid,$tbname);
  2376. $datafr=explode(',',$dataf);
  2377. $datar=explode($fieldexp,$datastr);
  2378. $datafield='';
  2379. $datavalues='';
  2380. $count=count($datafr);
  2381. for($i=0;$i<$count;$i++)
  2382. {
  2383. $f=$datafr[$i];
  2384. if(!stristr(','.$tbfield.',',','.$f.','))
  2385. {
  2386. continue;
  2387. }
  2388. $zzf='zz_'.$f;
  2389. $zf='z_'.$f;
  2390. $qzf='qz_'.$f;
  2391. $savef='save_'.$f;
  2392. $zzr=explode($sfieldexp,$datar[$i]);
  2393. $datafield.=",$zzf,$zf,$qzf,$savef";
  2394. $datavalues.=",'".addslashes($zzr[0])."','".addslashes($zzr[1])."','".addslashes($zzr[2])."','".addslashes($zzr[3])."'";
  2395. }
  2396. $empire->query("insert into {$dbtbpre}ecms_infoclass_".$tbname."(classid".$datafield.") values('$infoclassid'".$datavalues.");");
  2397. }
  2398. ?>