forked from joeroberts234/phpMyBitTorrent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathajax.php
2359 lines (2178 loc) · 119 KB
/
ajax.php
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
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
*----------------------------phpMyBitTorrent V 2.0.4---------------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*-------------- Created By Antonio Anzivino (aka DJ Echelon) --------------*
*------------------- And Joe Robertson (aka joeroberts) -------------------*
*------------- http://www.p2pmania.it -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*------------- http://www.bittorrent.com -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*-- This program is free software; you can redistribute it and/or modify --*
*-- it under the terms of the GNU General Public License as published by --*
*-- the Free Software Foundation; either version 2 of the License, or --*
*-- (at your option) any later version. --*
*-- --*
*-- This program is distributed in the hope that it will be useful, --*
*-- but WITHOUT ANY WARRANTY; without even the implied warranty of --*
*-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --*
*-- GNU General Public License for more details. --*
*-- --*
*-- You should have received a copy of the GNU General Public License --*
*-- along with this program; if not, write to the Free Software --*
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --*
*-- --*
*------------------------------------------------------------------------------*
*------ ©2010 phpMyBitTorrent Development Team ------*
*----------- http://phpmybittorrent.com -----------*
*------------------------------------------------------------------------------*
*------------------- Saturday, JUN 27, 2009 1:05 AM -----------------------*
*/
if (defined('IN_PMBT'))die ("You can't include this file");
define("IN_PMBT",true);
require_once("include/config.php");
if ($use_rsa) require_once("include/rsalib.php");
require_once("include/class.user.php");
if ($use_rsa) $rsa = New RSA($rsa_modulo, $rsa_public, $rsa_private);
$user = @new User($_COOKIE["btuser"]);
define("AUTH_PENDING",0);
define("AUTH_GRANTED",1);
define("AUTH_DENIED",2);
define("AUTH_NONE",3);
function hex_to_base32($hex) {
$b32_alpha_to_rfc3548_chars = array(
'0' => 'A',
'1' => 'B',
'2' => 'C',
'3' => 'D',
'4' => 'E',
'5' => 'F',
'6' => 'G',
'7' => 'H',
'8' => 'I',
'9' => 'J',
'a' => 'K',
'b' => 'L',
'c' => 'M',
'd' => 'N',
'e' => 'O',
'f' => 'P',
'g' => 'Q',
'h' => 'R',
'i' => 'S',
'j' => 'T',
'k' => 'U',
'l' => 'V',
'm' => 'W',
'n' => 'X',
'o' => 'Y',
'p' => 'Z',
'q' => '2',
'r' => '3',
's' => '4',
't' => '5',
'u' => '6',
'v' => '7'
);
for ($pos = 0; $pos < strlen($hex); $pos += 10) {
$hs = substr($hex,$pos,10);
$b32_alpha_part = base_convert($hs,16,32);
$expected_b32_len = strlen($hs) * 0.8;
$actual_b32_len = strlen($b32_alpha_part);
$b32_padding_needed = $expected_b32_len - $actual_b32_len;
for ($i = $b32_padding_needed; $i > 0; $i--) {
$b32_alpha_part = '0' . $b32_alpha_part;
}
$b32_alpha .= $b32_alpha_part;
}
for ($i = 0; $i < strlen($b32_alpha); $i++) {
$b32_rfc3548 .= $b32_alpha_to_rfc3548_chars[$b32_alpha[$i]];
}
return $b32_rfc3548;
}
function getauthstatus($torrent) {
global $user, $db, $db_prefix;
if ($torrent["owner"] != 0) {
$sql = "SELECT * FROM ".$db_prefix."_privacy_global WHERE master = '".$torrent["owner"]."' AND slave = '".$user->id."' LIMIT 1;";
$res = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($res)) {
if ($row["status"] == "whitelist") return AUTH_GRANTED;
elseif ($row["status"] == "blacklistlist") return AUTH_DENIED;
}
$sql = "SELECT * FROM ".$db_prefix."_privacy_file WHERE torrent = '".$torrent["id"]."' AND slave = '".$user->id."' LIMIT 1;";
$res = $db->sql_query($sql) or btsqlerror($sql);
if ($row = $db->sql_fetchrow($res)) {
if ($row["status"] == "granted") return AUTH_GRANTED;
elseif ($row["status"] == "denied") return AUTH_DENIED;
return AUTH_PENDING;
} else return AUTH_NONE;
} else return AUTH_NONE;
}
function str_links($text){
$text = preg_replace(
array("/(\A|[^=\]'\"a-zA-Z0-9])((http|ftp|https|ftps|irc):\/\/[^<>\s]+)/i","/\[url=((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\]((\s|.)+?)\[\/url\]/i","/\[url\]((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\[\/url\]/i"),
array("\\1","\\3",""), $text);
}
function error($string) {
OpenErrTable("Error");
if (is_array($string)) {
echo _btalertmsg;
echo "<UL>";
foreach ($string as $msg) {
echo "<LI>".$msg."</LI>";
}
echo "</UL>";
} else {
echo "<p class=\"errortext\">".$string."</p>";
}
echo "<p class=\"errortext\">"._btgoback."</p>";
CloseErrTable();
ob_end_flush();
$db->sql_close();
die();
}
if (isset($btlanguage) AND is_readable("language/".$btlanguage.".php")) $language = $btlanguage;
if (isset($bttheme) AND is_readable("themes/".$bttheme."/main.php")) $theme = $bttheme;
if (is_readable("language/$language.php"))
include_once("language/$language.php");
else
include_once("language/english.php");
if (is_readable("themes/$theme/main.php")) {
require_once("themes/$theme/main.php");
} else {
die("You should not see this...");
}
if (is_banned($user, $reason)) {
echo "<meta http-equiv=\"refresh\" content=\"0;url=ban.php?reson=".urlencode($reason)."\">"; die();
}
if ($user->user AND(
$op =="private__chat" ||
$op =="getactive" ||
$op =="activeusers" ||
$op =="more_smiles" ||
$op =="view_shout" ||
$op =="take_edit_shout_cancel" ||
$op =="take_shout" ||
$op =="edit_shout" ||
$op =="take_delete_shout")) {
//Update online user list
$pagename = 'index.php';
$sqlupdate = "UPDATE ".$db_prefix."_online_users SET last_action = NOW() WHERE id = ".$user->id.";";
$sqlinsert = "INSERT INTO ".$db_prefix."_online_users VALUES ('".$user->id."','".addslashes($pagename)."', NOW(), NOW())";
$res = $db->sql_query($sqlupdate);
if (!$db->sql_affectedrows($res)) $db->sql_query($sqlinsert);
}
switch ($op) {
case "check_username": {
if (!$user->user) loginrequired("user",true);
if( !isset( $_GET['username'] ) || empty( $_GET['username'] ) ){
error("No username specified!");
}
// check for that username
$sql = "SELECT COUNT(`id`) FROM `".$db_prefix."_users` WHERE `username` = '".$_GET['username']."'";
$res = $db->sql_query($sql);
$num = $db_sql_fetchfield( $res, 0, 0 );
if( $num != 0 ){
print("Username taken!");
}
ob_end_flush();
$db->sql_close();
die();
}
case 'getactive':{
$usql = "SELECT id FROM ".$db_prefix."_online_users WHERE page='index.php' AND UNIX_TIMESTAMP(NOW()-last_action) < 600";
$ures = $db->sql_query($usql)or print(mysql_error());
$utot = $db->sql_numrows($ures);
print($utot);
ob_end_flush();
$db->sql_close();
die();
}
case 'private__chat':{
$shoutannounce = format_comment($shout_config['announce_ment'], false, true);
parse_smiles($shoutannounce);
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">".$shoutannounce."</p></div>";
$utc2 = $btback1;
//$db->sql_query("ALTER TABLE `torrent_shouts` ADD `id_to` INT( 10 ) NOT NULL DEFAULT '0';";
$sql = "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id WHERE S.id_to ='".$to."' AND S.user = '".$user->id."' OR S.user='".$to."' AND S.id_to ='".$user->id."' ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
$shoutres = $db->sql_query($sql) or btsqlerror($sql);
$num2s = $db->sql_numrows($shoutres);
if ($num2s > 0) {
while ($shout = $db->sql_fetchrow($shoutres)) {
$donator ='';
if($shout['donator'] == 'true')$donator ='<img src="images/donator.gif" height="16" width="16" title="donator" alt="donator" />';
if ($num2s > 1)
{
$ucs++;
}
if($ucs%2 == 0)
{
$utc3 = "od";
$utc2 = $btback1;
}
else
{
$utc3 = "even";
$utc2 = $btback2;
}
$i++;
$caneditshout = false;
$candeleteshout = false;
if ($user->moderator) $caneditshout = true;
if ($user->moderator) $candeleteshout = true;
if ($user->id == $shout['uid'] AND $shout_config['canedit_on'] =="yes") $caneditshout = true;
if ($user->id == $shout['uid'] AND $shout_config['candelete_on'] =="yes") $candeleteshout = true;
echo "<p>";
$warn = "";
$quote = addslashes($shout["text"]);
$text = format_comment($shout["text"], false, true);
parse_smiles($text);
if($shout["warned"] == "1") $warn = '<img src="images/warning.gif" alt="warned" />';
$shout_time = gmdate("Y-m-d H:i:s", sql_timestamp_to_unix_timestamp($shout['posted'])+(60 * get_user_timezone($user->id)));
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
if(preg_match("/\/notice (.*)/",$text,$m)){
$text = preg_replace('/\/notice/','',$text);
}elseif(preg_match("/\/me (.*)/",$text,$m)){
$text = preg_replace('/\/me/','',$text);
echo"<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>:";
}else{
echo ($candeleteshout ? "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("drop.gif","",_btalt_edit) ."</a>" : "").($caneditshout ? "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("edit.gif","",_btalt_edit) ."</a>" : "").($shout_config['bbcode_on'] =="yes" ? "<a onclick=\"comment_smile('[quote=".htmlspecialchars($shout["user_name"])."]".$quote."[/quote]',Shoutform.text);\"><img src=\"images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
}
echo str_replace("\n","<br />",$text);
echo "</p>";
echo "<hr></div></p>\n";
}
} else {
echo "<p align=\"center\">"._btnoshouts."</p>\n";
}
$db->sql_freeresult($shoutres);
ob_end_flush();
$db->sql_close();
die();
}
case 'activeusers':{
$sql = "SELECT O.id AS id, O.page AS page, UNIX_TIMESTAMP(O.logged_in) AS logged_in, IF(U.name IS NULL, U.username, U.name) as name, U.warned AS warned, U.can_do as can_do, U.level AS level, U.Show_online AS Show_online, U.uploaded as uploaded, U.downloaded AS downloaded FROM ".$db_prefix."_online_users O LEFT JOIN ".$db_prefix."_users U ON O.id = U.id WHERE O.page='index.php' AND UNIX_TIMESTAMP(NOW()-last_action) < 600 AND U.Show_online = true;";
$res = $db->sql_query($sql);
$tot = $db->sql_numrows($res);
$i = 1;
$simple = "\n<p>";
$advanced = "<table border=\"1\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
$advanced .= "<thead><tr><td><p align=\"center\"><b>"._btusername."</b></p></td><td><p align=\"center\"><b>"._btratio."</b></p></td><td><p align=\"center\"><b>"._btpagename."</b></p></td><td><p align=\"center\"><b>"._btloggedinfor."</b></p></td></tr></thead>\n<tbody>\n";
if ($db->sql_numrows($res) == 0) $simple .= _btnouseronline;
else {
while ($row = $db->sql_fetchrow($res)) {
$simple .= "<a href=\"user.php?op=profile&id=".$row["id"]."\"><font color=\"".getusercolor($row["can_do"])."\">";
$simple .= htmlspecialchars($row["name"])."</font></a>";
if ($row["level"] == "premium") $simple .= pic("icon_premium.gif",'','Premium');
elseif ($row["level"] == "uploader") $simple .= pic("icon_uploader.gif",'','Uploader');
elseif ($row["level"] == "moderator") $simple .= pic("icon_moderator.gif",'','Moderator');
elseif ($row["level"] == "admin") $simple .= pic("icon_admin.gif",'','Admin');
if($row["warned"] == "1") $simple .= '<img src="images/warning.gif" alt="warned" />';
if ($i < $tot) $simple .= ", ";
$i++;
$advanced .= "<tr>";
$advanced .= "<td><p><a href=\"user.php?op=profile&id=".$row["id"]."\"><font color=\"".getusercolor($row["can_do"])."\">";
$advanced .= htmlspecialchars($row["name"])."</font></a>";
if ($row["level"] == "premium") $advanced .= pic("icon_premium.gif",'','holder');
elseif ($row["level"] == "moderator") $advanced .= pic("icon_moderator.gif",'','holder');
elseif ($row["level"] == "admin") $advanced .= pic("icon_admin.gif",'','holder');
if($row["warned"] == "1") $advanced .= '<img src="images/warning.gif" alt="warned" />';
$advanced .= "</p></td>";
if ($row["uploaded"] == 0 AND $row["downloaded"] == 0) $ratio = "---";
elseif ($row["downloaded"] == 0) $ratio = "∞";
else {
$ratio = $row["uploaded"]/$row["downloaded"];
if ($ratio < 0.1) $ratio = "<font color=\"#ff0000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.2) $ratio = "<font color=\"#ee0000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.3) $ratio = "<font color=\"#dd0000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.4) $ratio = "<font color=\"#cc0000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.5) $ratio = "<font color=\"#bb0000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.6) $ratio = "<font color=\"#aa0000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.7) $ratio = "<font color=\"#990000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.8) $ratio = "<font color=\"#880000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 0.9) $ratio = "<font color=\"#770000\">" . number_format($ratio, 2) . "</font>";
elseif ($ratio < 1) $ratio = "<font color=\"#660000\">" . number_format($ratio, 2) . "</font>";
else $ratio = "<font color=\"#00FF00\">". number_format($ratio, 2) . "</font>";
}
$advanced .= "<td><p>".$ratio."</p></td>";
$advanced .= "<td><p>";
if (defined("_btpage_".$row["page"])) $advanced .= constant("_btpage_".$row["page"]);
$advanced .= "</p></td>";
$advanced .= "<td><p>".mkprettytime(time()-$row["logged_in"])."</p></td>";
$advanced .= "</tr>\n";
}
$simple .="<br><br><p>Legend: Admin <img src=\"themes/".$theme."/pics/icon_admin.gif\" alt=\"holder\">, Moderator<img src=\"themes/".$theme."/pics/icon_moderator.gif\" alt=\"holder\">, Premium<img src=\"themes/".$theme."/pics/icon_premium.gif\" alt=\"holder\"> </p><div style='font-size: 8pt;' align=\"center\"><a href=\"javascript:advanced();\">"._btadvancedmode."</a></div>";
$simple .= "";
}
$advanced .= "</tbody></table>\n";
$db->sql_freeresult($res);
//Simple mode
echo "<div id=\"users_simple\" class=\"show\">";
echo $simple;
echo "</div>";
//Advanced mode
echo "<div id=\"users_advanced\" class=\"hide\">";
echo $advanced;
echo "<br><p>Legend: Admin <img src=\"themes/".$theme."/pics/icon_admin.gif\" alt=\"holder\">, Moderator<img src=\"themes/".$theme."/pics/icon_moderator.gif\" alt=\"holder\">, Premium<img src=\"themes/".$theme."/pics/icon_premium.gif\" alt=\"holder\"> </p><div style='font-size: 8pt;' align=\"center\"><a href=\"javascript:simple();\">"._btsimplemode."</a></div>";
echo "</div>";
ob_end_flush();
$db->sql_close();
die();
}
case 'edit_torrent_descr':{
// check for valid ID
if( !isset( $_GET['torrent'] ) || !is_numeric( $_GET['torrent'] ) ){
error("Invalid torrent!" );
}
// get the torrent description
$sql = "SELECT `descr`, `owner` FROM `".$db_prefix."_torrents` WHERE `id` = '".$_GET['torrent']."'";
$res = $db->sql_query($sql);
$descr = $db->sql_fetchrow( $res );
// make sure user is owner of torrent
if (!$descr['owner'] = $user->id OR !$user->moderator){
error("Invalid permissions!");
}
print( "<textarea enctype=\"multipart/form-data\" rows=\"10\" cols=\"80\" style=\"border:0px\" onblur=\"if(confirm('Save changes to torrent description?')==true){sndReq('op=save_torrent_descr&torrent=".$_GET['torrent']."&descr='+escape(this.value), 'descrTD".$_GET['torrent']."')}\">".$descr['descr']."</textarea>" );
ob_end_flush();
$db->sql_close();
die();
}
case 'more_smiles':{
if (!$user->user) loginrequired("user",true);
$sql = "SELECT * FROM ".$db_prefix."_smiles GROUP BY file ORDER BY id ASC;";
$smile_res = $db->sql_query($sql);
if ($db->sql_numrows($smile_res) > 0) {
$smile_rows = $db->sql_fetchrowset($smile_res);
echo "<p>";
foreach ($smile_rows as $smile) {
echo " <img src=\"smiles/".$smile["file"]."\" onclick=\"comment_smile('".$smile["code"]."',Shoutform.text);\" border=\"0\" alt=\"".$smile["alt"]."\">\n";
}
echo "</p>";
}
$db->sql_freeresult($smile_res);
ob_end_flush();
$db->sql_close();
die();
}
case 'view_shout':{
if (!$user->user) loginrequired("user",true);
if($user->can_shout == 'false'){
echo "YouR shout rights have been banned";
ob_end_flush();
$db->sql_close();
die();
}
$shoutannounce = format_comment($shout_config['announce_ment'], false, true);
parse_smiles($shoutannounce);
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">".$shoutannounce."</p></div>";
if(isset($shotuser)){
$privateonly = "WHERE S.id_to ='".$shotuser."' AND S.user = '".$user->id."' OR S.id_to ='".$user->id."' AND S.user = '".$shotuser."'";
}else{
$privateonly = '';
}
$utc2 = $btback1;
$sql = "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id ".$privateonly." ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
$shoutres = $db->sql_query($sql) or btsqlerror($sql);
$num2s = $db->sql_numrows($shoutres);
if ($num2s > 0) {
while ($shout = $db->sql_fetchrow($shoutres)) {
$donator ='';
if($shout['donator'] == 'true')$donator ='<img src="images/donator.gif" height="16" width="16" title="donator" alt="donator" />';
//$num2s = $db->sql_numrows($shoutres);
if ($num2s > 1)
{
$ucs++;
}
if($ucs%2 == 0)
{
$utc3 = "od";
$utc2 = $btback1;
}
else
{
$utc3 = "even";
$utc2 = $btback2;
}
$i++;
$caneditshout = false;
$candeleteshout = false;
if ($user->moderator) $caneditshout = true;
if ($user->moderator) $candeleteshout = true;
if ($user->id == $shout['uid'] AND $shout_config['canedit_on'] =="yes") $caneditshout = true;
if ($user->id == $shout['uid'] AND $shout_config['candelete_on'] =="yes") $candeleteshout = true;
if ($shout['id_to']!=0){
if ($user->id == $shout['id_to'] OR $user->id == $shout['uid']){
echo "<p>";
$warn = "";
$quote = addslashes($shout["text"]);
$text = format_comment($shout["text"], false, true);
parse_smiles($text);
if($shout["warned"] == "1") $warn = '<img src="images/warning.gif" alt="warned" />';
$shout_time = gmdate("Y-m-d H:i:s", sql_timestamp_to_unix_timestamp($shout['posted'])+(60 * get_user_timezone($user->id)));
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
if(preg_match("/\/notice (.*)/",$text,$m)){
$text = preg_replace('/\/notice/','',$text);
}elseif(preg_match("/\/me (.*)/",$text,$m)){
$text = preg_replace('/\/me/','',$text);
echo _btprivates."<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.":";
}else{
echo ($candeleteshout ? "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("drop.gif","",_btalt_edit) ."</a>" : "").($caneditshout ? "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("edit.gif","",_btalt_edit) ."</a>" : "").($shout_config['bbcode_on'] =="yes" ? "<a onclick=\"comment_smile('[quote=".htmlspecialchars($shout["user_name"])."]".$quote."[/quote]',Shoutform.text);\"><img src=\"images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>]"._btprivates." <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
}
echo str_replace("\n","<br />",$text);
echo "</p>";
echo "<hr></div>\n";
}
}
if ($shout['id_to']==0){
echo "<p>";
$warn = "";
$quote = addslashes($shout["text"]);
$text = format_comment($shout["text"], false, true);
parse_smiles($text);
if($shout["warned"] == "1") $warn = '<img src="images/warning.gif" alt="warned" />';
$shout_time = gmdate("Y-m-d H:i:s", sql_timestamp_to_unix_timestamp($shout['posted'])+(60 * get_user_timezone($user->id)));
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
if(preg_match("/\/notice (.*)/",$text,$m)){
$text = preg_replace('/\/notice/','',$text);
}elseif(preg_match("/\/me (.*)/",$text,$m)){
$text = preg_replace('/\/me/','',$text);
echo"<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>:";
}else{
echo ($candeleteshout ? "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("drop.gif","",_btalt_edit) ."</a>" : "").($caneditshout ? "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("edit.gif","",_btalt_edit) ."</a>" : "").($shout_config['bbcode_on'] =="yes" ? "<a onclick=\"comment_smile('[quote=".htmlspecialchars($shout["user_name"])."]".$quote."[/quote]',Shoutform.text);\"><img src=\"images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
}
echo str_replace("\n","<br />",$text);
echo "</p>";
echo "<hr></div>\n";
}
}
} else {
echo "<p align=\"center\">"._btnoshouts."</p>\n";
}
$db->sql_freeresult($shoutres);
ob_end_flush();
$db->sql_close();
die();
}
case 'edit_shout':{
//echo $_GET['shout'];
// check for valid ID
if( !isset( $_GET['shout'] ) || !is_numeric( $_GET['shout'] ) ){
error("Invalid torrent!" );
}
// get the torrent description
$sql = "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
$res = $db->sql_query($sql) or btsqlerror($sql);
$shout = $db->sql_fetchrow( $res );
// make sure user is owner of torrent edit_others_shouts
if ($shout['user'] != $user->id AND !checkaccess("edit_others_shouts")){
error("Invalid permissions!");
}
print( "<form mane=\"shoutedit\" id=\"shoutedit\"><textarea name=\"textedit\" id=\"textedit\" enctype=\"multipart/form-data\" rows=\"1\" cols=\"80\" style=\"border:1px\" >".$shout['text']."</textarea><input type=\"button\" onclick=\"sndReq('op=take_edit_shout&shout=".$_GET['shout']."&shout_text='+escape(textedit.value), 'shoutTD')\" value=\""._btshoutnow."\" /><input type=\"button\" onclick=\"sndReq('op=take_edit_shout_cancel', 'shoutTD')\" value=\"Cancel\" /></form>" );
ob_end_flush();
$db->sql_close();
die();
}
case 'edit_archive_shout':{
// check for valid ID
if( !isset( $_GET['shout'] ) || !is_numeric( $_GET['shout'] ) ){
error("Invalid torrent!" );
}
$sql = "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
$res = $db->sql_query($sql) or btsqlerror($sql);
$shout = $db->sql_fetchrow( $res );
if ($shout['user'] != $user->id AND !checkaccess("edit_others_shouts")){
error("Invalid permissions!");
}
print( "<form mane=\"shoutedit\" id=\"shoutedit\"><textarea name=\"textedit\" id=\"textedit\" enctype=\"multipart/form-data\" rows=\"1\" style=\"border:1px\" >".$shout['text']."</textarea><br /><input type=\"button\" onclick=\"sndReq('op=take_edit_archive_shout&shout=".$_GET['shout']."&shout_text='+escape(textedit.value), 'shout_shell_".$_GET['shout']."')\" value=\""._btshoutnow."\" /><input type=\"button\" onclick=\"sndReq('op=take_edit_shout_cancel', 'shout_archive_edit_".$_GET['shout']."')\" value=\"Cancel\" /></form>" );
ob_end_flush();
$db->sql_close();
die();
}
case 'take_delete_shout':{
$sql = "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
$res = $db->sql_query($sql) or btsqlerror($sql);
$shout = $db->sql_fetchrow( $res );
if ($shout['user'] != $user->id AND !checkaccess("edit_others_shouts")){
error("Invalid permissions!");
}
$db->sql_query("DELETE FROM `".$db_prefix."_shouts` WHERE `".$db_prefix."_shouts`.`id`='".$_GET['shout']."' LIMIT 1");
ob_end_flush();
$db->sql_close();
die();
}
case 'take_delete_archive_shout':{
$sql = "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
$res = $db->sql_query($sql) or btsqlerror($sql);
$shout = $db->sql_fetchrow( $res );
if ($shout['user'] != $user->id AND !checkaccess("edit_others_shouts")){
error("Invalid permissions!");
}
$db->sql_query("DELETE FROM `".$db_prefix."_shouts` WHERE `".$db_prefix."_shouts`.`id`='".$_GET['shout']."' LIMIT 1");
ob_end_flush();
$db->sql_close();
die();
}
case 'take_edit_shout_cancel':{
echo "";
ob_end_flush();
$db->sql_close();
die();
}
case 'take_edit_shout':{
$shout = str_replace("op=take_edit_shout&shout=".$_GET['shout']."&shout_text=","",$_SERVER['QUERY_STRING']);
$shout = str_replace(array("/amp2/","/amp3/"),array("&","#"),$shout);
$shout = urldecode($shout);
$shout = addslashes($shout);
$sql = "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
$res = $db->sql_query($sql) or btsqlerror($sql);
$shout2 = $db->sql_fetchrow( $res );
if ($shout2['user'] != $user->id AND !checkaccess("edit_others_shouts")){
error("Invalid permissions!");
}
$upd_sql = "UPDATE `".$db_prefix."_shouts` SET `text` = '".$shout."' WHERE `id` = '".$_GET['shout']."'";
$db->sql_query($upd_sql) or btsqlerror($upd_sql);
ob_end_flush();
$db->sql_close();
die();
}
case 'take_edit_archive_shout':{
$shout = str_replace("op=take_edit_archive_shout&shout=".$_GET['shout']."&shout_text=","",$_SERVER['QUERY_STRING']);
$shout = str_replace("/amp2/","&",$shout);
$shout = urldecode($shout);
$shout3 = format_comment($shout, false, true);
parse_smiles($shout3);
$sql = "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
$res = $db->sql_query($sql) or btsqlerror($sql);
$shout2 = $db->sql_fetchrow( $res );
if ($shout2['user'] != $user->id AND !checkaccess("edit_others_shouts")){
error("Invalid permissions!");
}
$upd_sql = "UPDATE `".$db_prefix."_shouts` SET `text` = '".$shout."' WHERE `id` = '".$_GET['shout']."'";
$db->sql_query($upd_sql) or btsqlerror($upd_sql);
echo" <td class=\"alt1\" id=\"shout_shell_".$_GET['shout']."\" width=\"1%\" align=\"left\">
<div id=\"shout_".$_GET['shout']."\">
".$shout3."
</div>
<div id=\"shout_archive_edit_".$_GET['shout']."\">
</div>
</td>
";
ob_end_flush();
$db->sql_close();
die();
}
case 'take_shout':{
if($user->can_shout == 'false'){
echo "YouR shout rights have been banned";
ob_end_flush();
$db->sql_close();
die();
}
if (!$user->user) loginrequired("user",true);
if (strlen($_GET['text']) < 1) continue;
//print($_SERVER['QUERY_STRING']);
if(isset($sendto)){
$resend = "sendto=".$sendto."&";
$sendtable = ", id_to";
$sendtorow = ", '".$sendto."'";
}
else
{
$resend = '';
$sendtable = '';
$sendtorow = '';
}
$shout = str_replace("op=take_shout&".$resend."text=","",$_SERVER['QUERY_STRING']);
$shout = str_replace("/amp2/","&",$shout);
// die($shout);
$shout = urldecode($shout);
if ($shout == "/empty" && $user->admin) {
//$db->sql_query("TRUNCATE TABLE ".$db_prefix."_shouts");
$shout = '/notice The modshout has been truncated by '.$user->name;
#die('The modshout has been truncated');
}
if ($shout == "/prune" && $user->admin) {
$db->sql_query("TRUNCATE TABLE ".$db_prefix."_shouts");
$shout = '/notice The modshout has been truncated by '.$user->name;
#die('The modshout has been truncated');
}
if ($shout == "/pruneshout" && $user->admin) {
$db->sql_query("TRUNCATE TABLE ".$db_prefix."_shouts");
$shout = '/notice The modshout has been truncated by '.$user->name;
#die('The modshout has been truncated');
}
if(preg_match("/\/deletenotice/",$shout,$matches) && $user->admin) {
$db->sql_query("DELETE FROM ".$db_prefix."_shouts WHERE text LIKE '%/notice%'");
}
if(preg_match("/\/unwarn (.*)/",$shout,$m) && $user->admin) {
$res = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!$res) echo "No Such user found";
$row = $db->sql_fetchrow($res);
if($row[id]==0 || $row[id] == "")echo "No Such user found";
if($row[id] == $user->id)
{
echo "You can not unWarn your self";
}
else{
$modcomment = "[ " . gmdate("Y-m-d H:i:s", time()) . " - WARN deleted by " . getusername($user) . " ]\n" . $row['modcomment'];
$added3 = gmdate("Y-m-d H:i:s", time());
$msg3 = "Your WARNNING was deleted by " . $user->name . "!";
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('". $user->id ."', '".$row[id]."', 'WARNNING', '" . $msg3 . "', NOW())") or btsqlerror();
$db->sql_query("UPDATE ".$db_prefix."_users SET modcomment='".$modcomment."', warned='0', warn_kapta='0', warn_hossz='0' WHERE id='".$row[id]."'") or die(mysql_error());
$shout = "/notice $m[1]'s warnning has been removed";
}
}
if(preg_match("/\/warn (.*)/",$shout,$m) && $user->admin) {
$res = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!$res) echo "No Such user found";
$row = $db->sql_fetchrow($res);
if($row[id]==0 || $row[id] == "")echo "No Such user found";
if($row[id] == $user->id)
{
echo "You can not Warn your self";
}
if($row[level] == 'admin')
{
echo "This level is expempt You Ars";
}else{
$weeks = "unlimited time";
$warnlength = -1;
$added2 = (gmdate("Y-m-d H:i:s", time()));
$modcomment = "" . gmdate("Y-m-d H:i:s", time()) . " - WARNed for " . $weeks . " by " . getusername($user) . " - Reason: Shoutbox Warned " . $row['modcomment']."";
$msg2 = ("You have been WARNNED by " . getusername($user) . " for " . $weeks . " with reason: Shoutbox Warned.");
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('". $user->id ."', '".$row[id]."', 'WARNNING', '" . $msg2 . "', NOW())") or die(mysql_error());
$db->sql_query("UPDATE ".$db_prefix."_users SET modcomment='".$modcomment."', warned='1', warn_kapta='" . strtotime(gmdate("Y-m-d H:i:s", time())) . "', warn_hossz='".$warnlength."' WHERE id= '".$row[id]."'") or die(mysql_error());
$shout = "/notice $m[1] has been Warned!!";
}
}
if(preg_match("/\/ban (.*) : (.*)/",$shout,$m) && $user->admin) {
//die($m[1] ." and ".$m[2]);
if($m[2] == "" || !isset($m[2]))die("no reason given");
$res = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!$res) echo "No Such user found";
$row = $db->sql_fetchrow($res);
if($row[id]==0 || $row[id] == "")echo "No Such user found";
if($row[id] == $user->id)
{
echo "You can not Ban your self";
}else{
$sql = "UPDATE ".$db_prefix."_users SET ban = 1, banreason = '".strip_tags($m[2])."' WHERE username = '".$row['username']." AND id NOT IN (1,2,3,4,5)';";
$db->sql_query($sql) or btsqlerror($sql);
if($forumshare)forum_ban ($$row['username'], strip_tags($reason_user));
echo "banned ".$m[1]." test";
$shout = "";
}
}
if(preg_match("/\/unban (.*)/",$shout,$m) && $user->admin) {
$res = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!$res) echo "No Such user found";
$row = $db->sql_fetchrow($res);
if($row[id]==0 || $row[id] == "")echo "No Such user found";
if($row[id] == $user->id)
{
echo "You can not Warn your self";
}else{
$db->sql_query("UPDATE ".$db_prefix."_users SET ban = 0, banreason = NULL WHERE id = '".$row['id']."';");
if($forumshare)forum_unban ($row['id']);
echo "unbanned ".$m[1]." test";
$shout = "";
}
}
if(preg_match("/\/banshout (.*)/",$shout,$m) && $user->admin) {
$res = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!$res) echo "No Such user found";
$row = $db->sql_fetchrow($res);
if($row[id]==0 || $row[id] == "")echo "No Such user found";
if($row[id] == $user->id)
{
echo "You can not Warn your self";
}else{
$sql = "UPDATE ".$db_prefix."_users SET can_shout = 'false' WHERE id = '".$row['id']."';";
if (!$db->sql_query($sql)) btsqlerror($sql);
}
}
if(preg_match("/\/unbanshout (.*)/",$shout,$m) && $user->admin) {
$res = $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!$res) echo "No Such user found";
$row = $db->sql_fetchrow($res);
if($row[id]==0 || $row[id] == "")echo "No Such user found";
if($row[id] == $user->id)
{
echo "You can not Warn your self";
}else{
$sql = "UPDATE ".$db_prefix."_users SET can_shout = 'true' WHERE id = '".$row['id']."';";
if (!$db->sql_query($sql)) btsqlerror($sql);
$shout = "/notice $m[1] has been Warned!!";
}
}
if(preg_match("/\/slapuser (.*)/",$shout,$m)) {
$shout = "/me Slaps $m[1] ";
}
if(preg_match("/\/pmuser (.*);(.*)/",$shout,$m)) {
if(!is_numeric($m[1])) $m[1] = getuser($m[1]);
echo "pm to userid{$m[1]} saying $m[2]";
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('". $user->id ."', '".$m[1]."', 'Quick Pm From shouts', '" . escape($m[2]) . "', NOW())") or die(mysql_error());
$shout = '';
}
$shout = preg_replace("/\/warn (.*)/","",$shout);
$shout = preg_replace("/\/empty/",'',$shout);
$shout = preg_replace("/\/ban (.*)/",'',$shout);
$shout = preg_replace("/\/unban (.*)/",'',$shout);
$shout = preg_replace("/\/warn (.*)/",'',$shout);
$shout = preg_replace("/\/unwarn (.*)/",'',$shout);
//$shout = preg_replace("/\/help/",'',$shout);
$shout = preg_replace("/\/prune/",'',$shout);
$shout = preg_replace("/\/pruneshout/",'',$shout);
$shout = preg_replace("/\/deletenotice/",'',$shout);
if ($shout == '/help') {
//die("help set");
$shout = "[quote]";
if($user->admin){
$shout .= "If you want to make an notice - use the /notice command.
If you want to empty shouts - use the /empty command
If you want to warn or unwarn a user - use the /warn (user) and /unwarn (user) commands
If you want to ban(disable) or unban(enable) a user - use the /ban (user) and /unban (user) commands
To delete all notices from the shout, use /deletenotice command
If you want to slap a user /slapuser user name
If you want to send a quick Private Message /pmuser (user name or id);(message)
If you want to speak at 3rd person, use the /me (message)command.";
}else{
$shout .= "As an user, you have the folowing commands:
If you want to view this message in the shout, use the /help command
If you want to slap a user /slapuser user name
If you want to send a quick Private Message /pmuser (user name or id);(message)
If you want to speak at 3rd person, use the /me command.";
}
$shout .= "[/quote]";
echo format_comment($shout, false, true);//die($shout);
//ob_end_flush();
//$db->sql_close();
//die();
$shout = "";
}
if(!$user->admin)
$shout = preg_replace("/\/notice/",'',$shout);
if($shout_config['allow_url'] == "no")$shout = str_links($shout);
if ($shout != "") {
$sql = "INSERT INTO ".$db_prefix."_shouts (user, text, posted".$sendtable.") VALUES ('".$user->id."', '".addslashes(strip_tags(urldecode($shout)))."', NOW()".$sendtorow.");";
$db->sql_query($sql)or btsqlerror($sql);
}
$shoutannounce = format_comment($shout_config['announce_ment'], false, true);
parse_smiles($shoutannounce);
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">".$shoutannounce."</p></div>";
if(!isset($sendto))$sql = "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
else
$sql = "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id WHERE S.id_to ='".$sendto."' AND S.user = '".$user->id."' OR S.id_to ='".$user->id."' AND S.user = '".$sendto."' ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
$shoutres = $db->sql_query($sql) or btsqlerror($sql);
$num2s = $db->sql_numrows($shoutres);
if ($num2s > 0) {
while ($shout = $db->sql_fetchrow($shoutres)) {
$donator ='';
if($shout['donator'] == 'true')$donator ='<img src="images/donator.gif" height="16" width="16" title="donator" alt="donator" />';
if ($num2s > 1)
{
$ucs++;
}
if($ucs%2 == 0)
{
$utc3 = "od";
$utc2 = $btback1;
}
else
{
$utc3 = "even";
$utc2 = $btback2;
}
$i++;
$caneditshout = false;
$candeleteshout = false;
if ($user->moderator) $caneditshout = true;
if ($user->moderator) $candeleteshout = true;
if ($user->id == $shout['uid'] AND $shout_config['canedit_on'] =="yes") $caneditshout = true;
if ($user->id == $shout['uid'] AND $shout_config['candelete_on'] =="yes") $candeleteshout = true;
if ($shout['id_to']!=0){
if ($user->id == $shout['id_to'] OR $user->id == $shout['uid']){
echo "<p>";
$warn = "";
$quote = addslashes($shout["text"]);
$text = format_comment($shout["text"], false, true);
parse_smiles($text);
if(preg_match("/\/staffmesage (.*)/",$text,$m) AND $user->moderator){
}
if($shout["warned"] == "1") $warn = '<img src="images/warning.gif" alt="warned" />';
$shout_time = gmdate("Y-m-d H:i:s", sql_timestamp_to_unix_timestamp($shout['posted'])+(60 * get_user_timezone($user->id)));
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
if(preg_match("/\/notice (.*)/",$text,$m)){
$text = preg_replace('/\/notice/','',$text);
}elseif(preg_match("/\/me (.*)/",$text,$m)){
$text = preg_replace('/\/me/','',$text);
echo _btprivates."<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.":";
}else{
echo ($candeleteshout ? "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("drop.gif","",_btalt_edit) ."</a>" : "").($caneditshout ? "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("edit.gif","",_btalt_edit) ."</a>" : "").($shout_config['bbcode_on'] =="yes" ? "<a onclick=\"comment_smile('[quote=".htmlspecialchars($shout["user_name"])."]".$quote."[/quote]',Shoutform.text);\"><img src=\"images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>][PM] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
}
echo str_replace("\n","<br />",$text);
echo "</p>";
echo "<hr></div>\n";
}
}
if ($shout['id_to']==0){
echo "<p>";
$warn = "";
$quote = addslashes($shout["text"]);
$text = format_comment($shout["text"], false, true);
parse_smiles($text);
if($shout["warned"] == "1") $warn = '<img src="images/warning.gif" alt="warned" />';
$shout_time = gmdate("Y-m-d H:i:s", sql_timestamp_to_unix_timestamp($shout['posted'])+(60 * get_user_timezone($user->id)));
echo "<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
if(preg_match("/\/notice (.*)/",$text,$m)){
$text = preg_replace('/\/notice/','',$text);
}elseif(preg_match("/\/me (.*)/",$text,$m)){
$text = preg_replace('/\/me/','',$text);
echo"<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.":";
}else{
echo ($candeleteshout ? "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("drop.gif","",_btalt_edit) ."</a>" : "").($caneditshout ? "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" . pic("edit.gif","",_btalt_edit) ."</a>" : "").($shout_config['bbcode_on'] =="yes" ? "<a onclick=\"comment_smile('[quote=".htmlspecialchars($shout["user_name"])."]".$quote."[/quote]',Shoutform.text);\"><img src=\"images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
}
echo str_replace("\n","<br />",$text);
echo "</p>";
echo "<hr></div>\n";
}
}
} else {
echo "<p align=\"center\">"._btnoshouts."</p>\n";
}
$db->sql_freeresult($shoutres);
ob_end_flush();
$db->sql_close();
die();
}
case 'save_torrent_descr':{
// check for valid ID
if( !isset( $_GET['torrent'] ) || !is_numeric( $_GET['torrent'] ) ){
error("Invalid torrent!" );
}
// get the torrent description
$sql = "SELECT `owner` FROM `".$db_prefix."_torrents` WHERE `id` = '".$_GET['torrent']."'";
$res = $db->sql_query($sql);
$descr = $db->sql_fetchrow( $res );
// make sure user is owner of torrent
if (!$descr['owner'] = $user->id OR !$user->moderator){
error("Invalid permissions!");
}
$descr = addslashes($_GET['descr']);
$upd_sql = "UPDATE `".$db_prefix."_torrents` SET `descr` = '".$descr."' WHERE `id` = '".$_GET['torrent']."'";
$db->sql_query($upd_sql) or btsqlerror($upd_sql);
print( nl2br( stripslashes( $_GET['descr'] ) ) );
ob_end_flush();
$db->sql_close();
die();
}
case 'change_banned_torrent':{
if( !isset( $_GET['torrent'] ) || !is_numeric( $_GET['torrent'] ) ){
error("Invalid torrent!" );
}
// check is mod or higher
if(!checkaccess("bann_torrents")){
error("Invalid permissions!" );
}
// create the select
print( "<select onchange=\"if(confirm('Save banned state?')==true){sndReq('op=save_banned_torrent&torrent=".$_GET['torrent']."&banned='+this.selectedIndex, 'bannedChange')}\">
<option value=\"\" selected=\"selected\">Banned?</option>
<option value=\"1\">Yes</option>
<option value=\"0\">No</option>
</select>
");
ob_end_flush();
$db->sql_close();
die();
}
case 'save_banned_torrent':{
//check valid torrent
if( !isset( $_GET['torrent'] ) || !is_numeric( $_GET['torrent'] ) ){
error("Invalid torrent!" );
}
// check is mod or higher
if(!checkaccess("bann_torrents")){
error("Invalid permissions!" );
}
// convert $_GET['banned'] to 'yes' or 'no'
switch( $_GET['banned'] ){
case 1 : $state = 'yes'; break;
case 2 : $state = 'no'; break;
default : $state = 'no'; break;
}
// do the SQL
$sql = "UPDATE `".$db_prefix."_torrents` SET `banned` = '".$state."' WHERE `id` = '".$_GET['id']."' LIMIT 1";
$db->sql_query($sql) or btsqlerror($sql);
// print the outcome
print( $state );
ob_end_flush();
$db->sql_close();
die();
}
case 'change_type_torrent':{
//check valid torrent
if( !isset( $_GET['torrent'] ) || !is_numeric( $_GET['torrent'] ) ){
print( "Invalid torrent!" );
ob_end_flush();
$db->sql_close();
die();
}
// check is mod or higher
if(!$user->moderator){
error("Invalid permissions!" );
ob_end_flush();
$db->sql_close();
die();
}
// create the select
print("<select onchange=\"if(confirm('Save type change?')==true){sndReq('op=save_type_torrent&torrent=".$_GET['torrent']."&type='+this.options[this.selectedIndex].value, 'catTD')}\">");
$cats = catlist();
print("<option value=\"\">(choose one)</option>\n");
foreach ($cats as $row){
print("<option value=\"".$row["id"]."\">".htmlspecialchars($row["name"])."</option>\n");
}
print("</select>\n");
ob_end_flush();
$db->sql_close();
die();
}
case 'save_type_torrent':{
//check valid torrent
if( !isset( $_GET['torrent'] ) || !is_numeric( $_GET['torrent'] ) ){
error("Invalid torrent!" );
ob_end_flush();
$db->sql_close();
die();
}
// check is mod or higher
if(!$user->moderator){
error("Invalid permissions!" );
ob_end_flush();
$db->sql_close();
die();