Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- date_default_timezone_set('Australia/Melbourne');
- ini_set("display_errors", "on");
- error_reporting(E_ALL);
- new core();
- class core
- {
- public $userid, $configured = False, $mysql = Null, $config = False, $auth = False;
- public function __construct()
- {
- session_start();
- $GLOBALS["core"] = &$this;
- $this->dir = __DIR__ . DIRECTORY_SEPARATOR;
- $this->root = str_replace(array('\', '/'), DIRECTORY_SEPARATOR, $_SERVER["DOCUMENT_ROOT"]) . DIRECTORY_SEPARATOR;
- $this->ds = DIRECTORY_SEPARATOR; /* Cause I get sick of typing "DIRECTORY_SEPARATOR" */
- $this->userip = isset($_SERVER["HTTP_CF_CONNECTING_IP"]) ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"];
- @include_once $this->dir . "_config.php";
- require_once $this->dir . "_pdo.php";
- $this->config = (object) array();
- if(isset($config))
- {
- $this->config = (object) $config;
- $this->mysql = new Database($this->config->sql->host, $this->config->sql->user, $this->config->sql->pass, $this->config->sql->name);
- $this->page = isset($_GET["page"]) && is_string($_GET["page"]) ? strtolower($_GET["page"]) : "home";
- $this->parse_page();
- $this->pc = trim(ob_get_contents());
- $this->pc = utf8_encode($this->pc);
- ob_clean();
- }
- public function auth()
- {
- if(empty($_SESSION) && empty($_COOKIE))
- {
- return False;
- }
- if(empty($_SESSION) && !empty($_COOKIE[md5($this->userip)]))
- {
- $cookie = explode(chr(0), $_COOKIE[md5($this->userip)]);
- $cookie = array_map(array($this->mysql, 'decrypt'), $cookie);
- if(count($cookie) == 2 && $cookie[0] != false && $cookie[1] != false)
- {
- $_SESSION["user"] = $cookie[0];
- $_SESSION["pass"] = $cookie[1];
- }
- }
- if(empty($_SESSION["user"]))
- {
- return false;
- }
- $user = $this->mysql->fetch_array("select * from `users` where `username`='{$this->mysql->sanatize($_SESSION["user"])}';");
- if(empty($user))
- {
- session_destroy();
- setcookie(md5($this->userip), null, time() - 86400);
- exit(header("Location: /ixat/home"));
- } else {
- $_SESSION["id"] = $this->userid = $user[0]["id"];
- }
- return isset($_SESSION["id"]) ? true : false;
- }
- public function parse_page()
- {
- $this->pages = glob($this->root . "_pages" . $this->ds . "*.php");
- $this->pages = array_map(function($x)
- {
- return strtolower(substr($x, strrpos($x, DIRECTORY_SEPARATOR) + 1, -4));
- }, $this->pages);
- if(!in_array($this->page, $this->pages))
- {
- $embed = $this->getEmbed($this->page);
- if($embed !== false)
- {
- return print "<h2 class=\"nopadding nomargin\"> {$this->page} </h2> <hr class=\"nopadding nomargin\" /> <br /> <div class=\"center\">{$embed}</div>";
- } else {
- $this->page = "home";
- }
- }
- $core = &$this;
- require_once "{$this->root}ixat/_pages{$this->ds}{$this->page}.php";
- }
- public function getEmbed($chat, $pass = false)
- {
- $chat = $this->mysql->fetch_array("select * from `chats` where `name`='{$this->mysql->sanatize($chat)}' or `id`='{$this->mysql->sanatize($chat)}';");
- if($pass !== false)
- {
- $pass = "&pass=" . urlencode($pass);
- }
- return empty($chat) ? false : "<div class=\"panel panel-default\"><div class=\"panel-heading\"><h3 class=\"panel-title\"><b><font color=\"black\">{$chat[0]["name"]}</font></b></h3></div><br /><div class=\"panel-body\"><embed id=\"XenoBox\" width=\"730\" height=\"490\" type=\"application/x-shockwave-flash\" quality=\"high\" src=\"http://{$_SERVER["SERVER_NAME"]}/static/static.php?c=chat.swf&d=flash&id={$chat[0]["id"]}&gn={$chat[0]["name"]}{$pass}\" flashvars=\"id={$chat[0]["id"]}&gn={$chat[0]["name"]}{$pass}\" wmode=\"transparent\"></div></div>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement