|
@@ -1,92 +1,94 @@
|
1
|
|
-<?
|
2
|
|
-class Misc {
|
3
|
|
- /**
|
4
|
|
- * Send an email.
|
5
|
|
- *
|
6
|
|
- * @param string $To the email address to send it to.
|
7
|
|
- * @param string $Subject
|
8
|
|
- * @param string $Body
|
9
|
|
- * @param string $From The user part of the user@SITE_DOMAIN email address.
|
10
|
|
- * @param string $ContentType text/plain or text/html
|
11
|
|
- */
|
12
|
|
- public static function send_email($To, $Subject, $Body, $From = 'noreply', $ContentType = 'text/plain') {
|
13
|
|
- $Headers = 'MIME-Version: 1.0'."\r\n";
|
14
|
|
- $Headers .= 'Content-type: '.$ContentType.'; charset=iso-8859-1'."\r\n";
|
15
|
|
- $Headers .= 'From: '.SITE_NAME.' <'.$From.'@'.SITE_DOMAIN.'>'."\r\n";
|
16
|
|
- $Headers .= 'Reply-To: '.$From.'@'.SITE_DOMAIN."\r\n";
|
17
|
|
- $Headers .= 'X-Mailer: Project Gazelle'."\r\n";
|
18
|
|
- $Headers .= 'Message-Id: <'.Users::make_secret().'@'.SITE_DOMAIN.">\r\n";
|
19
|
|
- $Headers .= 'X-Priority: 3'."\r\n";
|
20
|
|
- // check if email is enabled
|
21
|
|
- if (FEATURE_SEND_EMAIL) {
|
22
|
|
- mail($To, $Subject, $Body, $Headers, "-f $From@".SITE_DOMAIN);
|
|
1
|
+<?php
|
|
2
|
+class Misc
|
|
3
|
+{
|
|
4
|
+ /**
|
|
5
|
+ * Send an email.
|
|
6
|
+ *
|
|
7
|
+ * @param string $To the email address to send it to.
|
|
8
|
+ * @param string $Subject
|
|
9
|
+ * @param string $Body
|
|
10
|
+ * @param string $From The user part of the user@SITE_DOMAIN email address.
|
|
11
|
+ * @param string $ContentType text/plain or text/html
|
|
12
|
+ */
|
|
13
|
+ public static function send_email($To, $Subject, $Body, $From = 'noreply', $ContentType = 'text/plain')
|
|
14
|
+ {
|
|
15
|
+ $Headers = 'MIME-Version: 1.0'."\r\n";
|
|
16
|
+ $Headers .= 'Content-type: '.$ContentType.'; charset=iso-8859-1'."\r\n";
|
|
17
|
+ $Headers .= 'From: '.SITE_NAME.' <'.$From.'@'.SITE_DOMAIN.'>'."\r\n";
|
|
18
|
+ $Headers .= 'Reply-To: '.$From.'@'.SITE_DOMAIN."\r\n";
|
|
19
|
+ $Headers .= 'X-Mailer: Project Gazelle'."\r\n";
|
|
20
|
+ $Headers .= 'Message-Id: <'.Users::make_secret().'@'.SITE_DOMAIN.">\r\n";
|
|
21
|
+ $Headers .= 'X-Priority: 3'."\r\n";
|
|
22
|
+ // check if email is enabled
|
|
23
|
+ if (FEATURE_SEND_EMAIL) {
|
|
24
|
+ mail($To, $Subject, $Body, $Headers, "-f $From@".SITE_DOMAIN);
|
|
25
|
+ }
|
23
|
26
|
}
|
24
|
|
- }
|
25
|
|
-
|
26
|
|
-
|
27
|
|
- /**
|
28
|
|
- * Sanitize a string to be allowed as a filename.
|
29
|
|
- *
|
30
|
|
- * @param string $EscapeStr the string to escape
|
31
|
|
- * @return the string with all banned characters removed.
|
32
|
|
- */
|
33
|
|
- public static function file_string($EscapeStr) {
|
34
|
|
- return str_replace(array('"', '*', '/', ':', '<', '>', '?', '\\', '|'), '', $EscapeStr);
|
35
|
|
- }
|
36
|
|
-
|
37
|
|
-
|
38
|
|
- /**
|
39
|
|
- * Sends a PM from $FromId to $ToId.
|
40
|
|
- *
|
41
|
|
- * @param string $ToID ID of user to send PM to. If $ToID is an array and $ConvID is empty, a message will be sent to multiple users.
|
42
|
|
- * @param string $FromID ID of user to send PM from, 0 to send from system
|
43
|
|
- * @param string $Subject
|
44
|
|
- * @param string $Body
|
45
|
|
- * @param int $ConvID The conversation the message goes in. Leave blank to start a new conversation.
|
46
|
|
- * @return
|
47
|
|
- */
|
48
|
|
- public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
|
49
|
|
- global $Time;
|
50
|
|
- $UnescapedSubject = $Subject;
|
51
|
|
- $UnescapedBody = $Body;
|
52
|
|
- $Subject = db_string($Subject);
|
53
|
|
- $Body = Crypto::encrypt(substr($Body, 0, 49135)); // 49135 -> encryption -> 65536 (max length in mysql)
|
54
|
|
- if ($ToID == 0) {
|
55
|
|
- // Don't allow users to send messages to the system
|
56
|
|
- return;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+ /**
|
|
30
|
+ * Sanitize a string to be allowed as a filename.
|
|
31
|
+ *
|
|
32
|
+ * @param string $EscapeStr the string to escape
|
|
33
|
+ * @return the string with all banned characters removed.
|
|
34
|
+ */
|
|
35
|
+ public static function file_string($EscapeStr)
|
|
36
|
+ {
|
|
37
|
+ return str_replace(array('"', '*', '/', ':', '<', '>', '?', '\\', '|'), '', $EscapeStr);
|
57
|
38
|
}
|
58
|
39
|
|
59
|
|
- $QueryID = G::$DB->get_query_id();
|
60
|
40
|
|
61
|
|
- if ($ConvID == '') {
|
62
|
|
- // Create a new conversation.
|
63
|
|
- G::$DB->query("
|
|
41
|
+ /**
|
|
42
|
+ * Sends a PM from $FromId to $ToId.
|
|
43
|
+ *
|
|
44
|
+ * @param string $ToID ID of user to send PM to. If $ToID is an array and $ConvID is empty, a message will be sent to multiple users.
|
|
45
|
+ * @param string $FromID ID of user to send PM from, 0 to send from system
|
|
46
|
+ * @param string $Subject
|
|
47
|
+ * @param string $Body
|
|
48
|
+ * @param int $ConvID The conversation the message goes in. Leave blank to start a new conversation.
|
|
49
|
+ * @return
|
|
50
|
+ */
|
|
51
|
+ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '')
|
|
52
|
+ {
|
|
53
|
+ global $Time;
|
|
54
|
+ $UnescapedSubject = $Subject;
|
|
55
|
+ $UnescapedBody = $Body;
|
|
56
|
+ $Subject = db_string($Subject);
|
|
57
|
+ $Body = Crypto::encrypt(substr($Body, 0, 49135)); // 49135 -> encryption -> 65536 (max length in mysql)
|
|
58
|
+ if ($ToID == 0) {
|
|
59
|
+ // Don't allow users to send messages to the system
|
|
60
|
+ return;
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ $QueryID = G::$DB->get_query_id();
|
|
64
|
+
|
|
65
|
+ if ($ConvID == '') {
|
|
66
|
+ // Create a new conversation.
|
|
67
|
+ G::$DB->query("
|
64
|
68
|
INSERT INTO pm_conversations (Subject)
|
65
|
69
|
VALUES ('$Subject')");
|
66
|
|
- $ConvID = G::$DB->inserted_id();
|
67
|
|
- G::$DB->query("
|
|
70
|
+ $ConvID = G::$DB->inserted_id();
|
|
71
|
+ G::$DB->query("
|
68
|
72
|
INSERT INTO pm_conversations_users
|
69
|
73
|
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
|
70
|
74
|
VALUES
|
71
|
75
|
('$ToID', '$ConvID', '1','0', NOW(), NOW(), '1')");
|
72
|
|
- if ($FromID == $ToID) {
|
73
|
|
- G::$DB->query("
|
|
76
|
+ if ($FromID == $ToID) {
|
|
77
|
+ G::$DB->query("
|
74
|
78
|
UPDATE pm_conversations_users
|
75
|
79
|
SET InSentbox = '1'
|
76
|
|
- WHERE ConvID = '$ConvID'"
|
77
|
|
- );
|
78
|
|
- }
|
79
|
|
- elseif ($FromID != 0) {
|
80
|
|
- G::$DB->query("
|
|
80
|
+ WHERE ConvID = '$ConvID'");
|
|
81
|
+ } elseif ($FromID != 0) {
|
|
82
|
+ G::$DB->query("
|
81
|
83
|
INSERT INTO pm_conversations_users
|
82
|
84
|
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
|
83
|
85
|
VALUES
|
84
|
86
|
('$FromID', '$ConvID', '0','1', NOW(), NOW(), '0')");
|
85
|
|
- }
|
86
|
|
- $ToID = array($ToID);
|
87
|
|
- } else {
|
88
|
|
- // Update the pre-existing conversations.
|
89
|
|
- G::$DB->query("
|
|
87
|
+ }
|
|
88
|
+ $ToID = array($ToID);
|
|
89
|
+ } else {
|
|
90
|
+ // Update the pre-existing conversations.
|
|
91
|
+ G::$DB->query("
|
90
|
92
|
UPDATE pm_conversations_users
|
91
|
93
|
SET
|
92
|
94
|
InInbox = '1',
|
|
@@ -95,102 +97,103 @@ class Misc {
|
95
|
97
|
WHERE UserID IN (".implode(',', $ToID).")
|
96
|
98
|
AND ConvID = '$ConvID'");
|
97
|
99
|
|
98
|
|
- G::$DB->query("
|
|
100
|
+ G::$DB->query("
|
99
|
101
|
UPDATE pm_conversations_users
|
100
|
102
|
SET
|
101
|
103
|
InSentbox = '1',
|
102
|
104
|
SentDate = NOW()
|
103
|
105
|
WHERE UserID = '$FromID'
|
104
|
106
|
AND ConvID = '$ConvID'");
|
105
|
|
- }
|
|
107
|
+ }
|
106
|
108
|
|
107
|
|
- // Now that we have a $ConvID for sure, send the message.
|
108
|
|
- G::$DB->query("
|
|
109
|
+ // Now that we have a $ConvID for sure, send the message.
|
|
110
|
+ G::$DB->query("
|
109
|
111
|
INSERT INTO pm_messages
|
110
|
112
|
(SenderID, ConvID, SentDate, Body)
|
111
|
113
|
VALUES
|
112
|
114
|
('$FromID', '$ConvID', NOW(), '$Body')");
|
113
|
115
|
|
114
|
|
- // Update the cached new message count.
|
115
|
|
- foreach ($ToID as $ID) {
|
116
|
|
- G::$DB->query("
|
|
116
|
+ // Update the cached new message count.
|
|
117
|
+ foreach ($ToID as $ID) {
|
|
118
|
+ G::$DB->query("
|
117
|
119
|
SELECT COUNT(ConvID)
|
118
|
120
|
FROM pm_conversations_users
|
119
|
121
|
WHERE UnRead = '1'
|
120
|
122
|
AND UserID = '$ID'
|
121
|
123
|
AND InInbox = '1'");
|
122
|
|
- list($UnRead) = G::$DB->next_record();
|
123
|
|
- G::$Cache->cache_value("inbox_new_$ID", $UnRead);
|
124
|
|
- }
|
|
124
|
+ list($UnRead) = G::$DB->next_record();
|
|
125
|
+ G::$Cache->cache_value("inbox_new_$ID", $UnRead);
|
|
126
|
+ }
|
125
|
127
|
|
126
|
|
- G::$DB->query("
|
|
128
|
+ G::$DB->query("
|
127
|
129
|
SELECT Username
|
128
|
130
|
FROM users_main
|
129
|
131
|
WHERE ID = '$FromID'");
|
130
|
|
- list($SenderName) = G::$DB->next_record();
|
131
|
|
- foreach ($ToID as $ID) {
|
132
|
|
- G::$DB->query("
|
|
132
|
+ list($SenderName) = G::$DB->next_record();
|
|
133
|
+ foreach ($ToID as $ID) {
|
|
134
|
+ G::$DB->query("
|
133
|
135
|
SELECT COUNT(ConvID)
|
134
|
136
|
FROM pm_conversations_users
|
135
|
137
|
WHERE UnRead = '1'
|
136
|
138
|
AND UserID = '$ID'
|
137
|
139
|
AND InInbox = '1'");
|
138
|
|
- list($UnRead) = G::$DB->next_record();
|
139
|
|
- G::$Cache->cache_value("inbox_new_$ID", $UnRead);
|
140
|
|
- }
|
|
140
|
+ list($UnRead) = G::$DB->next_record();
|
|
141
|
+ G::$Cache->cache_value("inbox_new_$ID", $UnRead);
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ G::$DB->set_query_id($QueryID);
|
141
|
145
|
|
142
|
|
- G::$DB->set_query_id($QueryID);
|
143
|
|
-
|
144
|
|
- return $ConvID;
|
145
|
|
- }
|
146
|
|
-
|
147
|
|
- /**
|
148
|
|
- * Create thread function, things should already be escaped when sent here.
|
149
|
|
- *
|
150
|
|
- * @param int $ForumID
|
151
|
|
- * @param int $AuthorID ID of the user creating the post.
|
152
|
|
- * @param string $Title
|
153
|
|
- * @param string $PostBody
|
154
|
|
- * @return -1 on error, -2 on user not existing, thread id on success.
|
155
|
|
- */
|
156
|
|
- public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
|
157
|
|
- global $Time;
|
158
|
|
- if (!$ForumID || !$AuthorID || !is_number($AuthorID) || !$Title || !$PostBody) {
|
159
|
|
- return -1;
|
|
146
|
+ return $ConvID;
|
160
|
147
|
}
|
161
|
148
|
|
162
|
|
- $QueryID = G::$DB->get_query_id();
|
|
149
|
+ /**
|
|
150
|
+ * Create thread function, things should already be escaped when sent here.
|
|
151
|
+ *
|
|
152
|
+ * @param int $ForumID
|
|
153
|
+ * @param int $AuthorID ID of the user creating the post.
|
|
154
|
+ * @param string $Title
|
|
155
|
+ * @param string $PostBody
|
|
156
|
+ * @return -1 on error, -2 on user not existing, thread id on success.
|
|
157
|
+ */
|
|
158
|
+ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody)
|
|
159
|
+ {
|
|
160
|
+ global $Time;
|
|
161
|
+ if (!$ForumID || !$AuthorID || !is_number($AuthorID) || !$Title || !$PostBody) {
|
|
162
|
+ return -1;
|
|
163
|
+ }
|
|
164
|
+
|
|
165
|
+ $QueryID = G::$DB->get_query_id();
|
163
|
166
|
|
164
|
|
- G::$DB->query("
|
|
167
|
+ G::$DB->query("
|
165
|
168
|
SELECT Username
|
166
|
169
|
FROM users_main
|
167
|
170
|
WHERE ID = $AuthorID");
|
168
|
|
- if (!G::$DB->has_results()) {
|
169
|
|
- G::$DB->set_query_id($QueryID);
|
170
|
|
- return -2;
|
171
|
|
- }
|
172
|
|
- list($AuthorName) = G::$DB->next_record();
|
|
171
|
+ if (!G::$DB->has_results()) {
|
|
172
|
+ G::$DB->set_query_id($QueryID);
|
|
173
|
+ return -2;
|
|
174
|
+ }
|
|
175
|
+ list($AuthorName) = G::$DB->next_record();
|
173
|
176
|
|
174
|
|
- $ThreadInfo = [];
|
175
|
|
- $ThreadInfo['IsLocked'] = 0;
|
176
|
|
- $ThreadInfo['IsSticky'] = 0;
|
|
177
|
+ $ThreadInfo = [];
|
|
178
|
+ $ThreadInfo['IsLocked'] = 0;
|
|
179
|
+ $ThreadInfo['IsSticky'] = 0;
|
177
|
180
|
|
178
|
|
- G::$DB->query("
|
|
181
|
+ G::$DB->query("
|
179
|
182
|
INSERT INTO forums_topics
|
180
|
183
|
(Title, AuthorID, ForumID, LastPostTime, LastPostAuthorID, CreatedTime)
|
181
|
184
|
VALUES
|
182
|
185
|
('$Title', '$AuthorID', '$ForumID', NOW(), '$AuthorID', NOW())");
|
183
|
|
- $TopicID = G::$DB->inserted_id();
|
184
|
|
- $Posts = 1;
|
|
186
|
+ $TopicID = G::$DB->inserted_id();
|
|
187
|
+ $Posts = 1;
|
185
|
188
|
|
186
|
|
- G::$DB->query("
|
|
189
|
+ G::$DB->query("
|
187
|
190
|
INSERT INTO forums_posts
|
188
|
191
|
(TopicID, AuthorID, AddedTime, Body)
|
189
|
192
|
VALUES
|
190
|
193
|
('$TopicID', '$AuthorID', NOW(), '$PostBody')");
|
191
|
|
- $PostID = G::$DB->inserted_id();
|
|
194
|
+ $PostID = G::$DB->inserted_id();
|
192
|
195
|
|
193
|
|
- G::$DB->query("
|
|
196
|
+ G::$DB->query("
|
194
|
197
|
UPDATE forums
|
195
|
198
|
SET
|
196
|
199
|
NumPosts = NumPosts + 1,
|
|
@@ -201,7 +204,7 @@ class Misc {
|
201
|
204
|
LastPostTime = NOW()
|
202
|
205
|
WHERE ID = '$ForumID'");
|
203
|
206
|
|
204
|
|
- G::$DB->query("
|
|
207
|
+ G::$DB->query("
|
205
|
208
|
UPDATE forums_topics
|
206
|
209
|
SET
|
207
|
210
|
NumPosts = NumPosts + 1,
|
|
@@ -210,320 +213,331 @@ class Misc {
|
210
|
213
|
LastPostTime = NOW()
|
211
|
214
|
WHERE ID = '$TopicID'");
|
212
|
215
|
|
213
|
|
- // Bump this topic to head of the cache
|
214
|
|
- list($Forum,,, $Stickies) = G::$Cache->get_value("forums_$ForumID");
|
215
|
|
- if (!empty($Forum)) {
|
216
|
|
- if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
|
217
|
|
- array_pop($Forum);
|
218
|
|
- }
|
219
|
|
- G::$DB->query("
|
|
216
|
+ // Bump this topic to head of the cache
|
|
217
|
+ list($Forum, , , $Stickies) = G::$Cache->get_value("forums_$ForumID");
|
|
218
|
+ if (!empty($Forum)) {
|
|
219
|
+ if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
|
|
220
|
+ array_pop($Forum);
|
|
221
|
+ }
|
|
222
|
+ G::$DB->query("
|
220
|
223
|
SELECT IsLocked, IsSticky, NumPosts
|
221
|
224
|
FROM forums_topics
|
222
|
225
|
WHERE ID ='$TopicID'");
|
223
|
|
- list($IsLocked, $IsSticky, $NumPosts) = G::$DB->next_record();
|
224
|
|
- $Part1 = array_slice($Forum, 0, $Stickies, true); //Stickys
|
225
|
|
- $Part2 = array(
|
226
|
|
- $TopicID => array(
|
227
|
|
- 'ID' => $TopicID,
|
228
|
|
- 'Title' => $Title,
|
229
|
|
- 'AuthorID' => $AuthorID,
|
230
|
|
- 'IsLocked' => $IsLocked,
|
231
|
|
- 'IsSticky' => $IsSticky,
|
232
|
|
- 'NumPosts' => $NumPosts,
|
233
|
|
- 'LastPostID' => $PostID,
|
234
|
|
- 'LastPostTime' => sqltime(),
|
235
|
|
- 'LastPostAuthorID' => $AuthorID,
|
236
|
|
- )
|
237
|
|
- ); //Bumped thread
|
238
|
|
- $Part3 = array_slice($Forum, $Stickies, TOPICS_PER_PAGE, true); //Rest of page
|
239
|
|
- if ($Stickies > 0) {
|
240
|
|
- $Part1 = array_slice($Forum, 0, $Stickies, true); //Stickies
|
241
|
|
- $Part3 = array_slice($Forum, $Stickies, TOPICS_PER_PAGE - $Stickies - 1, true); //Rest of page
|
242
|
|
- } else {
|
243
|
|
- $Part1 = [];
|
244
|
|
- $Part3 = $Forum;
|
245
|
|
- }
|
246
|
|
- if (is_null($Part1)) {
|
247
|
|
- $Part1 = [];
|
248
|
|
- }
|
249
|
|
- if (is_null($Part3)) {
|
250
|
|
- $Part3 = [];
|
251
|
|
- }
|
252
|
|
- $Forum = $Part1 + $Part2 + $Part3;
|
253
|
|
- G::$Cache->cache_value("forums_$ForumID", array($Forum, '', 0, $Stickies), 0);
|
|
226
|
+ list($IsLocked, $IsSticky, $NumPosts) = G::$DB->next_record();
|
|
227
|
+ $Part1 = array_slice($Forum, 0, $Stickies, true); //Stickys
|
|
228
|
+ $Part2 = array(
|
|
229
|
+ $TopicID => array(
|
|
230
|
+ 'ID' => $TopicID,
|
|
231
|
+ 'Title' => $Title,
|
|
232
|
+ 'AuthorID' => $AuthorID,
|
|
233
|
+ 'IsLocked' => $IsLocked,
|
|
234
|
+ 'IsSticky' => $IsSticky,
|
|
235
|
+ 'NumPosts' => $NumPosts,
|
|
236
|
+ 'LastPostID' => $PostID,
|
|
237
|
+ 'LastPostTime' => sqltime(),
|
|
238
|
+ 'LastPostAuthorID' => $AuthorID,
|
|
239
|
+ )
|
|
240
|
+ ); //Bumped thread
|
|
241
|
+ $Part3 = array_slice($Forum, $Stickies, TOPICS_PER_PAGE, true); //Rest of page
|
|
242
|
+ if ($Stickies > 0) {
|
|
243
|
+ $Part1 = array_slice($Forum, 0, $Stickies, true); //Stickies
|
|
244
|
+ $Part3 = array_slice($Forum, $Stickies, TOPICS_PER_PAGE - $Stickies - 1, true); //Rest of page
|
|
245
|
+ } else {
|
|
246
|
+ $Part1 = [];
|
|
247
|
+ $Part3 = $Forum;
|
|
248
|
+ }
|
|
249
|
+ if (is_null($Part1)) {
|
|
250
|
+ $Part1 = [];
|
|
251
|
+ }
|
|
252
|
+ if (is_null($Part3)) {
|
|
253
|
+ $Part3 = [];
|
|
254
|
+ }
|
|
255
|
+ $Forum = $Part1 + $Part2 + $Part3;
|
|
256
|
+ G::$Cache->cache_value("forums_$ForumID", array($Forum, '', 0, $Stickies), 0);
|
|
257
|
+ }
|
|
258
|
+
|
|
259
|
+ //Update the forum root
|
|
260
|
+ G::$Cache->begin_transaction('forums_list');
|
|
261
|
+ $UpdateArray = array(
|
|
262
|
+ 'NumPosts' => '+1',
|
|
263
|
+ 'NumTopics' => '+1',
|
|
264
|
+ 'LastPostID' => $PostID,
|
|
265
|
+ 'LastPostAuthorID' => $AuthorID,
|
|
266
|
+ 'LastPostTopicID' => $TopicID,
|
|
267
|
+ 'LastPostTime' => sqltime(),
|
|
268
|
+ 'Title' => $Title,
|
|
269
|
+ 'IsLocked' => $ThreadInfo['IsLocked'],
|
|
270
|
+ 'IsSticky' => $ThreadInfo['IsSticky']
|
|
271
|
+ );
|
|
272
|
+
|
|
273
|
+ $UpdateArray['NumTopics'] = '+1';
|
|
274
|
+
|
|
275
|
+ G::$Cache->update_row($ForumID, $UpdateArray);
|
|
276
|
+ G::$Cache->commit_transaction(0);
|
|
277
|
+
|
|
278
|
+ $CatalogueID = floor((POSTS_PER_PAGE * ceil($Posts / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE);
|
|
279
|
+ G::$Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
|
|
280
|
+ $Post = array(
|
|
281
|
+ 'ID' => $PostID,
|
|
282
|
+ 'AuthorID' => G::$LoggedUser['ID'],
|
|
283
|
+ 'AddedTime' => sqltime(),
|
|
284
|
+ 'Body' => $PostBody,
|
|
285
|
+ 'EditedUserID' => 0,
|
|
286
|
+ 'EditedTime' => null,
|
|
287
|
+ 'Username' => ''
|
|
288
|
+ );
|
|
289
|
+ G::$Cache->insert('', $Post);
|
|
290
|
+ G::$Cache->commit_transaction(0);
|
|
291
|
+
|
|
292
|
+ G::$Cache->begin_transaction('thread_'.$TopicID.'_info');
|
|
293
|
+ G::$Cache->update_row(false, array('Posts' => '+1', 'LastPostAuthorID' => $AuthorID));
|
|
294
|
+ G::$Cache->commit_transaction(0);
|
|
295
|
+
|
|
296
|
+ G::$DB->set_query_id($QueryID);
|
|
297
|
+
|
|
298
|
+ return $TopicID;
|
254
|
299
|
}
|
255
|
300
|
|
256
|
|
- //Update the forum root
|
257
|
|
- G::$Cache->begin_transaction('forums_list');
|
258
|
|
- $UpdateArray = array(
|
259
|
|
- 'NumPosts' => '+1',
|
260
|
|
- 'NumTopics' => '+1',
|
261
|
|
- 'LastPostID' => $PostID,
|
262
|
|
- 'LastPostAuthorID' => $AuthorID,
|
263
|
|
- 'LastPostTopicID' => $TopicID,
|
264
|
|
- 'LastPostTime' => sqltime(),
|
265
|
|
- 'Title' => $Title,
|
266
|
|
- 'IsLocked' => $ThreadInfo['IsLocked'],
|
267
|
|
- 'IsSticky' => $ThreadInfo['IsSticky']
|
268
|
|
- );
|
269
|
|
-
|
270
|
|
- $UpdateArray['NumTopics'] = '+1';
|
271
|
|
-
|
272
|
|
- G::$Cache->update_row($ForumID, $UpdateArray);
|
273
|
|
- G::$Cache->commit_transaction(0);
|
274
|
|
-
|
275
|
|
- $CatalogueID = floor((POSTS_PER_PAGE * ceil($Posts / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE);
|
276
|
|
- G::$Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
|
277
|
|
- $Post = array(
|
278
|
|
- 'ID' => $PostID,
|
279
|
|
- 'AuthorID' => G::$LoggedUser['ID'],
|
280
|
|
- 'AddedTime' => sqltime(),
|
281
|
|
- 'Body' => $PostBody,
|
282
|
|
- 'EditedUserID' => 0,
|
283
|
|
- 'EditedTime' => NULL,
|
284
|
|
- 'Username' => ''
|
285
|
|
- );
|
286
|
|
- G::$Cache->insert('', $Post);
|
287
|
|
- G::$Cache->commit_transaction(0);
|
288
|
|
-
|
289
|
|
- G::$Cache->begin_transaction('thread_'.$TopicID.'_info');
|
290
|
|
- G::$Cache->update_row(false, array('Posts' => '+1', 'LastPostAuthorID' => $AuthorID));
|
291
|
|
- G::$Cache->commit_transaction(0);
|
292
|
|
-
|
293
|
|
- G::$DB->set_query_id($QueryID);
|
294
|
|
-
|
295
|
|
- return $TopicID;
|
296
|
|
- }
|
297
|
|
-
|
298
|
|
- /**
|
299
|
|
- * If the suffix of $Haystack is $Needle
|
300
|
|
- *
|
301
|
|
- * @param string $Haystack String to search in
|
302
|
|
- * @param string $Needle String to search for
|
303
|
|
- * @return boolean True if $Needle is a suffix of $Haystack
|
304
|
|
- */
|
305
|
|
- public static function ends_with($Haystack, $Needle) {
|
306
|
|
- return substr($Haystack, strlen($Needle) * -1) == $Needle;
|
307
|
|
- }
|
308
|
|
-
|
309
|
|
-
|
310
|
|
- /**
|
311
|
|
- * If the prefix of $Haystack is $Needle
|
312
|
|
- *
|
313
|
|
- * @param string $Haystack String to search in
|
314
|
|
- * @param string $Needle String to search for
|
315
|
|
- * @return boolean True if $Needle is a prefix of $Haystack
|
316
|
|
- */
|
317
|
|
- public static function starts_with($Haystack, $Needle) {
|
318
|
|
- return strpos($Haystack, $Needle) === 0;
|
319
|
|
- }
|
320
|
|
-
|
321
|
|
- /**
|
322
|
|
- * Variant of in_array() with trailing wildcard support
|
323
|
|
- *
|
324
|
|
- * @param string $Needle, array $Haystack
|
325
|
|
- * @return boolean true if (substring of) $Needle exists in $Haystack
|
326
|
|
- */
|
327
|
|
- public static function in_array_partial($Needle, $Haystack) {
|
328
|
|
- static $Searches = [];
|
329
|
|
- if (array_key_exists($Needle, $Searches)) {
|
330
|
|
- return $Searches[$Needle];
|
|
301
|
+ /**
|
|
302
|
+ * If the suffix of $Haystack is $Needle
|
|
303
|
+ *
|
|
304
|
+ * @param string $Haystack String to search in
|
|
305
|
+ * @param string $Needle String to search for
|
|
306
|
+ * @return boolean True if $Needle is a suffix of $Haystack
|
|
307
|
+ */
|
|
308
|
+ public static function ends_with($Haystack, $Needle)
|
|
309
|
+ {
|
|
310
|
+ return substr($Haystack, strlen($Needle) * -1) == $Needle;
|
331
|
311
|
}
|
332
|
|
- foreach ($Haystack as $String) {
|
333
|
|
- if (substr($String, -1) == '*') {
|
334
|
|
- if (!strncmp($Needle, $String, strlen($String) - 1)) {
|
335
|
|
- $Searches[$Needle] = true;
|
336
|
|
- return true;
|
337
|
|
- }
|
338
|
|
- } elseif (!strcmp($Needle, $String)) {
|
339
|
|
- $Searches[$Needle] = true;
|
340
|
|
- return true;
|
341
|
|
- }
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+ /**
|
|
315
|
+ * If the prefix of $Haystack is $Needle
|
|
316
|
+ *
|
|
317
|
+ * @param string $Haystack String to search in
|
|
318
|
+ * @param string $Needle String to search for
|
|
319
|
+ * @return boolean True if $Needle is a prefix of $Haystack
|
|
320
|
+ */
|
|
321
|
+ public static function starts_with($Haystack, $Needle)
|
|
322
|
+ {
|
|
323
|
+ return strpos($Haystack, $Needle) === 0;
|
342
|
324
|
}
|
343
|
|
- $Searches[$Needle] = false;
|
344
|
|
- return false;
|
345
|
|
- }
|
346
|
|
-
|
347
|
|
- /**
|
348
|
|
- * Used to check if keys in $_POST and $_GET are all set, and throws an error if not.
|
349
|
|
- * This reduces 'if' statement redundancy for a lot of variables
|
350
|
|
- *
|
351
|
|
- * @param array $Request Either $_POST or $_GET, or whatever other array you want to check.
|
352
|
|
- * @param array $Keys The keys to ensure are set.
|
353
|
|
- * @param boolean $AllowEmpty If set to true, a key that is in the request but blank will not throw an error.
|
354
|
|
- * @param int $Error The error code to throw if one of the keys isn't in the array.
|
355
|
|
- */
|
356
|
|
- public static function assert_isset_request($Request, $Keys = null, $AllowEmpty = false, $Error = 0) {
|
357
|
|
- if (isset($Keys)) {
|
358
|
|
- foreach ($Keys as $K) {
|
359
|
|
- if (!isset($Request[$K]) || ($AllowEmpty == false && $Request[$K] == '')) {
|
360
|
|
- error($Error);
|
361
|
|
- break;
|
|
325
|
+
|
|
326
|
+ /**
|
|
327
|
+ * Variant of in_array() with trailing wildcard support
|
|
328
|
+ *
|
|
329
|
+ * @param string $Needle, array $Haystack
|
|
330
|
+ * @return boolean true if (substring of) $Needle exists in $Haystack
|
|
331
|
+ */
|
|
332
|
+ public static function in_array_partial($Needle, $Haystack)
|
|
333
|
+ {
|
|
334
|
+ static $Searches = [];
|
|
335
|
+ if (array_key_exists($Needle, $Searches)) {
|
|
336
|
+ return $Searches[$Needle];
|
362
|
337
|
}
|
363
|
|
- }
|
364
|
|
- } else {
|
365
|
|
- foreach ($Request as $R) {
|
366
|
|
- if (!isset($R) || ($AllowEmpty == false && $R == '')) {
|
367
|
|
- error($Error);
|
368
|
|
- break;
|
|
338
|
+ foreach ($Haystack as $String) {
|
|
339
|
+ if (substr($String, -1) == '*') {
|
|
340
|
+ if (!strncmp($Needle, $String, strlen($String) - 1)) {
|
|
341
|
+ $Searches[$Needle] = true;
|
|
342
|
+ return true;
|
|
343
|
+ }
|
|
344
|
+ } elseif (!strcmp($Needle, $String)) {
|
|
345
|
+ $Searches[$Needle] = true;
|
|
346
|
+ return true;
|
|
347
|
+ }
|
369
|
348
|
}
|
370
|
|
- }
|
|
349
|
+ $Searches[$Needle] = false;
|
|
350
|
+ return false;
|
371
|
351
|
}
|
372
|
|
- }
|
373
|
|
-
|
374
|
|
-
|
375
|
|
- /**
|
376
|
|
- * Given an array of tags, return an array of their IDs.
|
377
|
|
- *
|
378
|
|
- * @param array $TagNames
|
379
|
|
- * @return array IDs
|
380
|
|
- */
|
381
|
|
- public static function get_tags($TagNames) {
|
382
|
|
- $TagIDs = [];
|
383
|
|
- foreach ($TagNames as $Index => $TagName) {
|
384
|
|
- $Tag = G::$Cache->get_value("tag_id_$TagName");
|
385
|
|
- if (is_array($Tag)) {
|
386
|
|
- unset($TagNames[$Index]);
|
387
|
|
- $TagIDs[$Tag['ID']] = $Tag['Name'];
|
388
|
|
- }
|
|
352
|
+
|
|
353
|
+ /**
|
|
354
|
+ * Used to check if keys in $_POST and $_GET are all set, and throws an error if not.
|
|
355
|
+ * This reduces 'if' statement redundancy for a lot of variables
|
|
356
|
+ *
|
|
357
|
+ * @param array $Request Either $_POST or $_GET, or whatever other array you want to check.
|
|
358
|
+ * @param array $Keys The keys to ensure are set.
|
|
359
|
+ * @param boolean $AllowEmpty If set to true, a key that is in the request but blank will not throw an error.
|
|
360
|
+ * @param int $Error The error code to throw if one of the keys isn't in the array.
|
|
361
|
+ */
|
|
362
|
+ public static function assert_isset_request($Request, $Keys = null, $AllowEmpty = false, $Error = 0)
|
|
363
|
+ {
|
|
364
|
+ if (isset($Keys)) {
|
|
365
|
+ foreach ($Keys as $K) {
|
|
366
|
+ if (!isset($Request[$K]) || ($AllowEmpty == false && $Request[$K] == '')) {
|
|
367
|
+ error($Error);
|
|
368
|
+ break;
|
|
369
|
+ }
|
|
370
|
+ }
|
|
371
|
+ } else {
|
|
372
|
+ foreach ($Request as $R) {
|
|
373
|
+ if (!isset($R) || ($AllowEmpty == false && $R == '')) {
|
|
374
|
+ error($Error);
|
|
375
|
+ break;
|
|
376
|
+ }
|
|
377
|
+ }
|
|
378
|
+ }
|
389
|
379
|
}
|
390
|
|
- if (count($TagNames) > 0) {
|
391
|
|
- $QueryID = G::$DB->get_query_id();
|
392
|
|
- G::$DB->query("
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+ /**
|
|
383
|
+ * Given an array of tags, return an array of their IDs.
|
|
384
|
+ *
|
|
385
|
+ * @param array $TagNames
|
|
386
|
+ * @return array IDs
|
|
387
|
+ */
|
|
388
|
+ public static function get_tags($TagNames)
|
|
389
|
+ {
|
|
390
|
+ $TagIDs = [];
|
|
391
|
+ foreach ($TagNames as $Index => $TagName) {
|
|
392
|
+ $Tag = G::$Cache->get_value("tag_id_$TagName");
|
|
393
|
+ if (is_array($Tag)) {
|
|
394
|
+ unset($TagNames[$Index]);
|
|
395
|
+ $TagIDs[$Tag['ID']] = $Tag['Name'];
|
|
396
|
+ }
|
|
397
|
+ }
|
|
398
|
+ if (count($TagNames) > 0) {
|
|
399
|
+ $QueryID = G::$DB->get_query_id();
|
|
400
|
+ G::$DB->query("
|
393
|
401
|
SELECT ID, Name
|
394
|
402
|
FROM tags
|
395
|
403
|
WHERE Name IN ('".implode("', '", $TagNames)."')");
|
396
|
|
- $SQLTagIDs = G::$DB->to_array();
|
397
|
|
- G::$DB->set_query_id($QueryID);
|
398
|
|
- foreach ($SQLTagIDs as $Tag) {
|
399
|
|
- $TagIDs[$Tag['ID']] = $Tag['Name'];
|
400
|
|
- G::$Cache->cache_value('tag_id_'.$Tag['Name'], $Tag, 0);
|
401
|
|
- }
|
402
|
|
- }
|
|
404
|
+ $SQLTagIDs = G::$DB->to_array();
|
|
405
|
+ G::$DB->set_query_id($QueryID);
|
|
406
|
+ foreach ($SQLTagIDs as $Tag) {
|
|
407
|
+ $TagIDs[$Tag['ID']] = $Tag['Name'];
|
|
408
|
+ G::$Cache->cache_value('tag_id_'.$Tag['Name'], $Tag, 0);
|
|
409
|
+ }
|
|
410
|
+ }
|
403
|
411
|
|
404
|
|
- return($TagIDs);
|
405
|
|
- }
|
|
412
|
+ return($TagIDs);
|
|
413
|
+ }
|
406
|
414
|
|
407
|
415
|
|
408
|
|
- /**
|
409
|
|
- * Gets the alias of the tag; if there is no alias, silently returns the original tag.
|
410
|
|
- *
|
411
|
|
- * @param string $BadTag the tag we want to alias
|
412
|
|
- * @return string The aliased tag.
|
413
|
|
- */
|
414
|
|
- public static function get_alias_tag($BadTag) {
|
415
|
|
- $QueryID = G::$DB->get_query_id();
|
416
|
|
- G::$DB->query("
|
|
416
|
+ /**
|
|
417
|
+ * Gets the alias of the tag; if there is no alias, silently returns the original tag.
|
|
418
|
+ *
|
|
419
|
+ * @param string $BadTag the tag we want to alias
|
|
420
|
+ * @return string The aliased tag.
|
|
421
|
+ */
|
|
422
|
+ public static function get_alias_tag($BadTag)
|
|
423
|
+ {
|
|
424
|
+ $QueryID = G::$DB->get_query_id();
|
|
425
|
+ G::$DB->query("
|
417
|
426
|
SELECT AliasTag
|
418
|
427
|
FROM tag_aliases
|
419
|
428
|
WHERE BadTag = '$BadTag'
|
420
|
429
|
LIMIT 1");
|
421
|
|
- if (G::$DB->has_results()) {
|
422
|
|
- list($AliasTag) = G::$DB->next_record();
|
423
|
|
- } else {
|
424
|
|
- $AliasTag = $BadTag;
|
|
430
|
+ if (G::$DB->has_results()) {
|
|
431
|
+ list($AliasTag) = G::$DB->next_record();
|
|
432
|
+ } else {
|
|
433
|
+ $AliasTag = $BadTag;
|
|
434
|
+ }
|
|
435
|
+ G::$DB->set_query_id($QueryID);
|
|
436
|
+ return $AliasTag;
|
425
|
437
|
}
|
426
|
|
- G::$DB->set_query_id($QueryID);
|
427
|
|
- return $AliasTag;
|
428
|
|
- }
|
429
|
|
-
|
430
|
|
-
|
431
|
|
- /*
|
432
|
|
- * Write a message to the system log.
|
433
|
|
- *
|
434
|
|
- * @param string $Message the message to write.
|
435
|
|
- */
|
436
|
|
- public static function write_log($Message) {
|
437
|
|
- global $Time;
|
438
|
|
- $QueryID = G::$DB->get_query_id();
|
439
|
|
- G::$DB->query("
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+ /*
|
|
441
|
+ * Write a message to the system log.
|
|
442
|
+ *
|
|
443
|
+ * @param string $Message the message to write.
|
|
444
|
+ */
|
|
445
|
+ public static function write_log($Message)
|
|
446
|
+ {
|
|
447
|
+ global $Time;
|
|
448
|
+ $QueryID = G::$DB->get_query_id();
|
|
449
|
+ G::$DB->query("
|
440
|
450
|
INSERT INTO log (Message, Time)
|
441
|
451
|
VALUES (?, NOW())", $Message);
|
442
|
|
- G::$DB->set_query_id($QueryID);
|
443
|
|
- }
|
444
|
|
-
|
445
|
|
-
|
446
|
|
- /**
|
447
|
|
- * Get a tag ready for database input and display.
|
448
|
|
- *
|
449
|
|
- * @param string $Str
|
450
|
|
- * @return sanitized version of $Str
|
451
|
|
- */
|
452
|
|
- public static function sanitize_tag($Str) {
|
453
|
|
- $Str = strtolower($Str);
|
454
|
|
- $Str = preg_replace('/[^a-z0-9:.]/', '', $Str);
|
455
|
|
- $Str = preg_replace('/(^[.,]*)|([.,]*$)/', '', $Str);
|
456
|
|
- $Str = htmlspecialchars($Str);
|
457
|
|
- $Str = db_string(trim($Str));
|
458
|
|
- return $Str;
|
459
|
|
- }
|
460
|
|
-
|
461
|
|
- /**
|
462
|
|
- * HTML escape an entire array for output.
|
463
|
|
- * @param array $Array, what we want to escape
|
464
|
|
- * @param boolean/array $Escape
|
465
|
|
- * if true, all keys escaped
|
466
|
|
- * if false, no escaping.
|
467
|
|
- * If array, it's a list of array keys not to escape.
|
468
|
|
- * @return mutated version of $Array with values escaped.
|
469
|
|
- */
|
470
|
|
- public static function display_array($Array, $Escape = []) {
|
471
|
|
- foreach ($Array as $Key => $Val) {
|
472
|
|
- if ((!is_array($Escape) && $Escape == true) || !in_array($Key, $Escape)) {
|
473
|
|
- $Array[$Key] = display_str($Val);
|
474
|
|
- }
|
|
452
|
+ G::$DB->set_query_id($QueryID);
|
475
|
453
|
}
|
476
|
|
- return $Array;
|
477
|
|
- }
|
478
|
|
-
|
479
|
|
- /**
|
480
|
|
- * Searches for a key/value pair in an array.
|
481
|
|
- *
|
482
|
|
- * @return array of results
|
483
|
|
- */
|
484
|
|
- public static function search_array($Array, $Key, $Value) {
|
485
|
|
- $Results = [];
|
486
|
|
- if (is_array($Array))
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+ /**
|
|
457
|
+ * Get a tag ready for database input and display.
|
|
458
|
+ *
|
|
459
|
+ * @param string $Str
|
|
460
|
+ * @return sanitized version of $Str
|
|
461
|
+ */
|
|
462
|
+ public static function sanitize_tag($Str)
|
|
463
|
+ {
|
|
464
|
+ $Str = strtolower($Str);
|
|
465
|
+ $Str = preg_replace('/[^a-z0-9:.]/', '', $Str);
|
|
466
|
+ $Str = preg_replace('/(^[.,]*)|([.,]*$)/', '', $Str);
|
|
467
|
+ $Str = htmlspecialchars($Str);
|
|
468
|
+ $Str = db_string(trim($Str));
|
|
469
|
+ return $Str;
|
|
470
|
+ }
|
|
471
|
+
|
|
472
|
+ /**
|
|
473
|
+ * HTML escape an entire array for output.
|
|
474
|
+ * @param array $Array, what we want to escape
|
|
475
|
+ * @param boolean/array $Escape
|
|
476
|
+ * if true, all keys escaped
|
|
477
|
+ * if false, no escaping.
|
|
478
|
+ * If array, it's a list of array keys not to escape.
|
|
479
|
+ * @return mutated version of $Array with values escaped.
|
|
480
|
+ */
|
|
481
|
+ public static function display_array($Array, $Escape = [])
|
487
|
482
|
{
|
488
|
|
- if (isset($Array[$Key]) && $Array[$Key] == $Value) {
|
489
|
|
- $Results[] = $Array;
|
490
|
|
- }
|
|
483
|
+ foreach ($Array as $Key => $Val) {
|
|
484
|
+ if ((!is_array($Escape) && $Escape == true) || !in_array($Key, $Escape)) {
|
|
485
|
+ $Array[$Key] = display_str($Val);
|
|
486
|
+ }
|
|
487
|
+ }
|
|
488
|
+ return $Array;
|
|
489
|
+ }
|
|
490
|
+
|
|
491
|
+ /**
|
|
492
|
+ * Searches for a key/value pair in an array.
|
|
493
|
+ *
|
|
494
|
+ * @return array of results
|
|
495
|
+ */
|
|
496
|
+ public static function search_array($Array, $Key, $Value)
|
|
497
|
+ {
|
|
498
|
+ $Results = [];
|
|
499
|
+ if (is_array($Array)) {
|
|
500
|
+ if (isset($Array[$Key]) && $Array[$Key] == $Value) {
|
|
501
|
+ $Results[] = $Array;
|
|
502
|
+ }
|
|
503
|
+
|
|
504
|
+ foreach ($Array as $subarray) {
|
|
505
|
+ $Results = array_merge($Results, self::search_array($subarray, $Key, $Value));
|
|
506
|
+ }
|
|
507
|
+ }
|
|
508
|
+ return $Results;
|
|
509
|
+ }
|
491
|
510
|
|
492
|
|
- foreach ($Array as $subarray) {
|
493
|
|
- $Results = array_merge($Results, self::search_array($subarray, $Key, $Value));
|
494
|
|
- }
|
|
511
|
+ /**
|
|
512
|
+ * Search for $Needle in the string $Haystack which is a list of values separated by $Separator.
|
|
513
|
+ * @param string $Haystack
|
|
514
|
+ * @param string $Needle
|
|
515
|
+ * @param string $Separator
|
|
516
|
+ * @param boolean $Strict
|
|
517
|
+ * @return boolean
|
|
518
|
+ */
|
|
519
|
+ public static function search_joined_string($Haystack, $Needle, $Separator = '|', $Strict = true)
|
|
520
|
+ {
|
|
521
|
+ return (array_search($Needle, explode($Separator, $Haystack), $Strict) !== false);
|
495
|
522
|
}
|
496
|
|
- return $Results;
|
497
|
|
- }
|
498
|
|
-
|
499
|
|
- /**
|
500
|
|
- * Search for $Needle in the string $Haystack which is a list of values separated by $Separator.
|
501
|
|
- * @param string $Haystack
|
502
|
|
- * @param string $Needle
|
503
|
|
- * @param string $Separator
|
504
|
|
- * @param boolean $Strict
|
505
|
|
- * @return boolean
|
506
|
|
- */
|
507
|
|
- public static function search_joined_string($Haystack, $Needle, $Separator = '|', $Strict = true) {
|
508
|
|
- return (array_search($Needle, explode($Separator, $Haystack), $Strict) !== false);
|
509
|
|
- }
|
510
|
|
-
|
511
|
|
- /**
|
512
|
|
- * Check for a ":" in the beginning of a torrent meta data string
|
513
|
|
- * to see if it's stored in the old base64-encoded format
|
514
|
|
- *
|
515
|
|
- * @param string $Torrent the torrent data
|
516
|
|
- * @return true if the torrent is stored in binary format
|
517
|
|
- */
|
518
|
|
- public static function is_new_torrent(&$Data) {
|
519
|
|
- return strpos(substr($Data, 0, 10), ':') !== false;
|
520
|
|
- }
|
521
|
|
-
|
522
|
|
- public static function display_recommend($ID, $Type, $Hide = true) {
|
523
|
|
- if ($Hide) {
|
524
|
|
- $Hide = ' style="display: none;"';
|
|
523
|
+
|
|
524
|
+ /**
|
|
525
|
+ * Check for a ":" in the beginning of a torrent meta data string
|
|
526
|
+ * to see if it's stored in the old base64-encoded format
|
|
527
|
+ *
|
|
528
|
+ * @param string $Torrent the torrent data
|
|
529
|
+ * @return true if the torrent is stored in binary format
|
|
530
|
+ */
|
|
531
|
+ public static function is_new_torrent(&$Data)
|
|
532
|
+ {
|
|
533
|
+ return strpos(substr($Data, 0, 10), ':') !== false;
|
525
|
534
|
}
|
526
|
|
- ?>
|
|
535
|
+
|
|
536
|
+ public static function display_recommend($ID, $Type, $Hide = true)
|
|
537
|
+ {
|
|
538
|
+ if ($Hide) {
|
|
539
|
+ $Hide = ' style="display: none;"';
|
|
540
|
+ } ?>
|
527
|
541
|
<div id="recommendation_div" data-id="<?=$ID?>" data-type="<?=$Type?>"<?=$Hide?> class="center">
|
528
|
542
|
<div style="display: inline-block;">
|
529
|
543
|
<strong>Recommend to:</strong>
|
|
@@ -535,12 +549,12 @@ class Misc {
|
535
|
549
|
</div>
|
536
|
550
|
<div class="new" id="recommendation_status"><br /></div>
|
537
|
551
|
</div>
|
538
|
|
-<?
|
539
|
|
- }
|
540
|
|
-
|
541
|
|
- public static function is_valid_url($URL) {
|
542
|
|
- return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $URL);
|
543
|
|
- }
|
|
552
|
+ <?php
|
|
553
|
+ }
|
544
|
554
|
|
|
555
|
+ public static function is_valid_url($URL)
|
|
556
|
+ {
|
|
557
|
+ return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $URL);
|
|
558
|
+ }
|
545
|
559
|
}
|
546
|
560
|
?>
|