Esempio n. 1
0
 public static function init()
 {
     if (self::$hasinit) {
         return false;
     }
     // Load configuration.
     self::$config = new Config('realms.ini');
     if (!self::$config->get('general', 'service_requests')) {
         // Service unavaliable. :(
         http_response_code(503);
         // 503 Service Unavaliable.
         echo 'service unavaliable';
         exit;
         // terminate here.
     }
     // Load request registry
     self::$requestRegistry = new RequestRegistry();
     // create request registry instance
     // Dynamically load request handlers.
     $handler_files = scandir('inc/Requests');
     foreach ($handler_files as $handler_file) {
         if ($handler_file == '.' || $handler_file == '..') {
             continue;
         }
         // skip ghost files
         // Load PHP file
         require 'inc/Requests/' . $handler_file;
         // Register handler
         $classname = pathinfo($handler_file, PATHINFO_FILENAME);
         self::$requestRegistry->register(new $classname());
     }
     // Realms init finish.
     self::$hasinit = true;
     return true;
 }
Esempio n. 2
0
 public static function GetAllRealms()
 {
     $Statement = Realms::$AConnection->prepare('SELECT id, name, address, port, icon, flag, timezone, population, gamebuild FROM realmlist');
     $Statement->execute();
     $Result = $Statement->fetchAll(PDO::FETCH_ASSOC);
     $Index = 0;
     foreach ($Result as $Server) {
         $CheckConnection = @fsockopen($Server['address'], $Server['port'], $errno, $errstr, 0.5);
         if ($CheckConnection) {
             $Result[$Index]['status'] = "up";
         } else {
             $Result[$Index]['status'] = "down";
         }
         $Result[$Index]['type'] = Realms::RealmTypeByID($Server['icon']);
         $Result[$Index]['language'] = Realms::LanguageByID($Server['timezone']);
         $Result[$Index]['uptime'] = Realms::GetUptimeForRealm($Server['id']);
         $Result[$Index]['online'] = Realms::GetOnlineForRealm($Server['id']);
         $Index++;
     }
     return $Result;
 }
Esempio n. 3
0
             $Smarty->assign('Articles', News::GetAllNews());
             $Smarty->assign('Article', $Article);
             $Smarty->assign('Page', Page::Info('blog', array('bodycss' => 'blog-article news', 'pagetitle' => $Article['title'] . ' - ')));
             $Smarty->display('blog');
         }
     }
     break;
 case 'community':
     if (Text::IsNull($_REQUEST['subcategory'])) {
         $Smarty->assign('Page', Page::Info('community', array('bodycss' => 'community-home', 'pagetitle' => $Smarty->GetConfigVars('Menu_Community') . ' - ')));
         $Smarty->display('community');
     } else {
         switch ($_REQUEST['subcategory']) {
             case 'status':
                 Manager::LoadExtension('Realms', $ClassConstructor);
                 $Smarty->assign('Realms', Realms::GetAllRealms());
                 $Smarty->assign('Page', Page::Info('community', array('bodycss' => 'realm-status', 'pagetitle' => $Smarty->GetConfigVars('Menu_Community') . ' - ')));
                 $Smarty->display('pages/community_status');
                 break;
         }
     }
     break;
 case 'discussion':
     Manager::LoadExtension('News', $ClassConstructor);
     if (Text::IsNull($_REQUEST['subcategory'])) {
         header('Location: /');
     } else {
         $ExplodeCategory = explode('.', $_REQUEST['subcategory']);
         $Language = $ExplodeCategory[0];
         $Category = $ExplodeCategory[1];
         $SearchFor = $ExplodeCategory[2];
Esempio n. 4
0
 * Handles incoming API requests.
 */
/**
 * Dynamic loading of classes.
 * @param string $classname
 */
function __autoload($classname)
{
    if (file_exists('inc/' . $classname . '.php')) {
        include 'inc/' . $classname . '.php';
    } elseif (file_exists('inc/Requests/' . $classname . '.php')) {
        include 'inc/Requests/' . $classname . '.php';
    }
}
require_once 'inc/Realms.php';
Realms::init();
// initilize Realms.
// Sent our footprint.
header('X-Powered-By: Realms ' . Realms::VERSION . ' http://github.com/mitchfizz05/Realms');
// Find the client session if applicable.
$session = new Session();
if (isset($_COOKIE['sid'], $_COOKIE['user'], $_COOKIE['version'])) {
    // Everything passed in.
    file_put_contents('user.txt', $_COOKIE['user'] . '_' . $_COOKIE['sid']);
}
// Handle request.
$requestpath = '/' . $_GET['path'];
$request = new HTTPRequest($requestpath, apache_request_headers());
// create http request object
$resp = Realms::$requestRegistry->handle($request);
if ($resp === null) {
Esempio n. 5
0
 function get_access_realms() {
     $levels = $this->get_access_levels();
     $realms = array();
     foreach ($levels as $level) {
         if ($level->gmlevel >= Environment::get_value('min_gm_level', 'access')) {
             if ($level->realmid == -1) {
                 $realms = Realm::find()->available()->all();
                 break;
             } else {
                 $realms = Realms::find()->where(array('realmid' => $level->realmid))->first();
             }
         }
     }
     return $realms;
 }