コード例 #1
0
 function joinServer()
 {
     $server = new server($this->id);
     if ($this->isServerJoinable($this->id)) {
         echo '<a href="' . $server->getUrl() . '">Join server</a>';
     }
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #4
0
 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']);
 }
コード例 #5
0
ファイル: dbfclass.php プロジェクト: Apoooorv/DBFProject
 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;
     }
 }
コード例 #6
0
ファイル: SmsServer.php プロジェクト: q920980002/mdx1.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' => '短信发送失败'];
 }
コード例 #7
0
ファイル: character.php プロジェクト: Kheros/CraftedWeb
 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;
     }
 }
コード例 #8
0
ファイル: url.php プロジェクト: chrishiam/LVSL
 /**
  * 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');
 }
コード例 #9
0
ファイル: delete.php プロジェクト: cozylife/tht-reworked
 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");
     }
 }
コード例 #10
0
ファイル: panel.php プロジェクト: 04x10/04x10.com
 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();
 }
コード例 #11
0
ファイル: uri.php プロジェクト: narrenfrei/kirbycms
 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;
 }
コード例 #12
0
ファイル: uri.php プロジェクト: codecuts/lanningsmith-website
 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;
 }
コード例 #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;
 }
コード例 #14
0
ファイル: load.php プロジェクト: nilshendriks/kirbycms-panel
 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');
 }
コード例 #15
0
ファイル: kirby.php プロジェクト: muten84/luigibifulco.it
 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);
         }
     }
 }
コード例 #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;
     }
 }
コード例 #17
0
ファイル: urls.php プロジェクト: aoimedia/kosmonautensofa
 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'));
     }
 }
コード例 #18
0
ファイル: error.php プロジェクト: irenehilber/kirby-base
 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));
     }
 }
コード例 #19
0
ファイル: urls.php プロジェクト: parasutcom/styleguide
 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'));
     }
 }
コード例 #20
0
ファイル: server.php プロジェクト: soldair/solumWebSocket
 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;
 }
コード例 #21
0
ファイル: uri.php プロジェクト: ajmalafif/bradshawsguide
 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();
 }
コード例 #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'));
 }
コード例 #23
0
ファイル: app.php プロジェクト: kompuser/panel
 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()));
 }
コード例 #24
0
ファイル: donations.php プロジェクト: TRMassey/ProjectB
 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();
 }
コード例 #25
0
ファイル: urls.php プロジェクト: nsteiner/kdoc
 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;
 }
コード例 #26
0
ファイル: kirby.php プロジェクト: sharontheil/bengroulx.com
 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);
     }
 }
コード例 #27
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]));
     }
 }
コード例 #28
0
ファイル: site.php プロジェクト: robeam/kirbycms
 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);
 }
コード例 #29
0
ファイル: smart-submit.php プロジェクト: chrishiam/LVSL
<?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.') . '"}');
}
コード例 #30
0
ファイル: attack.php プロジェクト: honchoman/singpolyma
<?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