* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
". $lang['ConstructionTime'] .": " . pretty_time($time);
}
// ----------------------------------------------------------------------------------------------------------------
//
function add_points ($resources, $userid) {
return false;
}
function remove_points ($resources, $userid) {
return false;
}
function get_userdata () {
return '';
}
// ----------------------------------------------------------------------------------------------------------------
//
// Fonction de lecture / ecriture / exploitation de templates
//
function ReadFromFile($filename) {
$content = @file_get_contents ($filename);
return $content;
}
function saveToFile($filename, $content) {
$content = file_put_contents($filename, $content);
}
function parsetemplate($template, $array)
{
static $baseUrl = null;
if ($baseUrl === null) {
$user = Legacies_Empire_Model_User::getSingleton();
if ($user !== null && $user->getId() && ($baseUrl = $user->getSkinPath()) == '') {
$baseUrl = DEFAULT_SKINPATH;
}
}
$array['dpath'] = $baseUrl;
return preg_replace('#\{([a-z0-9\-_]*?)\}#Ssie', 'isset($array["\1"]) ? $array["\1"] : "";', $template);
}
function getTemplate($templateName) {
$filename = TEMPLATE_DIR . '/' . TEMPLATE_NAME . "/{$templateName}.tpl";
return ReadFromFile($filename);
}
/**
* Gestion de la localisation des chaînes
*
* @param string $filename
* @param string $extension
* @return void
*/
function includeLang($filename, $extension = 'mo')
{
global $lang, $user;
$pathPattern = ROOT_PATH . "language/%s/{$filename}.%s";
if (isset($user['lang']) && !empty($user['lang'])) {
if (($fp = @fopen($filename = sprintf($pathPattern, $user['lang'], $extension), 'r', false)) !== false) {
fclose($fp);
require_once $filename;
return;
} else if (($fp = @fopen($filename = sprintf($pathPattern, $user['lang'], 'csv'), 'r', false)) !== false) {
while (!feof($fp)) {
$line = fgetcsv($fp);
if (count($line) == 2 && !empty($line[0])) {
$lang[$line[0]] = $line[1];
}
}
fclose($fp);
return;
}
}
require_once sprintf($pathPattern, DEFAULT_LANG, 'mo');
return;
}
// ----------------------------------------------------------------------------------------------------------------
//
// Affiche une adresse de depart sous forme de lien
function GetStartAdressLink ( $FleetRow, $FleetType ) {
$Link = "";
$Link .= "[".$FleetRow['fleet_start_galaxy'].":".$FleetRow['fleet_start_system'].":".$FleetRow['fleet_start_planet']."]";
return $Link;
}
// Affiche une adresse de cible sous forme de lien
function GetTargetAdressLink ( $FleetRow, $FleetType ) {
$Link = "";
$Link .= "[".$FleetRow['fleet_end_galaxy'].":".$FleetRow['fleet_end_system'].":".$FleetRow['fleet_end_planet']."]";
return $Link;
}
// Affiche une adresse de planete sous forme de lien
function BuildPlanetAdressLink ( $CurrentPlanet ) {
$Link = "";
$Link .= "[".$CurrentPlanet['galaxy'].":".$CurrentPlanet['system'].":".$CurrentPlanet['planet']."]";
return $Link;
}
// Création d'un lien pour le joueur hostile
function BuildHostileFleetPlayerLink ( $FleetRow ) {
global $lang, $dpath;
$PlayerName = doquery ("SELECT `username` FROM {{table}} WHERE `id` = '". $FleetRow['fleet_owner']."';", 'users', true);
$Link = $PlayerName['username']. " ";
$Link .= "";
$Link .= "
";
return $Link;
}
function GetNextJumpWaitTime ( $CurMoon ) {
global $resource;
$JumpGateLevel = $CurMoon[$resource[43]];
$LastJumpTime = $CurMoon['last_jump_time'];
if ($JumpGateLevel > 0) {
$WaitBetweenJmp = (60 * 60) * (1 / $JumpGateLevel);
$NextJumpTime = $LastJumpTime + $WaitBetweenJmp;
if ($NextJumpTime >= time()) {
$RestWait = $NextJumpTime - time();
$RestString = " ". pretty_time($RestWait);
} else {
$RestWait = 0;
$RestString = "";
}
} else {
$RestWait = 0;
$RestString = "";
}
$RetValue['string'] = $RestString;
$RetValue['value'] = $RestWait;
return $RetValue;
}
/**
* Céation du lien avec popup pour la flotte
*
* @deprecated
*/
function CreateFleetPopupedFleetLink ( $FleetRow, $Texte, $FleetType ) {
global $lang;
$FleetRec = explode(";", $FleetRow['fleet_array']);
$FleetPopup = " $Group) {
if ($Group != '') {
$Ship = explode(",", $Group);
$FleetPopup .= " ";
}
}
$FleetPopup .= "";
$FleetPopup .= "');\" onmouseout=\"return nd();\" class=\"". $FleetType ."\">". $Texte ."";
return $FleetPopup;
}
// ----------------------------------------------------------------------------------------------------------------
//
// Céation du lien avec popup pour le type de mission avec ou non les ressources si disponibles
function CreateFleetPopupedMissionLink ( $FleetRow, $Texte, $FleetType ) {
global $lang;
$FleetTotalC = $FleetRow['fleet_resource_metal'] + $FleetRow['fleet_resource_crystal'] + $FleetRow['fleet_resource_deuterium'];
if ($FleetTotalC <> 0) {
$FRessource = "". $lang['tech'][$Ship[0]] .": ". pretty_number($Ship[1]) ."
| ". $lang['Metal'] ." | ". pretty_number($FleetRow['fleet_resource_metal']) ." |
| ". $lang['Crystal'] ." | ". pretty_number($FleetRow['fleet_resource_crystal']) ." |
| ". $lang['Deuterium'] ." | ". pretty_number($FleetRow['fleet_resource_deuterium']) ." |