Exemplo n.º 1
0
 function joinServer()
 {
     $server = new server($this->id);
     if ($this->isServerJoinable($this->id)) {
         echo '<a href="' . $server->getUrl() . '">Join server</a>';
     }
 }
Exemplo n.º 2
0
 /**
  * server() returns an instance of Leafo\ScssPhp\Server, constructing it if
  * necessary.
  *
  * If you provide an instance of Server as argument, it uses that instead.
  *
  * @return Server
  */
 public static function server($instance = null)
 {
     if ($instance !== null) {
         static::$scss_server = $instance;
     } elseif (static::$scss_server === null) {
         include __DIR__ . '/../vendor/autoload.php';
         static::$scss_server = new Server(dirname(craft()->request->getScriptFile()), dirname(craft()->request->getScriptFile()) . '/writable/scss_cache');
         static::$scss_server->showErrorsAsCSS();
     }
     return static::$scss_server;
 }
Exemplo n.º 3
0
 /**
  * server() returns an instance of Leafo\ScssPhp\Server, constructing it if
  * necessary.
  *
  * If you provide an instance of Server as argument, it uses that instead.
  *
  * @return Server
  */
 public static function server($instance = null)
 {
     if ($instance !== null) {
         static::$scss_server = $instance;
     } elseif (static::$scss_server === null) {
         $sass_cache_dir = craft()->path->getStoragePath() . '/scss_cache';
         IOHelper::ensureFolderExists($sass_cache_dir);
         static::$scss_server = new Server(dirname(craft()->request->getScriptFile()), $sass_cache_dir);
         static::$scss_server->showErrorsAsCSS();
     }
     return static::$scss_server;
 }
 public function prepare()
 {
     $this->template = "server";
     $this->tab = 'server';
     require_once 'classes/server.php';
     $server = new server($this->request[0]);
     $this->params['image'] = $server->get_map_image();
     $this->params['info'] = $server->info;
     $this->params['map_list'] = $server->get_map_list();
     $this->params['rule_list'] = $server->get_rule_list();
     $this->title = htmlspecialchars($this->params['info']['name']);
 }
Exemplo n.º 5
0
 function getdata()
 {
     $newconnection = new server();
     $newconnection->makeConnection();
     $result = $newconnection->fireQuery();
     $newconnection->closeConnection();
     $arrayindex = 0;
     while ($row = $result->fetch_assoc()) {
         $this->result[$arrayindex] = array($row['id'], $row['username'], $row['first_name']);
         $arrayindex += 1;
     }
 }
Exemplo n.º 6
0
 /**
  * @param $phone
  * @param $msg
  * @return mixed
  */
 public function send($phone, $msg)
 {
     try {
         $provider = $this->_providerMap[$this->provider];
         $this->_server = new $provider['class']($provider['url'], $provider['key']);
         if ($this->_server->send($phone, $msg)) {
             return ['code' => 1, 'msg' => '短信发送成功'];
         }
     } catch (Exception $e) {
         return ['code' => 0, 'msg' => $e->getMessage()];
     }
     return ['code' => 0, 'msg' => '短信发送失败'];
 }
Exemplo n.º 7
0
 public static function revive($guid, $char_db)
 {
     $guid = (int) $guid;
     $rid = server::getRealmId($char_db);
     connect::connectToRealmDB($rid);
     if (character::isOnline($guid) == TRUE) {
         echo '<b class="red_text">Please log out your character before proceeding.';
     } else {
         if ($GLOBALS['service']['revive']['currency'] == 'vp') {
             if (account::hasVP($_SESSION['cw_user'], $GLOBALS['service']['unstuck']['price']) == FALSE) {
                 die('<b class="red_text">Not enough Vote Points!</b>');
             } else {
                 account::deductVP(account::getAccountID($_SESSION['cw_user']), $GLOBALS['service']['revive']['price']);
             }
         }
         if ($GLOBALS['service']['revive']['currency'] == 'dp') {
             if (account::hasDP($_SESSION['cw_user'], $GLOBALS['service']['unstuck']['price']) == FALSE) {
                 die('<b class="red_text">Not enough ' . $GLOBALS['donation']['coins_name'] . '</b>');
             } else {
                 account::deductDP(account::getAccountID($_SESSION['cw_user']), $GLOBALS['service']['revive']['price']);
             }
         }
         mysql_query("DELETE FROM character_aura WHERE guid = '" . $guid . "' AND spell = '20584' OR guid = '" . $guid . "' AND spell = '8326'");
         account::logThis("Performed a revive on " . character::getCharName($guid, $rid), 'Revive', $rid);
         return TRUE;
     }
 }
Exemplo n.º 8
0
 /**
  * Returns the current url with all bells and whistles
  *
  * @return string
  */
 public static function current()
 {
     if (!is_null(static::$current)) {
         return static::$current;
     }
     return static::$current = static::scheme() . '://' . server::get('HTTP_HOST') . server::get('REQUEST_URI');
 }
Exemplo n.º 9
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$dbh->config("delacc")) {
         die('This feature has been disabled.');
     } else {
         if ($_POST) {
             $user = $_SESSION['cuser'];
             $pass = $postvar['password'];
             $client = $dbh->client($user);
             unset($where);
             $where[] = array("is_paid", "=", "0", "AND");
             $where[] = array("uid", "=", $user);
             $balance_query = $dbh->select("invoices", $where, 0, "1", 1);
             if ($dbh->num_rows($balance_query) != 0) {
                 main::errors("You can't close your account with an outstanding balance.  Please contact an administrator for assistance or pay any unpaid invoices.");
             }
             if (crypto::passhash($pass, $client['salt']) == $client['password']) {
                 if (server::terminate($client['id'], "", 1)) {
                     main::errors("Your account has been cancelled successfully.");
                     session_destroy();
                 } else {
                     main::errors("Your account wasn't cancelled.  Please try again or contact your system administrator.");
                 }
             } else {
                 main::errors("The password entered is incorrect.");
             }
         }
         echo style::replaceVar("tpl/client/delete-account.tpl");
     }
 }
Exemplo n.º 10
0
 function __construct()
 {
     s::start();
     c::set('home.keepurl', true);
     // auto-detect the url if it is not set
     if (!c::get('url')) {
         c::set('url', c::get('scheme') . server::get('http_host'));
     }
     // setup the thumb plugin
     c::set('thumb.cache.root', c::get('root') . '/thumbs');
     c::set('thumb.cache.url', c::get('url') . '/thumbs');
     c::set('url', c::get('url') . '/' . c::get('panel.folder'));
     // remove the panel folder name from the uri
     c::set('subfolder', ltrim(c::get('subfolder') . '/' . c::get('panel.folder'), '/'));
     // attach the uri after caching
     $this->uri = new paneluri();
     if (c::get('lang.support')) {
         $path = $this->uri->path->toArray();
         $first = array_shift($path);
         if (!in_array($first, c::get('lang.available', array()))) {
             $first = c::get('lang.default');
         }
         // set the current language
         c::set('lang.current', $first);
         $this->uri->path = new uriPath($path);
     }
     // get the first set of pages
     $this->rootPages();
     // get the additional site info from content/site.txt
     $this->siteInfo();
 }
Exemplo n.º 11
0
 function raw($uri = false)
 {
     $raw = $uri ? $uri : ltrim(server::get('request_uri'), '/');
     // strip subfolders from uri
     if (c::get('subfolder')) {
         $raw = ltrim(str_replace(c::get('subfolder') . '/', '/', $raw), '/');
     }
     return $raw;
 }
Exemplo n.º 12
0
 static function raw($uri = false)
 {
     $raw = $uri ? $uri : ltrim(server::get('request_uri'), '/');
     // strip subfolders from uri
     if (c::get('subfolder')) {
         $raw = ltrim(preg_replace('!^' . preg_quote(c::get('subfolder')) . '\\/!i', '/', $raw), '/');
     }
     return $raw;
 }
Exemplo n.º 13
0
 public function set_paid($iid, $noemail = 0)
 {
     global $dbh, $postvar, $getvar, $instance;
     $invoices_update = array("datepaid" => time(), "is_paid" => "1");
     $response = $dbh->update("invoices", $invoices_update, array("id", "=", $iid));
     $invoices_data = $dbh->select("invoices", array("id", "=", $iid), 0, "1");
     server::unsuspend($invoices_data['uid'], $noemail);
     return $response;
 }
Exemplo n.º 14
0
 static function config()
 {
     parent::config();
     // load the default panel config file
     self::file(c::get('root.panel') . '/defaults/config/config.php');
     $root = c::get('root.site') . '/' . c::get('panel.folder') . '/config';
     self::file($root . '/config.php');
     self::file($root . '/config.' . server::get('server_name') . '.php');
 }
Exemplo n.º 15
0
 public function configure()
 {
     // load all available config files
     $root = $this->roots()->config();
     $configs = array('main' => 'config.php', 'host' => 'config.' . server::get('SERVER_NAME') . '.php', 'addr' => 'config.' . server::get('SERVER_ADDR') . '.php');
     $allowed = array_filter(dir::read($root), function ($file) {
         return substr($file, 0, 7) === 'config.' and substr($file, -4) === '.php';
     });
     foreach ($configs as $config) {
         $file = $root . DS . $config;
         if (in_array($config, $allowed, true) and file_exists($file)) {
             include_once $file;
         }
     }
     // apply the options
     $this->options = array_merge($this->options, c::$data);
     // overwrite the autodetected url
     if ($this->options['url']) {
         $this->urls->index = $this->options['url'];
     }
     // connect the url class with its handlers
     url::$home = $this->urls()->index();
     url::$to = $this->option('url.to', function ($url = '') {
         if (url::isAbsolute($url)) {
             return $url;
         }
         $start = substr($url, 0, 1);
         switch ($start) {
             case '#':
                 return $url;
                 break;
             case '.':
                 return page()->url() . '/' . $url;
                 break;
             default:
                 // don't convert absolute urls
                 return url::makeAbsolute($url);
                 break;
         }
     });
     // setup the thumbnail generator
     thumb::$defaults['root'] = $this->roots->thumbs();
     thumb::$defaults['url'] = $this->urls->thumbs();
     thumb::$defaults['driver'] = $this->option('thumbs.driver');
     thumb::$defaults['filename'] = $this->option('thumbs.filename');
     // simple error handling
     if ($this->options['debug'] === true) {
         error_reporting(E_ALL);
         ini_set('display_errors', 1);
     } else {
         if ($this->options['debug'] === false) {
             error_reporting(0);
             ini_set('display_errors', 0);
         }
     }
 }
Exemplo n.º 16
0
 public function serverhasrestore($servertype)
 {
     global $dbh, $postvar, $getvar, $instance;
     $restoreserver = server::createServer(0, $servertype);
     if (method_exists($restoreserver, "restore")) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 17
0
 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     if (r::cli()) {
         return $this->index = '/';
     } else {
         return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
 }
Exemplo n.º 18
0
 public function index($text = null, $exception = null)
 {
     $this->auth();
     if (is_null($text)) {
         $text = l('pages.error.missing');
     }
     if (server::get('HTTP_MODAL')) {
         return $this->modal('error', array('text' => $text, 'back' => url::last()));
     } else {
         return $this->screen('error/index', 'error', array('text' => $text, 'exception' => $exception));
     }
 }
Exemplo n.º 19
0
 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     // this value is used by the Panel
     $this->indexDetected = true;
     if (r::cli()) {
         return $this->index = '/';
     } else {
         return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
 }
Exemplo n.º 20
0
 private static function load_config()
 {
     $config = snarf_scope(SERVER_ROOT . '/config.php');
     $config['address'] = $address = getArg('a', 'address', get($config, 'ip', '0.0.0.0'));
     $port = get($config, 'port', 10000);
     if (strpos($address, ':') !== false) {
         $parts = explode(':', $address);
         $address = $parts[0];
         $port = (int) $parts[1];
     }
     $config['port'] = getArg('p', 'port', $port);
     self::$config = $config;
 }
Exemplo n.º 21
0
 function __construct($uri = false)
 {
     // set the defaults
     $this->path = new uriPath();
     $this->params = new uriParams();
     $this->query = new uriQuery(str::parse(server::get('query_string'), 'query'));
     $this->extension = false;
     $this->original = $_SERVER['REQUEST_URI'];
     $this->raw = $this->raw($uri);
     $this->url = url(ltrim($this->raw, '/'));
     // crawl the uri and get all elements
     $this->crawl();
 }
Exemplo n.º 22
0
 public function testSanitization()
 {
     $_SERVER['HTTP_HOST'] = '<script>alert("xss")</script>';
     $_SERVER['SERVER_NAME'] = '<script>alert("xss")</script>';
     $this->assertEquals('alertxss', server::get('HTTP_HOST'));
     $this->assertEquals('alertxss', server::get('SERVER_NAME'));
     $_SERVER['HTTP_HOST'] = '127.0.0.1';
     $_SERVER['SERVER_NAME'] = '127.0.0.1';
     $this->assertEquals('127.0.0.1', server::get('HTTP_HOST'));
     $this->assertEquals('127.0.0.1', server::get('SERVER_NAME'));
     $_SERVER['SERVER_PORT'] = '<script>alert("xss")</script>999';
     $this->assertEquals('999', server::get('SERVER_PORT'));
 }
Exemplo n.º 23
0
 public static function configure()
 {
     if (is_null(static::$site)) {
         static::$site = kirby::panelsetup();
     }
     // load all available routes
     static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'api.php');
     static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'views.php');
     // setup the blueprint root
     blueprint::$root = c::get('root.site') . DS . 'blueprints';
     // start the router
     static::$router = new Router();
     static::$router->register(static::$routes);
     // content language switcher variable
     if (static::$site->multilang()) {
         if ($language = server::get('http_language') or $language = s::get('lang')) {
             static::$site->visit('/', $language);
         }
         app::$language = static::$site->language()->code();
         s::set('lang', app::$language);
     }
     // load the interface language file
     if (static::$site->user()) {
         $languageCode = static::$site->user()->language();
     } else {
         $languageCode = c::get('panel.language', 'en');
     }
     // validate the language code
     if (!in_array($languageCode, static::languages()->keys())) {
         $languageCode = 'en';
     }
     // store the interface language
     app::$interfaceLanguage = $languageCode;
     $language = (require root('panel.app.languages') . DS . $languageCode . '.php');
     // set all language variables
     l::$data = $language['data'];
     // register router filters
     static::$router->filter('auth', function () {
         if (!app::$site->user()) {
             go('panel/login');
         }
     });
     // check for a completed installation
     static::$router->filter('isInstalled', function () {
         if (app::$site->users()->count() == 0) {
             go('panel/install');
         }
     });
     // only use the fragments of the path without params
     static::$path = implode('/', (array) url::fragments(detect::path()));
 }
Exemplo n.º 24
0
 public function sqlInsert($donor, $contact, $email, $phone, $description, $foodType, $distcenter, $isNew = 1)
 {
     global $servername;
     global $username;
     global $password;
     global $dbname;
     $connection = new mysqli($servername, $username, $password, $dbname);
     if ($connection === null) {
         echo "Error connecting to database";
     }
     $theInsert = $connection->prepare("INSERT INTO donations SET DONOR=?, CONTACT=?, EMAIL=?, PHONE=?, DESCRIPTION=?, FOODTYPE=?, DISTID=?, ISNEW=?");
     $theInsert->bind_param("sssssisi", $donor, $contact, $email, $phone, $description, $foodType, $distcenter, $isNew);
     $theInsert->execute();
     server::emailClients();
 }
Exemplo n.º 25
0
 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     if (r::cli()) {
         $index = '/';
     } else {
         $index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
     // fix index URL for the Panel
     if (function_exists('panel')) {
         $index = dirname($index);
     }
     return $this->index = $index;
 }
Exemplo n.º 26
0
 public function configure()
 {
     // load all available config files
     $root = $this->roots()->config();
     $configs = array('main' => $root . DS . 'config.php', 'host' => $root . DS . 'config.' . server::get('HTTP_HOST') . '.php', 'addr' => $root . DS . 'config.' . server::get('SERVER_ADDR') . '.php');
     foreach ($configs as $config) {
         if (file_exists($config)) {
             include_once $config;
         }
     }
     // apply the options
     $this->options = array_merge($this->options, c::$data);
     // connect the url class with its handlers
     url::$home = $this->urls()->index();
     url::$to = $this->option('url.to', function ($url = '') {
         if (url::isAbsolute($url)) {
             return $url;
         }
         $start = substr($url, 0, 1);
         switch ($start) {
             case '#':
                 return $url;
                 break;
             case '.':
                 return page()->url() . '/' . $url;
                 break;
             default:
                 // don't convert absolute urls
                 return url::makeAbsolute($url);
                 break;
         }
     });
     // setup the thumbnail generator
     thumb::$defaults['root'] = $this->roots->thumbs();
     thumb::$defaults['url'] = $this->urls->thumbs();
     thumb::$defaults['driver'] = $this->option('thumbs.driver');
     thumb::$defaults['filename'] = $this->option('thumbs.filename');
     // simple error handling
     if ($this->option('debug')) {
         error_reporting(E_ALL);
         ini_set('display_errors', 1);
     } else {
         error_reporting(0);
         ini_set('display_errors', 0);
     }
 }
 public function prepare()
 {
     global $db;
     $this->template = "server_search";
     $this->tab = 'server';
     require_once 'classes/server.php';
     if ($this->request['search']) {
         $req = $this->request['search'];
         if (strpos($req, ':')) {
             list($ip, $port) = explode(":", $req);
             $wheres[] = '(ip = %s AND port = %s)';
             $whargs[] = $ip;
             $whargs[] = $port;
         } else {
             $wheres[] = 'ip LIKE %s';
             $whargs[] = '%' . $req . '%';
         }
         // name search
         $wheres[] = 's.name LIKE %s';
         $whargs[] = '%' . $req . '%';
         // tag search
         $wheres[] = 'tags LIKE %s';
         $whargs[] = '%' . $req . '%';
         $where = implode(' OR ', $wheres);
         $q = $this->request['search'];
         $db->query("SELECT ip, port FROM tf2_servers s WHERE " . $where, $whargs);
         //echo mysql_error();
         if ($db->num_rows() == 1) {
             $row = $db->fetch_array();
             header(sprintf('Location: /server/%s:%s', $row['ip'], $row['port']));
             exit;
         }
         if (!$db->num_rows()) {
             page::error("Spy sappin my search results", "Sorry to <i>pop in</i> unannounced, but that server you were looking for?\r\n\t\t\t\tIt's nowhere to be found. I'm not saying one of my sappers didn't have anything to do with it, but mind the charred\r\n\t\t\t\tbits of computer on the floor.", array('image' => "spy"));
         }
         //$db->debug=true;
         foreach ($whargs as $wh) {
             $cleanargs[] = "'" . mysql_real_escape_string($wh) . "'";
         }
         $query = vsprintf('SELECT s.ip, s.port, s.name, s.map_id, m.name AS map_name, s.players, s.max_players, bots FROM tf2_servers s LEFT JOIN tf2_maps m ON s.map_id=m.id WHERE ' . $where . ' LIMIT 50', $cleanargs);
         $this->params['list'] = server::get_server_list(array('funcs' => array('link' => array('func' => 'link'), 'label' => array('func' => 'label'), 'player_label' => array('func' => 'player_label', 'param' => '%d/%d')), 'query' => $query));
         $this->title = sprintf("Search: %s", htmlspecialchars($this->request[0]));
     }
 }
Exemplo n.º 28
0
 function load()
 {
     // initiate the site and make pages and page
     // globally available
     $pages = $this->pages;
     $page = $this->pages->active();
     // check for ssl
     if (c::get('ssl')) {
         // if there's no https in the url
         if (!server::get('https')) {
             go(str_replace('http://', 'https://', $page->url()));
         }
     }
     // check for a misconfigured subfolder install
     if ($page->isErrorPage()) {
         // get the subfolder in which the site is running
         $subfolder = ltrim(dirname(server::get('script_name')), '/');
         // if it is running in a subfolder and it does not match the config
         // send an error with some explanations how to fix that
         if (!empty($subfolder) && c::get('subfolder') != $subfolder) {
             // this main url
             $url = 'http://' . server::get('http_host') . '/' . $subfolder;
             require_once c::get('root.kirby') . '/modals/subfolder.php';
             exit;
         }
     }
     // redirect file urls (file:image.jpg)
     if ($this->uri->param('file')) {
         // get the local file
         $file = $page->files()->find($this->uri->param('file'));
         if ($file) {
             go($file->url());
         }
     }
     // redirect /home to /
     if ($this->uri->path() == c::get('home')) {
         go(url());
     }
     // redirect tinyurls
     if ($this->uri->path(1) == c::get('tinyurl.folder') && c::get('tinyurl.enabled')) {
         $hash = $this->uri->path(2);
         if (!empty($hash)) {
             $resolved = $this->pages->findByHash($hash)->first();
             // redirect to the original page
             if ($resolved) {
                 go(url($resolved->uri));
             }
         }
     }
     // set the global template vars
     tpl::set('site', $this);
     tpl::set('pages', $pages);
     tpl::set('page', $page);
     $cacheID = $this->uri->toCacheID() . '.php';
     $cacheModified = time();
     $cacheData = null;
     if ($this->htmlCacheEnabled) {
         // check if the cache is disabled for some reason
         $this->htmlCacheEnabled = $page->isErrorPage() || in_array($page->uri(), c::get('cache.ignore', array())) ? false : true;
         // check for the last modified date of the cache file
         $cacheModified = cache::modified($cacheID);
         // check if the files have been modified
         // since the last html cache file has been written
         if ($this->htmlCacheEnabled && $cacheModified >= $this->modified) {
             $cacheData = cache::get($cacheID, true);
         }
     }
     if (empty($cacheData)) {
         // load the main template
         $html = tpl::load($page->template(), false, true);
         if ($this->htmlCacheEnabled) {
             cache::set($cacheID, (string) $html, true);
         }
     } else {
         $html = $cacheData;
     }
     die($html);
 }
Exemplo n.º 29
0
<?php

// detect handler from 1) query parameter ("?handler="), or fallback to 2) http referer
$handler_name = get('handler') ?: a::last(array_filter(explode('/', server::get('http_referer'))));
$handler_path = c::get('root.content') . '/smart-submit/' . $handler_name . '.php';
// check honeypot
if (get('smart-submit-honeypot') && intval(get('smart-submit-honeypot')) < 2) {
    die('{"error":"' . (l::get('smart-submit-alarm') ?: 'Anti-spam alarm. Please try again.') . '"}');
}
if (file_exists($handler_path)) {
    require $handler_path;
} else {
    die('{"error":"' . (l::get('smart-submit-missing-handler') ?: 'Error - handler not found. Please contact web site administrator for details.') . '"}');
}
Exemplo n.º 30
0
<?php

require_once dirname(__FILE__) . '/include/city.php';
require_once dirname(__FILE__) . '/include/server.php';
require_once dirname(__FILE__) . '/include/user.php';
require_once dirname(__FILE__) . '/include/invisible_header.php';
if (!$LOGIN_DATA['user_id']) {
    die('Please log in.');
}
if (!$server) {
    $server = new server($_REQUEST['server_id']);
}
$current_user = new user($LOGIN_DATA['user_id'], $server);
$cities = preg_split('/[\\s\\+]+/', $_REQUEST['attack_id']);
if ($cities[0]) {
    $tocity = new city($cities[0], $server);
}
if ($cities[1]) {
    $fromcity = new city($cities[1], $server);
}
if ($fromcity && $fromcity->getValue('user')->getValue('userid') != $LOGIN_DATA['user_id']) {
    die('Invalid from city.');
}
if ($_POST['attack_id']) {
    $message = $fromcity->initiate_transaction(intval($_POST['attack_id']), intval($_POST['attack_count']), intval($_POST['attack_destination']));
    if (!$message) {
        header('Location: ' . dirname(dirname($_SERVER['SCRIPT_URI'])), true, 303);
        exit;
    }
}
//end if POST attack_id