site.php
5.84 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
<?php
/**
* 贺卡模块微站定义
*
* @author 超级无聊
* @url
*/
defined('IN_IA') or exit('Access Denied');
class Wl_hekaModuleSite extends WeModuleSite {
public $tablename = 'heka_reply';
public function getHomeTiles() {
global $_W;
$urls = array();
$list = pdo_fetchall("SELECT name, id FROM " . tablename('rule') . " WHERE uniacid = '{$_W['uniacid']}' AND module = 'wl_heka'");
if (!empty($list)) {
foreach ($list as $row) {
$urls[] = array('title' => $row['name'], 'url' => $this->createMobileUrl('index', array('id' => $row['id'])));
}
}
return $urls;
}
public function doMobileindex() {
global $_GPC, $_W;
include $this->template('index');
}
public function doMobileshow() {
global $_GPC, $_W;
if (!empty($_GPC['cid'])) {
$show = pdo_fetch("SELECT * FROM " . tablename('heka_list') . " WHERE id = :cid ORDER BY `id` DESC", array(':cid' => $_GPC['cid']));
}
if ($show == false) {
$show = array(
'id' => 0,
'title' => '收卡人',
'author' => '署名',
);
} else {
pdo_update('heka_list', array('hits' => intval($show['hits']) + 1), array('id' => $show['id']));
}
$nikename = $_W['uniaccount']['name'];
$card = $_GPC['card'];
include $this->template($card);
}
public function doMobileset() {
global $_GPC,$_W;
$_GPC['title'] = urldecode($_GPC['title']);
$_GPC['content'] = urldecode($_GPC['content']);
$_GPC['author'] = urldecode($_GPC['author']);
$_GPC['cardName'] = urldecode($_GPC['cardName']);
$insert = array(
'rid' => $_GPC['id'],
'weid' => $_W['uniacid'],
'title' => $_GPC['title'],
'card' => $_GPC['card'],
'content' => $_GPC['content'],
'author' => $_GPC['author'],
'cardName' => $_GPC['cardName'],
'from_user' => $_W['fans']['from_user'],
'create_time' => time(),
);
$temp = pdo_insert('heka_list', $insert);
if ($temp == false) {
$this->_message(0, '保存数据失败');
} else {
$id = pdo_insertid();
$this->_message($id, '保存数据成功', 1, $_GPC['author']);
}
}
public function doMobileshare() {
global $_GPC;
$id = $_GPC['cid'];
$show = pdo_fetch("SELECT share FROM " . tablename('heka_list') . " WHERE id = :cid ORDER BY `id` DESC", array(':cid' => $id));
if ($show != false) {
if (empty($show['share'])) {
$show['share'] = 0;
}
pdo_update('heka_list', array('share' => intval($show['share']) + 1), array('id' => $id));
}
}
public function _message($_id, $_msg, $_state = 0, $_username = '') {
$_data = array(
'id' => $_id,
'msg' => $_msg,
'state' => $_state,
);
if (!empty($_username)) {
$_data['username'] = $_username;
}
echo json_encode($_data);
}
public function doWebList() {
global $_GPC, $_W;
$weid = $_W['uniacid'];
if (checksubmit('delete')) {
pdo_delete('heka_list', " id IN ('" . implode("','", $_GPC['select']) . "')");
message('删除成功!', referer(),'success');
}
$where = ' WHERE `weid` = :weid';
$params = array(':weid' => $_W['uniacid']);
$sql = 'SELECT COUNT(*) FROM ' . tablename('heka_list') . $where;
$total = pdo_fetchcolumn($sql, $params);
if ($total > 0) {
$pindex = max(1, intval($_GPC['page']));
$psize = 15;
$sql = 'SELECT * FROM ' . tablename('heka_list') . $where . ' ORDER BY `create_time` DESC LIMIT ' .
($pindex - 1) * $psize . ',' . $psize;
$list = pdo_fetchall($sql, $params);
$pager = pagination($total, $pindex, $psize);
}
if (checksubmit('export')) {
/* 输入到CSV文件 */
$html = "\xEF\xBB\xBF";
/* 输出表头 */
$filter = array(
'id' => '编号',
'title' => '标题',
'author' => '署名',
'hits' => '点击数',
'share' => '分享数',
'create_time' => '创建时间',
);
foreach ($filter as $key => $value) {
$html .= $value . "\t,";
}
$html .= "\n";
foreach ($list as $key => $value) {
foreach ($filter as $index => $title) {
if ($index != 'create_time') {
$html .= $value[$index] . "\t, ";
} else {
$html .= date('Y-m-d H:i:s', $value[$index]) . "\t, ";
}
}
$html .= "\n";
}
/* 输出CSV文件 */
header("Content-type:text/csv");
header("Content-Disposition:attachment; filename=全部数据.csv");
echo $html;
exit();
}
include $this->template('list');
}
public function doWebDeleteImage() {
global $_GPC;
load()->func('file');
$id = intval($_GPC['id']);
$sql = "SELECT id, picture FROM " . tablename($this->tablename) . " WHERE `id`=:id";
$row = pdo_fetch($sql, array(':id' => $id));
if (empty($row)) {
message('抱歉,回复不存在或是已经被删除!', '', 'error');
}
if (pdo_update($this->tablename, array('picture' => ''), array('id' => $id))) {
file_delete($row['picture']);
}
message('删除图片成功!', '', 'success');
}
}