Beispiel #1
0
 public function __construct($hex)
 {
     $this->flightGroupCount = getShort($hex, self::HEADER_FG);
     $this->messageCount = getShort($hex, self::HEADER_MSG);
     $this->briefingOfficers = getByte($hex, self::HEADER_BRIEF);
     $this->capturedOnEject = getBool($hex, self::HEADER_CAPTURED);
 }
Beispiel #2
0
 public function __construct($byteString)
 {
     $this->platformID = getShort($byteString, self::HEADER_START);
     $this->flightGroupCount = getShort($byteString, self::HEADER_FG);
     $this->messageCount = getShort($byteString, self::HEADER_MSG);
     for ($i = 0; $i < self::IFF_COUNT; $i++) {
         $this->IFFNames[] = getString($byteString, self::HEADER_IFF + $i * self::IFF_LENGTH, self::IFF_LENGTH);
     }
     for ($r = 0; $r < self::REGION_COUNT; $r++) {
         $this->regionNames[] = getString($byteString, self::HEADER_REGION + $r * self::REGION_LENGTH, self::REGION_LENGTH);
     }
     for ($c = 0; $c < self::CARGO_COUNT; $c++) {
         $this->globalCargos[] = new GlobalCargo(substr($byteString, self::HEADER_CARGO + $c * GlobalCargo::LENGTH, GlobalCargo::LENGTH));
     }
     for ($g = 0; $g < self::GG_COUNT; $g++) {
         $this->globalGroupNames[] = getString($byteString, self::HEADER_GG + $g * self::GG_LENGTH, self::GG_LENGTH);
     }
     $this->hangar = getByte($byteString, self::HEADER_HANGAR);
     $this->timeLimitMinutes = getByte($byteString, self::HEADER_TIME);
     $this->endMissionWhenComplete = getBool($byteString, self::HEADER_END);
     $this->briefingOfficer = getByte($byteString, self::HEADER_OFFICER);
     $this->briefingLogo = getByte($byteString, self::HEADER_LOGO);
     $this->hex = \Hex::hexToStr($byteString);
 }
Beispiel #3
0
 public static function dispatch()
 {
     static::$_uri = $uri = trim($_SERVER['REQUEST_URI'], static::URI_DELIMITER);
     $containerRoute = static::containerRoute();
     if (null !== $containerRoute) {
         return;
     }
     $defaultRoute = static::defaultRoute();
     if (null !== $defaultRoute) {
         return;
     }
     $entities = container()->getEntities();
     /* Pages non routées */
     if (true === container()->getMultiSite() && !empty($entities) && null === container()->getMapRoutes()) {
         $url = substr($_SERVER['REQUEST_URI'], 1);
         $db = new Querydata('page');
         $res = $db->where('is_home = ' . getBool('true')->getId())->get();
         $home = $db->first($res);
         $_homeUrl = Cms::__($home->getUrl());
         $homeUrl = null !== $_homeUrl ? $_homeUrl : 'home';
         $url = !strlen($url) ? $homeUrl : $url;
         $pages = Cms::getPages();
         $cmsRoutes = array();
         $lngs = explode(',', cms_option('page_languages'));
         if (count($pages)) {
             foreach ($pages as $pageTmp) {
                 if (1 < count($lngs)) {
                     $urlTab = $pageTmp->getUrl();
                     foreach ($lngs as $lng) {
                         if (ake($lng, $urlTab)) {
                             $cmsRoutes[$urlTab[$lng]] = $pageTmp;
                         }
                     }
                 } else {
                     $cmsRoutes[Cms::__($pageTmp->getUrl())] = $pageTmp;
                 }
             }
         }
         $found = Arrays::exists($url, $cmsRoutes);
         if (false === $found) {
             $found = Cms::match($cmsRoutes);
         }
         if (true === $found && ake($url, $cmsRoutes)) {
             $page = $cmsRoutes[$url];
             $status = Inflector::lower($page->getStatuspage()->getName());
             $dateDepub = $page->getDateOut();
             $now = time();
             $continue = true;
             if (strlen($dateDepub)) {
                 list($d, $m, $y) = explode('-', $dateDepub, 3);
                 $dateDepub = "{$y}-{$m}-{$d}";
                 $dateDepub = new Date($dateDepub);
             }
             if ($dateDepub instanceof Date) {
                 $ts = $dateDepub->getTimestamp();
                 if ($ts < $now) {
                     $page = $cmsRoutes['home'];
                 }
             }
             if ('offline' == $status) {
                 $continue = false;
             } else {
                 if ('online' != $status) {
                     $page = ake($status, $cmsRoutes) ? $cmsRoutes[$status] : $cmsRoutes['home'];
                 }
             }
             if (true === $continue) {
                 return static::isCms($page);
             }
         }
     }
     if (true === container()->getMultiSite()) {
         $file = APPLICATION_PATH . DS . 'config' . DS . SITE_NAME . DS . 'routes.php';
     } else {
         $file = APPLICATION_PATH . DS . 'config' . DS . 'routes.php';
     }
     if (File::exists($file)) {
         $configRoutes = (include $file);
         $routes = $configRoutes['collection'];
         $routes += null !== container()->getRoutes() ? container()->getRoutes() : array();
         foreach ($routes as $route) {
             if (!$route instanceof Container) {
                 continue;
             }
             $path = $route->getPath();
             if ($path == $uri) {
                 return static::make($route);
             }
         }
         foreach ($routes as $route) {
             if (!$route instanceof Container) {
                 continue;
             }
             if (!strlen($route->getPath())) {
                 continue;
             }
             $matched = static::match($route->getPath());
             if (false === $matched) {
                 continue;
             } else {
                 return static::make($route);
             }
         }
     } else {
         static::make(container()->getNotFoundRoute());
         return;
     }
     if (null === container()->getMapRoutes()) {
         static::is404();
     } else {
         static::make(container()->getNotFoundRoute());
         return;
     }
 }
Beispiel #4
0
 function readFlightGroup($hex)
 {
     $orig = $hex;
     $fg = array('Name' => getString($hex, self::FG_NAME * 0, self::FG_NAME), 'Pilot' => getString($hex, self::FG_NAME * 1, self::FG_NAME), 'Cargo' => getString($hex, self::FG_NAME * 2, self::FG_NAME), 'Special Cargo' => getString($hex, self::FG_NAME * 3, self::FG_NAME));
     $hex = substr($hex, self::FG_NAME * 4);
     //TFW General Tab
     $fg['SpecialPos'] = getByte($hex[0]);
     $fg['SpecialRand'] = getBool($hex[1]);
     $fg['ShipType'] = new ShipType($hex[2]);
     $fg['Ships'] = getByte($hex[3]);
     $fg['Status'] = $this->lookup('status', $hex[4]);
     $fg['Warheads'] = $this->lookup('warheads', $hex[5]);
     $fg['Beam'] = $this->lookup('beam', $hex[6]);
     $fg['IFF'] = $this->lookup('IFF', $hex[7]);
     $fg['AI'] = $this->lookup('AI', $hex[8]);
     $fg['Colour'] = $this->lookup('colour', $hex[9]);
     $fg['ObeysRadio'] = getByte($hex[10]);
     $fg['Formation'] = $this->lookup('formation', $hex[12]);
     $fg['FormSpacing'] = getByte($hex[13]);
     //NOT IN TFW
     $fg['GlobalGroup'] = getByte($hex[14]);
     //NOT IN TFW
     $fg['LeaderSpacing'] = getByte($hex[15]);
     //NOT IN TFW
     $fg['Waves'] = getByte($hex[16]);
     $fg['Pos'] = getByte($hex[18]);
     $fg['OrientationX'] = getByte($hex[19]);
     //NOT IN TFW
     $fg['OrientationY'] = getByte($hex[20]);
     //NOT IN TFW
     $fg['OrientationZ'] = getByte($hex[21]);
     //NOT IN TFW
     $fg = array('General' => $fg);
     //TFW Win Conditions Tab
     $win = array();
     $win['PrimaryWhat'] = $this->lookup('goalCond', $hex[110]);
     $win['PrimaryWho'] = $this->lookup('goalAmount', $hex[111]);
     $win['SecondrWhat'] = $this->lookup('goalCond', $hex[112]);
     $win['SecondrWho'] = $this->lookup('goalAmount', $hex[113]);
     $win['SecretWhat'] = $this->lookup('goalCond', $hex[114]);
     $win['SecretWho'] = $this->lookup('goalAmount', $hex[115]);
     $win['BonusWhat'] = $this->lookup('goalCond', $hex[116]);
     $win['BonusWho'] = $this->lookup('goalAmount', $hex[117]);
     $win['BonusPts'] = getSByte($hex[118]) * 50;
     //TODO Const
     $fg['Win'] = $win;
     //TFW Arrival
     $arr = array();
     $arr['Difficulty'] = $this->lookup('difficulty', $hex[25]);
     $arr['TriggerA'] = $this->getTrigger($hex, 26);
     $arr['TriggerB'] = $this->getTrigger($hex, 30);
     $arr['CondAB'] = getBool($hex[34]) ? "OR" : "AND";
     $arr['DelayMin'] = getByte($hex[36]);
     $arr['DelaySec'] = getByte($hex[37]);
     //TFW Departure
     $dep = array();
     $dep['Stop'] = $this->lookup('abort', ord($hex[44]));
     $dep['CondType'] = $this->lookup('switch', ord($hex[39]));
     $dep['CondAmount'] = $this->lookup('percentage', ord($hex[41]));
     $dep['CondValue'] = $this->lookupSwitch($dep['CondType'], ord($hex[40]));
     $dep['CondResult'] = $this->lookup('goalCond', ord($hex[38]));
     //TFW arr/dep methods
     $arr['MethodA'] = getByte($hex[48]);
     $dep['MethodA'] = getByte($hex[50]);
     $arr['MethodB'] = getByte($hex[52]);
     $dep['MethodB'] = getByte($hex[54]);
     $arr['MethodAon'] = getByte($hex[49]);
     $dep['MethodAon'] = getByte($hex[51]);
     $arr['MethodBon'] = getByte($hex[53]);
     $dep['MethodBon'] = getByte($hex[55]);
     $fg['Arrival'] = $arr;
     $fg['Departure'] = $dep;
     //TFW orders
     $orders = array();
     foreach (array(56, 74, 92) as $o) {
         //TODO use primary/secondary format instead of TFW format
         $ord = array();
         $ord['Order'] = $this->lookup('orders', $hex[$o]);
         $ord['Speed'] = getByte($hex[$o + 1]);
         $ord['ParamA'] = getByte($hex[$o + 2]);
         $ord['ParamB'] = getByte($hex[$o + 3]);
         $ord['TargetTypeA'] = getByte($hex[$o + 12]);
         $ord['TargetVal A'] = getByte($hex[$o + 13]);
         $ord['TargetTypeB'] = getByte($hex[$o + 14]);
         $ord['TargetVal B'] = getByte($hex[$o + 15]);
         $ord['TargetA orB'] = getBool($hex[$o + 16]) ? 'OR' : "AND";
         $ord['TargetTypeC'] = getByte($hex[$o + 6]);
         $ord['TargetVal C'] = getByte($hex[$o + 8]);
         $ord['TargetTypeD'] = getByte($hex[$o + 7]);
         $ord['TargetVal D'] = getByte($hex[$o + 9]);
         $ord['TargetC orD'] = getBool($hex[$o + 10]) ? 'OR' : "AND";
         $orders[] = new FGOrder($ord);
     }
     $fg['Orders'] = $orders;
     //TFW Navigation
     $nav = array();
     $navStr = substr($hex, 120, 90);
     $enabled = substr($hex, 210);
     //last 30 bytes are booleans for the enabled with a 00 afterwards.
     for ($i = 0; $i < 15; $i++) {
         $nav[$i] = array();
         foreach (array('x' => 0, 'y' => 30, 'z' => 60) as $key => $offset) {
             //                $coord = substr($navStr, $offset + ($i*2), 2);
             $coord = getShort($navStr, $offset + $i * 2);
             $nav[$i][$key] = $coord / 160;
         }
         $nav[$i]['on'] = ord($enabled[$i * 2]);
     }
     //        $fg['Navigation'] = $nav;
     $this->hasUnknowns($hex);
     //        unset($fg['Orders']);
     //        unset($fg['Navigation']);
     //        unset($fg['Win']);
     //        unset($fg['Arrival']);
     //        unset($fg['Departure']);
     //        $fg['General'] = $fg['General']['Name'];
     //        $fg['hex'] = Hex::hexToStr($hex);
     $fg['rest'] = $this->unknownSet;
     return $fg;
 }
<?php

include_once 'includes/includes.php';
include_once 'translate_fns.php';
$MAX_PAGE = 20;
$id = $_GET['id'];
$langto = $_GET['langto'];
$langfrom = $_GET['langfrom'];
$fversion = $_GET['fversion'];
$untranslated = getBool('untraslated');
if (!isset($fversion)) {
    $fversion = 0;
}
tn_check($id, $fversion, $langfrom, $langto);
$start = $_GET['start'];
if (!isset($start)) {
    $start = 0;
}
$updated = "updated";
$mode = "updated";
$author = $_GET['user'];
$slang = $langfrom;
$squery = "select authorID,version,original,locked,text,lang_id,edited_seq,last,estart_time,estart_time_fraction,eend_time,eend_time_fraction,fversion from subs ";
$query = "where subID={$id} and fversion={$fversion}";
$query .= " and lang_id={$langfrom}";
if ($untranslated) {
    $query .= " and edited_seq= ANY (select sequence from translating where subID={$id} and fversion={$fversion} and lang_id={$langto})";
}
$query .= " and last=1 order by edited_seq,version";
$fquery .= " limit {$start},{$MAX_PAGE}";
$finalresult = mysql_query($squery . $query . $fquery);
Beispiel #6
0
 public static function makeForm($name)
 {
     $html = '';
     $db = dm('adminform');
     $db2 = dm('adminformfield');
     $res = $db->where('name = ' . $name)->get();
     if (count($res)) {
         $form = $db->first($res);
         $html .= '<form class="form-horizontal" action="' . URLSITE . static::__($form->getPage()->getUrl()) . '" id="form_' . Inflector::lower($name) . '" method="post">';
         $html .= Form::hidden('cms_form', $form->getId(), array('id' => 'cms_form'));
         $fields = $db2->where('adminform = ' . $form->getId())->order('hierarchy')->get();
         if (count($fields)) {
             foreach ($fields as $field) {
                 $true = getBool('true');
                 $fieldName = $field->getName();
                 $label = static::__($field->getLabel());
                 $type = $field->getAdminformfieldtype()->getValue();
                 $value = static::__($field->getDefault());
                 $required = $field->getRequired() == $true->getId();
                 if (empty($value)) {
                     $value = null;
                 }
                 switch ($type) {
                     case 'hidden':
                         $html .= Form::hidden($fieldName, $value, array('id' => $fieldName));
                         break;
                     case 'select':
                         $options = explode("\n", $value);
                         $tab = array();
                         foreach ($options as $row) {
                             list($key, $val) = explode('##', $row, 2);
                             $tab[$key] = $val;
                         }
                         $html .= Form::select($fieldName, $tab, null, array('id' => $fieldName, 'required' => $required), $label);
                         break;
                     case 'password':
                         $html .= Form::password($fieldName, array('id' => $fieldName, 'required' => $required), $label);
                         break;
                     default:
                         $html .= Form::$type($fieldName, $value, array('id' => $fieldName, 'required' => $required), $label);
                 }
             }
         }
         $html .= '<div class="control-group" id="control-group-submit"><label for="submit" class="control-label labelrequired">&nbsp;</label><div class="control-group" id="control-group-submit" style="position: relative; left: 20px;">' . Form::submit(static::__($form->getButton())) . '</div></div>';
     }
     return $html;
 }
Beispiel #7
0
require_once "database.php";
// GET options {{{
$server = getString("server", "s2.travian.com");
$alliance = getString("alliance", null);
$player = getString("player", null);
$town = getString("town", null);
$order = getString("order", "default");
$zoom = getString("zoom", null);
$layout = getString("layout", "default");
$caption = getString("caption", $words["key"]);
$groupby = getString("groupby", "player");
$colby = getString("colby", $groupby);
$lines = getBool("lines");
$casen = getBool("casen");
$azoom = getBool("azoom");
$nocache = getBool("nocache");
$dotsize = getFloat("dotsize", 1);
$maxdist = getInt("maxdist", null);
$mindist = getInt("mindist", null);
$maxpop = getInt("maxpop", null);
$minpop = getInt("minpop", null);
$table = preg_replace("/[^a-zA-Z0-9]/", "_", $server);
$s_server = sql_escape_string($server);
$server_info = sql_fetch_row(sql_query("SELECT * FROM servers WHERE name='{$s_server}'"));
// }}}
// figure out where we are {{{
if ($layout == "spread") {
    $cx = 768 / 2;
    $cy = 256;
} else {
    $cx = 256;