hinfofun.php 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199
  1. <?php
  2. //*************************** 信息 ***************************
  3. //增加投票
  4. function AddInfoVote($classid,$id,$add){
  5. global $empire,$dbtbpre,$class_r;
  6. $pubid=ReturnInfoPubid($classid,$id);
  7. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1");
  8. $votename=$add['vote_name'];
  9. $votenum=$add['vote_num'];
  10. //统计总票数
  11. for($i=0;$i<count($votename);$i++)
  12. {
  13. $t_votenum+=$votenum[$i];
  14. }
  15. $t_votenum=(int)$t_votenum;
  16. $voteclass=(int)$add['vote_class'];
  17. $width=(int)$add['vote_width'];
  18. $height=(int)$add['vote_height'];
  19. $doip=(int)$add['dovote_ip'];
  20. $tempid=(int)$add['vote_tempid'];
  21. $add['vote_title']=hRepPostStr($add['vote_title'],1);
  22. $add['vote_dotime']=hRepPostStr($add['vote_dotime'],1);
  23. //附加字段
  24. $diyotherlink=(int)$add['info_diyotherlink'];
  25. $infouptime=0;
  26. if($add['info_infouptime'])
  27. {
  28. $infouptime=to_time($add['info_infouptime']);
  29. }
  30. $infodowntime=0;
  31. if($add['info_infodowntime'])
  32. {
  33. $infodowntime=to_time($add['info_infodowntime']);
  34. }
  35. if($num) //修改
  36. {
  37. $votetext=ReturnVote($add['vote_name'],$add['vote_num'],$add['delvote_id'],$add['vote_id'],1); //返回组合
  38. $votetext=hRepPostStr($votetext,1);
  39. $sql=$empire->query("update {$dbtbpre}enewsinfovote set title='$add[vote_title]',votenum='$t_votenum',votetext='$votetext',voteclass='$voteclass',doip='$doip',dotime='$add[vote_dotime]',tempid='$tempid',width='$width',height='$height',diyotherlink='$diyotherlink',infouptime='$infouptime',infodowntime='$infodowntime' where pubid='$pubid' limit 1");
  40. }
  41. else //增加
  42. {
  43. $votetext=ReturnVote($add['vote_name'],$add['vote_num'],$add['delvote_id'],$add['vote_id'],0); //返回组合
  44. if(!($votetext||$diyotherlink||$infouptime||$infodowntime))
  45. {
  46. return '';
  47. }
  48. $votetext=hRepPostStr($votetext,1);
  49. $sql=$empire->query("insert into {$dbtbpre}enewsinfovote(pubid,id,classid,title,votenum,voteip,votetext,voteclass,doip,dotime,tempid,width,height,diyotherlink,infouptime,infodowntime,copyids) values('$pubid','$id','$classid','$add[vote_title]','$t_votenum','','$votetext','$voteclass','$doip','$add[vote_dotime]','$tempid','$width','$height','$diyotherlink','$infouptime','$infodowntime','');");
  50. }
  51. }
  52. //更新同时发布
  53. function UpdateInfoCopyids($classid,$id,$copyids){
  54. global $empire,$dbtbpre,$class_r;
  55. $pubid=ReturnInfoPubid($classid,$id);
  56. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1");
  57. if($num) //修改
  58. {
  59. $empire->query("update {$dbtbpre}enewsinfovote set copyids='$copyids' where pubid='$pubid' limit 1");
  60. }
  61. else //增加
  62. {
  63. $empire->query("insert into {$dbtbpre}enewsinfovote(pubid,id,classid,copyids) values('$pubid','$id','$classid','$copyids');");
  64. }
  65. }
  66. //返回标题是否重复
  67. function ReturnCheckRetitle($add){
  68. global $empire,$dbtbpre,$class_r;
  69. $classid=(int)$add['classid'];
  70. $id=(int)$add['id'];
  71. $title=AddAddsData($add['title']);
  72. $where='';
  73. if($id)
  74. {
  75. $where=' and id<>'.$id;
  76. }
  77. //已审核
  78. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where title='".addslashes($title)."'".$where." limit 1");
  79. //未审核
  80. if(empty($num))
  81. {
  82. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check where title='".addslashes($title)."'".$where." limit 1");
  83. }
  84. return $num;
  85. }
  86. //AJAX验证标题是否重复
  87. function CheckReTitleAjax($add){
  88. if(ReturnCheckRetitle($add))
  89. {
  90. echo 1;
  91. }
  92. else
  93. {
  94. echo 0;
  95. }
  96. }
  97. //增加信息处理变量
  98. function DoPostInfoVar($add){
  99. global $class_r,$public_r;
  100. $add['classid']=(int)$add['classid'];
  101. //组合标题属性
  102. $add[titlecolor]=eDoRepPostComStr(RepPhpAspJspcodeText($add[titlecolor]));
  103. $add['my_titlefont']=eDoRepPostComStr(TitleFont($add[titlefont],$add[titlecolor]));
  104. //专题
  105. $add['ztids']=RepPostVar($add['ztids']);
  106. $add['zcids']=RepPostVar($add['zcids']);
  107. $add['oldztids']=RepPostVar($add['oldztids']);
  108. $add['oldzcids']=RepPostVar($add['oldzcids']);
  109. //其它变量
  110. $add['title']=eDoInfoTbfToQj($class_r[$add['classid']]['tbname'],'title',$add['title'],$public_r['toqjf']);
  111. $add[title]=eDoRepPostComStr($add[title],1);
  112. $add[keyboard]=eDoRepPostComStr(RepPhpAspJspcodeText(DoReplaceQjDh($add[keyboard])),1);
  113. $add[titleurl]=eDoRepPostComStr(RepPhpAspJspcodeText($add[titleurl]),1);
  114. $add[checked]=(int)$add[checked];
  115. $add[istop]=(int)$add[istop];
  116. $add[dokey]=(int)$add[dokey];
  117. $add[isgood]=(int)$add[isgood];
  118. $add[groupid]=(int)$add[groupid];
  119. $add[newstempid]=(int)$add[newstempid];
  120. $add[firsttitle]=(int)$add[firsttitle];
  121. $add[userfen]=(int)$add[userfen];
  122. $add[closepl]=(int)$add[closepl];
  123. $add[ttid]=(int)$add[ttid];
  124. $add[oldttid]=(int)$add[oldttid];
  125. $add[onclick]=(int)$add[onclick];
  126. $add[totaldown]=(int)$add[totaldown];
  127. $add[infotags]=eDoRepPostComStr(RepPhpAspJspcodeText(DoReplaceQjDh($add[infotags])),1);
  128. $add[titlepic]=eDoRepPostComStr($add[titlepic],1);
  129. $add[ispic]=$add[titlepic]?1:0;
  130. $add[filename]=RepFilenameQz($add[filename],1);
  131. $add[newspath]=RepFilenameQz($add[newspath],1);
  132. $add['newspath']=hRepPostStr($add['newspath'],1);
  133. $add['filename']=hRepPostStr($add['filename'],1);
  134. $add['keyboard']=hRepPostStr($add['keyboard'],0);
  135. $add['infotags']=hRepPostStr($add['infotags'],1);
  136. $add['isurl']=$add['titleurl']?1:0;
  137. return $add;
  138. }
  139. //相关链接ID处理
  140. function DoPostDiyOtherlinkID($keyid){
  141. if(!$keyid||$keyid==',')
  142. {
  143. return '';
  144. }
  145. $new_keyid='';
  146. $dh='';
  147. $r=explode(',',$keyid);
  148. $count=count($r);
  149. for($i=0;$i<$count;$i++)
  150. {
  151. $r[$i]=(int)$r[$i];
  152. if(!$r[$i])
  153. {
  154. continue;
  155. }
  156. $new_keyid.=$dh.$r[$i];
  157. $dh=',';
  158. }
  159. return $new_keyid;
  160. }
  161. //增加信息
  162. function AddNews($add,$userid,$username){
  163. global $empire,$class_r,$class_zr,$bclassid,$public_r,$dbtbpre,$emod_r,$lur;
  164. $add[classid]=(int)$add[classid];
  165. $userid=(int)$userid;
  166. if(!$add[title]||!$add[classid])
  167. {
  168. printerror("EmptyTitle","history.go(-1)");
  169. }
  170. //操作权限
  171. $doselfinfo=CheckLevel($userid,$username,$add[classid],"news");
  172. if(!$doselfinfo['doaddinfo'])//增加权限
  173. {
  174. printerror("NotAddInfoLevel","history.go(-1)");
  175. }
  176. $ccr=$empire->fetch1("select classid,modid,listdt,haddlist,sametitle,addreinfo,wburl,repreinfo from {$dbtbpre}enewsclass where classid='$add[classid]' and islast=1 limit 1");
  177. if(!$ccr['classid']||$ccr['wburl'])
  178. {
  179. printerror("ErrorUrl","history.go(-1)");
  180. }
  181. if($ccr['sametitle'])//验证标题重复
  182. {
  183. if(ReturnCheckRetitle($add))
  184. {
  185. printerror("ReInfoTitle","history.go(-1)");
  186. }
  187. }
  188. //修改文件名权限
  189. if(!$doselfinfo['doinfofile'])
  190. {
  191. $add['newspath']=date($class_r[$add['classid']]['newspath']);
  192. $add['filename']='';
  193. }
  194. $add=DoPostInfoVar($add);//返回变量
  195. $ret_r=ReturnAddF($add,$class_r[$add[classid]][modid],$userid,$username,0,0,1);//返回自定义字段
  196. $newspath=FormatPath($add[classid],$add[newspath],1);//查看目录是否存在,不存在则建立
  197. //审核权限
  198. if(!$doselfinfo['docheckinfo'])
  199. {
  200. $add['checked']=$class_r[$add[classid]][checked];
  201. }
  202. //必须审核
  203. if($doselfinfo['domustcheck'])
  204. {
  205. $add['checked']=0;
  206. }
  207. //推荐权限
  208. if(!$doselfinfo['dogoodinfo'])
  209. {
  210. $add['isgood']=0;
  211. $add['firsttitle']=0;
  212. $add['istop']=0;
  213. }
  214. else
  215. {
  216. if(!eFirstTitleCheckLevel($add['isgood'],0))//推荐
  217. {
  218. $add['isgood']=0;
  219. }
  220. if(!eFirstTitleCheckLevel($add['firsttitle'],1))//头条
  221. {
  222. $add['firsttitle']=0;
  223. }
  224. }
  225. //签发
  226. $isqf=0;
  227. if($class_r[$add[classid]][wfid])
  228. {
  229. $userisqf=EcmsReturnDoIsqf($userid,$username,$lur['groupid'],0);
  230. if(!$userisqf)
  231. {
  232. $add[checked]=0;
  233. $isqf=1;
  234. }
  235. }
  236. $newstime=empty($add['newstime'])?time():to_time($add['newstime']);
  237. $truetime=time();
  238. $lastdotime=$truetime;
  239. //是否生成
  240. $havehtml=0;
  241. if($add['checked']==1&&$ccr['addreinfo'])
  242. {
  243. $havehtml=1;
  244. }
  245. //返回关键字组合
  246. if($add['info_diyotherlink'])
  247. {
  248. $keyid=DoPostDiyOtherlinkID($add['info_keyid']);
  249. }
  250. else
  251. {
  252. $keyid=GetKeyid($add[keyboard],$add[classid],0,$class_r[$add[classid]][link_num]);
  253. }
  254. //附加链接参数
  255. $addecmscheck=empty($add['checked'])?'&ecmscheck=1':'';
  256. //索引表
  257. $sql=$empire->query("insert into {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]."_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('$add[classid]','$add[checked]','$newstime','$truetime','$lastdotime','$havehtml');");
  258. $id=$empire->lastid();
  259. $pubid=ReturnInfoPubid($add['classid'],$id);
  260. $infotbr=ReturnInfoTbname($class_r[$add[classid]][tbname],$add['checked'],$ret_r['tb']);
  261. //主表
  262. $infosql=$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".$ret_r['fields'].") values('$id','$add[classid]','$add[ttid]','$add[onclick]',0,'$add[totaldown]','$newspath','$filename','$userid','".addslashes($username)."','$add[firsttitle]','$add[isgood]','$add[ispic]','$add[istop]','$isqf',0,'$add[isurl]','$truetime','$lastdotime','$havehtml','$add[groupid]','$add[userfen]','".addslashes($add[my_titlefont])."','".addslashes($add[titleurl])."','$ret_r[tb]','$public_r[filedeftb]','$public_r[pldeftb]','".addslashes($add[keyboard])."'".$ret_r['values'].");");
  263. //副表
  264. $finfosql=$empire->query("insert into ".$infotbr['datatbname']."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$ret_r['datafields'].") values('$id','$add[classid]','$keyid','$add[dokey]','$add[newstempid]','$add[closepl]',0,'".addslashes($add[infotags])."'".$ret_r['datavalues'].");");
  265. //更新栏目信息数
  266. AddClassInfos($add['classid'],'+1','+1',$add['checked']);
  267. //更新新信息数
  268. DoUpdateAddDataNum('info',$class_r[$add['classid']]['tid'],1);
  269. //签发
  270. if($isqf==1)
  271. {
  272. InfoInsertToWorkflow($id,$add[classid],$class_r[$add[classid]][wfid],$userid,$username);
  273. }
  274. //更新附件表
  275. UpdateTheFile($id,$add['filepass'],$add['classid'],$public_r['filedeftb']);
  276. //取第一张图作为标题图片
  277. if($add['getfirsttitlepic']&&empty($add['titlepic']))
  278. {
  279. $firsttitlepic=GetFpicToTpic($add['classid'],$id,$add['getfirsttitlepic'],$add['getfirsttitlespic'],$add['getfirsttitlespicw'],$add['getfirsttitlespich'],$public_r['filedeftb']);
  280. if($firsttitlepic)
  281. {
  282. $addtitlepic=",titlepic='".addslashes($firsttitlepic)."',ispic=1";
  283. }
  284. }
  285. //文件命名
  286. if($add['filename'])
  287. {
  288. $filename=$add['filename'];
  289. }
  290. else
  291. {
  292. $filename=ReturnInfoFilename($add[classid],$id,'');
  293. }
  294. //信息地址
  295. $updateinfourl='';
  296. if(!$add['isurl'])
  297. {
  298. $infourl=GotoGetTitleUrl($add['classid'],$id,$newspath,$filename,$add['groupid'],$add['isurl'],$add['titleurl']);
  299. $updateinfourl=",titleurl='$infourl'";
  300. }
  301. $usql=$empire->query("update ".$infotbr['tbname']." set filename='$filename'".$updateinfourl.$addtitlepic." where id='$id'");
  302. //替换图片下一页
  303. if($add['repimgnexturl'])
  304. {
  305. UpdateImgNexturl($add[classid],$id,$add['checked']);
  306. }
  307. //投票
  308. AddInfoVote($add['classid'],$id,$add);
  309. //加入专题
  310. InsertZtInfo($add['ztids'],$add['zcids'],$add['oldztids'],$add['oldzcids'],$add['classid'],$id,$newstime);
  311. //TAGS
  312. if($add[infotags]&&$add[infotags]<>$add[oldinfotags])
  313. {
  314. eInsertTags($add[infotags],$add['classid'],$id,$newstime);
  315. }
  316. //处理函数
  317. DoMFun($class_r[$add['classid']]['modid'],$add['classid'],$id,1,0);
  318. //增加信息是否生成文件
  319. if($ccr['addreinfo']&&$add['checked'])
  320. {
  321. GetHtml($add['classid'],$id,'',0);
  322. }
  323. //生成上一篇
  324. $epreid=0;
  325. if($ccr['repreinfo']&&$add['checked'])
  326. {
  327. $prer=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id<$id and classid='$add[classid]' order by id desc limit 1");
  328. $epreid=$prer['id'];
  329. GetHtml($add['classid'],$prer['id'],$prer,1);
  330. }
  331. //生成栏目
  332. if($ccr['haddlist']&&$add['checked'])
  333. {
  334. hAddListHtml($add['classid'],$ccr['modid'],$ccr['haddlist'],$ccr['listdt']);//生成信息列表
  335. if($add['ttid'])//生成标题分类列表
  336. {
  337. ListHtml($add['ttid'],'',5);
  338. }
  339. }
  340. //同时发布
  341. $copyclassid=$add[copyclassid];
  342. $cpcount=count($copyclassid);
  343. if($cpcount)
  344. {
  345. $copyids=AddInfoToCopyInfo($add[classid],$id,$copyclassid,$userid,$username,$doselfinfo);
  346. if($copyids)
  347. {
  348. UpdateInfoCopyids($add['classid'],$id,$copyids);
  349. }
  350. }
  351. //更新动态缓存
  352. if($public_r['ctimeopen']&&$add['checked'])
  353. {
  354. eUpCacheInfo(1,$add['classid'],0,$epreid,$add['ttid'],'',$add['infotags'],0,0);
  355. }
  356. if($sql)
  357. {
  358. //返回地址
  359. if($add['ecmsfrom']&&(stristr($add['ecmsfrom'],'ListNews.php')||stristr($add['ecmsfrom'],'ListAllInfo.php')))
  360. {
  361. $ecmsfrom=$add['ecmsfrom'];
  362. }
  363. else
  364. {
  365. $ecmsfrom=$add['ecmsnfrom']==1?"ListNews.php?bclassid=$add[bclassid]&classid=$add[classid]":"ListAllInfo.php?tbname=".$class_r[$add[classid]][tbname];
  366. $ecmsfrom.=hReturnEcmsHashStrHref2(0);
  367. }
  368. $GLOBALS['ecmsadderrorurl']=$ecmsfrom.$addecmscheck;
  369. insert_dolog("classid=$add[classid]<br>id=".$id."<br>title=".$add[title],$pubid);//操作日志
  370. printerror("AddNewsSuccess","AddNews.php?enews=AddNews&ecmsnfrom=$add[ecmsnfrom]&bclassid=$add[bclassid]&classid=$add[classid]".$addecmscheck.hReturnEcmsHashStrHref2(0));
  371. }
  372. else
  373. {
  374. printerror("DbError","");
  375. }
  376. }
  377. //修改信息
  378. function EditNews($add,$userid,$username){
  379. global $empire,$class_r,$class_zr,$bclassid,$public_r,$dbtbpre,$emod_r;
  380. $add[classid]=(int)$add[classid];
  381. $userid=(int)$userid;
  382. $add[id]=(int)$add[id];
  383. if(!$add[id]||!$add[title]||!$add[classid]||!$add[filename])
  384. {
  385. printerror("EmptyTitle","history.go(-1)");
  386. }
  387. $doselfinfo=CheckLevel($userid,$username,$add[classid],"news");//操作权限
  388. if(!$doselfinfo['doeditinfo'])//编辑权限
  389. {
  390. printerror("NotEditInfoLevel","history.go(-1)");
  391. }
  392. $ccr=$empire->fetch1("select classid,modid,listdt,haddlist,sametitle,addreinfo,wburl,repreinfo from {$dbtbpre}enewsclass where classid='$add[classid]' and islast=1 limit 1");
  393. if(!$ccr['classid']||$ccr['wburl'])
  394. {
  395. printerror("ErrorUrl","history.go(-1)");
  396. }
  397. //索引表
  398. $index_checkr=$empire->fetch1("select id,classid,checked from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]."_index where id='$add[id]' limit 1");
  399. if(!$index_checkr['id']||$index_checkr['classid']!=$add['classid'])
  400. {
  401. printerror("ErrorUrl","history.go(-1)");
  402. }
  403. //主表
  404. $infotb=ReturnInfoMainTbname($class_r[$add[classid]][tbname],$index_checkr['checked']);
  405. $checkr=$empire->fetch1("select id,classid,userid,username,ismember,stb,newspath,filename,isqf,fstb,isgood,firsttitle,istop,ttid,eckuid from ".$infotb." where id='$add[id]' limit 1");
  406. if($doselfinfo['doselfinfo']&&($checkr['userid']<>$userid||$checkr['ismember']))//只能编辑自己的信息
  407. {
  408. printerror("NotDoSelfinfo","history.go(-1)");
  409. }
  410. //已审核信息不可修改
  411. if($doselfinfo['docheckedit']&&$index_checkr['checked'])
  412. {
  413. printerror("NotEditCheckInfoLevel","history.go(-1)");
  414. }
  415. //签发信息
  416. if($checkr['isqf'])
  417. {
  418. $qfr=$empire->fetch1("select wfid,checktno from {$dbtbpre}enewswfinfo where id='$add[id]' and classid='$add[classid]' limit 1");
  419. if($qfr['checktno']<100)
  420. {
  421. $qfwfr=$empire->fetch1("select wfid,canedit from {$dbtbpre}enewsworkflow where wfid='$qfr[wfid]' limit 1");
  422. if($qfwfr['wfid']&&!$qfwfr['canedit'])
  423. {
  424. printerror("WorkflowCanNotEditInfo","history.go(-1)");
  425. }
  426. }
  427. }
  428. //审核权限
  429. if(!$doselfinfo['docheckinfo'])
  430. {
  431. $add['checked']=$index_checkr['checked'];
  432. }
  433. //必须审核
  434. if($doselfinfo['domustcheck']&&!$index_checkr['checked'])
  435. {
  436. $add['checked']=0;
  437. }
  438. //推荐权限
  439. if(!$doselfinfo['dogoodinfo'])
  440. {
  441. $add['isgood']=$checkr['isgood'];
  442. $add['firsttitle']=$checkr['firsttitle'];
  443. $add['istop']=$checkr['istop'];
  444. }
  445. else
  446. {
  447. if(!eFirstTitleCheckLevel($add['isgood'],0))//推荐
  448. {
  449. $add['isgood']=$checkr['isgood'];
  450. }
  451. if(!eFirstTitleCheckLevel($add['firsttitle'],1))//头条
  452. {
  453. $add['firsttitle']=$checkr['firsttitle'];
  454. }
  455. }
  456. if($ccr['sametitle'])//验证标题重复
  457. {
  458. if(ReturnCheckRetitle($add))
  459. {
  460. printerror("ReInfoTitle","history.go(-1)");
  461. }
  462. }
  463. //修改文件名权限
  464. if(!$doselfinfo['doinfofile'])
  465. {
  466. $add['newspath']=$checkr['newspath'];
  467. $add['filename']=$checkr['filename'];
  468. }
  469. //公共表
  470. $pubid=ReturnInfoPubid($add['classid'],$add['id']);
  471. $pubcheckr=$empire->fetch1("select copyids from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1");
  472. $mid=$class_r[$add[classid]][modid];
  473. $pf=$emod_r[$mid]['pagef'];
  474. $add=DoPostInfoVar($add);//返回变量
  475. $add['fstb']=$checkr['fstb'];
  476. $ret_r=ReturnAddF($add,$class_r[$add[classid]][modid],$userid,$username,1,0,1);//返回自定义字段
  477. $deloldfile=0;
  478. if($add[groupid]<>$add[oldgroupid]||($index_checkr['checked']&&!$add[checked]))//改变文件权限
  479. {
  480. DelNewsFile($checkr[filename],$checkr[newspath],$add[classid],$add[$pf],$add[oldgroupid]);//删除旧的文件
  481. $deloldfile=1;
  482. }
  483. //签发
  484. $newchecked=$index_checkr['checked'];
  485. $a='';
  486. if($class_r[$add[classid]][wfid]&&$checkr['isqf'])
  487. {
  488. $qfr=$empire->fetch1("select checktno from {$dbtbpre}enewswfinfo where id='$add[id]' and classid='$add[classid]' limit 1");
  489. if($qfr['checktno']=='100')//已通过
  490. {
  491. $aqf=",checked='$add[checked]'";
  492. $newchecked=$add[checked];
  493. }
  494. else
  495. {
  496. if($add[reworkflow])
  497. {
  498. InfoUpdateToWorkflow($add[id],$add[classid],$class_r[$add[classid]][wfid],$userid,$username);
  499. }
  500. $aqf='';
  501. }
  502. }
  503. else
  504. {
  505. $aqf=",checked='$add[checked]'";
  506. $newchecked=$add[checked];
  507. }
  508. //日期目录
  509. $updatefile='';
  510. $urlnewspath=$checkr['newspath'];
  511. if($add['newspath']!=$checkr[newspath])
  512. {
  513. $add[newspath]=FormatPath($add[classid],$add[newspath],1);//查看目录是否存在,不存在则建立
  514. $updatefile.=",newspath='$add[newspath]'";
  515. if($deloldfile==0)
  516. {
  517. DelNewsFile($checkr[filename],$checkr[newspath],$add[classid],$add[$pf],$add[oldgroupid]);//删除旧文件
  518. $deloldfile=1;
  519. }
  520. $urlnewspath=$add['newspath'];
  521. }
  522. //文件名
  523. $urlfilename=$checkr['filename'];
  524. if($add['filename']&&$add['filename']!=$checkr[filename])
  525. {
  526. $newfilename=$add['filename'];
  527. $updatefile.=",filename='$newfilename'";
  528. if($deloldfile==0)
  529. {
  530. DelNewsFile($checkr[filename],$checkr[newspath],$add[classid],$add[$pf],$add[oldgroupid]);//删除旧文件
  531. $deloldfile=1;
  532. }
  533. $urlfilename=$newfilename;
  534. }
  535. //审核人
  536. if(!$index_checkr['checked']&&$index_checkr['checked']!=$newchecked)
  537. {
  538. if(!$checkr['eckuid']&&($checkr['ismember']||$checkr['userid']!=$userid))
  539. {
  540. $updatefile.=",eckuid='$userid'";
  541. }
  542. }
  543. $newstime=empty($add['newstime'])?time():to_time($add['newstime']);
  544. $lastdotime=time();
  545. //返回关键字组合
  546. if($add['info_diyotherlink'])
  547. {
  548. $keyid=DoPostDiyOtherlinkID($add['info_keyid']);
  549. }
  550. else
  551. {
  552. $keyid=GetKeyid($add[keyboard],$add[classid],$add[id],$class_r[$add[classid]][link_num]);
  553. }
  554. //附加链接参数
  555. $addecmscheck=empty($newchecked)?'&ecmscheck=1':'';
  556. //信息地址
  557. $infourl=GotoGetTitleUrl($add['classid'],$add['id'],$urlnewspath,$urlfilename,$add['groupid'],$add['isurl'],$add['titleurl']);
  558. //返回表信息
  559. $infotbr=ReturnInfoTbname($class_r[$add[classid]][tbname],$index_checkr['checked'],$checkr['stb']);
  560. //索引表
  561. $indexsql=$empire->query("update {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]."_index set newstime='$newstime',lastdotime='$lastdotime'".$aqf." where id='$add[id]' limit 1");
  562. //主表
  563. $sql=$empire->query("update ".$infotbr['tbname']." set classid='$add[classid]',ttid='$add[ttid]',onclick='$add[onclick]',totaldown='$add[totaldown]',firsttitle=$add[firsttitle],isgood=$add[isgood],ispic='$add[ispic]',istop=$add[istop],isurl='$add[isurl]',lastdotime=$lastdotime,groupid=$add[groupid],userfen=$add[userfen],titlefont='".addslashes($add[my_titlefont])."',titleurl='".addslashes($infourl)."',keyboard='".addslashes($add[keyboard])."'".$updatefile.$ret_r[values]." where id='$add[id]' limit 1");
  564. //副表
  565. $stb=$checkr['stb'];
  566. $fsql=$empire->query("update ".$infotbr['datatbname']." set classid='$add[classid]',keyid='$keyid',dokey=$add[dokey],newstempid=$add[newstempid],closepl=$add[closepl],infotags='".addslashes($add[infotags])."'".$ret_r[datavalues]." where id='$add[id]' limit 1");
  567. //取第一张图作为标题图片
  568. if($add['getfirsttitlepic']&&empty($add['titlepic']))
  569. {
  570. $firsttitlepic=GetFpicToTpic($add['classid'],$add['id'],$add['getfirsttitlepic'],$add['getfirsttitlespic'],$add['getfirsttitlespicw'],$add['getfirsttitlespich'],$checkr['fstb']);
  571. if($firsttitlepic)
  572. {
  573. $usql=$empire->query("update ".$infotbr['tbname']." set titlepic='".addslashes($firsttitlepic)."',ispic=1 where id='$add[id]'");
  574. }
  575. }
  576. //更新附件
  577. UpdateTheFileEdit($add['classid'],$add['id'],$checkr['fstb']);
  578. //替换图片下一页
  579. if($add['repimgnexturl'])
  580. {
  581. UpdateImgNexturl($add['classid'],$add['id'],$index_checkr['checked']);
  582. }
  583. //投票
  584. AddInfoVote($add['classid'],$add['id'],$add);
  585. //写入专题
  586. InsertZtInfo($add['ztids'],$add['zcids'],$add['oldztids'],$add['oldzcids'],$add['classid'],$add['id'],$newstime);
  587. //TAGS
  588. if($add[infotags]&&$add[infotags]<>$add[oldinfotags])
  589. {
  590. eInsertTags($add[infotags],$add['classid'],$add['id'],$newstime);
  591. }
  592. //是否改变审核状态
  593. if($index_checkr['checked']!=$newchecked)
  594. {
  595. MoveCheckInfoData($class_r[$add[classid]][tbname],$index_checkr['checked'],$checkr['stb'],"id='$add[id]'");
  596. //更新栏目信息数
  597. if($newchecked)
  598. {
  599. AddClassInfos($add['classid'],'','+1');
  600. }
  601. else
  602. {
  603. AddClassInfos($add['classid'],'','-1');
  604. }
  605. }
  606. //处理函数
  607. DoMFun($class_r[$add['classid']]['modid'],$add['classid'],$add['id'],0,0);
  608. //生成文件
  609. if($ccr['addreinfo']&&$newchecked)
  610. {
  611. GetHtml($add['classid'],$add['id'],'',0);
  612. }
  613. //生成上一篇
  614. $epreid=0;
  615. if($ccr['repreinfo']&&($newchecked||$newchecked<>$add[oldchecked]))
  616. {
  617. $prer=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id<$add[id] and classid='$add[classid]' order by id desc limit 1");
  618. $epreid=$prer['id'];
  619. GetHtml($prer['classid'],$prer['id'],$prer,1);
  620. }
  621. //生成栏目
  622. if($ccr['haddlist']&&($newchecked||$newchecked<>$add[oldchecked]))
  623. {
  624. hAddListHtml($add[classid],$ccr['modid'],$ccr['haddlist'],$ccr['listdt']);//生成信息列表
  625. if($add['ttid'])//生成标题分类列表
  626. {
  627. ListHtml($add['ttid'],'',5);
  628. }
  629. //改变标题分类
  630. if($add['oldttid']&&$add['ttid']<>$add['oldttid'])
  631. {
  632. ListHtml($add['oldttid'],'',5);
  633. }
  634. }
  635. //同时更新
  636. if($pubcheckr['copyids']&&$pubcheckr['copyids']<>'1')
  637. {
  638. EditInfoToCopyInfo($add[classid],$add[id],$userid,$username,$doselfinfo);
  639. }
  640. else
  641. {
  642. $copyclassid=$add[copyclassid];
  643. $cpcount=count($copyclassid);
  644. if($cpcount)
  645. {
  646. $copyids=AddInfoToCopyInfo($add[classid],$add[id],$copyclassid,$userid,$username,$doselfinfo);
  647. if($copyids)
  648. {
  649. UpdateInfoCopyids($add['classid'],$add['id'],$copyids);
  650. }
  651. }
  652. }
  653. //更新动态缓存
  654. if($public_r['ctimeopen']&&($newchecked||$newchecked<>$add[oldchecked]))
  655. {
  656. eUpCacheInfo(1,$add['classid'],0,$epreid,$add['ttid'],'',$add['infotags'],0,$checkr['ttid']);
  657. }
  658. if($sql)
  659. {
  660. //返回地址
  661. if($add['ecmsfrom']&&(stristr($add['ecmsfrom'],'ListNews.php')||stristr($add['ecmsfrom'],'ListAllInfo.php')))
  662. {
  663. $ecmsfrom=$add['ecmsfrom'];
  664. }
  665. else
  666. {
  667. $ecmsfrom="ListNews.php?bclassid=$add[bclassid]&classid=$add[classid]".hReturnEcmsHashStrHref2(0);
  668. }
  669. insert_dolog("classid=$add[classid]<br>id=".$add[id]."<br>title=".$add[title],$pubid);//操作日志
  670. printerror("EditNewsSuccess",$ecmsfrom.$addecmscheck);
  671. }
  672. else
  673. {
  674. printerror("DbError","history.go(-1)");
  675. }
  676. }
  677. //修改信息(快速)
  678. function EditInfoSimple($add,$userid,$username){
  679. global $empire,$class_r,$class_zr,$bclassid,$public_r,$dbtbpre,$emod_r;
  680. $add[classid]=(int)$add[classid];
  681. $userid=(int)$userid;
  682. $add[id]=(int)$add[id];
  683. $closeurl='info/EditInfoSimple.php?isclose=1&reload=1'.hReturnEcmsHashStrHref2(0);
  684. if(!$add[id]||!$add[title]||!$add[classid])
  685. {
  686. printerror("EmptyTitle","history.go(-1)",8);
  687. }
  688. $doselfinfo=CheckLevel($userid,$username,$add[classid],"news");//操作权限
  689. if(!$doselfinfo['doeditinfo'])//编辑权限
  690. {
  691. printerror("NotEditInfoLevel","history.go(-1)",8);
  692. }
  693. $ccr=$empire->fetch1("select classid,modid,listdt,haddlist,sametitle,addreinfo,wburl,repreinfo from {$dbtbpre}enewsclass where classid='$add[classid]' and islast=1 limit 1");
  694. if(!$ccr['classid']||$ccr['wburl'])
  695. {
  696. printerror("ErrorUrl","history.go(-1)",8);
  697. }
  698. //索引表
  699. $index_checkr=$empire->fetch1("select id,classid,checked from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]."_index where id='$add[id]' limit 1");
  700. if(!$index_checkr['id']||$index_checkr['classid']!=$add['classid'])
  701. {
  702. printerror("ErrorUrl","history.go(-1)",8);
  703. }
  704. //主表
  705. $infotb=ReturnInfoMainTbname($class_r[$add[classid]][tbname],$index_checkr['checked']);
  706. $checkr=$empire->fetch1("select id,classid,userid,username,ismember,stb,newspath,filename,isqf,fstb,isgood,firsttitle,istop,groupid,ttid from ".$infotb." where id='$add[id]' limit 1");
  707. if($doselfinfo['doselfinfo']&&($checkr['userid']<>$userid||$checkr['ismember']))//只能编辑自己的信息
  708. {
  709. printerror("NotDoSelfinfo","history.go(-1)",8);
  710. }
  711. //已审核信息不可修改
  712. if($doselfinfo['docheckedit']&&$index_checkr['checked'])
  713. {
  714. printerror("NotEditCheckInfoLevel","history.go(-1)");
  715. }
  716. //签发信息
  717. if($checkr['isqf'])
  718. {
  719. $qfr=$empire->fetch1("select wfid,checktno from {$dbtbpre}enewswfinfo where id='$add[id]' and classid='$add[classid]' limit 1");
  720. if($qfr['checktno']<100)
  721. {
  722. $qfwfr=$empire->fetch1("select wfid,canedit from {$dbtbpre}enewsworkflow where wfid='$qfr[wfid]' limit 1");
  723. if($qfwfr['wfid']&&!$qfwfr['canedit'])
  724. {
  725. printerror("WorkflowCanNotEditInfo","history.go(-1)");
  726. }
  727. }
  728. }
  729. //审核权限
  730. if(!$doselfinfo['docheckinfo'])
  731. {
  732. $add['checked']=$index_checkr['checked'];
  733. }
  734. //必须审核
  735. if($doselfinfo['domustcheck']&&!$index_checkr['checked'])
  736. {
  737. $add['checked']=0;
  738. }
  739. //推荐权限
  740. if(!$doselfinfo['dogoodinfo'])
  741. {
  742. $add['isgood']=$checkr['isgood'];
  743. $add['firsttitle']=$checkr['firsttitle'];
  744. $add['istop']=$checkr['istop'];
  745. }
  746. else
  747. {
  748. if(!eFirstTitleCheckLevel($add['isgood'],0))//推荐
  749. {
  750. $add['isgood']=$checkr['isgood'];
  751. }
  752. if(!eFirstTitleCheckLevel($add['firsttitle'],1))//头条
  753. {
  754. $add['firsttitle']=$checkr['firsttitle'];
  755. }
  756. }
  757. if($ccr['sametitle'])//验证标题重复
  758. {
  759. if(ReturnCheckRetitle($add))
  760. {
  761. printerror("ReInfoTitle","history.go(-1)",8);
  762. }
  763. }
  764. //公共表
  765. $pubid=ReturnInfoPubid($add['classid'],$add['id']);
  766. $pubcheckr=$empire->fetch1("select copyids from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1");
  767. $mid=$class_r[$add[classid]][modid];
  768. $pf=$emod_r[$mid]['pagef'];
  769. $add=DoPostInfoVar($add);//返回变量
  770. //签发
  771. $newchecked=$index_checkr['checked'];
  772. $a="";
  773. if($class_r[$add[classid]][wfid]&&$checkr['isqf'])
  774. {
  775. $qfr=$empire->fetch1("select checktno from {$dbtbpre}enewswfinfo where id='$add[id]' and classid='$add[classid]' limit 1");
  776. if($qfr['checktno']=='100')//已通过
  777. {
  778. $aqf=",checked='$add[checked]'";
  779. $newchecked=$add[checked];
  780. }
  781. else
  782. {
  783. if($add[reworkflow])
  784. {
  785. InfoUpdateToWorkflow($add[id],$add[classid],$class_r[$add[classid]][wfid],$userid,$username);
  786. }
  787. $aqf='';
  788. }
  789. }
  790. else
  791. {
  792. $aqf=",checked='$add[checked]'";
  793. $newchecked=$add[checked];
  794. }
  795. $lastdotime=time();
  796. //发布时间
  797. $newstime=empty($add['newstime'])?time():to_time($add['newstime']);
  798. //附加链接参数
  799. $addecmscheck=empty($newchecked)?'&ecmscheck=1':'';
  800. //信息地址
  801. $infourl=GotoGetTitleUrl($add['classid'],$add['id'],$checkr['newspath'],$checkr['filename'],$checkr['groupid'],$add['isurl'],$add['titleurl']);
  802. //返回表信息
  803. $infotbr=ReturnInfoTbname($class_r[$add[classid]][tbname],$index_checkr['checked'],$checkr['stb']);
  804. //索引表
  805. $indexsql=$empire->query("update {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]."_index set newstime='$newstime',lastdotime='$lastdotime'".$aqf." where id='$add[id]' limit 1");
  806. //主表
  807. $sql=$empire->query("update ".$infotbr['tbname']." set classid='$add[classid]',ttid='$add[ttid]',onclick='$add[onclick]',totaldown='$add[totaldown]',firsttitle='$add[firsttitle]',isgood='$add[isgood]',ispic='$add[ispic]',istop='$add[istop]',isurl='$add[isurl]',lastdotime='$lastdotime',titlefont='".addslashes($add[my_titlefont])."',titleurl='".addslashes($infourl)."',title='".addslashes($add[title])."',titlepic='".addslashes($add[titlepic])."',newstime='$newstime' where id='$add[id]' limit 1");
  808. //副表
  809. $fsql=$empire->query("update ".$infotbr['datatbname']." set classid='$add[classid]',closepl='$add[closepl]'".$ret_r[datavalues]." where id='$add[id]' limit 1");
  810. //更新附件
  811. UpdateTheFileEdit($add['classid'],$add['id'],$checkr['fstb']);
  812. //是否改变审核状态
  813. if($index_checkr['checked']!=$newchecked)
  814. {
  815. MoveCheckInfoData($class_r[$add[classid]][tbname],$index_checkr['checked'],$checkr['stb'],"id='$add[id]'");
  816. //更新栏目信息数
  817. if($newchecked)
  818. {
  819. AddClassInfos($add['classid'],'','+1');
  820. }
  821. else
  822. {
  823. AddClassInfos($add['classid'],'','-1');
  824. }
  825. }
  826. //处理函数
  827. DoMFun($class_r[$add['classid']]['modid'],$add['classid'],$add['id'],0,0);
  828. //生成文件
  829. if($ccr['addreinfo']&&$newchecked)
  830. {
  831. GetHtml($add['classid'],$add['id'],'',0);
  832. }
  833. //生成上一篇
  834. $epreid=0;
  835. if($ccr['repreinfo']&&($newchecked||$newchecked<>$add[oldchecked]))
  836. {
  837. $prer=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$add[classid]][tbname]." where id<$add[id] and classid='$add[classid]' order by id desc limit 1");
  838. $epreid=$prer['id'];
  839. GetHtml($prer['classid'],$prer['id'],$prer,1);
  840. }
  841. //生成栏目
  842. if($ccr['haddlist']&&($newchecked||$newchecked<>$add[oldchecked]))
  843. {
  844. hAddListHtml($add[classid],$ccr['modid'],$ccr['haddlist'],$ccr['listdt']);//生成信息列表
  845. }
  846. //同时更新
  847. if($pubcheckr['copyids']&&$pubcheckr['copyids']<>'1')
  848. {
  849. EditInfoToCopyInfo($add[classid],$add[id],$userid,$username,$doselfinfo);
  850. }
  851. //更新动态缓存
  852. if($public_r['ctimeopen']&&($newchecked||$newchecked<>$add[oldchecked]))
  853. {
  854. eUpCacheInfo(1,$add['classid'],0,$epreid,$add['ttid'],'','',0,$checkr['ttid']);
  855. }
  856. if($sql)
  857. {
  858. //返回地址
  859. if($add['ecmsfrom']&&(stristr($add['ecmsfrom'],'ListNews.php')||stristr($add['ecmsfrom'],'ListAllInfo.php')))
  860. {
  861. $ecmsfrom=$add['ecmsfrom'];
  862. }
  863. else
  864. {
  865. $ecmsfrom="ListNews.php?bclassid=$add[bclassid]&classid=$add[classid]".hReturnEcmsHashStrHref2(0);
  866. }
  867. $ecmsfrom=$ecmsfrom.$addecmscheck;
  868. insert_dolog("classid=$add[classid]<br>id=".$add[id]."<br>title=".$add[title],$pubid);//操作日志
  869. printerror("EditNewsSuccess",$closeurl,8);
  870. }
  871. else
  872. {
  873. printerror("DbError","history.go(-1)",8);
  874. }
  875. }
  876. //删除信息
  877. function DelNews($id,$classid,$userid,$username){
  878. global $empire,$class_r,$class_zr,$bclassid,$public_r,$dbtbpre,$emod_r,$adddatar;
  879. $id=(int)$id;
  880. $classid=(int)$classid;
  881. if(!$id||!$classid)
  882. {
  883. printerror("NotDelNewsid","history.go(-1)");
  884. }
  885. $doselfinfo=CheckLevel($userid,$username,$classid,"news");//操作权限
  886. if(!$doselfinfo['dodelinfo'])//删除权限
  887. {
  888. printerror("NotDelInfoLevel","history.go(-1)");
  889. }
  890. $ccr=$empire->fetch1("select classid,modid,listdt,haddlist,repreinfo from {$dbtbpre}enewsclass where classid='$classid' limit 1");
  891. if(!$ccr['classid'])
  892. {
  893. printerror("ErrorUrl","history.go(-1)");
  894. }
  895. //索引表
  896. $index_r=$empire->fetch1("select classid,checked from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index where id='$id' limit 1");
  897. if(!$index_r[classid]||$index_r[classid]!=$classid)
  898. {
  899. printerror("ErrorUrl","history.go(-1)");
  900. }
  901. //返回表
  902. $infotb=ReturnInfoMainTbname($class_r[$classid][tbname],$index_r['checked']);
  903. $r=$empire->fetch1("select * from ".$infotb." where id='$id' limit 1");
  904. if($doselfinfo['doselfinfo']&&($r[userid]<>$userid||$r[ismember]))//只能编辑自己的信息
  905. {
  906. printerror("NotDoSelfinfo","history.go(-1)");
  907. }
  908. $pubid=ReturnInfoPubid($classid,$id);
  909. $pubcheckr=$empire->fetch1("select copyids from {$dbtbpre}enewsinfovote where pubid='$pubid' limit 1");
  910. //附加链接参数
  911. $addecmscheck=empty($index_r['checked'])?'&ecmscheck=1':'';
  912. $mid=$class_r[$classid][modid];
  913. $tbname=$class_r[$classid][tbname];
  914. $pf=$emod_r[$mid]['pagef'];
  915. $stf=$emod_r[$mid]['savetxtf'];
  916. //返回表信息
  917. $infotbr=ReturnInfoTbname($class_r[$classid][tbname],$index_r['checked'],$r['stb']);
  918. //分页字段
  919. if($pf)
  920. {
  921. if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
  922. {
  923. $finfor=$empire->fetch1("select ".$pf." from ".$infotbr['datatbname']." where id='$id' limit 1");
  924. $r[$pf]=$finfor[$pf];
  925. }
  926. }
  927. //存文本
  928. if($stf)
  929. {
  930. $newstextfile=$r[$stf];
  931. $r[$stf]=GetTxtFieldText($r[$stf]);
  932. DelTxtFieldText($newstextfile);//删除文件
  933. }
  934. DelNewsFile($r[filename],$r[newspath],$classid,$r[$pf],$r[groupid]);//删除信息文件
  935. $sql=$empire->query("delete from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index where id='$id'");
  936. $sql=$empire->query("delete from ".$infotbr['tbname']." where id='$id'");
  937. $fsql=$empire->query("delete from ".$infotbr['datatbname']." where id='$id'");
  938. //更新栏目信息数
  939. AddClassInfos($classid,'-1','-1',$index_r['checked']);
  940. //删除其它表记录和附件
  941. DelSingleInfoOtherData($r['classid'],$id,$r,0,0);
  942. $epreid=0;
  943. $epreid2=0;
  944. if($index_r['checked'])
  945. {
  946. //生成上一篇
  947. if($ccr['repreinfo'])
  948. {
  949. $prer=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id<$id and classid='$classid' order by id desc limit 1");
  950. $epreid=$prer['id'];
  951. GetHtml($prer['classid'],$prer['id'],$prer,1);
  952. //下一篇
  953. $nextr=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id>$id and classid='$classid' order by id limit 1");
  954. if($nextr['id'])
  955. {
  956. $epreid2=$nextr['id'];
  957. GetHtml($nextr['classid'],$nextr['id'],$nextr,1);
  958. }
  959. }
  960. hAddListHtml($classid,$ccr['modid'],$ccr['haddlist'],$ccr['listdt']);//生成信息列表
  961. if($r['ttid'])//如果是标题分类
  962. {
  963. ListHtml($r['ttid'],'',5);
  964. }
  965. }
  966. //同步删除
  967. if($pubcheckr['copyids']&&$pubcheckr['copyids']<>'1')
  968. {
  969. DelInfoToCopyInfo($classid,$id,$r,$userid,$username,$doselfinfo,$pubcheckr['copyids']);
  970. }
  971. //更新动态缓存
  972. if($public_r['ctimeopen']&&$index_r['checked'])
  973. {
  974. eUpCacheInfo(1,$classid,$epreid2,$epreid,$r['ttid'],'','',0,0);
  975. }
  976. if($sql)
  977. {
  978. $returl=EcmsGetReturnUrl();
  979. //发送通知
  980. if($adddatar['causetext'])
  981. {
  982. DoInfoSendNotice($userid,$username,$r['userid'],$r['username'],$adddatar['causetext'],$r,1);
  983. if($adddatar['ecmsfrom']&&(stristr($adddatar['ecmsfrom'],'ListNews.php')||stristr($adddatar['ecmsfrom'],'ListAllInfo.php')))
  984. {
  985. $returl=$adddatar['ecmsfrom'];
  986. }
  987. else
  988. {
  989. $returl="ListNews.php?bclassid=$adddatar[bclassid]&classid=$adddatar[classid]".$addecmscheck.hReturnEcmsHashStrHref2(0);
  990. }
  991. }
  992. else
  993. {
  994. if($_POST['enews']=='DoInfoAndSendNotice')
  995. {
  996. $returl="ListNews.php?bclassid=$adddatar[bclassid]&classid=$adddatar[classid]".$addecmscheck.hReturnEcmsHashStrHref2(0);
  997. }
  998. }
  999. insert_dolog("classid=$classid<br>id=".$id."<br>title=".$r[title],$pubid);//操作日志
  1000. printerror("DelNewsSuccess",$returl);
  1001. }
  1002. else
  1003. {
  1004. printerror("ErrorUrl","history.go(-1)");
  1005. }
  1006. }
  1007. //批量删除信息
  1008. function DelNews_all($id,$classid,$userid,$username,$ecms=0){
  1009. global $empire,$class_r,$class_zr,$public_r,$dbtbpre,$emod_r;
  1010. $classid=(int)$classid;
  1011. $count=count($id);
  1012. if(!$count)
  1013. {
  1014. printerror("NotDelNewsid","history.go(-1)");
  1015. }
  1016. $doselfinfo=CheckLevel($userid,$username,$classid,"news");//操作权限
  1017. if(!$doselfinfo['dodelinfo'])//删除权限
  1018. {
  1019. printerror("NotDelInfoLevel","history.go(-1)");
  1020. }
  1021. $dopubid=0;
  1022. $mid=$class_r[$classid][modid];
  1023. $tbname=$class_r[$classid][tbname];
  1024. $pf=$emod_r[$mid]['pagef'];
  1025. $stf=$emod_r[$mid]['savetxtf'];
  1026. if($ecms==1)
  1027. {
  1028. $doctb="_doc";
  1029. }
  1030. elseif($ecms==2)
  1031. {
  1032. $doctb="_check";
  1033. }
  1034. for($i=0;$i<$count;$i++)
  1035. {
  1036. $add.="id='".intval($id[$i])."' or ";
  1037. }
  1038. $donum=0;
  1039. $dolog='';
  1040. $add=substr($add,0,strlen($add)-4);
  1041. for($i=0;$i<$count;$i++)//删除信息文件
  1042. {
  1043. $id[$i]=intval($id[$i]);
  1044. $r=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname.$doctb." where id='$id[$i]'");
  1045. if($doselfinfo['doselfinfo']&&($r[userid]<>$userid||$r[ismember]))//只能编辑自己的信息
  1046. {
  1047. $add=str_replace("id='".$id[$i]."'","id='0'",$add);
  1048. continue;
  1049. }
  1050. $donum++;
  1051. if($donum==1)
  1052. {
  1053. $dopubid=ReturnInfoPubid($r['classid'],$id[$i]);
  1054. $dolog="classid=".$r['classid']."<br>id=".$r['id']."&ecms=$ecms<br>title=".$r['title'];
  1055. }
  1056. //分页字段
  1057. if($pf)
  1058. {
  1059. if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
  1060. {
  1061. if($ecms==1)
  1062. {
  1063. $finfor=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_doc_data where id='$id[$i]'");
  1064. }
  1065. elseif($ecms==2)
  1066. {
  1067. $finfor=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_check_data where id='$id[$i]'");
  1068. }
  1069. else
  1070. {
  1071. $finfor=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$id[$i]'");
  1072. }
  1073. $r[$pf]=$finfor[$pf];
  1074. }
  1075. }
  1076. //存文本
  1077. if($stf)
  1078. {
  1079. $newstextfile=$r[$stf];
  1080. $r[$stf]=GetTxtFieldText($r[$stf]);
  1081. DelTxtFieldText($newstextfile);//删除文件
  1082. }
  1083. DelNewsFile($r[filename],$r[newspath],$r[classid],$r[$pf],$r[groupid]);
  1084. //删除副表
  1085. if($ecms==0)
  1086. {
  1087. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$id[$i]'");
  1088. }
  1089. //删除其它表记录和附件
  1090. DelSingleInfoOtherData($r['classid'],$id[$i],$r,0,0);
  1091. //更新动态缓存
  1092. if($public_r['ctimeopen']&&$ecms==0)
  1093. {
  1094. eUpCacheInfo(1,$r['classid'],0,0,$r['ttid'],'','',0,0,1);
  1095. }
  1096. //更新栏目信息数
  1097. if($ecms==0||$ecms==2)
  1098. {
  1099. AddClassInfos($r['classid'],'-1','-1',$ecms==2?0:1);
  1100. }
  1101. }
  1102. //删除信息
  1103. $sql=$empire->query("delete from {$dbtbpre}ecms_".$tbname.$doctb." where ".$add);
  1104. if($ecms==0)
  1105. {
  1106. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_index where ".$add);
  1107. $ccr=$empire->fetch1("select classid,modid,listdt,haddlist from {$dbtbpre}enewsclass where classid='$classid'");
  1108. hAddListHtml($classid,$ccr['modid'],$ccr['haddlist'],$ccr['listdt']);//生成信息列表
  1109. }
  1110. elseif($ecms==1)
  1111. {
  1112. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_doc_index where ".$add);
  1113. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_doc_data where ".$add);
  1114. }
  1115. elseif($ecms==2)
  1116. {
  1117. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_index where ".$add);
  1118. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_check_data where ".$add);
  1119. }
  1120. if($sql)
  1121. {
  1122. //操作日志
  1123. if($donum==1)
  1124. {
  1125. insert_dolog($dolog,$dopubid);
  1126. }
  1127. else
  1128. {
  1129. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]."&ecms=$ecms");
  1130. }
  1131. printerror("DelNewsAllSuccess",EcmsGetReturnUrl());
  1132. }
  1133. else
  1134. {
  1135. printerror("DbError","history.go(-1)");
  1136. }
  1137. }
  1138. //批量修改发布时间
  1139. function EditMoreInfoTime($add,$userid,$username){
  1140. global $empire,$dbtbpre,$class_r,$public_r;
  1141. $classid=(int)$add['classid'];
  1142. $infoid=$add['infoid'];
  1143. $newstime=$add['newstime'];
  1144. $count=count($infoid);
  1145. $tbname=$class_r[$classid]['tbname'];
  1146. if(!$classid||!$tbname||!$count)
  1147. {
  1148. printerror('EmptyMoreInfoTime','');
  1149. }
  1150. //操作权限
  1151. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  1152. if(!$doselfinfo['doeditinfo'])//编辑权限
  1153. {
  1154. printerror('NotEditInfoLevel','history.go(-1)');
  1155. }
  1156. $dopubid=0;
  1157. $donum=0;
  1158. $dolog='';
  1159. //主表
  1160. $infotb='';
  1161. for($i=0;$i<$count;$i++)
  1162. {
  1163. $doinfoid=(int)$infoid[$i];
  1164. if(empty($infotb))
  1165. {
  1166. //索引表
  1167. $index_r=$empire->fetch1("select classid,checked from {$dbtbpre}ecms_".$tbname."_index where id='$doinfoid' limit 1");
  1168. if(!$index_r['classid'])
  1169. {
  1170. continue;
  1171. }
  1172. //返回表
  1173. $infotb=ReturnInfoMainTbname($tbname,$index_r['checked']);
  1174. }
  1175. $donum++;
  1176. if($donum==1)
  1177. {
  1178. $dopubid=ReturnInfoPubid($classid,$doinfoid);
  1179. $dolog="classid=".$classid."<br>classname=".$class_r[$classid][classname]."<br>id=".$doinfoid;
  1180. }
  1181. $donewstime=$newstime[$i]?to_time($newstime[$i]):time();
  1182. $empire->query("update {$dbtbpre}ecms_".$tbname."_index set newstime='$donewstime' where id='$doinfoid'");
  1183. $empire->query("update ".$infotb." set newstime='$donewstime' where id='$doinfoid'");
  1184. }
  1185. //更新动态缓存
  1186. if($public_r['ctimeopen']&&$index_r['checked'])
  1187. {
  1188. eUpCacheInfo(1,$classid,0,0,0,'','',0,0);
  1189. }
  1190. //操作日志
  1191. if($donum==1)
  1192. {
  1193. insert_dolog($dolog,$dopubid);
  1194. }
  1195. else
  1196. {
  1197. insert_dolog("classid=$classid<br>classname=".$class_r[$classid][classname]);
  1198. }
  1199. printerror('EditMoreInfoTimeSuccess',EcmsGetReturnUrl());
  1200. }
  1201. //刷新页面
  1202. function AddInfoToReHtml($classid,$dore){
  1203. global $class_r;
  1204. $classid=(int)$classid;
  1205. $dore=RepPostVar($dore);
  1206. hAddListHtml($classid,$class_r[$classid]['modid'],$dore,$class_r[$classid]['listdt']);//生成信息列表
  1207. insert_dolog("classid=".$classid."<br>do=".$dore);//操作日志
  1208. printerror('AddInfoToReHtmlSuccess','history.go(-1)');
  1209. }
  1210. //增加信息生成页面
  1211. function hAddListHtml($classid,$mid,$qaddlist,$listdt){
  1212. global $class_r;
  1213. if($qaddlist==0)//不生成
  1214. {
  1215. return "";
  1216. }
  1217. elseif($qaddlist==1)//生成当前栏目
  1218. {
  1219. if(!$listdt)
  1220. {
  1221. $sonclass="|".$classid."|";
  1222. hReClassHtml($sonclass);
  1223. }
  1224. }
  1225. elseif($qaddlist==2)//生成首页
  1226. {
  1227. hReIndex();
  1228. }
  1229. elseif($qaddlist==3)//生成父栏目
  1230. {
  1231. $featherclass=$class_r[$classid]['featherclass'];
  1232. if($featherclass&&$featherclass!="|")
  1233. {
  1234. hReClassHtml($featherclass);
  1235. }
  1236. }
  1237. elseif($qaddlist==4)//生成当前栏目与父栏目
  1238. {
  1239. $featherclass=$class_r[$classid]['featherclass'];
  1240. if(empty($featherclass))
  1241. {
  1242. $featherclass="|";
  1243. }
  1244. if(!$listdt)
  1245. {
  1246. $featherclass.=$classid."|";
  1247. }
  1248. hReClassHtml($featherclass);
  1249. }
  1250. elseif($qaddlist==5)//生成父栏目与首页
  1251. {
  1252. hReIndex();
  1253. $featherclass=$class_r[$classid]['featherclass'];
  1254. if($featherclass&&$featherclass!="|")
  1255. {
  1256. hReClassHtml($featherclass);
  1257. }
  1258. }
  1259. elseif($qaddlist==6)//生成当前栏目、父栏目与首页
  1260. {
  1261. hReIndex();
  1262. $featherclass=$class_r[$classid]['featherclass'];
  1263. if(empty($featherclass))
  1264. {
  1265. $featherclass="|";
  1266. }
  1267. if(!$listdt)
  1268. {
  1269. $featherclass.=$classid."|";
  1270. }
  1271. hReClassHtml($featherclass);
  1272. }
  1273. }
  1274. //增加信息生成栏目
  1275. function hReClassHtml($sonclass){
  1276. global $empire,$dbtbpre,$class_r;
  1277. $r=explode("|",$sonclass);
  1278. $count=count($r);
  1279. for($i=1;$i<$count-1;$i++)
  1280. {
  1281. //终极栏目
  1282. if($class_r[$r[$i]]['islast'])
  1283. {
  1284. if(!$class_r[$r[$i]]['listdt'])
  1285. {
  1286. ListHtml($r[$i],'',0,$userlistr);
  1287. }
  1288. }
  1289. elseif($class_r[$r[$i]]['islist']==1)//列表式父栏目
  1290. {
  1291. if(!$class_r[$r[$i]]['listdt'])
  1292. {
  1293. ListHtml($r[$i],'',3);
  1294. }
  1295. }
  1296. elseif($class_r[$r[$i]]['islist']==3)//栏目绑定信息
  1297. {
  1298. ReClassBdInfo($r[$i]);
  1299. }
  1300. else//父栏目
  1301. {
  1302. $cr=$empire->fetch1("select classtempid from {$dbtbpre}enewsclass where classid='$r[$i]'");
  1303. $classtemp=$class_r[$r[$i]]['islist']==2?GetClassText($r[$i]):GetClassTemp($cr['classtempid']);
  1304. NewsBq($r[$i],$classtemp,0,0);
  1305. }
  1306. }
  1307. }
  1308. //增加信息生成首页
  1309. function hReIndex(){
  1310. $indextemp=GetIndextemp();
  1311. NewsBq($classid,$indextemp,1,0);
  1312. }
  1313. //发布同时复制
  1314. function AddInfoToCopyInfo($classid,$id,$to_classid,$userid,$username,$usergroupr){
  1315. global $empire,$public_r,$class_r,$dbtbpre,$emod_r,$lur;
  1316. $classid=(int)$classid;
  1317. $id=(int)$id;
  1318. $cr=$to_classid;
  1319. $count=count($cr);
  1320. if(empty($classid)||empty($id)||empty($count))
  1321. {
  1322. return '';
  1323. }
  1324. $mid=$class_r[$classid][modid];
  1325. $tbname=$class_r[$classid][tbname];
  1326. $stf=$emod_r[$mid]['savetxtf'];
  1327. //索引表
  1328. $index_r=$empire->fetch1("select id,checked from {$dbtbpre}ecms_".$tbname."_index where id='$id' limit 1");
  1329. if(empty($index_r['id']))
  1330. {
  1331. return '';
  1332. }
  1333. //返回表
  1334. $infotb=ReturnInfoMainTbname($tbname,$index_r['checked']);
  1335. //主表
  1336. $r=$empire->fetch1("select * from ".$infotb." where id='$id'");
  1337. //返回表信息
  1338. $infotbr=ReturnInfoTbname($tbname,$index_r['checked'],$r['stb']);
  1339. //副表
  1340. $fr=$empire->fetch1("select ".ReturnSqlFtextF($mid)." from ".$infotbr['datatbname']." where id='$id' limit 1");
  1341. $r=array_merge($r,$fr);
  1342. if($stf)//存放文本
  1343. {
  1344. $r[newstext_url]=$r[$stf];
  1345. $r[$stf]=GetTxtFieldText($r[$stf]);
  1346. }
  1347. //返回信息地址
  1348. $copyinfourl=0;
  1349. if($_POST['copyinfotitleurl']&&!$r['isurl'])
  1350. {
  1351. $r['titleurl']=sys_ReturnBqTitleLink($r);
  1352. $r['isurl']=1;
  1353. $copyinfourl=1;
  1354. }
  1355. $userisqf=EcmsReturnDoIsqf($userid,$username,$lur['groupid'],0);
  1356. $ids=',';
  1357. for($i=0;$i<$count;$i++)
  1358. {
  1359. $newclassid=(int)$cr[$i];
  1360. //发布权限
  1361. if(empty($usergroupr['doall'])&&!strstr($usergroupr['add_adminclass'],'|'.$newclassid.'|'))
  1362. {
  1363. continue;
  1364. }
  1365. if(!$newclassid||!$class_r[$newclassid][islast]||$mid<>$class_r[$newclassid][modid]||$newclassid==$classid)
  1366. {
  1367. continue;
  1368. }
  1369. //查看目录是否存在,不存在则建立
  1370. $newspath=FormatPath($newclassid,"",0);
  1371. $newstempid=0;
  1372. $copyids='1';
  1373. //返回自定义字段
  1374. $ret_r=ReturnAddF($r,$mid,$userid,$username,9,1,0);
  1375. if($class_r[$newclassid][wfid])
  1376. {
  1377. if($userisqf)
  1378. {
  1379. $checked=$class_r[$newclassid][checked];
  1380. $isqf=0;
  1381. }
  1382. else
  1383. {
  1384. $checked=0;
  1385. $isqf=1;
  1386. }
  1387. }
  1388. else
  1389. {
  1390. $checked=$class_r[$newclassid][checked];
  1391. $isqf=0;
  1392. }
  1393. //必须审核
  1394. if($usergroupr['domustcheck'])
  1395. {
  1396. $checked=0;
  1397. }
  1398. $checked=(int)$checked;
  1399. //索引表
  1400. $empire->query("insert into {$dbtbpre}ecms_".$tbname."_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('$newclassid','$checked','$r[newstime]','$r[truetime]','$r[truetime]','$r[havehtml]');");
  1401. $l_id=$empire->lastid();
  1402. $infotbr=ReturnInfoTbname($tbname,$checked,$ret_r['tb']);
  1403. //主表
  1404. $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".$ret_r[fields].") values('$l_id','$newclassid','$r[ttid]',0,0,0,'$newspath','$filename','$r[userid]','".StripAddsData($r[username])."',0,0,'$r[ispic]',0,'$isqf',0,'$r[isurl]','$r[truetime]',$r[truetime],$r[havehtml],$r[groupid],$r[userfen],'".StripAddsData($r[titlefont])."','".StripAddsData($r[titleurl])."','$ret_r[tb]','$public_r[filedeftb]','$public_r[pldeftb]','".StripAddsData($r[keyboard])."'".$ret_r[values].");");
  1405. //副表
  1406. $empire->query("insert into ".$infotbr['datatbname']."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$ret_r[datafields].") values('$l_id','$newclassid','$r[keyid]',$r[dokey],'".$newstempid."',$r[closepl],0,''".$ret_r[datavalues].");");
  1407. //公共表
  1408. UpdateInfoCopyids($newclassid,$l_id,$copyids);
  1409. //更新栏目信息数
  1410. AddClassInfos($newclassid,'+1','+1',$checked);
  1411. //更新新信息数
  1412. DoUpdateAddDataNum('info',$class_r[$newclassid]['tid'],1);
  1413. //签发
  1414. if($isqf==1)
  1415. {
  1416. InfoInsertToWorkflow($l_id,$newclassid,$class_r[$newclassid][wfid],$userid,$username);
  1417. }
  1418. //文件命名
  1419. $filename=ReturnInfoFilename($newclassid,$l_id,$r[filenameqz]);
  1420. //信息地址
  1421. $updateinfourl='';
  1422. if(!$copyinfourl)
  1423. {
  1424. $infourl=GotoGetTitleUrl($newclassid,$l_id,$newspath,$filename,$r['groupid'],$r['isurl'],$r['titleurl']);
  1425. $updateinfourl=",titleurl='$infourl'";
  1426. }
  1427. $empire->query("update ".$infotbr['tbname']." set filename='$filename'".$updateinfourl." where id='$l_id' limit 1");
  1428. //处理函数
  1429. DoMFun($class_r[$newclassid]['modid'],$newclassid,$l_id,1,0);
  1430. //生成信息文件
  1431. if($checked)
  1432. {
  1433. $addr=$empire->fetch1("select * from ".$infotbr['tbname']." where id='$l_id' limit 1");
  1434. GetHtml($addr['classid'],$addr['id'],$addr,1);
  1435. }
  1436. $ids.=$l_id.',';
  1437. //更新动态缓存
  1438. if($public_r['ctimeopen']&&$checked)
  1439. {
  1440. eUpCacheInfo(1,$newclassid,0,0,0,'','',0,0,1);
  1441. }
  1442. }
  1443. if($ids==',')
  1444. {
  1445. $ids='';
  1446. }
  1447. return $ids;
  1448. }
  1449. //发布同步修改
  1450. function EditInfoToCopyInfo($classid,$id,$userid,$username,$usergroupr){
  1451. global $empire,$public_r,$class_r,$dbtbpre,$emod_r;
  1452. $classid=(int)$classid;
  1453. $id=(int)$id;
  1454. if(empty($classid)||empty($id))
  1455. {
  1456. return '';
  1457. }
  1458. $mid=$class_r[$classid][modid];
  1459. $tbname=$class_r[$classid][tbname];
  1460. $stf=$emod_r[$mid]['savetxtf'];
  1461. //公共表
  1462. $pubid=ReturnInfoPubid($classid,$id);
  1463. $pub_r=$empire->fetch1("select copyids from {$dbtbpre}enewsinfovote where pubid='$pubid'");
  1464. $cr=explode(',',$pub_r['copyids']);
  1465. $count=count($cr);
  1466. if($count<3)
  1467. {
  1468. return '';
  1469. }
  1470. //索引表
  1471. $index_r=$empire->fetch1("select id,checked from {$dbtbpre}ecms_".$tbname."_index where id='$id' limit 1");
  1472. //返回表
  1473. $infotb=ReturnInfoMainTbname($tbname,$index_r['checked']);
  1474. //主表
  1475. $r=$empire->fetch1("select * from ".$infotb." where id='$id' limit 1");
  1476. //返回表信息
  1477. $infotbr=ReturnInfoTbname($tbname,$index_r['checked'],$r['stb']);
  1478. //副表
  1479. $fr=$empire->fetch1("select ".ReturnSqlFtextF($mid)." from ".$infotbr['datatbname']." where id='$id' limit 1");
  1480. $r=array_merge($r,$fr);
  1481. if($stf)//存放文本
  1482. {
  1483. $r[newstext_url]=$r[$stf];
  1484. $r[$stf]=GetTxtFieldText($r[$stf]);
  1485. }
  1486. //信息链接地址
  1487. $titleurl=sys_ReturnBqTitleLink($r);
  1488. for($i=1;$i<$count-1;$i++)
  1489. {
  1490. $infoid=(int)$cr[$i];
  1491. if(empty($infoid))
  1492. {
  1493. continue;
  1494. }
  1495. //索引表
  1496. $index_infor=$empire->fetch1("select classid,checked from {$dbtbpre}ecms_".$tbname."_index where id='$infoid' limit 1");
  1497. //返回表
  1498. $update_infotb=ReturnInfoMainTbname($tbname,$index_infor['checked']);
  1499. if($stf)
  1500. {
  1501. if(strstr($emod_r[$mid]['tbdataf'],','.$stf.','))
  1502. {
  1503. $infor=$empire->fetch1("select stb,isurl,newspath,filename from ".$update_infotb." where id='$infoid' limit 1");
  1504. if(!$infor[stb])
  1505. {
  1506. continue;
  1507. }
  1508. //返回表信息
  1509. $update_infotbr=ReturnInfoTbname($tbname,$index_infor['checked'],$infor['stb']);
  1510. $infodr=$empire->fetch1("select ".$stf." from ".$update_infotbr['datatbname']." where id='$infoid' limit 1");
  1511. $r[newstext_url]=$infodr[$stf];
  1512. }
  1513. else
  1514. {
  1515. $infor=$empire->fetch1("select ".$stf.",stb,isurl,newspath,filename from ".$update_infotb." where id='$infoid' limit 1");
  1516. if(!$infor[stb])
  1517. {
  1518. continue;
  1519. }
  1520. $r[newstext_url]=$infor[$stf];
  1521. }
  1522. }
  1523. else
  1524. {
  1525. $infor=$empire->fetch1("select stb,isurl,newspath,filename from ".$update_infotb." where id='$infoid' limit 1");
  1526. if(!$infor[stb])
  1527. {
  1528. continue;
  1529. }
  1530. }
  1531. if($infor['isurl'])
  1532. {
  1533. $r['titleurl']=$titleurl;
  1534. $r['isurl']=1;
  1535. }
  1536. else
  1537. {
  1538. //信息地址
  1539. $infourl=GotoGetTitleUrl($index_infor['classid'],$infoid,$infor['newspath'],$infor['filename'],$r['groupid'],$infor['isurl'],$r['titleurl']);
  1540. $r['titleurl']=$infourl;
  1541. }
  1542. //返回自定义字段
  1543. $ret_r=ReturnAddF($r,$mid,$userid,$username,8,1,0);
  1544. //返回表信息
  1545. $update_infotbr=ReturnInfoTbname($tbname,$index_infor['checked'],$infor['stb']);
  1546. //索引表
  1547. $empire->query("update {$dbtbpre}ecms_".$tbname."_index set checked='$index_r[checked]',newstime='$r[newstime]',lastdotime='$r[lastdotime]' where id='$infoid'");
  1548. //主表
  1549. $empire->query("update ".$update_infotb." set ttid='$r[ttid]',ispic='$r[ispic]',isurl='$r[isurl]',lastdotime=$r[lastdotime],groupid=$r[groupid],userfen=$r[userfen],titlefont='".StripAddsData($r[titlefont])."',titleurl='".StripAddsData($r[titleurl])."',keyboard='".StripAddsData($r[keyboard])."'".$ret_r[values]." where id='$infoid'");
  1550. //副表
  1551. $empire->query("update ".$update_infotbr['datatbname']." set keyid='$r[keyid]',dokey=$r[dokey],closepl=$r[closepl]".$ret_r[datavalues]." where id='$infoid'");
  1552. //是否改变审核状态
  1553. if($index_infor['checked']!=$index_r['checked'])
  1554. {
  1555. MoveCheckInfoData($tbname,$index_infor['checked'],$infor['stb'],"id='$infoid'");
  1556. //更新栏目信息数
  1557. if($index_r['checked'])
  1558. {
  1559. AddClassInfos($index_infor['classid'],'','+1');
  1560. }
  1561. else
  1562. {
  1563. AddClassInfos($index_infor['classid'],'','-1');
  1564. }
  1565. }
  1566. //处理函数
  1567. DoMFun($class_r[$index_infor['classid']]['modid'],$index_infor['classid'],$infoid,0,0);
  1568. if($index_r['checked'])
  1569. {
  1570. //生成信息文件
  1571. $addr=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$infoid' limit 1");
  1572. GetHtml($addr['classid'],$addr['id'],$addr,1);
  1573. }
  1574. //更新动态缓存
  1575. if($public_r['ctimeopen']&&$index_r['checked'])
  1576. {
  1577. eUpCacheInfo(1,$index_infor['classid'],0,0,0,'','',0,0,1);
  1578. }
  1579. }
  1580. }
  1581. //发布同步删除
  1582. function DelInfoToCopyInfo($classid,$id,$r,$userid,$username,$usergroupr,$pubcopyids){
  1583. global $empire,$public_r,$class_r,$dbtbpre,$emod_r;
  1584. $classid=(int)$classid;
  1585. $id=(int)$id;
  1586. if(empty($classid)||empty($id))
  1587. {
  1588. return '';
  1589. }
  1590. $mid=$class_r[$classid][modid];
  1591. $tbname=$class_r[$classid][tbname];
  1592. $stf=$emod_r[$mid]['savetxtf'];
  1593. //公共表
  1594. $pubid=ReturnInfoPubid($classid,$id);
  1595. //$pub_r=$empire->fetch1("select copyids from {$dbtbpre}enewsinfovote where pubid='$pubid'");
  1596. $cr=explode(',',$pubcopyids);
  1597. $count=count($cr);
  1598. if(empty($r['id'])||$count<3)
  1599. {
  1600. return '';
  1601. }
  1602. $selectdataf='';
  1603. $dh='';
  1604. if($stf&&strstr($emod_r[$mid]['tbdataf'],','.$stf.','))
  1605. {
  1606. $selectdataf.=$stf;
  1607. $dh=',';
  1608. }
  1609. $pf=$emod_r[$mid]['pagef'];
  1610. if($pf&&strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
  1611. {
  1612. $selectdataf.=$dh.$pf;
  1613. }
  1614. for($i=1;$i<$count-1;$i++)
  1615. {
  1616. $infoid=(int)$cr[$i];
  1617. if(empty($infoid))
  1618. {
  1619. continue;
  1620. }
  1621. //索引表
  1622. $index_infor=$empire->fetch1("select checked from {$dbtbpre}ecms_".$tbname."_index where id='$infoid' limit 1");
  1623. //返回表
  1624. $update_infotb=ReturnInfoMainTbname($tbname,$index_infor['checked']);
  1625. //主表
  1626. $infor=$empire->fetch1("select * from ".$update_infotb." where id='$infoid' limit 1");
  1627. if(!$infor[stb])
  1628. {
  1629. continue;
  1630. }
  1631. //返回表信息
  1632. $update_infotbr=ReturnInfoTbname($tbname,$index_infor['checked'],$infor['stb']);
  1633. if($selectdataf)
  1634. {
  1635. $infodr=$empire->fetch1("select ".$selectdataf." from ".$update_infotbr['datatbname']." where id='$infoid' limit 1");
  1636. $infor=array_merge($infor,$infodr);
  1637. }
  1638. //存文本
  1639. if($stf)
  1640. {
  1641. $newstextfile=$infor[$stf];
  1642. $infor[$stf]=GetTxtFieldText($infor[$stf]);
  1643. DelTxtFieldText($newstextfile);//删除文件
  1644. }
  1645. DelNewsFile($infor[filename],$infor[newspath],$infor[classid],$infor[$pf],$infor[groupid]);//删除信息文件
  1646. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_index where id='$infoid'");
  1647. $empire->query("delete from ".$update_infotbr['tbname']." where id='$infoid'");
  1648. $empire->query("delete from ".$update_infotbr['datatbname']." where id='$infoid'");
  1649. //更新栏目信息数
  1650. AddClassInfos($infor['classid'],'-1','-1',$index_infor['checked']);
  1651. //删除其它表记录与附件
  1652. DelSingleInfoOtherData($infor['classid'],$infoid,$infor,0,0);
  1653. //更新动态缓存
  1654. if($public_r['ctimeopen']&&$index_infor['checked'])
  1655. {
  1656. eUpCacheInfo(1,$infor['classid'],0,0,0,'','',0,0,1);
  1657. }
  1658. }
  1659. }
  1660. //信息置顶
  1661. function TopNews_all($classid,$id,$istop,$userid,$username){
  1662. global $empire,$bclassid,$class_r,$dbtbpre,$public_r;
  1663. $classid=(int)$classid;
  1664. if(empty($classid))
  1665. {
  1666. printerror("ErrorUrl","history.go(-1)");
  1667. }
  1668. $doselfinfo=CheckLevel($userid,$username,$classid,"news");//验证权限
  1669. if(!$doselfinfo['dogoodinfo'])//权限
  1670. {
  1671. printerror("NotGoodInfoLevel","history.go(-1)");
  1672. }
  1673. $count=count($id);
  1674. if(empty($count))
  1675. {
  1676. printerror("NotTopNewsid","history.go(-1)");
  1677. }
  1678. $dopubid=0;
  1679. $donum=0;
  1680. $dolog='';
  1681. $infotb='';
  1682. for($i=0;$i<$count;$i++)
  1683. {
  1684. $infoid=(int)$id[$i];
  1685. $add.="id='".$infoid."' or ";
  1686. if($infoid&&empty($infotb))
  1687. {
  1688. $index_r=$empire->fetch1("select checked from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index where id='$infoid' limit 1");
  1689. //返回表
  1690. $infotb=ReturnInfoMainTbname($class_r[$classid][tbname],$index_r['checked']);
  1691. }
  1692. $donum++;
  1693. if($donum==1)
  1694. {
  1695. $dopubid=ReturnInfoPubid($classid,$infoid);
  1696. $dolog="classid=".$classid."<br>classname=".$class_r[$classid][classname]."<br>id=".$infoid;
  1697. }
  1698. }
  1699. if(empty($infotb))
  1700. {
  1701. printerror("NotTopNewsid","history.go(-1)");
  1702. }
  1703. $istop=(int)$istop;
  1704. $add=substr($add,0,strlen($add)-4);
  1705. $sql=$empire->query("update ".$infotb." set istop=$istop where ".$add);
  1706. if($index_r['checked'])
  1707. {
  1708. //刷新列表
  1709. ReListHtml($classid,1);
  1710. }
  1711. //更新动态缓存
  1712. if($public_r['ctimeopen']&&$index_r['checked'])
  1713. {
  1714. eUpCacheInfo(1,$classid,0,0,0,'','',0,0);
  1715. }
  1716. if($sql)
  1717. {
  1718. //操作日志
  1719. if($donum==1)
  1720. {
  1721. insert_dolog($dolog,$dopubid);
  1722. }
  1723. else
  1724. {
  1725. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]);
  1726. }
  1727. printerror("TopNewsSuccess",EcmsGetReturnUrl());
  1728. }
  1729. else
  1730. {printerror("DbError","history.go(-1)");}
  1731. }
  1732. //审核信息
  1733. function CheckNews_all($classid,$id,$userid,$username){
  1734. global $empire,$class_r,$dbtbpre,$emod_r,$adddatar,$public_r;
  1735. $classid=(int)$classid;
  1736. $userid=(int)$userid;
  1737. if(empty($classid))
  1738. {
  1739. printerror("ErrorUrl","history.go(-1)");
  1740. }
  1741. //验证权限
  1742. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  1743. //权限
  1744. if(!$doselfinfo['docheckinfo'])
  1745. {
  1746. printerror("NotCheckInfoLevel","history.go(-1)");
  1747. }
  1748. $count=count($id);
  1749. if(empty($count))
  1750. {
  1751. printerror("NotCheckNewsid","history.go(-1)");
  1752. }
  1753. $dopubid=0;
  1754. $donum=0;
  1755. $dolog='';
  1756. //附加链接参数
  1757. $addecmscheck=empty($_POST['ecmscheck'])?'&ecmscheck=1':'';
  1758. $add='';
  1759. for($i=0;$i<$count;$i++)
  1760. {
  1761. $infoid=(int)$id[$i];
  1762. if(empty($infoid))
  1763. {
  1764. continue;
  1765. }
  1766. $infor=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check where id='$infoid' limit 1");
  1767. if(!$infor['id']||$infor['isqf']==1)
  1768. {
  1769. continue;
  1770. }
  1771. $sql=$empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index set checked=1 where id='$infoid'");
  1772. //投稿增加积分
  1773. if($infor['ismember']&&$infor['userid'])
  1774. {
  1775. $cr=$empire->fetch1("select classid,addinfofen from {$dbtbpre}enewsclass where classid='$infor[classid]'");
  1776. if($cr['addinfofen'])
  1777. {
  1778. $finfor=$empire->fetch1("select haveaddfen from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check_data where id='$infoid' limit 1");
  1779. if(!$finfor['haveaddfen'])
  1780. {
  1781. AddInfoFen($cr[addinfofen],$infor[userid]);
  1782. if($cr['addinfofen']<0)
  1783. {
  1784. BakDown($infor[classid],$infor[id],0,$infor[userid],$infor[username],$infor[title],abs($cr[addinfofen]),3);
  1785. }
  1786. }
  1787. }
  1788. $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check_data set haveaddfen=1 where id='$infoid'");
  1789. }
  1790. //未审核表转换
  1791. MoveCheckInfoData($class_r[$classid][tbname],0,$infor['stb'],"id='$infoid'");
  1792. //审核人
  1793. if(!$infor['eckuid']&&($infor['ismember']||$infor['userid']!=$userid))
  1794. {
  1795. $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]." set eckuid='$userid' where id='$infoid'");
  1796. }
  1797. //更新栏目信息数
  1798. AddClassInfos($infor['classid'],'','+1');
  1799. //刷新信息
  1800. GetHtml($infor['classid'],$infor['id'],$infor,1);
  1801. //更新动态缓存
  1802. if($public_r['ctimeopen'])
  1803. {
  1804. eUpCacheInfo(1,$infor['classid'],0,0,$infor['ttid'],'',$infor['infotags'],0,0,1);
  1805. }
  1806. $donum++;
  1807. if($donum==1)
  1808. {
  1809. $dopubid=ReturnInfoPubid($infor['classid'],$infor['id']);
  1810. $dolog="classid=".$infor['classid']."<br>id=".$infor['id']."<br>title=".$infor['title'];
  1811. }
  1812. }
  1813. //刷新列表
  1814. //ReListHtml($classid,1);
  1815. $returl=EcmsGetReturnUrl();
  1816. //发送通知
  1817. if($adddatar['causetext']&&$infoid)
  1818. {
  1819. if(!$infor['id'])
  1820. {
  1821. $infor=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$infoid' limit 1");
  1822. }
  1823. DoInfoSendNotice($userid,$username,$infor['userid'],$infor['username'],$adddatar['causetext'],$infor,2);
  1824. if($adddatar['ecmsfrom']&&(stristr($adddatar['ecmsfrom'],'ListNews.php')||stristr($adddatar['ecmsfrom'],'ListAllInfo.php')))
  1825. {
  1826. $returl=$adddatar['ecmsfrom'];
  1827. }
  1828. else
  1829. {
  1830. $returl="ListNews.php?bclassid=$adddatar[bclassid]&classid=$adddatar[classid]".$addecmscheck.hReturnEcmsHashStrHref2(0);
  1831. }
  1832. }
  1833. //操作日志
  1834. if($donum==1)
  1835. {
  1836. insert_dolog($dolog,$dopubid);
  1837. }
  1838. else
  1839. {
  1840. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]);
  1841. }
  1842. printerror("CheckNewsSuccess",$returl);
  1843. }
  1844. //取消审核信息
  1845. function NoCheckNews_all($classid,$id,$userid,$username){
  1846. global $empire,$class_r,$public_r,$dbtbpre,$emod_r,$adddatar;
  1847. $classid=(int)$classid;
  1848. if(empty($classid))
  1849. {
  1850. printerror("ErrorUrl","history.go(-1)");
  1851. }
  1852. //验证权限
  1853. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  1854. //权限
  1855. if(!$doselfinfo['docheckinfo'])
  1856. {
  1857. printerror("NotCheckInfoLevel","history.go(-1)");
  1858. }
  1859. $count=count($id);
  1860. if(empty($count))
  1861. {
  1862. printerror("NotNoCheckNewsid","history.go(-1)");
  1863. }
  1864. $dopubid=0;
  1865. $donum=0;
  1866. $dolog='';
  1867. //附加链接参数
  1868. $addecmscheck=empty($_POST['ecmscheck'])?'&ecmscheck=1':'';
  1869. $mid=$class_r[$classid][modid];
  1870. $tbname=$class_r[$classid][tbname];
  1871. $pf=$emod_r[$mid]['pagef'];
  1872. $stf=$emod_r[$mid]['savetxtf'];
  1873. for($i=0;$i<$count;$i++)
  1874. {
  1875. $infoid=(int)$id[$i];
  1876. //主表
  1877. $r=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$infoid' limit 1");
  1878. if(!$r['id']||$r['isqf']==1)
  1879. {
  1880. continue;
  1881. }
  1882. $sql=$empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index set checked=0 where id='$infoid'");
  1883. //未审核互转
  1884. MoveCheckInfoData($class_r[$classid][tbname],1,$r['stb'],"id='$infoid'");
  1885. //更新栏目信息数
  1886. AddClassInfos($r['classid'],'','-1');
  1887. //分页字段
  1888. if($pf)
  1889. {
  1890. if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
  1891. {
  1892. $finfor=$empire->fetch1("select ".$pf." from {$dbtbpre}ecms_".$tbname."_data_".$r[stb]." where id='$infoid'");
  1893. $r[$pf]=$finfor[$pf];
  1894. }
  1895. if($stf&&$stf==$pf)//存放文本
  1896. {
  1897. $r[$pf]=GetTxtFieldText($r[$pf]);
  1898. }
  1899. }
  1900. DelNewsFile($r[filename],$r[newspath],$r[classid],$r[$pf],$r[groupid]);
  1901. //更新动态缓存
  1902. if($public_r['ctimeopen'])
  1903. {
  1904. eUpCacheInfo(1,$r['classid'],0,0,$r['ttid'],'',$r['infotags'],0,0,1);
  1905. }
  1906. $donum++;
  1907. if($donum==1)
  1908. {
  1909. $dopubid=ReturnInfoPubid($r['classid'],$r['id']);
  1910. $dolog="classid=".$r['classid']."<br>id=".$r['id']."<br>title=".$r['title'];
  1911. }
  1912. }
  1913. //刷新列表
  1914. ReListHtml($classid,1);
  1915. $returl=EcmsGetReturnUrl();
  1916. //发送通知
  1917. if($adddatar['causetext']&&$infoid)
  1918. {
  1919. if(!$r['id'])
  1920. {
  1921. $r=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check where id='$infoid' limit 1");
  1922. }
  1923. DoInfoSendNotice($userid,$username,$r['userid'],$r['username'],$adddatar['causetext'],$r,3);
  1924. if($adddatar['ecmsfrom']&&(stristr($adddatar['ecmsfrom'],'ListNews.php')||stristr($adddatar['ecmsfrom'],'ListAllInfo.php')))
  1925. {
  1926. $returl=$adddatar['ecmsfrom'];
  1927. }
  1928. else
  1929. {
  1930. $returl="ListNews.php?bclassid=$adddatar[bclassid]&classid=$adddatar[classid]".$addecmscheck.hReturnEcmsHashStrHref2(0);
  1931. }
  1932. }
  1933. //操作日志
  1934. if($donum==1)
  1935. {
  1936. insert_dolog($dolog,$dopubid);
  1937. }
  1938. else
  1939. {
  1940. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]);
  1941. }
  1942. printerror("NoCheckNewsSuccess",$returl);
  1943. }
  1944. //移动信息
  1945. function MoveNews_all($classid,$id,$to_classid,$userid,$username){
  1946. global $empire,$class_r,$dbtbpre,$emod_r,$adddatar,$public_r;
  1947. $classid=(int)$classid;
  1948. $to_classid=(int)$to_classid;
  1949. if(empty($classid)||empty($to_classid))
  1950. {
  1951. printerror("EmptyMoveClassid","history.go(-1)");
  1952. }
  1953. if(empty($class_r[$classid][islast])||empty($class_r[$to_classid][islast]))
  1954. {
  1955. printerror("EmptyMoveClassid","history.go(-1)");
  1956. }
  1957. if($class_r[$classid][modid]<>$class_r[$to_classid][modid])
  1958. {
  1959. printerror("DefModid","history.go(-1)");
  1960. }
  1961. //验证权限
  1962. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  1963. //权限
  1964. if(!$doselfinfo['domoveinfo'])
  1965. {
  1966. printerror("NotMoveInfoLevel","history.go(-1)");
  1967. }
  1968. $count=count($id);
  1969. if(empty($count))
  1970. {
  1971. printerror("NotMoveNewsid","history.go(-1)");
  1972. }
  1973. $dopubid=0;
  1974. $donum=0;
  1975. $dolog='';
  1976. //附加链接参数
  1977. $addecmscheck=empty($_POST['ecmscheck'])?'&ecmscheck=1':'';
  1978. $infotb='';
  1979. $tbname=$class_r[$classid][tbname];
  1980. for($i=0;$i<$count;$i++)
  1981. {
  1982. $id[$i]=(int)$id[$i];
  1983. $add.="id='".$id[$i]."' or ";
  1984. if(empty($infotb))
  1985. {
  1986. //索引表
  1987. $index_r=$empire->fetch1("select checked from {$dbtbpre}ecms_".$tbname."_index where id='".$id[$i]."' limit 1");
  1988. //返回表
  1989. $infotb=ReturnInfoMainTbname($tbname,$index_r['checked']);
  1990. }
  1991. //主表
  1992. $r=$empire->fetch1("select stb,classid,fstb,restb,id,isurl,filename,groupid,newspath,titleurl,title,ismember,userid,username,newstime,truetime,ttid from ".$infotb." where id='".$id[$i]."' limit 1");
  1993. $pubid=ReturnInfoPubid($r['classid'],$id[$i]);
  1994. //信息地址
  1995. $infourl=GotoGetTitleUrl($to_classid,$id[$i],$r['newspath'],$r['filename'],$r['groupid'],$r['isurl'],$r['titleurl']);
  1996. //返回表信息
  1997. $infotbr=ReturnInfoTbname($tbname,$index_r['checked'],$r['stb']);
  1998. //主表
  1999. $empire->query("update ".$infotb." set classid='$to_classid',titleurl='$infourl' where id='".$id[$i]."'");
  2000. //副表
  2001. $empire->query("update ".$infotbr['datatbname']." set classid='$to_classid' where id='".$id[$i]."'");
  2002. //更新栏目信息数
  2003. AddClassInfos($r['classid'],'-1','-1',$index_r['checked']);
  2004. AddClassInfos($to_classid,'+1','+1',$index_r['checked']);
  2005. //更新信息附加表
  2006. UpdateSingleInfoOtherData($r['classid'],$id[$i],$to_classid,$r,0,0);
  2007. //更新动态缓存
  2008. if($public_r['ctimeopen']&&$index_r['checked'])
  2009. {
  2010. eUpCacheInfo(1,$r['classid'],0,0,$r['ttid'],'','',$to_classid,0,1);
  2011. }
  2012. $donum++;
  2013. if($donum==1)
  2014. {
  2015. $dopubid=ReturnInfoPubid($r['classid'],$id[$i]);
  2016. $dolog="classid=".$r['classid']."<br>classname=".$class_r[$r['classid']][classname]."<br>id=".$id[$i]."<br>to_classid=".$to_classid;
  2017. }
  2018. }
  2019. $add=substr($add,0,strlen($add)-4);
  2020. $sql=$empire->query("update {$dbtbpre}ecms_".$tbname."_index set classid='$to_classid' where ".$add);
  2021. //刷新列表
  2022. ReListHtml($classid,1);
  2023. ReListHtml($to_classid,1);
  2024. $returl=EcmsGetReturnUrl();
  2025. //发送通知
  2026. if($donum==1&&$r['id'])
  2027. {
  2028. DoInfoSendNotice($userid,$username,$r['userid'],$r['username'],$adddatar['causetext'],$r,4);
  2029. if($adddatar['causetext'])
  2030. {
  2031. if($adddatar['ecmsfrom']&&(stristr($adddatar['ecmsfrom'],'ListNews.php')||stristr($adddatar['ecmsfrom'],'ListAllInfo.php')))
  2032. {
  2033. $returl=$adddatar['ecmsfrom'];
  2034. }
  2035. else
  2036. {
  2037. $returl="ListNews.php?bclassid=$adddatar[bclassid]&classid=$adddatar[classid]".$addecmscheck.hReturnEcmsHashStrHref2(0);
  2038. }
  2039. }
  2040. }
  2041. if($sql)
  2042. {
  2043. //操作日志
  2044. if($donum==1)
  2045. {
  2046. insert_dolog($dolog,$dopubid);
  2047. }
  2048. else
  2049. {
  2050. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]."<br>to_classid=".$to_classid);
  2051. }
  2052. printerror("MoveNewsSuccess",$returl);
  2053. }
  2054. else
  2055. {printerror("DbError","history.go(-1)");}
  2056. }
  2057. //复制信息
  2058. function CopyNews_all($classid,$id,$to_classid,$userid,$username){
  2059. global $empire,$public_r,$class_r,$dbtbpre,$emod_r,$lur;
  2060. $classid=(int)$classid;
  2061. $to_classid=(int)$to_classid;
  2062. if(empty($classid)||empty($to_classid))
  2063. {
  2064. printerror("EmptyCopyClassid","history.go(-1)");
  2065. }
  2066. if(empty($class_r[$classid][islast])||empty($class_r[$to_classid][islast]))
  2067. {
  2068. printerror("EmptyCopyClassid","history.go(-1)");
  2069. }
  2070. if($class_r[$classid][modid]<>$class_r[$to_classid][modid])
  2071. {
  2072. printerror("DefModid","history.go(-1)");
  2073. }
  2074. $userid=(int)$userid;
  2075. //验证权限
  2076. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  2077. //权限
  2078. if(!$doselfinfo['domoveinfo'])
  2079. {
  2080. printerror("NotMoveInfoLevel","history.go(-1)");
  2081. }
  2082. $count=count($id);
  2083. if(empty($count))
  2084. {
  2085. printerror("NotCopyNewsid","history.go(-1)");
  2086. }
  2087. $userisqf=EcmsReturnDoIsqf($userid,$username,$lur['groupid'],0);
  2088. $dopubid=0;
  2089. $donum=0;
  2090. $dolog='';
  2091. //附加链接参数
  2092. $addecmscheck=empty($_POST['ecmscheck'])?'&ecmscheck=1':'';
  2093. for($i=0;$i<$count;$i++)
  2094. {
  2095. $add.="id='".intval($id[$i])."' or ";
  2096. }
  2097. $add=substr($add,0,strlen($add)-4);
  2098. $mid=$class_r[$classid][modid];
  2099. $tbname=$class_r[$classid][tbname];
  2100. $stf=$emod_r[$mid]['savetxtf'];
  2101. //查看目录是否存在,不存在则建立
  2102. $newspath=FormatPath($to_classid,"",0);
  2103. $newstime=time();
  2104. $truetime=$newstime;
  2105. $newstempid=0;
  2106. $dosql=$empire->query("select id,classid,checked from {$dbtbpre}ecms_".$tbname."_index where ".$add);
  2107. while($index_r=$empire->fetch($dosql))
  2108. {
  2109. //返回表
  2110. $infotb=ReturnInfoMainTbname($tbname,$index_r['checked']);
  2111. //主表
  2112. $r=$empire->fetch1("select * from ".$infotb." where id='$index_r[id]' limit 1");
  2113. //返回表信息
  2114. $infotbr=ReturnInfoTbname($tbname,$index_r['checked'],$r['stb']);
  2115. //副表
  2116. $finfor=$empire->fetch1("select ".ReturnSqlFtextF($mid)." from ".$infotbr['datatbname']." where id='$r[id]' limit 1");
  2117. $r=array_merge($r,$finfor);
  2118. if($stf)//存放文本
  2119. {
  2120. $r[$stf]=GetTxtFieldText($r[$stf]);
  2121. }
  2122. //返回自定义字段
  2123. $ret_r=ReturnAddF($r,$class_r[$to_classid][modid],$userid,$username,9,1,0);
  2124. if($class_r[$to_classid][wfid])
  2125. {
  2126. if($userisqf)
  2127. {
  2128. $checked=$class_r[$to_classid][checked];
  2129. $isqf=0;
  2130. }
  2131. else
  2132. {
  2133. $checked=0;
  2134. $isqf=1;
  2135. }
  2136. }
  2137. else
  2138. {
  2139. $checked=$class_r[$to_classid][checked];
  2140. $isqf=0;
  2141. }
  2142. $checked=(int)$checked;
  2143. //索引表
  2144. $empire->query("insert into {$dbtbpre}ecms_".$tbname."_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('$to_classid','$checked','$r[newstime]','$truetime','$truetime','$r[havehtml]');");
  2145. $l_id=$empire->lastid();
  2146. $update_infotbr=ReturnInfoTbname($tbname,$checked,$ret_r['tb']);
  2147. //主表
  2148. $sql=$empire->query("insert into ".$update_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".$ret_r[fields].") values('$l_id','$to_classid','$r[ttid]',0,0,0,'$newspath','$filename',$userid,'$username',0,0,'$r[ispic]',0,'$isqf',0,'$r[isurl]',$truetime,$truetime,$r[havehtml],$r[groupid],$r[userfen],'$r[titlefont]','$r[titleurl]','$ret_r[tb]','$public_r[filedeftb]','$public_r[pldeftb]','$r[keyboard]'".$ret_r[values].");");
  2149. //副表
  2150. $empire->query("insert into ".$update_infotbr['datatbname']."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$ret_r[datafields].") values('$l_id','$to_classid','$r[keyid]',$r[dokey],'".$newstempid."',$r[closepl],0,'$r[infotags]'".$ret_r[datavalues].");");
  2151. //签发
  2152. if($isqf==1)
  2153. {
  2154. InfoInsertToWorkflow($l_id,$to_classid,$class_r[$to_classid][wfid],$userid,$username);
  2155. }
  2156. //文件命名
  2157. $filename=ReturnInfoFilename($to_classid,$l_id,$r[filenameqz]);
  2158. //信息地址
  2159. $updateinfourl='';
  2160. if(!$r['isurl'])
  2161. {
  2162. $infourl=GotoGetTitleUrl($to_classid,$l_id,$newspath,$filename,$r['groupid'],$r['isurl'],$r['titleurl']);
  2163. $updateinfourl=",titleurl='$infourl'";
  2164. }
  2165. $usql=$empire->query("update ".$update_infotbr['tbname']." set filename='$filename'".$updateinfourl." where id='$l_id'");
  2166. //更新栏目信息数
  2167. AddClassInfos($to_classid,'+1','+1',$checked);
  2168. //生成信息文件
  2169. if($checked)
  2170. {
  2171. $addr=$empire->fetch1("select * from ".$update_infotbr['tbname']." where id='$l_id'");
  2172. GetHtml($addr['classid'],$addr['id'],$addr,1);
  2173. }
  2174. //更新动态缓存
  2175. if($public_r['ctimeopen']&&$checked)
  2176. {
  2177. eUpCacheInfo(1,$to_classid,0,0,$r['ttid'],'',$r[infotags],0,0,1);
  2178. }
  2179. $donum++;
  2180. if($donum==1)
  2181. {
  2182. $dopubid=ReturnInfoPubid($r['classid'],$r['id']);
  2183. $dolog="classid=".$r['classid']."<br>id=".$r['id']."<br>title=".$r['title']."<br>to_classid=".$to_classid;
  2184. }
  2185. }
  2186. //刷新列表
  2187. ReListHtml($to_classid,1);
  2188. //操作日志
  2189. if($donum==1)
  2190. {
  2191. insert_dolog($dolog,$dopubid);
  2192. }
  2193. else
  2194. {
  2195. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]."<br>to_classid=".$to_classid);
  2196. }
  2197. printerror("CopyNewsSuccess",EcmsGetReturnUrl());
  2198. }
  2199. //批量转移信息
  2200. function MoveClassNews($add,$userid,$username){
  2201. global $empire,$class_r,$dbtbpre,$emod_r,$public_r;
  2202. $add[classid]=(int)$add[classid];
  2203. $add[toclassid]=(int)$add[toclassid];
  2204. if(empty($add[classid])||empty($add[toclassid]))
  2205. {
  2206. printerror("EmptyMovetoClassid","history.go(-1)");
  2207. }
  2208. if($class_r[$add[classid]][modid]<>$class_r[$add[toclassid]][modid])
  2209. {
  2210. printerror("DefModid","history.go(-1)");
  2211. }
  2212. //验证权限
  2213. CheckLevel($userid,$username,$classid,"movenews");
  2214. //终极栏目
  2215. if(!$class_r[$add[classid]][islast]||!$class_r[$add[toclassid]][islast])
  2216. {
  2217. printerror("MovetoClassidMustLastid","history.go(-1)");
  2218. }
  2219. if($add[classid]==$add[toclassid])
  2220. {
  2221. printerror("MoveClassidsame","history.go(-1)");
  2222. }
  2223. $mid=$class_r[$add[classid]][modid];
  2224. $tbname=$class_r[$add[classid]][tbname];
  2225. //主表
  2226. $indexsql=$empire->query("update {$dbtbpre}ecms_".$tbname."_index set classid=$add[toclassid] where classid='$add[classid]'");
  2227. $sql=$empire->query("update {$dbtbpre}ecms_".$tbname." set classid=$add[toclassid] where classid='$add[classid]'");
  2228. $empire->query("update {$dbtbpre}ecms_".$tbname."_check set classid=$add[toclassid] where classid='$add[classid]'");
  2229. $empire->query("update {$dbtbpre}ecms_".$tbname."_doc set classid=$add[toclassid] where classid='$add[classid]'");
  2230. //副表
  2231. UpdateAllDataTbField($tbname,"classid='$add[toclassid]'"," where classid='$add[classid]'",1,1);
  2232. //更新栏目信息数
  2233. $cr=$empire->fetch1("select classid,allinfos,infos from {$dbtbpre}enewsclass where classid='$add[classid]'");
  2234. AddClassInfos($add[classid],'-'.$cr[allinfos],'-'.$cr[infos]);
  2235. $tocr=$empire->fetch1("select classid,allinfos,infos from {$dbtbpre}enewsclass where classid='$add[toclassid]'");
  2236. AddClassInfos($add[toclassid],'+'.$cr[allinfos],'+'.$cr[infos]);
  2237. //更新信息附加表与附件表
  2238. UpdateMoreInfoOtherData($add[classid],$add[toclassid],0,0);
  2239. //生成信息列表
  2240. ListHtml($add[toclassid],$ret_r,0);
  2241. //更新动态缓存
  2242. if($public_r['ctimeopen'])
  2243. {
  2244. eUpCacheInfo(1,$add['classid'],0,0,0,'','',$add['toclassid'],0);
  2245. }
  2246. //移动数据
  2247. $opath=ECMS_PATH.$class_r[$add[classid]][classpath];
  2248. DelPath($opath);//删除旧的栏目目录
  2249. $mk=DoMkdir($opath);
  2250. if($sql)
  2251. {
  2252. //操作日志
  2253. insert_dolog("classid=".$add[classid]."&nbsp;(".$class_r[$add[classid]][classname].")<br>toclassid=".$add[toclassid]."(".$class_r[$add[toclassid]][classname].")");
  2254. printerror("MoveClassNewsSuccess","MoveClassNews.php".hReturnEcmsHashStrHref2(1));
  2255. }
  2256. else
  2257. {printerror("DbError","history.go(-1)");}
  2258. }
  2259. //批量推荐/头条信息
  2260. function GoodInfo_all($classid,$id,$isgood,$doing=0,$userid,$username){
  2261. global $empire,$class_r,$dbtbpre,$public_r;
  2262. $classid=(int)$classid;
  2263. if(empty($classid))
  2264. {
  2265. printerror("ErrorUrl","history.go(-1)");
  2266. }
  2267. //验证权限
  2268. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  2269. //权限
  2270. if(!$doselfinfo['dogoodinfo'])
  2271. {
  2272. printerror("NotGoodInfoLevel","history.go(-1)");
  2273. }
  2274. //附加链接参数
  2275. $addecmscheck=empty($_POST['ecmscheck'])?'&ecmscheck=1':'';
  2276. $isgood=(int)$isgood;
  2277. $doing=(int)$doing;
  2278. if($doing==0)//推荐
  2279. {
  2280. if(!eFirstTitleCheckLevel($isgood,0))
  2281. {
  2282. printerror("NotGoodInfoLevel","history.go(-1)");
  2283. }
  2284. $mess="EmptyGoodInfoId";
  2285. $domess="GoodInfoSuccess";
  2286. $setf="isgood=$isgood";
  2287. }
  2288. else//头条
  2289. {
  2290. if(!eFirstTitleCheckLevel($isgood,1))
  2291. {
  2292. printerror("NotGoodInfoLevel","history.go(-1)");
  2293. }
  2294. $mess="EmptyFirsttitleInfoId";
  2295. $domess="FirsttitleInfoSuccess";
  2296. $setf="firsttitle=$isgood";
  2297. }
  2298. $count=count($id);
  2299. if(empty($count))
  2300. {
  2301. printerror($mess,"history.go(-1)");
  2302. }
  2303. $dopubid=0;
  2304. $donum=0;
  2305. $dolog='';
  2306. $infotb='';
  2307. for($i=0;$i<$count;$i++)
  2308. {
  2309. $infoid=(int)$id[$i];
  2310. $add.="id='".$infoid."' or ";
  2311. if($infoid&&empty($infotb))
  2312. {
  2313. $index_r=$empire->fetch1("select checked from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index where id='$infoid' limit 1");
  2314. //返回表
  2315. $infotb=ReturnInfoMainTbname($class_r[$classid][tbname],$index_r['checked']);
  2316. }
  2317. $donum++;
  2318. if($donum==1)
  2319. {
  2320. $dopubid=ReturnInfoPubid($classid,$infoid);
  2321. $dolog="classid=".$classid."<br>classname=".$class_r[$classid][classname]."<br>id=".$infoid."&doing=$doing";
  2322. }
  2323. }
  2324. if(empty($infotb))
  2325. {
  2326. printerror($mess,"history.go(-1)");
  2327. }
  2328. $add=substr($add,0,strlen($add)-4);
  2329. $sql=$empire->query("update ".$infotb." set ".$setf." where ".$add);
  2330. if($sql)
  2331. {
  2332. //操作日志
  2333. if($donum==1)
  2334. {
  2335. insert_dolog($dolog,$dopubid);
  2336. }
  2337. else
  2338. {
  2339. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]."<br>doing=".$doing);
  2340. }
  2341. printerror($domess,EcmsGetReturnUrl());
  2342. }
  2343. else
  2344. {printerror("DbError","history.go(-1)");}
  2345. }
  2346. //本栏目信息全部审核
  2347. function SetAllCheckInfo($bclassid,$classid,$userid,$username){
  2348. global $empire,$dbtbpre,$class_r,$public_r;
  2349. $classid=(int)$classid;
  2350. if(empty($classid))
  2351. {
  2352. printerror("ErrorUrl","history.go(-1)");
  2353. }
  2354. //验证权限
  2355. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  2356. //权限
  2357. if(!$doselfinfo['docheckinfo'])
  2358. {
  2359. printerror("NotCheckInfoLevel","history.go(-1)");
  2360. }
  2361. //附加链接参数
  2362. $addecmscheck=empty($_POST['ecmscheck'])?'&ecmscheck=1':'';
  2363. $sql=$empire->query("select id,classid,userid,ismember,isqf,stb from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check where classid='$classid'");
  2364. $n=0;
  2365. while($r=$empire->fetch($sql))
  2366. {
  2367. //只能操作自己的信息
  2368. if($doselfinfo['doselfinfo']&&($userid!=$r['userid']||$r['ismember']==1))
  2369. {
  2370. continue;
  2371. }
  2372. if($r['isqf']==1)
  2373. {
  2374. continue;
  2375. }
  2376. $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index set checked=1 where id='$r[id]'");
  2377. //审核表转换
  2378. MoveCheckInfoData($class_r[$classid][tbname],0,$r['stb'],"id='$r[id]'");
  2379. $n++;
  2380. }
  2381. //更新动态缓存
  2382. if($public_r['ctimeopen']&&$n)
  2383. {
  2384. eUpCacheInfo(1,$classid,0,0,0,'','',0,0);
  2385. }
  2386. //更新栏目信息数
  2387. AddClassInfos($classid,'','+'.$n);
  2388. //操作日志
  2389. insert_dolog("classid=".$classid."<br>classname=".$class_r[$classid][classname]);
  2390. printerror("CheckNewsSuccess",EcmsGetReturnUrl());
  2391. }
  2392. //签发信息
  2393. function DoWfInfo($add,$userid,$username){
  2394. global $empire,$dbtbpre,$class_r,$emod_r,$lur,$public_r;
  2395. $id=(int)$add[id];
  2396. $classid=(int)$add[classid];
  2397. $doing=(int)$add['doing'];
  2398. if(!$id||!$classid||!$doing)
  2399. {
  2400. printerror('EmptyDoWfInfo','');
  2401. }
  2402. $wfinfor=$empire->fetch1("select id,checknum,wfid,tid,groupid,userclass,username,checktno from {$dbtbpre}enewswfinfo where id='$id' and classid='$classid' limit 1");
  2403. if(!$wfinfor[id])
  2404. {
  2405. printerror('ErrorUrl','');
  2406. }
  2407. if($wfinfor[checktno]=='100'||$wfinfor[checktno]=='101'||$wfinfor[checktno]=='102')
  2408. {
  2409. printerror('DoWfInfoOver','');
  2410. }
  2411. $wfitemr=$empire->fetch1("select tid,wfid,tno,groupid,userclass,username,lztype,tbdo,tddo,tstatus from {$dbtbpre}enewsworkflowitem where tid='$wfinfor[tid]'");
  2412. if(!(strstr(','.$wfitemr[groupid].',',','.$lur[groupid].',')||strstr(','.$wfitemr[userclass].',',','.$lur[classid].',')||strstr(','.$wfitemr[username].',',','.$lur[username].',')))
  2413. {
  2414. printerror("NotDoCheckUserLevel","history.go(-1)");
  2415. }
  2416. if(!(strstr(','.$wfinfor[groupid].',',','.$lur[groupid].',')||strstr(','.$wfinfor[userclass].',',','.$lur[classid].',')||strstr(','.$wfinfor[username].',',','.$lur[username].',')))
  2417. {
  2418. printerror("HaveDoWfInfo","history.go(-1)");
  2419. }
  2420. $pubid=ReturnInfoPubid($classid,$id);
  2421. //附加链接参数
  2422. $addecmscheck=empty($_POST['ecmscheck'])?'&ecmscheck=1':'';
  2423. $checktext=hRepPostStr($add[checktext],1);
  2424. if($doing==1)//通过
  2425. {
  2426. if($wfitemr[lztype]==0)//普签
  2427. {
  2428. if($wfitemr['tno']=='100')//全部通过
  2429. {
  2430. $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index set checked=1 where id='$id'");
  2431. $ar=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check where id='$id'");
  2432. //未审核表转换
  2433. MoveCheckInfoData($class_r[$classid][tbname],0,$ar['stb'],"id='$id'");
  2434. //更新栏目信息数
  2435. AddClassInfos($classid,'','+1');
  2436. $empire->query("update {$dbtbpre}enewswfinfo set tstatus='',checktno='100' where id='$id' and classid='$classid' limit 1");
  2437. //日志
  2438. InsertWfLog($classid,$id,$wfitemr[wfid],$wfitemr[tid],$username,$checktext,$wfinfor[checknum],1);
  2439. //生成
  2440. GetHtml($ar['classid'],$ar['id'],$ar,1);
  2441. ListHtml($classid,$fr,0);
  2442. //更新动态缓存
  2443. if($public_r['ctimeopen'])
  2444. {
  2445. eUpCacheInfo(1,$ar['classid'],0,0,$ar['ttid'],'','',0,0);
  2446. }
  2447. }
  2448. else//流转
  2449. {
  2450. $newwfitemr=$empire->fetch1("select tid,wfid,tno,groupid,userclass,username,lztype,tbdo,tddo,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfitemr[wfid]' and tno>$wfitemr[tno] order by tno limit 1");
  2451. $empire->query("update {$dbtbpre}enewswfinfo set tid='$newwfitemr[tid]',groupid='$newwfitemr[groupid]',userclass='$newwfitemr[userclass]',username='$newwfitemr[username]',tstatus='$newwfitemr[tstatus]',checktno='0' where id='$id' and classid='$classid' limit 1");
  2452. //日志
  2453. InsertWfLog($classid,$id,$newwfitemr[wfid],$newwfitemr[tid],$username,$checktext,$wfinfor[checknum],1);
  2454. }
  2455. }
  2456. else//会签
  2457. {
  2458. $newgroupid=str_replace(','.$lur[groupid].',',',',$wfinfor[groupid]);
  2459. $newuserclass=str_replace(','.$lur[classid].',',',',$wfinfor[userclass]);
  2460. $newusername=str_replace(','.$lur[username].',',',',$wfinfor[username]);
  2461. //下一个节点
  2462. if(($newgroupid==''||$newgroupid==',')&&($newuserclass==''||$newuserclass==',')&&($newusername==''||$newusername==','))
  2463. {
  2464. if($wfitemr['tno']=='100')//全部通过
  2465. {
  2466. $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index set checked=1 where id='$id'");
  2467. $ar=$empire->fetch1("select * from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check where id='$id'");
  2468. //未审核表转换
  2469. MoveCheckInfoData($class_r[$classid][tbname],0,$ar['stb'],"id='$id'");
  2470. //更新栏目信息数
  2471. AddClassInfos($classid,'','+1');
  2472. $empire->query("update {$dbtbpre}enewswfinfo set tstatus='',checktno='100' where id='$id' and classid='$classid' limit 1");
  2473. //日志
  2474. InsertWfLog($classid,$id,$wfitemr[wfid],$wfitemr[tid],$username,$checktext,$wfinfor[checknum],1);
  2475. //生成
  2476. GetHtml($ar['classid'],$ar['id'],$ar,1);
  2477. ListHtml($classid,$fr,0);
  2478. //更新动态缓存
  2479. if($public_r['ctimeopen'])
  2480. {
  2481. eUpCacheInfo(1,$ar['classid'],0,0,$ar['ttid'],'','',0,0);
  2482. }
  2483. }
  2484. else//流转
  2485. {
  2486. $newwfitemr=$empire->fetch1("select tid,wfid,tno,groupid,userclass,username,lztype,tbdo,tddo,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfitemr[wfid]' and tno>$wfitemr[tno] order by tno limit 1");
  2487. $empire->query("update {$dbtbpre}enewswfinfo set tid='$newwfitemr[tid]',groupid='$newwfitemr[groupid]',userclass='$newwfitemr[userclass]',username='$newwfitemr[username]',tstatus='$newwfitemr[tstatus]',checktno='0' where id='$id' and classid='$classid' limit 1");
  2488. //日志
  2489. InsertWfLog($classid,$id,$newwfitemr[wfid],$newwfitemr[tid],$username,$checktext,$wfinfor[checknum],1);
  2490. }
  2491. }
  2492. else//本节点继续
  2493. {
  2494. $empire->query("update {$dbtbpre}enewswfinfo set groupid='$newgroupid',userclass='$newuserclass',username='$newusername' where id='$id' and classid='$classid' limit 1");
  2495. //日志
  2496. InsertWfLog($classid,$id,$wfitemr[wfid],$wfitemr[tid],$username,$checktext,$wfinfor[checknum],1);
  2497. }
  2498. }
  2499. $mess='DoWfInfoCkSuccess';
  2500. }
  2501. elseif($doing==2)//返工
  2502. {
  2503. if(empty($checktext))
  2504. {
  2505. printerror('EmptyChecktext','history.go(-1)');
  2506. }
  2507. if($wfitemr[tbdo]==0)//发给作者
  2508. {
  2509. $empire->query("update {$dbtbpre}enewswfinfo set tid=0,tstatus='',checktno='101' where id='$id' and classid='$classid' limit 1");
  2510. }
  2511. else//发给节点
  2512. {
  2513. $newwfitemr=$empire->fetch1("select tid,wfid,tno,groupid,userclass,username,lztype,tbdo,tddo,tstatus from {$dbtbpre}enewsworkflowitem where wfid='$wfitemr[wfid]' and tid='$wfitemr[tbdo]' limit 1");
  2514. $empire->query("update {$dbtbpre}enewswfinfo set tid='$newwfitemr[tid]',groupid='$newwfitemr[groupid]',userclass='$newwfitemr[userclass]',username='$newwfitemr[username]',tstatus='$newwfitemr[tstatus]',checktno='101' where id='$id' and classid='$classid' limit 1");
  2515. }
  2516. //日志
  2517. InsertWfLog($classid,$id,$wfitemr[wfid],$wfitemr[tid],$username,$checktext,$wfinfor[checknum],2);
  2518. $mess='DoWfInfoTbSuccess';
  2519. }
  2520. else//否决
  2521. {
  2522. if(empty($checktext))
  2523. {
  2524. printerror('EmptyChecktext','history.go(-1)');
  2525. }
  2526. $empire->query("update {$dbtbpre}enewswfinfo set tid=0,tstatus='',checktno='102' where id='$id' and classid='$classid' limit 1");
  2527. //日志
  2528. InsertWfLog($classid,$id,$wfitemr[wfid],$wfitemr[tid],$username,$checktext,$wfinfor[checknum],3);
  2529. if($wfitemr[tddo])//删除信息
  2530. {
  2531. $index_r=$empire->fetch1("select checked from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index where id='$id' limit 1");
  2532. //返回表
  2533. $infotb=ReturnInfoMainTbname($class_r[$classid][tbname],$index_r['checked']);
  2534. $r=$empire->fetch1("select * from ".$infotb." where id='$id' limit 1");
  2535. $mid=$class_r[$classid][modid];
  2536. $tbname=$class_r[$classid][tbname];
  2537. $pf=$emod_r[$mid]['pagef'];
  2538. $stf=$emod_r[$mid]['savetxtf'];
  2539. //返回表信息
  2540. $infotbr=ReturnInfoTbname($class_r[$classid][tbname],$index_r['checked'],$r['stb']);
  2541. //分页字段
  2542. if($pf)
  2543. {
  2544. if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
  2545. {
  2546. $finfor=$empire->fetch1("select ".$pf." from ".$infotbr['datatbname']." where id='$id' limit 1");
  2547. $r[$pf]=$finfor[$pf];
  2548. }
  2549. }
  2550. //存文本
  2551. if($stf)
  2552. {
  2553. $newstextfile=$r[$stf];
  2554. $r[$stf]=GetTxtFieldText($r[$stf]);
  2555. DelTxtFieldText($newstextfile);//删除文件
  2556. }
  2557. DelNewsFile($r[filename],$r[newspath],$classid,$r[$pf],$r[groupid]);//删除信息文件
  2558. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_index where id='$id'");
  2559. $sql=$empire->query("delete from ".$infotbr['tbname']." where id='$id'");
  2560. $fsql=$empire->query("delete from ".$infotbr['datatbname']." where id='$id'");
  2561. //更新栏目信息数
  2562. AddClassInfos($r[classid],'-1','-1',$index_r['checked']);
  2563. //删除其它表记录与附件
  2564. DelSingleInfoOtherData($r['classid'],$id,$r,0,0);
  2565. }
  2566. $mess='DoWfInfoTdSuccess';
  2567. $isclose=1;
  2568. }
  2569. //操作日志
  2570. insert_dolog("classid=$classid&id=$id",$pubid);
  2571. printerror($mess,"workflow/DoWfInfo.php?classid=$classid&id=$id&isclose=$isclose".hReturnEcmsHashStrHref2(0));
  2572. }
  2573. //批量删除信息
  2574. function DelInfoData($start,$classid,$from,$retype,$startday,$endday,$startid,$endid,$tbname,$add,$userid,$username){
  2575. global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$emod_r;
  2576. //验证权限
  2577. CheckLevel($userid,$username,$classid,"delinfodata");
  2578. $search='';
  2579. $start=(int)$start;
  2580. $tbname=RepPostVar($tbname);
  2581. if(empty($tbname))
  2582. {
  2583. printerror("ErrorUrl","history.go(-1)");
  2584. }
  2585. $search.="&tbname=$tbname";
  2586. //查询表
  2587. $infotb="{$dbtbpre}ecms_".$tbname;
  2588. //按栏目
  2589. $classid=(int)$classid;
  2590. if($classid)
  2591. {
  2592. if(empty($class_r[$classid][islast]))//大栏目
  2593. {
  2594. $where=ReturnClass($class_r[$classid][sonclass]);
  2595. }
  2596. else//终极栏目
  2597. {
  2598. $where="classid='$classid'";
  2599. }
  2600. $add1=" and (".$where.")";
  2601. $search.="&classid=$classid";
  2602. }
  2603. //按ID刷新
  2604. $search.="&retype=$retype";
  2605. if($retype)
  2606. {
  2607. $startid=(int)$startid;
  2608. $endid=(int)$endid;
  2609. if($endid)
  2610. {
  2611. $add1.=" and id>=$startid and id<=$endid";
  2612. }
  2613. $search.="&startid=$startid&endid=$endid";
  2614. }
  2615. else
  2616. {
  2617. $startday=RepPostVar($startday);
  2618. $endday=RepPostVar($endday);
  2619. if($startday&&$endday)
  2620. {
  2621. $add1.=" and truetime>=".to_time($startday." 00:00:00")." and truetime<=".to_time($endday." 23:59:59");
  2622. }
  2623. $search.="&startday=$startday&endday=$endday";
  2624. }
  2625. //信息类型
  2626. $delckinfo=0;
  2627. $infost=(int)$add['infost'];
  2628. if($infost)
  2629. {
  2630. if($infost==1)//已审核
  2631. {
  2632. $delckinfo=1;
  2633. }
  2634. else//未审核
  2635. {
  2636. $infotb="{$dbtbpre}ecms_".$tbname."_check";
  2637. $delckinfo=2;
  2638. }
  2639. $search.="&infost=$infost";
  2640. }
  2641. else
  2642. {
  2643. $dodelcheck=(int)$add['dodelcheck'];
  2644. if($dodelcheck)
  2645. {
  2646. $infotb="{$dbtbpre}ecms_".$tbname."_check";
  2647. $delckinfo=2;
  2648. $search.="&dodelcheck=1";
  2649. }
  2650. }
  2651. //用户发布
  2652. $ismember=(int)$add['ismember'];
  2653. if($ismember)
  2654. {
  2655. if($ismember==1)//游客
  2656. {
  2657. $add1.=" and userid=0";
  2658. }
  2659. elseif($ismember==2)//会员+用户
  2660. {
  2661. $add1.=" and userid>0";
  2662. }
  2663. elseif($ismember==3)//会员
  2664. {
  2665. $add1.=" and userid>0 and ismember=1";
  2666. }
  2667. elseif($ismember==4)//用户
  2668. {
  2669. $add1.=" and userid>0 and ismember=0";
  2670. }
  2671. $search.="&ismember=$ismember";
  2672. }
  2673. //是否外部链接
  2674. $isurl=(int)$add['isurl'];
  2675. if($isurl)
  2676. {
  2677. if($isurl==1)//外部链接
  2678. {
  2679. $add1.=" and isurl=1";
  2680. }
  2681. else//内部信息
  2682. {
  2683. $add1.=" and isurl=0";
  2684. }
  2685. $search.="&isurl=$isurl";
  2686. }
  2687. //评论数
  2688. $plnum=(int)$add['plnum'];
  2689. if($plnum)
  2690. {
  2691. $add1.=" and plnum<".$plnum;
  2692. $search.="&plnum=$plnum";
  2693. }
  2694. //点击数
  2695. $onclick=(int)$add['onclick'];
  2696. if($onclick)
  2697. {
  2698. $add1.=" and onclick<".$onclick;
  2699. $search.="&onclick=$onclick";
  2700. }
  2701. //下载数
  2702. $totaldown=(int)$add['totaldown'];
  2703. if($totaldown)
  2704. {
  2705. $add1.=" and totaldown<".$totaldown;
  2706. $search.="&totaldown=$totaldown";
  2707. }
  2708. //用户ID
  2709. $userids=RepPostVar($add['userids']);
  2710. $usertype=(int)$add['usertype'];
  2711. if($userids)
  2712. {
  2713. $uidsr=explode(',',$userids);
  2714. $uidscount=count($uidsr);
  2715. $uids='';
  2716. $udh='';
  2717. for($ui=0;$ui<$uidscount;$ui++)
  2718. {
  2719. $uids.=$udh.intval($uidsr[$ui]);
  2720. $udh=',';
  2721. }
  2722. if($usertype==1)//用户
  2723. {
  2724. $add1.=" and userid in (".$uids.") and ismember=0";
  2725. }
  2726. else//会员
  2727. {
  2728. $add1.=" and userid in (".$uids.") and ismember=1";
  2729. }
  2730. $search.="&userids=$userids&usertype=$usertype";
  2731. }
  2732. //标题
  2733. $title=RepPostStr($add['title']);
  2734. if($title)
  2735. {
  2736. $titler=explode('|',$title);
  2737. $titlecount=count($titler);
  2738. $titlewhere='';
  2739. $titleor='';
  2740. for($ti=0;$ti<$titlecount;$ti++)
  2741. {
  2742. $titlewhere.=$titleor."title like '%".$titler[$ti]."%'";
  2743. $titleor=' or ';
  2744. }
  2745. $add1.=" and (".$titlewhere.")";
  2746. $search.="&title=$title";
  2747. }
  2748. $b=0;
  2749. $sql=$empire->query("select * from ".$infotb." where id>$start".$add1." order by id limit ".$public_r[delnewsnum]);
  2750. while($r=$empire->fetch($sql))
  2751. {
  2752. $b=1;
  2753. $new_start=$r[id];
  2754. $mid=$class_r[$r[classid]]['modid'];
  2755. $pf=$emod_r[$mid]['pagef'];
  2756. $stf=$emod_r[$mid]['savetxtf'];
  2757. //未审核表
  2758. if($delckinfo==2)
  2759. {
  2760. $infodatatb="{$dbtbpre}ecms_".$tbname."_check_data";
  2761. }
  2762. else
  2763. {
  2764. $infodatatb="{$dbtbpre}ecms_".$tbname."_data_".$r['stb'];
  2765. }
  2766. //分页字段
  2767. if($pf)
  2768. {
  2769. if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
  2770. {
  2771. $finfor=$empire->fetch1("select ".$pf." from ".$infodatatb." where id='$r[id]' limit 1");
  2772. $r[$pf]=$finfor[$pf];
  2773. }
  2774. }
  2775. //存文本
  2776. if($stf)
  2777. {
  2778. $newstextfile=$r[$stf];
  2779. $r[$stf]=GetTxtFieldText($r[$stf]);
  2780. DelTxtFieldText($newstextfile);//删除文件
  2781. }
  2782. //删除信息文件
  2783. if($add['delhtml']!=1&&$delckinfo!=2)
  2784. {
  2785. DelNewsFile($r[filename],$r[newspath],$r[classid],$r[$pf],$r[groupid]);
  2786. }
  2787. //删除表信息
  2788. $empire->query("delete from {$dbtbpre}ecms_".$tbname."_index where id='$r[id]'");
  2789. $empire->query("delete from ".$infotb." where id='$r[id]'");
  2790. $empire->query("delete from ".$infodatatb." where id='$r[id]'");
  2791. //更新栏目信息数
  2792. AddClassInfos($r['classid'],'-1','-1',($delckinfo==2?0:1));
  2793. //删除其它表记录和附件
  2794. DelSingleInfoOtherData($r['classid'],$r['id'],$r,0,0);
  2795. }
  2796. if(empty($b))
  2797. {
  2798. if($delckinfo==0&&!$dodelcheck)
  2799. {
  2800. echo $fun_r[DelDataSuccess]."<script>self.location.href='ecmsinfo.php?enews=DelInfoData&start=0&from=".urlencode($from)."&delhtml=$add[delhtml]&dodelcheck=1".$search.hReturnEcmsHashStrHref(0)."';</script>";
  2801. exit();
  2802. }
  2803. //操作日志
  2804. insert_dolog("");
  2805. printerror("DelNewsAllSuccess","db/DelData.php".hReturnEcmsHashStrHref2(1));
  2806. }
  2807. echo $fun_r[OneDelDataSuccess]."(ID:<font color=red><b>".$new_start."</b></font>)<script>self.location.href='ecmsinfo.php?enews=DelInfoData&start=$new_start&from=".urlencode($from)."&delhtml=$add[delhtml]".$search.hReturnEcmsHashStrHref(0)."';</script>";
  2808. exit();
  2809. }
  2810. //归档信息(栏目)
  2811. function InfoToDoc_class($add,$userid,$username){
  2812. global $empire,$dbtbpre,$public_r,$class_r;
  2813. //操作权限
  2814. CheckLevel($userid,$username,$classid,"class");
  2815. $classid=(int)$add['classid'];
  2816. if(!$classid)
  2817. {
  2818. printerror("EmptyDocClass","");
  2819. }
  2820. $start=(int)$add['start'];
  2821. $cr=$empire->fetch1("select tbname,doctime from {$dbtbpre}enewsclass where classid='$classid' and islast=1");
  2822. if(!$cr['tbname']||!$cr['doctime'])
  2823. {
  2824. printerror("EmptyDocTimeClass","");
  2825. }
  2826. $line=$public_r['docnewsnum'];
  2827. $b=0;
  2828. $doctime=time()-$cr['doctime']*24*3600;
  2829. $sql=$empire->query("select * from {$dbtbpre}ecms_".$cr[tbname]." where id>$start and classid='$classid' and truetime<$doctime order by id limit ".$line);
  2830. while($r=$empire->fetch($sql))
  2831. {
  2832. $b=1;
  2833. $new_start=$r['id'];
  2834. DoDocInfo($cr[tbname],$r,0);
  2835. }
  2836. if(empty($b))
  2837. {
  2838. //未审核信息
  2839. DoDocCkInfo($cr['tbname'],"classid='$classid' and truetime<$doctime",0);
  2840. $add['docfrom']=urldecode($add['docfrom']);
  2841. //操作日志
  2842. insert_dolog("tbname=".$cr['tbname']."&classid=$classid&do=1");
  2843. printerror("InfoToDocSuccess",$add['docfrom']);
  2844. }
  2845. echo $fun_r[OneInfoToDocSuccess]."(ID:<font color=red><b>".$new_start."</b></font>)<script>self.location.href='ecmsinfo.php?enews=InfoToDoc&ecmsdoc=1&classid=$classid&start=$new_start&docfrom=".urlencode($add[docfrom]).hReturnEcmsHashStrHref(0)."';</script>";
  2846. exit();
  2847. }
  2848. //归档信息(按条件批量)
  2849. function InfoToDoc($add,$userid,$username){
  2850. global $empire,$dbtbpre,$public_r,$class_r;
  2851. //操作权限
  2852. CheckLevel($userid,$username,$classid,"infodoc");
  2853. $tbname=RepPostVar($add['tbname']);
  2854. if(empty($tbname))
  2855. {
  2856. printerror("EmptyDocTb","");
  2857. }
  2858. $selecttbname=$tbname;
  2859. if($add['doing']==1)
  2860. {
  2861. $selecttbname=$tbname.'_doc';
  2862. }
  2863. $search="&retype=$add[retype]";
  2864. if($add['retype']==0)//按天数归档
  2865. {
  2866. if($add['doing']==1)//还原
  2867. {
  2868. $doctime=(int)$add['doctime1'];
  2869. $dx=">";
  2870. }
  2871. else//归档
  2872. {
  2873. $doctime=(int)$add['doctime'];
  2874. $dx="<";
  2875. }
  2876. if(!$doctime)
  2877. {
  2878. printerror("EmptyDoctime","");
  2879. }
  2880. $chtime=time()-$doctime*24*3600;
  2881. $where='truetime'.$dx.$chtime;
  2882. $log="doctime=$doctime";
  2883. $search.="&doctime=$add[doctime]&doctime1=$add[doctime1]";
  2884. }
  2885. elseif($add['retype']==1)//按时间归档
  2886. {
  2887. $startday=RepPostVar($add['startday']);
  2888. $endday=RepPostVar($add['endday']);
  2889. if(!$endday)
  2890. {
  2891. printerror("EmptyDocDay","");
  2892. }
  2893. if($startday)
  2894. {
  2895. $where="truetime>=".to_time($startday." 00:00:00")." and ";
  2896. }
  2897. $where.="truetime<=".to_time($endday." 23:59:59");
  2898. $log="startday=$startday&endday=$endday";
  2899. $search.="&startday=$add[startday]&endday=$add[endday]";
  2900. }
  2901. else//按ID归档
  2902. {
  2903. $startid=(int)$add['startid'];
  2904. $endid=(int)$add['endid'];
  2905. if(!$endid)
  2906. {
  2907. printerror("EmptyDocId","");
  2908. }
  2909. if($startid)
  2910. {
  2911. $where="id>=".$startid." and ";
  2912. }
  2913. $where.="id<=".$endid;
  2914. $log="startid=$startid&endid=$endid";
  2915. $search.="&startid=$add[startid]&endid=$add[endid]";
  2916. }
  2917. //栏目
  2918. $classid=$add['classid'];
  2919. $count=count($classid);
  2920. if($count)
  2921. {
  2922. for($i=0;$i<$count;$i++)
  2923. {
  2924. $dh=",";
  2925. if($i==0)
  2926. {
  2927. $dh="";
  2928. }
  2929. $ids.=$dh.intval($classid[$i]);
  2930. $search.='&classid[]='.$classid[$i];
  2931. }
  2932. $where.=" and classid in (".$ids.")";
  2933. }
  2934. $log.="<br>doing=$add[doing]";
  2935. $start=(int)$add['start'];
  2936. $line=$public_r['docnewsnum'];
  2937. $b=0;
  2938. $sql=$empire->query("select * from {$dbtbpre}ecms_".$selecttbname." where id>$start and ".$where." order by id limit ".$line);
  2939. while($r=$empire->fetch($sql))
  2940. {
  2941. $b=1;
  2942. $new_start=$r['id'];
  2943. DoDocInfo($tbname,$r,$add['doing']);
  2944. }
  2945. if(empty($b))
  2946. {
  2947. //未审核信息归档
  2948. DoDocCkInfo($tbname,$where,$add['doing']);
  2949. $add['docfrom']=urldecode($add['docfrom']);
  2950. //操作日志
  2951. insert_dolog("tbname=".$tbname.$log."&doing=$add[doing]&do=2");
  2952. printerror("InfoToDocSuccess",$add['docfrom']);
  2953. }
  2954. echo $fun_r[OneInfoToDocSuccess]."(ID:<font color=red><b>".$new_start."</b></font>)<script>self.location.href='ecmsinfo.php?enews=InfoToDoc&ecmsdoc=2&doing=$add[doing]&tbname=$tbname&start=$new_start&docfrom=".urlencode($add[docfrom]).$search.hReturnEcmsHashStrHref(0)."';</script>";
  2955. exit();
  2956. }
  2957. //归档信息(选择信息)
  2958. function InfoToDoc_info($add,$userid,$username){
  2959. global $empire,$dbtbpre,$class_r;
  2960. $classid=(int)$add['classid'];
  2961. //操作权限
  2962. $doselfinfo=CheckLevel($userid,$username,$classid,"news");
  2963. //权限
  2964. if(!$doselfinfo['dodocinfo'])
  2965. {
  2966. printerror("NotDocInfoLevel","history.go(-1)");
  2967. }
  2968. $id=$add['id'];
  2969. $count=count($id);
  2970. if($count==0)
  2971. {
  2972. printerror("EmptyDocInfo","");
  2973. }
  2974. $tbname=$class_r[$classid]['tbname'];
  2975. if(empty($tbname))
  2976. {
  2977. printerror("EmptyDocInfo","");
  2978. }
  2979. $selecttbname=$tbname;
  2980. if($add['doing']==1)
  2981. {
  2982. $selecttbname=$tbname.'_doc';
  2983. }
  2984. for($i=0;$i<$count;$i++)
  2985. {
  2986. $dh=",";
  2987. if($i==0)
  2988. {
  2989. $dh="";
  2990. }
  2991. $ids.=$dh.intval($id[$i]);
  2992. }
  2993. $where="id in (".$ids.")";
  2994. $sql=$empire->query("select * from {$dbtbpre}ecms_".$selecttbname." where ".$where);
  2995. while($r=$empire->fetch($sql))
  2996. {
  2997. DoDocInfo($tbname,$r,$add['doing']);
  2998. }
  2999. //未审核信息归档
  3000. DoDocCkInfo($tbname,$where,$add['doing']);
  3001. $add['docfrom']=urldecode($add['docfrom']);
  3002. //操作日志
  3003. insert_dolog("tbname=".$tbname."&doing=$add[doing]&do=0");
  3004. printerror("InfoToDocSuccess",$add['docfrom']);
  3005. }
  3006. //处理归档
  3007. function DoDocInfo($tb,$r,$ecms=0){
  3008. global $empire,$dbtbpre,$class_r,$emod_r;
  3009. if($ecms==1)//还原
  3010. {
  3011. $table=$dbtbpre.'ecms_'.$tb.'_doc_index'; //索引表
  3012. $table1=$dbtbpre.'ecms_'.$tb.'_doc'; //主表
  3013. $table2=$dbtbpre.'ecms_'.$tb.'_doc_data'; //副表
  3014. $ytable=$dbtbpre.'ecms_'.$tb.'_index'; //目标索引表
  3015. $ytable1=$dbtbpre.'ecms_'.$tb; //目标主表
  3016. $ytable2=$dbtbpre.'ecms_'.$tb.'_data_'.$r[stb]; //目标副表
  3017. }
  3018. else//归档
  3019. {
  3020. $table=$dbtbpre.'ecms_'.$tb.'_index'; //索引表
  3021. $table1=$dbtbpre.'ecms_'.$tb; //主表
  3022. $table2=$dbtbpre.'ecms_'.$tb.'_data_'.$r[stb]; //副表
  3023. $ytable=$dbtbpre.'ecms_'.$tb.'_doc_index'; //目标索引表
  3024. $ytable1=$dbtbpre.'ecms_'.$tb.'_doc'; //目标主表
  3025. $ytable2=$dbtbpre.'ecms_'.$tb.'_doc_data'; //目标副表
  3026. }
  3027. $mid=$class_r[$r[classid]][modid];
  3028. //索引表
  3029. $index_r=$empire->fetch1("select * from ".$table." where id='$r[id]' limit 1");
  3030. if($index_r['checked']==0)
  3031. {
  3032. return '';
  3033. }
  3034. //副表
  3035. $fr=$empire->fetch1("select ".ReturnSqlFtextF($mid)." from ".$table2." where id='$r[id]' limit 1");
  3036. $r=array_merge($r,$fr);
  3037. $ret_r=ReturnAddF($r,$mid,$userid,$username,10,0,0);//返回自定义字段
  3038. //索引表
  3039. $empire->query("insert into ".$ytable."(id,classid,checked,newstime,truetime,lastdotime,havehtml) values('$index_r[id]','$index_r[classid]','$index_r[checked]','$index_r[newstime]','$index_r[truetime]','$index_r[lastdotime]','$index_r[havehtml]');");
  3040. //主表
  3041. $empire->query("replace into ".$ytable1."(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".$ret_r[fields].") values('$r[id]','$r[classid]','$r[ttid]','$r[onclick]','$r[plnum]','$r[totaldown]','".StripAddsData($r[newspath])."','".StripAddsData($r[filename])."','$r[userid]','".StripAddsData($r[username])."','$r[firsttitle]','$r[isgood]','$r[ispic]','$r[istop]','$r[isqf]','$r[ismember]','$r[isurl]','$r[truetime]','$r[lastdotime]','$r[havehtml]','$r[groupid]','$r[userfen]','".StripAddsData($r[titlefont])."','".StripAddsData($r[titleurl])."','$r[stb]','$r[fstb]','$r[restb]','".StripAddsData($r[keyboard])."'".$ret_r[values].");");
  3042. //副表
  3043. $empire->query("replace into ".$ytable2."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$ret_r[datafields].") values('$r[id]','$r[classid]','$r[keyid]','$r[dokey]','$r[newstempid]','$r[closepl]','$r[haveaddfen]','".StripAddsData($r[infotags])."'".$ret_r[datavalues].");");
  3044. //删除
  3045. $empire->query("delete from ".$table." where id='$r[id]'");
  3046. $empire->query("delete from ".$table1." where id='$r[id]'");
  3047. $empire->query("delete from ".$table2." where id='$r[id]'");
  3048. //更新栏目信息数
  3049. if($ecms==1)//还原
  3050. {
  3051. AddClassInfos($r['classid'],'+1','+1');
  3052. }
  3053. else//归档
  3054. {
  3055. AddClassInfos($r['classid'],'-1','-1');
  3056. }
  3057. }
  3058. //处理归档(未审核信息)
  3059. function DoDocCkInfo($tb,$where,$ecms=0){
  3060. global $empire,$dbtbpre,$class_r,$emod_r;
  3061. if($ecms==1)//还原
  3062. {
  3063. $table=$dbtbpre.'ecms_'.$tb.'_doc_index'; //主表
  3064. $table1=$dbtbpre.'ecms_'.$tb.'_doc'; //主表
  3065. $table2=$dbtbpre.'ecms_'.$tb.'_doc_data'; //副表
  3066. $ytable=$dbtbpre.'ecms_'.$tb.'_index'; //目标主表
  3067. $ytable1=$dbtbpre.'ecms_'.$tb.'_check'; //目标主表
  3068. $ytable2=$dbtbpre.'ecms_'.$tb.'_check_data'; //目标副表
  3069. }
  3070. else//归档
  3071. {
  3072. $table=$dbtbpre.'ecms_'.$tb.'_index'; //主表
  3073. $table1=$dbtbpre.'ecms_'.$tb.'_check'; //主表
  3074. $table2=$dbtbpre.'ecms_'.$tb.'_check_data'; //副表
  3075. $ytable=$dbtbpre.'ecms_'.$tb.'_doc_index'; //目标主表
  3076. $ytable1=$dbtbpre.'ecms_'.$tb.'_doc'; //目标主表
  3077. $ytable2=$dbtbpre.'ecms_'.$tb.'_doc_data'; //目标副表
  3078. }
  3079. //转换副表
  3080. $fids='';
  3081. $dh='';
  3082. $sql=$empire->query("select id,classid from ".$table1." where ".$where);
  3083. while($r=$empire->fetch($sql))
  3084. {
  3085. $fids.=$dh.$r['id'];
  3086. $dh=',';
  3087. //更新栏目信息数
  3088. if($ecms==1)//还原
  3089. {
  3090. AddClassInfos($r['classid'],'+1','',0);
  3091. }
  3092. else//归档
  3093. {
  3094. AddClassInfos($r['classid'],'-1','',0);
  3095. }
  3096. }
  3097. if(empty($fids))
  3098. {
  3099. return '';
  3100. }
  3101. $empire->query("replace into ".$ytable." select * from ".$table." where ".$where);
  3102. $empire->query("replace into ".$ytable1." select * from ".$table1." where ".$where);
  3103. $empire->query("replace into ".$ytable2." select * from ".$table2." where id in (".$fids.")");
  3104. //删除
  3105. $empire->query("delete from ".$table." where ".$where);
  3106. $empire->query("delete from ".$table1." where ".$where);
  3107. $empire->query("delete from ".$table2." where id in (".$fids.")");
  3108. }
  3109. //发送信息操作通知
  3110. function DoInfoSendNotice($userid,$username,$to_userid,$to_username,$causetext,$infor,$ecms=0){
  3111. global $empire,$dbtbpre,$class_r;
  3112. if(!$infor['ismember'])
  3113. {
  3114. return '';
  3115. }
  3116. //操作者
  3117. $user_r=$empire->fetch1("select wname from {$dbtbpre}enewsuser where userid='$userid'");
  3118. $dousername=$user_r['wname']?$user_r['wname']:'管理员';
  3119. //操作类型
  3120. if($ecms==1)
  3121. {
  3122. $doing='删除';
  3123. $title='您的信息被删除';
  3124. }
  3125. elseif($ecms==2)
  3126. {
  3127. $doing='审核通过';
  3128. $title='您的信息已审核通过';
  3129. }
  3130. elseif($ecms==3)
  3131. {
  3132. $doing='取消审核';
  3133. $title='您的信息被取消审核';
  3134. }
  3135. elseif($ecms==4)
  3136. {
  3137. $doing='转移';
  3138. $title='您的信息被转移';
  3139. }
  3140. //操作信息
  3141. $title=RepPostStr($title);
  3142. $causetext=RepPostStr($causetext);
  3143. $dotime=date("Y-m-d H:i:s");
  3144. //信息内容
  3145. $titleurl=sys_ReturnBqTitleLink($infor);
  3146. $infotitle=$infor['title'];
  3147. $infotime=date("Y-m-d H:i:s",$infor[truetime]);
  3148. $classname=$class_r[$infor[classid]]['classname'];
  3149. $classurl=sys_ReturnBqClassname($infor,9);
  3150. $isadmin=$infor['ismember']==1?0:1;
  3151. $dousername=RepPostVar($dousername);
  3152. $to_username=RepPostVar($to_username);
  3153. $msgtext="您发布的信息被 <strong>$dousername</strong> 执行 <strong>$doing</strong> 操作<br>
  3154. <br>
  3155. <strong>信息标题:</strong><a href='".$titleurl."'>".$infotitle."</a><br>
  3156. <strong>发布时间:</strong>".$infotime."<br>
  3157. <strong>所在栏目:</strong><a href='".$classurl."'>".$classname."</a><br>
  3158. <strong>操作时间:</strong>$dotime<br>
  3159. <strong>操作理由:</strong>".$causetext."<br>";
  3160. eSendMsg(addslashes($title),addslashes($msgtext),$to_username,0,'',1,1,$isadmin);
  3161. }
  3162. ?>