* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
$user = Wootook_Empire_Model_User::getSingleton();
$planet = $user->getCurrentPlanet();
$moon = $planet->getMoon();
$action = isset($_GET['action']) ? $_GET['action'] : null;
if (isset($_POST) && !empty($_POST)) {
$action = isset($_POST['action']) && !empty($_POST['action']) ? $_POST['action'] : $action;
$formKey = isset($_POST['form_key']) && !empty($_POST['form_key']) ? $_POST['form_key'] : null;
if ($formKey == Wootook::getSession('security')->getData('form_key')) {
if ($action == 'rename' && isset($_POST['name']) && !empty($_POST['name'])) {
$planet->setData('name', $_POST['name'])->save();
} else if ($action == 'destroy' && isset($_POST['password']) && !empty($_POST['password']) && isset($_POST['confirm'])) {
if (!$user->checkPassword($_POST['password'])) {
Wootook::getSession('user')
->addError(Wootook::__('Password was not correct.'));
}
try {
$user->getCurrentPlanet()->destroy();
Wootook::getSession('user')
->addSucces(Wootook::__('Planet has been successfully destroyed.'));
} catch (Wootook_Empire_Model_Planet_Exception $e) {
Wootook::getSession('user')
->addError($e->getMessage());
}
}
} else {
Wootook::getSession('user')
->addError(Wootook::__('Invalid security key.'));
}
header('HTTP/1.1 302 Found');
header('Location: ' . Wootook::getUrl(basename(__FILE__)));
exit(0);
} else if ($action == 'rename') {
$layout = new Wootook_Core_Layout();
$layout->load('overview.rename-planet');
echo $layout->render();
exit(0);
} else if ($action == 'destroy') {
$layout = new Wootook_Core_Layout();
$layout->load('overview.destroy-planet');
echo $layout->render();
exit(0);
} else {
includeLang('resources');
includeLang('overview');
$layout = new Wootook_Core_Layout();
$layout->load('overview');
if ($user->getId()) {
$planetCollection = $user->getPlanetCollection();
$planetBlock = $layout->createBlock('core/deprecated', 'planet.view');
$planetBlock->setTemplate('empire/overview/planet/view.phtml');
$planetList = $layout->createBlock('core/concat', 'planet.list');
$planetBlock->planetList = $planetList;
$i = 0;
foreach ($planetCollection as $userPlanet) {
if ($userPlanet->getId() == $planet->getId()) {
continue;
}
/*
* Update planet resources and constructions
*/
Wootook::dispatchEvent('planet.update', array(
'planet' => $userPlanet
));
$userPlanet->save();
if ($userPlanet->getId() != $user->getCurrentPlanet()->getId() && $userPlanet->isPlanet()) {
$id = uniqid();
$block = $layout->createBlock('core/deprecated', "planet.list.item.{$id}");
$block->setTemplate('empire/overview/planet/list/item.phtml');
$block['planet'] = $userPlanet;
$buildingQueue = $userPlanet->getBuildingQueue();
$buildingQueue->rewind();
$currentItem = $buildingQueue->current();
$block['queue_item'] = $currentItem;
$block['even'] = (($i++ % 4) == 3);
$planetList->$id = $block;
}
}
/**
* Missile attack management
* Refactoring needed
* {{{
*/
$iraks_query = doquery("SELECT * FROM {{table}} WHERE owner = '" . $user['id'] . "'", 'iraks');
$Record = 4000;
while ($irak = $iraks_query->fetch(PDO::FETCH_ASSOC)) {
$Record++;
$fpage[$irak['zeit']] = '';
if ($irak['zeit'] > time()) {
$time = $irak['zeit'] - time();
$fpage[$irak['zeit']] .= InsertJavaScriptChronoApplet ("fm", $Record, $time, true);
$planet_start = doquery("SELECT * FROM {{table}} WHERE
galaxy = '" . $irak['galaxy'] . "' AND
system = '" . $irak['system'] . "' AND
planet = '" . $irak['planet'] . "' AND
planet_type = '1'", 'planets');
$user_planet = doquery("SELECT * FROM {{table}} WHERE
galaxy = '" . $irak['galaxy_angreifer'] . "' AND
system = '" . $irak['system_angreifer'] . "' AND
planet = '" . $irak['planet_angreifer'] . "' AND
planet_type = '1'", 'planets', true);
if ($planet_start->rowCount() == 1) {
$planet = mysql_fetch_array($planet_start);
}
$fpage[$irak['zeit']] .= "