Пример #1
0
 /**
  * Returns the spec object of the used drive.
  * 
  * @param	LWUser	user
  * @return	Spec	drive
  */
 public function getDrive()
 {
     $drives = array();
     if ($this->drive == null) {
         return null;
     }
     foreach ($this->drive as $driveSpecID => $driveData) {
         $driveObj = self::getSpecObj($driveSpecID);
         $driveColName = $driveObj->colName;
         $driveLevel = self::$user->{$driveColName};
         // check
         if (LWUtil::checkInt($driveLevel, $driveData['min'], $driveData['max']) != $driveLevel) {
             continue;
         }
         // we must use intval here, because array_flip can only flip strings and integers (no floats)
         $drives[$driveSpecID] = intval($driveData['speed'] + $driveData['speed'] * self::$user->{$driveColName} * $driveData['factor']);
     }
     if (!count($drives)) {
         return null;
     }
     asort($drives, SORT_NUMERIC);
     $drives = array_flip($drives);
     $driveSpecID = array_pop($drives);
     return self::getSpecObj($driveSpecID);
 }
Пример #2
0
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['fleetID'])) {
         $this->fleetID = LWUtil::checkInt($_REQUEST['fleetID']);
     }
 }
Пример #3
0
 /**
  * Decides which drives is used.
  * 
  * @param	int		spec id
  * @param	LWUser	drive
  */
 public static function getDriveSpecID($specID, $user = null)
 {
     if ($user === null) {
         $user = WCF::getUser();
     }
     $specs = WCF::getCache()->get('spec-' . PACKAGE_ID, 'bySpecID');
     $spec = $specs[$specID];
     $drives = array();
     foreach ($spec['drive'] as $driveSpecID => $drive) {
         $driveColName = BasicSpecUtil::getColName($driveSpecID);
         $driveLevel = $user->{$driveColName};
         // check
         if (LWUtil::checkInt($driveLevel, $drive['min'], $drive['max']) != $driveLevel) {
             continue;
         }
         // we must use intval here, because array_flip can only flip strings and integers
         $drives[$driveSpecID] = intval($drive['speed'] + $drive['speed'] * $user->{$driveColName} * $drive['factor']);
     }
     if (!count($drives)) {
         return null;
     }
     asort($drives, SORT_NUMERIC);
     //var_dump($drives);
     $drives = array_flip($drives);
     return array_pop($drives);
 }
Пример #4
0
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     $sql = "SELECT *\n\t\t\t\tFROM ugml_archive_fleet\n\t\t\t\tWHERE fleetID = " . $this->fleetID;
     $row = WCF::getDB()->getFirstRow($sql);
     $this->fleetData = unserialize(LWUtil::unserialize($row['data']));
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['primaryDestination'])) {
         $this->primaryDestination = LWUtil::checkInt($_REQUEST['primaryDestination']);
     }
 }
Пример #6
0
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['type'])) {
         $this->type = StringUtil::trim($_REQUEST['type']);
     }
     if (isset($_REQUEST['name'])) {
         $this->name = StringUtil::trim($_REQUEST['name']);
     }
     if (isset($_REQUEST['startInput']) && !empty($_REQUEST['startInput'])) {
         $this->start = LWUtil::checkInt($_REQUEST['startInput'], 1);
         if ($this->start >= 1 && $this->start <= 99) {
             // e.g. 5 => 501; 14 => 1401
             $this->start *= 100;
             $this->start++;
         }
     } else {
         if (isset($_REQUEST['start'])) {
             $this->start = LWUtil::checkInt($_REQUEST['start'], 0);
         } else {
             if (isset($_REQUEST['relationalID'])) {
                 $this->relationalID = LWUtil::checkInt($_REQUEST['relationalID']);
             }
         }
     }
     if (isset($_REQUEST['rowCount'])) {
         $this->rowCount = LWUtil::checkInt($_REQUEST['rowCount'], 10, 500);
     }
 }
Пример #7
0
 /**
  * Reads the detectors to start from the database
  */
 protected function getDetectors()
 {
     $sql = "SELECT *\n\t\t\t\tFROM ugml_bot_detector\n\t\t\t\tWHERE executionProbability > " . rand(0, 99) . "\n\t\t\t\t\tAND '" . $_SERVER['PHP_SELF'] . LWUtil::getArgsStr() . "' REGEXP locationPattern\n\t\t\t\tORDER BY executionPriority DESC";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->detectors[$row['detectorID']] = $row;
     }
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['oventID'])) {
         $this->oventID = LWUtil::checkInt($_REQUEST['oventID']);
     }
     if (isset($_REQUEST['highlighted'])) {
         $this->highlighted = LWUtil::checkInt($_REQUEST['highlighted'], 0, 1);
     }
 }
Пример #9
0
 /**
  * Catches the too many connections error and sets a file system lock.
  */
 protected function connect()
 {
     try {
         parent::connect();
     } catch (DatabaseException $e) {
         if (defined("COOKIE_PREFIX") && isset($_COOKIE[COOKIE_PREFIX . 'userID']) && $_COOKIE[COOKIE_PREFIX . 'userID']) {
             LWUtil::lockAccount(intval($_COOKIE[COOKIE_PREFIX . 'userID']), 10);
         }
         // throw again...
         throw $e;
     }
 }
 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     $specs = Spec::getBySpecType(3);
     foreach ($specs as $specID => $specObj) {
         $shipCount = LWUtil::checkInt(@$_REQUEST['ship' . $specID], 0, $specObj->level);
         if ($shipCount) {
             $specObj->level = $shipCount;
             $this->specs[$specID] = clone $specObj;
             $this->ships[$specID] = $shipCount;
         }
     }
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     global $game_config;
     AbstractForm::save();
     $data = LWUtil::serialize(array('text' => $this->applicationText), 1);
     $this->alliance2->addInterrelation($this->allianceID, $this->interrelationType, 1, $data);
     if ($this->interrelationType == 3) {
         require_once WCF_DIR . 'lib/system/exception/NamedUserException.class.php';
         throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.diplomacy.newWar', array('boardURL' => $game_config['diplomacyBoardURL'], 'boardID' => $game_config['diplomacyBoardID'])));
     }
     header('Location: index.php?page=Alliance');
     exit;
 }
Пример #12
0
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['fleetID'])) {
         $this->fleetID = LWUtil::checkInt($_REQUEST['fleetID']);
     }
     if (isset($_GET['doSearch'])) {
         try {
             $this->validate();
             // no errors
             $this->save();
         } catch (UserInputException $e) {
             $this->errorField = $e->getField();
             $this->errorType = $e->getType();
         }
     }
 }
Пример #13
0
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['mission'])) {
         $this->missionID = LWUtil::checkInt($_REQUEST['mission']);
     }
     if (isset($_REQUEST['metal'])) {
         $this->metal = LWUtil::checkInt($_REQUEST['metal'], 0, LWCore::getPlanet()->metal);
     }
     if (isset($_REQUEST['crystal'])) {
         $this->crystal = LWUtil::checkInt($_REQUEST['crystal'], 0, LWCore::getPlanet()->crystal);
     }
     if (isset($_REQUEST['deuterium'])) {
         $this->deuterium = LWUtil::checkInt($_REQUEST['deuterium'], 0, LWCore::getPlanet()->deuterium);
     }
     //TODO: integrate this in wcf eventlistener readParameters@FleetStartFireAction
     if (isset($_REQUEST['formation'])) {
         $this->formationID = LWUtil::checkInt($_REQUEST['formation']);
     }
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['allianceID'])) {
         $this->allianceID = LWUtil::checkInt($_REQUEST['allianceID']);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if (isset($_REQUEST['userID'])) {
         $this->userID = LWUtil::checkInt($_REQUEST['userID']);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if (isset($_REQUEST['rankID'])) {
         $this->rankID = LWUtil::checkInt($_REQUEST['rankID'], -1);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
 }
Пример #15
0
 /**
  * Updates the data of a logged fleet.
  * 
  * @param	LoggableFleet
  */
 public static function update(LoggableFleet $fleet)
 {
     EventHandler::fireAction($fleet, 'logData');
     // TODO: integrate this in wcf eventlistener logData@Fleet
     self::addRelevantData($fleet);
     $data = $fleet->getData();
     if (isset(self::$invalidFleetIDs[$data['fleetID']])) {
         return;
     }
     $array = self::readArray($data['fleetID']);
     if ($array === false) {
         self::$invalidFleetIDs[$data['fleetID']] = true;
         return;
     }
     $array[] = array('data' => $data, 'fleet' => $fleet->getFleetArray(), 'stack' => self::getStacktrace(), 'time' => time());
     $string = LWUtil::serialize(serialize($array), 1);
     $sql = "UPDATE ugml_archive_fleet\r\n\t\t\t\tSET data = '" . escapeString($string) . "'\r\n\t\t\t\tWHERE fleetID = " . $data['fleetID'];
     WCF::getDB()->sendQuery($sql);
 }
Пример #16
0
 /**
  * Saves a given target to the fleet queue.
  */
 protected function readTarget()
 {
     if (isset($_REQUEST['targetPlanetID'])) {
         $this->targetPlanetID = LWUtil::checkInt($_REQUEST['targetPlanetID']);
     } else {
         if (isset($_REQUEST['galaxy'])) {
             $this->galaxy = LWUtil::checkInt($_REQUEST['galaxy'], 1, 9);
         }
         if (isset($_REQUEST['system'])) {
             $this->system = LWUtil::checkInt($_REQUEST['system'], 1, 499);
         }
         if (isset($_REQUEST['planet'])) {
             $this->planet = LWUtil::checkInt($_REQUEST['planet'], 1, 15);
         }
         if (isset($_REQUEST['planetType'])) {
             $this->planetType = LWUtil::checkInt($_REQUEST['planetType'], 1, 3);
         }
         if (isset($_REQUEST['missionID'])) {
             $this->fleetQueue->missionID = LWUtil::checkInt($_REQUEST['missionID']);
         }
     }
     // planet
     $this->fleetQueue->startPlanetID = LWCore::getPlanet()->planetID;
     $this->planetObj = Planet::getInstance($this->targetPlanetID);
     if ($this->planetObj->planetID) {
         $this->fleetQueue->storePlanet($this->planetObj);
         return;
     }
     $this->systemObj = new System($this->galaxy, $this->system);
     $this->planetObj = $this->systemObj->getPlanet($this->planet, $this->planetType);
     if ($this->planetObj !== null) {
         $this->fleetQueue->storePlanet($this->planetObj);
     }
 }
Пример #17
0
    WOT Game is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    WOT Game is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with WOT Game.  If not, see <http://www.gnu.org/licenses/>.
*/
//fleetback.php
/*
define('INSIDE', true);
$ugamela_root_path = '../';
include($ugamela_root_path . 'extension.inc');
include($ugamela_root_path . 'common.'.$phpEx);
if(!check_user()){ header("Location: login.php"); die();}*/
define('WCF_DIR', 'G:\\workspace\\lw\\wcf\\');
require_once '../game/lib/util/LWUtil.class.php';
require_once '../game/lib/system/spec/Spec.class.php';
$a = array(1 => 2);
$b = array(1 => 3);
var_Dump(Spec::diff($a, $b));
var_Dump(array_diff_assoc($b, $a));
$data = '3:1~eJztXW2P3LYR/mwD/Q+LRdHagL0R9a6174o0TgvDeXEbp/lwCBY8ibernFZSKcn2xvBv7R/phw5fpJW00pKK4+aS6IAEu+TMaDgcDoePxku8ttfv4rXxBLMPBfxvGeESL+G7ZbIGb728SQgpnz9bPuHfAhuZBjLZt2C93MdFEWep6DXXS9OQHTkOb/GWNB1ewD4ga72M99BXfv6apFKov14i3zdt37Zqmjf4lnybt2jQemnUnZSUFU0HBdg1TVFiWr5McNrS3DQtz7Z9TgLjBIot6dMghEzb9OW37E1KqOgDhgAhVz4uu4kxxU2PGVi8B4GaNxnd47KxSa24u15ucYLfHmSjJxuLQ1GSfW0kU7bmXCtJykU7YGtS4qQtEzQMKfB3W8H4EalKQuNq32vnVnkV7wlvN2C4pmWaZhC4Qd0iZueExjLMwKxbxAQM0LjIqVvEDDY0UgewVZGTkH0EGt4D1sxpvMf08IwUZZxy27V5HOmByydfiVHwWfkKC8kg8Uv89m39WDExdScCU95mNF1UKViZXidxuOPtXsdDPssyGhVyar11YK29P6Naubab9Ag9c+0KwsZXXnI2mErfX3lohbxg5aLaNQRJPjQBjtH1rJe1IwfmynNWyPVWYOBauCTqSTJ9CyYpgKl837YaBkvCEncM60kMFpGdMPzwlvFaYKO/Mcp/VKQ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V+DkuUS8Vn4uET+jzFwi3uObIeQZQh6hnyHk3t9cIj6XiHdsMpeI65eI+xqo/OQScfEr5NNLxOWvkz943t41Kf/R/zUs34cNdf1T5XH6GidxNPgb9vwXzgdA9QcnUm6aiKSiVCL2vZ9Fl5cYiZgirjDqEjQ3nsiV3u09W/l91bnSSCwjeaFRl65zrdGAW1x1rjZqC+q+BLrqXG8kAZLT+vWr7hVHMo6cvpK4kvccCeP0C8qv6suOJKjQezdw1brwaGhIo68KzrwaGH8V0Aqhvee0g2WvqxsWjQFTvqozhOOFSEMz3CXjdyINzV+frA+AXh0vRxrUKCfh6R5+dXpL0hDzcQWJi5IGJrp5AcLuGhma6oagf2HSqBOK25DEVMpLk8Y9sUMsLk4acseXYn9uXZ40RJX3jd3/hwW1+wpxnTuUBunaAutrlNrR5+F9nVva/PXyu69f8YX8ubiZrbmijTcWj85c4nbmqrb3/wO/fPAu';
$array = unserialize(LWUtil::unserialize($data));
var_dump($array);
Пример #18
0
 /**
  * Adds a document to the index.
  * 
  * @param	array	documents or fields
  * @param	bool	commit after adding
  * @param	bool	ignore missing fields
  */
 public function add($documents, $commit = true, $ignoreMissingFields = false)
 {
     $this->loadFieldData();
     if (LWUtil::getDimensionCount($documents) == 1) {
         $documents = array($documents);
     }
     foreach ($documents as $fields) {
         $document = new Zend_Search_Lucene_Document();
         foreach ($this->fields as $fieldName => $fieldType) {
             if (!isset($fields[$fieldName])) {
                 if (!$ignoreMissingFields) {
                     var_Dump($fields);
                     require_once WCF_DIR . 'lib/system/exception/SystemException.class.php';
                     throw new SystemException('missing field ' . $fieldName);
                 }
             }
             $field = call_user_func_array(array('Zend_Search_Lucene_Field', $fieldType), array($fieldName, $fields[$fieldName]));
             $document->addField($field);
         }
         $this->getIndex()->addDocument($document);
     }
     if ($commit) {
         $this->getIndex()->commit();
     }
 }
Пример #19
0
 /**
  * Prepares the data for simulation
  */
 protected function simulate()
 {
     // organize data
     foreach ($this->shipDataArray as $key => $value) {
         if (empty($value)) {
             continue;
         }
         $nfsSlotNo = intval(substr($key, 8, 2));
         $front = strtolower(substr($key, 10, 8));
         $isTech = strlen($key) > 21;
         $arrayName = $front . 'Fleets';
         if ($isTech) {
             $techID = substr($key, -3);
             $this->{$arrayName}[$nfsSlotNo]['tech'][$techID] = intval($value);
         } else {
             $techID = substr($key, -3);
             $this->{$arrayName}[$nfsSlotNo]['fleet'][$techID] = intval($value);
         }
     }
     if (!count($this->attackerFleets) || !count($this->defenderFleets)) {
         return;
     }
     // create objs
     foreach ($this->attackerFleets as $nfsSlotNo => $fleetData) {
         $fleetStr = LWUtil::serialize($fleetData['fleet']);
         $array = array('fleet' => Spec::arrayToStr($fleetData['fleet']), 'galaxy' => 0, 'system' => 0, 'planet' => 0, 'ownerID' => 0, 'targetPlanetID' => 0, 'fleetID' => 0, 'weaponTech' => $fleetData['tech'][109], 'shieldTech' => $fleetData['tech'][110], 'hullPlatingTech' => $fleetData['tech'][111]);
         $this->attackerFleetObjs[$nfsSlotNo] = new PhantomFleet(null, $array);
     }
     $simulatingFleetArray = $array;
     foreach ($this->defenderFleets as $nfsSlotNo => $fleetData) {
         $fleetStr = LWUtil::serialize($fleetData['fleet']);
         $array = array('fleet' => Spec::arrayToStr($fleetData['fleet']), 'galaxy' => 0, 'system' => 0, 'planet' => 0, 'ownerID' => 0, 'targetPlanetID' => 0, 'fleetID' => 0, 'weaponTech' => $fleetData['tech'][109], 'shieldTech' => $fleetData['tech'][110], 'hullPlatingTech' => $fleetData['tech'][111]);
         $this->defenderFleetObjs[$nfsSlotNo] = new PhantomFleet(null, $array);
     }
     // simulate
     set_time_limit(60);
     for ($i = 0; $i < self::SIMULATIONS; ++$i) {
         try {
             ob_start();
             $simulator = new CombatSimulator($this->attackerFleetObjs, $this->defenderFleetObjs, $simulatingFleetArray);
             $simulator->simulate();
             ob_clean();
         } catch (Exception $e) {
             message('Es ist ein fehler bei der Simulation aufgetreten!');
         }
         $this->unitsAttackerArray[$i] = $simulator->units['attacker'];
         $this->unitsDefenderArray[$i] = $simulator->units['defender'];
         $this->debrisMetalArray[$i] = $simulator->debris['metal'];
         $this->debrisCrystalArray[$i] = $simulator->debris['crystal'];
         $this->bootyArray[$i] = $simulator->totalCapacity;
         $this->roundNoArray[$i] = $simulator->roundNo;
         $this->winnerArray[$i] = $simulator->winner;
         // check extrema
         if ($i == 0) {
             //var_dump($simulator);
             $this->minSimulator = $this->maxSimulator = $simulator;
             continue;
         }
         // real best case: difference in attacker units
         $byAttackerUnits = $simulator->units['attacker'] < $this->minSimulator->units['attacker'];
         // unreal best case: no difference in attacker units, but more defender units
         $byDefenderUnits = $simulator->units['attacker'] == $this->minSimulator->units['attacker'] && $simulator->units['defender'] > $this->minSimulator->units['defender'];
         if ($byAttackerUnits || $byDefenderUnits) {
             $this->minSimulator = $simulator;
         }
         // real worst case: difference in attacker units
         $byAttackerUnits = $simulator->units['attacker'] > $this->maxSimulator->units['attacker'];
         // unreal worst case: no difference in attacker units, but less defender units
         $byDefenderUnits = $simulator->units['attacker'] == $this->maxSimulator->units['attacker'] && $simulator->units['defender'] < $this->maxSimulator->units['defender'];
         if ($byAttackerUnits || $byDefenderUnits) {
             $this->maxSimulator = $simulator;
         }
     }
     $simulator->generateReport();
     $report = CombatReport::create(time(), $simulator->report, false, array(WCF::getUser()->userID => WCF::getUser()->userID));
     $this->reportID = $report->reportID;
     // sum up (avg)
     $this->units['attacker'] = array_sum($this->unitsAttackerArray) / self::SIMULATIONS;
     $this->units['defender'] = array_sum($this->unitsDefenderArray) / self::SIMULATIONS;
     $this->debris['metal'] = array_sum($this->debrisMetalArray) / self::SIMULATIONS;
     $this->debris['crystal'] = array_sum($this->debrisCrystalArray) / self::SIMULATIONS;
     $this->booty = array_sum($this->bootyArray) / self::SIMULATIONS;
     $this->roundNo = array_sum($this->roundNoArray) / self::SIMULATIONS;
     // sum up (min)
     $this->minUnits['attacker'] = $this->minSimulator->units['attacker'];
     $this->minUnits['defender'] = $this->minSimulator->units['defender'];
     $this->minDebris['metal'] = $this->minSimulator->debris['metal'];
     $this->minDebris['crystal'] = $this->minSimulator->debris['crystal'];
     $this->minBooty = $this->minSimulator->totalCapacity;
     // sum up (max)
     $this->maxUnits['attacker'] = $this->maxSimulator->units['attacker'];
     $this->maxUnits['defender'] = $this->maxSimulator->units['defender'];
     $this->maxDebris['metal'] = $this->maxSimulator->debris['metal'];
     $this->maxDebris['crystal'] = $this->maxSimulator->debris['crystal'];
     $this->maxBooty = $this->maxSimulator->totalCapacity;
     $this->winner = array_count_values($this->winnerArray);
 }
Пример #20
0
include $ugamela_root_path . 'extension.inc';
include $ugamela_root_path . 'common.' . $phpEx;
if (!check_user()) {
    header("Location: login.php");
    die;
}
$start = intval($_GET['start']);
$interval = 500;
$sql = "SELECT ugml_archive_fleet.*\n\t\tFROM ugml_planets\n\t\tLEFT JOIN ugml_users\n\t\tON ugml_users.id = ugml_planets.id_owner\n\t\tLEFT JOIN wcf1_user\n\t\tON ugml_users.id = wcf1_user.userID\n\t\tLEFT JOIN ugml_archive_fleet\n\t\tON ugml_planets.id = ugml_archive_fleet.targetPlanetID\n\t\tWHERE wcf1_user.userID IS NULL\n\t\tLIMIT " . $start . ", " . $interval;
$result = WCF::getDB()->sendQuery($sql);
$users = array();
while ($row = WCF::getDB()->fetchArray($result)) {
    if ($row['data'] === null) {
        continue;
    }
    $data = unserialize(LWUtil::unserialize($row['data']));
    $rev = end($data);
    if (!isset($users[$rev['data']['ownerID']])) {
        $metalu = $crystalu = $deuteriumu = 0;
    } else {
        extract($users[$rev['data']['ownerID']]);
    }
    $date['metalu'] = intval($rev['data']['metal'] + $metalu);
    $date['crystalu'] = intval($rev['data']['crystal'] + $crystalu);
    $date['deuteriumu'] = intval($rev['data']['deuterium'] + $deuteriumu);
    $users[$rev['data']['ownerID']] = $date;
}
foreach ($users as $userID => $user) {
    $sql = "INSERT INTO ugml_umod_bug_ress\n\t\t\t (userID, metalu, crystalu, deuteriumu)\n\t\t\tVALUES\n\t\t\t (" . $userID . ", " . $user['metalu'] . ", " . $user['crystalu'] . ", " . $user['deuteriumu'] . ")\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\tmetalu = metalu + " . $user['metalu'] . ",\n\t\t\t\tcrystalu = crystalu + " . $user['crystalu'] . ",\n\t\t\t\tdeuteriumu = deuteriumu + " . $user['deuteriumu'];
    WCF::getDB()->sendQuery($sql);
}
Пример #21
0
 /**
  * Creates the fleet object
  *
  * @param	int		fleet id
  * @param	array	database row
  */
 public function __construct($fleetID = null, $row = null)
 {
     if ($row === null) {
         $sql = "SELECT *\n\t\t\t\t\tFROM ugml_fleets\n\t\t\t\t\tLEFT JOIN ugml_naval_formation_to_fleets\n\t\t    \t\t\tON ugml_fleets.fleet_id = ugml_naval_formation_to_fleets.fleetID\n\t\t    \t\tLEFT JOIN ugml_naval_formation\n\t\t    \t\t\tON ugml_naval_formation_to_fleets.formationID = ugml_naval_formation.formationID\n\t\t    \t\t\tWHERE fleet_id = " . $fleetID;
         $row = WCF::getDB()->getFirstRow($sql);
     }
     parent::__construct($row);
     if ($this->fleet_mess != 1) {
         $this->time = $this->fleet_start_time;
     } else {
         $this->time = $this->fleet_end_time;
     }
     /*$shipTypeDatas = explode(";", $this->fleet_array);
     		foreach($shipTypeDatas as $shipTypeData) {
     			$shipArray = explode(",", $shipTypeData);
     
     			if(empty($shipArray[1]) || !$shipArray[1]) continue;
     
     			$this->fleet[$shipArray[0]] = $shipArray[1];
     		}*/
     $this->fleet = LWUtil::unserialize($this->fleet_array);
     $this->fleetID = $this->fleet_id;
 }
Пример #22
0
 /**
  * Gets the list of results.
  */
 protected function readFleets()
 {
     // get fleets
     $sql = "SELECT *\n\t\t\t\tFROM ugml_archive_fleet\n\t\t\t\tWHERE fleetID IN (" . implode(',', $this->fleetIDs) . ")\n\t\t\t\tORDER BY " . $this->sortField . " " . $this->sortOrder . "\n\t\t\t\tLIMIT " . $this->itemsPerPage . "\n\t\t\t\tOFFSET " . ($this->pageNo - 1) * $this->itemsPerPage;
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->fleets[] = unserialize(LWUtil::unserialize($row['data']));
     }
 }
Пример #23
0
 /**
  * @see	WCF::assignDefaultTemplateVariables()
  */
 protected function assignDefaultTemplateVariables()
 {
     parent::assignDefaultTemplateVariables();
     $dpath = !self::getUser()->dpath ? DEFAULT_SKINPATH : self::getUser()->dpath;
     if (!defined('DPATH')) {
         define('DPATH', $dpath);
     }
     self::getTPL()->assign(array('dpath' => $dpath, 'planets' => Planet::getByUserID(WCF::getUser()->userID, null, true), 'site' => LWUtil::getFileName(), 'args' => LWUtil::getArgsStr()));
 }
Пример #24
0
 /**
  * Updates the information on all servers
  */
 public static function update($userID, $userName, $email)
 {
     $hash = LWUtil::createHash($userID, $userName, $email);
     $args = array('action' => 2, 'userID' => $userID, 'userName' => $userName, 'email' => $email, 'hash' => $hash);
     self::getAccessableServers();
     foreach (self::$servers as $worldID => $server) {
         if ($server['registered']) {
             self::sendRequest($worldID, $args);
         }
     }
 }
Пример #25
0
/*
  This file is part of WOT Game.

    WOT Game is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    WOT Game is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with WOT Game.  If not, see <http://www.gnu.org/licenses/>.
*/
define('INSIDE', true);
$ugamela_root_path = './';
include $ugamela_root_path . 'extension.inc';
include $ugamela_root_path . 'common.' . $phpEx;
$userID = intval($_GET['u']);
if ($userID != 0 && !isset($_COOKIE['dili_link_used' . $userID])) {
    // log
    $sql = "INSERT INTO ugml_dilizium_link\n\t\t\t(userID, registered, `time`,\n\t\t\t ipAddress, userAgent, cookieData)\n\t\t\tVALUES\n\t\t\t(" . $userID . ", 0, " . time() . ",\n\t\t\t INET_ATON('" . escapeString($_SERVER['REMOTE_ADDR']) . "'), '" . escapeString($_SERVER['HTTP_USER_AGENT']) . "', '" . escapeString(LWUtil::serialize($_COOKIE)) . "')";
    WCF::getDB()->sendQuery($sql);
    $diliLinkID = WCF::getDB()->getInsertID();
    setcookie('dili_link_used' . $userID, time(), time() + 60 * 60 * 24 * 365);
    setcookie('dili_link_clicked', $diliLinkID, time() + 60 * 60 * 24 * 365);
}
header("Location: index.htm");
Пример #26
0
 /**
  * Checks if the user requests a planet change.
  */
 protected function checkPlanetChange()
 {
     if (!(isset($_GET['cp']) || isset($_POST['cp'])) || !(isset($_REQUEST['page']) || isset($_REQUEST['form']) || isset($_REQUEST['action']))) {
         return;
     }
     $planetID = isset($_GET['cp']) ? intval(@$_GET['cp']) : intval(@$_POST['cp']);
     $planets = Planet::getByUserID($this->userID);
     if (isset($planets[$planetID])) {
         $this->changePlanet($planetID, $planets[$planetID]->className);
         // now create new request without planet change (forwarding)
         unset($_REQUEST['cp']);
         if (isset($_REQUEST['re'])) {
             unset($_REQUEST['re']);
         }
         $location = LWUtil::getFileName() . '.php' . LWUtil::getArgsStr();
         WCF::getDB()->deleteShutdownUpdates();
         header('Location: ' . $location);
         exit;
     }
 }
 /**
  * Reads the parameters of the specs.
  */
 public function readParametersSpec()
 {
     $specs = Spec::getBySpecType($this->lookForSpecType, false);
     foreach ($specs as $specID => $specObj) {
         if (isset($_REQUEST['spec' . $specID]) && intval($_REQUEST['spec' . $specID])) {
             $this->spec[$specID] = LWUtil::checkInt($_REQUEST['spec' . $specID], 0, $specObj->level);
         }
     }
 }