Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!defined('RPG')) exit;
- class Config {
- private static $instance;
- public static $_url;
- public static $breadcrumb;
- public static $data;
- public static $categories;
- public static $excluded;
- public static $app_status;
- public static $cp_status;
- public static $cp_types;
- public static $admr;
- public static $options;
- public function __construct() {
- if(defined('MAINTENANCE')) return;
- DB::init();
- User::init();
- Arrays::init();
- }
- public static function app()
- {
- $url = isset($_GET['page']) ? $_GET['page'] : null;
- $url = rtrim($url, '/');
- $url = filter_var($url, FILTER_SANITIZE_URL);
- self::$_url = explode('/', $url);
- if (is_null(self::$instance))
- {
- self::$instance = new self();
- }
- return self::$instance;
- }
- public static function run() {
- // if(strpos($_SERVER['REQUEST_URI'],'/panel/') !== false) Redirect::to('');
- if(self::$_url[0] === 'action' && isset(self::$_url[1]) && file_exists(ACTIONS_PATH . self::$_url[1] . '.a.php'))
- { include ACTIONS_PATH . self::$_url[1] . '.a.php'; return; }
- if(defined('MAINTENANCE')) { include PAGES_PATH . 'maintenance.p.php'; return; }
- include_once THEME_PATH . 'header.inc.php';
- if(file_exists(PAGES_PATH . self::$_url[0] . '.p.php')) {
- include PAGES_PATH . self::$_url[0] . '.p.php'; if(self::$_url[0] !== 'lang')
- (!isset(self::$_url[1])) ? $_SESSION['page'] = self::$_url[0] : $_SESSION['page'] = self::$_url[0] . '/' . self::$_url[1];
- } else {
- include_once PAGES_PATH . 'index.p.php'; $_SESSION['page'] = ''; }
- include_once THEME_PATH . 'footer.inc.php';
- }
- public static function date($data,$reverse = false) {
- return (!$reverse ? date('H:i:s d/m/Y',$data) : date('d/m/Y H:i:s',$data));
- }
- public static function format($number) {
- return number_format($number,0,'.','.');
- }
- public static function getDate($timestamp,$time = false){
- if(!$timestamp) return 1;
- $difference = time() - $timestamp;
- if($difference == 0)
- return 'just now';
- $periods = array("second", "minute", "hour", "day", "week",
- "month", "year", "decade");
- $lengths = array("60","60","24","7","4.35","12","10");
- if ($difference > 0) {
- $ending = "ago";
- } else {
- $difference = -$difference;
- $ending = "to go";
- }
- if(!$difference) return 'just now';
- for($j = 0; $difference >= $lengths[$j]; $j++)
- $difference /= $lengths[$j];
- $difference = round($difference);
- if($difference != 1) $periods[$j].= "s";
- if($time) $text = "$difference $periods[$j]";
- else $text = "$difference $periods[$j] $ending";
- return $text;
- }
- public static function generateEmailId()
- {
- return sprintf(
- "<%s.%s@%s>",
- base_convert(microtime(), 10, 36),
- base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
- $_SERVER['SERVER_NAME']
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement