daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. if(!defined('RPG')) exit;
  3. class Config {
  4.  
  5.     private static $instance;
  6.     public static $_url;
  7.     public static $breadcrumb;
  8.     public static $data;
  9.     public static $categories;
  10.     public static $excluded;
  11.     public static $app_status;
  12.     public static $cp_status;
  13.     public static $cp_types;
  14.     public static $admr;
  15.     public static $options;
  16.  
  17.     public function __construct() {
  18.         if(defined('MAINTENANCE')) return;
  19.         DB::init();
  20.         User::init();
  21.         Arrays::init();
  22.     }
  23.    
  24.     public static function app()
  25.     {
  26.         $url = isset($_GET['page']) ? $_GET['page'] : null;
  27.         $url = rtrim($url, '/');
  28.         $url = filter_var($url, FILTER_SANITIZE_URL);
  29.         self::$_url = explode('/', $url);
  30.    
  31.         if (is_null(self::$instance))
  32.         {
  33.             self::$instance = new self();
  34.         }
  35.         return self::$instance;
  36.     }
  37.  
  38.     public static function run() {
  39.         // if(strpos($_SERVER['REQUEST_URI'],'/panel/') !== false) Redirect::to('');
  40.         if(self::$_url[0] === 'action' && isset(self::$_url[1]) && file_exists(ACTIONS_PATH . self::$_url[1] . '.a.php'))
  41.             { include ACTIONS_PATH . self::$_url[1] . '.a.php'; return; }
  42.        
  43.         if(defined('MAINTENANCE')) { include PAGES_PATH . 'maintenance.p.php'; return; }
  44.         include_once THEME_PATH . 'header.inc.php';
  45.         if(file_exists(PAGES_PATH . self::$_url[0] . '.p.php')) {
  46.             include PAGES_PATH . self::$_url[0] . '.p.php'; if(self::$_url[0] !== 'lang')
  47.             (!isset(self::$_url[1])) ? $_SESSION['page'] = self::$_url[0] : $_SESSION['page'] = self::$_url[0] . '/' . self::$_url[1];
  48.         } else {
  49.             include_once PAGES_PATH . 'index.p.php'; $_SESSION['page'] = ''; }
  50.         include_once THEME_PATH . 'footer.inc.php';
  51.     }
  52.    
  53.     public static function date($data,$reverse = false) {
  54.         return (!$reverse ? date('H:i:s d/m/Y',$data) : date('d/m/Y H:i:s',$data));
  55.     }
  56.    
  57.     public static function format($number) {
  58.         return number_format($number,0,'.','.');
  59.     }
  60.  
  61.     public static function getDate($timestamp,$time = false){
  62.         if(!$timestamp) return 1;
  63.         $difference = time() - $timestamp;
  64.         if($difference == 0)
  65.             return 'just now';
  66.         $periods = array("second", "minute", "hour", "day", "week",
  67.         "month", "year", "decade");
  68.         $lengths = array("60","60","24","7","4.35","12","10");
  69.         if ($difference > 0) {
  70.             $ending = "ago";
  71.         } else {
  72.             $difference = -$difference;
  73.             $ending = "to go";
  74.         }
  75.         if(!$difference) return 'just now';
  76.         for($j = 0; $difference >= $lengths[$j]; $j++)
  77.         $difference /= $lengths[$j];
  78.         $difference = round($difference);
  79.         if($difference != 1) $periods[$j].= "s";
  80.         if($time) $text = "$difference $periods[$j]";
  81.         else $text = "$difference $periods[$j] $ending";
  82.         return $text;
  83.     }
  84.    
  85.     public static function generateEmailId()
  86.     {
  87.         return sprintf(
  88.             "<%s.%s@%s>",
  89.             base_convert(microtime(), 10, 36),
  90.             base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
  91.             $_SERVER['SERVER_NAME']
  92.         );
  93.     }
  94.    
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top