function page_start() { global $db, $params, $config; // start stopwatch stopwatch('start'); // get configuration $config = new Config(); // check for cookie // FIXME german string.. if (!sizeof($_COOKIE)) { page_error403('Sie müssen 3rd party cookies erlauben.'); } // start session session_start(); // get request params $params = new Params(); // check for valid session // FIXME german string.. if (!$params->SESSION->player->playerID) { page_error403(sprintf('Sie waren für %d Minuten oder mehr inaktiv.', date("i", ini_get("session.gc_maxlifetime")))); } // connect to database if (!($db = new Db())) { page_dberror(); } // init I18n $params->SESSION->player->init_i18n(); }
function tribePlayerList_getContent($caveID, $tribe) { global $db, $no_resource_flag, $config, $params; $no_resource_flag = 1; $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'tribePlayerList.ihtml'); tmpl_set($template, 'tribe', $tribe); $query = 'SELECT r.rank, r.playerID AS link, r.name, r.average AS points, r.caves, r.religion, r.fame, p.awards ' . ' FROM Ranking r' . ' LEFT JOIN Player p' . ' ON p.playerID = r.playerID' . ' WHERE p.tribe LIKE "' . $tribe . '"' . ' ORDER BY r.rank ASC'; if (!($dbresult = $db->query($query))) { page_dberror(); } while ($row = $dbresult->nextRow(MYSQL_ASSOC)) { $i++; tmpl_iterate($template, 'ROWS'); $row['link'] = "main.php?modus=" . PLAYER_DETAIL . "&detailID=" . $row['link'] . "&caveID=" . $caveID; if (!empty($row['awards'])) { $tmp = explode('|', $row['awards']); $awards = array(); foreach ($tmp as $tag) { $awards[] = array('tag' => $tag, 'award_modus' => AWARD_DETAIL); } $row['award'] = $awards; } if ($i % 2) { tmpl_set($template, 'ROWS/ROW_ALTERNATE', $row); } else { tmpl_set($template, 'ROWS/ROW', $row); } } return tmpl_parse($template); }
function tribe_getContent($caveID, $tag) { global $db, $no_resource_flag, $config, $params; $no_resource_flag = 1; if (!($r = $db->query("SELECT t.*, p.playerID, p.name AS leaderName " . "FROM Tribe t " . "LEFT JOIN Player p " . "ON p.playerID = t.leaderID " . "WHERE t.tag LIKE '{$tag}'"))) { page_dberror(); } if (!($row = $r->nextRow(MYSQL_ASSOC))) { page_dberror(); } $JuniorAdmin = $targetPlayer = new Player(getPlayerByID($row['juniorLeaderID'])); $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'tribeDetail.ihtml'); $row["urltag"] = urlencode(unhtmlentities($tag)); $row["playerList_modus"] = TRIBE_PLAYER_LIST; $row["playerDetail_modus"] = PLAYER_DETAIL; $row["tribeHistory_modus"] = TRIBE_HISTORY; $row["tribeRelationList_modus"] = TRIBE_RELATION_LIST; if (!empty($row['awards'])) { $tmp = explode('|', $row['awards']); $awards = array(); foreach ($tmp as $tag) { $awards[] = array('tag' => $tag, 'award_modus' => AWARD_DETAIL); } $row['award'] = $awards; } foreach ($row as $k => $v) { if (!$v) { $row[$k] = "k.A."; } } $row['juniorLeaderName'] = $JuniorAdmin->name; $row['juniorLeaderID'] = $JuniorAdmin->playerID; tmpl_set($template, 'DETAILS', $row); return tmpl_parse($template); }
function getFarmschutz($playerID) { global $db, $params; $query = "SELECT round( sum( r.average ) / count( r.average ) / 1.5 ) AS grenze, p.farmschutz AS protection, r2.average AS punkte FROM ranking r LEFT JOIN player p ON p.playerID = " . $playerID . " LEFT JOIN ranking r2 ON p.playerID = r2.playerID GROUP BY p.playerID"; if (!($result = $db->query($query))) { page_dberror(); } if (!($myrow = $result->nextRow(MYSQL_ASSOC))) { // page_dberror(); return "Noch nicht berechenbar"; } $row['farmschutz'] = $myrow[protection] . "% - " . $myrow[grenze]; // if ($playerID == $params->SESSION->user['playerID']) { // eigenes Profil if ($myrow[grenze] > $myrow[punkte]) { // spieler unter grenze $pkmin = round($myrow[punkte] / 100 * $myrow[protection]); $pkmax = round($myrow[punkte] * 100 / $myrow[protection]); if ($pkmax > 10000) { $pkmax = 10000; } if ($pkmin < 0) { $pkmin = 0; } $row['farmschutz'] = $row['farmschutz'] . "<br><b>Punktegrenzen: " . $pkmin . " - " . $pkmax . "</b>"; } else { $row['farmschutz'] = $row['farmschutz'] . "<br>Spieler liegt über der Noobgrenze"; } // } return $row['farmschutz']; }
function player_getContent($caveID, $playerID) { global $db, $no_resource_flag, $config, $params; $no_resource_flag = 1; if (!($r = $db->query("SELECT * FROM Player WHERE playerID = '{$playerID}'"))) { page_dberror(); } if (!($row = $r->nextRow(MYSQL_ASSOC))) { page_dberror(); } $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'playerDetail.ihtml'); if ($row['avatar']) { // FIXME: should be configurable tmpl_set($template, 'DETAILS/AVATAR_IMG/avatar', $row['avatar']); tmpl_set($template, 'DETAILS/AVATAR_IMG/width', 120); tmpl_set($template, 'DETAILS/AVATAR_IMG/height', 120); } if (!empty($row['awards'])) { $tmp = explode('|', $row['awards']); $awards = array(); foreach ($tmp as $tag) { $awards[] = array('tag' => $tag, 'award_modus' => AWARD_DETAIL); } $row['award'] = $awards; } unset($row['awards']); foreach ($row as $k => $v) { if (!$v) { $row[$k] = _('k.A.'); } } $row['mail_modus'] = NEW_MESSAGE; $row['mail_receiver'] = urlencode($row['name']); $row['caveID'] = $caveID; $timediff = getUgaAggaTimeDiff(time_fromDatetime($row['created']), time()); $row['age'] = 18 + $timediff['year']; tmpl_set($template, 'DETAILS', $row); // ADDED by chris--- for rank_history $row['playerID'] = $playerID; // show player's caves $caves = getCaves($playerID); if ($caves) { tmpl_set($template, '/DETAILS/CAVES', $caves); } //show bodycount // Keinen Bodycount fuers erste.... Nebrot //$body_count = $row['body_count']; //tmpl_set($template, '/DETAILS/BODYCOUNT/body_count', $body_count); // show player's history $history = Player::getHistory($db, $playerID); if (sizeof($history)) { tmpl_set($template, '/DETAILS/HISTORY/ENTRY', $history); } else { tmpl_set($template, '/DETAILS/HISTORY/NOENTRIES/iterate', ''); } return tmpl_parse($template); }
function initMovements() { global $db, $unitTypeList; // collect caveIDs $caveIDs = $this->_collectCaveIDs(); // prepare query $sql = $db->prepare("SELECT * FROM " . EVENT_MOVEMENT_TABLE . " WHERE caveID IN (" . implode(', ', $caveIDs) . ")"); // get records if (!$sql->execute()) { return page_dberror(); } // iterate through movements $this->movements = array(); while ($movement = $sql->fetch(PDO::FETCH_ASSOC)) { $this->movements[] = $movement; } }
function profile_show($db_login, $feedback = NULL) { global $params; // get login data $playerData = profile_getPlayerData($db_login); if (!$playerData) { page_dberror(); } // open template $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'profile.ihtml'); // show message if ($feedback) { tmpl_set($template, '/MESSAGE/message', $feedback); } // show the profile's data profile_fillUserData($template, $playerData); return tmpl_parse($template); }
function tribeLeaderDetermination_getContent($playerID, $tribe, $data) { global $no_resource_flag, $governmentList, $leaderDeterminationList, $db, $config, $params; $no_resource_flag = 1; if (!($governmentData = government_getGovernmentForTribe($tribe, $db))) { page_dberror(); } $handlers[1] = "leaderDetermination_infoHandler"; $handlers[2] = "leaderDetermination_electionHandler"; $templates[1] = "leaderDeterminationInfo.ihtml"; $templates[2] = "leaderDeterminationElection.ihtml"; $id = $governmentList[$governmentData['governmentID']]['leaderDeterminationID']; $template = tmpl_open($params->SESSION->player->getTemplatePath() . $templates[$id]); if (!($templateData = $handlers[$id]($playerID, $tribe, $governmentData, $data))) { page_dberror(); } tmpl_set($template, 'LEADERDETERMINATION', $templateData); return tmpl_parse($template); }
function profile_deleteAccount($playerID, $data) { global $config, $db, $no_resource_flag, $params; $no_resource_flag = 1; // try to connect to login db $db_login = new DB($config->DB_LOGIN_HOST, $config->DB_LOGIN_USER, $config->DB_LOGIN_PWD, $config->DB_LOGIN_NAME); if (!$db_login) { page_dberror(); } // proccess form data if (isset($data->confirm)) { // the only necessary field $success = profile_processDeleteAccount($playerID, $db_login); $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'deleteResponse.ihtml'); if ($success) { session_destroy(); tmpl_set($template, 'message', _('Ihr Account wurde zur Löschung vorgemerkt. Sie sind jetzt ausgeloggt und können das Fenster schließen.')); tmpl_set($template, 'link', LOGIN_PATH); } else { tmpl_set($template, 'message', _('Das löschen Ihres Accounts ist fehlgeschlagen. Bitte wenden Sie sich an das Support Team.')); tmpl_set($template, 'link', "ugastart.php"); } return tmpl_parse($template); } // Show confirmation request $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'dialog.ihtml'); tmpl_set($template, 'message', _('Möchten Sie Ihren Account unwiderruflich löschen? Ihre gesamten Spieldaten gehen verloren, ein neuerliches einloggen als dieser Spieler ist nicht möglich. <br /> Allerdings steht Ihnen die Emailadresse anschließend für eine Neuanmeldung zur Verfügung. <br /> Beachten Sie, daß Ihre Höhle noch für einige Zeit nach der Löschung für andere Spieler sichtbar ist, da die Löschungen aus der Datenbank nur einmal am Tag vorgenommen werden.')); tmpl_set($template, 'BUTTON/formname', 'confirm'); tmpl_set($template, 'BUTTON/text', _('Account löschen')); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', DELETE_ACCOUNT); tmpl_set($template, 'BUTTON/ARGUMENT/arg_name', 'confirm'); tmpl_set($template, 'BUTTON/ARGUMENT/arg_value', 1); tmpl_iterate($template, 'BUTTON'); tmpl_set($template, 'BUTTON/formname', 'cancel'); tmpl_set($template, 'BUTTON/text', _('Abbrechen')); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', USER_PROFILE); return tmpl_parse($template); }
function profile_deleteAccount($playerID, $data) { global $config, $db, $no_resource_flag, $params; $no_resource_flag = 1; // try to connect to login db $db_login = new DB($config->DB_LOGIN_HOST, $config->DB_LOGIN_USER, $config->DB_LOGIN_PWD, $config->DB_LOGIN_NAME); if (!$db_login) { page_dberror(); } // proccess form data if (isset($data->confirm)) { // the only necessary field $success = profile_processDeleteAccount($playerID, $db_login); $template = @tmpl_open('./templates/' . $config->template_paths[$params->SESSION->user['template']] . '/deleteResponse.ihtml'); if ($success) { session_destroy(); tmpl_set($template, 'message', "Ihr Account wurde zur Löschung vorgemerkt. " . "Sie sind jetzt ausgeloggt und können das Fenster " . "Schließen."); tmpl_set($template, 'link', "http://tntchris.dyndns.org/ugaagga/"); } else { tmpl_set($template, 'message', "Das löschen Ihres Accounts ist fehlgeschlagen." . "Bitte wenden Sie sich an das Support Team."); tmpl_set($template, 'link', "ugastart.php"); } return tmpl_parse($template); } // Show confirmation request $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/dialog.ihtml"); tmpl_set($template, 'message', "Möchten Sie Ihren Account unwiderruflich löschen? " . "Ihre gesamten Spieldaten gehen verloren, ein neuerliches " . "einloggen als dieser Spieler ist nicht möglich. " . "<p> Allerdings steht Ihnen die Emailadresse anschließend " . "für eine Neuanmeldung zur Verfügung." . "<p> Beachten Sie, daß Ihre Siedlung noch für einige " . "Zeit nach der Löschung für ander Spieler sichtbar ist, " . "da die Löschungen aus der Datenbank nur einmal am Tag " . "vorgenommen werden."); tmpl_set($template, 'BUTTON/formname', 'confirm'); tmpl_set($template, 'BUTTON/text', 'Account löschen'); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', DELETE_ACCOUNT); tmpl_set($template, 'BUTTON/ARGUMENT/arg_name', 'confirm'); tmpl_set($template, 'BUTTON/ARGUMENT/arg_value', 1); tmpl_iterate($template, 'BUTTON'); tmpl_set($template, 'BUTTON/formname', 'cancel'); tmpl_set($template, 'BUTTON/text', 'Abbrechen'); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', USER_PROFILE); return tmpl_parse($template); }
function tribeRelationList_getContent($tribe) { global $db, $no_resource_flag, $config, $params, $relationList; $no_resource_flag = 1; $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'tribeRelationList.ihtml'); tmpl_set($template, 'tribe', $tribe); $relations = relation_getRelationsForTribe($tribe, $db); if (!$relations) { page_dberror(); } foreach ($relations['own'] as $target => $relationData) { tmpl_iterate($template, 'ROWS'); $data = array("tribe" => $relationData['tribe_target'], "relationTo" => $relationList[$relationData['relationType']]['name'], "relationFrom" => $relations['other'][$target] ? $relationList[$relations['other'][$target]['relationType']]['name'] : $relationList[0]['name'], "link" => "main.php?modus=" . TRIBE_DETAIL . "&tribe=" . $relationData['tribe_target']); $relations['other'][$target] = 0; // mark this relation if ($i++ % 2) { tmpl_set($template, 'ROWS/ROW_ALTERNATE', $data); } else { tmpl_set($template, 'ROWS/ROW', $data); } } foreach ($relations['other'] as $target => $relationData) { if (!$relationData) { // already printed out this relation continue; } tmpl_iterate($template, 'ROWS'); $data = array("tribe" => $relationData['tribe'], "relationFrom" => $relationList[$relationData['relationType']]['name'], "relationTo" => $relationList[0]['name'], "link" => "main.php?modus=" . TRIBE_DETAIL . "&tribe=" . $relationData['tribe']); if ($i++ % 2) { tmpl_set($template, 'ROWS/ROW_ALTERNATE', $data); } else { tmpl_set($template, 'ROWS/ROW', $data); } } return tmpl_parse($template); }
function tribeDelete_getContent($playerID, $tribe, $confirm) { global $no_resource_flag; $no_resource_flag = 1; // try to connect to login db if (!tribe_isLeader($playerID, $tribe)) { page_dberror(); } // proccess form data if ($confirm) { // the only necessary field $success = tribe_deleteTribe($tribe); $template = tmpl_open($_SESSION['player']->getTemplatePath() . 'tribeDeleteResponse.ihtml'); if ($success) { tmpl_set($template, 'message', _('Der Stamm wurde aufgelöst. Alle Mitglieder sind jetzt wieder stammeslos. Das Stammesmenü funktioniert bei allen erst nach dem nächsten einloggen wieder.')); } else { tmpl_set($template, 'message', _('Das löschen des Stammes ist fehlgeschlagen. Bitte wenden Sie sich an das Support Team.')); } return tmpl_parse($template); } // Show confirmation request $template = tmpl_open($_SESSION['player']->getTemplatePath() . 'dialog.ihtml'); tmpl_set($template, 'message', _('Möchten Sie diesen Stamm unwiderruflich löschen? Ihre gesamten Stammesdaten gehen verloren.')); tmpl_set($template, 'BUTTON/formname', 'confirm'); tmpl_set($template, 'BUTTON/text', _('Stamm auflösen')); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', TRIBE_DELETE); tmpl_set($template, 'BUTTON/ARGUMENT/arg_name', 'confirm'); tmpl_set($template, 'BUTTON/ARGUMENT/arg_value', 1); tmpl_iterate($template, 'BUTTON'); tmpl_set($template, 'BUTTON/formname', 'cancel'); tmpl_set($template, 'BUTTON/text', _('Abbrechen')); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', TRIBE_ADMIN); return tmpl_parse($template); }
function tribeDelete_getContent($playerID, $tribe, $confirm) { global $config, $db, $no_resource_flag, $params; $no_resource_flag = 1; // try to connect to login db if (!tribe_isLeader($playerID, $tribe, $db)) { page_dberror(); } // proccess form data if ($confirm) { // the only necessary field $success = tribe_deleteTribe($tribe, $db); $template = @tmpl_open('./templates/' . $config->template_paths[$params->SESSION->user['template']] . '/tribeDeleteResponse.ihtml'); if ($success) { tmpl_set($template, 'message', "Der Clan wurde aufgelöst. Alle Mitglieder sind jetzt " . "wieder Clanlos. Das Clanmenü funktioniert bei allen erst " . "nach dem nächsten einloggen wieder."); } else { tmpl_set($template, 'message', "Das löschen des Clans ist fehlgeschlagen." . "Bitte wenden Sie sich an das Support Team."); } return tmpl_parse($template); } // Show confirmation request $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/dialog.ihtml"); tmpl_set($template, 'message', "Möchten Sie diesen Clan unwiderruflich löschen? " . "Ihre gesamten Clandaten gehen verloren. "); tmpl_set($template, 'BUTTON/formname', 'confirm'); tmpl_set($template, 'BUTTON/text', 'Clan löschen'); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', TRIBE_DELETE); tmpl_set($template, 'BUTTON/ARGUMENT/arg_name', 'confirm'); tmpl_set($template, 'BUTTON/ARGUMENT/arg_value', 1); tmpl_iterate($template, 'BUTTON'); tmpl_set($template, 'BUTTON/formname', 'cancel'); tmpl_set($template, 'BUTTON/text', 'Abbrechen'); tmpl_set($template, 'BUTTON/modus_name', 'modus'); tmpl_set($template, 'BUTTON/modus_value', TRIBE_ADMIN); return tmpl_parse($template); }
session_id(md5(microtime() . posix_getpid())); } else { session_id(md5(microtime() . rand())); } // start session session_start(); $params = new Params(); $config = new Config(); // keine Variablen angegeben if (!$params->POST->id || !$params->POST->userID) { page_error403(__FILE__ . ":" . __LINE__ . ": Fehlende Loginvariablen."); } // connect to database $db = new Db(); if (!$db) { page_dberror(); } //check user from Session-table with id $query = "SELECT * FROM Session " . "WHERE s_id = '{$params->POST->id}' " . "AND playerID = '{$params->POST->userID}'"; $dbresult = $db->query($query); if (!$dbresult || $dbresult->isEmpty()) { page_error403(__FILE__ . ":" . __LINE__ . ": Falsche SessionID."); } $session_row = $dbresult->nextRow(MYSQL_ASSOC); // sessionstart sollte nur einmal augerufen werden können $query = "UPDATE `Session` SET s_id_used = 1 " . "WHERE s_id = '{$params->POST->id}' " . "AND playerID = '{$params->POST->userID}' " . "AND s_id_used = 0"; $dbresult = $db->query($query); if (!$dbresult || !$db->affected_rows() == 1) { page_error403(__FILE__ . ":" . __LINE__ . ": Ungültige SessionID."); } // get player by playerID for session
function tribeAdmin_getContent($playerID, $tag) { global $config, $params, $db, $no_resource_flag, $relationList, $governmentList, $wonderTypeList; $no_resource_flag = 1; // check, for security reasons! if (!tribe_isLeaderOrJuniorLeader($playerID, $tag, $db)) { page_dberror(); } $isLeader = tribe_isLeader($playerID, $tag, $db); $isLeader ? $leaderID = $playerID : ($leaderID = tribe_getLeaderID($tag, $db)); !$isLeader ? $juniorLeaderID = $playerID : ($juniorLeaderID = tribe_getJuniorLeaderID($tag, $db)); //get Member Data if (!($memberData = tribe_getAllMembers($tag, $db))) { page_dberror(); } // get government if (!($tribeGovernment = government_getGovernmentForTribe($tag, $db))) { page_dberror(); } $tribeGovernment['name'] = $governmentList[$tribeGovernment['governmentID']]['name']; //seems to be leader, but not in tribe if ($isLeader && !is_array($memberData[$leaderID])) { tribe_unmakeLeaderJuniorLeader($leaderID, $tag, $db); } //seems to be juniorleader, but not in tribe if (!$isLeader && !is_array($memberData[$leaderID])) { tribe_unmakeJuniorLeader($leaderID, $tag, $db); } // messages $messageText = array(-27 => _('Das Stammeswunder wurde gewirkt.'), -26 => _('Das Stammeswunder konnte nicht gewirkt werden.'), -25 => _('Ihr Kriegsanteil ist nicht hoch genug, um den Gegner zur Aufgabe zu zwingen.'), -24 => _('Nur in der Demokratie sind solche Wahlen möglich.'), -23 => _('Sie sind schon Stammesanführer.'), -22 => _('Dieser Spieler ist nicht im Stamm.'), -21 => _('Dies darf nur der Stammesanführer tun.'), -20 => _('Es ist kein gleicher Vorkriegsgegner vorhanden.'), -19 => _('Die Beziehung des anderen Stammes erlauben kein Kriegsbündniss.'), -18 => _('Unsere aktuelle Beziehung erlaubt kein Kriegsbündniss.'), -17 => _('Der Stamm hat noch nicht genug Mitglieder um Beziehungen eingehen zu dürfen'), -16 => _('Die Stammeszugehörigkeit hat sich erst vor kurzem geändert. Warten Sie, bis die Stammeszugehörigkeit geändert werden darf.'), -15 => _('Ihr Stamm befindet sich im Krieg. Sie dürfen derzeit nicht austreten.'), -14 => _('Die Beziehung wurde nicht geändert, weil der ausgewählte Beziehungstyp bereits eingestellt ist.'), -13 => _('Eure Untergebenen weigern sich, diese Beziehung gegenüber einem so großen Stamm einzugehen.'), -12 => _('Eure Untergebenen weigern sich, diese Beziehung gegenüber einem so kleinen Stamm einzugehen.'), -11 => sprintf(_('Die Moral des Gegners ist noch nicht schlecht genug. Sie muss unter %d sinken. Eine weitere Chance besteht, wenn die Mitgliederzahl des gegnerischen Stammes um 30 Prozent gesunken ist. Das Verhältnis Eurer Rankingpunkte zu denen des Gegners muss sich seit Kriegsbeginn verdoppelt haben.'), RELATION_FORCE_MORAL_THRESHOLD), -10 => _('Die zu ändernde Beziehung wurde nicht gefunden!'), -9 => _('Die Regierung konnte nicht geändert werden, weil sie erst vor kurzem geändert wurde.'), -8 => _('Die Regierung konnte aufgrund eines Fehlers nicht aktualisiert werden'), -7 => _('Zu sich selber kann man keine Beziehungen aufnehmen!'), -6 => _('Den Stamm gibt es nicht!'), -5 => _('Von der derzeitigen Beziehung kann nicht direkt auf die ausgewählte Beziehungsart gewechselt werden.'), -4 => _('Die Mindestlaufzeit läuft noch!'), -3 => _('Die Beziehung konnte aufgrund eines Fehlers nicht aktualisiert werden.'), -2 => _('Der Spieler ist ebenfalls Stammesanführer und kann nicht gekickt werden. Er kann nur freiwillig gehen.'), -1 => _('Der Spieler konnte nicht gekickt werden!'), 0 => _('Die Daten wurden erfolgreich aktualisiert.'), 1 => _('Der Spieler wurde erfolgreich gekickt.'), 2 => _('Die Daten konnten gar nicht oder zumindest nicht vollständig aktualisiert werden.'), 3 => _('Die Beziehung wurde umgestellt.'), 4 => _('Die Regierung wurde geändert.')); // proccess form data if ($params->POST->relationData && $params->POST->forceSurrender) { $messageID = relation_forceSurrender($tag, $params->POST->relationData, $db); } else { if ($params->POST->relationData && !$params->POST->forceSurrender) { $messageID = relation_processRelationUpdate($tag, $params->POST->relationData, $db); } else { if ($params->POST->data) { $messageID = tribe_processAdminUpdate($playerID, $tag, $params->POST->data, $db); } else { if ($params->POST->kick) { if (!$isLeader) { $messageID = -21; } else { $messageID = tribe_processKickMember($params->POST->playerID, $tag, $db); } } else { if ($params->POST->governmentData) { if (!$isLeader) { $messageID = -21; } else { $messageID = government_processGovernmentUpdate($tag, $params->POST->governmentData, $db); } } else { if ($params->POST->juniorLeader) { $newleadership = array(0 => $leaderID, 1 => $params->POST->juniorLeader[juniorLeaderID]); if (!$isLeader) { $messageID = -21; } elseif ($newleadership[1] && !is_array($memberData[$newleadership[1]])) { $messageID = -22; } elseif ($newleadership[1] == $newleadership[0]) { $messageID = -23; } elseif ($tribeGovernment['governmentID'] != 2) { $messageID = -24; } elseif (tribe_ChangeLeader($tag, $newleadership, $leaderID, $juniorLeaderID, $db)) { $messageID = 0; //success } else { $messageID = 2; //something went wrong } } } } } } } // get the tribe data if (!($tribeData = tribe_getTribeByTag($tag, $db))) { page_dberror(); } $tribeData['description'] = str_replace('<br />', '', $tribeData['description']); // get relations if (!($tribeRelations = relation_getRelationsForTribe($tag, $db))) { page_dberror(); } // get current wars $tribeWarTargets = relation_getWarTargetsAndFame($tag, $db); $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'tribeAdmin.ihtml'); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // show the profile's data tmpl_set($template, 'modus_name', 'modus'); tmpl_set($template, 'modus_value', TRIBE_ADMIN); ////////////// user data ////////////////////// tmpl_set($template, 'DATA_GROUP/heading', _('Stammesdaten')); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/name', _('Tag')); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/value', $tribeData['tag']); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INFO'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', _('Name')); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'name'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $tribeData['name']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '20'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '90'); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', _('Password')); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'password'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $tribeData['password']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '15'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '15'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/name', _('Beschreibung')); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/dataentry', 'description'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/value', $tribeData['description']); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/cols', '25'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/rows', '8'); ////////////// junioLeader //////////////////// if ($isLeader && $tribeGovernment['governmentID'] == 2) { tmpl_set($template, 'JUNIORADMIN', array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'caption' => _('Wählen'), 'SELECTOR' => array('dataarray' => 'juniorLeader', 'dataentry' => 'juniorLeaderID'))); foreach ($memberData as $playerID => $playerData) { if ($leaderID == $playerID) { continue; } tmpl_iterate($template, 'JUNIORADMIN/SELECTOR/OPTION'); tmpl_set($template, 'JUNIORADMIN/SELECTOR/OPTION', array("value" => $playerID, 'selected' => $tribeData['juniorLeaderID'] == $playerID ? "selected" : "", 'text' => $playerData['name'])); } tmpl_iterate($template, 'JUNIORADMIN/SELECTOR/OPTION'); tmpl_set($template, 'JUNIORADMIN/SELECTOR/OPTION', array("value" => 0, 'selected' => $tribeData['juniorLeaderID'] == 0 ? "selected" : "", 'text' => _('keinen Stellvertreter wählen'))); } ////////////// government ///////////////////// if ($isLeader) { if ($tribeGovernment['isChangeable']) { tmpl_set($template, 'GOVERNMENT', array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'caption' => _('Ändern'), 'SELECTOR' => array('dataarray' => 'governmentData', 'dataentry' => 'governmentID'))); foreach ($governmentList as $governmentID => $typeData) { tmpl_iterate($template, 'GOVERNMENT/SELECTOR/OPTION'); tmpl_set($template, 'GOVERNMENT/SELECTOR/OPTION', array('value' => $governmentID, 'selected' => $governmentID == $tribeGovernment['governmentID'] ? "selected" : "", 'text' => $typeData['name'])); } } else { tmpl_set($template, 'GOVERNMENT_INFO', array('name' => $tribeGovernment['name'], 'duration' => $tribeGovernment['time'])); } } ////////////// tribewonder ////////////////////// /* init_Wonders(); $tribewonderExists = False; for ($i = 0; $i < sizeof($wonderTypeList); $i++){ $wonder = $wonderTypeList[$i]; if ($wonder->groupID<>3) continue; $tribewonderExists = True; tmpl_iterate($template,'TRIBEWONDER/OPTION'); tmpl_set($template, 'TRIBEWONDER/OPTION', array('text' => $wonder->name, 'value' => $i)); }; if ($tribewonderExists) { tmpl_set($template, 'TRIBEWONDER/caption',_('erwirken')); tmpl_set($template, 'TRIBEWONDER/modus_name',"modus"); tmpl_set($template, 'TRIBEWONDER/modus', TRIBE_ADMIN); }; */ ////////////// relations ////////////////////// tmpl_set($template, 'RELATION_NEW', array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'dataarray' => "relationData", 'dataentry' => "tag", 'value' => $params->POST->relationData['tag'], 'size' => 8, 'maxlength' => 8, 'caption' => _('Ändern'))); tmpl_set($template, 'RELATION_NEW/SELECTOR', array('dataarray' => "relationData", 'dataentry' => "relationID")); foreach ($relationList as $relationID => $typeData) { tmpl_iterate($template, 'RELATION_NEW/SELECTOR/OPTION'); tmpl_set($template, 'RELATION_NEW/SELECTOR/OPTION', array('value' => $relationID, 'selected' => $relationID == $params->POST->relationData['relationID'] ? "selected" : "", 'text' => $typeData['name'])); } // existing relations towards other clans ////////////////// foreach ($tribeRelations['own'] as $target => $targetData) { if (!$targetData['changeable']) { // relation, that couldn't be changed at the moment tmpl_iterate($template, 'RELATION_INFO'); $relation_info = array('tag' => $target, 'relation' => $relationList[$targetData['relationType']]['name'], 'duration' => $targetData['time'], 'their_relation' => $tribeRelations['other'][$target] ? $relationList[$tribeRelations['other'][$target]['relationType']]['name'] : $relationList[0]['name']); // war? if ($tribeWarTargets[$target]) { $relation_info["WAR/fame_own"] = $tribeWarTargets[$target]["fame_own"]; $relation_info["WAR/fame_target"] = $tribeWarTargets[$target]["fame_target"]; $relation_info["WAR/percent_actual"] = $tribeWarTargets[$target]["percent_actual"]; } tmpl_set($template, 'RELATION_INFO', $relation_info); // check, if it is possible to get or loose fame, and display if true /*if ($targetData['attackerReceivesFame'] || $targetData['defenderReceivesFame'] || $tribeRelations['other'][$target]['attackerReceivesFame'] || $tribeRelations['other'][$target]['defenderReceivesFame']) { tmpl_set($template, 'RELATION_INFO/FAME', array('tribe_fame' => $targetData['fame'], 'target_fame' => $tribeRelations['other'][$target]['fame'], 'tribe_moral' => $targetData['moral'], 'target_moral' => $tribeRelations['other'][$target]['moral'])); }*/ continue; } else { // relation, that is changeable tmpl_iterate($template, 'RELATION'); $relation = array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'dataarray' => "relationData", 'dataentry' => "tag", 'value' => $target, 'target_points' => $targetData['target_rankingPoints'], 'tribe_points' => $targetData['tribe_rankingPoints'], 'their_relation' => $tribeRelations['other'][$target] ? $relationList[$tribeRelations['other'][$target]['relationType']]['name'] : $relationList[0]['name'], 'caption' => _('Ändern')); // war? if ($tribeWarTargets[$target]) { $wartarget = $tribeWarTargets[$target]; $relation["WAR/fame_own"] = $wartarget["fame_own"]; $relation["WAR/fame_target"] = $wartarget["fame_target"]; $relation["WAR/percent_actual"] = $wartarget["percent_actual"]; if ($wartarget["isForcedSurrenderTheoreticallyPossible"]) { $relation["WAR/FORCEDSURRENDER/percent_estimated"] = $wartarget["percent_estimated"]; if ($wartarget["isForcedSurrenderPracticallyPossible"]) { $relation["WAR/FORCEDSURRENDER/class"] = "enough"; } else { if ($target["isForcedSurrenderPracticallyPossibleForTarget"]) { $relation["WAR/FORCEDSURRENDER/class"] = "less"; } else { $relation["WAR/FORCEDSURRENDER/class"] = ""; } } } } tmpl_set($template, 'RELATION', $relation); tmpl_set($template, 'RELATION/SELECTOR', array('dataarray' => "relationData", 'dataentry' => "relationID")); // check, if it is possible to get or loose fame, and display if true /*if ($targetData['attackerReceivesFame'] || $targetData['defenderReceivesFame'] || $tribeRelations['other'][$target]['attackerReceivesFame'] || $tribeRelations['other'][$target]['defenderReceivesFame']) { tmpl_set($template, 'RELATION/FAME', array('tribe_fame' => $targetData['fame'], 'target_fame' => $tribeRelations['other'][$target]['fame'], 'tribe_moral' => $targetData['moral'], 'target_moral' => $tribeRelations['other'][$target]['moral'])); }*/ foreach ($relationList as $relationType => $typeData) { // get relation of target to tr. if ($tribeRelations['other'][$tag]) { $relationTypeTowardsTribe = $tribeRelations['other'][$tag]['relationType']; } // check, if switch to relationType is possible if ($relationTypeTowardsTribe != $relationType && $relationType != $targetData['relationType'] && !relation_isPossible($relationType, $targetData['relationType'])) { continue; } tmpl_iterate($template, 'RELATION/SELECTOR/OPTION'); tmpl_set($template, 'RELATION/SELECTOR/OPTION', array('value' => $relationType, 'selected' => $relationType == $targetData['relationType'] ? "selected" : "", 'text' => $typeData['name'])); } } } ////////////// memberliste //////////////////// foreach ($memberData as $playerID => $playerData) { if ($isLeader) { tmpl_iterate($template, 'MEMBERADMIN'); tmpl_set($template, 'MEMBERADMIN', array("name" => $playerData['name'], "lastAction" => $playerData['lastAction'], "player_link" => "modus=" . PLAYER_DETAIL . "&detailID={$playerID}", "player_kick_link" => "modus=" . TRIBE_ADMIN . "&playerID={$playerID}&kick=1")); } else { tmpl_iterate($template, 'MEMBERJUNIORADMIN'); tmpl_set($template, 'MEMBERJUNIORADMIN', array("name" => $playerData['name'], "lastAction" => $playerData['lastAction'], "player_link" => "modus=" . PLAYER_DETAIL . "&detailID={$playerID}")); } } ////////////// delete tribe //////////////////// if ($isLeader) { tmpl_set($template, 'DELETE/modus_name', 'modus'); tmpl_set($template, 'DELETE/modus', TRIBE_DELETE); tmpl_set($template, 'DELETE/heading', _('Stamm auflösen')); tmpl_set($template, 'DELETE/text', _('Den gesamten Stamm auflösen. Alle Mitglieder sind danach stammeslos.')); tmpl_set($template, 'DELETE/caption', sprintf(_('%s auflösen'), $tribe)); } return tmpl_parse($template); }
function profile_getContent($playerID) { global $config, $params, $db, $no_resource_flag; $no_resource_flag = 1; // try to connect to login db if (!($db_login = new DB($config->DB_LOGIN_HOST, $config->DB_LOGIN_USER, $config->DB_LOGIN_PWD, $config->DB_LOGIN_NAME))) { page_dberror(); } // messages $messageText = array(0 => "Die Daten wurden erfolgreich aktualisiert.", 1 => "Das Paßwort stimmt nicht mit der Wiederholung überein.", 2 => "Die Daten konnten gar nicht oder zumindest nicht vollständig " . "aktualisiert werden.", 3 => "Das Passwort muss mindestens 4 Zeichen lang sein!", 5 => "Die Priorität muß zwischen 0 und 10 liegen!", 6 => "Dein Clan ist im Krieg und du kannst darum den Urlaubsmodus nicht aktivieren!", 7 => "Du warst erst kürzlich im Urlaub und mußt mindestens die gleiche Zeitspanne warten!", 8 => "Fehler beim Aktivieren des Urlaubsmodus", 10 => "Dieser Clanname ist nicht erlaubt!"); // proccess form data if ($params->POST->data || $params->POST->password) { // insert necessary fields $messageID = profile_processUpdate($playerID, $params->POST->data, $params->POST->password, $params->POST->cave_prio, $db, $db_login); } // get the user data if (!($playerData = profile_getPlayerData($playerID, $db, $db_login))) { page_dberror(); } $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/profile.ihtml"); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); page_refreshUserData(); } // show the profile's data tmpl_set($template, 'modus_name', 'modus'); tmpl_set($template, 'modus_value', USER_PROFILE); ////////////// user data ////////////////////// tmpl_set($template, 'DATA_GROUP/heading', 'Benutzerdaten'); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/name', 'Name'); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/value', $playerData['game']['name']); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INFO'); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/name', 'Email'); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/value', $playerData['game']['email']); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INFO'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Email 2'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'email2'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $playerData['game']['email2']); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Geschlecht (m/w)'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'sex'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $playerData['game']['sex']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '1'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '1'); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Herkunft'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'origin'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $playerData['game']['origin']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '30'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '30'); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Alter'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'age'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $playerData['game']['age']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '2'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '2'); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'ICQ#'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'icq'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $playerData['game']['icq']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '15'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '15'); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Avatar URL (max ' . AVATAR_X . 'x' . AVATAR_Y . ')'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'avatar'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $playerData['game']['avatar']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '30'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '90'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/name', 'Beschreibung'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/dataentry', 'description'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/value', $playerData['game']['description']); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/cols', '25'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/rows', '8'); // ADDED by chris--- for cave sorting ////////////// cave sorting ////////////////////// $meineHoehlen = getCaves($playerID); // only show this if there is more than one cave if (sizeof($meineHoehlen) > 1) { tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', 'Siedlungspriorität (1=hoch, 10=niedrig)'); $i = 0; $select = array(); foreach ($meineHoehlen as $key => $value) { tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', lib_shorten_html($value['name'], 17)); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'cave_prio'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', $key); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $meineHoehlen[$key][priority]); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '2'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '2'); if ($i + 1 < sizeof($meineHoehlen)) { tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); } $i++; } } // end if // --------------------------------------------------------------------------------------------- ////////////// template ////////////////////// /* DISABLED tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', 'Template auswählen'); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/name', 'Wählen Sie ein Template (erneutes einloggen erforderlich!):'); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataentry', 'template'); $selector = array(); foreach ($config->template_paths as $key => $value){ if ($key == $params->SESSION->user['template']) array_push($selector, array('value' => $key, 'selected' => "selected", 'text' => $value)); else array_push($selector, array('value' => $key, 'text' => $value)); } tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/SELECTOR', $selector); */ ////////////// show_unqualified ////////////////////// tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', "Erweiterte Ansicht"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/name', "Sollen auch Einheiten, Erweiterungen etc. angezeigt werden, die noch nicht gebaut werden können:"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataentry', 'show_unqualified'); $selector = array(); $selector[0] = array('value' => 0, 'selected' => $params->SESSION->user['show_unqualified'] == 0 ? "selected" : "", 'text' => "nein"); $selector[1] = array('value' => 1, 'selected' => $params->SESSION->user['show_unqualified'] == 1 ? "selected" : "", 'text' => "ja"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/SELECTOR', $selector); // ADDED by chris--- for urlaubsmod: ////////////// urlaub ////////////////////// tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', "Urlaubsmodus"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/name', "Soll der Urlaubsmodus eingeschaltet werden:<br>ACHTUNG: Lest vorher die Hilfe unten genau durch!"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataentry', 'urlaub'); $selector = array(); $selector[0] = array('value' => 0, 'selected' => $params->SESSION->user['urlaub'] == 0 ? "selected" : "", 'text' => "nein"); $selector[1] = array('value' => 1, 'selected' => $params->SESSION->user['urlaub'] == 1 ? "selected" : "", 'text' => "ja"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/SELECTOR', $selector); // ADDED by chris--- for ticker: ////////////// show_ticker ////////////////////// tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', "Nachrichten Ticker"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/name', "Soll der Nachrichten Ticker angezeigt werden:"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataentry', 'show_ticker'); $selector = array(); $selector[0] = array('value' => 0, 'selected' => $params->SESSION->user['show_ticker'] == 0 ? "selected" : "", 'text' => "nein"); $selector[1] = array('value' => 1, 'selected' => $params->SESSION->user['show_ticker'] == 1 ? "selected" : "", 'text' => "ja"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/SELECTOR', $selector); // ADDED by chris--- for returns: ////////////// show_returns ////////////////////// tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', "Rückkehrbewegungen"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/name', "Sollen Rückkehrbewegungen im Terminkalender angezeigt werden:"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/dataentry', 'show_returns'); $selector = array(); $selector[0] = array('value' => 0, 'selected' => $params->SESSION->user['show_returns'] == 0 ? "selected" : "", 'text' => "nein"); $selector[1] = array('value' => 1, 'selected' => $params->SESSION->user['show_returns'] == 1 ? "selected" : "", 'text' => "ja"); tmpl_set($template, 'DATA_GROUP/ENTRY_SELECTION/SELECTOR', $selector); ////////////// gfxpath ////////////////////// tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', "Grafikpack"); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Pfad zum Grafikpack (default:' . DEFAULT_GFX_PATH . '):'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'gfxpath'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $playerData['game']['gfxpath']); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '30'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '200'); ////////////// password ////////////////////// tmpl_iterate($template, 'DATA_GROUP'); tmpl_set($template, 'DATA_GROUP/heading', 'Passwort Änderung'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/name', 'Neues Passwort'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/dataarray', 'password'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/dataentry', 'password1'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/size', '15'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/maxlength', '15'); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT_PWD'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/name', 'Neues Passwort Wiederholung'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/dataarray', 'password'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/dataentry', 'password2'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/size', '15'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT_PWD/maxlength', '15'); ////////////// delete account //////////////////// tmpl_set($template, 'DELETE/modus_name', 'modus'); tmpl_set($template, 'DELETE/modus', DELETE_ACCOUNT); tmpl_set($template, 'DELETE/heading', 'Account Löschen'); tmpl_set($template, 'DELETE/text', 'Ich habe keine Lust mehr!'); return tmpl_parse($template); }
function defenseSystem_getDefenseSystemDetail($caveID, &$details) { global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db; // messages $messageText = array(0 => "Der Arbeitsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Arbeitsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 5 => "Das Gebäude wurde erfolgreich abgerissen", 6 => "Das Gebäude konnte nicht abgerissen werden", 7 => "Sie haben von der Sorte gar keine Gebäude"); // proccess a cancel-order request if (isset($params->POST->eventID)) { $messageID = defenseSystem_processOrderCancel($params->POST->eventID, $caveID, $db); } // proccess a tore down or new order request if (isset($params->POST->breakDownConfirm)) { $messageID = defenseSystem_breakDown($params->POST->defenseSystemID, $caveID, $details, $db); $reload = 1; } else { if (isset($params->POST->defenseSystemID)) { check_timestamp($params->POST->tstamp); $messageID = defenseSystem_processOrder($params->POST->defenseSystemID, $caveID, $details, $db); $reload = 1; } } if ($reload) { // this isn't that elegant... $r = getCaveSecure($caveID, $params->SESSION->user['playerID']); if ($r->isEmpty()) { page_dberror(); } $details = $r->nextRow(); } $queue = defenseSystem_getDefenseSystemQueueForCave($params->SESSION->user['playerID'], $caveID); $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/fortification.ihtml"); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // Show the defenseSystem table for ($i = 0; $i < sizeof($defenseSystemTypeList); $i++) { $notenough = FALSE; $defenseSystem = $defenseSystemTypeList[$i]; // the current building $maxLevel = round(eval('return ' . formula_parseToPHP("{$defenseSystem->maxLevel};", '$details'))); $result = rules_checkDependencies($defenseSystem, $details); // if all requirements are met but the maxLevel is 0, // treat it like a non-buildable if ($maxLevel <= 0 && $result === TRUE) { $result = $details[$defenseSystem->dbFieldName] ? 'Max. Stufe: 0' : FALSE; } if ($result === TRUE) { tmpl_iterate($template, 'DEFENSESYSTEM'); tmpl_set($template, "DEFENSESYSTEM/alternate", $count++ % 2 ? "alternate" : ""); tmpl_set($template, 'DEFENSESYSTEM', array('name' => $defenseSystem->name, 'dbFieldName' => $defenseSystem->dbFieldName, 'defenseSystemID' => $i, 'modus' => DEFENSESYSTEM_DETAIL, 'caveID' => $caveID, 'maxlevel' => $maxLevel, 'size' => "0" + $details[$defenseSystem->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($defenseSystem->productionTimeFunction . ";", '$details')) * DEFENSESYSTEM_TIME_BASE_FACTOR))); // iterate ressourcecosts foreach ($defenseSystem->resourceProductionCost as $resourceID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/RESSOURCECOST"); if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName); tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name); } } // iterate unitcosts foreach ($defenseSystem->unitProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/UNITCOST"); if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/UNITCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/UNITCOST/name", $unitTypeList[$unitID]->name); } } // iterate buildingcosts foreach ($defenseSystem->buildingProductionCost as $buildingID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST"); if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name); } } // iterate externalcosts foreach ($defenseSystem->externalProductionCost as $externalID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST"); if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name); } } // show the break down link if ($details[$defenseSystem->dbFieldName]) { tmpl_set($template, 'DEFENSESYSTEM/BREAK_DOWN_LINK', array('action' => DEFENSESYSTEM_BREAK_DOWN, 'defenseSystemID' => $defenseSystem->defenseSystemID, 'caveID' => $caveID)); } // show the improvement link ?! if ($queue) { tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK_NO/message', "Ausbau im Gange"); } else { if ($notenough && $maxLevel > $details[$defenseSystem->dbFieldName]) { tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK_NO/message', ""); } else { if ($maxLevel > $details[$defenseSystem->dbFieldName]) { tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK', array('action' => DEFENSESYSTEM, 'defenseSystemID' => $defenseSystem->defenseSystemID, 'caveID' => $caveID, 'tstamp' => "" . time())); } else { tmpl_set($template, '/DEFENSESYSTEM/BUILD_LINK_NO/message', "Max. Stufe"); } } } } else { if ($details[$defenseSystem->dbFieldName]) { tmpl_iterate($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM'); tmpl_set($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM', array('alternate' => $count_unwanted++ % 2 ? "" : "alternate", 'modus' => DEFENSESYSTEM_DETAIL, 'defenseSystemID' => $i, 'size' => $details[$defenseSystem->dbFieldName], 'dbFieldName' => $defenseSystem->dbFieldName, 'name' => $defenseSystem->name, 'action' => DEFENSESYSTEM_BREAK_DOWN)); if ($result !== FALSE) { tmpl_set($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM/dependencies', $result); } } else { if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$defenseSystem->nodocumentation) { tmpl_iterate($template, '/UNQUALIFIEDDEFENSESYSTEMS/DEFENSESYSTEM'); tmpl_set($template, '/UNQUALIFIEDDEFENSESYSTEMS/DEFENSESYSTEM', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => DEFENSESYSTEM_DETAIL, 'defenseSystemID' => $i, 'name' => $defenseSystem->name, 'dbFieldName' => $defenseSystem->dbFieldName, 'dependencies' => $result)); } } } } // Show the building queue if ($queue) { $row = $queue->nextRow(); tmpl_set($template, 'DEFENSESYSTEM_QUEUE', array('name' => $defenseSystemTypeList[$row['defenseSystemID']]->name, 'size' => $details[$defenseSystemTypeList[$row['defenseSystemID']]->dbFieldName] + 1, 'finish' => date("d.m.Y H:i:s", time_timestampToTime($row['event_end'])), 'action' => DEFENSESYSTEM, 'eventID' => $row['event_defenseSystemID'], 'caveID' => $caveID)); } return tmpl_parse($template); }
function science_getScienceDetail($caveID, &$details) { global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $scienceTypeList, $config, $params, $db; // messages $messageText = array(0 => _('Der Forschungsauftrag wurde erfolgreich gestoppt.'), 1 => _('Es konnte kein Forschungsauftrag gestoppt werden.'), 2 => _('Der Auftrag konnte nicht erteilt werden. Es fehlen die notwendigen Voraussetzungen.'), 3 => _('Der Auftrag wurde erteilt'), 4 => _('Dieses Wissen wird schon in einer anderen Höhle erforscht.'), 5 => _('Es wird gerade in einer anderen Höhle Wissen erforscht, dass dieses Wissen ausschließt.')); // proccess a cancel-order request if (isset($params->POST->eventID)) { $messageID = science_processOrderCancel($params->POST->eventID, $caveID, $db); } if (isset($params->POST->scienceID)) { $messageID = science_processOrder($params->POST->scienceID, $caveID, $params->SESSION->player->playerID, $details, $db); $r = getCaveSecure($caveID, $params->SESSION->player->playerID); if ($r->isEmpty()) { page_dberror(); } $details = $r->nextRow(); } $queue = science_getScienceQueueForCave($params->SESSION->player->playerID, $caveID); $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'science.ihtml'); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // Show the science table for ($i = 0; $i < sizeof($scienceTypeList); $i++) { $science = $scienceTypeList[$i]; // the current science $maxLevel = round(eval('return ' . formula_parseToPHP("{$science->maxLevel};", '$details'))); $notenough = FALSE; $result = rules_checkDependencies($science, $details); if ($result === TRUE) { tmpl_iterate($template, 'SCIENCE'); tmpl_set($template, "SCIENCE/alternate", $count++ % 2 ? "alternate" : ""); tmpl_set($template, 'SCIENCE', array('dbFieldName' => $science->dbFieldName, 'name' => $science->name, 'scienceID' => $i, 'modus' => SCIENCE_DETAIL, 'caveID' => $caveID, 'size' => "0" + $details[$science->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($science->productionTimeFunction . ";", '$details')) * SCIENCE_TIME_BASE_FACTOR))); // iterate ressourcecosts foreach ($science->resourceProductionCost as $resourceID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "SCIENCE/RESSOURCECOST"); if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) { tmpl_set($template, "SCIENCE/RESSOURCECOST/ENOUGH/value", $cost); } else { tmpl_set($template, "SCIENCE/RESSOURCECOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "SCIENCE/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName); tmpl_set($template, "SCIENCE/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name); } } // iterate unitcosts foreach ($science->unitProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "SCIENCE/UNITCOST"); if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "SCIENCE/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "SCIENCE/UNITCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "SCIENCE/UNITCOST/name", $unitTypeList[$unitID]->name); } } // iterate buildingcosts foreach ($science->buildingProductionCost as $buildingID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST"); if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name); } } // iterate externalcosts foreach ($science->externalProductionCost as $externalID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST"); if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name); } } // show the science link ?! if ($queue) { tmpl_set($template, 'SCIENCE/RESEARCH_LINK_NO/message', _('Erforschung im Gange')); } else { if ($notenough && $maxLevel > $details[$science->dbFieldName]) { tmpl_set($template, 'SCIENCE/RESEARCH_LINK_NO/message', _('Zu wenig Rohstoffe')); } else { if ($maxLevel > $details[$science->dbFieldName]) { tmpl_set($template, 'SCIENCE/RESEARCH_LINK', array('action' => SCIENCE, 'scienceID' => $science->scienceID, 'caveID' => $caveID)); } else { tmpl_set($template, '/SCIENCE/RESEARCH_LINK_NO/message', _('Max. Stufe')); } } } } else { if ($result !== FALSE && !$science->nodocumentation) { tmpl_iterate($template, '/UNQUALIFIEDSCIENCES/SCIENCE'); tmpl_set($template, '/UNQUALIFIEDSCIENCES/SCIENCE', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => SCIENCE_DETAIL, 'scienceID' => $science->scienceID, 'caveID' => $caveID, 'dbFieldName' => $science->dbFieldName, 'name' => $science->name, 'dependencies' => $result)); } } } // Show the science queue if ($queue) { // display the science queue $row = $queue->nextRow(); tmpl_set($template, 'SCIENCE_QUEUE', array('name' => $scienceTypeList[$row['scienceID']]->name, 'size' => $details[$scienceTypeList[$row['scienceID']]->dbFieldName] + 1, 'finish' => time_formatDatetime($row['end']), 'action' => SCIENCE, 'eventID' => $row['event_scienceID'], 'caveID' => $caveID)); } tmpl_set($template, "rules_path", RULES_PATH); return tmpl_parse($template); }
function wonder_getWonderContent($playerID, $caveID, &$details) { global $buildingTypeList, $resourceTypeList, $wonderTypeList, $unitTypeList, $config, $params, $db; // messages $messageText = array(-3 => "Die angegebene Zielhöhle wurde nicht gefunden.", -2 => "Das Wunder kann nicht auf die angegbene Zielhöhle erwirkt " . "werden.", -1 => "Es ist ein Fehler bei der Verarbeitung Ihrer Anfrage aufgetreten. " . "Bitte wenden Sie sich an die Administratoren.", 0 => "Das Wunder kann nicht erwirkt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 1 => "Das Erflehen des Wunders scheint Erfolg zu haben.", 2 => "Die Götter haben Ihr Flehen nicht erhört! Die " . "eingesetzten Opfergaben sind natürlich dennoch verloren. " . "Mehr Glück beim nächsten Mal!"); if (isset($params->POST->wonderID)) { $messageID = wonder_processOrder($playerID, $params->POST->wonderID, $caveID, $params->POST->xCoord, $params->POST->yCoord, $details, $db); $reload = 1; } if ($reload) { // this isn't that elegant... $r = getCaveSecure($caveID, $params->SESSION->player->playerID); if ($r->isEmpty()) { page_dberror(); } $details = $r->nextRow(); } $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'wonder.ihtml'); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // Show the wonder table for ($i = 0; $i < sizeof($wonderTypeList); $i++) { $wonder = $wonderTypeList[$i]; // the current wonder $result = rules_checkDependencies($wonder, $details); if ($result === TRUE && !$wonder->nodocumentation) { tmpl_iterate($template, 'WONDER'); tmpl_set($template, "WONDER/alternate", $count++ % 2 ? "alternate" : ""); tmpl_set($template, 'WONDER', array('name' => $wonder->name, 'wonderID' => $i, 'modus' => WONDER_DETAIL, 'caveID' => $caveID)); // iterate ressourcecosts foreach ($wonder->resourceProductionCost as $resourceID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "WONDER/RESSOURCECOST"); if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) { tmpl_set($template, "WONDER/RESSOURCECOST/ENOUGH/value", $cost); } else { tmpl_set($template, "WONDER/RESSOURCECOST/LESS/value", $cost); } tmpl_set($template, "WONDER/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName); tmpl_set($template, "WONDER/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name); } } // iterate unitcosts foreach ($wonder->unitProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "WONDER/UNITCOST"); if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "WONDER/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "WONDER/UNITCOST/LESS/value", $cost); } tmpl_set($template, "WONDER/UNITCOST/name", $unitTypeList[$unitID]->name); } } foreach ($wonder->buildingProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "WONDER/UNITCOST"); if ($details[$buildingTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "WONDER/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "WONDER/UNITCOST/LESS/value", $cost); } tmpl_set($template, "WONDER/UNITCOST/name", $buildingTypeList[$unitID]->name); } } // show the wonder link tmpl_set($template, 'WONDER/BUILD_LINK', array('action' => WONDER, 'wonderID' => $wonder->wonderID, 'caveID' => $caveID)); if ($wonder->target != "same") { // show input field of target cave iff wonder may be cast on another cave tmpl_iterate($template, 'WONDER/BUILD_LINK/TARGET'); } } else { if ($result !== FALSE && !$wonder->nodocumentation) { tmpl_iterate($template, '/UNQUALIFIEDWONDERS/WONDER'); tmpl_set($template, '/UNQUALIFIEDWONDERS/WONDER', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => WONDER_DETAIL, 'wonderID' => $i, 'caveID' => $caveID, 'name' => $wonder->name, 'dependencies' => $result)); } } } tmpl_set($template, "rules_path", RULES_PATH); return tmpl_parse($template); }
function tribeAdmin_getContent($playerID, $tag) { global $config, $params, $db, $no_resource_flag, $relationList, $governmentList; $no_resource_flag = 1; // check, for sercurity reasons! if (!tribe_isLeader($playerID, $tag, $db)) { page_dberror(); } // messages $messageText = array(-13 => "Die Beziehung wurde nicht geändert, weil der ausgewählte " . "Beziehungstyp bereits eingestellt ist.", -12 => "Eure Untergebenen weigern sich, " . "diese Beziehung gegenüber einem so kleinen Clan einzugehen.", -11 => "Die Moral des Gegners ist noch nicht schlecht genug. Sie muss unter " . RELATION_FORCE_MORAL_THRESHOLD . " sinken. Eine weitere Chance besteht, " . "wenn die Mitglierzahl des gegnerischen Clans um 30 Prozent gesunken ist.", "Euren Gunsten verschoben. Das Verhältnis Eurer Rankingpunkte zu " . "denen des Gegners muss sich seit Kriegsbeginn verdoppelt haben.", -10 => "Die zu ändernde Beziehung wurde nicht gefunden!", -9 => "Die Regierung konnte nicht geändert werden, weil sie erst " . "vor kurzem geändert wurde.", -8 => "Die Regierung konnte aufgrund eines Fehlers nicht aktualisiert " . "werden", -7 => "Zu sich selber kann man keine Beziehungen aufhehmen!", -6 => "Den Clan gibt es nicht!", -5 => "Von der derzeititgen Beziehung kann nicht dirket auf die " . "ausgewählte Beziehungsart gewechselt werden.", -4 => "Die Mindestlaufzeit läuft noch!", -3 => "Die Beziehung konnte aufgrund eines Fehlers nicht aktualisiert " . "werden.", -2 => "Der Spieler ist ebenfalls Clananführer und kann nicht " . "gekickt werden. Er kann nur freiwillig gehen.", -1 => "Der Spieler konnte nicht gekickt werden!", 0 => "Die Daten wurden erfolgreich aktualisiert.", 1 => "Der Spieler wurde erfolgreich gekickt.", 2 => "Die Daten konnten gar nicht oder zumindest nicht vollständig " . "aktualisiert werden.", 3 => "Die Beziehung wurde umgestellt.", 4 => "Die Regierung wurde geändert."); // proccess form data if ($params->POST->forceRelationData) { $messageID = relation_processForceRelation($tag, $params->POST->forceRelationData, $db); } else { if ($params->POST->relationData) { $messageID = relation_processRelationUpdate($tag, $params->POST->relationData, $db); } else { if ($params->POST->data) { $messageID = tribe_processAdminUpdate($playerID, $tag, $params->POST->data, $db); } else { if ($params->POST->kick) { $messageID = tribe_processKickMember($params->POST->playerID, $tag, $db); } else { if ($params->POST->governmentData) { $messageID = government_processGovernmentUpdate($tag, $params->POST->governmentData, $db); } } } } } // get the tribe data if (!($tribeData = tribe_getTribeByTag($tag, $db))) { page_dberror(); } $tribeData[description] = str_replace("<br />", "", $tribeData[description]); if (!($memberData = tribe_getAllMembers($tag, $db))) { page_dberror(); } // get government if (!($tribeGovernment = government_getGovernmentForTribe($tag, $db))) { page_dberror(); } $tribeGovernment[name] = $governmentList[$tribeGovernment[governmentID]][name]; // get relations if (!($tribeRelations = relation_getRelationsForTribe($tag, $db))) { page_dberror(); } $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/tribeAdmin.ihtml"); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // show the profile's data tmpl_set($template, 'modus_name', 'modus'); tmpl_set($template, 'modus_value', TRIBE_ADMIN); ////////////// user data ////////////////////// tmpl_set($template, 'DATA_GROUP/heading', 'Clandaten'); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/name', 'Tag'); tmpl_set($template, 'DATA_GROUP/ENTRY_INFO/value', $tribeData[tag]); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INFO'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Name'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'name'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $tribeData[name]); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '20'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '90'); tmpl_iterate($template, 'DATA_GROUP/ENTRY_INPUT'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/name', 'Password'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/dataentry', 'password'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/value', $tribeData[password]); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/size', '15'); tmpl_set($template, 'DATA_GROUP/ENTRY_INPUT/maxlength', '15'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/name', 'Beschreibung'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/dataarray', 'data'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/dataentry', 'description'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/value', $tribeData[description]); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/cols', '25'); tmpl_set($template, 'DATA_GROUP/ENTRY_MEMO/rows', '8'); ////////////// government ///////////////////// if ($tribeGovernment[isChangeable]) { tmpl_set($template, 'GOVERNMENT', array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'caption' => "Ändern", 'SELECTOR' => array('dataarray' => 'governmentData', 'dataentry' => 'governmentID'))); foreach ($governmentList as $governmentID => $typeData) { tmpl_iterate($template, 'GOVERNMENT/SELECTOR/OPTION'); tmpl_set($template, 'GOVERNMENT/SELECTOR/OPTION', array('value' => $governmentID, 'selected' => $governmentID == $tribeGovernment[governmentID] ? "selected" : "", 'text' => $typeData[name])); } } else { tmpl_set($template, 'GOVERNMENT_INFO', array('name' => $tribeGovernment[name], 'duration' => $tribeGovernment[time])); } ////////////// relations ////////////////////// tmpl_set($template, 'RELATION_NEW', array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'dataarray' => "relationData", 'dataentry' => "tag", 'value' => $params->POST->relationData['tag'], 'size' => 8, 'maxlength' => 8, 'caption' => "Ändern")); tmpl_set($template, 'RELATION_NEW/SELECTOR', array('dataarray' => "relationData", 'dataentry' => "relationID")); foreach ($relationList as $relationID => $typeData) { tmpl_iterate($template, 'RELATION_NEW/SELECTOR/OPTION'); tmpl_set($template, 'RELATION_NEW/SELECTOR/OPTION', array('value' => $relationID, 'selected' => $relationID == $params->POST->relationData[relationID] ? "selected" : "", 'text' => $typeData[name])); } // existing relations towards other clans ////////////////// foreach ($tribeRelations[own] as $target => $targetData) { if (!$targetData[changeable]) { // relation, that couldn't be changed at the moment tmpl_iterate($template, 'RELATION_INFO'); tmpl_set($template, 'RELATION_INFO', array('tag' => $target, 'relation' => $relationList[$targetData[relationType]][name], 'duration' => $targetData[time], 'their_relation' => $tribeRelations[other][$target] ? $relationList[$tribeRelations[other][$target][relationType]][name] : $relationList[0][name])); continue; } else { // relation, that is changeable tmpl_iterate($template, 'RELATION'); tmpl_set($template, 'RELATION', array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'dataarray' => "relationData", 'dataentry' => "tag", 'value' => $target, 'target_points' => $targetData[target_rankingPoints], 'tribe_points' => $targetData[tribe_rankingPoints], 'their_relation' => $tribeRelations[other][$target] ? $relationList[$tribeRelations[other][$target][relationType]][name] : $relationList[0][name], 'caption' => "Ändern")); tmpl_set($template, 'RELATION/SELECTOR', array('dataarray' => "relationData", 'dataentry' => "relationID")); // check, if it is possible to get or loose fame, and display if true if ($targetData[attackerReceivesFame] || $targetData[defenderReceivesFame] || $tribeRelations[other][$target][attackerReceivesFame] || $tribeRelations[other][$target][defenderReceivesFame]) { tmpl_set($template, 'RELATION/FAME', array('tribe_fame' => $targetData[fame], 'target_fame' => $tribeRelations[other][$target][fame], 'tribe_moral' => $targetData[moral], 'target_moral' => $tribeRelations[other][$target][moral])); } foreach ($relationList as $relationType => $typeData) { if ($tribeRelations[other][$tag]) { // get relation of target to tr. $relationTypeTowardsTribe = $tribeRelations[other][$tag][relationType]; } // check, if switch to relationType is possible if ($relationTypeTowardsTribe != $relationType && $relationType != $targetData[relationType] && !relation_isPossible($relationType, $targetData[relationType])) { continue; } tmpl_iterate($template, 'RELATION/SELECTOR/OPTION'); tmpl_set($template, 'RELATION/SELECTOR/OPTION', array('value' => $relationType, 'selected' => $relationType == $targetData[relationType] ? "selected" : "", 'text' => $typeData[name])); } if ($targetData[relationType] == RELATION_FORCE_FROM_ID) { tmpl_set($template, 'RELATION/FORCE', array('modus_name' => "modus", 'modus' => TRIBE_ADMIN, 'dataarray' => forceRelationData, 'dataentry' => "tag", 'value' => $target, 'caption' => "Kapitulation von {$target} erzwingen")); } } } ////////////// memberliste //////////////////// foreach ($memberData as $playerID => $playerData) { tmpl_iterate($template, 'MEMBER'); tmpl_set($template, 'MEMBER', array("name" => $playerData['name'], "lastAction" => $playerData['lastAction'], "player_link" => "modus=" . PLAYER_DETAIL . "&detailID={$playerID}", "player_kick_link" => "modus=" . TRIBE_ADMIN . "&playerID={$playerID}&kick=1")); } ////////////// delete tribe //////////////////// tmpl_set($template, 'DELETE/modus_name', 'modus'); tmpl_set($template, 'DELETE/modus', TRIBE_DELETE); tmpl_set($template, 'DELETE/heading', 'Clan auflösen'); tmpl_set($template, 'DELETE/text', 'Den gesamten Clan auflösen. Alle Mitglieder sind danach Clanlos.'); tmpl_set($template, 'DELETE/caption', "{$tribe} auflösen"); return tmpl_parse($template); }
function questionnaire_getPresent($caveID, &$meineHoehlen, $presentID) { global $config, $db, $params, $defenseSystemTypeList, $resourceTypeList, $unitTypeList; $query = "SELECT * FROM `Questionnaire_presents` WHERE presentID = " . intval($presentID); if (!($result = $db->query($query))) { return "Datenbankfehler: " . mysql_error(); } $row = $result->nextRow(MYSQL_ASSOC); if (!questionnaire_timeIsRight($row)) { return ""Dieses Geschenk kann ich euch nicht anbieten, Häuptling!""; } // genügend Schnecken? $myaccount = questionnaire_getCredits($params->SESSION->user['questionCredits']); $price = questionnaire_getCredits($row['credits']); /* if ($myaccount['credits'] < $price['credits'] || $myaccount['COPPER']['copper'] < $price['COPPER']['copper'] || $myaccount['SILVER']['silver'] < $price['SILVER']['silver'] || $myaccount['GOLD']['gold'] < $price['GOLD']['gold']) return ""Ihr habt nicht die passenden Schnecken, Häuptling!""; */ if ($myaccount['credits'] < $price['credits']) { return ""Ihr habt nicht die passenden Schnecken, Häuptling!""; } // Preis abziehen if (!questionnaire_addCredits(-$row['credits'])) { return ""Ich bin mit dem Schnecken abzählen durcheinander " . "gekommen, Häuptling! Versucht es noch einmal!""; } // Geschenk überreichen $presents = array(); $caveData = $meineHoehlen[$caveID]; foreach ($defenseSystemTypeList as $external) { if ($row[$external->dbFieldName] > 0) { $dbField = $external->dbFieldName; $maxLevel = round(eval('return ' . formula_parseToPHP("{$external->maxLevel};", '$caveData'))); $presents[] = "{$dbField} = LEAST(GREATEST({$maxLevel}, {$dbField}), {$dbField} + " . $row[$external->dbFieldName] . ")"; } } foreach ($resourceTypeList as $resource) { if ($row[$resource->dbFieldName] > 0) { $dbField = $resource->dbFieldName; $maxLevel = round(eval('return ' . formula_parseToPHP("{$resource->maxLevel};", '$caveData'))); $presents[] = "{$dbField} = LEAST({$maxLevel}, {$dbField} + " . $row[$resource->dbFieldName] . ")"; } } foreach ($unitTypeList as $unit) { if ($row[$unit->dbFieldName] > 0) { $dbField = $unit->dbFieldName; $presents[] = "{$dbField} = {$dbField} + " . $row[$unit->dbFieldName]; } } if (sizeof($presents)) { // UPDATE Cave $query = "UPDATE Cave SET " . implode(", ", $presents) . " WHERE caveID = {$caveID} AND playerID = " . $params->SESSION->user['playerID']; $update_result = $db->query($query); if (!$update_result) { return "Datenbankfehler: " . mysql_error(); } // UPDATE Questionnaire_presents $query = "UPDATE Questionnaire_presents SET use_count = use_count + 1 " . "WHERE presentID = " . $presentID; $update_result = $db->query($query); if (!$update_result) { return "Datenbankfehler: " . mysql_error(); } if ($db->affected_rows() != 1) { return "Probleme beim UPDATE des Geschenks"; } // Höhle auffrischen $r = getCaveSecure($caveID, $params->SESSION->user['playerID']); if ($r->isEmpty()) { page_dberror(); } $meineHoehlen[$caveID] = $r->nextRow(); return "Eure Geschenke sind nun in eurer Siedlung!"; } return "Danke für die Schnecken!"; }
function player_getContent($caveID, $playerID) { global $db, $no_resource_flag, $config, $params; $no_resource_flag = 1; if (!($r = $db->query("SELECT * FROM Player WHERE playerID = '{$playerID}'"))) { page_dberror(); } if (!($row = $r->nextRow(MYSQL_ASSOC))) { page_dberror(); } $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/playerDetail.ihtml"); if ($row['avatar']) { $x = 120; $y = 120; if ($x != -1 && $y != -1) { tmpl_set($template, 'DETAILS/AVATAR_IMG/avatar', $row[avatar]); if ($x > AVATAR_X || $y > AVATAR_Y) { if ($x > $y) { $y *= AVATAR_X / $x; $x = AVATAR_X; } else { $x *= AVATAR_Y / $y; $y = AVATAR_Y; } } tmpl_set($template, 'DETAILS/AVATAR_IMG/width', floor($x)); tmpl_set($template, 'DETAILS/AVATAR_IMG/height', floor($y)); } } if (!empty($row['awards'])) { $tmp = explode('|', $row['awards']); $awards = array(); foreach ($tmp as $tag) { $awards[] = array('tag' => $tag, 'award_modus' => AWARD_DETAIL); } $row['award'] = $awards; } unset($row['awards']); foreach ($row as $k => $v) { if (!$v) { $row[$k] = "k.A."; } } $row['mail_modus'] = NEW_MESSAGE; $row['mail_receiver'] = urlencode($row['name']); $row['caveID'] = $caveID; // ADDED by chris--- for adressbook $row['adressbook_add_modus'] = MESSAGE_BOOK_ADD; // ADDED by chris--- for rank_history $row['playerID'] = $playerID; // ADDED by chris--- for farmschutz if (FARMSCHUTZ_ACTIVE == 1) { $query = "SELECT round( sum( r.average ) / count( r.average ) / 1.5 ) AS grenze, p.farmschutz AS protection, r2.average AS punkte FROM ranking r LEFT JOIN player p ON p.playerID = " . $playerID . " LEFT JOIN ranking r2 ON p.playerID = r2.playerID GROUP BY p.playerID"; if (!($result = $db->query($query))) { page_dberror(); } if (!($myrow = $result->nextRow(MYSQL_ASSOC))) { // page_dberror(); $row['farmschutz'] = "noch nicht berechenbar"; } else { $row['farmschutz'] = $myrow[protection] . "% - " . $myrow[grenze]; // if ($playerID == $params->SESSION->user['playerID']) { // eigenes Profil if ($myrow[grenze] > $myrow[punkte]) { // spieler unter grenze $pkmin = round($myrow[punkte] / 100 * $myrow[protection]); $pkmax = round($myrow[punkte] * 100 / $myrow[protection]); if ($pkmax > 10000) { $pkmax = 10000; } if ($pkmin < 0) { $pkmin = 0; } $row['farmschutz'] = $row['farmschutz'] . "<br><b>Punktegrenzen: " . $pkmin . " - " . $pkmax . "</b>"; } else { $row['farmschutz'] = $row['farmschutz'] . "<br>Spieler liegt über der Noobgrenze"; } // } } } else { $row['farmschutz'] = ""; } tmpl_set($template, 'DETAILS', $row); if (!($dbresult = $db->query("SELECT xCoord, yCoord, name, caveID AS targetCaveID FROM Cave WHERE playerID = '{$playerID}'"))) { page_dberror(); } $caves = array(); while ($row = $dbresult->nextRow(MYSQL_ASSOC)) { $row['modus'] = MAP; $row['caveID'] = $caveID; $row['movementLink'] = MOVEMENT; // ADDED by chris--- for cavebook $row['addCaveLink'] = "?modus=" . CAVE_BOOK_ADD . "&id="; // ADDED by chris--- for cavebook array_push($caves, $row); } tmpl_set($template, 'DETAILS/CAVES', $caves); return tmpl_parse($template); }
function science_processOrder($scienceID, $caveID, $playerID, $caveData, $db) { global $defenseSystemTypeList, $buildingTypeList, $scienceTypeList, $resourceTypeList, $unitTypeList, $config; $science = $scienceTypeList[$scienceID]; $maxLevel = round(eval('return ' . formula_parseToPHP("{$science->maxLevel};", '$caveData'))); // check, that this science isn't researched in an other cave at the // same time $sql = "SELECT event_scienceID FROM Event_science " . "WHERE playerID='{$playerID}' AND scienceID = '{$scienceID}'"; $r = $db->query($sql); if (!$r) { page_dberror(); } if (!$r->isEmpty()) { return 4; } // check for scienceMaxDeps in Event_Handler $dep_count = 0; foreach ($science->maxScienceDepList as $key => $value) { if ($value != -1 && $caveData[$scienceTypeList[$key]->dbFieldName] > $value - 1) { if ($dep_count) { $deps .= ","; } $deps .= $key; $dep_count++; } } if ($dep_count) { $query = "SELECT event_scienceID FROM Event_science " . "WHERE playerID = '{$playerID}' AND scienceID IN ({$deps})"; if (!($r = $db->query($query))) { page_dberror(); } if (!$r->isEmpty()) { return 5; } } $set = array(); $setBack = array(); $where = array("WHERE caveID = '{$caveID}'", "{$science->dbFieldName} < {$maxLevel}"); // get all the resource costs foreach ($science->resourceProductionCost as $key => $value) { if ($value != "" && $value != "0") { $formula = formula_parseToSQL($value); $dbField = $resourceTypeList[$key]->dbFieldName; array_push($set, "{$dbField} = {$dbField} - ({$formula})"); array_push($setBack, "{$dbField} = {$dbField} + ({$formula})"); array_push($where, "{$dbField} >= ({$formula})"); } } // get all the unit costs foreach ($science->unitProductionCost as $key => $value) { if ($value != "" && $value != "0") { $formula = formula_parseToSQL($value); $dbField = $unitTypeList[$key]->dbFieldName; array_push($set, "{$dbField} = {$dbField} - {$formula}"); array_push($setBack, "{$dbField} = {$dbField} + {$formula}"); array_push($where, "{$dbField} >= {$formula}"); } } // get all the building costs foreach ($science->buildingProductionCost as $key => $value) { if ($value != "" && $value != "0") { $formula = formula_parseToSQL($value); $dbField = $buildingTypeList[$key]->dbFieldName; array_push($set, "{$dbField} = {$dbField} - {$formula}"); array_push($setBack, "{$dbField} = {$dbField} + {$formula}"); array_push($where, "{$dbField} >= {$formula}"); } } // get all the external costs foreach ($science->externalProductionCost as $key => $value) { if ($value != "" && $value != "0") { $formula = formula_parseToSQL($value); $dbField = $defenseSystemTypeList[$key]->dbFieldName; array_push($set, "{$dbField} = {$dbField} - {$formula}"); array_push($setBack, "{$dbField} = {$dbField} + {$formula}"); array_push($where, "{$dbField} >= {$formula}"); } } // generate SQL if (sizeof($set)) { $set = implode(", ", $set); $set = "UPDATE Cave SET {$set} "; $setBack = implode(", ", $setBack); $setBack = "UPDATE Cave SET {$setBack} WHERE caveID = '{$caveID}'"; } // generate dependecies foreach ($science->buildingDepList as $key => $value) { if ($value != "" && $value != "0") { array_push($where, "{$buildingTypeList[$key]->dbFieldName} >= {$value}"); } } foreach ($science->maxBuildingDepList as $key => $value) { if ($value != -1) { array_push($where, "{$buildingTypeList[$key]->dbFieldName} <= {$value}"); } } foreach ($science->defenseSystemDepList as $key => $value) { if ($value != "" && $value != "0") { array_push($where, "{$defenseSystemTypeList[$key]->dbFieldName} >= {$value}"); } } foreach ($science->maxDefenseSystemDepList as $key => $value) { if ($value != -1) { array_push($where, "{$defenseSystemTypeList[$key]->dbFieldName} <= {$value}"); } } foreach ($science->resourceDepList as $key => $value) { if ($value != "" && $value != "0") { array_push($where, "{$resourceTypeList[$key]->dbFieldName} >= {$value}"); } } foreach ($science->maxResourceDepList as $key => $value) { if ($value != -1) { array_push($where, "{$resourceTypeList[$key]->dbFieldName} <= {$value}"); } } foreach ($science->scienceDepList as $key => $value) { if ($value != "" && $value != "0") { array_push($where, "{$scienceTypeList[$key]->dbFieldName} >= {$value}"); } } foreach ($science->maxScienceDepList as $key => $value) { if ($value != -1) { array_push($where, "{$scienceTypeList[$key]->dbFieldName} <= {$value}"); } } foreach ($science->unitDepList as $key => $value) { if ($value != "" && $value != "0") { array_push($where, "{$unitTypeList[$key]->dbFieldName} >= {$value}"); } } foreach ($science->maxUnitDepList as $key => $value) { if ($value != -1) { array_push($where, "{$unitTypeList[$key]->dbFieldName} <= {$value}"); } } $where = implode(" AND ", $where); if (!$db->query($set . $where) || !$db->affected_rows() == 1) { return 2; } $prodTime = 0; // calculate the production time; if ($time_formula = $science->productionTimeFunction) { $time_eval_formula = formula_parseToPHP($time_formula, '$caveData'); $time_eval_formula = "\$prodTime={$time_eval_formula};"; eval($time_eval_formula); } $prodTime *= SCIENCE_TIME_BASE_FACTOR; $now = time(); $query = sprintf("INSERT INTO Event_science (caveID, playerID, scienceID, " . "`start`, `end`) VALUES (%d, %d, %d, '%s', '%s')", $caveID, $playerID, $scienceID, time_toDatetime($now), time_toDatetime($now + $prodTime)); if (!$db->query($query)) { $db->query($setBack); return 2; } return 3; }
function wonder_getWonderContent($playerID, $caveID, &$details) { global $buildingTypeList, $resourceTypeList, $wonderTypeList, $unitTypeList, $config, $params, $db; // messages $messageText = array(-4 => "Die Zielsiedlung steht unter Schutz. Der Zauber kann nicht erwirkt werden.", -3 => "Die angegebene Zielsiedlung wurde nicht gefunden.", -2 => "Der Zauber kann nicht auf die angegbene Zielsiedlung erwirkt " . "werden.", -1 => "Es ist ein Fehler bei der Verarbeitung Ihrer Anfrage aufgetreten. " . "Bitte wenden Sie sich an die Administratoren.", 0 => "Der Zauber kann nicht erwirkt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 1 => "Das Erwirken des Zaubers scheint Erfolg zu haben.", 2 => "Die Götter haben Ihr Flehen nicht erhört! Die " . "eingesetzten Opfergaben sind natürlich dennoch verloren. " . "Mehr Glück beim nächsten Mal!"); // ADDED by chris--- for cavebook ----------------------- if ($params->POST->targetCaveID != -1) { $targetCave = getCaveByID($params->POST->targetCaveID); $x = $targetCave[xCoord]; $y = $targetCave[yCoord]; } else { $x = $params->POST->xCoord; $y = $params->POST->yCoord; } // ------------------------------------------------------ // and changed $params->POST->xCoord to $x etc if (isset($params->POST->wonderID)) { $messageID = wonder_processOrder($playerID, $params->POST->wonderID, $caveID, $x, $y, $details, $db); $reload = 1; } if ($reload) { // this isn't that elegant... $r = getCaveSecure($caveID, $params->SESSION->user['playerID']); if ($r->isEmpty()) { page_dberror(); } $details = $r->nextRow(); } $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/wonder.ihtml"); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // ADDED by chris--- for cavebook --------------------------------- // Getting entries $cavelist = cavebook_getEntries($params->SESSION->user['playerID']); // Show the cave table $cavebook = array(); for ($ix = 0; $ix < sizeof($cavelist[id]); $ix++) { $cavebook[$ix][cavebook_entry] = $cavelist[name][$ix]; $cavebook[$ix][cavebook_id] = $cavelist[id][$ix]; $cavebook[$ix][cavebook_x] = $cavelist[x][$ix]; $cavebook[$ix][cavebook_y] = $cavelist[y][$ix]; } // -------------------------------------------------------------- // Show the wonder table for ($i = 0; $i < sizeof($wonderTypeList); $i++) { $wonder = $wonderTypeList[$i]; // the current building $result = rules_checkDependencies($wonder, $details); if ($result === TRUE) { tmpl_iterate($template, 'WONDER'); tmpl_set($template, "WONDER/alternate", $count++ % 2 ? "alternate" : ""); tmpl_set($template, 'WONDER', array('name' => $wonder->name, 'wonderID' => $i, 'modus' => WONDER_DETAIL, 'caveID' => $caveID)); // iterate ressourcecosts foreach ($wonder->resourceProductionCost as $resourceID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "WONDER/RESSOURCECOST"); if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) { tmpl_set($template, "WONDER/RESSOURCECOST/ENOUGH/value", $cost); } else { tmpl_set($template, "WONDER/RESSOURCECOST/LESS/value", $cost); } tmpl_set($template, "WONDER/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName); tmpl_set($template, "WONDER/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name); } } // iterate unitcosts foreach ($wonder->unitProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "WONDER/UNITCOST"); if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "WONDER/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "WONDER/UNITCOST/LESS/value", $cost); } tmpl_set($template, "WONDER/UNITCOST/name", $unitTypeList[$unitID]->name); } } // show the wonder link tmpl_set($template, 'WONDER/BUILD_LINK', array('action' => WONDER, 'wonderID' => $wonder->wonderID, 'cave_book_link' => CAVE_BOOK, 'BOOKENTRY' => $cavebook, 'caveID' => $caveID)); } else { if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$wonder->nodocumentation) { tmpl_iterate($template, '/UNQUALIFIEDWONDERS/WONDER'); tmpl_set($template, '/UNQUALIFIEDWONDERS/WONDER', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => WONDER_DETAIL, 'wonderID' => $i, 'caveID' => $caveID, 'name' => $wonder->name, 'dependencies' => $result)); } } } return tmpl_parse($template); }
function improvement_getImprovementDetail($caveID, &$details) { global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db; // messages $messageText = array(0 => "Der Arbeitsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Arbeitsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 5 => "Das Gebäude wurde erfolgreich abgerissen", 6 => "Das Gebäude konnte nicht abgerissen werden", 7 => "Sie haben von der Sorte gar keine Gebäude", 8 => "Sie können derzeit kein Gebäude abreissen, weil erst vor Kurzem etwas in dieser Siedlung abgerissen wurde. Generell muss zwischen zwei Abrissen eine Zeitspanne von " . TORE_DOWN_TIMEOUT . " Minuten liegen."); // proccess a cancel-order request if (isset($params->POST->eventID)) { $messageID = improvement_processOrderCancel($params->POST->eventID, $caveID, $db); } // proccess a tore down or new order request if (isset($params->POST->breakDownConfirm)) { $messageID = improvement_breakDown($params->POST->buildingID, $caveID, $details, $db); $reload = 1; } else { if (isset($params->POST->buildingID)) { $messageID = improvement_processOrder($params->POST->buildingID, $caveID, $details, $db); $reload = 1; } } if ($reload) { // this isn't that elegant... $r = getCaveSecure($caveID, $params->SESSION->user['playerID']); if ($r->isEmpty()) { page_dberror(); } $details = $r->nextRow(); } $queue = improvement_getImprovementQueueForCave($params->SESSION->user['playerID'], $caveID); $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/improvement.ihtml"); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // Show the improvement table for ($i = 0; $i < sizeof($buildingTypeList); $i++) { $notenough = FALSE; $building = $buildingTypeList[$i]; // the current building $maxLevel = round(eval('return ' . formula_parseToPHP("{$building->maxLevel};", '$details'))); $result = rules_checkDependencies($building, $details); if ($result === TRUE) { tmpl_iterate($template, 'IMPROVEMENT'); tmpl_set($template, "IMPROVEMENT/alternate", $count++ % 2 ? "alternate" : ""); tmpl_set($template, 'IMPROVEMENT', array('name' => $building->name, 'dbFieldName' => $building->dbFieldName, 'buildingID' => $i, 'modus' => IMPROVEMENT_BUILDING_DETAIL, 'caveID' => $caveID, 'maxlevel' => $maxLevel, 'size' => "0" + $details[$building->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($building->productionTimeFunction . ";", '$details')) * BUILDING_TIME_BASE_FACTOR))); // iterate ressourcecosts foreach ($building->resourceProductionCost as $resourceID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "IMPROVEMENT/RESSOURCECOST"); if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) { tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/ENOUGH/value", $cost); } else { tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName); tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name); } } // iterate unitcosts foreach ($building->unitProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "IMPROVEMENT/UNITCOST"); if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "IMPROVEMENT/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "IMPROVEMENT/UNITCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "IMPROVEMENT/UNITCOST/name", $unitTypeList[$unitID]->name); } } // iterate buildingcosts /* foreach ($building->buildingProductionCost as $buildingID => $function){ $cost = ceil(eval('return '. formula_parseToPHP($function . ';', '$details'))); if ($cost){ tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST"); if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost){ tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name); } } */ // iterate buildingcosts foreach ($building->buildingProductionCost as $buildingID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "IMPROVEMENT/BUILDINGCOST"); if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) { tmpl_set($template, "IMPROVEMENT/BUILDINGCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "IMPROVEMENT/BUILDINGCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "IMPROVEMENT/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name); } } // iterate externalcosts foreach ($building->externalProductionCost as $externalID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST"); if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name); } } // show the break down link tmpl_set($template, 'IMPROVEMENT/BREAK_DOWN_LINK', array('action' => IMPROVEMENT_BREAK_DOWN, 'buildingID' => $building->buildingID, 'caveID' => $caveID)); // show the building link ?! if ($queue) { tmpl_set($template, 'IMPROVEMENT/BUILD_LINK_NO/message', "Ausbau im Gange"); } else { if ($notenough && $maxLevel > $details[$building->dbFieldName]) { tmpl_set($template, 'IMPROVEMENT/BUILD_LINK_NO/message', ""); } else { if ($maxLevel > $details[$building->dbFieldName]) { tmpl_set($template, 'IMPROVEMENT/BUILD_LINK', array('action' => IMPROVEMENT_DETAIL, 'buildingID' => $building->buildingID, 'caveID' => $caveID)); } else { tmpl_set($template, '/IMPROVEMENT/BUILD_LINK_NO/message', "Max. Stufe"); } } } } else { if ($details[$building->dbFieldName]) { tmpl_iterate($template, '/UNWANTEDIMPROVEMENTS/IMPROVEMENT'); tmpl_set($template, '/UNWANTEDIMPROVEMENTS/IMPROVEMENT', array('alternate' => $count_unwanted++ % 2 ? "" : "alternate", 'modus' => IMPROVEMENT_BUILDING_DETAIL, 'buildingID' => $i, 'caveID' => $caveID, 'size' => $details[$building->dbFieldName], 'dbFieldName' => $building->dbFieldName, 'name' => $building->name, 'action' => IMPROVEMENT_BREAK_DOWN)); if ($result !== FALSE) { tmpl_set($template, '/UNWANTEDIMPROVEMENTS/IMPROVEMENT/dependencies', $result); } } else { if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$building->nodocumentation) { tmpl_iterate($template, '/UNQUALIFIEDIMPROVEMENTS/IMPROVEMENT'); tmpl_set($template, '/UNQUALIFIEDIMPROVEMENTS/IMPROVEMENT', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => IMPROVEMENT_BUILDING_DETAIL, 'buildingID' => $i, 'caveID' => $caveID, 'dbFieldName' => $building->dbFieldName, 'name' => $building->name, 'dependencies' => $result)); } } } } // Show the building queue if ($queue) { // display the building queue $row = $queue->nextRow(); tmpl_set($template, 'IMPROVEMENT_QUEUE', array('name' => $buildingTypeList[$row['expansionID']]->name, 'size' => $details[$buildingTypeList[$row['expansionID']]->dbFieldName] + 1, 'finish' => date("d.m.Y H:i:s", time_timestampToTime($row['event_end'])), 'action' => IMPROVEMENT_DETAIL, 'eventID' => $row['event_expansionID'], 'caveID' => $caveID)); } return tmpl_parse($template); }
function player_getContent($caveID, $playerID) { global $db, $template; // open template $template->setFile('playerDetail.tmpl'); $template->setShowResource(false); // workaround, if no playerID is submitted! TODO if ($playerID == 0) { $playerID = $_SESSION['player']->playerID; } $playerDetails = Player::getPlayer($playerID, true); if (!$playerDetails) { $template->throwError('Da wollte irgendwie was nicht aus der Datenbank ausgelesen werden :('); return; } if ($playerDetails['avatar']) { $playerDetails['avatar'] = @unserialize($playerDetails['avatar']); $template->addVars(array('player_avatar' => $playerDetails['avatar']['path'], 'player_avatar_width' => $playerDetails['avatar']['width'], 'player_avatar_height' => $playerDetails['avatar']['height'])); } if (!empty($playerDetails['awards'])) { $tmp = explode('|', $playerDetails['awards']); $awards = array(); foreach ($tmp as $tag) { $awards[] = $tag; } $playerDetails['award'] = $awards; } unset($playerDetails['awards']); foreach ($playerDetails as $k => $v) { if (!$v) { $playerDetails[$k] = _('k.A.'); } } $playerDetails['mail_receiver'] = urlencode($playerDetails['name']); $playerDetails['caveID'] = $caveID; $playerTribe = $playerDetails['tribe']; $timediff = getUgaAggaTimeDiff(time_fromDatetime($playerDetails['created']), time()); $playerDetails['age'] = 18 + $timediff['year']; // init messages class $parser = new parser(); $playerDetails['description'] = $parser->p($playerDetails['description']); // show player's caves $caves = getCaves($playerID); if ($caves) { $template->addVar('player_caves', $caves); } // show player's history $history = Player::getHistory($playerID); if (sizeof($history)) { $template->addVar('player_history', $history); } //get player rank $sql = $db->prepare("SELECT rank FROM " . RANKING_TABLE . " WHERE playerID = :playerID"); $sql->bindValue('playerID', $playerID, pDo::PARAM_INT); if (!$sql->execute()) { page_dberror(); } if ($row = $sql->fetch()) { $playerDetails['rank'] = $row['rank']; } else { $playerDetails['rank'] = ''; } $template->addVars(array('player_details' => $playerDetails)); }
/** * */ function externals_builder($caveID, &$cave) { global $config, $db, $params, $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList; // process a cancel-order request if (isset($params->POST->eventID)) { $message = externals_cancelOrder($params->POST->eventID, $caveID, $db); // process a demolish request } else { if (isset($params->POST->breakDownConfirm)) { $message = externals_performDemolishing($params->POST->externalID, $caveID, $cave, $db); $reload = 1; // process an order request } else { if (isset($params->POST->externalID)) { check_timestamp($params->POST->tstamp); $message = externals_performOrder($params->POST->externalID, $caveID, $cave, $db); $reload = 1; } } } // refresh cave data if ($reload) { $r = getCaveSecure($caveID, $params->SESSION->player->playerID); if ($r->isEmpty()) { page_dberror(); } $cave = $r->nextRow(); } // get this cave's queue $queue = externals_getQueue($params->SESSION->player->playerID, $caveID); // open template $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'externalBuilder.ihtml'); // show special messages if (isset($message)) { tmpl_set($template, '/MESSAGE/message', $message); } // show the external table for ($i = 0; $i < sizeof($defenseSystemTypeList); $i++) { $external = $defenseSystemTypeList[$i]; $maxLevel = round(eval('return ' . formula_parseToPHP("{$external->maxLevel};", '$cave'))); $notenough = FALSE; $result = rules_checkDependencies($external, $cave); // if all requirements are met, but the maxLevel is 0, treat it like a non-buildable if ($maxLevel <= 0 && $result === TRUE) { $result = $cave[$external->dbFieldName] ? _('Max. Stufe: 0') : FALSE; } if ($result === TRUE) { tmpl_iterate($template, 'DEFENSESYSTEM'); tmpl_set($template, "DEFENSESYSTEM/alternate", $count++ % 2 ? "alternate" : ""); tmpl_set($template, 'DEFENSESYSTEM', array('name' => $external->name, 'dbFieldName' => $external->dbFieldName, 'externalID' => $i, 'size' => "0" + $cave[$external->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($external->productionTimeFunction . ";", '$cave')) * DEFENSESYSTEM_TIME_BASE_FACTOR))); // iterate ressourcecosts foreach ($external->resourceProductionCost as $resourceID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$cave'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/RESSOURCECOST"); if ($cave[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName); tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name); } } // iterate unitcosts foreach ($external->unitProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$cave'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/UNITCOST"); if ($cave[$unitTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/UNITCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/UNITCOST/name", $unitTypeList[$unitID]->name); } } // iterate buildingcosts foreach ($external->buildingProductionCost as $buildingID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$cave'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST"); if ($cave[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name); } } // iterate externalcosts foreach ($external->externalProductionCost as $externalID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$cave'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST"); if ($cave[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name); } } // show the break down link if ($cave[$external->dbFieldName]) { tmpl_set($template, 'DEFENSESYSTEM/BREAK_DOWN_LINK', array('externalID' => $external->defenseSystemID)); } // do not show order link if ($queue) { tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK_NO/message', _('Ausbau im Gange')); } else { if ($notenough && $maxLevel > $cave[$external->dbFieldName]) { tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK_NO/message', _('Zu wenig Rohstoffe')); // show order link } else { if ($maxLevel > $cave[$external->dbFieldName]) { tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK', array('externalID' => $external->defenseSystemID, 'tstamp' => time())); // maxlvl reached } else { tmpl_set($template, '/DEFENSESYSTEM/BUILD_LINK_NO/message', _('Max. Stufe')); } } } // can't build but already in cave } else { if ($cave[$external->dbFieldName]) { tmpl_iterate($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM'); tmpl_set($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM', array('alternate' => $count_unwanted++ % 2 ? "" : "alternate", 'externalID' => $i, 'size' => $cave[$external->dbFieldName], 'dbFieldName' => $external->dbFieldName, 'name' => $external->name)); // if building not impossible, show dependencies if ($result !== FALSE) { tmpl_set($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM/dependencies', $result); } // building not impossible, but DONT show dependencies } else { if ($result !== FALSE && !$external->nodocumentation) { tmpl_iterate($template, '/UNQUALIFIEDDEFENSESYSTEMS/DEFENSESYSTEM'); tmpl_set($template, '/UNQUALIFIEDDEFENSESYSTEMS/DEFENSESYSTEM', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'externalID' => $i, 'name' => $external->name, 'dbFieldName' => $external->dbFieldName, 'dependencies' => $result)); } } } } // queue if ($queue) { $row = $queue->nextRow(); tmpl_set($template, 'DEFENSESYSTEM_QUEUE', array('name' => $defenseSystemTypeList[$row['defenseSystemID']]->name, 'size' => $cave[$defenseSystemTypeList[$row['defenseSystemID']]->dbFieldName] + 1, 'finish' => time_formatDatetime($row['end']), 'eventID' => $row['event_defenseSystemID'])); } tmpl_set($template, array('rules_path' => RULES_PATH)); return tmpl_parse($template); }
function unit_getUnitDetail($caveID, &$details) { global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db, $MAX_RESOURCE; // messages $messageText = array(0 => "Der Arbeitsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Arbeitsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 4 => "Bitte korrekte Anzahl der Einheiten Angeben (1 ... " . MAX_SIMULTAN_BUILDED_UNITS . ")"); // proccess a cancel-order request if (isset($params->POST->eventID)) { $messageID = unit_processOrderCancel($params->POST->eventID, $caveID, $db); } // proccess a new order request if (isset($params->POST->unitID)) { $messageID = unit_processOrder($params->POST->unitID, intval($params->POST->quantity), $caveID, $db, $details); $r = getCaveSecure($caveID, $params->SESSION->user['playerID']); if ($r->isEmpty()) { page_dberror(); } $details = $r->nextRow(); } $queue = unit_getUnitQueueForCave($params->SESSION->user['playerID'], $caveID); $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/unitbuild.ihtml"); // Show a special message if (isset($messageID)) { tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]); } // Show the unit table for ($i = 0; $i < sizeof($unitTypeList); $i++) { $notenough = FALSE; $unit = $unitTypeList[$i]; // the current unit $result = rules_checkDependencies($unit, $details); if ($result === TRUE) { tmpl_iterate($template, '/UNIT'); tmpl_set($template, "UNIT/alternate", $count++ % 2 ? "alternate" : ""); tmpl_set($template, 'UNIT', array('name' => $unit->name, 'dbFieldName' => $unit->dbFieldName, 'unitID' => $i, 'modus' => UNIT_PROPERTIES, 'caveID' => $caveID, 'size' => "0" + $details[$unit->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($unit->productionTimeFunction . ";", '$details')) * BUILDING_TIME_BASE_FACTOR))); // iterate ressourcecosts foreach ($unit->resourceProductionCost as $resourceID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "UNIT/RESSOURCECOST"); if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) { tmpl_set($template, "UNIT/RESSOURCECOST/ENOUGH/value", $cost); } else { tmpl_set($template, "UNIT/RESSOURCECOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "UNIT/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName); tmpl_set($template, "UNIT/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name); } } // iterate unitcosts foreach ($unit->unitProductionCost as $unitID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "UNIT/UNITCOST"); if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) { tmpl_set($template, "UNIT/UNITCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "UNIT/UNITCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "UNIT/UNITCOST/name", $unitTypeList[$unitID]->name); } } // iterate buildingcosts foreach ($unit->buildingProductionCost as $buildingID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST"); if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name); } } // iterate externalcosts foreach ($unit->externalProductionCost as $externalID => $function) { $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details'))); if ($cost) { tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST"); if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost); } else { tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost); $notenough = TRUE; } tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name); } } // show the improvement link ?! if ($queue) { tmpl_set($template, "UNIT/UNIT_LINK_NO/message", "Ausbildung im Gange"); } else { if ($notenough) { tmpl_set($template, "UNIT/UNIT_LINK_NO/message", ""); } else { $formParams = array(array('name' => 'modus', 'value' => UNIT_BUILDER), array('name' => 'caveID', 'value' => $caveID), array('name' => 'unitID', 'value' => $unit->unitID)); tmpl_set($template, "UNIT/UNIT_LINK/PARAMS", $formParams); } } } else { if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$unit->nodocumentation) { tmpl_iterate($template, '/UNQUALIFIEDUNITS/UNIT'); tmpl_set($template, '/UNQUALIFIEDUNITS/UNIT', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => UNIT_PROPERTIES, 'unitID' => $i, 'caveID' => $caveID, 'dbFieldName' => $unit->dbFieldName, 'name' => $unit->name, 'dependencies' => $result)); } } } // Show the building queue if ($queue) { // display the unit building queue $row = $queue->nextRow(); tmpl_set($template, 'UNIT_QUEUE', array('name' => $unitTypeList[$row[unitID]]->name, 'quantity' => $row['quantity'], 'finish' => date("d.m.Y H:i:s", time_timestampToTime($row[event_end])), 'action' => UNIT_BUILDER, 'eventID' => $row['event_unitID'], 'caveID' => $caveID)); } return tmpl_parse($template); }