forked from RetroAchievements/RAWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_db_forum.php
More file actions
687 lines (596 loc) · 18.8 KB
/
_db_forum.php
File metadata and controls
687 lines (596 loc) · 18.8 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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
<?php
require_once('db.inc.php');
abstract class ModifyTopicField
{
const ModifyTitle = 0;
const DeleteTopic = 1;
const RequiredPermissions = 2;
};
//////////////////////////////////////////////////////////////////////////////////////////
// Forums
//////////////////////////////////////////////////////////////////////////////////////////
function getForumList( $categoryID = 0 )
{
// Specify NULL for all categories
$query = " SELECT f.ID, f.CategoryID, fc.Name AS CategoryName, fc.Description AS CategoryDescription, f.Title, f.Description, COUNT(DISTINCT ft.ID) AS NumTopics, COUNT( ft.ID ) AS NumPosts, ftc2.ID AS LastPostID, ftc2.Author AS LastPostAuthor, ftc2.DateCreated AS LastPostCreated, ft2.Title AS LastPostTopicName, ft2.ID AS LastPostTopicID, f.DisplayOrder
FROM Forum AS f
LEFT JOIN ForumCategory AS fc ON fc.ID = f.CategoryID
LEFT JOIN ForumTopic AS ft ON ft.ForumID = f.ID
LEFT JOIN ForumTopicComment AS ftc ON ftc.ForumTopicID = ft.ID
LEFT JOIN ForumTopicComment AS ftc2 ON ftc2.ID = f.LatestCommentID
LEFT JOIN ForumTopic AS ft2 ON ft2.ID = ftc2.ForumTopicID ";
if( $categoryID > 0 )
{
settype( $categoryID, "integer" );
$query .= "WHERE fc.ID = '$categoryID' ";
}
$query .= "GROUP BY f.ID ";
$query .= "ORDER BY fc.DisplayOrder, f.DisplayOrder, f.ID ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$dataOut = Array();
$numResults = 0;
while( $db_entry = mysqli_fetch_assoc($dbResult) )
{
$dataOut[$numResults] = $db_entry;
$numResults++;
}
return $dataOut;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
return NULL;
}
}
function getForumDetails( $forumID, &$forumDataOut )
{
settype( $forumID, "integer" );
$query = " SELECT f.ID, f.Title AS ForumTitle, f.Description AS ForumDescription, fc.ID AS CategoryID, fc.Name AS CategoryName
FROM Forum AS f
LEFT JOIN ForumCategory AS fc ON fc.ID = f.CategoryID
WHERE f.ID = $forumID ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$forumDataOut = mysqli_fetch_assoc( $dbResult );
return TRUE;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
$forumDataOut = NULL;
return FALSE;
}
}
function getForumTopics( $forumID, $offset, $count )
{
settype( $forumID, "integer" );
$query = " SELECT f.Title AS ForumTitle, ft.ID AS ForumTopicID, ft.Title AS TopicTitle, LEFT( ftc2.Payload, 50 ) AS TopicPreview, ft.Author, ft.AuthorID, ft.DateCreated AS ForumTopicPostedDate, ftc.ID AS LatestCommentID, ftc.Author AS LatestCommentAuthor, ftc.AuthorID AS LatestCommentAuthorID, ftc.DateCreated AS LatestCommentPostedDate, (COUNT(ftc2.ID)-1) AS NumTopicReplies
FROM ForumTopic AS ft
LEFT JOIN ForumTopicComment AS ftc ON ftc.ID = ft.LatestCommentID
LEFT JOIN Forum AS f ON f.ID = ft.ForumID
LEFT JOIN ForumTopicComment AS ftc2 ON ftc2.ForumTopicID = ft.ID
WHERE ft.ForumID = $forumID AND ftc.Authorised = 1
GROUP BY ft.ID
ORDER BY LatestCommentPostedDate DESC ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$dataOut = Array();
$numResults = 0;
while( $db_entry = mysqli_fetch_assoc($dbResult) )
{
$dataOut[$numResults] = $db_entry;
$numResults++;
}
return $dataOut;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
return NULL;
}
}
function getUnauthorisedForumLinks()
{
$query = " SELECT f.Title AS ForumTitle, ft.ID AS ForumTopicID, ft.Title AS TopicTitle, LEFT( ftc2.Payload, 50 ) AS TopicPreview, ft.Author, ft.AuthorID, ft.DateCreated AS ForumTopicPostedDate, ftc.ID AS LatestCommentID, ftc.Author AS LatestCommentAuthor, ftc.AuthorID AS LatestCommentAuthorID, ftc.DateCreated AS LatestCommentPostedDate, (COUNT(ftc2.ID)-1) AS NumTopicReplies
FROM ForumTopic AS ft
LEFT JOIN ForumTopicComment AS ftc ON ftc.ID = ft.LatestCommentID
LEFT JOIN Forum AS f ON f.ID = ft.ForumID
LEFT JOIN ForumTopicComment AS ftc2 ON ftc2.ForumTopicID = ft.ID
WHERE ftc.Authorised = 0
GROUP BY ft.ID
ORDER BY LatestCommentPostedDate DESC ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$dataOut = Array();
$numResults = 0;
while( $db_entry = mysqli_fetch_assoc($dbResult) )
{
$dataOut[$numResults] = $db_entry;
$numResults++;
}
return $dataOut;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
return NULL;
}
}
function getTopicDetails( $topicID, &$topicDataOut )
{
settype( $topicID, "integer" );
$query = " SELECT ft.ID, ft.Author, ft.AuthorID, fc.ID AS CategoryID, fc.Name AS Category, fc.ID as CategoryID, f.ID AS ForumID, f.Title AS Forum, ft.Title AS TopicTitle, ft.RequiredPermissions
FROM ForumTopic AS ft
LEFT JOIN Forum AS f ON f.ID = ft.ForumID
LEFT JOIN ForumCategory AS fc ON fc.ID = f.CategoryID
WHERE ft.ID = $topicID ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
//error_log( __FUNCTION__ . " $topicID, " . mysqli_num_rows( $dbResult ) );
$topicDataOut = mysqli_fetch_assoc( $dbResult );
return TRUE;
}
else
{
$topicNameOut = NULL;
return FALSE;
}
}
function getTopicComments( $topicID, $offset, $count, &$maxCountOut )
{
settype( $topicID, "integer" );
$query = " SELECT COUNT(*) FROM ForumTopicComment AS ftc
WHERE ftc.ForumTopicID = $topicID ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$data = mysqli_fetch_assoc( $dbResult );
$maxCountOut = $data['COUNT(*)'];
}
$query = "SELECT ftc.ID, ftc.ForumTopicID, ftc.Payload, ftc.Author, ftc.AuthorID, ftc.DateCreated, ftc.DateModified, ftc.Authorised, ua.RAPoints
FROM ForumTopicComment AS ftc
LEFT JOIN UserAccounts AS ua ON ua.ID = ftc.AuthorID
WHERE ftc.ForumTopicID = $topicID
ORDER BY DateCreated ASC
LIMIT $offset, $count";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$dataOut = Array();
$numResults = 0;
while( $db_entry = mysqli_fetch_assoc($dbResult) )
{
$dataOut[$numResults] = $db_entry;
$numResults++;
}
return $dataOut;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
return NULL;
}
}
function getSingleTopicComment( $forumPostID, &$dataOut )
{
settype( $forumPostID, 'integer' );
$query = " SELECT ID, ForumTopicID, Payload, Author, AuthorID, DateCreated, DateModified
FROM ForumTopicComment
WHERE ID=$forumPostID";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$dataOut = mysqli_fetch_assoc( $dbResult );
return TRUE;
}
return FALSE;
}
function submitNewTopic( $user, $forumID, $topicTitle, $topicPayload, &$newTopicIDOut )
{
$userID = getUserIDFromUser( $user );
if( strlen( $topicTitle ) < 2 )
$topicTitle = "$user's topic";
// Replace inverted commas, Remove HTML, TBD: allow phpbb
$topicTitle = str_replace( "'", "''", $topicTitle );
$topicTitle = strip_tags( $topicTitle );
// Create new topic, then submit new comment
//$authFlags = getUserForumPostAuth( $user );
$query = "INSERT INTO ForumTopic VALUES ( NULL, $forumID, '$topicTitle', '$user', $userID, NOW(), 0, 0 )";
log_sql( $query );
global $db;
$dbResult = mysqli_query( $db, $query );
if( $dbResult !== FALSE )
{
global $db;
$newTopicIDOut = mysqli_insert_id( $db );
if( submitTopicComment( $user, $newTopicIDOut, $topicPayload, $newCommentID ) )
{
//error_log( __FUNCTION__ . " posted OK!" );
//error_log( "$user posted new topic $topicTitle giving topic ID $newTopicIDOut with added comment ID $newCommentID" );
return TRUE;
}
else
{
log_sql_fail();
error_log( __FUNCTION__ . " struggled to post comment after adding new topic..." );
error_log( $query );
error_log( "$user posted $topicPayload for topic ID $newTopicIDOut" );
return FALSE;
}
}
else
{
log_sql_fail();
error_log( $query );
error_log( __FUNCTION__ . " failed!" );
return FALSE;
}
}
function setLatestCommentInForumTopic( $topicID, $commentID )
{
// Update ForumTopic table
$query = "UPDATE ForumTopic SET LatestCommentID=$commentID WHERE ID=$topicID";
log_sql( $query );
$dbResult = s_mysql_query( $query );
if( $dbResult == FALSE )
{
error_log( __FUNCTION__ . " failed!" );
error_log( $query );
}
// Propogate to Forum table
$query = " UPDATE Forum AS f
INNER JOIN ForumTopic AS ft ON ft.ForumID = f.ID
SET f.LatestCommentID = ft.LatestCommentID
WHERE ft.ID = $topicID ";
log_sql( $query );
$dbResult = s_mysql_query( $query );
if( $dbResult == FALSE )
{
error_log( __FUNCTION__ . " failed!" );
error_log( $query );
}
return TRUE;
}
function editTopicComment( $commentID, $newPayload )
{
settype( $commentID, 'integer' );
$newPayload = str_replace( "'", "''", $newPayload );
$newPayload = str_replace( "<", "<", $newPayload );
$newPayload = str_replace( ">", ">", $newPayload );
$query = "UPDATE ForumTopicComment SET Payload = '$newPayload' WHERE ID=$commentID";
log_sql( $query );
global $db;
$dbResult = mysqli_query( $db, $query ); // TBD: unprotected to allow all characters..
if( $dbResult !== FALSE )
{
//error_log( __FUNCTION__ . " posted OK!" );
error_log( __FUNCTION__ . " ID $commentID now becomes $newPayload" );
return TRUE;
}
else
{
log_sql_fail();
error_log( "$query" );
error_log( __FUNCTION__ . " failed!" );
return FALSE;
}
}
function submitTopicComment( $user, $topicID, $commentPayload, &$newCommentIDOut )
{
$userID = getUserIDFromUser( $user );
// Replace inverted commas, Remove HTML
$commentPayload = str_replace( "'", "''", $commentPayload );
$commentPayload = str_replace( "<", "<", $commentPayload );
$commentPayload = str_replace( ">", ">", $commentPayload );
//$commentPayload = strip_tags( $commentPayload );
$authFlags = getUserForumPostAuth( $user );
$query = "INSERT INTO ForumTopicComment VALUES ( NULL, $topicID, '$commentPayload', '$user', $userID, NOW(), NULL, $authFlags ) ";
log_sql( $query );
global $db;
$dbResult = mysqli_query( $db, $query ); // TBD: unprotected to allow all characters..
if( $dbResult !== FALSE )
{
$newCommentIDOut = mysqli_insert_id( $db );
setLatestCommentInForumTopic( $topicID, $newCommentIDOut );
notifyUsersAboutForumActivity( $topicID, $user, $newCommentIDOut );
//error_log( __FUNCTION__ . " posted OK!" );
error_log( __FUNCTION__ . " $user posted $commentPayload for topic ID $topicID" );
return TRUE;
}
else
{
log_sql_fail();
error_log( "$query" );
error_log( __FUNCTION__ . " failed!" );
return FALSE;
}
}
function notifyUsersAboutForumActivity( $topicID, $author, $commentID )
{
// $author has made a post in the topic $topicID
// Find all people involved in this forum thread, and if they are not the author and prefer to
// hear about comments, let them know!
$query = "SELECT ua.User, ua.EmailAddress FROM ForumTopicComment AS ftc
INNER JOIN ForumTopic AS ft ON ftc.ForumTopicID = ft.ID
INNER JOIN UserAccounts AS ua ON ua.ID = ftc.AuthorID AND (ua.websitePrefs & (1<<3) != 0)
WHERE ft.ID = $topicID AND ua.User != '$author'
GROUP BY ua.ID ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
while( $db_entry = mysqli_fetch_assoc($dbResult) )
{
$nextUser = $db_entry['User'];
$nextEmail = $db_entry['EmailAddress'];
$urlTarget = "viewtopic.php?t=$topicID&c=$commentID";
sendActivityEmail( $nextUser, $nextEmail, $topicID, $author, 6, NULL, $urlTarget );
}
}
else
{
error_log( $query );
error_log( __FUNCTION__ . "wtf!! Can't notify anybody" );
}
}
function getTopicCommentCommentOffset( $forumTopicID, $commentID, $count, &$offset )
{
// Focus on most recent comment
if( $commentID == -1 )
$commentID = 99999999;
$query = "SELECT COUNT(ID) AS CommentOffset FROM
( SELECT ID FROM ForumTopicComment
WHERE ForumTopicID = $forumTopicID
ORDER BY ID ) AS InnerTable
WHERE ID < $commentID ";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$data = mysqli_fetch_assoc( $dbResult );
$commentOffset = $data['CommentOffset'];
$pageOffset = 0;
while( $pageOffset <= $commentOffset )
$pageOffset += $count;
$offset = $pageOffset - $count;
return TRUE;
}
else
{
$offset = 0;
return FALSE;
}
}
function generateGameForumTopic( $user, $gameID, &$forumTopicID )
{
settype( $gameID, 'integer' );
if( $gameID == 0 )
return FALSE;
getGameMetaData( $gameID, $user, $achievementData, $gameData );
if( isset( $oldForumTopicID ) )
{
// Bad times?!
error_log( __FUNCTION__ . ", $user trying to create a forum topic for $gameTitle when one already exists!" );
}
$forumID = 0;
$consoleID = $gameData['ConsoleID'];
if( $consoleID == 1 ) // Mega Drive
$forumID = 10;
else if( $consoleID == 3 ) // SNES
$forumID = 13;
else if( $consoleID == 4 || $consoleID == 5 || $consoleID == 6 ) // GB/GBA/GBC
$forumID = 16;
else if( $consoleID == 7 ) // NES
$forumID = 18;
else if( $consoleID == 8 ) // PC Engine
$forumID = 22;
else // Default to Mega Drive
$forumID = 10;
$gameTitle = $gameData['Title'];
$topicTitle = $gameTitle;
$nowTimestamp = time();
$lastLoginTimestamp = strtotime( $lastLoginActivity['timestamp'] );
$urlSafeGameTitle = str_replace( " ", "+", "$gameTitle $consoleName" );
$urlSafeGameTitle = str_replace( "'", "''", $urlSafeGameTitle );
$gameFAQsURL = "http://www.google.com/search?q=site:www.gamefaqs.com+$urlSafeGameTitle";
$longplaysURL = "http://www.google.com/search?q=site:www.longplays.org+$urlSafeGameTitle";
$wikipediaURL = "http://www.google.com/search?q=site:en.wikipedia.org+$urlSafeGameTitle";
$embedLongplayURL;
$topicPayload = "Official Topic Post for discussion about [game=$gameID]\n" .
"Created " . date( "j M, Y H:i" ) . " by [user=$user]\n\n" .
"[b]Resources:[/b]\n" .
"[url=$gameFAQsURL]GameFAQs[/url]\n" .
"[url=$longplaysURL]Longplay[/url]\n" .
"[url=$wikipediaURL]Wikipedia[/url]\n" .
$embedLongplayURL;
if( submitNewTopic( $user, $forumID, $topicTitle, $topicPayload, $forumTopicID ) )
{
$query = "UPDATE GameData SET ForumTopicID = $forumTopicID
WHERE ID=$gameID ";
$dbResult = s_mysql_query( $query );
return( $dbResult !== FALSE );
}
else
{
log_email( __FUNCTION__ . " failed :( $user, $gameID, $gameTitle )" );
return FALSE;
}
}
function getRecentForumPosts( $offset, $count, $numMessageChars, &$dataOut )
{
// 02:08 21/02/2014 - cater for 20 spam messages
$countPlusSpam = $count+20;
$query = "
SELECT LatestComments.DateCreated AS PostedAt, LEFT( LatestComments.Payload, $numMessageChars ) AS ShortMsg, LatestComments.Author, ua.RAPoints, ua.Motto, ft.ID AS ForumTopicID, ft.Title AS ForumTopicTitle, LatestComments.ID AS CommentID
FROM
(
SELECT *
FROM ForumTopicComment AS ftc
WHERE ftc.Authorised = 1
ORDER BY ftc.DateCreated DESC
LIMIT $offset, $countPlusSpam
) AS LatestComments
INNER JOIN ForumTopic AS ft ON ft.ID = LatestComments.ForumTopicID
LEFT JOIN Forum AS f ON f.ID = ft.ForumID
LEFT JOIN UserAccounts AS ua ON ua.User = LatestComments.Author
ORDER BY LatestComments.DateCreated DESC
LIMIT $offset, $count";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
$dataOut = Array();
$numResults = 0;
while( $db_entry = mysqli_fetch_assoc($dbResult) )
{
$dataOut[$numResults] = $db_entry;
$numResults++;
}
return $numResults;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
return NULL;
}
}
function requestModifyTopic( $user, $permissions, $topicID, $field, $value )
{
settype( $field, 'integer' );
settype( $topicID, 'integer' );
if( !getTopicDetails( $topicID, $topicData ) )
{
error_log( __FUNCTION__ . " cannot process, $topicID doesn't exist?!" );
return FALSE;
}
switch( $field )
{
case ModifyTopicField::ModifyTitle:
if( ( $permissions >= Permissions::Developer ) || ( $user == $topicData['Author'] ) )
{
$query = " UPDATE ForumTopic AS ft
SET Title='$value'
WHERE ID=$topicID";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
error_log( "$user changed forum topic $topicID title from '" . $topicData['TopicTitle'] . "' to '$value'" );
return TRUE;
}
else
{
error_log( __FUNCTION__ . " change title error" );
error_log( $query );
return FALSE;
}
}
else
{
error_log( __FUNCTION__ . " change title... not enough permissions?!" );
error_log( $query );
return FALSE;
}
break;
case ModifyTopicField::DeleteTopic:
if( ( $permissions >= Permissions::Developer ) || ( $user == $topicData['Author'] ) )
{
$query = " DELETE FROM ForumTopic
WHERE ID=$topicID";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
error_log( "$user deleted forum topic $topicID ('" . $topicData['TopicTitle'] . "')" );
return TRUE;
}
else
{
error_log( __FUNCTION__ . " delete error" );
error_log( $query );
return FALSE;
}
}
else
{
error_log( __FUNCTION__ . " delete title... not enough permissions?!" );
error_log( $query );
return FALSE;
}
break;
case ModifyTopicField::RequiredPermissions:
if( ( $permissions >= Permissions::Developer ) || ( $user == $topicData['Author'] ) )
{
$query = " UPDATE ForumTopic AS ft
SET RequiredPermissions='$value'
WHERE ID=$topicID";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
error_log( "$user changed permissions for topic ID $topicID ('" . $topicData['TopicTitle'] . "') to $value" );
return TRUE;
}
else
{
error_log( __FUNCTION__ . " modify error" );
error_log( $query );
return FALSE;
}
}
else
{
error_log( __FUNCTION__ . " modify topic... not enough permissions?!" );
error_log( $query );
return FALSE;
}
break;
}
}
function RemoveUnauthorisedForumPosts( $user )
{
// Removes all 'unauthorised' forum posts by a particular user
$query = "DELETE FROM ForumTopicComment
WHERE Author = '$user' AND Authorised = 0";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
log_email( __FUNCTION__ . " user's forum post comments have all been permanently removed!" );
error_log( "$user's posts have been removed!" );
return TRUE;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
return FALSE;
}
}
function AuthoriseAllForumPosts( $user )
{
// Sets all unauthorised forum posts by a particular user to authorised
// Removes all 'unauthorised' forum posts by a particular user
$query = "UPDATE ForumTopicComment AS ftc
SET ftc.Authorised = 1
WHERE Author = '$user'";
$dbResult = s_mysql_query( $query );
if( $dbResult !== FALSE )
{
//log_email( __FUNCTION__ . " user's forum post comments have all been authorised!" );
error_log( "$user's posts have all been authorised!" );
return TRUE;
}
else
{
error_log( __FUNCTION__ . " error" );
error_log( $query );
return FALSE;
}
}
?>