/** * Index action. * * @return Bengine_Game_Controller_Resource */ protected function indexAction() { Hook::event("ShowResourcesBefore", array($this)); Core::getTPL()->addLoop("data", $this->data); $productFactor = (double) Core::getConfig()->get("PRODUCTION_FACTOR"); $isMoon = (bool) Game::getPlanet()->getData("ismoon"); // Basic prod $basicMetal = $isMoon ? 0 : Core::getOptions()->get("METAL_BASIC_PROD"); Core::getTPL()->assign("basicMetal", fNumber($basicMetal * $productFactor)); $basicSilicon = $isMoon ? 0 : Core::getOptions()->get("SILICON_BASIC_PROD"); Core::getTPL()->assign("basicSilicon", fNumber($basicSilicon * $productFactor)); $basicHydrogen = $isMoon ? 0 : Core::getOptions()->get("HYDROGEN_BASIC_PROD"); Core::getTPL()->assign("basicHydrogen", fNumber($basicHydrogen * $productFactor)); Core::getTPL()->assign("sats", Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID)); if (Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID) > 0) { Core::getTPL()->assign("satsNum", fNumber(Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID))); $solarSatProduction = Game::getPlanet()->getBuildingProd("energy", Bengine_Game_Planet::SOLAR_SAT_ID); Core::getTPL()->assign("satsProd", fNumber($solarSatProduction)); Core::getLang()->assign("prodPerSat", floor($solarSatProduction / Game::getPlanet()->getBuilding(Bengine_Game_Planet::SOLAR_SAT_ID))); Core::getTPL()->assign("solar_satellite_prod", Game::getPlanet()->getData("solar_satellite_prod")); } // Storage capacity Core::getTPL()->assign("storageMetal", fNumber(Game::getPlanet()->getStorage("metal") / 1000) . "k"); Core::getTPL()->assign("storageSilicon", fNumber(Game::getPlanet()->getStorage("silicon") / 1000) . "k"); Core::getTPL()->assign("sotrageHydrogen", fNumber(Game::getPlanet()->getStorage("hydrogen") / 1000) . "k"); // Total prod Core::getTPL()->assign("totalMetal", fNumber(Game::getPlanet()->getProd("metal"))); Core::getTPL()->assign("totalSilicon", fNumber(Game::getPlanet()->getProd("silicon"))); Core::getTPL()->assign("totalHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen"))); Core::getTPL()->assign("totalEnergy", fNumber(Game::getPlanet()->getEnergy())); // Daily prod Core::getTPL()->assign("dailyMetal", fNumber(Game::getPlanet()->getProd("metal") * 24)); Core::getTPL()->assign("dailySilicon", fNumber(Game::getPlanet()->getProd("silicon") * 24)); Core::getTPL()->assign("dailyHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen") * 24)); // Weekly prod Core::getTPL()->assign("weeklyMetal", fNumber(Game::getPlanet()->getProd("metal") * 168)); Core::getTPL()->assign("weeklySilicon", fNumber(Game::getPlanet()->getProd("silicon") * 168)); Core::getTPL()->assign("weeklyHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen") * 168)); // Monthly prod Core::getTPL()->assign("monthlyMetal", fNumber(Game::getPlanet()->getProd("metal") * 720)); Core::getTPL()->assign("monthlySilicon", fNumber(Game::getPlanet()->getProd("silicon") * 720)); Core::getTPL()->assign("monthlyHydrogen", fNumber(Game::getPlanet()->getProd("hydrogen") * 720)); $selectBox = ""; for ($i = 10; $i >= 0; $i--) { $selectBox .= createOption($i * 10, $i * 10, 0); } Core::getTPL()->assign("selectProd", $selectBox); Hook::event("ShowResourcesAfter"); $this->assign("updateAction", BASE_URL . "game/" . SID . "/Resource/Update"); return $this; }
/** * @param bool $asArray * @param string $package * @return array|string */ protected function getTemplatePackages($asArray = true, $package = "none") { $templates = $asArray ? array() : ""; if ($directory = new DirectoryIterator(APP_ROOT_DIR . "app/templates/")) { /* @var DirectoryIterator $dir */ foreach ($directory as $dir) { $dirname = $dir->getFilename(); if (!$dir->isDot() && $dir->isDir() && $dirname != ".svn") { if ($asArray) { $templates[]["template"] = $dirname; } else { $templates .= createOption($dirname, $dirname, $dirname == $package ? 1 : 0); } } } } return $templates; }
} if (!isset($_POST['Submit'])) { $sys->stop(false); $sys->set_layout('blank'); $q = "SELECT id, name FROM bbc_module ORDER BY name"; ?> <form action="" method="POST" enctype="multipart/form-data" target="output"> <table class="table"> <tr> <td width="100px">Template</td> <td><input type=text name="template" value="" class="form-control"></td> </tr> <tr> <td>Module</td> <td><select name="module_id" class="form-control"><?php echo createOption($db->getAssoc($q), ''); ?> </select></td> </tr> <tr> <td>Mail to</td> <td><input type=text name="mail_to" value="" class="form-control"></td> </tr> <tr> <td>Params</td> <td style="height:100px;"> <textarea name="params" class="form-control" rows=3><?php echo "\$params = array(\n\n);"; ?> </textarea> </td>
/** * Generates the select list to chose rank. * * @param array $ranks * @param integer $id * * @return string Select box content */ protected function getRankSelect($ranks, $id) { $return = ""; foreach ($ranks as $key => $value) { if ($id == $key) { $s = 1; } else { $s = 0; } $return .= createOption($key, $value["name"], $s); } return $return; }
/** * Creates the options of all resources. * * @param string $what Pre-selected entry * * @return string Option list */ protected function getResourceSelect($what) { $options = ""; foreach ($this->resources as $key => $value) { if ($what == $key) { $s = 1; } else { $s = 0; } $options .= createOption($key, Core::getLang()->getItem($value), $s); } return $options; }
<?php require_once 'main.php'; handleLanguage(__FILE__); if (isset($_POST) && !empty($_POST['StAction'])) { switch ($_POST['StAction']) { case 'insertMenu': if (!createOption('menu', 'menu_tabs', $_POST['StName'], array('id' => $_POST['StAddress']))) { ErrorHandler::setNotice('menu', MENU_INSERT_ERR, 'error'); } break; case 'removeMenu': if (!removeOption($_POST['IDMenu'], 'id')) { ErrorHandler::setNotice('menu', MENU_REMOVE_ERR, 'error'); } break; case 'editMenu': if (!setOption($_POST['StOldAddress'], array('id' => addslashes($_POST['StAddress']), 'text' => addslashes($_POST['StName'])), 'id')) { ErrorHandler::setNotice('menu', MENU_EDIT_ERR, 'error'); } break; case 'editDepartment': if (!isset($_POST['IDDepartment'])) { ErrorHandler::setNotice('department', NO_EDIT_ID, 'error'); } else { $ArData = array('StDepartment' => f1desk_escape_string($_POST['StDepartment']), 'StDescription' => f1desk_escape_string($_POST['StDescription'])); $ItAffedcted = F1DeskUtils::editDepartment($_POST['IDDepartment'], $ArData); if (!$ItAffedcted) { ErrorHandler::setNotice('department', DEPTO_EDIT_ERROR, 'error'); } else { ErrorHandler::setNotice('department', DEPTO_EDIT_OK, 'ok');
/** * @param integer $cronid * @return Bengine_Admin_Controller_Cronjob */ protected function editAction($cronid) { $result = Core::getQuery()->select("cronjob", array("class", "month", "day", "weekday", "hour", "minute"), "", Core::getDB()->quoteInto("cronid = ?", $cronid)); if ($row = $result->fetchRow()) { if ($this->getParam("edit_cronjob")) { $this->save($cronid, $this->getParam("month"), $this->getParam("day"), $this->getParam("weekday"), $this->getParam("hour"), $this->getParam("minute"), $this->getParam("class")); } $selMin = explode(",", $row["minute"]); $selHour = explode(",", $row["hour"]); $selWD = explode(",", $row["weekday"]); $selDay = explode(",", $row["day"]); $selMon = explode(",", $row["month"]); $minute = ""; $hour = ""; $weekday = ""; $day = ""; $month = ""; $i = 0; while ($i < 60) { $minute .= createOption($i, $i, in_array($i, $selMin) ? 1 : 0); $i += 5; } for ($i = 0; $i < 24; $i++) { $hour .= createOption($i, $i, in_array($i, $selHour) ? 1 : 0); } $wds = array(1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat", 7 => "Sun"); for ($i = 1; $i <= 7; $i++) { $weekday .= createOption($i, $wds[$i], in_array($i, $selWD) ? 1 : 0); } for ($i = 1; $i <= 31; $i++) { $day .= createOption($i, $i, in_array($i, $selDay) ? 1 : 0); } for ($i = 1; $i <= 12; $i++) { $month .= createOption($i, $i, in_array($i, $selMon) ? 1 : 0); } Core::getTPL()->assign("minute", $minute); Core::getTPL()->assign("hour", $hour); Core::getTPL()->assign("weekday", $weekday); Core::getTPL()->assign("day", $day); Core::getTPL()->assign("month", $month); Core::getTPL()->assign("class", $row["class"]); } return $this; }
/** * @param integer $langid * @param integer $groupid * @return Bengine_Admin_Controller_Language */ protected function showfromgroupAction($langid, $groupid) { if ($this->getParam("save_phrases")) { $this->savePhrases($this->getParam("phraseid")); } $langs = array(); $result = Core::getQuery()->select("languages", array("languageid", "title"), "ORDER BY title ASC"); foreach ($result->fetchAll() as $row) { $id = $row["languageid"]; $langs[$id]["title"] = $row["title"]; } $groups = array(); $result = Core::getQuery()->select("phrasesgroups", array("phrasegroupid", "title"), "ORDER BY title ASC"); foreach ($result->fetchAll() as $row) { $id = $row["phrasegroupid"]; $groups[$id]["title"] = $row["title"]; } $phrases = array(); $where = Core::getDB()->quoteInto("p.languageid = ? AND p.phrasegroupid = ?", array($langid, $groupid)); $result = Core::getQuery()->select("phrases p", array("p.phraseid", "p.languageid", "p.phrasegroupid", "p.title", "p.content"), "", $where); foreach ($result->fetchAll() as $row) { $id = $row["phraseid"]; $phrases[$id]["phraseid"] = $id; $phrases[$id]["title"] = $row["title"]; $phrases[$id]["content"] = $row["content"]; $phrases[$id]["delete"] = Link::get("admin/language/deletephrase/" . $langid . "/" . $groupid . "/" . $id . "/", Core::getLanguage()->getItem("Delete")); $phrases[$id]["lang"] = ""; foreach ($langs as $key => $value) { $phrases[$id]["lang"] .= createOption($key, $value["title"], $key == $row["languageid"] ? 1 : 0); } $phrases[$id]["groups"] = ""; foreach ($groups as $key => $value) { $phrases[$id]["groups"] .= createOption($key, $value["title"], $key == $row["phrasegroupid"] ? 1 : 0); } } Core::getTPL()->addLoop("vars", $phrases); return $this; }
/** * Select the mission's target and speed. * * @param integer $galaxy * @param integer $system * @param integer $position * @param string $targetType * @param string $code * @param array $ships * * @return Bengine_Game_Controller_Mission */ protected function selectCoordinates($galaxy, $system, $position, $targetType, $code, $ships) { $this->noAction = true; Core::getTPL()->addHTMLHeaderFile("lib/jquery.countdown.js", "js"); $galaxy = $galaxy > 0 ? (int) $galaxy : Game::getPlanet()->getData("galaxy"); $system = $system > 0 ? (int) $system : Game::getPlanet()->getData("system"); $position = $position > 0 ? (int) $position : Game::getPlanet()->getData("position"); $targetType = $targetType == "tf" ? "tf" : ($targetType == "moon" ? "moon" : "planet"); $data = array("ships" => array()); Core::getQuery()->delete("temp_fleet", "planetid = ?", null, null, array(Core::getUser()->get("curplanet"))); $select = array("u2s.unitid", "u2s.quantity", "d.capicity", "d.speed", "d.consume", "b.name"); $joins = "LEFT JOIN " . PREFIX . "construction b ON (b.buildingid = u2s.unitid)"; $joins .= "LEFT JOIN " . PREFIX . "ship_datasheet d ON (d.unitid = u2s.unitid)"; $result = Core::getQuery()->select("unit2shipyard u2s", $select, $joins, Core::getDB()->quoteInto("b.mode = '3' AND u2s.planetid = ?", Core::getUser()->get("curplanet"))); $capacity = 0; $consumption = 0; $speed = 0; $quantity = 0; foreach ($result->fetchAll() as $row) { $id = $row["unitid"]; $quantity = isset($ships[$id]) ? (int) $ships[$id] : 0; if ($quantity > $row["quantity"]) { $quantity = $row["quantity"]; } if ($quantity > 0) { $id = (int) $id; $capacity += $row["capicity"] * $quantity; $data["ships"][$id]["quantity"] = $quantity; $data["ships"][$id]["name"] = $row["name"]; $data["ships"][$id]["id"] = $id; $shipSpeed = Game::getSpeed($id, $row["speed"]); if ($speed == 0 || $shipSpeed < $speed) { $speed = $shipSpeed; } $consumption += $row["consume"] * $quantity; } } $result->closeCursor(); if (count($data["ships"]) > 0 && $speed > 0) { $distance = Game::getDistance($galaxy, $system, $position); $time = Game::getFlyTime($distance, $speed); Hook::event("MissionSetData", array(&$data, &$quantity, &$consumption, &$speed, &$capacity)); Core::getTPL()->assign(array("galaxy" => $galaxy, "system" => $system, "position" => $position, "targetType" => $targetType, "code" => $code, "oGalaxy" => Game::getPlanet()->getData("galaxy"), "oSystem" => Game::getPlanet()->getData("system"), "oPos" => Game::getPlanet()->getData("position"), "maxspeedVar" => $speed, "distance" => $distance, "capacity_raw" => $capacity, "basicConsumption" => $consumption, "time" => getTimeTerm($time), "maxspeed" => fNumber($speed), "capacity" => fNumber($capacity - Game::getFlyConsumption($consumption, $distance)), "fuel" => fNumber(Game::getFlyConsumption($consumption, $distance)))); $data["consumption"] = $consumption; $data["maxspeed"] = $speed; $data["capacity"] = $capacity; $data = serialize($data); Core::getQuery()->insert("temp_fleet", array("planetid" => Core::getUser()->get("curplanet"), "data" => $data)); // Short speed selection $selectbox = ""; for ($n = 10; $n > 0; $n--) { $selectbox .= createOption($n * 10, $n * 10, 0); } Core::getTPL()->assign("speedFromSelectBox", $selectbox); // Invatations for alliance attack $invitations = array(); $joins = "LEFT JOIN " . PREFIX . "events e ON (e.eventid = fi.eventid)"; $joins .= "LEFT JOIN " . PREFIX . "attack_formation af ON (e.eventid = af.eventid)"; $joins .= "LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = e.destination)"; $joins .= "LEFT JOIN " . PREFIX . "galaxy m ON (m.moonid = e.destination)"; $select = array("af.eventid", "af.name", "af.time", "g.galaxy", "g.system", "g.position", "m.galaxy AS moongala", "m.system AS moonsys", "m.position AS moonpos"); $_result = Core::getQuery()->select("formation_invitation fi", $select, $joins, Core::getDB()->quoteInto("fi.userid = ? AND af.time > '" . TIME . "'", Core::getUser()->get("userid"))); foreach ($_result->fetchAll() as $_row) { $_row["type"] = 0; if (!empty($_row["moongala"]) && !empty($_row["moonsys"]) && !empty($_row["moonpos"])) { $_row["galaxy"] = $_row["moongala"]; $_row["system"] = $_row["moonsys"]; $_row["position"] = $_row["moonpos"]; $_row["type"] = 2; } $_row["time_r"] = $_row["time"] - TIME; $_row["formatted_time"] = getTimeTerm($_row["time_r"]); $invitations[] = $_row; } $_result->closeCursor(); Core::getTPL()->addLoop("invitations", $invitations); // Planet shortlinks $sl = array(); $order = "p.sort_index ASC, p.planetid ASC"; $where = Core::getDB()->quoteInto("p.userid = ? AND p.planetid != ?", array(Core::getUser()->get("userid"), Core::getUser()->get("curplanet"))); $_result = Core::getQuery()->select("planet p", array("p.ismoon", "p.planetname", "g.galaxy", "g.system", "g.position", "gm.galaxy moongala", "gm.system as moonsys", "gm.position as moonpos"), "LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = p.planetid) LEFT JOIN " . PREFIX . "galaxy gm ON (gm.moonid = p.planetid)", $where, $order); foreach ($_result->fetchAll() as $_row) { $sl[] = array("planetname" => $_row["planetname"], "galaxy" => $_row["ismoon"] ? $_row["moongala"] : $_row["galaxy"], "system" => $_row["ismoon"] ? $_row["moonsys"] : $_row["system"], "position" => $_row["ismoon"] ? $_row["moonpos"] : $_row["position"], "type" => $_row["ismoon"] ? 2 : 0); } $_result->closeCursor(); Hook::event("MissionPlanetQuickLinks", array(&$sl)); Core::getTPL()->addLoop("shortlinks", $sl); $this->setTemplate("mission/step2"); } else { Logger::addMessage("NO_SHIPS_SELECTED"); } return $this; }
include_once 'functions.php'; include_once '../includes/configure.php'; include_once '../includes/database_tables.php'; include_once '../includes/functions/database.php'; if (!postNotEmpty('id')) { die('Product Id not given'); } $products_id = $_POST['id']; if (postOK('category')) { $category = explode('/', $_POST['category']); $option = $category[0]; $value = $category[1]; $optionId = optionExists($option); $valueId = valueExists($value); if (!$optionId) { $optionId = createOption($option); } if (!$valueId) { $valueId = createValue($value); } if (!isOptionLinkedToValue($optionId, $valueId)) { createLink($optionId, $valueId); } if (!isProductLinked($optionId, $valueId, $products_id)) { createLinkToProduct($optionId, $valueId, $products_id); } die; } tep_db_connect() or die('Unable to connect to database'); $language_id = getDefaultLanguageID(); $update_array = array('title');
/** * Shows alliance ranking. * * @param integer $type Type of ranking (Fleet, Research, Points) * @param integer $pos Position to start ranking * * @return Bengine_Game_Controller_Ranking */ protected function allianceRanking($type, $pos) { $joins = "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.aid = a.aid)"; $joins .= "LEFT JOIN " . PREFIX . "user u ON (u.userid = u2a.userid)"; $result = Core::getQuery()->select("alliance a", "SUM(u." . $type . ") AS points", $joins, "a.aid > '0'", "", "", "a.aid", "HAVING points >= (points)"); $oPos = $result->rowCount(); $oPos = $oPos <= 0 ? 1 : $oPos; $oPos = ceil($oPos / Core::getOptions()->get("USER_PER_PAGE")); $result->closeCursor(); $result = Core::getQuery()->select("alliance", "aid", "", "aid > '0'"); $pages = ceil($result->rowCount() / Core::getOptions()->get("USER_PER_PAGE")); $result->closeCursor(); if (!is_numeric($pos)) { $pos = $oPos; } else { if ($pos > $pages) { $pos = $pages; } else { if ($pos < 1) { $pos = 1; } } } $ranks = ""; for ($i = 0; $i < $pages; $i++) { $n = $i * Core::getOptions()->get("USER_PER_PAGE") + 1; if ($i + 1 == $pos) { $s = 1; } else { $s = 0; } if ($i + 1 == $oPos) { $c = "ownPosition"; } else { $c = ""; } $ranks .= createOption($i + 1, fNumber($n) . " - " . fNumber($n + Core::getOptions()->get("USER_PER_PAGE") - 1), $s, $c); } Core::getTPL()->assign("rankingSel", $ranks); $order = $this->average ? "average" : "points"; $rank = abs(($pos - 1) * Core::getOptions()->get("USER_PER_PAGE")); $max = Core::getOptions()->get("USER_PER_PAGE"); $select = array("a.aid", "a.name", "a.tag", "a.showhomepage", "a.homepage", "a.open", "COUNT(u2a.userid) AS members", "FLOOR(SUM(u." . $type . ")) AS points", "AVG(u." . $type . ") AS average"); $joins = "LEFT JOIN " . PREFIX . "user2ally u2a ON u2a.aid = a.aid "; $joins .= "LEFT JOIN " . PREFIX . "user u ON u2a.userid = u.userid "; $result = Core::getQuery()->select("alliance a", $select, $joins, "a.aid > '0'", $order . " DESC, members DESC, a.tag ASC", $rank . ", " . $max, "a.aid"); $AllianceList = new Bengine_Game_Alliance_List($result, $rank); Hook::event("ShowRankingAlliance", array($AllianceList)); Core::getTPL()->addLoop("ranking", $AllianceList->getArray()); $this->setTemplate("ranking/ally"); return $this; }
public static function createLanguage($StTitle, $StPath) { return createOption('avail_languages', 'language', $StPath, array('xml:id' => strtolower($StPath), 'title' => $StTitle)); }
/** * Fetches all ships returns them as an option list. * * @param integer $unit Pre-selected ship * * @return string Options */ protected function getShipSelect($unit = 0) { $ret = ""; $sel = array("b.buildingid", "p.content AS name"); $join = "LEFT JOIN " . PREFIX . "phrases p ON (b.name = p.title)"; $result = Core::getQuery()->select("construction b", $sel, $join, Core::getDB()->quoteInto("(b.mode = '3' OR b.mode = '4') AND p.languageid = ?", Core::getUser()->get("languageid"))); foreach ($result->fetchAll() as $row) { $ret .= createOption($row["buildingid"], $row["name"], $row["buildingid"] == $unit ? 1 : 0); } return $ret; }
/** * @param int $groupid * @return string */ protected function getGroupSelect($groupid = 0) { $select = ""; foreach ($this->getConfigGroups() as $group) { $select .= createOption($group["groupid"], $group["groupname"], $group["groupid"] == $groupid ? 1 : 0); } return $select; }