Advertisement
Guest User

Untitled

a guest
Jul 9th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.74 KB | None | 0 0
  1. <?php
  2. /*=======================================================================
  3. | UberCMS - Advanced Website and Content Management System for uberEmu
  4. | #######################################################################
  5. | Copyright (c) 2010, Roy 'Meth0d'
  6. | http://www.meth0d.org
  7. | #######################################################################
  8. | This program is free software: you can redistribute it and/or modify
  9. | it under the terms of the GNU General Public License as published by
  10. | the Free Software Foundation, either version 3 of the License, or
  11. | (at your option) any later version.
  12. | #######################################################################
  13. | This program is distributed in the hope that it will be useful,
  14. | but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. | GNU General Public License for more details.
  17. \======================================================================*/
  18.  
  19. class uberCore
  20. {
  21.     public $config;
  22.     public $execStart;
  23.    
  24.     public function __construct()
  25.     {
  26.         $this->execStart = microtime(true);
  27.     }  
  28.    
  29.     public static function CheckBetaKey($keyCode)
  30.     {
  31.         return (mysql_num_rows(dbquery("SELECT null FROM betakeys WHERE keyc = '" . filter($keyCode) . "' AND qty > 0 LIMIT 1")) > 0) ? true : false;
  32.     }
  33.    
  34.     public static function EatBetaKey($keyCode)
  35.     {
  36.         dbquery("UPDATE betakeys SET qty = qty - 1 WHERE keyc = '" . filter($keyCode) . "' LIMIT 1");
  37.     }
  38.    
  39.     public static function CheckCookies()
  40.     {
  41.         if (LOGGED_IN)
  42.         {
  43.             return;
  44.         }
  45.    
  46.         if (isset($_COOKIE['rememberme']) && $_COOKIE['rememberme'] == "true" && isset($_COOKIE['rememberme_token']) && isset($_COOKIE['rememberme_name']))
  47.         {
  48.             $name = filter($_COOKIE['rememberme_name']);
  49.             $token = filter($_COOKIE['rememberme_token']);
  50.             $find = dbquery("SELECT id,username FROM users WHERE username = '" . $name . "' AND password = '" . $token . "' LIMIT 1");
  51.            
  52.             if (mysql_num_rows($find) > 0)
  53.             {
  54.                 $data = mysql_fetch_assoc($find);
  55.                
  56.                 $_SESSION['UBER_USER_N'] = $data['username'];
  57.                 $_SESSION['UBER_USER_H'] = $token;
  58.                 $_SESSION['set_cookies'] = true; // renew cookies
  59.                
  60.                 header("Location: " . WWW . "/security_check");
  61.                 exit;              
  62.             }
  63.         }
  64.     }
  65.    
  66.     public static function FormatDate()
  67.     {
  68.         return date('j F Y, h:i:s A');
  69.     }
  70.    
  71.     public function UberHash($input = '')
  72.     {
  73.         return md5($input);
  74.     }
  75.    
  76.     public static function GenerateTicket($seed = '')
  77.     {
  78.         $ticket = "ST-";
  79.         $ticket .= sha1($seed . 'Uber' . rand(118,283));
  80.         $ticket .= '-' . rand(100, 255);
  81.         $ticket .= '-uber-fe' . rand(0, 5);
  82.        
  83.         return $ticket;
  84.     }
  85.    
  86.     public static function FilterInputString($strInput = '')
  87.     {
  88.         return mysql_real_escape_string(stripslashes(trim($strInput)));
  89.     }
  90.    
  91.     public static function FilterSpecialChars($strInput, $allowLB = false)
  92.     {
  93.         $strInput = str_replace(chr(1), ' ', $strInput);
  94.         $strInput = str_replace(chr(2), ' ', $strInput);
  95.         $strInput = str_replace(chr(3), ' ', $strInput);
  96.         $strInput = str_replace(chr(9), ' ', $strInput);
  97.        
  98.         if (!$allowLB)
  99.         {
  100.             $strInput = str_replace(chr(13), ' ', $strInput);
  101.         }
  102.        
  103.         return $strInput;
  104.     }
  105.    
  106.     public static function CleanStringForOutput($strInput = '', $ignoreHtml = false, $nl2br = false)
  107.     {
  108.         $strInput = stripslashes(trim($strInput));
  109.  
  110.         if (!$ignoreHtml)
  111.         {
  112.             $strInput = htmlentities($strInput);
  113.         }
  114.        
  115.         if ($nl2br)
  116.         {
  117.             $strInput = nl2br($strInput);
  118.         }
  119.  
  120.         return $strInput;
  121.     }
  122.  
  123.     public static function SystemError($title, $text)
  124.     {
  125.         echo '<div style="width: 80%; padding: 15px 15px 15px 15px; margin: 50px auto; background-color: #F6CECE; font-family: arial; font-size: 12px; color: #000000; border: 1px solid #FF0000;">';
  126.         echo '<img src="' . WWW . '/images/error.png" style="float: left;" title="Error">&nbsp;';
  127.         echo '<b>' . $title. '</b><br />';
  128.         echo '&nbsp;' . $text;
  129.         echo '<hr size="1" style="width: 100%; margin: 15px 0px 15px 0px;" />';
  130.         echo 'Script execution was aborted. We apoligize for the possible inconvenience. If this problem is persistant, please contact an Administrator.';
  131.         echo '</div><center style="font-family: arial; font-size: 10px;">Powered by <a href="http://www.uberemu.info">uberEmu</a> - Copyright &copy 2009-2010, <a href="http://www.meth0d.org">Meth0d dot org</a>.</center>';
  132.         exit;      
  133.     }
  134.    
  135.     public function ParseConfig()
  136.     {
  137.         $configPath = INCLUDES . 'inc.config.php';
  138.        
  139.         if (!file_exists($configPath))
  140.         {
  141.             $this->systemError('Configuration Error', 'The configuration file could not be located at ' . $configPath);
  142.         }
  143.        
  144.         require_once $configPath;
  145.        
  146.         if (!isset($config) || count($config) < 2)
  147.         {
  148.             $this->systemError('Configuration Error', 'The configuration file was located, but is in an invalid format. Data is missing or in the wrong format.');
  149.         }
  150.        
  151.         $this->config = $config;
  152.        
  153.         define('WWW', $this->config['Site']['www']);
  154.     }
  155.    
  156.     public static function GetSystemStatusString($statsFig)
  157.     {
  158.         switch (uberCore::getSystemStatus())
  159.         {
  160.             case 2:
  161.             case 0:
  162.            
  163.                 return "0 Vizion's online!";
  164.                
  165.             case 1:
  166.            
  167.                 if (!$statsFig)
  168.                 {
  169.                     return uberCore::GetUsersOnline() . ' Vizion(s) online!';
  170.                 }
  171.                 else
  172.                 {
  173.                     return '<span class="stats-fig">' . uberCore::GetUsersOnline() . '</span> user(s) online!';
  174.                 }
  175.        
  176.             default:
  177.            
  178.                 return "Unknown";
  179.         }
  180.     }
  181.    
  182.     public static function GetSystemStatus()
  183.     {
  184.         return intval(mysql_result(dbquery("SELECT status FROM server_status LIMIT 1"), 0));
  185.     }
  186.    
  187.     public static function GetUsersOnline()
  188.     {
  189.         return intval(mysql_result(dbquery("SELECT count(*) FROM `users` WHERE `online` = '1'"), 0));
  190.     }
  191.    
  192.     public static function GetMaintenanceStatus()
  193.     {
  194.         return mysql_result(dbquery("SELECT maintenance FROM site_config LIMIT 1"), 0);
  195.     }
  196.    
  197.     public static function GetWebBuild()
  198.     {
  199.         return mysql_result(dbquery("SELECT web_build FROM site_config LIMIT 1"), 0);
  200.     }  
  201.    
  202.     public function Mus($header, $data = '')
  203.     {
  204.         if ($this->config['MUS']['enabled'] == false || $this->getSystemStatus() == "0")
  205.         {
  206.             return;
  207.         }
  208.        
  209.         $musData = $header . chr(1) . $data;
  210.        
  211.         $sock = @socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
  212.         @socket_connect($sock, $this->config['MUS']['ip'], intval($this->config['MUS']['port']));
  213.         @socket_send($sock, $musData, strlen($musData), MSG_DONTROUTE);
  214.         @socket_close($sock);
  215.     }
  216.    
  217.     public static function AddBan($type, $value, $reason, $expireTime, $addedBy, $blockAppeal)
  218.     {
  219.         dbquery("INSERT INTO bans (id,bantype,value,reason,expire,added_by,added_date,appeal_state) VALUES (NULL,'" . $type . "','" . $value . "','" . $reason . "','" . $expireTime . "','" . $addedBy . "','" . date('d/m/Y H:i') . "','" . (($blockAppeal) ? '0' : '1') . "')");
  220.     }
  221. }
  222.  
  223. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement