Share Pastebin
Guest
Public paste!

_settings.php

By: a guest | Mar 20th, 2010 | Syntax: None | Size: 11.00 KB | Hits: 154 | Expires: Never
Copy text to clipboard
  1. <?php
  2. /*
  3. ##########################################################################
  4. #                                                                        #
  5. #           Version 4       /                        /   /               #
  6. #          -----------__---/__---__------__----__---/---/-               #
  7. #           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
  8. #          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
  9. #                       Free Content / Management System                 #
  10. #                                   /                                    #
  11. #                                                                        #
  12. #                                                                        #
  13. #   Copyright 2005-2009 by webspell.org                                  #
  14. #                                                                        #
  15. #   visit webSPELL.org, webspell.info to get webSPELL for free           #
  16. #   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
  17. #   - It's NOT allowed to remove this copyright-tag                      #
  18. #   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
  19. #                                                                        #
  20. #   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
  21. #   Far Development by Development Team - webspell.org                   #
  22. #                                                                        #
  23. #   visit webspell.org                                                   #
  24. #                                                                        #
  25. ##########################################################################
  26. */
  27.  
  28. // -- ERROR REPORTING -- //
  29.  
  30. define('DEBUG', "OFF");
  31. error_reporting(E_ALL); // 0 = public mode, E_ALL = development-mode
  32.  
  33. // -- SET ENCODING FOR MB-FUNCTIONS -- //
  34.  
  35. mb_internal_encoding("UTF-8");
  36.  
  37. // -- SET HTTP ENCODING -- //
  38.  
  39. header('content-type: text/html; charset=utf-8');
  40.  
  41. // -- CONNECTION TO MYSQL -- //
  42.  
  43. mysql_connect($host, $user, $pwd) or system_error('ERROR: Can not connect to MySQL-Server');
  44. mysql_select_db($db) or system_error('ERROR: Can not connect to database "'.$db.'"');
  45.  
  46. mysql_query("SET NAMES 'utf8'");
  47.  
  48. // -- GENERAL PROTECTIONS -- //
  49.  
  50. function globalskiller() {              // kills all non-system variables
  51.  
  52.   $global = array('GLOBALS', '_POST', '_GET', '_COOKIE', '_FILES', '_SERVER', '_ENV',  '_REQUEST', '_SESSION');
  53.   foreach ($GLOBALS as $key=>$val) {
  54.         if(!in_array($key, $global)) {
  55.                 if(is_array($val)) unset_array($GLOBALS[$key]);
  56.                 else unset($GLOBALS[$key]);
  57.         }
  58.   }
  59. }
  60.  
  61. function unset_array($array) {
  62.  
  63.         foreach($array as $key) {
  64.                 if(is_array($key)) unset_array($key);
  65.                 else unset($key);
  66.         }
  67. }
  68.  
  69. globalskiller();
  70.  
  71. if(isset($_GET['site'])) $site=$_GET['site'];
  72. else $site= null;
  73. if($site!="search") {
  74.         $request=strtolower(urldecode($_SERVER['QUERY_STRING']));
  75.         $protarray=array("union","select","into","where","update ","from","/*","set ",PREFIX."user ",PREFIX."user(",PREFIX."user`",PREFIX."user_groups","phpinfo",
  76.         "escapeshellarg","exec","fopen","fwrite","escapeshellcmd","passthru","proc_close","proc_get_status","proc_nice",
  77.         "proc_open","proc_terminate","shell_exec","system","telnet","ssh","cmd","mv","chmod","chdir","locate","killall",
  78.         "passwd","kill","script","bash","perl","mysql","~root",".history","~nobody","getenv"
  79.         );
  80.         $check=str_replace($protarray, '*', $request);
  81.         if($request != $check) system_error("Invalid request detected.");
  82. }
  83.  
  84. function security_slashes(&$array) {
  85.         foreach($array as $key => $value) {
  86.                 if(is_array($array[$key])) {
  87.                         security_slashes($array[$key]);
  88.                 }
  89.                 else {
  90.                         if(get_magic_quotes_gpc()) {
  91.                                 $tmp = stripslashes($value);
  92.                         }
  93.                         else {
  94.                                 $tmp = $value;
  95.                         }
  96.                         if(function_exists("mysql_real_escape_string")) {
  97.                                 $array[$key] = mysql_real_escape_string($tmp);
  98.                         }
  99.                         else {
  100.                                 $array[$key] = addslashes($tmp);
  101.                         }
  102.                         unset($tmp);
  103.                 }
  104.         }
  105. }
  106.  
  107. security_slashes($_POST);
  108. security_slashes($_COOKIE);
  109. security_slashes($_GET);
  110.  
  111. // -- MYSQL QUERY FUNCTION -- //
  112. $_mysql_querys = array();
  113. function safe_query($query="") {
  114.         if(stristr(str_replace(' ', '', $query), "unionselect")===FALSE AND stristr(str_replace(' ', '', $query), "union(select")===FALSE){
  115.                 if(empty($query)) return false;
  116.                 if(DEBUG == "OFF") $result = mysql_query($query) or die('Query failed!');
  117.                 else {
  118.                         $result = mysql_query($query) or die('Query failed: '
  119.                         .'<li>errorno='.mysql_errno()
  120.                         .'<li>error='.mysql_error()
  121.                         .'<li>query='.$query);
  122.                 }
  123.                 return $result;
  124.         }
  125.         else die();
  126. }
  127.  
  128. // -- SYSTEM ERROR DISPLAY -- //
  129.  
  130. function system_error($text,$system=1) {
  131.         if($system) {
  132.                 include('version.php');
  133.                 $info='webSPELL Version: '.$version.'<br />PHP Version: '.phpversion().'<br />MySQL Version: '.mysql_get_server_info().'<br />';
  134.         } else {
  135.                 $info = '';
  136.         }
  137.         die('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  138.   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  139.   <head>
  140.           <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  141.           <meta name="description" content="Clanpage using webSPELL 4 CMS" />
  142.           <meta name="author" content="webspell.org" />
  143.           <meta name="keywords" content="webspell, webspell4, clan, cms" />
  144.           <meta name="copyright" content="Copyright &copy; 2005 - 2009 by webspell.org" />
  145.           <meta name="generator" content="webSPELL" />
  146.           <title>webSPELL</title>
  147.   </head>
  148.   <body>
  149.   <center>
  150.   <table border="0" cellpadding="1" cellspacing="1" bgcolor="#eeeeee">
  151.     <tr>
  152.       <td><a href="http://www.webspell.org" target="_blank"><img src="images/banner.gif" style="border:none;" alt="webSPELL.org" title="webSPELL.org" /></a></td>
  153.     </tr>
  154.     <tr bgcolor="#ffffff">
  155.       <td><div style="color:#333333;font-family:Tahoma,Verdana,Arial;font-size:11px;padding:5px;">'.$info.'<br /><font color="red">'.$text.'</font><br />&nbsp;</div></td>
  156.     </tr>
  157.     <tr bgcolor="#ffffff">
  158.       <td><div style="color:#333333;font-family:Tahoma,Verdana,Arial;font-size:11px;padding:5px;">For support visit <a href="http://webspell.org" target="_blank">webspell.org</a></div></td>
  159.     </tr>
  160.   </table>
  161.   </center>
  162.   </body>
  163.   </html>');
  164. }
  165.  
  166. // -- SYSTEM FILE INCLUDE -- //
  167.  
  168. function systeminc($file) {
  169.         if(!include('src/'.$file.'.php')) system_error('Could not get system file for '.$file);
  170. }
  171.  
  172. // -- IGNORED USERS -- //
  173.  
  174. function isignored($userID, $buddy) {
  175.         $anz=mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."buddys WHERE buddy='$buddy' AND userID='$userID' "));
  176.         if($anz) {
  177.                 $ergebnis=safe_query("SELECT * FROM ".PREFIX."buddys WHERE buddy='$buddy' AND userID='$userID' ");
  178.                 $ds=mysql_fetch_array($ergebnis);
  179.                 if($ds['banned']==1) return 1;
  180.                 else return 0;
  181.         }
  182.         else return 0;
  183. }
  184.  
  185. // -- GLOBAL SETTINGS -- //
  186.  
  187. $ds = mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."settings"));
  188.  
  189. $maxshownnews                           =       $ds['news'];                            if(empty($maxshownnews)) $maxshownnews = 10;
  190. $maxnewsarchiv                          =       $ds['newsarchiv'];                      if(empty($maxnewsarchiv)) $maxnewsarchiv = 20;
  191. $maxheadlines                           =       $ds['headlines'];                       if(empty($maxheadlines)) $maxheadlines = 10;
  192. $maxheadlinechars                       =       $ds['headlineschars'];          if(empty($maxheadlinechars)) $maxheadlinechars = 18;
  193. $maxtopnewschars                        =       $ds['topnewschars'];            if(empty($maxtopnewschars)) $maxtopnewschars = 200;
  194. $maxarticles                            =       $ds['articles'];                        if(empty($maxarticles)) $maxarticles = 20;
  195. $latestarticles                         =       $ds['latestarticles'];          if(empty($latestarticles)) $latestarticles = 5;
  196. $articleschars                          =       $ds['articleschars'];           if(empty($articleschars)) $articleschars = 18;
  197. $maxclanwars                            =       $ds['clanwars'];                        if(empty($maxclanwars)) $maxclanwars = 20;
  198. $maxresults                                     =       $ds['results'];                         if(empty($maxresults)) $maxresults = 5;
  199. $maxupcoming                            =       $ds['upcoming'];                        if(empty($maxupcoming)) $maxupcoming = 5;
  200. $maxguestbook                           =       $ds['guestbook'];                       if(empty($maxguestbook)) $maxguestbook = 20;
  201. $maxshoutbox                            =       $ds['shoutbox'];                        if(empty($maxshoutbox)) $maxshoutbox = 5;
  202. $maxsball                                       =       $ds['sball'];                           if(empty($latestarticles)) $latestarticles = 5;
  203. $sbrefresh                                      =       $ds['sbrefresh'];                       if(empty($sbrefresh)) $sbrefresh = 60;
  204. $maxtopics                                      =       $ds['topics'];                          if(empty($maxtopics)) $maxtopics = 20;
  205. $maxposts                                       =       $ds['posts'];                           if(empty($maxposts)) $maxposts = 10;
  206. $maxlatesttopics                        =       $ds['latesttopics'];            if(empty($maxlatesttopics)) $maxlatesttopics = 10;
  207. $maxlatesttopicchars            =       $ds['latesttopicchars'];        if(empty($maxlatesttopicchars)) $maxlatesttopicchars = 18;
  208. $maxfeedback                            =       $ds['feedback'];                        if(empty($maxfeedback)) $maxfeedback = 5;
  209. $maxmessages                            =       $ds['messages'];                        if(empty($maxmessages)) $maxmessages = 5;
  210. $maxusers                                       =       $ds['users'];                           if(empty($maxusers)) $maxusers = 5;
  211. $hp_url                                         =       $ds['hpurl'];
  212. $admin_name                                     =       $ds['adminname'];
  213. $admin_email                            =       $ds['adminemail'];
  214. $myclantag                                      =       $ds['clantag'];
  215. $myclanname                                     =       $ds['clanname'];
  216. $maxarticles                            =       $ds['articles'];                        if(empty($maxarticles)) $maxarticles = 5;
  217. $maxawards                                      =       $ds['awards'];                          if(empty($maxawards)) $maxawards = 20;
  218. $maxdemos                                       =       $ds['demos'];                           if(empty($maxdemos)) $maxdemos = 20;
  219. $profilelast                            =       $ds['profilelast'];             if(empty($profilelast)) $profilelast = 20;
  220. $topnewsID                                      =       $ds['topnewsID'];
  221. $sessionduration                        =       $ds['sessionduration'];         if(empty($sessionduration)) $sessionduration = 24;
  222. $closed                                         =       (int)$ds['closed'];
  223. $gb_info                                        =       $ds['gb_info'];
  224. $imprint_type                           =       $ds['imprint'];
  225. $picsize_l                                      =       $ds['picsize_l'];                       if(empty($picsize_l)) $picsize_l = 9999;
  226. $picsize_h                                      =       $ds['picsize_h'];                       if(empty($picsize_h)) $picsize_h = 9999;
  227. $gallerypictures                        =       $ds['pictures'];
  228. $publicadmin                            =       $ds['publicadmin'];
  229. $thumbwidth                                     =       $ds['thumbwidth'];              if(empty($thumbwidth)) $thumbwidth = 120;
  230. $usergalleries                          =       $ds['usergalleries'];
  231. $maxusergalleries                       =       $ds['maxusergalleries'];
  232. $default_language                       =       $ds['default_language'];        if(empty($default_language)) $default_language = 'uk';
  233. $rss_default_language           =       $ds['default_language'];        if(empty($rss_default_language)) $rss_default_language = 'uk';
  234. $search_min_len                         =       $ds['search_min_len'];          if(empty($search_min_len)) $search_min_len = '4';
  235. $autoresize                             =       $ds['autoresize'];                      if(empty($autoresize)) $autoresize = 2;
  236. $max_wrong_pw                           =       $ds['max_wrong_pw'];            if(empty($max_wrong_pw)) $max_wrong_pw = 3;
  237. $lastBanCheck                           =       $ds['bancheck'];
  238. $insertlinks                            =       $ds['insertlinks'];
  239. $new_chmod = 0666;
  240.  
  241. // -- STYLES -- //
  242.  
  243. $ergebnis=safe_query("SELECT * FROM ".PREFIX."styles");
  244. $ds=mysql_fetch_array($ergebnis);
  245.  
  246. define('PAGEBG', $ds['bgpage']);
  247. define('BORDER', $ds['border']);
  248. define('BGHEAD', $ds['bghead']);
  249. define('BGCAT', $ds['bgcat']);
  250. define('BG_1', $ds['bg1']);
  251. define('BG_2', $ds['bg2']);
  252. define('BG_3', $ds['bg3']);
  253. define('BG_4', $ds['bg4']);
  254.  
  255. $hp_title = stripslashes($ds['title']);
  256. $pagebg = PAGEBG;
  257. $border = BORDER;
  258. $bghead = BGHEAD;
  259. $bgcat  = BGCAT;
  260.  
  261. $wincolor = $ds['win'];
  262. $loosecolor = $ds['loose'];
  263. $drawcolor = $ds['draw'];
  264. ?>