PushToZt.php
7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php
define('EmpireCMSAdmin','1');
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
require "../".LoadLang("pub/fun.php");
require("../../data/dbcache/class.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//驗證用戶
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//ehash
$ecms_hashur=hReturnEcmsHashStrAll();
//推送信息
function PushInfoToZt($add,$userid,$username){
global $empire,$dbtbpre,$class_r;
$classid=(int)$add['classid'];
$tid=(int)$add['tid'];
$ztid=$add['ztid'];
$cid=$add['cid'];
$id=$add['id'];
$count=count($ztid);
if(!$count||!$id)
{
echo"<script>window.close();</script>";
exit();
}
//表名
$tbname='';
if($classid)
{
$tbname=$class_r[$classid]['tbname'];
}
elseif($tid)
{
$tbr=$empire->fetch1("select tbname from {$dbtbpre}enewstable where tid='$tid'");
$tbname=$tbr['tbname'];
}
if(!$tbname)
{
printerror('ErrorUrl','');
}
//ID
$id=eReturnInids($id);
$where='id in ('.$id.')';
$ztids='';
$zcids='';
for($i=0;$i<$count;$i++)
{
$true_ztid=(int)$ztid[$i];
if(!$true_ztid)
{
continue;
}
$true_cid=(int)$cid[$true_ztid];
if($true_cid<0)
{
$true_cid=0;
}
$ztids.=$dh.$true_ztid;
$dh=',';
AddMoreInfoToZt($true_ztid,$true_cid,$tbname,$where,1);
}
//操作日誌
insert_dolog("classid=$classid&tid=$tid<br>ztid=".$ztids."<br>id=".$id);
echo"<script>alert('推送成功');window.close();</script>";
exit();
}
//返回所屬選擇專題
function ReturnZtToInfo($add,$userid,$username){
global $empire,$dbtbpre,$class_r;
$ztid=$add['ztid'];
$cid=$add['cid'];
$count=count($ztid);
if(!$count)
{
//echo"<script>window.close();</script>";
//exit();
}
$ztids='';
$zcids='';
$oldztids=$add['oldztids'];
$oldzcids=$add['oldcids'];
for($i=0;$i<$count;$i++)
{
$true_ztid=(int)$ztid[$i];
if(!$true_ztid)
{
continue;
}
$true_cid=(int)$cid[$true_ztid];
$ztids.=$dh.$true_ztid;
$dh=',';
$zcids.=$cdh.$true_cid;
$cdh=',';
}
?>
<script>
opener.document.add.ztids.value="<?=$ztids?>";
opener.document.add.zcids.value="<?=$zcids?>";
opener.document.add.oldztids.value="<?=$oldztids?>";
opener.document.add.oldzcids.value="<?=$oldzcids?>";
window.close();
</script>
<?php
exit();
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
}
if($enews=='PushInfoToZt')//選擇專題
{
if($_POST['sinfo'])
{
ReturnZtToInfo($_POST,$logininid,$loginin);
}
PushInfoToZt($_POST,$logininid,$loginin);
}
$add='';
//分類
$zcid=(int)$_GET['zcid'];
if($zcid)
{
$add.=" and zcid='$zcid'";
}
//欄目
$classid=(int)$_GET['classid'];
if($classid)
{
$classwhere=ReturnClass($class_r[$classid][featherclass]);
$add.=" and (classid=0 or classid='$classid' or (".$classwhere."))";
}
$sinfo=(int)$_GET['sinfo'];
//表ID
$tid=(int)$_GET['tid'];
//ID
$id=RepPostStr($_GET['id'],1);
if(empty($sinfo)&&!$id)
{
echo"<script>alert('請選擇信息');window.close();</script>";
exit();
}
//信息
$info_ztids='';
$info_cids='';
if($sinfo&&$id)
{
$ztdh='';
$cdh='';
$id=(int)$id;
$infosql=$empire->query("select ztid,cid from {$dbtbpre}enewsztinfo where id='$id' and classid='$classid'");
while($infor=$empire->fetch($infosql))
{
$info_ztids.=$ztdh.$infor['ztid'];
$ztdh=',';
if($infor['cid'])
{
$info_cids.=$cdh.$infor['cid'];
}
else
{
$info_cids.=$cdh.'-'.$infor['ztid'];
}
$cdh=',';
}
}
elseif($sinfo&&empty($id))
{
$firstpost=1;
}
$time=time();
//專題
$query="select ztid,ztname from {$dbtbpre}enewszt where usezt=0 and (endtime=0 or endtime>$time)".$add." order by myorder,ztid desc";
$sql=$empire->query($query);
//分類
$zcstr="";
$zcsql=$empire->query("select classid,classname from {$dbtbpre}enewsztclass order by classid");
while($zcr=$empire->fetch($zcsql))
{
$select="";
if($zcr[classid]==$zcid)
{
$select=" selected";
}
$zcstr.="<option value='".$zcr[classid]."'".$select.">".$zcr[classname]."</option>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>推送信息到專題</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td>位置: 推送信息到專題
<div align="right"> </div></td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<form name="searchform" method="GET" action="PushToZt.php">
<?=$ecms_hashur['eform']?>
<tr>
<td> 選擇專題分類:
<select name="select" id="select" onchange=window.location='PushToZt.php?<?=$ecms_hashur['ehref']?>&classid=<?=$classid?>&tid=<?=$tid?>&id=<?=$id?>&sinfo=<?=$sinfo?>&oldztids=<?=$info_ztids?>&oldcids=<?=$info_cids?>&zcid='+this.options[this.selectedIndex].value>
<option value="0">所有分類</option>
<?=$zcstr?>
</select></td>
</tr>
</form>
</table>
<form name="form1" method="post" action="PushToZt.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<?=$ecms_hashur['form']?>
<tr>
<td>
<?php
if(empty($sinfo))
{
?>
推送信息ID:<?=$id?>
<?php
}
else
{
?>
推送信息:<script>document.write(opener.document.add.title.value);</script>
<?php
}
?>
</td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr class="header">
<td width="74%" height="25"> 專題名稱</td>
</tr>
<?
while($r=$empire->fetch($sql))
{
$check='';
if($info_ztids&&strstr(','.$info_ztids.',',','.$r[ztid].','))
{
$check=' checked';
}
?>
<tr bgcolor="#FFFFFF" id="chzt<?=$r[ztid]?>">
<td height="25"><input name="ztid[]" type="checkbox" id="ztid[]" value="<?=$r[ztid]?>"<?=$check?>>
<?=$r['ztname']?></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25"><table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><input type="radio" name="cid[<?=$r['ztid']?>]" value="-<?=$r[ztid]?>"<?=empty($check)||$firstpost==1||($check&&$info_cids&&strstr(','.$info_cids.',',',-'.$r[ztid].','))?' checked':''?>> 不屬專題子類</td>
</tr>
<?php
$csql=$empire->query("select cid,cname from {$dbtbpre}enewszttype where ztid='$r[ztid]'");
while($cr=$empire->fetch($csql))
{
?>
<tr>
<td><input type="radio" name="cid[<?=$r['ztid']?>]" value="<?=$cr[cid]?>"<?=$check&&$info_cids&&strstr(','.$info_cids.',',','.$cr[cid].',')?' checked':''?>> <?=$cr[cname]?></td>
</tr>
<?php
}
?>
</table></td>
</tr>
<?php
}
?>
<tr bgcolor="#FFFFFF">
<td height="25"><div align="center">
<input type="submit" name="Submit2" value="確定推送">
<input type="button" name="Submit3" value="取消" onclick="window.close();">
<input name="enews" type="hidden" id="enews" value="PushInfoToZt">
<input name="classid" type="hidden" id="classid" value="<?=$classid?>">
<input name="tid" type="hidden" id="tid" value="<?=$tid?>">
<input name="id" type="hidden" id="id" value="<?=$id?>">
<input name="sinfo" type="hidden" id="sinfo" value="<?=$sinfo?>">
<input name="oldztids" type="hidden" value="<?=$info_ztids?>">
<input name="oldcids" type="hidden" value="<?=$info_cids?>">
</div></td>
</tr>
</table>
</form>
</body>
</html>
<?
db_close();
$empire=null;
?>