PageRenderTime 102ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/jiaju001/news/lic/archives_do.php

https://gitlab.com/BGCX262/zyyhong-svn-to-git
PHP | 265 lines | 233 code | 2 blank | 30 comment | 37 complexity | 1e77c982ae7c4834cfa4cf01134d3d41 MD5 | raw file
  1. <?php
  2. require_once(dirname(__FILE__)."/config.php");
  3. require_once(dirname(__FILE__)."/../include/inc_typelink.php");
  4. require_once(dirname(__FILE__)."/inc/inc_batchup.php");
  5. require_once(dirname(__FILE__)."/inc/inc_archives_functions.php");
  6. empty($_COOKIE['ENV_GOBACK_URL']) ? $ENV_GOBACK_URL = "content_list.php" : $ENV_GOBACK_URL=$_COOKIE['ENV_GOBACK_URL'];
  7. if(empty($dopost)||empty($aid)){
  8. ShowMsg("对不起,你没指定运行参数!","-1");
  9. exit();
  10. }
  11. $aid = ereg_replace("[^0-9]","",$aid);
  12. /*--------------------------
  13. //编辑文档
  14. function editArchives();
  15. ---------------------------*/
  16. if($dopost=="editArchives")
  17. {
  18. $dsql = new DedeSql(-100);
  19. $row = $dsql->GetOne("Select c.editcon from `#@__full_search` i left join #@__channeltype c on c.ID=i.channelid where i.aid='$aid'");
  20. $gurl = $row["editcon"];
  21. $dsql->Close();
  22. if($gurl==""){ $gurl="article_edit.php"; }
  23. require_once(dirname(__FILE__)."/$gurl");
  24. }
  25. /*--------------------------
  26. //浏览文档
  27. function viewArchives();
  28. ---------------------------*/
  29. else if($dopost=="viewArchives")
  30. {
  31. $aid = intval($aid);
  32. $dsql = new DedeSql(-100);
  33. $tables = GetChannelTable($dsql,$aid,'arc');
  34. $arcQuery = "
  35. Select arc.ID,arc.title,arc.typeid,arc.channel,
  36. arc.ismake,arc.senddate,arc.arcrank,c.addtable,
  37. arc.money,t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,
  38. t.moresite,t.siteurl,t.siterefer,t.sitepath
  39. from `{$tables['maintable']}` arc
  40. left join #@__arctype t on t.ID = arc.typeid
  41. left join #@__channeltype c on c.ID = arc.channel
  42. where arc.ID='$aid'
  43. ";
  44. $arcRow = $dsql->GetOne($arcQuery);
  45. if($arcRow['ismake']==-1||$arcRow['arcrank']!=0
  46. ||$arcRow['typeid']==0||$arcRow['money']>0||$arcRow['channel']<-1)
  47. {
  48. $dsql->Close();
  49. echo "<script language='javascript'>location.href='{$cfg_plus_dir}/view.php?aid={$aid}';</script>";
  50. exit();
  51. }
  52. $arcurl = GetFileUrl($arcRow['ID'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],$arcRow['ismake'],
  53. $arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],true,$arcRow['siteurl']);
  54. $arcfile = GetFileUrl($arcRow['ID'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],$arcRow['ismake'],
  55. $arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],false,'');
  56. $truefile = GetTruePath($arcRow['siterefer'],$arcRow['sitepath']).$arcfile;
  57. MakeArt($aid,true,true);
  58. $dsql->Close();
  59. echo "<script language='javascript'>location.href='$arcurl"."?".time()."';</script>";
  60. exit();
  61. }
  62. /*--------------------------
  63. //推荐文档
  64. function commendArchives();
  65. ---------------------------*/
  66. else if($dopost=="commendArchives")
  67. {
  68. CheckPurview('a_Commend,sys_ArcBatch');
  69. $dsql = new DedeSql(false);
  70. if( $aid!="" && !ereg("(".$aid."`|`".$aid.")",$qstr) ) $qstr .= "`".$aid;
  71. if($qstr==""){
  72. ShowMsg("参数无效!",$ENV_GOBACK_URL);
  73. exit();
  74. }
  75. $qstrs = explode("`",$qstr);
  76. $dsql = new DedeSql(false);
  77. foreach($qstrs as $aid)
  78. {
  79. $aid = ereg_replace("[^0-9]","",$aid);
  80. if($aid=='') continue;
  81. $tables = GetChannelTable($dsql,$aid,'arc');
  82. $dsql->ExecuteNoneQuery(" Update `{$tables['maintable']}` set iscommend=iscommend+11 where ID='$aid' and iscommend<11 ");
  83. }
  84. $dsql->Close();
  85. ShowMsg("成功把所选的文档设为推荐!",$ENV_GOBACK_URL);
  86. exit();
  87. }
  88. /*--------------------------
  89. //生成HTML
  90. function makeArchives();
  91. ---------------------------*/
  92. else if($dopost=="makeArchives")
  93. {
  94. CheckPurview('sys_MakeHtml,sys_ArcBatch');
  95. $aid = ereg_replace("[^0-9]","",$aid);
  96. require_once(dirname(__FILE__)."/inc/inc_archives_functions.php");
  97. if(empty($qstr)){
  98. $pageurl = MakeArt($aid,true,true);
  99. ClearAllLink();
  100. ShowMsg("成功更新{$pageurl}...",$ENV_GOBACK_URL);
  101. exit();
  102. }
  103. else{
  104. $qstrs = explode("`",$qstr);
  105. $i = 0;
  106. foreach($qstrs as $aid){
  107. $i++;
  108. $pageurl = MakeArt($aid,false,false);
  109. }
  110. ClearAllLink();
  111. ShowMsg("成功更新指定 $i 个文件...",$ENV_GOBACK_URL);
  112. exit();
  113. }
  114. }
  115. /*--------------------------
  116. //审核文档
  117. function checkArchives();
  118. ---------------------------*/
  119. else if($dopost=="checkArchives")
  120. {
  121. CheckPurview('a_Check,a_AccCheck,sys_ArcBatch');
  122. require_once(DEDEADMIN."/inc/inc_archives_functions.php");
  123. $dsql = new DedeSql(false);
  124. if( $aid!="" && !ereg("(".$aid."`|`".$aid.")",$qstr) ) $qstr .= "`".$aid;
  125. if($qstr==""){
  126. ShowMsg("参数无效!",$ENV_GOBACK_URL);
  127. exit();
  128. }
  129. $qstrs = explode("`",$qstr);
  130. foreach($qstrs as $aid)
  131. {
  132. $aid = ereg_replace("[^0-9]","",$aid);
  133. if($aid=="") continue;
  134. $tables = GetChannelTable($dsql,$aid,'arc');
  135. $dsql->ExecuteNoneQuery(" Update `{$tables['maintable']}` set arcrank='0' where ID='$aid' And arcrank<'0' ");
  136. $dsql->ExecuteNoneQuery(" Update `#@__full_search` set arcrank='0' where aid='$aid' And arcrank<'0' ");
  137. $dsql->ExecuteNoneQuery(" OPTIMIZE TABLE `{$tables['maintable']}`; ");
  138. $dsql->ExecuteNoneQuery(" OPTIMIZE TABLE `#@__full_search`; ");
  139. $pageurl = MakeArt($aid,false,false);
  140. $dsql->ExecuteNoneQuery(" Update `#@__full_search` set url='$pageurl' where aid='$aid'");
  141. }
  142. ClearAllLink();
  143. ShowMsg("成功审核指定的文档!",$ENV_GOBACK_URL);
  144. exit();
  145. }
  146. /*--------------------------
  147. //删除文档
  148. function delArchives();
  149. ---------------------------*/
  150. else if($dopost=="delArchives")
  151. {
  152. CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
  153. require_once(dirname(__FILE__)."/../include/pub_oxwindow.php");
  154. if(empty($fmdo)) $fmdo = "";
  155. if($fmdo=="yes")
  156. {
  157. if( $aid!="" && !ereg("(".$aid."`|`".$aid.")",$qstr) ) $qstr .= "`".$aid;
  158. if($qstr==""){
  159. ShowMsg("参数无效!",$ENV_GOBACK_URL);
  160. exit();
  161. }
  162. $qstrs = explode("`",$qstr);
  163. $okaids = Array();
  164. $dsql = new DedeSql(false);
  165. foreach($qstrs as $aid){
  166. echo $channelid;
  167. if(!isset($okaids[$aid])) DelArc($aid,false,$channelid);
  168. else $okaids[$aid] = 1;
  169. }
  170. $dsql->Close();
  171. ShowMsg("成功删除指定的文档!",$ENV_GOBACK_URL);
  172. exit();
  173. }//确定刪除操作完成
  174. //删除确认消息
  175. //-----------------------
  176. $wintitle = "文档管理-删除文档";
  177. $wecome_info = "<a href='".$ENV_GOBACK_URL."'>文档管理</a>::删除文档";
  178. $win = new OxWindow();
  179. $win->Init("archives_do.php","js/blank.js","POST");
  180. $win->AddHidden("fmdo","yes");
  181. $win->AddHidden("dopost",$dopost);
  182. $win->AddHidden("channelid",$channelid);
  183. $win->AddHidden("qstr",$qstr);
  184. $win->AddHidden("aid",$aid);
  185. $win->AddTitle("你确实要删除“ $qstr 和 $aid ”这些文档?");
  186. $winform = $win->GetWindow("ok");
  187. $win->Display();
  188. }
  189. /*-----------------------------
  190. function moveArchives()
  191. ------------------------------*/
  192. else if($dopost=='moveArchives'){
  193. CheckPurview('sys_ArcBatch');
  194. require_once(dirname(__FILE__)."/../include/pub_oxwindow.php");
  195. require_once(dirname(__FILE__)."/../include/inc_typelink.php");
  196. if(empty($targetTypeid)){
  197. $tl = new TypeLink(0);
  198. $typeOptions = $tl->GetOptionArray(0,$tl->TypeInfos['channeltype'],0);
  199. $tl->Close();
  200. $typeOptions = "
  201. <select name='targetTypeid' style='width:350'>
  202. <option value='0'>请选择移动到的位置...</option>\r\n
  203. $typeOptions
  204. </select>
  205. ";
  206. $wintitle = "文档管理-移动文档";
  207. $wecome_info = "<a href='".$ENV_GOBACK_URL."'>文档管理</a>::移动文档";
  208. $win = new OxWindow();
  209. $win->Init("archives_do.php","js/blank.js","POST");
  210. $win->AddHidden("fmdo","yes");
  211. $win->AddHidden("dopost",$dopost);
  212. $win->AddHidden("qstr",$qstr);
  213. $win->AddHidden("aid",$aid);
  214. $win->AddTitle("你目前的操作是移动文档,请选择目标栏目:");
  215. $win->AddMsgItem($typeOptions,"30","1");
  216. $win->AddMsgItem("你选中的文档ID是: $qstr <br>移动的栏目必须和选定的文档频道类型一致,否则程序会自动勿略不符合的文档。","30","1");
  217. $winform = $win->GetWindow("ok");
  218. $win->Display();
  219. }else{
  220. $targetTypeid = ereg_replace('[^0-9]','',$targetTypeid);
  221. $dsql = new DedeSql(false);
  222. $typeInfos = $dsql->GetOne(" Select * From #@__arctype where ID='$targetTypeid' ");
  223. if(!is_array($typeInfos)){
  224. ShowMsg("参数错误!","-1");
  225. $dsql->Close();
  226. exit();
  227. }
  228. if($typeInfos['ispart']!=0){
  229. ShowMsg("文档保存的栏目必须为最终列表栏目!","-1");
  230. $dsql->Close();
  231. exit();
  232. }
  233. $arcids = explode('`',$qstr);
  234. $arc = "";
  235. $j = 0;
  236. $okids = Array();
  237. foreach($arcids as $arcid){
  238. $arcid = ereg_replace('[^0-9]','',$arcid);
  239. $tables = GetChannelTable($dsql,$arcid,'arc');
  240. if($tables['channelid']==$typeInfos['channeltype'])
  241. {
  242. $dsql->ExecuteNoneQuery("Update `{$tables['maintable']}` Set typeid='$targetTypeid' where ID='$arcid' ");
  243. $dsql->ExecuteNoneQuery("Update `{$tables['addtable']}` Set typeid='$targetTypeid' where aid='$arcid' ");
  244. $dsql->ExecuteNoneQuery("Update `#@__full_search` Set typeid='$targetTypeid' where aid='$arcid' ");
  245. $okids[] = $arcid;
  246. $j++;
  247. }
  248. }
  249. //更新HTML
  250. require_once(DEDEADMIN."/../include/inc_archives_view.php");
  251. foreach($okids as $aid){
  252. $arc = new Archives($aid);
  253. $arc->MakeHtml();
  254. }
  255. $dsql->ExecuteNoneQuery(" OPTIMIZE TABLE `{$tables['maintable']}`; ");
  256. $dsql->ExecuteNoneQuery(" OPTIMIZE TABLE `#@__full_search`; ");
  257. $dsql->Close();
  258. if(is_object($arc)) $arc->Close();
  259. ShowMsg("成功移动 $j 个文档!",$ENV_GOBACK_URL);
  260. exit();
  261. }
  262. }
  263. ?>