Example #1
0
 static function render($viewName)
 {
     $viewName = str_replace('\\', DIRECTORY_SEPARATOR, $viewName);
     if (!self::exists($viewName)) {
         throw new ViewNotFoundException('View not found: ' . $viewName);
     }
     // Add some useful vars to the response
     $config = \ManiaLib\Application\Config::getInstance();
     $session = \ManiaLib\Application\Session::getInstance();
     $response = \ManiaLib\Application\Response::getInstance();
     $tracking = \ManiaLib\Application\Tracking\Config::getInstance();
     $response->login = $session->login;
     $response->mediaURL = $config->getMediaURL();
     $response->appURL = $config->getLinkCreationURL();
     $response->baseURL = $config->URL;
     $response->trackingAccount = $tracking->account;
     $vars = \ManiaLib\Application\Response::getInstance()->getAll();
     extract($vars);
     error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
     if (file_exists(MANIALIB_APP_PATH . 'resources/' . $viewName . '.php')) {
         require MANIALIB_APP_PATH . 'resources/' . $viewName . '.php';
     } else {
         require MANIALIB_APP_PATH . 'ressources/' . $viewName . '.php';
     }
     error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
 }
Example #2
0
 /**
  * Loads the Manialink GUI toolkit. This should be called before doing
  * anything with the toolkit.
  * @param bool Whether you want to create the root "<manialink>" element in the XML
  */
 public static final function load($root = true, $timeout = 0, $version = 1, $background = self::DEFAULT_BACKGROUND, $navigable3d = false)
 {
     if (class_exists('\\ManiaLib\\Application\\Config')) {
         $config = \ManiaLib\Application\Config::getInstance();
         self::$langsURL = $config->getLangsURL();
         self::$imagesURL = $config->getImagesURL();
         self::$mediaURL = $config->getMediaURL();
     }
     // Load the XML object
     self::$domDocument = new \DOMDocument('1.0', 'utf-8');
     self::$parentNodes = array();
     self::$parentLayouts = array();
     self::$parentFrames = array();
     if ($root) {
         $nodeManialink = self::$domDocument->createElement('manialink');
         $nodeManialink->setAttribute('version', $version);
         $nodeManialink->setAttribute('background', $background);
         $nodeManialink->setAttribute('navigable3d', (int) $navigable3d);
         self::$domDocument->appendChild($nodeManialink);
         self::$parentNodes[] = $nodeManialink;
         $nodeTimeout = self::$domDocument->createElement('timeout');
         $nodeManialink->appendChild($nodeTimeout);
         $nodeTimeout->nodeValue = $timeout;
     } else {
         $frame = self::$domDocument->createElement('frame');
         self::$domDocument->appendChild($frame);
         self::$parentNodes[] = $frame;
     }
 }
 /**
  * In the class the constructor is a bit different: there is a 3rd param to
  * specify the Manialink from which the notifications are sent.
  *
  * IMPORTANT NOTE:
  *
  * If you are sending many notifications, please use the $group variable
  * See http://maniapla.net/maniahome-group
  *
  * The API username must be allowed to post notifications for the Manialink!
  * If you're the Manialink owner, go in ManiaHome's Manager to the "API user"
  * page to set it.
  *
  * @param string $username
  * @param string $password
  * @param string $manialink
  */
 function __construct($username = null, $password = null, $manialink = null)
 {
     parent::__construct($username, $password);
     // If you're using ManiaLib, credentials can be automatically loaded
     if (!$manialink && class_exists('\\ManiaLib\\Application\\Config')) {
         $config = \ManiaLib\Application\Config::getInstance();
         $manialink = $config->manialink;
     }
     $this->manialink = $manialink;
 }
 /**
  * @deprecated since version 3.1.0
  */
 function __construct($username = null, $password = null, $manialink = null)
 {
     // If you're using ManiaLib, credentials can be automatically loaded
     if (!$manialink && class_exists('\\ManiaLib\\Application\\Config')) {
         $config = \ManiaLib\Application\Config::getInstance();
         $manialink = $config->manialink;
     }
     $this->username = $username;
     $this->password = $password;
     $this->manialinkPublisher = new ManiaHome\ManialinkPublisher($username, $password, $manialink);
 }
Example #5
0
 static function rawMap(\Maniaplanet\DedicatedServer\Structures\Map $map, $name = 'maps[]', $checked = false, $withThumbnail = true, $disabled = false, $readonly = false)
 {
     $id = uniqid('maps-', true);
     $str = sprintf('<input type="checkbox" id="%s" name="%s" value="%s"%s%s%s/>', $id, $name, htmlentities($map->fileName, ENT_QUOTES, 'utf-8'), $checked ? ' checked="checked"' : '', $disabled ? ' disabled="disabled"' : '', $readonly ? ' class="readonly-checkbox"' : '');
     $label = sprintf(_('%s by %s'), StyleParser::toHtml($map->name), $map->author);
     if ($withThumbnail) {
         $str .= sprintf('<label for="%s">' . '<img src="%s" class="map-thumbnail" alt="thumbnail"/>' . '<span>%s</span>' . '</label>', $id, Config::getInstance()->getImagesURL() . 'thumbnails/' . $map->uId . '.jpg', $label);
     } else {
         $str .= sprintf('<label for="%s">%s</label>', $id, $label);
     }
     return $str;
 }
Example #6
0
 function display()
 {
     parent::display();
     $config = \ManiaHost\Config::getInstance();
     if (static::$showBackground) {
         $ui = new Quad(320, 180);
         $ui->setAlign('center', 'center');
         $ui->setImage($config->background, true);
         $ui->setPosZ(-3);
         $ui->save();
     }
     $ui = new \ManiaLib\Gui\Elements\IncludeManialink();
     $ui->setUrl('manialib.xml', false);
     $ui->save();
     Manialink::beginFrame(110, -81, 0.1);
     $ui = new \ManiaLib\Gui\Elements\IncludeManialink();
     $query = array();
     $query['url'] = \ManiaLib\Application\Config::getInstance()->manialink;
     $query['name'] = $config->appName;
     $ui->setUrl('http://maniahome.maniaplanet.com/add/?' . http_build_query($query, '', '&'));
     $ui->save();
     Manialink::endFrame();
 }
Example #7
0
 protected function createLinkString($route = '', $params = array())
 {
     // Current pages
     if (!$route || $route == '.') {
         $controller = $this->getController();
         $action = $this->getAction(null);
     } elseif ($route == '/') {
         $controller = null;
         $action = null;
     } elseif ($route == '..' || $route == '../') {
         $controller = $this->getController();
         $action = null;
     } else {
         // Absolute route
         if (substr($route, 0, 1) == '/') {
             list($controller, $action) = Route::getActionAndControllerFromRoute($route);
         } elseif (strlen($route) > 3 && substr($route, 0, 3) == '../') {
             $_route = substr($route, 3);
             if (substr($_route, -1, 1) == '/') {
                 $_route = substr($_route, 0, -1);
             }
             $controller = $this->getController();
             $action = $_route;
         } else {
             throw new Exception('Request link: syntax error');
         }
     }
     $config = Config::getInstance();
     if ($controller == $config->defaultController && !$action) {
         $controller = null;
     }
     $url = $config->getLinkCreationURL();
     $url .= Route::computeRoute($controller, $action);
     $addSid = $config->sessionUseURL && defined('SID') && SID && !array_key_exists(Session::NAME, $_COOKIE);
     $sid = $addSid ? htmlspecialchars(SID) : '';
     $queryString = http_build_query($params, '', '&');
     return $url . ($sid || $queryString ? '?' : '') . $sid . ($sid ? '&' : '') . $queryString . ($this->fragment ? '#' . $this->fragment : '');
 }
Example #8
0
 function preFilter()
 {
     if (!Config::getInstance()->debug) {
         if (!UserAgent::isManiaPlanet()) {
             call_user_func(self::$callback);
         }
     }
 }
Example #9
0
<?php

define('DEDICATED_MANAGER_VERSION', '2.1.1');
require_once __DIR__ . '/../libraries/autoload.php';
I18n\Functions::LOAD;
\ManiaLib\Application\Config::getInstance()->URL = 'http://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . '/manager/';
\ManiaLib\Application\Bootstrapper::$errorReporting = E_ALL ^ E_DEPRECATED;
\ManiaLib\Application\Bootstrapper::run();
Example #10
0
 /**
  * Fallback exception handler when nothing works. It tries to dump the 
  * exception in a file at the app root and prints a message.
  */
 static function fatalExceptionHandler(\Exception $exception)
 {
     throw $exception;
     file_put_contents(MANIALIB_APP_PATH . 'fatal-error.log', print_r($exception, true), FILE_APPEND);
     if (array_key_exists('HTTP_USER_AGENT', $_SERVER) && $_SERVER['HTTP_USER_AGENT'] == 'GameBox') {
         echo '<manialink><timeout>0</timeout><label text="Fatal error." /></manialink>';
     } else {
         echo '<h1>Oops</h1>';
         echo '<p>An error occured. Please try again later.</p>';
         echo '<hr />';
         if (\ManiaLib\Application\Config::getInstance()->debug) {
             var_dump($exception);
         }
     }
 }
 protected function saveConfiguration(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>Saving your configuration in app.ini file</info>');
     $applicationConfig = ApplicationConfig::getInstance();
     $dedicatedManagerConfig = DedicatedManagerConfig::getInstance();
     $webServicesConfig = WSConfig::getInstance();
     $databaseConfig = DatabaseConfig::getInstance();
     $config = "application.namespace = DedicatedManager\n";
     $config .= "application.webapp = true\n";
     $config .= sprintf("application.URL = '%s'\n", $applicationConfig->URL . '/');
     $config .= "DedicatedManager\\Config.maniaConnect = On\n";
     $config .= sprintf("DedicatedManager\\Config.dedicatedPath = '%s'\n", $dedicatedManagerConfig->dedicatedPath . '/');
     foreach ($dedicatedManagerConfig->admins as $admin) {
         $config .= sprintf("DedicatedManager\\Config.admins[] = %s\n", $admin);
     }
     $config .= sprintf("webservices.username = '******'\n", $webServicesConfig->username);
     $config .= sprintf("webservices.password = '******'\n", $webServicesConfig->password);
     $config .= sprintf("database.host = '%s'\n", $databaseConfig->host);
     $config .= sprintf("database.user = '******'\n", $databaseConfig->user);
     $config .= sprintf("database.password = '******'\n", $databaseConfig->password);
     $config .= sprintf("database.database = '%s'\n", $databaseConfig->database);
     $config .= "database.slowQueryLog = true\n";
     file_put_contents('./config/app.ini', $config);
     $output->writeln('<success>Your Dedicated manager is successfully configured</success>');
     $output->writeln(sprintf('<success>You can now access to: %s</success>', $applicationConfig->URL));
 }
Example #12
0
 function checkoutExtend($idRent, $hours = 0, $days = 0)
 {
     if ($hours < 0 || $days < 0 || $hours + $days == 0) {
         throw new \ManiaLib\Application\UserException('You have to enter a positive duration');
     }
     $duration = $hours + 24 * $days;
     $transactionService = new \ManiaHost\Services\TransactionService();
     $transaction = $transactionService->create($this->session->login, $duration * \ManiaHost\Config::getInstance()->hourlyCost);
     $query = array();
     $query['ml-forcepathinfo'] = '/rent/pay-extend/';
     if ($transaction->id) {
         $query['transaction'] = $transaction->id;
     }
     \ManiaLib\Utils\Logger::info((int) $idRent);
     $query['idRent'] = $idRent;
     $query['duration'] = $duration;
     $this->session->set('transaction-' . $this->session->login, $transaction);
     $queryString = http_build_query($query);
     $url = \ManiaLib\Application\Config::getInstance()->manialink . '?' . $queryString;
     $this->request->redirectAbsolute($url);
 }