module.php
2.72 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
<?php
/**
* 送粽子模块
*
* [天蓝创想] www.v0591.com 5517286@qq.com
*/
defined('IN_IA') or exit('Access Denied');
class Hl_zzzModule extends WeModule {
public $tablename = 'zzz_reply';
public function fieldsFormDisplay($rid = 0) {
global $_W;
if (!empty($rid)) {
$reply = pdo_fetch("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
} else {
$reply = array(
'periodlottery' => 1,
'maxlottery' => 5,
'prace_times' => 10,
'start_time' => TIMESTAMP,
'end_time' => TIMESTAMP + 3600 * 24 * 7,
'smallunit' => '冰花',
'bigunit' => '杯',
);
}
include $this->template('form');
}
public function fieldsFormValidate($rid = 0) {
return true;
}
public function fieldsFormSubmit($rid = 0) {
global $_GPC, $_W;
$id = intval($_GPC['reply_id']);
$insert = array(
'rid' => $rid,
'uniacid' => $_W['uniacid'],
'picture' => $_GPC['picture'],
'title' => $_GPC['title'],
'prace_times' => intval($_GPC['prace_times']),
'description' => $_GPC['description'],
'smallunit' => $_GPC['smallunit'],
'bigunit' => $_GPC['bigunit'],
'bgurl' => $_GPC['bgurl'],
'periodlottery' => 1,
'maxlottery' => intval($_GPC['maxlottery']),
'rule' => htmlspecialchars_decode($_GPC['rule']),
'start_time' => strtotime($_GPC['start_time']),
'end_time' => strtotime($_GPC['end_time']),
'guzhuurl' => $_GPC['guzhuurl'],
'sharevalue' => intval($_GPC['sharevalue'])
);
if (empty($id)) {
pdo_insert($this->tablename, $insert);
} else {
if (!empty($_GPC['picture'])) {
load()->func('file');
file_delete($_GPC['picture-old']);
} else {
unset($insert['picture']);
}
pdo_update($this->tablename, $insert, array('id' => $id));
}
}
public function ruleDeleted($rid = 0) {
global $_W;
$replies = pdo_fetchall("SELECT id, picture FROM " . tablename($this->tablename) . " WHERE rid = '$rid'");
$deleteid = array();
load()->func('file');
if (!empty($replies)) {
foreach ($replies as $index => $row) {
file_delete($row['picture']);
$deleteid[] = $row['id'];
}
}
pdo_delete($this->tablename, "id IN ('" . implode("','", $deleteid) . "')");
return true;
}
}