-
Notifications
You must be signed in to change notification settings - Fork 2
/
mainfile.php
1968 lines (1857 loc) · 73 KB
/
mainfile.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
/************************************************************************/
/* PHP-NUKE: Advanced Content Management System */
/* ============================================ */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* 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. */
/************************************************************************/
/* Additional Security and Code Cleanup for Patched 3.1 */
/* Commited by the Nuke Patched Development Team 2005 */
/* chatserv, Evaders99, Quake */
/* http://www.nukeresources.com - Download location */
/* http://www.nukefixes.com - Development location */
/* http://sourceforge.net/projects/nukepatched/ - CVS */
/* Last file update: 30/07/05 */
/************************************************************************/
/************************************************************************/
/* Additional code clean-up, performance enhancements, and W3C and */
/* XHTML compliance fixes by Raven and Montego. */
/************************************************************************/
// End the transaction
if(!defined('END_TRANSACTION')) {
define('END_TRANSACTION', 2);
}
// Get PHP Version
$phpver = phpversion();
// convert superglobals - Modified by Raven 5/12/2006 - from http://www.php.net/manual/en/language.variables.predefined.php
if (!isset($_SERVER))
{
$_GET = &$HTTP_GET_VARS;
$_POST = &$HTTP_POST_VARS;
$_ENV = &$HTTP_ENV_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
$_COOKIE = &$HTTP_COOKIE_VARS;
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
}
$PHP_SELF = $_SERVER['PHP_SELF'];
// After doing those superglobals we can now use one
// and check if this file isnt being accessed directly
if (stristr(htmlentities($_SERVER['PHP_SELF']), 'mainfile.php')) {
header('Location: index.php');
exit();
}
if (!function_exists('floatval')) {
function floatval($inputval) {
return (float)$inputval;
}
}
if ($phpver >= '4.0.4pl1' && isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'],'compatible')) {
if (extension_loaded('zlib')) {
@ob_end_clean();
ob_start('ob_gzhandler');
}
} elseif ($phpver > '4.0' && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
if (extension_loaded('zlib')) {
$do_gzip_compress = true;
ob_start(array('ob_gzhandler',5));
ob_implicit_flush(0);
if (ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Encoding: gzip');
}
}
}
}
if (!ini_get('register_globals')) {
@import_request_variables('GPC', '');
}
// This block of code makes sure $admin and $user are COOKIES
if((isset($admin) && $admin != $_COOKIE['admin']) OR (isset($user) && $user != $_COOKIE['user'])) {
die('Illegal Operation');
}
// We want to use the function stripos,
// but thats only available since PHP5.
// So we cloned the function...
if(!function_exists('stripos')) {
function stripos_clone($haystack, $needle, $offset=0) {
$return = strpos(strtoupper($haystack), strtoupper($needle), $offset);
if ($return === false) {
return false;
} else {
return true;
}
}
} else {
// But when this is PHP5, we use the original function
function stripos_clone($haystack, $needle, $offset=0) {
$return = stripos($haystack, $needle, $offset);
if ($return === false) {
return false;
} else {
return true;
}
}
}
/*****[BEGIN]******************************************
[ Base: GFX Code v1.0.0 ]
******************************************************/
define('GDSUPPORT', extension_loaded('gd'));
if(function_exists('imagecreatetruecolor') && function_exists('imageftbbox')) {
define('VISUAL_CAPTCHA',true);
}
/*****[END]********************************************
[ Base: GFX Code v1.0.0 ]
******************************************************/
if(isset($admin) && $admin == $_COOKIE['admin'])
{
$admin = base64_decode($admin);
$admin = addslashes($admin);
$admin = base64_encode($admin);
}
if(isset($user) && $user == $_COOKIE['user'])
{
$user = base64_decode($user);
$user = addslashes($user);
$user = base64_encode($user);
}
// Die message for not allowed HTML tags
define('_HTMLTAGSNOTALLOWED','The html tags you attempted to use are not allowed.');
define('_MAINFILEGOBACK','Go Back');
$htmltags = '<center><img src="images/logo.gif" alt="" /><br /><br /><b>';
$htmltags .= _HTMLTAGSNOTALLOWED.'</b><br /><br />';
$htmltags .= '[ <a href="javascript:history.go(-1)"><b>'._MAINFILEGOBACK.'</b></a> ]';
if(defined('FORUM_ADMIN')) define('INCLUDE_PATH', '../../../');
elseif(defined('INSIDE_MOD')) define('INCLUDE_PATH', '../../');
else define('INCLUDE_PATH', './');
require_once INCLUDE_PATH . 'config.php';
// Added by Raven for my RavenNuke(tm) installation
// Error reporting, to be set in rnconfig.php
// Modified by Raven 11/22/2005
// Default is error_reporting(E_ALL^E_NOTICE);
error_reporting($error_reporting);
if($display_errors) {
@ini_set('display_errors', 1);
} else {
@ini_set('display_errors', 0);
}
// Fail if $admin_file is not set or does not exist
define('_ADMINSET','You must set a value for admin_file in config.php');
define('_ADMINNOTEXISTS','The admin_file you defined in config.php does not exist');
if (!defined('FORUM_ADMIN')) {
if(empty($admin_file)) {
die (_ADMINSET);
} elseif (!empty($admin_file) && !file_exists($admin_file.'.php')) {
die (_ADMINNOTEXISTS);
}
}
require_once INCLUDE_PATH . 'db/db.php';
$result = $db->sql_query("SELECT * FROM `".$prefix."_config` LIMIT 0,1");
$nuke_config = $db->sql_fetchrow($result);
require_once INCLUDE_PATH . 'includes/ipban.php';
if (file_exists(INCLUDE_PATH . 'includes/custom_files/custom_mainfile.php')) {
include_once INCLUDE_PATH . 'includes/custom_files/custom_mainfile.php';
}
/**
* TegoNuke Mailer added by montego for 2.20.00
*/
$tnml_asCfg = array();
$result = $db->sql_query('SELECT * FROM ' . $prefix . '_mail_config');
$row = $db->sql_fetchrow($result);
$tnml_asCfg['nm_is_active'] = intval($row['active']);
if ($tnml_asCfg['nm_is_active'] == 1) {
define('TNML_IS_ACTIVE', true);
include_once INCLUDE_PATH . 'includes/tegonuke/mailer/mailer.php';
}
/*
* NOTE: NukeSentinel and NSN Groups MUST come after as both use the PHP mail() function for their operations
*
* end of TegoNuke Mailer add
*/
require_once INCLUDE_PATH . 'includes/nukesentinel.php';
// For RNYA to check for suspended users, TOS, etc.
require_once INCLUDE_PATH . 'modules/Your_Account/includes/mainfileend.php';
// GT-NExtGEn 0.4/0.5 by Bill Murrin (Audioslaved) http://gt.audioslaved.com (c) 2004
//Modified by montego from http://montegoscripts.com for TegoNuke(tm) ShortLinks
if ((isset($name) && isset($file)) && ($name == 'Forums' && $file == 'modcp')) {
} else {
if (isset($tnsl_bUseShortLinks) && $tnsl_bUseShortLinks && file_exists(INCLUDE_PATH . 'includes/tegonuke/shortlinks/shortlinks.php')) {
define('TNSL_USE_SHORTLINKS', TRUE);
include_once INCLUDE_PATH . 'includes/tegonuke/shortlinks/shortlinks.php';
}
}
/*
* The following two lines of code were moved and commented out in RN 2.30.00 to "test the waters" on
* finding out what old modules/blocks/hacks/etc. are still using this SQL layer that is so
* old it should be obsoleted. If you really need these back, uncomment them back. We will keep this
* code this way for one more major release as well as keep the includes/sql_layer.php script.
*/
//@require_once(INCLUDE_PATH.'includes/sql_layer.php');
//$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
define('NUKE_FILE', true);
//$result = $db->sql_query('SELECT * FROM '.$prefix.'_config');
//$row = $db->sql_fetchrow($result);
$sitename = $nuke_config['sitename'];
$nukeurl = $nuke_config['nukeurl'];
$site_logo = $nuke_config['site_logo'];
$slogan = $nuke_config['slogan'];
$startdate = $nuke_config['startdate'];
$adminmail = stripslashes($nuke_config['adminmail']);
$anonpost = $nuke_config['anonpost'];
$Default_Theme = $nuke_config['Default_Theme'];
$foot1 = $nuke_config['foot1'];
$foot2 = $nuke_config['foot2'];
$foot3 = $nuke_config['foot3'];
$commentlimit = intval($nuke_config['commentlimit']);
$anonymous = $nuke_config['anonymous'];
$minpass = intval($nuke_config['minpass']);
$pollcomm = intval($nuke_config['pollcomm']);
$articlecomm = intval($nuke_config['articlecomm']);
$broadcast_msg = intval($nuke_config['broadcast_msg']);
$my_headlines = intval($nuke_config['my_headlines']);
$top = intval($nuke_config['top']);
$storyhome = intval($nuke_config['storyhome']);
$user_news = intval($nuke_config['user_news']);
$oldnum = intval($nuke_config['oldnum']);
$banners = intval($nuke_config['banners']);
$backend_title = $nuke_config['backend_title'];
$backend_language = $nuke_config['backend_language'];
$language = $nuke_config['language'];
$locale = $nuke_config['locale'];
$multilingual = intval($nuke_config['multilingual']);
$useflags = intval($nuke_config['useflags']);
$notify = intval($nuke_config['notify']);
$notify_email = $nuke_config['notify_email'];
$notify_subject = $nuke_config['notify_subject'];
$notify_message = $nuke_config['notify_message'];
$notify_from = $nuke_config['notify_from'];
$moderate = intval($nuke_config['moderate']);
$admingraphic = intval($nuke_config['admingraphic']);
$CensorMode = intval($nuke_config['CensorMode']);
$CensorReplace = $nuke_config['CensorReplace'];
$copyright = $nuke_config['copyright'];
// $Version_Num = floatval($row['Version_Num']);
$Version_Num = htmlentities(strip_tags($nuke_config['Version_Num']));
$domain = str_replace('http://', '', $nukeurl);
$mtime = microtime();
$mtime = explode(' ',$mtime);
$mtime = $mtime[1] + $mtime[0];
$start_time = $mtime;
$pagetitle = '';
/*****[BEGIN]******************************************
[ Base: GFX Code v1.0.0 ]
******************************************************/
include_once INCLUDE_PATH . 'includes/gfx_check.php';
/*****[END]********************************************
[ Base: GFX Code v1.0.0 ]
******************************************************/
if (!defined('FORUM_ADMIN')) {
$ThemeSel = get_theme();
include_once 'themes/' . $ThemeSel . '/theme.php';
if (($multilingual == 1) AND isset($newlang) AND !stristr($newlang,'.')) {
$newlang = check_html($newlang, 'nohtml');
if (file_exists('language/lang-' . $newlang . '.php')) {
setcookie('lang', $newlang, time()+31536000);
include_once 'language/lang-' . $newlang . '.php';
$currentlang = $newlang;
} else {
setcookie('lang', $language, time()+31536000);
include_once 'language/lang-' . $language . '.php';
$currentlang = $language;
}
} elseif (($multilingual == 1) AND isset($lang) AND !stristr($lang, '.')) {
$lang = check_html($lang, 'nohtml');
if (file_exists('language/lang-' . $lang . '.php')) {
setcookie('lang', $lang, time()+31536000);
include_once 'language/lang-' . $lang . '.php';
$currentlang = $lang;
} else {
setcookie('lang', $language, time()+31536000);
include_once 'language/lang-' . $language . '.php';
$currentlang = $language;
}
} else {
setcookie('lang', $language, time()+31536000);
include_once 'language/lang-' . $language . '.php';
$currentlang = $language;
}
}
// NSN Groups
// This must come after $currentlang is defined
require_once INCLUDE_PATH . 'modules/Groups/includes/nsngr_func.php';
/**
* CSRF Protection for POST/GET forms and potentially "dangerous" links
*/
require_once INCLUDE_PATH . 'includes/csrf-magic.php';
// Added by Raven for my RavenNuke(tm) installation
if (isset($bypassInstallationFolderCheck) AND !$bypassInstallationFolderCheck AND file_exists('INSTALLATION/')) die(_RNINSTALLFILESFOUND);
if(!function_exists('themepreview')) {
function themepreview($title, $hometext, $bodytext = '', $notes = '') {
echo '<b>' . $title . '</b><br /><br />' . $hometext;
if (!empty($bodytext)) {
echo '<br /><br />' . $bodytext;
}
if (!empty($notes)) {
echo '<br /><br /><b>' . _NOTE . '</b> <i>' . $notes . '</i>';
}
}
}
if(!function_exists('themecenterbox')) {
function themecenterbox($title, $content) {
OpenTable();
echo '<center><font class="option"><b>' . $title . '</b></font></center><br />' . $content;
CloseTable();
echo '<br />';
}
}
if (!defined('ADMIN_FILE') && !file_exists('includes/nukesentinel.php')) {
$postString = '';
foreach ($_POST as $postkey => $postvalue) {
if ($postString > '') {
$postString .= '&'.$postkey.'='.$postvalue;
} else {
$postString .= $postkey.'='.$postvalue;
}
}
str_replace('%09', '%20', $postString);
$postString_64 = base64_decode($postString);
if ((!isset($admin) OR (isset($admin) AND !is_admin($admin))) AND (stristr($postString,'%20union%20') OR stristr($postString,'*/union/*') OR stristr($postString,' union ') OR stristr($postString_64,'%20union%20') OR stristr($postString_64,'*/union/*') OR stristr($postString_64,' union ') OR stristr($postString_64,'+union+') OR stristr($postString,'http-equiv') OR stristr($postString_64,'http-equiv') OR stristr($postString,'alert(') OR stristr($postString_64,'alert(') OR stristr($postString,'javascript:') OR stristr($postString_64,'javascript:') OR stristr($postString,'document.cookie') OR stristr($postString_64,'document.cookie') OR stristr($postString,'onmouseover=') OR stristr($postString_64,'onmouseover=') OR stristr($postString,'document.location') OR stristr($postString_64,'document.location'))) {
header('Location: index.php');
die();
}
}
/*****[BEGIN]******************************************
[ Base: GFX Code v1.0.0 ]
******************************************************/
if (isset($gfx)){
switch($gfx) {
case 'gfx':
include_once INCLUDE_PATH . 'includes/gfx.php';
break;
}
}
/*****[END]********************************************
[ Base: GFX Code v1.0.0 ]
******************************************************/
/**
* The following section of code is used to create the legal docs
* menu and set it in a constant so that the constant may be
* used anywhere within *nuke to show the legal menu links.
*
* @version 1.1.0
*
* Examples of usage:
*
* echo LGL_MENU_HTML;
* $s = LGL_MENU_HTML;
* echo $s;
*/
$lgl_legalMenu = '';
if (is_active('Legal')) {
include_once NUKE_CLASSES_DIR . 'class.legal_doctypes.php';
$objDocTypes = new Legal_DocTypes('', $lgl_langS);
$objDocTypes->setShowContact();
$lgl_legalMenu = '<div class="lgl_menu">' . $objDocTypes->html() . '</div>';
}
if (!defined('LGL_MENU_HTML')) define('LGL_MENU_HTML', $lgl_legalMenu);
//Check programmed news
automated_news();
/***********************************************************************************
Since PHP compiles all the functions first, placing all the functions at the end of
the logic helps to better organize the code
***********************************************************************************/
/*
* get_lang function modified by montego to actually return the language that was
* finally found to be "used".
*/
function get_lang($module) {
global $currentlang, $language;
$lang = 'english';
if ($module == 'admin') {
if (file_exists('admin/language/lang-' . $currentlang . '.php')) {
include_once 'admin/language/lang-' . $currentlang . '.php';
$lang = $currentlang;
} elseif (file_exists('admin/language/lang-' . $language . '.php')) {
include_once 'admin/language/lang-' . $language . '.php';
$lang = $language;
} else { // fall back to English
include_once 'admin/language/lang-english.php';
}
} else {
if (file_exists('modules/' . $module . '/language/lang-' . $currentlang . '.php')) {
include_once 'modules/' . $module . '/language/lang-' . $currentlang . '.php';
$lang = $currentlang;
} elseif (file_exists('modules/' . $module . '/language/lang-' . $language . '.php')) {
include_once 'modules/' . $module . '/language/lang-' . $language . '.php';
$lang = $language;
} elseif (file_exists('modules/' . $module . '/language/lang-english.php')) { // fall back to English
include_once 'modules/' . $module . '/language/lang-english.php';
}
}
return $lang;
}
function is_admin($admin) {
if (!$admin) { return 0; }
static $adminSave;
if (isset($adminSave)) return $adminSave;
if (!is_array($admin)) {
$admin = base64_decode($admin);
$admin = addslashes($admin);
$admin = explode(':', $admin);
}
$aid=$pwd='';
if (isset($admin[0])) $aid = $admin[0];
if (isset($admin[1])) $pwd = $admin[1];
$aid = substr(addslashes($aid), 0, 25);
if (!empty($aid) && !empty($pwd)) {
global $prefix, $db;
$sql = 'SELECT pwd FROM '.$prefix.'_authors WHERE aid=\''.$aid.'\'';
$result = $db->sql_query($sql);
$pass = $db->sql_fetchrow($result);
if ($pass[0] == $pwd && !empty($pass[0])) {
return $adminSave = 1;
}
}
return $adminSave = 0;
}
function is_user($user) {
if (!$user) { return 0; }
static $userSave;
if (isset($userSave)) return $userSave;
if (!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$user = explode(':', $user);
}
$uid = $user[0];
$pwd = $user[2];
$uid = intval($uid);
if (!empty($uid) AND !empty($pwd)) {
global $db, $user_prefix;
$sql = 'SELECT user_password FROM ' . $user_prefix . '_users WHERE user_id=\''.$uid.'\'';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
if ($row[0] == $pwd && !empty($row[0])) {
return $userSave = 1;
}
}
return $userSave = 0;
}
function is_group($user, $name) {
global $prefix, $db, $user_prefix, $cookie, $user;
if (is_user($user)) {
if(!is_array($user)) {
$cookie = cookiedecode($user);
$uid = intval($cookie[0]);
} else {
$uid = intval($user[0]);
}
$result = $db->sql_query('SELECT points FROM ' . $user_prefix . '_users WHERE user_id=\'' . $uid . '\'');
list($points) = $db->sql_fetchrow($result);
$points = intval($points);
$result2 = $db->sql_query('SELECT mod_group FROM ' . $prefix . '_modules WHERE title=\'' . $name . '\'');
list($mod_group) = $db->sql_fetchrow($result2);
$mod_group = intval($mod_group);
$result3 = $db->sql_query('SELECT points FROM ' . $prefix . '_groups WHERE id=\'' . $mod_group . '\'');
list($rpoints) = $db->sql_fetchrow($result3);
$grp = intval($rpoints);
if (($points >= 0 AND $points >= $grp) OR $mod_group == 0) {
return 1;
}
}
return 0;
}
function update_points($id) {
global $user_prefix, $prefix, $db, $user;
if (is_user($user)) {
if(!is_array($user)) {
$cookie = cookiedecode($user);
$username = trim($cookie[1]);
} else {
$username = trim($user[1]);
}
if ($db->sql_numrows($db->sql_query('SELECT * FROM ' . $prefix . '_groups')) > '0') {
$id = intval($id);
$result = $db->sql_query('SELECT points FROM ' . $prefix . '_groups_points WHERE id=\'' . $id . '\'');
list($points) = $db->sql_fetchrow($result);
$rpoints = intval($points);
$db->sql_query('UPDATE ' . $user_prefix.'_users SET points=points+' . $rpoints . ' WHERE username=\'' . $username . '\'');
}
}
}
function title($text) {
OpenTable();
echo '<center><span class="title">' . $text . '</span></center>';
CloseTable();
echo '<br />';
}
function is_active($module) {
global $prefix, $db;
static $save;
if (is_array($save)) {
if (isset($save[$module])) return ($save[$module]);
return 0;
}
$sql = 'SELECT title FROM '.$prefix.'_modules WHERE active=\'1\'';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$save[$row[0]] = 1;
}
if (isset($save[$module])) return ($save[$module]);
return 0;
}
function render_blocks($side, $blockfile, $title, $content, $bid, $url) {
if(!defined('BLOCK_FILE')) {
define('BLOCK_FILE', true);
}
if (empty($url)) {
if (empty($blockfile)) {
// GT-NExtGEn 0.5 by Bill Murrin (Audioslaved) http://gt.audioslaved.com (c) 2004
//Modified by montego from http://montegoscripts.com for TegoNuke(tm) ShortLinks
global $tnsl_bAutoTapBlocks;
if (defined('TNSL_USE_SHORTLINKS') && isset($tnsl_bAutoTapBlocks) && $tnsl_bAutoTapBlocks) {
$content = tnsl_fShortenBlockURLs('', $content);
}
//End of GT-NExtGEn / ShortURLs
if ($side == 'c') {
themecenterbox($title, $content);
} elseif ($side == 'd') {
themecenterbox($title, $content);
} else {
themesidebox($title, $content);
}
} else {
if ($side == 'c') {
blockfileinc($title, $blockfile, 1);
} elseif ($side == 'd') {
blockfileinc($title, $blockfile, 1);
} else {
blockfileinc($title, $blockfile);
}
}
} else {
if ($side == 'c' OR $side == 'd') {
headlines($bid,1);
} else {
headlines($bid);
}
}
}
function blocks($side) {
global $storynum, $prefix, $multilingual, $currentlang, $db, $admin, $user;
if ($multilingual == 1) {
$querylang = 'AND (blanguage=\''.$currentlang.'\' OR blanguage=\'\')';
} else {
$querylang = '';
}
if (strtolower($side[0]) == 'l') {
$pos = 'l';
} elseif (strtolower($side[0]) == 'r') {
$pos = 'r';
} elseif (strtolower($side[0]) == 'c') {
$pos = 'c';
} elseif (strtolower($side[0]) == 'd') {
$pos = 'd';
}
$side = $pos;
$result = $db->sql_query('SELECT * FROM '.$prefix.'_blocks WHERE bposition=\''.$pos.'\' AND active=1 '.$querylang.' ORDER BY weight ASC');
while($row = $db->sql_fetchrow($result)) {
$groups = $row['groups'];
$bid = intval($row['bid']);
$title = stripslashes(check_html($row['title'], 'nohtml'));
$content = stripslashes($row['content']);
$url = stripslashes($row['url']);
$blockfile = $row['blockfile'];
$view = intval($row['view']);
$expire = intval($row['expire']);
$action = $row['action'];
$action = substr("$action", 0,1);
$now = time();
$sub = intval($row['subscription']);
if ($sub == 0 OR ($sub == 1 AND !paid())) {
if ($expire != 0 AND $expire <= $now) {
if ($action == 'd') {
$db->sql_query('UPDATE '.$prefix.'_blocks SET active=0, expire=\'0\' WHERE bid=\''.$bid.'\'');
return;
} elseif ($action == 'r') {
$db->sql_query('DELETE FROM '.$prefix.'_blocks WHERE bid=\''.$bid.'\'');
return;
}
}
if ($row['bkey'] == 'admin') {
adminblock();
} elseif ($row['bkey'] == 'userbox') {
userblock();
} elseif (empty($row['bkey'])) {
if ($view == 0) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 1 AND is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 2 AND is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view == 3 AND !is_user($user) || is_admin($admin)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
} elseif ($view > 3 AND in_groups($groups)) {
render_blocks($side, $blockfile, $title, $content, $bid, $url);
}
}
}
}
}
function message_box() {
global $bgcolor1, $bgcolor2, $user, $admin, $cookie, $textcolor2, $prefix, $multilingual, $currentlang, $db, $admin_file;
if ($multilingual == 1) {
$querylang = 'AND (mlanguage=\''.$currentlang.'\' OR mlanguage=\'\')';
} else {
$querylang = '';
}
$result = $db->sql_query('SELECT * FROM '.$prefix.'_message WHERE active=1 '.$querylang);
if ($numrows = $db->sql_numrows($result) == 0) {
return;
} else {
while ($row = $db->sql_fetchrow($result)) {
$groups = $row['groups'];
$mid = intval($row['mid']);
$title = stripslashes(check_html($row['title'], 'nohtml'));
$content = stripslashes($row['content']);
$mdate = $row['date'];
$expire = intval($row['expire']);
$view = intval($row['view']);
if (!empty($title) && !empty($content)) {
if ($expire == 0) {
$remain = _UNLIMITED;
} else {
$etime = (($mdate+$expire)-time())/3600;
$etime = (int)$etime;
if ($etime < 1) {
$remain = _EXPIRELESSHOUR;
} else {
$remain = _EXPIREIN.' '.$etime.' '._HOURS;
}
}
if ($view > 5 AND in_groups($groups)) {
OpenTable();
echo '<center><font class="option" color="'.$textcolor2.'"><b>'.$title.'</b></font></center><br />'."\n";
echo '<div class="content">'.$content.'</div>'."\n";
if (is_admin($admin)) {
echo '<br /><br /><center><font class="content">[ '._MVIEWGROUPS.' - '.$remain.' - <a href="'.$admin_file.'.php?op=editmsg&mid='.$mid.'">'._EDIT.'</a> ]</font></center>'."\n";
}
CloseTable();
echo '<br />';
} elseif ($view == 5 AND paid()) {
OpenTable();
echo '<center><font class="option" color="'.$textcolor2.'"><b>'.$title.'</b></font></center><br />'."\n"
.'<div class="content">'.$content.'</div>'."\n";
if (is_admin($admin)) {
echo '<br /><br /><center><font class="content">[ '._MVIEWSUBUSERS.' - '.$remain.' - <a href="'.$admin_file.'.php?op=editmsg&mid='.$mid.'">'._EDIT.'</a> ]</font></center>';
}
CloseTable();
echo '<br />';
} elseif ($view == 4 AND is_admin($admin)) {
OpenTable();
echo '<center><font class="option" color="'.$textcolor2.'"><b>'.$title.'</b></font></center><br />'."\n"
.'<div class="content">'.$content.'</div>'."\n"
.'<br /><br /><center><font class="content">[ '._MVIEWADMIN.' - '.$remain.' - <a href="'.$admin_file.'.php?op=editmsg&mid='.$mid.'">'._EDIT.'</a> ]</font></center>';
CloseTable();
echo '<br />';
} elseif ($view == 3 AND is_user($user) || is_admin($admin)) {
OpenTable();
echo '<center><font class="option" color="'.$textcolor2.'"><b>'.$title.'</b></font></center><br />'."\n"
.'<div class="content">'.$content.'</div>'."\n";
if (is_admin($admin)) {
echo '<br /><br /><center><font class="content">[ '._MVIEWUSERS.' - '.$remain.' - <a href="'.$admin_file.'.php?op=editmsg&mid='.$mid.'">'._EDIT.'</a> ]</font></center>';
}
CloseTable();
echo '<br />';
} elseif ($view == 2 AND !is_user($user) || is_admin($admin)) {
OpenTable();
echo '<center><font class="option" color="'.$textcolor2.'"><b>'.$title.'</b></font></center><br />'."\n"
.'<div class="content">'.$content.'</div>'."\n";
if (is_admin($admin)) {
echo '<br /><br /><center><font class="content">[ '._MVIEWANON.' - '.$remain.' - <a href="'.$admin_file.'.php?op=editmsg&mid='.$mid.'">'._EDIT.'</a> ]</font></center>';
}
CloseTable();
echo '<br />';
} elseif ($view == 1) {
OpenTable();
echo '<center><font class="option" color="'.$textcolor2.'"><b>'.$title.'</b></font></center><br />'."\n"
.'<div class="content">'.$content.'</div>'."\n";
if (is_admin($admin)) {
echo '<br /><br /><center><font class="content">[ '._MVIEWALL.' - '.$remain.' - <a href="'.$admin_file.'.php?op=editmsg&mid='.$mid.'">'._EDIT.'</a> ]</font></center>';
}
CloseTable();
echo '<br />';
}
if ($expire != 0) {
$past = time()-$expire;
if ($mdate < $past) {
$db->sql_query('UPDATE '.$prefix.'_message SET active=0 WHERE mid=\''.$mid.'\'');
}
}
}
}
}
}
function online() {
global $nsnst_const, $user, $cookie, $prefix, $db;
if(!defined('NUKESENTINEL_IS_LOADED')) {
$ip = $_SERVER['REMOTE_ADDR'];
if(!validIP($ip)) $ip = 'none'; //RN0000991 + tightened it up some with new validIP() function in mainfile.php
} else {
$ip = (!isset($nsnst_const['remote_ip'])) ? 'none' : $nsnst_const['remote_ip']; //RN0000991
}
$guest = 0;
if (is_user($user)) {
cookiedecode($user);
$uname = $cookie[1];
if (!isset($uname)) {
$uname = $ip;
$guest = 1;
}
} else {
$uname = $ip;
$guest = 1;
}
$uname = addslashes($uname);
$past = time()-3600;
$sql = 'DELETE FROM '.$prefix.'_session WHERE time < \''.$past.'\'';
$db->sql_query($sql);
$sql = 'SELECT time FROM '.$prefix.'_session WHERE uname=\''.$uname.'\'';
$result = $db->sql_query($sql);
$ctime = time();
if (!empty($uname)) {
$uname = substr($uname, 0,25);
$row = $db->sql_fetchrow($result);
if ($row) {
$db->sql_query('UPDATE '.$prefix.'_session SET uname=\''.$uname.'\', time=\''.$ctime.'\', host_addr=\''.$ip.'\', guest=\''.$guest.'\' WHERE uname=\''.$uname.'\'');
} else {
$db->sql_query('INSERT INTO '.$prefix.'_session (uname, time, host_addr, guest) VALUES (\''.$uname.'\', \''.$ctime.'\', \''.$ip.'\', \''.$guest.'\')');
}
}
}
function blockfileinc($title, $blockfile, $side=0) {
$blockfiletitle = $title;
$file = file_exists('blocks/'.$blockfile);
if (!$file) {
$content = _BLOCKPROBLEM;
} else {
include_once('blocks/'.$blockfile);
}
if (empty($content)) {
$content = _BLOCKPROBLEM2;
} else { //Added by montego from http://montegoscripts.com for TegoNuke(tm) ShortLinks
global $tnsl_bAutoTapBlocks;
if (defined('TNSL_USE_SHORTLINKS') && isset($tnsl_bAutoTapBlocks) && $tnsl_bAutoTapBlocks) {
$content = tnsl_fShortenBlockURLs($blockfile, $content);
}
}
//End of TegoNuke(tm) ShortLinks
if ($side == 1) {
themecenterbox($blockfiletitle, $content);
} elseif ($side == 2) {
themecenterbox($blockfiletitle, $content);
} else {
themesidebox($blockfiletitle, $content);
}
}
/*
* The following lines of code were moved and commented out in RN 2.40.00 . This is/was an unussed funtion.
* RN has a block file that does the same thing. This function should not be here becuase it is loaded on every page even if it isn't needed.
* If you really need this function back, uncomment it. We will keep this
* code this way for one more major release.
*/
/*
function selectlanguage() {
global $useflags, $currentlang;
if ($useflags == 1) {
$title = _SELECTLANGUAGE;
$content = '<center><font class="content">'._SELECTGUILANG.'<br /><br />';
$langdir = dir('language');
while($func=$langdir->read()) {
if(substr($func, 0, 5) == 'lang-') {
$menulist .= "$func ";
}
}
closedir($langdir->handle);
$menulist = explode(' ', $menulist);
sort($menulist);
for ($i=0; $i < sizeof($menulist); $i++) {
if($menulist[$i]!='') {
$tl = str_replace('lang-','',$menulist[$i]);
$tl = str_replace('.php','',$tl);
$altlang = ucfirst($tl);
$content .= '<a href="index.php?newlang='.$tl.'"><img src="images/language/flag-'.$tl.'.png" border="0" alt="'.$altlang.'" title="'.$altlang.'" hspace="3" vspace="3" /></a> ';
}
}
$content .= '</font></center>';
themesidebox($title, $content);
} else {
$title = _SELECTLANGUAGE;
$content = '<center><font class="content">'._SELECTGUILANG.'<br /><br /></font>';
$content .= '<form action="index.php" method="get"><select name="newlanguage" onchange="top.location.href=this.options[this.selectedIndex].value">';
$handle=opendir('language');
while ($file = readdir($handle)) {
if (preg_match('/^lang\-(.+)\.php/', $file, $matches)) {
$langFound = $matches[1];
$languageslist .= "$langFound ";
}
}
closedir($handle);
$languageslist = explode(' ', $languageslist);
sort($languageslist);
for ($i=0; $i < sizeof($languageslist); $i++) {
if($languageslist[$i]!='') {
$content .= '<option value="index.php?newlang='.$languageslist[$i].'" ';
if($languageslist[$i]==$currentlang) {
$content .= ' selected="selected"';
}
$content .= '>'.ucfirst($languageslist[$i]).'</option>';
}
}
$content .= '</select></form></center>'."\n";
themesidebox($title, $content);
}
}*/
function cookiedecode($user) {
global $cookie, $db, $user_prefix;
static $pass;
if(!is_array($user)) {
$user = base64_decode($user);
$user = addslashes($user);
$cookie = explode(':', $user);
} else {
$cookie = $user;
}
if (!isset($pass) AND isset($cookie[1])) {
$sql = 'SELECT user_password FROM '.$user_prefix.'_users WHERE username=\''.$cookie[1].'\'';
$result = $db->sql_query($sql);
list($pass) = $db->sql_fetchrow($result);
}
if (isset($cookie[2]) AND ($cookie[2] == $pass) AND (!empty($pass))) { return $cookie; }
}
function getusrinfo($user) {
global $user_prefix, $db, $userinfo, $cookie;
if (!$user OR empty($user)) {
return NULL;
}
cookiedecode($user);
$user = $cookie;
if (isset($userrow) AND is_array($userrow)) {
if ($userrow['username'] == $user[1] && $userrow['user_password'] == $user[2]) {
return $userrow;
}
}
$sql = 'SELECT * FROM '.$user_prefix.'_users WHERE username=\''.$user[1].'\' AND user_password=\''.$user[2].'\'';
$result = $db->sql_query($sql);
if ($db->sql_numrows($result) == 1) {
static $userrow;
$userrow = $db->sql_fetchrow($result);
return $userinfo = $userrow;
}
unset($userinfo);
}
// Speed up this function with stripos_clone and str_replace
function FixQuotes ($what = '') {
$what = str_replace("'","''",$what);
while (stripos_clone($what, "\\\\'")) {
$what = str_replace("\\\\'","'",$what);
}
return $what;
}
/*********************************************************/
/* text filter */
/*********************************************************/
function check_words($Message) {
global $CensorMode, $CensorReplace, $EditedMessage, $CensorList;
include_once(INCLUDE_PATH.'config.php');
$EditedMessage = $Message;
if ($CensorMode != 0) {
if (is_array($CensorList)) {
$Replace = $CensorReplace;
if ($CensorMode == 1) {
for ($i = 0; $i < count($CensorList); $i++) {
$EditedMessage = eregi_replace("$CensorList[$i]([^a-zA-Z0-9])","$Replace\\1",$EditedMessage);
}
} elseif ($CensorMode == 2) {
for ($i = 0; $i < count($CensorList); $i++) {
$EditedMessage = eregi_replace("(^|[^[:alnum:]])$CensorList[$i]","\\1$Replace",$EditedMessage);
}
} elseif ($CensorMode == 3) {
for ($i = 0; $i < count($CensorList); $i++) {
$EditedMessage = eregi_replace("$CensorList[$i]","$Replace",$EditedMessage);
}
}
}
}
return $EditedMessage;
}
function delQuotes($string) {
/* no recursive function to add quote to an HTML tag if needed */
/* and delete duplicate spaces between attribs. */
$tmp=''; // string buffer
$result=''; // result string
$i=0;
$attrib=-1; // Are us in an HTML attrib ? -1: no attrib 0: name of the attrib 1: value of the atrib
$quote=0; // Is a string quote delimited opened ? 0=no, 1=yes
$len = strlen($string);
while ($i<$len) {
switch($string[$i]) { // What car is it in the buffer ?
case '"': // a quote.
if ($quote==0) {
$quote=1;
} else {
$quote=0;
if (($attrib>0) && ($tmp != '')) { $result .= "=\"$tmp\""; }
$tmp='';
$attrib=-1;
}
break;
case '=': // an equal - attrib delimiter
if ($quote==0) { // Is it found in a string ?
$attrib=1;
if ($tmp!='') $result.=" $tmp";
$tmp='';
} else $tmp .= '=';
break;
case ' ': // a blank ?
if ($attrib>0) { # add it to the string, if one opened.
$tmp .= $string[$i];
}
break;
default: // Other
if ($attrib<0) // If we weren't in an attrib, set attrib to 0
$attrib=0;
$tmp .= $string[$i];
break;
}
$i++;
}
if (($quote!=0) && ($tmp != '')) {
if ($attrib==1) { $result .= '='; } // If it is the value of an atrib, add the '='
$result .= "\"$tmp\""; // Add quote if needed (the reason of the function ;-)
}
return $result;
}
###############################################################################
#
# nukeWYSIWYG Copyright (c) 2005 Kevin Guske http://nukeseo.com
# kses developed by Ulf Harnhammar http://kses.sf.net