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