extend_thread_rushreply.php
5.48 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_rushreply.php 34216 2013-11-14 02:32:06Z hypowang $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_rushreply extends extend_thread_base {
public function before_newthread($parameters) {
if($this->group['allowpostrushreply']) {
$_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
$_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
$_GET['rewardfloor'] = preg_replace('#[^0-9|*|,]#', '', $_GET['rewardfloor']);
$_GET['stopfloor'] = intval($_GET['stopfloor']);
$_GET['replylimit'] = intval($_GET['replylimit']);
$_GET['creditlimit'] = $_GET['creditlimit'] == '' ? '-996' : intval($_GET['creditlimit']);
if($_GET['rushreplyfrom'] > $_GET['rushreplyto'] && !empty($_GET['rushreplyto'])) {
showmessage('post_rushreply_timewrong');
}
if(($_GET['rushreplyfrom'] > TIMESTAMP) || (!empty($_GET['rushreplyto']) && $_GET['rushreplyto'] < TIMESTAMP) || ($_GET['stopfloor'] == 1) ) {
$this->param['closed'] = true;
}
if(!empty($_GET['rewardfloor']) && !empty($_GET['stopfloor'])) {
$floors = explode(',', $_GET['rewardfloor']);
if(!empty($floors) && is_array($floors)) {
foreach($floors AS $key => $floor) {
if(strpos($floor, '*') === false) {
if(intval($floor) == 0) {
unset($floors[$key]);
} elseif($floor > $_GET['stopfloor']) {
unset($floors[$key]);
}
}
}
$_GET['rewardfloor'] = implode(',', $floors);
}
}
$parameters['tstatus'] = setstatus(3, 1, $parameters['tstatus']);
$parameters['tstatus'] = setstatus(1, 1, $parameters['tstatus']);
$this->param['tstatus'] = $parameters['tstatus'];
}
}
public function after_newthread() {
if($this->group['allowpostrushreply']) {
$rushdata = array('tid' => $this->tid, 'stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit'], 'replylimit' => $_GET['replylimit']);
C::t('forum_threadrush')->insert($rushdata);
}
}
public function before_newreply() {
global $_G, $rushinfo;
if(getstatus($this->thread['status'], 3) && $rushinfo['replylimit'] > 0) {
$replycount = C::t('forum_post')->count_by_tid_invisible_authorid($this->thread['tid'], $_G['uid']);
if($replycount >= $rushinfo['replylimit']) {
showmessage('noreply_replynum_error');
}
}
}
public function after_newreply() {
global $rushinfo;
if(getstatus($this->thread['status'], 3) && $this->param['maxposition']) {
$rushstopfloor = $rushinfo['stopfloor'];
if($rushstopfloor > 0 && $this->thread['closed'] == 0 && $this->param['maxposition'] >= $rushstopfloor) {
$this->param['updatethreaddata'] = array_merge((array)$this->param['updatethreaddata'], array('closed' => 1));
}
}
}
public function before_editpost($parameters) {
global $_G, $rushreply;
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
if($rushreply) {
$_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
$_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
$_GET['rewardfloor'] = preg_replace('#[^0-9|*|,]#', '', $_GET['rewardfloor']);
$_GET['stopfloor'] = intval($_GET['stopfloor']);
$_GET['replylimit'] = intval($_GET['replylimit']);
$_GET['creditlimit'] = $_GET['creditlimit'] == '' ? '-996' : intval($_GET['creditlimit']);
if($_GET['rushreplyfrom'] > $_GET['rushreplyto'] && !empty($_GET['rushreplyto'])) {
showmessage('post_rushreply_timewrong');
}
$maxposition = C::t('forum_post')->fetch_maxposition_by_tid($this->thread['posttableid'], $this->thread['tid']);
if($this->thread['closed'] == 1 && ((!$_GET['rushreplyfrom'] && !$_GET['rushreplyto']) || ($_GET['rushreplyfrom'] < $_G['timestamp'] && $_GET['rushreplyto'] > $_G['timestamp']) || (!$_GET['rushreplyfrom'] && $_GET['rushreplyto'] > $_G['timestamp']) || ($_GET['stopfloor'] && $_GET['stopfloor'] > $maxposition) )) {
$this->param['threadupdatearr']['closed'] = 0;
} elseif($this->thread['closed'] == 0 && (($_GET['rushreplyfrom'] && $_GET['rushreplyfrom'] > $_G['timestamp']) || ($_GET['rushreplyto'] && $_GET['rushreplyto'] && $_GET['rushreplyto'] < $_G['timestamp']) || ($_GET['stopfloor'] && $_GET['stopfloor'] <= $maxposition) )) {
$this->param['threadupdatearr']['closed'] = 1;
}
if(!empty($_GET['rewardfloor']) && !empty($_GET['stopfloor'])) {
$floors = explode(',', $_GET['rewardfloor']);
if(!empty($floors)) {
foreach($floors AS $key => $floor) {
if(strpos($floor, '*') === false) {
if(intval($floor) == 0) {
unset($floors[$key]);
} elseif($floor > $_GET['stopfloor']) {
unset($floors[$key]);
}
}
}
}
$_GET['rewardfloor'] = implode(',', $floors);
}
$rushdata = array('stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit'], 'replylimit' => $_GET['replylimit']);
C::t('forum_threadrush')->update($this->thread['tid'], $rushdata);
}
}
}
public function before_deletepost() {
global $rushreply;
if($rushreply) {
showmessage('post_edit_delete_rushreply_nopermission', NULL);
}
}
}
?>