Ajout d'une étape de linting dans DroneCi #3
263 changed files with 45327 additions and 42695 deletions
|
|
@ -8,6 +8,12 @@ platform:
|
|||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: lint
|
||||
image: php:7.2-alpine
|
||||
commands:
|
||||
- curl -L https://cs.symfony.com/download/php-cs-fixer-v2.phar -o php-cs-fixer.phar
|
||||
- php php-cs-fixer.phar fix htdocs --dry-run --using-cache=no --verbose --stop-on-violation
|
||||
- php php-cs-fixer.phar fix onyx2 --dry-run --using-cache=no --verbose --stop-on-violation
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
|
|
|
|||
210
htdocs/admin.php
210
htdocs/admin.php
|
|
@ -7,119 +7,111 @@ require_once(trim(file_get_contents('./.onyx')));
|
|||
require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
||||
|
||||
//On vérifie si le client est connecté ou non sur le site
|
||||
if (isset($SESS) && isset($SESS->values['connected']) && $SESS->values['connected'] && !empty($SESS->values['id']) && !empty($SESS->level) && $SESS->level >= 3)
|
||||
{
|
||||
function infoPlan($galaxie, $ss, $pos, $info)
|
||||
{
|
||||
$base = new BDD();
|
||||
$resultat = $base->unique_query("SELECT * FROM planete WHERE galaxie = '$galaxie' AND ss = '$ss' AND position= '$pos';");
|
||||
$base->deconnexion();
|
||||
return $resultat[$info];
|
||||
}
|
||||
if (isset($SESS) && isset($SESS->values['connected']) && $SESS->values['connected'] && !empty($SESS->values['id']) && !empty($SESS->level) && $SESS->level >= 3) {
|
||||
function infoPlan($galaxie, $ss, $pos, $info)
|
||||
{
|
||||
$base = new BDD();
|
||||
$resultat = $base->unique_query("SELECT * FROM planete WHERE galaxie = '$galaxie' AND ss = '$ss' AND position= '$pos';");
|
||||
$base->deconnexion();
|
||||
return $resultat[$info];
|
||||
}
|
||||
|
||||
//Passage des valeurs générales au template
|
||||
$titre = "Administration";
|
||||
$template->assign('page', 'admin');
|
||||
$template->assign('menu', $VAR['menu']);
|
||||
$template->assign('premiere_page', $VAR['first_page']);
|
||||
$template->assign('race', $SESS->values['race']);
|
||||
$template->assign("tpsdejeu", "un certain temps");
|
||||
//Passage des valeurs générales au template
|
||||
$titre = "Administration";
|
||||
$template->assign('page', 'admin');
|
||||
$template->assign('menu', $VAR['menu']);
|
||||
$template->assign('premiere_page', $VAR['first_page']);
|
||||
$template->assign('race', $SESS->values['race']);
|
||||
$template->assign("tpsdejeu", "un certain temps");
|
||||
|
||||
if (!empty($SESS->values['souscontrole']))
|
||||
{
|
||||
$pagea = 'erreur';
|
||||
if (!empty($SESS->values['souscontrole'])) {
|
||||
$pagea = 'erreur';
|
||||
|
||||
$SESS->values['id'] = $SESS->values['souscontrole'][0];
|
||||
$SESS->values['idPlan'] = $SESS->values['souscontrole'][1];
|
||||
$SESS->values['souscontrole'] = null;
|
||||
$SESS->put();
|
||||
$SESS->values['id'] = $SESS->values['souscontrole'][0];
|
||||
$SESS->values['idPlan'] = $SESS->values['souscontrole'][1];
|
||||
$SESS->values['souscontrole'] = null;
|
||||
$SESS->put();
|
||||
|
||||
$template->assign('message', 'Droits rétablis avec succès !<br />');
|
||||
}
|
||||
else
|
||||
{
|
||||
$id_user = $SESS->values['id'];
|
||||
$template->assign('message', 'Droits rétablis avec succès !<br />');
|
||||
} else {
|
||||
$id_user = $SESS->values['id'];
|
||||
|
||||
if (!isset($_GET['p']))
|
||||
$_GET['p'] = '';
|
||||
if ($SESS->level >= 5)
|
||||
{
|
||||
switch($_GET['p'])
|
||||
{
|
||||
case 'djoueurs':
|
||||
include("admin/supprimer_joueur.php");
|
||||
break;
|
||||
case 'bandeau':
|
||||
include("admin/bandeau.php");
|
||||
break;
|
||||
case 'demarrage':
|
||||
include("admin/demarrage.php");
|
||||
break;
|
||||
case 'version':
|
||||
include("admin/version.php");
|
||||
break;
|
||||
case 'inscription':
|
||||
include("admin/inscription.php");
|
||||
break;
|
||||
case 'njoueur':
|
||||
include("server/njoueur.php");
|
||||
break;
|
||||
case 'mail_mass':
|
||||
include("admin/mail_mass.php");
|
||||
break;
|
||||
case 'bdd':
|
||||
include("admin/bdd.php");
|
||||
break;
|
||||
case 'proxy':
|
||||
include("admin/proxy.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($pagea))
|
||||
{
|
||||
switch($_GET['p'])
|
||||
{
|
||||
case 'courrier':
|
||||
include("admin/mail.php");
|
||||
break;
|
||||
case 'vip':
|
||||
include("admin/ip.php");
|
||||
break;
|
||||
case 'vflottes':
|
||||
include("admin/flottes.php");
|
||||
break;
|
||||
case 'vplanetes':
|
||||
include("admin/planete.php");
|
||||
break;
|
||||
case 'vjoueurs':
|
||||
include("admin/joueur.php");
|
||||
break;
|
||||
case 'valliances':
|
||||
include("admin/alliance.php");
|
||||
break;
|
||||
case 'snalliances':
|
||||
include("admin/snalliances.php");
|
||||
break;
|
||||
case 'vrapports':
|
||||
include("admin/rapport.php");
|
||||
break;
|
||||
case 'sjoueurs':
|
||||
include("admin/sanction_joueur.php");
|
||||
break;
|
||||
case 'cjoueurs':
|
||||
include("admin/prendre_controle.php");
|
||||
break;
|
||||
default:
|
||||
include("admin/accueil.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($_GET['p'])) {
|
||||
$_GET['p'] = '';
|
||||
}
|
||||
if ($SESS->level >= 5) {
|
||||
switch ($_GET['p']) {
|
||||
case 'djoueurs':
|
||||
include("admin/supprimer_joueur.php");
|
||||
break;
|
||||
case 'bandeau':
|
||||
include("admin/bandeau.php");
|
||||
break;
|
||||
case 'demarrage':
|
||||
include("admin/demarrage.php");
|
||||
break;
|
||||
case 'version':
|
||||
include("admin/version.php");
|
||||
break;
|
||||
case 'inscription':
|
||||
include("admin/inscription.php");
|
||||
break;
|
||||
case 'njoueur':
|
||||
include("server/njoueur.php");
|
||||
break;
|
||||
case 'mail_mass':
|
||||
include("admin/mail_mass.php");
|
||||
break;
|
||||
case 'bdd':
|
||||
include("admin/bdd.php");
|
||||
break;
|
||||
case 'proxy':
|
||||
include("admin/proxy.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($pagea)) {
|
||||
switch ($_GET['p']) {
|
||||
case 'courrier':
|
||||
include("admin/mail.php");
|
||||
break;
|
||||
case 'vip':
|
||||
include("admin/ip.php");
|
||||
break;
|
||||
case 'vflottes':
|
||||
include("admin/flottes.php");
|
||||
break;
|
||||
case 'vplanetes':
|
||||
include("admin/planete.php");
|
||||
break;
|
||||
case 'vjoueurs':
|
||||
include("admin/joueur.php");
|
||||
break;
|
||||
case 'valliances':
|
||||
include("admin/alliance.php");
|
||||
break;
|
||||
case 'snalliances':
|
||||
include("admin/snalliances.php");
|
||||
break;
|
||||
case 'vrapports':
|
||||
include("admin/rapport.php");
|
||||
break;
|
||||
case 'sjoueurs':
|
||||
include("admin/sanction_joueur.php");
|
||||
break;
|
||||
case 'cjoueurs':
|
||||
include("admin/prendre_controle.php");
|
||||
break;
|
||||
default:
|
||||
include("admin/accueil.php");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('titre', $titre);
|
||||
$template->assign('pagea', $pagea);
|
||||
$template->display('admin/'.$pagea.'.tpl');
|
||||
$template->assign('titre', $titre);
|
||||
$template->assign('pagea', $pagea);
|
||||
$template->display('admin/'.$pagea.'.tpl');
|
||||
} else {
|
||||
header('Location: '.$VAR['first_page']);
|
||||
}
|
||||
else
|
||||
header('Location: '.$VAR['first_page']);
|
||||
?>
|
||||
|
|
@ -13,36 +13,30 @@ require_once("donnees.php");
|
|||
$SESS = new Session();
|
||||
|
||||
//On vérifie si le client est connecté sur le site
|
||||
if (isset($SESS) && isset($SESS->values['connected']) && $SESS->values['connected'] && !empty($SESS->values['id']) && !empty($SESS->values['race']) && !empty($SESS->level) && isset($SESS->values['idPlan']) && isset($SESS->values['idAsteroide']))
|
||||
{
|
||||
include_once("Class/user.php");
|
||||
$user = new User($SESS->values['id']);
|
||||
if (!empty($user->id_alliance))
|
||||
{
|
||||
if (isset($_POST['message']))
|
||||
{
|
||||
$message = htmlentities(trim(gpc("message", "post")));
|
||||
if (!empty($message) || $message == "0")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($message);
|
||||
$bdd->query("INSERT INTO $table_alliances_chat (id_alliance, emetteur, timestamp, message) VALUES (".$user->id_alliance.", ".$user->id_user.", ".time().", '$message');");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($_GET['time']))
|
||||
$time = intval(gpc("time"))." ORDER BY timestamp DESC";
|
||||
else
|
||||
$time = "0 ORDER BY timestamp DESC LIMIT 15";
|
||||
if (isset($SESS) && isset($SESS->values['connected']) && $SESS->values['connected'] && !empty($SESS->values['id']) && !empty($SESS->values['race']) && !empty($SESS->level) && isset($SESS->values['idPlan']) && isset($SESS->values['idAsteroide'])) {
|
||||
include_once("Class/user.php");
|
||||
$user = new User($SESS->values['id']);
|
||||
if (!empty($user->id_alliance)) {
|
||||
if (isset($_POST['message'])) {
|
||||
$message = htmlentities(trim(gpc("message", "post")));
|
||||
if (!empty($message) || $message == "0") {
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($message);
|
||||
$bdd->query("INSERT INTO $table_alliances_chat (id_alliance, emetteur, timestamp, message) VALUES (".$user->id_alliance.", ".$user->id_user.", ".time().", '$message');");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
} else {
|
||||
if (!empty($_GET['time'])) {
|
||||
$time = intval(gpc("time"))." ORDER BY timestamp DESC";
|
||||
} else {
|
||||
$time = "0 ORDER BY timestamp DESC LIMIT 15";
|
||||
}
|
||||
|
||||
$bdd = new BDD();
|
||||
$messages = $bdd->query("SELECT C.*, U.pseudo FROM $table_alliances_chat C INNER JOIN $table_user U ON U.id = C.emetteur WHERE C.id_alliance = ".$user->id_alliance." AND C.timestamp > $time;");
|
||||
$bdd->deconnexion();
|
||||
$bdd = new BDD();
|
||||
$messages = $bdd->query("SELECT C.*, U.pseudo FROM $table_alliances_chat C INNER JOIN $table_user U ON U.id = C.emetteur WHERE C.id_alliance = ".$user->id_alliance." AND C.timestamp > $time;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header("X-JSON: ".json_encode($messages));
|
||||
}
|
||||
}
|
||||
header("X-JSON: ".json_encode($messages));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -2,140 +2,150 @@
|
|||
define("INDEX", 1);
|
||||
$chrono_start = microtime();
|
||||
$onyx = @file_get_contents('./.onyx') or die("Configuration introuvable.");
|
||||
define("_FCORE",trim($onyx));
|
||||
define("_FCORE", trim($onyx));
|
||||
require(_FCORE."../game/Class/JSON.php");
|
||||
require_once(_FCORE."common.php");
|
||||
|
||||
if (isset($sess) && isset($sess->values['connected']) && $sess->values['connected'] && !empty($sess->values['id']) && !empty($sess->level) && !empty($sess->values['idPlan'])) {
|
||||
$json = new Services_JSON();
|
||||
$nbtrajet = 2;
|
||||
$json = new Services_JSON();
|
||||
$nbtrajet = 2;
|
||||
|
||||
if (empty($config['flottes']) && $sess->level <= 1) {
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => '<input class="dest" type="text" id="amas" name="amas" maxlength="2" value="'.gpc('galaxie', 'post').'" />:<input class="dest" type="text" id="ss" name="ss" maxlength="2" value="'.gpc('ss', 'post').'" />:<input class="dest" type="text" id="plan" name="pos" maxlength="2" value="'.gpc('pos', 'post').'" />',
|
||||
'temps' => '-',
|
||||
'deblok' => '<span style="color: #FF0000;"><b>Les flottes sont désactivés pour le moment.</b></span>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => ''
|
||||
)
|
||||
);
|
||||
header("X-JSON: ".$json->encode($datas));
|
||||
exit;
|
||||
}
|
||||
if (empty($config['flottes']) && $sess->level <= 1) {
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => '<input class="dest" type="text" id="amas" name="amas" maxlength="2" value="'.gpc('galaxie', 'post').'" />:<input class="dest" type="text" id="ss" name="ss" maxlength="2" value="'.gpc('ss', 'post').'" />:<input class="dest" type="text" id="plan" name="pos" maxlength="2" value="'.gpc('pos', 'post').'" />',
|
||||
'temps' => '-',
|
||||
'deblok' => '<span style="color: #FF0000;"><b>Les flottes sont désactivés pour le moment.</b></span>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => ''
|
||||
)
|
||||
);
|
||||
header("X-JSON: ".$json->encode($datas));
|
||||
exit;
|
||||
}
|
||||
|
||||
$destin = gpc('fav_dest', 'post');
|
||||
$destin = gpc('fav_dest', 'post');
|
||||
|
||||
$chapeau = new bdd();
|
||||
$chapeau->connexion();
|
||||
$idPlan = $sess->values['idPlan'];
|
||||
$queryPlanete = $chapeau->unique_query("SELECT * FROM $table_planete WHERE id = '$idPlan'");
|
||||
if (!empty($destin)) {
|
||||
$chapeau->escape($destin);
|
||||
$queryPlaneteRapid = $chapeau->unique_query("SELECT nom_planete, galaxie, ss, position FROM $table_planete WHERE id = $destin;");
|
||||
if ($queryPlaneteRapid) $destinRapid = '['.$queryPlaneteRapid['galaxie'].':'.$queryPlaneteRapid['ss'].':'.$queryPlaneteRapid['position'].']<input type="hidden" id="amas" name="amas" maxlength="2" value="'.$queryPlaneteRapid['galaxie'].'" /><input type="hidden" id="ss" name="ss" maxlength="2" value="'.$queryPlaneteRapid['ss'].'" /><input type="hidden" id="plan" name="pos" maxlength="2" value="'.$queryPlaneteRapid['position'].'" />';
|
||||
}
|
||||
if (!isset($destinRapid)) $destinRapid = '<input class="dest" type="text" id="amas" name="amas" maxlength="2" value="'.gpc('galaxie', 'post').'" />:<input class="dest" type="text" id="ss" name="ss" maxlength="2" value="'.gpc('ss', 'post').'" />:<input class="dest" type="text" id="plan" name="pos" maxlength="2" value="'.gpc('pos', 'post').'" />';
|
||||
$start_galaxie = $queryPlanete['galaxie'];
|
||||
$start_ss = $queryPlanete['ss'];
|
||||
$start_position = $queryPlanete['position'];
|
||||
$chapeau = new bdd();
|
||||
$chapeau->connexion();
|
||||
$idPlan = $sess->values['idPlan'];
|
||||
$queryPlanete = $chapeau->unique_query("SELECT * FROM $table_planete WHERE id = '$idPlan'");
|
||||
if (!empty($destin)) {
|
||||
$chapeau->escape($destin);
|
||||
$queryPlaneteRapid = $chapeau->unique_query("SELECT nom_planete, galaxie, ss, position FROM $table_planete WHERE id = $destin;");
|
||||
if ($queryPlaneteRapid) {
|
||||
$destinRapid = '['.$queryPlaneteRapid['galaxie'].':'.$queryPlaneteRapid['ss'].':'.$queryPlaneteRapid['position'].']<input type="hidden" id="amas" name="amas" maxlength="2" value="'.$queryPlaneteRapid['galaxie'].'" /><input type="hidden" id="ss" name="ss" maxlength="2" value="'.$queryPlaneteRapid['ss'].'" /><input type="hidden" id="plan" name="pos" maxlength="2" value="'.$queryPlaneteRapid['position'].'" />';
|
||||
}
|
||||
}
|
||||
if (!isset($destinRapid)) {
|
||||
$destinRapid = '<input class="dest" type="text" id="amas" name="amas" maxlength="2" value="'.gpc('galaxie', 'post').'" />:<input class="dest" type="text" id="ss" name="ss" maxlength="2" value="'.gpc('ss', 'post').'" />:<input class="dest" type="text" id="plan" name="pos" maxlength="2" value="'.gpc('pos', 'post').'" />';
|
||||
}
|
||||
$start_galaxie = $queryPlanete['galaxie'];
|
||||
$start_ss = $queryPlanete['ss'];
|
||||
$start_position = $queryPlanete['position'];
|
||||
|
||||
$met = gpc('met', 'post');
|
||||
$cri = gpc('cri', 'post');
|
||||
$hyd = gpc('hyd', 'post');
|
||||
if (!empty($sess->values['flcontenu']) && $met+$cri+$hyd >= 0 && $met >= 0 && $cri >= 0 && $hyd >= 0) $places = $sess->values['flcontenu'] - ($met+$cri+$hyd);
|
||||
else $places = 'inconnu';
|
||||
$met = gpc('met', 'post');
|
||||
$cri = gpc('cri', 'post');
|
||||
$hyd = gpc('hyd', 'post');
|
||||
if (!empty($sess->values['flcontenu']) && $met+$cri+$hyd >= 0 && $met >= 0 && $cri >= 0 && $hyd >= 0) {
|
||||
$places = $sess->values['flcontenu'] - ($met+$cri+$hyd);
|
||||
} else {
|
||||
$places = 'inconnu';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (empty($sess->values['fltime']) || $sess->values['fltime'] + 600 < time() || empty($sess->values['flnbvais']) || empty($sess->values['flvitesse']) && isset($sess->values['auth_level']))
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => '-',
|
||||
'deblok' => '<b>Une erreur est survenue lors de la création de la flotte. Veuillez recommencer</b>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
elseif (empty($_POST['nom']) || preg_replace('@[^a-zA-Z0-9_ ]@i', '', $_POST['nom']) != $_POST['nom'])
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => '-',
|
||||
'deblok' => '<b>Nom de la flotte incorrect !</b>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
elseif ($_POST['galaxie'] > MAX_AMAS || $_POST['ss'] > MAX_SYSTEME || $_POST['pos'] > MAX_PLANETE || $_POST['galaxie'] < 0 || $_POST['ss'] < 1 || $_POST['pos'] < 1 || ($_POST['galaxie'] < 1 && $sess->values['auth_level'] < 6))
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => '<span style="color: #FF0000;"><b>Lieu inaccessible</b></span>',
|
||||
'deblok' => '<b>Corrigez la destination !</b>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
else {
|
||||
$_POST['vitesse'] /= 100;
|
||||
$temps = vais_tempsDeplacement($start_galaxie,$start_ss,$start_position,$_POST['galaxie'],$_POST['ss'],$_POST['pos'],$sess->values['flvitesse'],$_POST['vitesse'],$sess->values['flpreparation'],$sess->values['flchauffe']);
|
||||
if ($temps <= 0) $temps = 454;
|
||||
$conso = vais_conso($temps, $sess->values['flnbvais'])*$_POST['vitesse']/45;
|
||||
$places -= ceil($conso*$nbtrajet);
|
||||
$tactique = '';
|
||||
if ($_POST['mission'] == '1') {
|
||||
$tactique = '<label for="selecttactique">Tactique d\'attaque :</label><select id="selecttactique" name="tactique">';
|
||||
//On récupère le niveau actuel de la technologie Commandement militaire
|
||||
$id_user = $sess->values['id'];
|
||||
$table = $config['db_prefix'].'user';
|
||||
$queryUser = $chapeau->unique_query("SELECT * FROM $table WHERE id = '$id_user'");
|
||||
$lvltechno = $queryUser['tactique'];
|
||||
$tactiquedef = $queryUser['combatAT_tactique'];
|
||||
if (empty($sess->values['fltime']) || $sess->values['fltime'] + 600 < time() || empty($sess->values['flnbvais']) || empty($sess->values['flvitesse']) && isset($sess->values['auth_level'])) {
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => '-',
|
||||
'deblok' => '<b>Une erreur est survenue lors de la création de la flotte. Veuillez recommencer</b>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
} elseif (empty($_POST['nom']) || preg_replace('@[^a-zA-Z0-9_ ]@i', '', $_POST['nom']) != $_POST['nom']) {
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => '-',
|
||||
'deblok' => '<b>Nom de la flotte incorrect !</b>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
} elseif ($_POST['galaxie'] > MAX_AMAS || $_POST['ss'] > MAX_SYSTEME || $_POST['pos'] > MAX_PLANETE || $_POST['galaxie'] < 0 || $_POST['ss'] < 1 || $_POST['pos'] < 1 || ($_POST['galaxie'] < 1 && $sess->values['auth_level'] < 6)) {
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => '<span style="color: #FF0000;"><b>Lieu inaccessible</b></span>',
|
||||
'deblok' => '<b>Corrigez la destination !</b>',
|
||||
'conso' => '-',
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$_POST['vitesse'] /= 100;
|
||||
$temps = vais_tempsDeplacement($start_galaxie, $start_ss, $start_position, $_POST['galaxie'], $_POST['ss'], $_POST['pos'], $sess->values['flvitesse'], $_POST['vitesse'], $sess->values['flpreparation'], $sess->values['flchauffe']);
|
||||
if ($temps <= 0) {
|
||||
$temps = 454;
|
||||
}
|
||||
$conso = vais_conso($temps, $sess->values['flnbvais'])*$_POST['vitesse']/45;
|
||||
$places -= ceil($conso*$nbtrajet);
|
||||
$tactique = '';
|
||||
if ($_POST['mission'] == '1') {
|
||||
$tactique = '<label for="selecttactique">Tactique d\'attaque :</label><select id="selecttactique" name="tactique">';
|
||||
//On récupère le niveau actuel de la technologie Commandement militaire
|
||||
$id_user = $sess->values['id'];
|
||||
$table = $config['db_prefix'].'user';
|
||||
$queryUser = $chapeau->unique_query("SELECT * FROM $table WHERE id = '$id_user'");
|
||||
$lvltechno = $queryUser['tactique'];
|
||||
$tactiquedef = $queryUser['combatAT_tactique'];
|
||||
|
||||
if ($lvltechno < 1) { //Si on a pas le niveau, on ne peux pas envoyer la flotte
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => affTemp(floor($temps)),
|
||||
'deblok' => '<b>Vous ne pouvez pas attaquer sans un minimum de connaissances militaires !</b>',
|
||||
'conso' => separerNombres(ceil($conso*$nbtrajet)),
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
header("X-JSON: ".$json->encode($datas));
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
for($i=1 ; $i<=$lvltechno ; $i++) {
|
||||
if ($tactiquedef == $i) $tactique .= '<option value="'.$i.'" selected>'.txtTactique($i).'</option>';
|
||||
else $tactique .= '<option value="'.$i.'">'.txtTactique($i).'</option>';
|
||||
}
|
||||
}
|
||||
$tactique .= '</select><br />';
|
||||
}
|
||||
$cds = sha1('flotte'.$conso.'ß10'.time().'|HB;'.rand(10,99).$temps);
|
||||
$sess->values['flcds'] = $cds;
|
||||
$sess->put();
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => affTemp(floor($temps)),
|
||||
'deblok' => '<input type="hidden" name="cds" value="'.$cds.'" /><input type="submit" value="GO" class="submit" />',
|
||||
'conso' => separerNombres(ceil($conso*2)),
|
||||
'tactique' => $tactique,
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($lvltechno < 1) { //Si on a pas le niveau, on ne peux pas envoyer la flotte
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => affTemp(floor($temps)),
|
||||
'deblok' => '<b>Vous ne pouvez pas attaquer sans un minimum de connaissances militaires !</b>',
|
||||
'conso' => separerNombres(ceil($conso*$nbtrajet)),
|
||||
'tactique' => '',
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
header("X-JSON: ".$json->encode($datas));
|
||||
exit;
|
||||
} else {
|
||||
for ($i=1 ; $i<=$lvltechno ; $i++) {
|
||||
if ($tactiquedef == $i) {
|
||||
$tactique .= '<option value="'.$i.'" selected>'.txtTactique($i).'</option>';
|
||||
} else {
|
||||
$tactique .= '<option value="'.$i.'">'.txtTactique($i).'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$tactique .= '</select><br />';
|
||||
}
|
||||
$cds = sha1('flotte'.$conso.'ß10'.time().'|HB;'.rand(10, 99).$temps);
|
||||
$sess->values['flcds'] = $cds;
|
||||
$sess->put();
|
||||
$datas = array(
|
||||
'root' => array(
|
||||
'destination' => $destinRapid,
|
||||
'temps' => affTemp(floor($temps)),
|
||||
'deblok' => '<input type="hidden" name="cds" value="'.$cds.'" /><input type="submit" value="GO" class="submit" />',
|
||||
'conso' => separerNombres(ceil($conso*2)),
|
||||
'tactique' => $tactique,
|
||||
'places' => separerNombres($places)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$chapeau->deconnexion();
|
||||
header("X-JSON: ".$json->encode($datas));
|
||||
$chapeau->deconnexion();
|
||||
header("X-JSON: ".$json->encode($datas));
|
||||
}
|
||||
?>
|
||||
|
|
@ -4,7 +4,7 @@ define("INDEX", 1); //Définition de la constante anti-hacking
|
|||
$chrono_start = microtime();
|
||||
//Inclusion de l'API Onyx
|
||||
$onyx = @file_get_contents('./.onyx') or die("Configuration introuvable.");
|
||||
define("_FCORE",str_replace('/onyx2/load.php', '/onyx/', trim($onyx)));
|
||||
define("_FCORE", str_replace('/onyx2/load.php', '/onyx/', trim($onyx)));
|
||||
require_once(_FCORE."common.php");
|
||||
$race = 'humain';
|
||||
require_once(_FCORE."../game/noms.php");
|
||||
|
|
@ -12,30 +12,24 @@ require_once(_FCORE."../game/vars.php");
|
|||
|
||||
$tree = array();
|
||||
|
||||
foreach($technologiesCALC as $keyB => $branche)
|
||||
{
|
||||
print "<h3><ins>Branche :</ins> ".$technologiesVAR[$keyB]."</h3>";
|
||||
foreach($branche as $keyT => $tech)
|
||||
{
|
||||
print $tech[0].' : '.$technolo[$keyB][$keyT]."<br />";
|
||||
if ($tech[1] > 0)
|
||||
{
|
||||
print '<em><ins>Requiert :</ins>';
|
||||
foreach($branche as $keyR => $req)
|
||||
{
|
||||
if ($req[0]&$tech[1])
|
||||
print ' '.$technolo[$keyB][$keyR].',';
|
||||
}
|
||||
print '</em><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<em>Ne requiert aucune technologie</em><br />';
|
||||
$tree[] = array($tech);
|
||||
}
|
||||
print "<br />";
|
||||
}
|
||||
}
|
||||
foreach ($technologiesCALC as $keyB => $branche) {
|
||||
print "<h3><ins>Branche :</ins> ".$technologiesVAR[$keyB]."</h3>";
|
||||
foreach ($branche as $keyT => $tech) {
|
||||
print $tech[0].' : '.$technolo[$keyB][$keyT]."<br />";
|
||||
if ($tech[1] > 0) {
|
||||
print '<em><ins>Requiert :</ins>';
|
||||
foreach ($branche as $keyR => $req) {
|
||||
if ($req[0]&$tech[1]) {
|
||||
print ' '.$technolo[$keyB][$keyR].',';
|
||||
}
|
||||
}
|
||||
print '</em><br />';
|
||||
} else {
|
||||
print '<em>Ne requiert aucune technologie</em><br />';
|
||||
$tree[] = array($tech);
|
||||
}
|
||||
print "<br />";
|
||||
}
|
||||
}
|
||||
|
||||
echo("\n<!--Page générée en : ".round((array_sum(explode(' ', microtime()))) - (array_sum(explode(' ', $chrono_start))), 4)." secondes.-->");
|
||||
?>
|
||||
|
|
@ -2,19 +2,24 @@
|
|||
define("INDEX", 1);
|
||||
$chrono_start = microtime();
|
||||
$onyx = @file_get_contents('./.onyx') or die("Configuration introuvable.");
|
||||
define("_FCORE",trim($onyx));
|
||||
define("_FCORE", trim($onyx));
|
||||
require_once(_FCORE."kernel.php");
|
||||
require_once(_FCORE."../game/tables.php");
|
||||
|
||||
$action = intval(gpc('a'));
|
||||
if (isset($sess->values['race'])) $race = $sess->values['race'];
|
||||
else $race = gpc('r');
|
||||
if (isset($sess->values['race'])) {
|
||||
$race = $sess->values['race'];
|
||||
} else {
|
||||
$race = gpc('r');
|
||||
}
|
||||
|
||||
$bdd = new BDD();
|
||||
$bdd->connexion();
|
||||
$act = $bdd->unique_query("SELECT nom FROM $table_bourse WHERE id = $action;");
|
||||
$bdd->deconnexion();
|
||||
if (empty($act)) exit;
|
||||
if (empty($act)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
$values_label = array();
|
||||
|
|
@ -23,82 +28,94 @@ $values_abscisse = array();
|
|||
//Extraction des derniers pourcentages
|
||||
$filename = '';
|
||||
$i = 6;
|
||||
while(!is_file($filename)) {
|
||||
$i++;
|
||||
if ($i > 14) break;
|
||||
$filename = _FCORE."../game/cache/bourse/".$action.".".strftime('%Y%m%d', time() - 86400 * $i).".bourse";
|
||||
while (!is_file($filename)) {
|
||||
$i++;
|
||||
if ($i > 14) {
|
||||
break;
|
||||
}
|
||||
$filename = _FCORE."../game/cache/bourse/".$action.".".strftime('%Y%m%d', time() - 86400 * $i).".bourse";
|
||||
}
|
||||
if (!is_file($filename)) {
|
||||
$i = 7;
|
||||
while(!is_file($filename)) {
|
||||
$i--;
|
||||
if ($i < 0) break;
|
||||
$filename = _FCORE."../game/cache/bourse/".$action.".".strftime('%Y%m%d', time() - 86400 * $i).".bourse";
|
||||
}
|
||||
$i = 7;
|
||||
while (!is_file($filename)) {
|
||||
$i--;
|
||||
if ($i < 0) {
|
||||
break;
|
||||
}
|
||||
$filename = _FCORE."../game/cache/bourse/".$action.".".strftime('%Y%m%d', time() - 86400 * $i).".bourse";
|
||||
}
|
||||
}
|
||||
if (is_file($filename)) {
|
||||
$handle = fopen($filename, "r");
|
||||
while (!feof($handle)) {
|
||||
$r = fgets($handle);
|
||||
if (preg_match('#;#', $r)) $last = $r;
|
||||
}
|
||||
fclose($handle);
|
||||
$calc = $last = explode(';', $last);
|
||||
$handle = fopen($filename, "r");
|
||||
while (!feof($handle)) {
|
||||
$r = fgets($handle);
|
||||
if (preg_match('#;#', $r)) {
|
||||
$last = $r;
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
$calc = $last = explode(';', $last);
|
||||
} else {
|
||||
$calc = $last = array(1, 1, 1);
|
||||
}
|
||||
else $calc = $last = array(1, 1, 1);
|
||||
|
||||
for($i = 6; $i >= 0; $i--){
|
||||
$filename = _FCORE."../game/cache/bourse/".$action.".".strftime('%Y%m%d', time() - 86400 * $i).".bourse";
|
||||
if (is_file($filename)) {
|
||||
$handle = fopen($filename, "r");
|
||||
while (!feof($handle)) {
|
||||
$r = fgets($handle);
|
||||
if (preg_match('#;#', $r)) $last = $r;
|
||||
}
|
||||
fclose($handle);
|
||||
$last = explode(';', $last);
|
||||
}
|
||||
$evolution = intval(($last[1]/$calc[1] - 1) * 100);
|
||||
$values[] = $evolution;
|
||||
if ($evolution >= 0 ) $evolution = '+'.$evolution;
|
||||
$values_label[] = $evolution.'%';
|
||||
$values_abscisse[] = ucfirst(strftime('%a', time() - 86400 * $i));
|
||||
for ($i = 6; $i >= 0; $i--) {
|
||||
$filename = _FCORE."../game/cache/bourse/".$action.".".strftime('%Y%m%d', time() - 86400 * $i).".bourse";
|
||||
if (is_file($filename)) {
|
||||
$handle = fopen($filename, "r");
|
||||
while (!feof($handle)) {
|
||||
$r = fgets($handle);
|
||||
if (preg_match('#;#', $r)) {
|
||||
$last = $r;
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
$last = explode(';', $last);
|
||||
}
|
||||
$evolution = intval(($last[1]/$calc[1] - 1) * 100);
|
||||
$values[] = $evolution;
|
||||
if ($evolution >= 0) {
|
||||
$evolution = '+'.$evolution;
|
||||
}
|
||||
$values_label[] = $evolution.'%';
|
||||
$values_abscisse[] = ucfirst(strftime('%a', time() - 86400 * $i));
|
||||
}
|
||||
|
||||
//*
|
||||
require_once ("../jpgraph/jpgraph.php");
|
||||
require_once ("../jpgraph/jpgraph_line.php");
|
||||
require_once("../jpgraph/jpgraph.php");
|
||||
require_once("../jpgraph/jpgraph_line.php");
|
||||
|
||||
if ($race != "humain" && $race != "covenant") $race = "humain";
|
||||
if ($race != "humain" && $race != "covenant") {
|
||||
$race = "humain";
|
||||
}
|
||||
|
||||
$graph = new Graph(282, 200);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->img->SetMargin(40,20,20,40);
|
||||
$graph->img->SetMargin(40, 20, 20, 40);
|
||||
|
||||
$lineplot=new LinePlot($values);
|
||||
$lineplot->mark->SetType(MARK_UTRIANGLE);
|
||||
$lineplot->value->show();
|
||||
$lineplot->value->SetFont(FF_FONT1,FS_BOLD);
|
||||
$lineplot->value->SetFont(FF_FONT1, FS_BOLD);
|
||||
$lineplot->value->SetFormat('%0.1f');
|
||||
|
||||
//Définition des couleurs
|
||||
$graph->SetBackgroundImage(_FCORE."../game/bourse/".$race.".png", BGIMG_COPY);
|
||||
if ($race == "covenant") {
|
||||
$graph->yaxis->SetColor("#FFFFFF");
|
||||
$graph->xaxis->SetColor("white");
|
||||
$lineplot->SetFillColor("pink@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#c00000");
|
||||
}
|
||||
else {
|
||||
$graph->yaxis->SetColor("#00DD00");
|
||||
$lineplot->SetFillColor("cyan@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#3bb3ff");
|
||||
$graph->yaxis->SetColor("#FFFFFF");
|
||||
$graph->xaxis->SetColor("white");
|
||||
$lineplot->SetFillColor("pink@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#c00000");
|
||||
} else {
|
||||
$graph->yaxis->SetColor("#00DD00");
|
||||
$lineplot->SetFillColor("cyan@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#3bb3ff");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -107,19 +124,19 @@ $graph->title->Set($act['nom']);
|
|||
$graph->yaxis->title->Set("Evolution (%)");
|
||||
$graph->xaxis->SetTickLabels($values_abscisse);
|
||||
|
||||
$graph->title->SetFont(FF_FONT1,FS_BOLD);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
||||
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
||||
$graph->title->SetFont(FF_FONT1, FS_BOLD);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
|
||||
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
|
||||
|
||||
$lineplot->SetWeight(2);
|
||||
|
||||
$graph->Stroke();
|
||||
exit;
|
||||
//*/
|
||||
require_once (_FCORE."../artichow/LinePlot.class.php");
|
||||
require_once(_FCORE."../artichow/LinePlot.class.php");
|
||||
|
||||
$graph = new Graph(282, 200);
|
||||
$graph->setAntiAliasing(FALSE);
|
||||
$graph->setAntiAliasing(false);
|
||||
$graph->border->setColor(new Color(210, 210, 210));
|
||||
$graph->title->set($act['nom']);
|
||||
$graph->title->setFont(new TuffyBold(14));
|
||||
|
|
@ -140,11 +157,11 @@ $plot->setBackgroundColor(new Color(240, 240, 240));
|
|||
$plot->setFillColor(new Color(180, 180, 180, 75));
|
||||
$plot->label->set($values_label);
|
||||
$plot->label->setBackgroundGradient(
|
||||
new LinearGradient(
|
||||
new Color(250, 250, 250, 10),
|
||||
new Color(255, 200, 200, 30),
|
||||
0
|
||||
)
|
||||
new LinearGradient(
|
||||
new Color(250, 250, 250, 10),
|
||||
new Color(255, 200, 200, 30),
|
||||
0
|
||||
)
|
||||
);
|
||||
$plot->label->border->setColor(new Color(20, 20, 20, 20));
|
||||
$plot->label->setPadding(3, 1, 1, 0);
|
||||
|
|
@ -154,13 +171,12 @@ $plot->xAxis->setLabelText($values_abscisse);
|
|||
// On ajoute 5 % d'espace à gauche et à droite de la courbe.
|
||||
// On ne change pas l'espace du haut et du bas de la courbe.
|
||||
$plot->setSpace(
|
||||
5, /* Gauche */
|
||||
5, /* Gauche */
|
||||
5, /* Droite */
|
||||
NULL, /* Haut */
|
||||
NULL /* Bas */
|
||||
null, /* Haut */
|
||||
null /* Bas */
|
||||
);
|
||||
|
||||
$graph->add($plot);
|
||||
|
||||
$graph->draw();
|
||||
?>
|
||||
|
|
@ -9,27 +9,40 @@ require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
|||
require_once("function.php"); //Inclusion des fonctions principales
|
||||
require_once("tables.php"); //Inclusion des noms des tables de base de données correspondant à l'architecture du serveur
|
||||
|
||||
function nomR($string, $race){
|
||||
if ($race == "covenant") {
|
||||
if ($string == 1) return "Cristal";
|
||||
elseif ($string == 2) return "Ions";
|
||||
else return "Metal";
|
||||
}
|
||||
else {
|
||||
if ($string == 1) return "Cristal";
|
||||
elseif ($string == 2) return "Hydrogene";
|
||||
else return "Metal";
|
||||
}
|
||||
function nomR($string, $race)
|
||||
{
|
||||
if ($race == "covenant") {
|
||||
if ($string == 1) {
|
||||
return "Cristal";
|
||||
} elseif ($string == 2) {
|
||||
return "Ions";
|
||||
} else {
|
||||
return "Metal";
|
||||
}
|
||||
} else {
|
||||
if ($string == 1) {
|
||||
return "Cristal";
|
||||
} elseif ($string == 2) {
|
||||
return "Hydrogene";
|
||||
} else {
|
||||
return "Metal";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$action = intval(gpc('a'));
|
||||
if (isset($sess->values['race'])) $race = $sess->values['race'];
|
||||
else $race = gpc('r');
|
||||
if (isset($sess->values['race'])) {
|
||||
$race = $sess->values['race'];
|
||||
} else {
|
||||
$race = gpc('r');
|
||||
}
|
||||
|
||||
$bdd = new BDD();
|
||||
$act = $bdd->unique_query("SELECT id, graph, dispo FROM $table_bourse_ressources WHERE id = $action;");
|
||||
$bdd->deconnexion();
|
||||
if (empty($act)) exit;
|
||||
if (empty($act)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
$values_label = array();
|
||||
|
|
@ -37,50 +50,54 @@ $values_abscisse = array();
|
|||
|
||||
$act['graph'] = unserialize($act['graph']);
|
||||
|
||||
for($i = 1; $i < 8; $i++){
|
||||
if (!isset($act['graph'][(date('w')+$i)%7])) $values[] = 0;
|
||||
else $values[] = ceil(pow($act['graph'][(date('w')+$i)%7], -0.1) * 20000)/10;
|
||||
for ($i = 1; $i < 8; $i++) {
|
||||
if (!isset($act['graph'][(date('w')+$i)%7])) {
|
||||
$values[] = 0;
|
||||
} else {
|
||||
$values[] = ceil(pow($act['graph'][(date('w')+$i)%7], -0.1) * 20000)/10;
|
||||
}
|
||||
}
|
||||
|
||||
for($i = 6; $i >= 0; $i--){
|
||||
$values_label[] = $values[$i];
|
||||
$values_abscisse[] = ucfirst(strftime('%a', time() - 86400 * $i));
|
||||
for ($i = 6; $i >= 0; $i--) {
|
||||
$values_label[] = $values[$i];
|
||||
$values_abscisse[] = ucfirst(strftime('%a', time() - 86400 * $i));
|
||||
}
|
||||
|
||||
//*
|
||||
require_once ("jpgraph/jpgraph.php");
|
||||
require_once ("jpgraph/jpgraph_line.php");
|
||||
require_once("jpgraph/jpgraph.php");
|
||||
require_once("jpgraph/jpgraph_line.php");
|
||||
|
||||
if ($race != "humain" && $race != "covenant") $race = "humain";
|
||||
if ($race != "humain" && $race != "covenant") {
|
||||
$race = "humain";
|
||||
}
|
||||
|
||||
$graph = new Graph(282, 200);
|
||||
$graph->SetScale("textlin");
|
||||
$graph->img->SetMargin(40,20,20,40);
|
||||
$graph->img->SetMargin(40, 20, 20, 40);
|
||||
|
||||
$lineplot=new LinePlot($values);
|
||||
$lineplot->mark->SetType(MARK_UTRIANGLE);
|
||||
$lineplot->value->show();
|
||||
$lineplot->value->SetFont(FF_FONT1,FS_BOLD);
|
||||
$lineplot->value->SetFont(FF_FONT1, FS_BOLD);
|
||||
//$lineplot->value->SetFormat('%0f');
|
||||
|
||||
//Définition des couleurs
|
||||
$graph->SetBackgroundImage(ONYX."include/content/bourse/".$race.".png", BGIMG_COPY);
|
||||
if ($race == "covenant") {
|
||||
$graph->yaxis->SetColor("#FFFFFF");
|
||||
$graph->xaxis->SetColor("white");
|
||||
$lineplot->SetFillColor("pink@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#c00000");
|
||||
}
|
||||
else {
|
||||
$graph->yaxis->SetColor("#00DD00");
|
||||
$lineplot->SetFillColor("cyan@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#3bb3ff");
|
||||
$graph->yaxis->SetColor("#FFFFFF");
|
||||
$graph->xaxis->SetColor("white");
|
||||
$lineplot->SetFillColor("pink@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#c00000");
|
||||
} else {
|
||||
$graph->yaxis->SetColor("#00DD00");
|
||||
$lineplot->SetFillColor("cyan@0.8");
|
||||
$lineplot->value->SetColor('#FF0000');
|
||||
$graph->yaxis->title->SetColor("white");
|
||||
$graph->title->SetColor("white");
|
||||
$lineplot->SetColor("#3bb3ff");
|
||||
}
|
||||
|
||||
$act['nom'] = nomR($act['id'], $race);
|
||||
|
|
@ -90,11 +107,10 @@ $graph->title->Set($act['nom']);
|
|||
$graph->yaxis->title->Set("Evolution (%)");
|
||||
$graph->xaxis->SetTickLabels($values_abscisse);
|
||||
|
||||
$graph->title->SetFont(FF_FONT1,FS_BOLD);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
||||
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
|
||||
$graph->title->SetFont(FF_FONT1, FS_BOLD);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
|
||||
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
|
||||
|
||||
$lineplot->SetWeight(2);
|
||||
|
||||
$graph->Stroke();
|
||||
?>
|
||||
|
|
@ -6,12 +6,14 @@ require_once(trim(file_get_contents('./.onyx')));
|
|||
$SESS = new Session();
|
||||
|
||||
//On défini la configuration
|
||||
if(!isset($_GET['nbr_chiffres']) || $_GET['nbr_chiffres'] < 5)
|
||||
$nbr_chiffres = mt_rand(7, 9); // Nombre de chiffres qui formerons le nombre par défaut
|
||||
else
|
||||
$nbr_chiffres = intval(gpc('nbr_chiffres')); // Si l'on met dans l'adresse un ?nbr_chiffres=X
|
||||
if (!isset($_GET['nbr_chiffres']) || $_GET['nbr_chiffres'] < 5) {
|
||||
$nbr_chiffres = mt_rand(7, 9);
|
||||
} // Nombre de chiffres qui formerons le nombre par défaut
|
||||
else {
|
||||
$nbr_chiffres = intval(gpc('nbr_chiffres'));
|
||||
} // Si l'on met dans l'adresse un ?nbr_chiffres=X
|
||||
|
||||
header ("Content-type: image/png");
|
||||
header("Content-type: image/png");
|
||||
//Création de l'image à partir d'un fond
|
||||
$_img = imagecreatefromgif('fond_verif_img.gif');
|
||||
|
||||
|
|
@ -19,23 +21,30 @@ $_img = imagecreatefromgif('fond_verif_img.gif');
|
|||
//$arriere_plan = imagecolorallocate($_img, 0, 0, 0); // Au cas où on utiliserai pas d'image de fond, on utilise cette couleur là.
|
||||
//On définit les autres couleurs
|
||||
$couleur = mt_rand(0, 4);
|
||||
if ($couleur == 0) $avant_plan = imagecolorallocate($_img, rand(250,225), rand(0,25), rand(0,25));
|
||||
elseif ($couleur == 1) $avant_plan = imagecolorallocate($_img, rand(0,25), rand(250,225), rand(0,25));
|
||||
if ($couleur == 0) {
|
||||
$avant_plan = imagecolorallocate($_img, rand(250, 225), rand(0, 25), rand(0, 25));
|
||||
} elseif ($couleur == 1) {
|
||||
$avant_plan = imagecolorallocate($_img, rand(0, 25), rand(250, 225), rand(0, 25));
|
||||
}
|
||||
// elseif ($couleur == 2) $avant_plan = imagecolorallocate($_img, rand(0,55), rand(0,55), rand(250,255));
|
||||
elseif ($couleur == 3) $avant_plan = imagecolorallocate($_img, rand(0,25), rand(250,225), rand(250,225));
|
||||
elseif ($couleur == 4) $avant_plan = imagecolorallocate($_img, rand(250,225), rand(0,25), rand(250,225));
|
||||
elseif ($couleur == 5) $avant_plan = imagecolorallocate($_img, rand(250,225), rand(250,225), rand(0,25));
|
||||
else $avant_plan = imagecolorallocate($_img, rand(200,225), rand(200,225), rand(200,225));
|
||||
elseif ($couleur == 3) {
|
||||
$avant_plan = imagecolorallocate($_img, rand(0, 25), rand(250, 225), rand(250, 225));
|
||||
} elseif ($couleur == 4) {
|
||||
$avant_plan = imagecolorallocate($_img, rand(250, 225), rand(0, 25), rand(250, 225));
|
||||
} elseif ($couleur == 5) {
|
||||
$avant_plan = imagecolorallocate($_img, rand(250, 225), rand(250, 225), rand(0, 25));
|
||||
} else {
|
||||
$avant_plan = imagecolorallocate($_img, rand(200, 225), rand(200, 225), rand(200, 225));
|
||||
}
|
||||
|
||||
//Définition de la liste des caractères
|
||||
$caracteres = "2345678azertypsdfhjkmwxcbn?";
|
||||
$nb_caracteres = strlen($caracteres)-1;
|
||||
$captcha = "";
|
||||
|
||||
for($i = 0; $i < $nbr_chiffres; $i++)
|
||||
{
|
||||
$alea = mt_rand(0, $nb_caracteres);
|
||||
$captcha .= $caracteres[$alea];
|
||||
for ($i = 0; $i < $nbr_chiffres; $i++) {
|
||||
$alea = mt_rand(0, $nb_caracteres);
|
||||
$captcha .= $caracteres[$alea];
|
||||
}
|
||||
|
||||
$SESS->values['_captcha'] = strtolower($captcha);
|
||||
|
|
@ -49,10 +58,10 @@ unset($chiffre, $i, $caractere, $nbr_chiffres, $nb_caracteres, $caracteres);
|
|||
$fontfile = './2.TTF';
|
||||
|
||||
//imagestring($_img, 5, 18, 8, $nombre, $avant_plan);
|
||||
if ($fontfile == './0.TTF')
|
||||
ImageTTFText($_img, 20, 2, 0, 23, $avant_plan, $fontfile, strtoupper($captcha));
|
||||
else
|
||||
ImageTTFText($_img, 20, mt_rand(1,5), rand(1,7), 30, $avant_plan, $fontfile, $captcha);
|
||||
if ($fontfile == './0.TTF') {
|
||||
ImageTTFText($_img, 20, 2, 0, 23, $avant_plan, $fontfile, strtoupper($captcha));
|
||||
} else {
|
||||
ImageTTFText($_img, 20, mt_rand(1, 5), rand(1, 7), 30, $avant_plan, $fontfile, $captcha);
|
||||
}
|
||||
|
||||
imagepng($_img);
|
||||
?>
|
||||
|
|
|
|||
621
htdocs/index.php
621
htdocs/index.php
|
|
@ -8,355 +8,334 @@ require_once(trim(file_get_contents('./.onyx')));
|
|||
require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
||||
|
||||
//On vérifie si le client est connecté sur le site
|
||||
if (isset($SESS) && !(empty($SESS->values["connected"]) && empty($SESS->values['id']) && empty($SESS->values['race']) && empty($SESS->level)) && isset($SESS->values['idPlan']) && isset($SESS->values['idAsteroide']))
|
||||
{
|
||||
//Si un nouveau joueur cherche à se connecter du même endroit, on déconnecte le joueur en cours avant
|
||||
$HB_login = gpc('l');
|
||||
if (!empty($HB_login) && strtolower($HB_login) != strtolower(trouvNom($SESS->values['id'])))
|
||||
{
|
||||
require("server/logout.php");
|
||||
}
|
||||
elseif (!empty($HB_login))
|
||||
{
|
||||
redirection("./".$VAR["first_page"]);
|
||||
exit;
|
||||
}
|
||||
//Déconnexion de secours
|
||||
elseif (isset($_GET["logout"]))
|
||||
{
|
||||
require("server/logout.php");
|
||||
redirection("./".$VAR["first_page"]);
|
||||
}
|
||||
unset($HB_login);
|
||||
if (isset($SESS) && !(empty($SESS->values["connected"]) && empty($SESS->values['id']) && empty($SESS->values['race']) && empty($SESS->level)) && isset($SESS->values['idPlan']) && isset($SESS->values['idAsteroide'])) {
|
||||
//Si un nouveau joueur cherche à se connecter du même endroit, on déconnecte le joueur en cours avant
|
||||
$HB_login = gpc('l');
|
||||
if (!empty($HB_login) && strtolower($HB_login) != strtolower(trouvNom($SESS->values['id']))) {
|
||||
require("server/logout.php");
|
||||
} elseif (!empty($HB_login)) {
|
||||
redirection("./".$VAR["first_page"]);
|
||||
exit;
|
||||
}
|
||||
//Déconnexion de secours
|
||||
elseif (isset($_GET["logout"])) {
|
||||
require("server/logout.php");
|
||||
redirection("./".$VAR["first_page"]);
|
||||
}
|
||||
unset($HB_login);
|
||||
|
||||
|
||||
$race = $SESS->values["race"];
|
||||
$securePlanete = array();
|
||||
$race = $SESS->values["race"];
|
||||
$securePlanete = array();
|
||||
|
||||
//Inclusion des formules
|
||||
require_once("donnees.php");
|
||||
//On inclus les différentes classes
|
||||
include_once("Class/exceptionHB.php");
|
||||
include_once("Class/user.php");
|
||||
include_once("Class/surface.php");
|
||||
include_once("Class/planete.php");
|
||||
include_once("Class/asteroide.php");
|
||||
include_once("Class/flotte.php");
|
||||
//Inclusion des formules
|
||||
require_once("donnees.php");
|
||||
//On inclus les différentes classes
|
||||
include_once("Class/exceptionHB.php");
|
||||
include_once("Class/user.php");
|
||||
include_once("Class/surface.php");
|
||||
include_once("Class/planete.php");
|
||||
include_once("Class/asteroide.php");
|
||||
include_once("Class/flotte.php");
|
||||
|
||||
//Récupération d'informations au sujet de l'utilisateur
|
||||
$id_user = $SESS->values["id"];
|
||||
$ip = $_SERVER["REMOTE_ADDR"];
|
||||
//Récupération d'informations au sujet de l'utilisateur
|
||||
$id_user = $SESS->values["id"];
|
||||
$ip = $_SERVER["REMOTE_ADDR"];
|
||||
|
||||
//On commence l'envoie des données requise pour les templates
|
||||
$template->assign("menu", array_map("url", $VAR["menu"])); //Envoie des liens du menu latéral
|
||||
$template->assign("auth_level", $SESS->level); //Envoie du niveau d'accès de l'utilisateur
|
||||
$template->assign("race", $race);
|
||||
//On commence l'envoie des données requise pour les templates
|
||||
$template->assign("menu", array_map("url", $VAR["menu"])); //Envoie des liens du menu latéral
|
||||
$template->assign("auth_level", $SESS->level); //Envoie du niveau d'accès de l'utilisateur
|
||||
$template->assign("race", $race);
|
||||
|
||||
//Connexion à la base de données ou reconnexion si la classe existe
|
||||
if (isset($bdd))
|
||||
$bdd->reconnexion();
|
||||
else
|
||||
$bdd = new BDD();
|
||||
//Connexion à la base de données ou reconnexion si la classe existe
|
||||
if (isset($bdd)) {
|
||||
$bdd->reconnexion();
|
||||
} else {
|
||||
$bdd = new BDD();
|
||||
}
|
||||
|
||||
//Recherche de multicompte
|
||||
$multi = $bdd->query("SELECT U.pseudo, R.id_util FROM $table_registre_identification R INNER JOIN $table_user U ON U.id = R.id_util WHERE R.ip = '$ip' GROUP BY R.ip, R.id_util HAVING R.id_util != $id_user;");
|
||||
//Recherche de multicompte
|
||||
$multi = $bdd->query("SELECT U.pseudo, R.id_util FROM $table_registre_identification R INNER JOIN $table_user U ON U.id = R.id_util WHERE R.ip = '$ip' GROUP BY R.ip, R.id_util HAVING R.id_util != $id_user;");
|
||||
|
||||
//On gère les demande de changement de planète
|
||||
if (isset($_POST["planete"]))
|
||||
{
|
||||
if (preg_match("#A#", $_POST["planete"]))
|
||||
{
|
||||
$idAsteroideTest = intval(substr(gpc("planete", "post"), 1));
|
||||
if ($bdd->unique_query("SELECT id FROM $table_alliances WHERE id = $idAsteroideTest;") && $bdd->unique_query("SELECT id FROM $table_user WHERE id = $id_user AND id_alliance = $idAsteroideTest;"))
|
||||
{
|
||||
$SESS->values["idPlan"] = 0;
|
||||
$SESS->values["idAsteroide"] = $idAsteroideTest;
|
||||
$SESS->values["isolement"] = 0;
|
||||
$SESS->put();
|
||||
$template->assign("page","vp");
|
||||
$template->display("game/vp.tpl");
|
||||
exit;
|
||||
}
|
||||
unset($idAsteroideTest);
|
||||
}
|
||||
else
|
||||
{
|
||||
$idPlanTest = intval(gpc("planete", "post"));
|
||||
if ($bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = $id_user AND id = $idPlanTest;"))
|
||||
{
|
||||
$SESS->values["idPlan"] = $idPlanTest;
|
||||
$SESS->values["idAsteroide"] = 0;
|
||||
$SESS->values["isolement"] = 0;
|
||||
$SESS->put();
|
||||
$template->assign("page","vp");
|
||||
$template->display("game/vp.tpl");
|
||||
exit;
|
||||
}
|
||||
unset($idPlanTest);
|
||||
}
|
||||
}
|
||||
$idPlan = $SESS->values["idPlan"];
|
||||
$idAsteroide = $SESS->values["idAsteroide"];
|
||||
//On gère les demande de changement de planète
|
||||
if (isset($_POST["planete"])) {
|
||||
if (preg_match("#A#", $_POST["planete"])) {
|
||||
$idAsteroideTest = intval(substr(gpc("planete", "post"), 1));
|
||||
if ($bdd->unique_query("SELECT id FROM $table_alliances WHERE id = $idAsteroideTest;") && $bdd->unique_query("SELECT id FROM $table_user WHERE id = $id_user AND id_alliance = $idAsteroideTest;")) {
|
||||
$SESS->values["idPlan"] = 0;
|
||||
$SESS->values["idAsteroide"] = $idAsteroideTest;
|
||||
$SESS->values["isolement"] = 0;
|
||||
$SESS->put();
|
||||
$template->assign("page", "vp");
|
||||
$template->display("game/vp.tpl");
|
||||
exit;
|
||||
}
|
||||
unset($idAsteroideTest);
|
||||
} else {
|
||||
$idPlanTest = intval(gpc("planete", "post"));
|
||||
if ($bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = $id_user AND id = $idPlanTest;")) {
|
||||
$SESS->values["idPlan"] = $idPlanTest;
|
||||
$SESS->values["idAsteroide"] = 0;
|
||||
$SESS->values["isolement"] = 0;
|
||||
$SESS->put();
|
||||
$template->assign("page", "vp");
|
||||
$template->display("game/vp.tpl");
|
||||
exit;
|
||||
}
|
||||
unset($idPlanTest);
|
||||
}
|
||||
}
|
||||
$idPlan = $SESS->values["idPlan"];
|
||||
$idAsteroide = $SESS->values["idAsteroide"];
|
||||
|
||||
$queryMail1 = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE destinataire = $id_user AND expediteur != false AND vu = '1';");
|
||||
$queryMail2 = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE destinataire = $id_user AND expediteur = false AND vu = '1';");
|
||||
$queryMail = array($queryMail1["nombre"], $queryMail2["nombre"]);
|
||||
$queryPlanetes = $bdd->query("SELECT * FROM $table_planete WHERE id_user = $id_user ORDER BY id ASC;");
|
||||
$queryMail1 = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE destinataire = $id_user AND expediteur != false AND vu = '1';");
|
||||
$queryMail2 = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE destinataire = $id_user AND expediteur = false AND vu = '1';");
|
||||
$queryMail = array($queryMail1["nombre"], $queryMail2["nombre"]);
|
||||
$queryPlanetes = $bdd->query("SELECT * FROM $table_planete WHERE id_user = $id_user ORDER BY id ASC;");
|
||||
|
||||
$bdd->deconnexion();
|
||||
unset($queryMail1, $queryMail2);
|
||||
$bdd->deconnexion();
|
||||
unset($queryMail1, $queryMail2);
|
||||
|
||||
//Chargement de la planète/astéroide actuel
|
||||
if ($idPlan == 0 && $idAsteroide == 0)
|
||||
{
|
||||
trigger_error('Planète et Asteroïde nul, deconnexion du joueur '.$id_user,E_USER_ERROR);
|
||||
include("server/logout.php");
|
||||
exit;
|
||||
}
|
||||
elseif ($idPlan == 0)
|
||||
{
|
||||
define('SURFACE', 'asteroide');
|
||||
$planete = new Asteroide($idAsteroide);
|
||||
$planete->actualiser();
|
||||
//On charge les permissions de l'utilisateur pour l'alliance
|
||||
$planete->loadPermissions($planete->fondateur);
|
||||
}
|
||||
else
|
||||
{
|
||||
define('SURFACE', 'planete');
|
||||
$planete = new Planete($idPlan);
|
||||
$planete->actualiser();
|
||||
}
|
||||
unset($ip, $idAsteroide, $idPlan);
|
||||
//Chargement de la planète/astéroide actuel
|
||||
if ($idPlan == 0 && $idAsteroide == 0) {
|
||||
trigger_error('Planète et Asteroïde nul, deconnexion du joueur '.$id_user, E_USER_ERROR);
|
||||
include("server/logout.php");
|
||||
exit;
|
||||
} elseif ($idPlan == 0) {
|
||||
define('SURFACE', 'asteroide');
|
||||
$planete = new Asteroide($idAsteroide);
|
||||
$planete->actualiser();
|
||||
//On charge les permissions de l'utilisateur pour l'alliance
|
||||
$planete->loadPermissions($planete->fondateur);
|
||||
} else {
|
||||
define('SURFACE', 'planete');
|
||||
$planete = new Planete($idPlan);
|
||||
$planete->actualiser();
|
||||
}
|
||||
unset($ip, $idAsteroide, $idPlan);
|
||||
|
||||
//On vérifie que le joueur ne soit pas en mode vacances forcé
|
||||
if ($planete->mv > 0)
|
||||
{
|
||||
$SESS->close();
|
||||
redirection($config["first_page"]."?mvf");
|
||||
exit;
|
||||
}
|
||||
//On vérifie que le joueur ne soit pas en mode vacances forcé
|
||||
if ($planete->mv > 0) {
|
||||
$SESS->close();
|
||||
redirection($config["first_page"]."?mvf");
|
||||
exit;
|
||||
}
|
||||
|
||||
//NOMS ET FLOTTES
|
||||
include("flottes.php");
|
||||
//NOMS ET FLOTTES
|
||||
include("flottes.php");
|
||||
|
||||
//Envoie d'informations au template
|
||||
$template->assign("alertMail", $queryMail);
|
||||
$template->assign("planete", $planete);
|
||||
$template->assign("planetes", $queryPlanetes);
|
||||
//Envoie d'informations au template
|
||||
$template->assign("alertMail", $queryMail);
|
||||
$template->assign("planete", $planete);
|
||||
$template->assign("planetes", $queryPlanetes);
|
||||
|
||||
//Calcul du temps de jeu
|
||||
$tpsdejeu = time() - $planete->last_visite;
|
||||
$heur = floor($tpsdejeu/3600);
|
||||
$min = floor(($tpsdejeu%3600)/60);
|
||||
if ($heur > 0)
|
||||
$min = $heur." h ".$min;
|
||||
$template->assign("tpsdejeu", $min." min");
|
||||
unset($tpsdejeu, $heur, $min, $queryMail);
|
||||
//Calcul du temps de jeu
|
||||
$tpsdejeu = time() - $planete->last_visite;
|
||||
$heur = floor($tpsdejeu/3600);
|
||||
$min = floor(($tpsdejeu%3600)/60);
|
||||
if ($heur > 0) {
|
||||
$min = $heur." h ".$min;
|
||||
}
|
||||
$template->assign("tpsdejeu", $min." min");
|
||||
unset($tpsdejeu, $heur, $min, $queryMail);
|
||||
|
||||
//Récupération de la page demandée
|
||||
$p = gpc('p');
|
||||
//Récupération de la page demandée
|
||||
$p = gpc('p');
|
||||
|
||||
//Vérification de l'isolement de la planète
|
||||
if ((empty($SESS->values['isolement']) || time() >= $SESS->values['isolement']) && $p != 'operateur' && $p != 'demarrage' && $p != 'avertmulti' && $p != 'chat' && $p != 'rename' && $p != 'accueil' && $p != 'arbre' && $p != 'prochainement' && $p != 'options' && $p != 'messagerie' && $p != 'envoyer' && $p != 'classement' && $p != 'bugs' && $p != 'deconnexion')
|
||||
{
|
||||
//TODO Si la planète est en isolement total, faire un autre message
|
||||
if ($planete->isolement())
|
||||
{
|
||||
$template->assign("titre", "Planète isolée");
|
||||
erreur("Impossible de rentrer en contact avec cette planète.<br />Réessayez vers ".date('H:i', $planete->isolement[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$SESS->values["isolement"] = $planete->isolement[0];
|
||||
$SESS->put();
|
||||
}
|
||||
}
|
||||
//Vérification de l'isolement de la planète
|
||||
if ((empty($SESS->values['isolement']) || time() >= $SESS->values['isolement']) && $p != 'operateur' && $p != 'demarrage' && $p != 'avertmulti' && $p != 'chat' && $p != 'rename' && $p != 'accueil' && $p != 'arbre' && $p != 'prochainement' && $p != 'options' && $p != 'messagerie' && $p != 'envoyer' && $p != 'classement' && $p != 'bugs' && $p != 'deconnexion') {
|
||||
//TODO Si la planète est en isolement total, faire un autre message
|
||||
if ($planete->isolement()) {
|
||||
$template->assign("titre", "Planète isolée");
|
||||
erreur("Impossible de rentrer en contact avec cette planète.<br />Réessayez vers ".date('H:i', $planete->isolement[1]));
|
||||
} else {
|
||||
$SESS->values["isolement"] = $planete->isolement[0];
|
||||
$SESS->put();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($SESS->values["avert"]) && $p != "avertmulti" && $p != "demarrage")
|
||||
include("server/avert.php");
|
||||
else
|
||||
{
|
||||
switch($p)
|
||||
{
|
||||
case "batiments":
|
||||
include("game/batiments.php");
|
||||
break;
|
||||
case "caserne":
|
||||
include("game/caserne.php");
|
||||
break;
|
||||
case "chantierspatial":
|
||||
include("game/chantierspatial.php");
|
||||
break;
|
||||
case "chantierterrestre":
|
||||
include("game/chantierterrestre.php");
|
||||
break;
|
||||
case "laboratoire":
|
||||
include("game/laboratoire.php");
|
||||
break;
|
||||
case "arbre":
|
||||
include("game/arbre.php");
|
||||
break;
|
||||
case "description":
|
||||
include("game/description.php");
|
||||
break;
|
||||
case "ressources":
|
||||
include("game/ressources.php");
|
||||
break;
|
||||
case "diplomatie":
|
||||
include("game/diplomatie.php");
|
||||
break;
|
||||
case "gestion":
|
||||
include("game/gestion.php");
|
||||
break;
|
||||
case "marche":
|
||||
include("game/marche.php");
|
||||
break;
|
||||
case "flotte":
|
||||
include("game/flotte.php");
|
||||
break;
|
||||
case "carte":
|
||||
include("game/carte.php");
|
||||
break;
|
||||
case "alliances":
|
||||
include("game/alliance.php");
|
||||
break;
|
||||
if (isset($SESS->values["avert"]) && $p != "avertmulti" && $p != "demarrage") {
|
||||
include("server/avert.php");
|
||||
} else {
|
||||
switch ($p) {
|
||||
case "batiments":
|
||||
include("game/batiments.php");
|
||||
break;
|
||||
case "caserne":
|
||||
include("game/caserne.php");
|
||||
break;
|
||||
case "chantierspatial":
|
||||
include("game/chantierspatial.php");
|
||||
break;
|
||||
case "chantierterrestre":
|
||||
include("game/chantierterrestre.php");
|
||||
break;
|
||||
case "laboratoire":
|
||||
include("game/laboratoire.php");
|
||||
break;
|
||||
case "arbre":
|
||||
include("game/arbre.php");
|
||||
break;
|
||||
case "description":
|
||||
include("game/description.php");
|
||||
break;
|
||||
case "ressources":
|
||||
include("game/ressources.php");
|
||||
break;
|
||||
case "diplomatie":
|
||||
include("game/diplomatie.php");
|
||||
break;
|
||||
case "gestion":
|
||||
include("game/gestion.php");
|
||||
break;
|
||||
case "marche":
|
||||
include("game/marche.php");
|
||||
break;
|
||||
case "flotte":
|
||||
include("game/flotte.php");
|
||||
break;
|
||||
case "carte":
|
||||
include("game/carte.php");
|
||||
break;
|
||||
case "alliances":
|
||||
include("game/alliance.php");
|
||||
break;
|
||||
|
||||
case "rename":
|
||||
include("game/rename.php");
|
||||
break;
|
||||
case "messagerie":
|
||||
include("server/messagerie.php");
|
||||
break;
|
||||
case "alli_messagerie":
|
||||
include("game/alliances/messagerie.php");
|
||||
break;
|
||||
case "options":
|
||||
case "changeopt":
|
||||
include("server/options.php");
|
||||
break;
|
||||
case "amis":
|
||||
include("server/amis.php");
|
||||
break;
|
||||
case "destinationsrapides":
|
||||
include("server/destinrapid.php");
|
||||
break;
|
||||
case "chat":
|
||||
$page = 'chat'; $titre = 'Chat';
|
||||
break;
|
||||
case "alli_chat":
|
||||
include("game/alliances/chat.php");
|
||||
break;
|
||||
case "aide":
|
||||
case "faq":
|
||||
include("server/aide.php");
|
||||
break;
|
||||
case "rename":
|
||||
include("game/rename.php");
|
||||
break;
|
||||
case "messagerie":
|
||||
include("server/messagerie.php");
|
||||
break;
|
||||
case "alli_messagerie":
|
||||
include("game/alliances/messagerie.php");
|
||||
break;
|
||||
case "options":
|
||||
case "changeopt":
|
||||
include("server/options.php");
|
||||
break;
|
||||
case "amis":
|
||||
include("server/amis.php");
|
||||
break;
|
||||
case "destinationsrapides":
|
||||
include("server/destinrapid.php");
|
||||
break;
|
||||
case "chat":
|
||||
$page = 'chat'; $titre = 'Chat';
|
||||
break;
|
||||
case "alli_chat":
|
||||
include("game/alliances/chat.php");
|
||||
break;
|
||||
case "aide":
|
||||
case "faq":
|
||||
include("server/aide.php");
|
||||
break;
|
||||
|
||||
case "operateur":
|
||||
include("server/operateur.php");
|
||||
break;
|
||||
case "prochainement":
|
||||
$page = "prochainement";
|
||||
$titre = "Prochainement";
|
||||
break;
|
||||
case "version":
|
||||
include("server/version.php");
|
||||
break;
|
||||
case "demarrage":
|
||||
include("server/demarrage.php");
|
||||
break;
|
||||
case "avertmulti":
|
||||
include("server/avertmulti.php");
|
||||
break;
|
||||
case "operateur":
|
||||
include("server/operateur.php");
|
||||
break;
|
||||
case "prochainement":
|
||||
$page = "prochainement";
|
||||
$titre = "Prochainement";
|
||||
break;
|
||||
case "version":
|
||||
include("server/version.php");
|
||||
break;
|
||||
case "demarrage":
|
||||
include("server/demarrage.php");
|
||||
break;
|
||||
case "avertmulti":
|
||||
include("server/avertmulti.php");
|
||||
break;
|
||||
|
||||
case "pilori":
|
||||
include("server/pilori.php");
|
||||
break;
|
||||
case "conditions":
|
||||
include("server/conditions.php");
|
||||
break;
|
||||
case "regles":
|
||||
include("game/regles.php");
|
||||
break;
|
||||
case "pilori":
|
||||
include("server/pilori.php");
|
||||
break;
|
||||
case "conditions":
|
||||
include("server/conditions.php");
|
||||
break;
|
||||
case "regles":
|
||||
include("game/regles.php");
|
||||
break;
|
||||
|
||||
case "deconnexion":
|
||||
case "logout":
|
||||
include("server/logout.php");
|
||||
break;
|
||||
default:
|
||||
include("game/accueil.php");
|
||||
}
|
||||
}
|
||||
//On supprime les dernières variables inutiles pour la suite
|
||||
unset($planete, $SESS, $bdd, $VAR, $queryPlanetes, $_POST, $_GET, $LANG);
|
||||
case "deconnexion":
|
||||
case "logout":
|
||||
include("server/logout.php");
|
||||
break;
|
||||
default:
|
||||
include("game/accueil.php");
|
||||
}
|
||||
}
|
||||
//On supprime les dernières variables inutiles pour la suite
|
||||
unset($planete, $SESS, $bdd, $VAR, $queryPlanetes, $_POST, $_GET, $LANG);
|
||||
|
||||
//Inclusion de la pub et du footer
|
||||
include("pub.php");
|
||||
//Inclusion de la pub et du footer
|
||||
include("pub.php");
|
||||
|
||||
$template->assign("page", $page);
|
||||
if (isset($titre))
|
||||
$template->assign("titre", $titre);
|
||||
$template->assign("page", $page);
|
||||
if (isset($titre)) {
|
||||
$template->assign("titre", $titre);
|
||||
}
|
||||
|
||||
$template->display("game/".$page.".tpl");
|
||||
$template->display("game/".$page.".tpl");
|
||||
}
|
||||
//Si le client n'est pas connecté au site
|
||||
else
|
||||
{
|
||||
include("server/connexion.php");
|
||||
else {
|
||||
include("server/connexion.php");
|
||||
|
||||
$p = gpc('p');
|
||||
switch($p){
|
||||
//Serveur principal
|
||||
/* case "validation":
|
||||
include('game/validation.php');
|
||||
break;
|
||||
case "inscription":
|
||||
include('game/inscription.php');
|
||||
break;
|
||||
case "oubliemdp":
|
||||
redirection('http://halo-battle.fr/');
|
||||
break;*/
|
||||
//Serveur de jeu
|
||||
$p = gpc('p');
|
||||
switch ($p) {
|
||||
//Serveur principal
|
||||
/* case "validation":
|
||||
include('game/validation.php');
|
||||
break;
|
||||
case "inscription":
|
||||
include('game/inscription.php');
|
||||
break;
|
||||
case "oubliemdp":
|
||||
redirection('http://halo-battle.fr/');
|
||||
break;*/
|
||||
//Serveur de jeu
|
||||
case "inscription":
|
||||
include('server/inscription.php');
|
||||
break;
|
||||
include('server/inscription.php');
|
||||
break;
|
||||
case "validation":
|
||||
include('server/validation.php');
|
||||
break;
|
||||
case "classement":
|
||||
include(_FCORE."../game/classement.php");
|
||||
break;
|
||||
case "njoueur":
|
||||
include("server/njoueur.php");
|
||||
break;
|
||||
case "inscription":
|
||||
redirection('http://halo-battle.s-fr.com/?p=inscription');
|
||||
exit;
|
||||
break;
|
||||
case "oubliemdp":
|
||||
include("server/oubliemdp.php");
|
||||
break;
|
||||
case "pilori":
|
||||
include("server/pilori.php");
|
||||
break;
|
||||
//Tous serveurs
|
||||
case "conditions":
|
||||
include("server/conditions.php");
|
||||
break;
|
||||
case "regles":
|
||||
include("server/regles.php");
|
||||
break;
|
||||
case "changeopt":
|
||||
erreur("Vous devez être connecté pour affectuer cette action !");
|
||||
case "connexion":
|
||||
default:
|
||||
$page = 'mini';
|
||||
break;
|
||||
//default:
|
||||
//$page = 'mini';
|
||||
// redirection('?p=connexion');
|
||||
// exit;
|
||||
}
|
||||
$template->display('cms/'.$page.'.tpl');
|
||||
include('server/validation.php');
|
||||
break;
|
||||
case "classement":
|
||||
include(_FCORE."../game/classement.php");
|
||||
break;
|
||||
case "njoueur":
|
||||
include("server/njoueur.php");
|
||||
break;
|
||||
case "inscription":
|
||||
redirection('http://halo-battle.s-fr.com/?p=inscription');
|
||||
exit;
|
||||
break;
|
||||
case "oubliemdp":
|
||||
include("server/oubliemdp.php");
|
||||
break;
|
||||
case "pilori":
|
||||
include("server/pilori.php");
|
||||
break;
|
||||
//Tous serveurs
|
||||
case "conditions":
|
||||
include("server/conditions.php");
|
||||
break;
|
||||
case "regles":
|
||||
include("server/regles.php");
|
||||
break;
|
||||
case "changeopt":
|
||||
erreur("Vous devez être connecté pour affectuer cette action !");
|
||||
// no break
|
||||
case "connexion":
|
||||
default:
|
||||
$page = 'mini';
|
||||
break;
|
||||
//default:
|
||||
//$page = 'mini';
|
||||
// redirection('?p=connexion');
|
||||
// exit;
|
||||
}
|
||||
$template->display('cms/'.$page.'.tpl');
|
||||
}
|
||||
?>
|
||||
|
|
@ -5,139 +5,133 @@
|
|||
<body>
|
||||
<h2>Vérification de l'intégrité des fichiers</h2>
|
||||
<?php
|
||||
define ('FILE_SAV', "../onyx2/cache/checksum.php");
|
||||
define ('dir_start', "../");
|
||||
define('FILE_SAV', "../onyx2/cache/checksum.php");
|
||||
define('dir_start', "../");
|
||||
|
||||
print 'Chargement du fichier de comparaison ...';
|
||||
if (is_file('checkSum.php'))
|
||||
{
|
||||
print ' Touvé ...';
|
||||
$SUM = sha1(file_get_contents('checkSum.php'));
|
||||
print ' Données chargées avec succès<br /><br />';
|
||||
}
|
||||
if (is_file('checkSum.php')) {
|
||||
print ' Touvé ...';
|
||||
$SUM = sha1(file_get_contents('checkSum.php'));
|
||||
print ' Données chargées avec succès<br /><br />';
|
||||
}
|
||||
|
||||
print 'Vérification du fichier de validation ...';
|
||||
if (sha1(sha1_file(__FILE__)) != $SUM)
|
||||
if (sha1(sha1_file(__FILE__)) != $SUM) {
|
||||
die(' INVALIDE !<br />Arrêt du processus de validation !');
|
||||
else
|
||||
} else {
|
||||
print ' Valide<br /><br />';
|
||||
}
|
||||
|
||||
print 'Recherche du fichier de sauvegarde ...';
|
||||
if (is_file(FILE_SAV) && !isset($_GET['erase']))
|
||||
if (is_file(FILE_SAV) && !isset($_GET['erase'])) {
|
||||
function parcourDir($dir, $sums)
|
||||
{
|
||||
function parcourDir($dir, $sums)
|
||||
{
|
||||
if (isset($_GET['v']))
|
||||
print "<br />Parcours du dossier à la recherche de nouveaux fichiers : ".$dir;
|
||||
if (isset($_GET['v'])) {
|
||||
print "<br />Parcours du dossier à la recherche de nouveaux fichiers : ".$dir;
|
||||
}
|
||||
|
||||
$new = 0;
|
||||
$pointeur = opendir($dir);
|
||||
while ($fichier = readdir($pointeur))
|
||||
{
|
||||
if($fichier == '.' || $fichier == '..' || $fichier == '.svn' || preg_match("#~#", $fichier))
|
||||
continue;
|
||||
|
||||
if(is_dir($dir.$fichier) && is_readable($dir.$fichier))
|
||||
$new += parcourDir($dir.$fichier.'/', $sums);
|
||||
|
||||
elseif(is_file($dir.$fichier))
|
||||
{
|
||||
if (!isset($sums[$dir.$fichier]))
|
||||
{
|
||||
$new++;
|
||||
print "<tr style=\"background: #00FFFF;\"><td>".$dir.$fichier."</td><td style=\"text-align: center;\">Nouveau fichier !</td></tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($pointeur);
|
||||
|
||||
return $new;
|
||||
$new = 0;
|
||||
$pointeur = opendir($dir);
|
||||
while ($fichier = readdir($pointeur)) {
|
||||
if ($fichier == '.' || $fichier == '..' || $fichier == '.svn' || preg_match("#~#", $fichier)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
print ' Trouvé<br /><br />';
|
||||
|
||||
if (isset($_GET["check"]))
|
||||
{
|
||||
print 'Contrôle de la somme de la dernière validation ...';
|
||||
if (sha1(sha1_file(FILE_SAV).'<^>'.sha1_file(__FILE__).sha1_file('checkSum.php')) == $_GET["check"])
|
||||
print ' <span style="color: #00FF00;">Authentique</span><br /><br />';
|
||||
else
|
||||
die (' Invalide !<br />Arrêt du processus de vérification !');
|
||||
|
||||
if (is_dir($dir.$fichier) && is_readable($dir.$fichier)) {
|
||||
$new += parcourDir($dir.$fichier.'/', $sums);
|
||||
} elseif (is_file($dir.$fichier)) {
|
||||
if (!isset($sums[$dir.$fichier])) {
|
||||
$new++;
|
||||
print "<tr style=\"background: #00FFFF;\"><td>".$dir.$fichier."</td><td style=\"text-align: center;\">Nouveau fichier !</td></tr>";
|
||||
}
|
||||
}
|
||||
else
|
||||
print '<span style="color: #FF0000; font-weigth: bold;">Les résultats présentés ci-dessus ne peuvent pas être authentifiés sans la somme d\'un précédent contrôle, rien ne dit que les fichiers de validation n\'ont pas été modifiés !</span><br /><br />';
|
||||
|
||||
$start = unserialize(file_get_contents(FILE_SAV));
|
||||
|
||||
print ' Vérification des fichiers ...';
|
||||
print '<table border="1" style=""><tr><th>Nom du fichier</th><th>Détails</th></tr>';
|
||||
$alerte = 0;
|
||||
foreach($start as $key => $sum)
|
||||
{
|
||||
if (!is_file($key))
|
||||
{
|
||||
$alerte++;
|
||||
if (!isset($_GET['a']))
|
||||
print "<tr style=\"background: #FFCC00;\"><td>".$key."</td><td style=\"text-align: center;\">Fichier supprimé !</td></tr>";
|
||||
}
|
||||
elseif (sha1_file($key) != $sum)
|
||||
{
|
||||
$alerte++;
|
||||
print "<tr style=\"background: #FF0000;\"><td>".$key."</td><td style=\"text-align: center;\">Alerte de différence de somme !</td></tr>";
|
||||
}
|
||||
elseif (isset($_GET['v']))
|
||||
print "<tr style=\"background: #00FF00;\"><td>".$key."</td><td style=\"text-align: center;\">Ok</td></tr>";
|
||||
}
|
||||
$newFiles = parcourDir(dir_start, $start);
|
||||
print '</table>';
|
||||
|
||||
print '<br />Fin de la vérification : '.$alerte.' alerte(s) sur '.count($start).' fichier(s). '.$newFiles.' nouveau(x) fichier(s).';
|
||||
|
||||
print '<br /><br />Contôle de la prochaine validation : '.sha1(sha1_file(FILE_SAV).'<^>'.sha1_file(__FILE__).sha1_file('checkSum.php'));
|
||||
}
|
||||
closedir($pointeur);
|
||||
|
||||
return $new;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_GET['erase']) && $_GET['erase'] == $SUM)
|
||||
print ' Trouvé<br />Détection d\'une demande d\'effacement<br /><br />';
|
||||
elseif (!is_file(FILE_SAV))
|
||||
//print ' Introuvable<br /><br />';
|
||||
die (' Introuvable<br /><br />Arrêt de la vérification.');
|
||||
else
|
||||
die(' ?<br /><br />Impossible de déterminer l\'origine de la requête !<br />Arrêt de la vérification.');
|
||||
|
||||
function extractDir($dir)
|
||||
{
|
||||
$sums = array();
|
||||
print ' Trouvé<br /><br />';
|
||||
|
||||
if (isset($_GET['v']))
|
||||
print "<br />Génération des sommes de fichiers pour le dossier : ".$dir;
|
||||
if (isset($_GET["check"])) {
|
||||
print 'Contrôle de la somme de la dernière validation ...';
|
||||
if (sha1(sha1_file(FILE_SAV).'<^>'.sha1_file(__FILE__).sha1_file('checkSum.php')) == $_GET["check"]) {
|
||||
print ' <span style="color: #00FF00;">Authentique</span><br /><br />';
|
||||
} else {
|
||||
die(' Invalide !<br />Arrêt du processus de vérification !');
|
||||
}
|
||||
} else {
|
||||
print '<span style="color: #FF0000; font-weigth: bold;">Les résultats présentés ci-dessus ne peuvent pas être authentifiés sans la somme d\'un précédent contrôle, rien ne dit que les fichiers de validation n\'ont pas été modifiés !</span><br /><br />';
|
||||
}
|
||||
|
||||
$pointeur = opendir($dir);
|
||||
while ($fichier = readdir($pointeur))
|
||||
{
|
||||
if($fichier == '.' || $fichier == '..' || $fichier == '.svn' || preg_match("#~#", $fichier))
|
||||
continue;
|
||||
|
||||
if(is_dir($dir.$fichier) && is_readable($dir.$fichier))
|
||||
$sums = array_merge($sums, extractDir($dir.$fichier.'/'));
|
||||
|
||||
elseif(is_file($dir.$fichier))
|
||||
$sums[$dir.$fichier] = sha1_file($dir.$fichier);
|
||||
}
|
||||
closedir($pointeur);
|
||||
|
||||
return $sums;
|
||||
$start = unserialize(file_get_contents(FILE_SAV));
|
||||
|
||||
print ' Vérification des fichiers ...';
|
||||
print '<table border="1" style=""><tr><th>Nom du fichier</th><th>Détails</th></tr>';
|
||||
$alerte = 0;
|
||||
foreach ($start as $key => $sum) {
|
||||
if (!is_file($key)) {
|
||||
$alerte++;
|
||||
if (!isset($_GET['a'])) {
|
||||
print "<tr style=\"background: #FFCC00;\"><td>".$key."</td><td style=\"text-align: center;\">Fichier supprimé !</td></tr>";
|
||||
}
|
||||
} elseif (sha1_file($key) != $sum) {
|
||||
$alerte++;
|
||||
print "<tr style=\"background: #FF0000;\"><td>".$key."</td><td style=\"text-align: center;\">Alerte de différence de somme !</td></tr>";
|
||||
} elseif (isset($_GET['v'])) {
|
||||
print "<tr style=\"background: #00FF00;\"><td>".$key."</td><td style=\"text-align: center;\">Ok</td></tr>";
|
||||
}
|
||||
}
|
||||
$newFiles = parcourDir(dir_start, $start);
|
||||
print '</table>';
|
||||
|
||||
print 'Génération du tableau ...';
|
||||
print '<br />Fin de la vérification : '.$alerte.' alerte(s) sur '.count($start).' fichier(s). '.$newFiles.' nouveau(x) fichier(s).';
|
||||
|
||||
print '<br /><br />Contôle de la prochaine validation : '.sha1(sha1_file(FILE_SAV).'<^>'.sha1_file(__FILE__).sha1_file('checkSum.php'));
|
||||
} else {
|
||||
if (isset($_GET['erase']) && $_GET['erase'] == $SUM) {
|
||||
print ' Trouvé<br />Détection d\'une demande d\'effacement<br /><br />';
|
||||
} elseif (!is_file(FILE_SAV)) {
|
||||
//print ' Introuvable<br /><br />';
|
||||
die(' Introuvable<br /><br />Arrêt de la vérification.');
|
||||
} else {
|
||||
die(' ?<br /><br />Impossible de déterminer l\'origine de la requête !<br />Arrêt de la vérification.');
|
||||
}
|
||||
|
||||
function extractDir($dir)
|
||||
{
|
||||
$sums = array();
|
||||
|
||||
$sums = extractDir(dir_start);
|
||||
|
||||
print "Écriture du fichier.<br />";
|
||||
file_put_contents(FILE_SAV, serialize($sums));
|
||||
print "Fin de l'opération.<br />";
|
||||
if (isset($_GET['v'])) {
|
||||
print "<br />Génération des sommes de fichiers pour le dossier : ".$dir;
|
||||
}
|
||||
|
||||
$pointeur = opendir($dir);
|
||||
while ($fichier = readdir($pointeur)) {
|
||||
if ($fichier == '.' || $fichier == '..' || $fichier == '.svn' || preg_match("#~#", $fichier)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($dir.$fichier) && is_readable($dir.$fichier)) {
|
||||
$sums = array_merge($sums, extractDir($dir.$fichier.'/'));
|
||||
} elseif (is_file($dir.$fichier)) {
|
||||
$sums[$dir.$fichier] = sha1_file($dir.$fichier);
|
||||
}
|
||||
}
|
||||
closedir($pointeur);
|
||||
|
||||
return $sums;
|
||||
}
|
||||
|
||||
print 'Génération du tableau ...';
|
||||
$sums = array();
|
||||
|
||||
$sums = extractDir(dir_start);
|
||||
|
||||
print "Écriture du fichier.<br />";
|
||||
file_put_contents(FILE_SAV, serialize($sums));
|
||||
print "Fin de l'opération.<br />";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<html>
|
||||
<html>
|
||||
<head>
|
||||
<title>.: Halo-Battle :: Lecteur de log :.</title>
|
||||
<style>
|
||||
|
|
@ -13,52 +13,50 @@
|
|||
<?php
|
||||
define('dir', '../onyx2/log');
|
||||
|
||||
if(!is_dir(dir))
|
||||
die('Dossier introuvable !');
|
||||
|
||||
if (empty($_GET['file']) || is_dir(dir.$_GET['file']))
|
||||
{
|
||||
if (!empty($_GET['file']) && str_replace("..", '' , $_GET['file']) != $_GET['file'])
|
||||
die('Accès au fichier non autorisé !');
|
||||
elseif (empty($_GET['file']))
|
||||
$_GET['file'] = '';
|
||||
|
||||
$pointeur = opendir(dir.$_GET['file']);
|
||||
print 'Dossier en cours : '.dir.$_GET['file'].'<br /><br />';
|
||||
while ($fichier = readdir($pointeur))
|
||||
{
|
||||
if($fichier == '.' || $fichier == '..')
|
||||
continue;
|
||||
|
||||
print '<a href="?file='.$_GET['file'].'/'.$fichier.'">'.$fichier.'</a><br />';
|
||||
}
|
||||
if (!is_dir(dir)) {
|
||||
die('Dossier introuvable !');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($_GET['file']) && str_replace("..", '' , $_GET['file']) != $_GET['file'])
|
||||
die('Accès au fichier non autorisé !');
|
||||
$file = dir.$_GET['file'];
|
||||
|
||||
print '<h3><ins>Fichier :</ins> '.$file.'</h3><hr />';
|
||||
if (empty($_GET['file']) || is_dir(dir.$_GET['file'])) {
|
||||
if (!empty($_GET['file']) && str_replace("..", '', $_GET['file']) != $_GET['file']) {
|
||||
die('Accès au fichier non autorisé !');
|
||||
} elseif (empty($_GET['file'])) {
|
||||
$_GET['file'] = '';
|
||||
}
|
||||
|
||||
if(!is_file($file))
|
||||
die('Fichier introuvable !');
|
||||
$pointeur = opendir(dir.$_GET['file']);
|
||||
print 'Dossier en cours : '.dir.$_GET['file'].'<br /><br />';
|
||||
while ($fichier = readdir($pointeur)) {
|
||||
if ($fichier == '.' || $fichier == '..') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fichier = @fopen($file,'r+');
|
||||
$contenu_log = fread($fichier,filesize($file));
|
||||
fclose($fichier);
|
||||
print '<a href="?file='.$_GET['file'].'/'.$fichier.'">'.$fichier.'</a><br />';
|
||||
}
|
||||
} else {
|
||||
if (!empty($_GET['file']) && str_replace("..", '', $_GET['file']) != $_GET['file']) {
|
||||
die('Accès au fichier non autorisé !');
|
||||
}
|
||||
$file = dir.$_GET['file'];
|
||||
|
||||
$exp = "#\[(\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})\] (\\w{6,13}) : ([^\[]{0,1000}) \[(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\] \[(\w{3,4})\] \[/([^\[]{1,200})\] \[([^\[]{0,200})\] \[([^\[]{0,75})\]#ui";
|
||||
print '<h3><ins>Fichier :</ins> '.$file.'</h3><hr />';
|
||||
|
||||
preg_match_all($exp,htmlentities(trim(str_replace("\n", ' ', $contenu_log))),$m);
|
||||
if (!is_file($file)) {
|
||||
die('Fichier introuvable !');
|
||||
}
|
||||
|
||||
if (empty($m[0][0]))
|
||||
{
|
||||
print '<pre>'.$contenu_log.'</pre>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table border="1">
|
||||
$fichier = @fopen($file, 'r+');
|
||||
$contenu_log = fread($fichier, filesize($file));
|
||||
fclose($fichier);
|
||||
|
||||
$exp = "#\[(\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2})\] (\\w{6,13}) : ([^\[]{0,1000}) \[(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\] \[(\w{3,4})\] \[/([^\[]{1,200})\] \[([^\[]{0,200})\] \[([^\[]{0,75})\]#ui";
|
||||
|
||||
preg_match_all($exp, htmlentities(trim(str_replace("\n", ' ', $contenu_log))), $m);
|
||||
|
||||
if (empty($m[0][0])) {
|
||||
print '<pre>'.$contenu_log.'</pre>';
|
||||
} else {
|
||||
print '<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
|
|
@ -68,44 +66,45 @@ else
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach($m[0] as $key => $lign)
|
||||
{
|
||||
if (preg_match('#array#', $m[3][$key]))
|
||||
{
|
||||
$exp = "#array \(( '(.{1,10})' => '([^',]{0,1000})',)( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?#ui";
|
||||
foreach ($m[0] as $key => $lign) {
|
||||
if (preg_match('#array#', $m[3][$key])) {
|
||||
$exp = "#array \(( '(.{1,10})' => '([^',]{0,1000})',)( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?( '(.{1,10})' => '([^',]{0,1000})',)?#ui";
|
||||
|
||||
preg_match_all($exp,$m[3][$key],$mArray);
|
||||
preg_match_all($exp, $m[3][$key], $mArray);
|
||||
|
||||
$m[3][$key] = '';
|
||||
foreach($mArray as $k => $lign)
|
||||
{
|
||||
if ($k == 0 || $k%3 == 1)
|
||||
continue;
|
||||
$m[3][$key] = '';
|
||||
foreach ($mArray as $k => $lign) {
|
||||
if ($k == 0 || $k%3 == 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($lign[0] == "")
|
||||
break;
|
||||
if ($k%3 == 2)
|
||||
$m[3][$key] .= '<b>'.$lign[0].' : </b>';
|
||||
else
|
||||
$m[3][$key] .= (strlen($lign[0])>80?'<acronym title="'.$lign[0].'">'.substr($lign[0],0,77).'...</acronym>':$lign[0]).'<br />';
|
||||
}
|
||||
}
|
||||
if ($lign[0] == "") {
|
||||
break;
|
||||
}
|
||||
if ($k%3 == 2) {
|
||||
$m[3][$key] .= '<b>'.$lign[0].' : </b>';
|
||||
} else {
|
||||
$m[3][$key] .= (strlen($lign[0])>80?'<acronym title="'.$lign[0].'">'.substr($lign[0], 0, 77).'...</acronym>':$lign[0]).'<br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($m[2][$key] == "ERREUR")
|
||||
print '<tr style="background: #FF0000;">';
|
||||
elseif ($m[2][$key] == "AVERTISSEMENT")
|
||||
print '<tr style="background: #FFCC00;">';
|
||||
else
|
||||
print '<tr>';
|
||||
print '
|
||||
if ($m[2][$key] == "ERREUR") {
|
||||
print '<tr style="background: #FF0000;">';
|
||||
} elseif ($m[2][$key] == "AVERTISSEMENT") {
|
||||
print '<tr style="background: #FFCC00;">';
|
||||
} else {
|
||||
print '<tr>';
|
||||
}
|
||||
print '
|
||||
<td>'.$m[1][$key].'<br />'.$m[5][$key].'</td>
|
||||
<td>'.$m[2][$key].'<br />'.(strlen($m[6][$key])>30?'<acronym title="'.$m[6][$key].'">'.substr($m[6][$key],0,27).'...</acronym>':$m[6][$key]).'</td>
|
||||
<td>'.$m[2][$key].'<br />'.(strlen($m[6][$key])>30?'<acronym title="'.$m[6][$key].'">'.substr($m[6][$key], 0, 27).'...</acronym>':$m[6][$key]).'</td>
|
||||
<td>'.$m[3][$key].'</td>
|
||||
<td><acronym title="'.$m[7][$key].'">'.$m[4][$key].'</acronym><br />'.$m[8][$key].'</td>
|
||||
</tr>';
|
||||
}
|
||||
print '</tbody></table>';
|
||||
}
|
||||
}
|
||||
print '</tbody></table>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
|
|
|||
460
htdocs/sign.php
460
htdocs/sign.php
|
|
@ -2,7 +2,7 @@
|
|||
//Définition de la constante anti-hacking
|
||||
define("INDEX", 1);
|
||||
define("DEBUG", false);
|
||||
define("xCSRF",true); //On annule la vérification des attaques CSRF car on sait que toutes les requêtes viennent d'un autre serveur, deplus les risques sont minimes
|
||||
define("xCSRF", true); //On annule la vérification des attaques CSRF car on sait que toutes les requêtes viennent d'un autre serveur, deplus les risques sont minimes
|
||||
|
||||
//Inclusion de l'API Onyx
|
||||
require_once(trim(file_get_contents('./.onyx')));
|
||||
|
|
@ -10,236 +10,250 @@ require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
|||
|
||||
function separerNombres($int)
|
||||
{
|
||||
return number_format(floor($int), 0, ',', ' ');
|
||||
return number_format(floor($int), 0, ',', ' ');
|
||||
}
|
||||
|
||||
|
||||
$id = gpc('i');
|
||||
if (!is_numeric($id)) $id = 0;
|
||||
if (!is_numeric($id)) {
|
||||
$id = 0;
|
||||
}
|
||||
|
||||
$f = gpc('f');
|
||||
$s = gpc('s');
|
||||
|
||||
header ("Content-type: image/png");
|
||||
header("Content-type: image/png");
|
||||
|
||||
if (file_exists(ONYX."cache/signatures/".$id.".".$f.$s.".sign") && time() - filemtime(ONYX."cache/signatures/".$id.".".$f.$s.".sign") < 36000) {
|
||||
readfile(ONYX."cache/signatures/".$id.".".$f.$s.".sign");
|
||||
readfile(ONYX."cache/signatures/".$id.".".$f.$s.".sign");
|
||||
} else {
|
||||
$fontfile = ONYX."include/content/signatures/ARIAL.TTF";
|
||||
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$joueur = $bdd->unique_query("SELECT $table_user.pseudo, $table_user.auth_level, $table_user.race, $table_user.place_points, $table_user.points, $table_user.batiments, $table_user.flotte, $table_alliances.tag, $table_alliances.nom FROM $table_user INNER JOIN $table_alliances ON $table_user.id_alliance = $table_alliances.id WHERE $table_user.id = $id;");
|
||||
if ($joueur == false) {
|
||||
$joueur = $bdd->unique_query("SELECT pseudo, auth_level, race, place_points, points, batiments, flotte FROM $table_user WHERE id = $id;");
|
||||
}
|
||||
$nomjoueur = $joueur['pseudo'];
|
||||
$raid = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE destinataire = '$nomjoueur' AND contenu LIKE '<b>Le combat contre % est termi%';");
|
||||
$transport = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE contenu LIKE 'Les vaisseaux de $nomjoueur %';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($s) && $joueur['auth_level'] >= 1) {
|
||||
switch ($s) {
|
||||
case 1:
|
||||
$img = 'mixte1userbarju7.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$img = 'mixte1userbarju7.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($joueur['race'] == 'covenant') {
|
||||
$_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/covi.png");
|
||||
} else {
|
||||
$_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/hum.png");
|
||||
}
|
||||
} elseif ($joueur['race'] == 'covenant') {
|
||||
switch ($f) {
|
||||
case 1:
|
||||
$img = 'userbarallicopygs1.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$img = 'covenantuserbarus1.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 0, 0, 0);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
}
|
||||
$_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/covi.png");
|
||||
} else {
|
||||
switch ($f) {
|
||||
case 1:
|
||||
$img = 'userbarallicopygs1.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$img = 'humainuserbarhz2.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
//$contenu = imagecolorallocate($_img, 160, 160, 0);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
}
|
||||
$_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/hum.png");
|
||||
}
|
||||
|
||||
$blanc = imagecolorallocate($_img, 255, 255, 255);
|
||||
$noir = imagecolorallocate($_img, 0, 0, 0);
|
||||
$rouge = imagecolorallocate($_img, 255, 0, 0);
|
||||
$vert = imagecolorallocate($_img, 0, 255, 0);
|
||||
$bleu = imagecolorallocate($_img, 0, 0, 255);
|
||||
$jaune = imagecolorallocate($_img, 255, 255, 0);
|
||||
|
||||
if ($joueur == false) {
|
||||
ImageTTFText($_img, 20, -20, 123, 17, $rouge, $fontfile, 'Joueur introuvable !');
|
||||
if (file_exists(ONYX."/cache/signatures/".$id.".".$f.$s.".sign")) {
|
||||
unlink(ONYX."/cache/signatures/".$id.".".$f.$s.".sign");
|
||||
}
|
||||
} else {
|
||||
if ($joueur['auth_level'] > 4) {
|
||||
ImageTTFText($_img, 12, 0, 45, 23, $vert, $fontfile, ucfirst($joueur['pseudo']));
|
||||
} elseif ($joueur['auth_level'] >= 1) {
|
||||
ImageTTFText($_img, 12, 0, 45, 23, $jaune, $fontfile, ucfirst($joueur['pseudo']));
|
||||
} else {
|
||||
ImageTTFText($_img, 12, 0, 45, 23, $entete, $fontfile, ucfirst($joueur['pseudo']));
|
||||
}
|
||||
|
||||
ImageTTFText($_img, 12, 0, 255, 23, $entete, $fontfile, $VAR['serveur_name']);
|
||||
|
||||
if (isset($joueur['tag'])) {
|
||||
if (empty($joueur['place_points'])) {
|
||||
ImageTTFText($_img, 11, 0, 32, 47, $contenu, $fontfile, "Classement : Non classé");
|
||||
} else {
|
||||
ImageTTFText($_img, 11, 0, 32, 47, $contenu, $fontfile, "Classement : ".separerNombres($joueur['place_points']).($joueur['place_points']==1?'er':'ème'));
|
||||
}
|
||||
ImageTTFText($_img, 11, 0, 32, 64, $contenu, $fontfile, "Points : ".separerNombres($joueur['points']));
|
||||
ImageTTFText($_img, 11, 0, 32, 82, $contenu, $fontfile, "Alliance : [".$joueur['tag']."] ".substr($joueur['nom'], 0, 9).(strlen($joueur['nom'])>9?'...':''));
|
||||
} else {
|
||||
if (empty($joueur['place_points'])) {
|
||||
ImageTTFText($_img, 11, 0, 32, 55, $contenu, $fontfile, "Classement : Non classé");
|
||||
} else {
|
||||
ImageTTFText($_img, 11, 0, 32, 55, $contenu, $fontfile, "Classement : ".separerNombres($joueur['place_points']).($joueur['place_points']==1?'er':'ème'));
|
||||
}
|
||||
ImageTTFText($_img, 11, 0, 32, 75, $contenu, $fontfile, "Points : ".separerNombres($joueur['points']));
|
||||
}
|
||||
|
||||
ImageTTFText($_img, 12, 0, 272, 51, $infos[0][0], $fontfile, $infos[0][1]);
|
||||
ImageTTFText($_img, 12, 0, 272, 78, $infos[1][0], $fontfile, $infos[1][1]);
|
||||
ImageTTFText($_img, 12, 0, 355, 50, $infos[2][0], $fontfile, $infos[2][1]);
|
||||
ImageTTFText($_img, 12, 0, 355, 78, $infos[3][0], $fontfile, $infos[3][1]);
|
||||
}
|
||||
imagecopy($_img, $_imgavatar, 435, 0, 0, 0, 98, 100);
|
||||
|
||||
imagealphablending($_img, false);
|
||||
imagesavealpha($_img, true);
|
||||
|
||||
if ($joueur == false) {
|
||||
imagepng($_img);
|
||||
} else {
|
||||
imagepng($_img, ONYX."cache/signatures/".$id.".".$f.$s.".sign");
|
||||
readfile(ONYX."cache/signatures/".$id.".".$f.$s.".sign");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$fontfile = ONYX."include/content/signatures/ARIAL.TTF";
|
||||
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$joueur = $bdd->unique_query("SELECT $table_user.pseudo, $table_user.auth_level, $table_user.race, $table_user.place_points, $table_user.points, $table_user.batiments, $table_user.flotte, $table_alliances.tag, $table_alliances.nom FROM $table_user INNER JOIN $table_alliances ON $table_user.id_alliance = $table_alliances.id WHERE $table_user.id = $id;");
|
||||
if ($joueur == false) $joueur = $bdd->unique_query("SELECT pseudo, auth_level, race, place_points, points, batiments, flotte FROM $table_user WHERE id = $id;");
|
||||
$nomjoueur = $joueur['pseudo'];
|
||||
$raid = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE destinataire = '$nomjoueur' AND contenu LIKE '<b>Le combat contre % est termi%';");
|
||||
$transport = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM $table_mail WHERE contenu LIKE 'Les vaisseaux de $nomjoueur %';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($s) && $joueur['auth_level'] >= 1){
|
||||
switch($s){
|
||||
case 1:
|
||||
$img = 'mixte1userbarju7.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$img = 'mixte1userbarju7.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($joueur['race'] == 'covenant') $_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/covi.png");
|
||||
else $_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/hum.png");
|
||||
}
|
||||
elseif ($joueur['race'] == 'covenant') {
|
||||
switch($f){
|
||||
case 1:
|
||||
$img = 'userbarallicopygs1.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$img = 'covenantuserbarus1.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 0, 0, 0);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
}
|
||||
$_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/covi.png");
|
||||
}
|
||||
else {
|
||||
switch($f){
|
||||
case 1:
|
||||
$img = 'userbarallicopygs1.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$img = 'humainuserbarhz2.png';
|
||||
$_img = imagecreatefrompng(ONYX."include/content/signatures/".$img);
|
||||
$entete = imagecolorallocate($_img, 255, 255, 255);
|
||||
//$contenu = imagecolorallocate($_img, 160, 160, 0);
|
||||
$contenu = imagecolorallocate($_img, 255, 255, 255);
|
||||
$infos = array(
|
||||
array(
|
||||
imagecolorallocate($_img, 0, 0, 0),
|
||||
separerNombres($raid['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['flotte'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($transport['nombre'])
|
||||
),
|
||||
array(
|
||||
imagecolorallocate($_img, 255, 255, 255),
|
||||
separerNombres($joueur['batiments'])
|
||||
)
|
||||
);
|
||||
}
|
||||
$_imgavatar = imagecreatefrompng(ONYX."include/content/signatures/hum.png");
|
||||
}
|
||||
|
||||
$blanc = imagecolorallocate($_img, 255, 255, 255);
|
||||
$noir = imagecolorallocate($_img, 0, 0, 0);
|
||||
$rouge = imagecolorallocate($_img, 255, 0, 0);
|
||||
$vert = imagecolorallocate($_img, 0, 255, 0);
|
||||
$bleu = imagecolorallocate($_img, 0, 0, 255);
|
||||
$jaune = imagecolorallocate($_img, 255, 255, 0);
|
||||
|
||||
if ($joueur == false) {
|
||||
ImageTTFText($_img, 20, -20, 123, 17, $rouge, $fontfile, 'Joueur introuvable !');
|
||||
if (file_exists(ONYX."/cache/signatures/".$id.".".$f.$s.".sign")) unlink(ONYX."/cache/signatures/".$id.".".$f.$s.".sign");
|
||||
}
|
||||
else {
|
||||
if ($joueur['auth_level'] > 4) ImageTTFText($_img, 12, 0, 45, 23, $vert, $fontfile, ucfirst($joueur['pseudo']));
|
||||
elseif ($joueur['auth_level'] >= 1) ImageTTFText($_img, 12, 0, 45, 23, $jaune, $fontfile, ucfirst($joueur['pseudo']));
|
||||
else ImageTTFText($_img, 12, 0, 45, 23, $entete, $fontfile, ucfirst($joueur['pseudo']));
|
||||
|
||||
ImageTTFText($_img, 12, 0, 255, 23, $entete, $fontfile, $VAR['serveur_name']);
|
||||
|
||||
if (isset($joueur['tag'])) {
|
||||
if (empty($joueur['place_points'])) ImageTTFText($_img, 11, 0, 32, 47, $contenu, $fontfile, "Classement : Non classé");
|
||||
else ImageTTFText($_img, 11, 0, 32, 47, $contenu, $fontfile, "Classement : ".separerNombres($joueur['place_points']).($joueur['place_points']==1?'er':'ème'));
|
||||
ImageTTFText($_img, 11, 0, 32, 64, $contenu, $fontfile, "Points : ".separerNombres($joueur['points']));
|
||||
ImageTTFText($_img, 11, 0, 32, 82, $contenu, $fontfile, "Alliance : [".$joueur['tag']."] ".substr($joueur['nom'],0,9).(strlen($joueur['nom'])>9?'...':''));
|
||||
}
|
||||
else {
|
||||
if (empty($joueur['place_points'])) ImageTTFText($_img, 11, 0, 32, 55, $contenu, $fontfile, "Classement : Non classé");
|
||||
else ImageTTFText($_img, 11, 0, 32, 55, $contenu, $fontfile, "Classement : ".separerNombres($joueur['place_points']).($joueur['place_points']==1?'er':'ème'));
|
||||
ImageTTFText($_img, 11, 0, 32, 75, $contenu, $fontfile, "Points : ".separerNombres($joueur['points']));
|
||||
}
|
||||
|
||||
ImageTTFText($_img, 12, 0, 272, 51, $infos[0][0], $fontfile, $infos[0][1]);
|
||||
ImageTTFText($_img, 12, 0, 272, 78, $infos[1][0], $fontfile, $infos[1][1]);
|
||||
ImageTTFText($_img, 12, 0, 355, 50, $infos[2][0], $fontfile, $infos[2][1]);
|
||||
ImageTTFText($_img, 12, 0, 355, 78, $infos[3][0], $fontfile, $infos[3][1]);
|
||||
}
|
||||
imagecopy($_img, $_imgavatar, 435, 0, 0, 0, 98, 100);
|
||||
|
||||
imagealphablending($_img, false);
|
||||
imagesavealpha($_img, true);
|
||||
|
||||
if ($joueur == false) imagepng($_img);
|
||||
else {
|
||||
imagepng($_img, ONYX."cache/signatures/".$id.".".$f.$s.".sign");
|
||||
readfile(ONYX."cache/signatures/".$id.".".$f.$s.".sign");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -31,4 +31,3 @@ $SESS->put();
|
|||
$file->DEBUG__print();
|
||||
var_dump($planete->vaisseaux);
|
||||
var_dump($planete->modif);
|
||||
?>
|
||||
|
|
@ -23,4 +23,3 @@ $planete2->position = 2;
|
|||
$vaisseaux = array(1);
|
||||
|
||||
print Flotte::calc_deplacement($planete1, 1, 1, 2, 1, $vaisseaux, 123456789);
|
||||
?>
|
||||
|
|
@ -9,4 +9,3 @@ require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
|||
require_once("donnees.php");
|
||||
|
||||
var_dump(bourse_calcPrixBase("640623608", 4000, 2));
|
||||
?>
|
||||
|
|
@ -11,4 +11,3 @@ require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
|||
|
||||
|
||||
var_dump(check_mdp("AzErTyUiOp"));
|
||||
?>
|
||||
|
|
@ -9,16 +9,14 @@ require_once("common.php"); //Chargement de tout le nécessaire pour le jeu
|
|||
|
||||
function traiterfichier($uri, &$list)
|
||||
{
|
||||
$fp = fopen($uri, "r");
|
||||
while (!feof($fp))
|
||||
{
|
||||
$buffer = fgets($fp);
|
||||
if (preg_match("#^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})#", $buffer, $match))
|
||||
{
|
||||
var_dump($match);
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
$fp = fopen($uri, "r");
|
||||
while (!feof($fp)) {
|
||||
$buffer = fgets($fp);
|
||||
if (preg_match("#^([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})#", $buffer, $match)) {
|
||||
var_dump($match);
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
$list = array();
|
||||
|
|
@ -33,4 +31,3 @@ $bdd->query("INSERT INTO proxy_list VALUES ('".implode("'),('", $list)."');");
|
|||
$bdd->deconnexion();
|
||||
|
||||
print "Procédure terminée, ".count($list)." proxys listés.";
|
||||
?>
|
||||
|
|
@ -4,4 +4,3 @@ $referer = "http://beta.halo-battle.fr/";
|
|||
|
||||
var_dump($referer, preg_match("#^http://(\w{1,4}\.)?halo-battle\.(fr|net|com|org|us|en)#", $referer, $osef), $osef);
|
||||
//var_dump($referer, preg_match("#^http://[\.|www\.|beta\.]halo-battle\.[fr|net|com|org|us|en|]#ui", $osef), $osef);
|
||||
?>
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$___profile['db'] = 'hb_game';
|
||||
if (getenv("MYSQL_HOST") === False) {
|
||||
$___profile['host'] = 'localhost';
|
||||
if (getenv("MYSQL_HOST") === false) {
|
||||
$___profile['host'] = 'localhost';
|
||||
} else {
|
||||
$___profile['host'] = getenv("MYSQL_HOST");
|
||||
$___profile['host'] = getenv("MYSQL_HOST");
|
||||
}
|
||||
$___profile['user'] = 'hb';
|
||||
$___profile['pass'] = 'hb';
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -3,208 +3,198 @@ require_once("Class/Donnees/interface.php");
|
|||
|
||||
class dAlliancesBatiments implements Donnees
|
||||
{
|
||||
public static function metal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$metal = ceil(pow(1.5, $niveau)*68);
|
||||
break;
|
||||
case 1:
|
||||
$metal = ceil(pow(1.6, $niveau)*53);
|
||||
break;
|
||||
case 2:
|
||||
$metal = ceil(pow(1.5, $niveau)*242);
|
||||
break;
|
||||
case 3:
|
||||
$metal = ceil(pow(1.5, $niveau)*92);
|
||||
break;
|
||||
case 4:
|
||||
$metal = ceil(pow(1.73, $niveau)*800);
|
||||
break;
|
||||
case 5:
|
||||
$metal = ceil(pow(2, $niveau)*750);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function metal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$metal = ceil(pow(1.5, $niveau)*68);
|
||||
break;
|
||||
case 1:
|
||||
$metal = ceil(pow(1.6, $niveau)*53);
|
||||
break;
|
||||
case 2:
|
||||
$metal = ceil(pow(1.5, $niveau)*242);
|
||||
break;
|
||||
case 3:
|
||||
$metal = ceil(pow(1.5, $niveau)*92);
|
||||
break;
|
||||
case 4:
|
||||
$metal = ceil(pow(1.73, $niveau)*800);
|
||||
break;
|
||||
case 5:
|
||||
$metal = ceil(pow(2, $niveau)*750);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $metal;
|
||||
}
|
||||
return $metal;
|
||||
}
|
||||
|
||||
public static function cristal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = ceil(pow(1.5, $niveau)*17);
|
||||
break;
|
||||
case 1:
|
||||
$cristal = ceil(pow(1.6, $niveau)*27);
|
||||
break;
|
||||
case 2:
|
||||
$cristal = ceil(pow(1.5, $niveau)*72);
|
||||
break;
|
||||
case 3:
|
||||
$cristal = ceil(pow(1.5, $niveau)*37);
|
||||
break;
|
||||
case 4:
|
||||
$cristal = ceil(pow(1.73, $niveau)*420);
|
||||
break;
|
||||
case 5:
|
||||
$cristal = ceil(pow(2, $niveau)*500);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function cristal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$cristal = ceil(pow(1.5, $niveau)*17);
|
||||
break;
|
||||
case 1:
|
||||
$cristal = ceil(pow(1.6, $niveau)*27);
|
||||
break;
|
||||
case 2:
|
||||
$cristal = ceil(pow(1.5, $niveau)*72);
|
||||
break;
|
||||
case 3:
|
||||
$cristal = ceil(pow(1.5, $niveau)*37);
|
||||
break;
|
||||
case 4:
|
||||
$cristal = ceil(pow(1.73, $niveau)*420);
|
||||
break;
|
||||
case 5:
|
||||
$cristal = ceil(pow(2, $niveau)*500);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $cristal;
|
||||
}
|
||||
return $cristal;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = ceil(pow(1.68, $niveau)*285);
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function hydrogene($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = ceil(pow(1.68, $niveau)*285);
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $hydrogene;
|
||||
}
|
||||
return $hydrogene;
|
||||
}
|
||||
|
||||
public static function credits($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$credits = ceil(pow(1.68, $niveau)*25);
|
||||
break;
|
||||
case 1:
|
||||
$credits = ceil(pow(1.68, $niveau)*85);
|
||||
break;
|
||||
case 2:
|
||||
$credits = ceil(pow(1.68, $niveau)*185);
|
||||
break;
|
||||
case 3:
|
||||
$credits = ceil(pow(1.68, $niveau)*285);
|
||||
break;
|
||||
case 4:
|
||||
$credits = ceil(pow(1.68, $niveau)*385);
|
||||
break;
|
||||
case 5:
|
||||
$credits = ceil(pow(1.68, $niveau)*485);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function credits($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$credits = ceil(pow(1.68, $niveau)*25);
|
||||
break;
|
||||
case 1:
|
||||
$credits = ceil(pow(1.68, $niveau)*85);
|
||||
break;
|
||||
case 2:
|
||||
$credits = ceil(pow(1.68, $niveau)*185);
|
||||
break;
|
||||
case 3:
|
||||
$credits = ceil(pow(1.68, $niveau)*285);
|
||||
break;
|
||||
case 4:
|
||||
$credits = ceil(pow(1.68, $niveau)*385);
|
||||
break;
|
||||
case 5:
|
||||
$credits = ceil(pow(1.68, $niveau)*485);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
return $credits;
|
||||
}
|
||||
return $credits;
|
||||
}
|
||||
|
||||
public static function temps($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$sec = pow(1.5, $niveau)*6;
|
||||
break;
|
||||
case 1:
|
||||
$sec = pow(1.55, $niveau)*6;
|
||||
break;
|
||||
case 2:
|
||||
$sec = pow(1.624, $niveau)*6;
|
||||
break;
|
||||
case 3:
|
||||
$sec = pow(1.597, $niveau)*6;
|
||||
break;
|
||||
case 4:
|
||||
$sec = pow(1.7, $niveau)*6;
|
||||
break;
|
||||
case 5:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function temps($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$sec = pow(1.5, $niveau)*6;
|
||||
break;
|
||||
case 1:
|
||||
$sec = pow(1.55, $niveau)*6;
|
||||
break;
|
||||
case 2:
|
||||
$sec = pow(1.624, $niveau)*6;
|
||||
break;
|
||||
case 3:
|
||||
$sec = pow(1.597, $niveau)*6;
|
||||
break;
|
||||
case 4:
|
||||
$sec = pow(1.7, $niveau)*6;
|
||||
break;
|
||||
case 5:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment d'alliance ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//Accélération du temps de construction
|
||||
$sec /= VITESSE;
|
||||
//Accélération du temps de construction
|
||||
$sec /= VITESSE;
|
||||
|
||||
return $sec;
|
||||
}
|
||||
return $sec;
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
//return "batimentcovieux4.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
//return "batimentcovieux4.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant") {
|
||||
switch ($id) {
|
||||
case 0:
|
||||
//return "batimentcovieux4.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
} elseif ($planete->race == "humain") {
|
||||
switch ($id) {
|
||||
case 0:
|
||||
//return "batimentcovieux4.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
} else {
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededAlliancesBatiments =
|
||||
array(
|
||||
0,
|
||||
array(
|
||||
array('batiments', 0, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 2)
|
||||
)
|
||||
);
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededAlliancesBatiments =
|
||||
array(
|
||||
0,
|
||||
array(
|
||||
array('batiments', 0, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 0, 2)
|
||||
)
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededAlliancesBatiments[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededAlliancesBatiments[$id], $planete);
|
||||
}
|
||||
if ($print) {
|
||||
return dDonnees::print_neededCheck($neededAlliancesBatiments[$id], $planete);
|
||||
} else {
|
||||
return dDonnees::neededCheck($neededAlliancesBatiments[$id], $planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,515 +3,489 @@ require_once("Class/Donnees/interface.php");
|
|||
|
||||
class dBatiments implements Donnees
|
||||
{
|
||||
public static function metal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$metal = ceil(pow(1.5, $niveau)*68);
|
||||
break;
|
||||
case 1:
|
||||
$metal = ceil(pow(1.6, $niveau)*53);
|
||||
break;
|
||||
case 2:
|
||||
$metal = ceil(pow(1.5, $niveau)*242);
|
||||
break;
|
||||
case 3:
|
||||
$metal = ceil(pow(1.5, $niveau)*92);
|
||||
break;
|
||||
case 4:
|
||||
//$metal = ceil(pow(1.73, $niveau)*800);
|
||||
$metal = ceil(pow(3, $niveau)*5000);
|
||||
break;
|
||||
case 5:
|
||||
$metal = ceil(pow(2, $niveau)*750);
|
||||
break;
|
||||
case 6:
|
||||
$metal = ceil(pow(2, $niveau)*200);
|
||||
break;
|
||||
case 7:
|
||||
$metal = ceil(pow(2, $niveau)*520);
|
||||
break;
|
||||
case 8:
|
||||
$metal = ceil(pow(2, $niveau)*600);
|
||||
break;
|
||||
case 9:
|
||||
$metal = ceil(pow(2, $niveau)*200);
|
||||
break;
|
||||
case 10:
|
||||
$metal = ceil(pow(2, $niveau)*400);
|
||||
break;
|
||||
case 11:
|
||||
$metal = ceil(pow(1.7, $niveau)*600);
|
||||
break;
|
||||
public static function metal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$metal = ceil(pow(1.5, $niveau)*68);
|
||||
break;
|
||||
case 1:
|
||||
$metal = ceil(pow(1.6, $niveau)*53);
|
||||
break;
|
||||
case 2:
|
||||
$metal = ceil(pow(1.5, $niveau)*242);
|
||||
break;
|
||||
case 3:
|
||||
$metal = ceil(pow(1.5, $niveau)*92);
|
||||
break;
|
||||
case 4:
|
||||
//$metal = ceil(pow(1.73, $niveau)*800);
|
||||
$metal = ceil(pow(3, $niveau)*5000);
|
||||
break;
|
||||
case 5:
|
||||
$metal = ceil(pow(2, $niveau)*750);
|
||||
break;
|
||||
case 6:
|
||||
$metal = ceil(pow(2, $niveau)*200);
|
||||
break;
|
||||
case 7:
|
||||
$metal = ceil(pow(2, $niveau)*520);
|
||||
break;
|
||||
case 8:
|
||||
$metal = ceil(pow(2, $niveau)*600);
|
||||
break;
|
||||
case 9:
|
||||
$metal = ceil(pow(2, $niveau)*200);
|
||||
break;
|
||||
case 10:
|
||||
$metal = ceil(pow(2, $niveau)*400);
|
||||
break;
|
||||
case 11:
|
||||
$metal = ceil(pow(1.7, $niveau)*600);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$metal = ceil(pow($niveau, 2.075)*1000+1500);
|
||||
break;
|
||||
case 13:
|
||||
$metal = ceil(pow($niveau,2.8)*1000+299000);
|
||||
break;
|
||||
case 14:
|
||||
$metal = ceil(pow($niveau, 2)*1200+140000);
|
||||
break;
|
||||
case 15:
|
||||
$metal = ceil(pow($niveau, 2)*1000+80000);
|
||||
break;
|
||||
case 16:
|
||||
$metal = ceil(pow($niveau, 2)*850+60000);
|
||||
break;
|
||||
case 17:
|
||||
$metal = ceil(pow($niveau, 2.5)*500 -300);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
case 12:
|
||||
$metal = ceil(pow($niveau, 2.075)*1000+1500);
|
||||
break;
|
||||
case 13:
|
||||
$metal = ceil(pow($niveau, 2.8)*1000+299000);
|
||||
break;
|
||||
case 14:
|
||||
$metal = ceil(pow($niveau, 2)*1200+140000);
|
||||
break;
|
||||
case 15:
|
||||
$metal = ceil(pow($niveau, 2)*1000+80000);
|
||||
break;
|
||||
case 16:
|
||||
$metal = ceil(pow($niveau, 2)*850+60000);
|
||||
break;
|
||||
case 17:
|
||||
$metal = ceil(pow($niveau, 2.5)*500 -300);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3)
|
||||
{
|
||||
if ($planete->technologies[0] &262144)
|
||||
{
|
||||
$metal *= 0.85;
|
||||
}
|
||||
elseif ($planete->technologies[0] &131072)
|
||||
{
|
||||
$metal *= 0.9;
|
||||
}
|
||||
elseif ($planete->technologies[0] &65536)
|
||||
{
|
||||
$metal *= 0.95;
|
||||
}
|
||||
}
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3) {
|
||||
if ($planete->technologies[0] &262144) {
|
||||
$metal *= 0.85;
|
||||
} elseif ($planete->technologies[0] &131072) {
|
||||
$metal *= 0.9;
|
||||
} elseif ($planete->technologies[0] &65536) {
|
||||
$metal *= 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
return $metal;
|
||||
}
|
||||
return $metal;
|
||||
}
|
||||
|
||||
public static function cristal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = ceil(pow(1.5, $niveau)*17);
|
||||
break;
|
||||
case 1:
|
||||
$cristal = ceil(pow(1.6, $niveau)*27);
|
||||
break;
|
||||
case 2:
|
||||
$cristal = ceil(pow(1.5, $niveau)*72);
|
||||
break;
|
||||
case 3:
|
||||
$cristal = ceil(pow(1.5, $niveau)*37);
|
||||
break;
|
||||
case 4:
|
||||
//$cristal = ceil(pow(1.73, $niveau)*420);
|
||||
$cristal = ceil(pow(3, $niveau)*3000);
|
||||
break;
|
||||
case 5:
|
||||
$cristal = ceil(pow(2, $niveau)*500);
|
||||
break;
|
||||
case 6:
|
||||
$cristal = ceil(pow(2, $niveau)*150);
|
||||
break;
|
||||
case 7:
|
||||
$cristal = ceil(pow(2, $niveau)*380);
|
||||
break;
|
||||
case 8:
|
||||
$cristal = ceil(pow(2, $niveau)*450);
|
||||
break;
|
||||
case 9:
|
||||
$cristal = ceil(pow(2, $niveau)*100);
|
||||
break;
|
||||
case 10:
|
||||
$cristal = ceil(pow(2, $niveau)*260);
|
||||
break;
|
||||
case 11:
|
||||
$cristal = ceil(pow(1.7, $niveau)*420);
|
||||
break;
|
||||
public static function cristal($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$cristal = ceil(pow(1.5, $niveau)*17);
|
||||
break;
|
||||
case 1:
|
||||
$cristal = ceil(pow(1.6, $niveau)*27);
|
||||
break;
|
||||
case 2:
|
||||
$cristal = ceil(pow(1.5, $niveau)*72);
|
||||
break;
|
||||
case 3:
|
||||
$cristal = ceil(pow(1.5, $niveau)*37);
|
||||
break;
|
||||
case 4:
|
||||
//$cristal = ceil(pow(1.73, $niveau)*420);
|
||||
$cristal = ceil(pow(3, $niveau)*3000);
|
||||
break;
|
||||
case 5:
|
||||
$cristal = ceil(pow(2, $niveau)*500);
|
||||
break;
|
||||
case 6:
|
||||
$cristal = ceil(pow(2, $niveau)*150);
|
||||
break;
|
||||
case 7:
|
||||
$cristal = ceil(pow(2, $niveau)*380);
|
||||
break;
|
||||
case 8:
|
||||
$cristal = ceil(pow(2, $niveau)*450);
|
||||
break;
|
||||
case 9:
|
||||
$cristal = ceil(pow(2, $niveau)*100);
|
||||
break;
|
||||
case 10:
|
||||
$cristal = ceil(pow(2, $niveau)*260);
|
||||
break;
|
||||
case 11:
|
||||
$cristal = ceil(pow(1.7, $niveau)*420);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$cristal = ceil(pow($niveau, 1.8)*1000+1000);
|
||||
break;
|
||||
case 13:
|
||||
$cristal = ceil(pow($niveau,2.5)*1000+149000);
|
||||
break;
|
||||
case 14:
|
||||
$cristal = ceil(pow($niveau, 2)*900+99000);
|
||||
break;
|
||||
case 15:
|
||||
$cristal = ceil(pow($niveau, 2)*750+65000);
|
||||
break;
|
||||
case 16:
|
||||
$cristal = ceil(pow($niveau, 2)*650+50000);
|
||||
break;
|
||||
case 17:
|
||||
$cristal = ceil(pow($niveau, 2.4)*400-250);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
case 12:
|
||||
$cristal = ceil(pow($niveau, 1.8)*1000+1000);
|
||||
break;
|
||||
case 13:
|
||||
$cristal = ceil(pow($niveau, 2.5)*1000+149000);
|
||||
break;
|
||||
case 14:
|
||||
$cristal = ceil(pow($niveau, 2)*900+99000);
|
||||
break;
|
||||
case 15:
|
||||
$cristal = ceil(pow($niveau, 2)*750+65000);
|
||||
break;
|
||||
case 16:
|
||||
$cristal = ceil(pow($niveau, 2)*650+50000);
|
||||
break;
|
||||
case 17:
|
||||
$cristal = ceil(pow($niveau, 2.4)*400-250);
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3)
|
||||
{
|
||||
if ($planete->technologies[0] &262144)
|
||||
{
|
||||
$cristal *= 0.85;
|
||||
}
|
||||
elseif ($planete->technologies[0] &131072)
|
||||
{
|
||||
$cristal *= 0.9;
|
||||
}
|
||||
elseif ($planete->technologies[0] &65536)
|
||||
{
|
||||
$cristal *= 0.95;
|
||||
}
|
||||
}
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3) {
|
||||
if ($planete->technologies[0] &262144) {
|
||||
$cristal *= 0.85;
|
||||
} elseif ($planete->technologies[0] &131072) {
|
||||
$cristal *= 0.9;
|
||||
} elseif ($planete->technologies[0] &65536) {
|
||||
$cristal *= 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
return $cristal;
|
||||
}
|
||||
return $cristal;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $niveau, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
//$hydrogene = ceil(pow(1.68, $niveau)*285);
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 9:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 10:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 11:
|
||||
$hydrogene = ceil(pow(1.7, $niveau)*100);
|
||||
break;
|
||||
public static function hydrogene($id, $niveau, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
//$hydrogene = ceil(pow(1.68, $niveau)*285);
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 9:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 10:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 11:
|
||||
$hydrogene = ceil(pow(1.7, $niveau)*100);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 13:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 14:
|
||||
$hydrogene = ceil(pow($niveau, 2)*500+30000);
|
||||
break;
|
||||
case 15:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 16:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 17:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
case 12:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 13:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 14:
|
||||
$hydrogene = ceil(pow($niveau, 2)*500+30000);
|
||||
break;
|
||||
case 15:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 16:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 17:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3)
|
||||
{
|
||||
if ($planete->technologies[0] &262144)
|
||||
{
|
||||
$hydrogene *= 0.85;
|
||||
}
|
||||
elseif ($planete->technologies[0] &131072)
|
||||
{
|
||||
$hydrogene *= 0.9;
|
||||
}
|
||||
elseif ($planete->technologies[0] &65536)
|
||||
{
|
||||
$hydrogene *= 0.95;
|
||||
}
|
||||
}
|
||||
//On tient compte des bonus
|
||||
//Bonus technologique pour les mines
|
||||
if ($id <= 3) {
|
||||
if ($planete->technologies[0] &262144) {
|
||||
$hydrogene *= 0.85;
|
||||
} elseif ($planete->technologies[0] &131072) {
|
||||
$hydrogene *= 0.9;
|
||||
} elseif ($planete->technologies[0] &65536) {
|
||||
$hydrogene *= 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
return $hydrogene;
|
||||
}
|
||||
return $hydrogene;
|
||||
}
|
||||
|
||||
public static function credits($id, $niveau, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public static function credits($id, $niveau, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function temps($id, $niveau, surface $planete, $demolition = false)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$sec = pow(1.5, $niveau)*6;
|
||||
break;
|
||||
case 1:
|
||||
$sec = pow(1.55, $niveau)*6;
|
||||
break;
|
||||
case 2:
|
||||
$sec = pow(1.624, $niveau)*6;
|
||||
break;
|
||||
case 3:
|
||||
$sec = pow(1.597, $niveau)*6;
|
||||
break;
|
||||
case 4:
|
||||
$sec = pow(1.7, $niveau)*6;
|
||||
break;
|
||||
case 5:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
case 6:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
case 7:
|
||||
$sec = ceil(pow(2, $niveau)*420);
|
||||
break;
|
||||
case 8:
|
||||
$sec = ceil(pow(2, $niveau)*600);
|
||||
break;
|
||||
case 9:
|
||||
$sec = ceil(pow(2, $niveau)*300);
|
||||
break;
|
||||
case 10:
|
||||
$sec = ceil(pow(2, $niveau)*1200);
|
||||
break;
|
||||
case 11:
|
||||
$sec = ceil((pow(1.9, $niveau)*800));
|
||||
break;
|
||||
public static function temps($id, $niveau, surface $planete, $demolition = false)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$sec = pow(1.5, $niveau)*6;
|
||||
break;
|
||||
case 1:
|
||||
$sec = pow(1.55, $niveau)*6;
|
||||
break;
|
||||
case 2:
|
||||
$sec = pow(1.624, $niveau)*6;
|
||||
break;
|
||||
case 3:
|
||||
$sec = pow(1.597, $niveau)*6;
|
||||
break;
|
||||
case 4:
|
||||
$sec = pow(1.7, $niveau)*6;
|
||||
break;
|
||||
case 5:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
case 6:
|
||||
$sec = ceil(pow(2, $niveau)*720);
|
||||
break;
|
||||
case 7:
|
||||
$sec = ceil(pow(2, $niveau)*420);
|
||||
break;
|
||||
case 8:
|
||||
$sec = ceil(pow(2, $niveau)*600);
|
||||
break;
|
||||
case 9:
|
||||
$sec = ceil(pow(2, $niveau)*300);
|
||||
break;
|
||||
case 10:
|
||||
$sec = ceil(pow(2, $niveau)*1200);
|
||||
break;
|
||||
case 11:
|
||||
$sec = ceil((pow(1.9, $niveau)*800));
|
||||
break;
|
||||
|
||||
case 12:
|
||||
$sec = ceil(pow($niveau, 2.5)*60+4)*60;
|
||||
break;
|
||||
case 13:
|
||||
$sec = ceil(pow($niveau, 1.6)*60+60)*60;
|
||||
break;
|
||||
case 14:
|
||||
$sec = ceil(pow($niveau, 2)*5+3)*60;
|
||||
break;
|
||||
case 15:
|
||||
$sec = pow($niveau, 2)*240;
|
||||
break;
|
||||
case 16:
|
||||
$sec = pow($niveau, 2)*180;
|
||||
break;
|
||||
case 17:
|
||||
$sec = pow($niveau, 1.65)*3600;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
case 12:
|
||||
$sec = ceil(pow($niveau, 2.5)*60+4)*60;
|
||||
break;
|
||||
case 13:
|
||||
$sec = ceil(pow($niveau, 1.6)*60+60)*60;
|
||||
break;
|
||||
case 14:
|
||||
$sec = ceil(pow($niveau, 2)*5+3)*60;
|
||||
break;
|
||||
case 15:
|
||||
$sec = pow($niveau, 2)*240;
|
||||
break;
|
||||
case 16:
|
||||
$sec = pow($niveau, 2)*180;
|
||||
break;
|
||||
case 17:
|
||||
$sec = pow($niveau, 1.65)*3600;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Batiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On applique le bonus de temps des ingénieurs et des centrales informatiques
|
||||
if ($id == 11 && $planete->casernes[7])
|
||||
$sec /= (1.0025 * $planete->casernes[7]);
|
||||
elseif ($id != 11 && ($planete->casernes[7] || $planete->batiments[11]))
|
||||
$sec /= (pow(1.23, $planete->batiments[11]) + 1.0025 * $planete->casernes[7]);
|
||||
//On applique le bonus de temps des ingénieurs et des centrales informatiques
|
||||
if ($id == 11 && $planete->casernes[7]) {
|
||||
$sec /= (1.0025 * $planete->casernes[7]);
|
||||
} elseif ($id != 11 && ($planete->casernes[7] || $planete->batiments[11])) {
|
||||
$sec /= (pow(1.23, $planete->batiments[11]) + 1.0025 * $planete->casernes[7]);
|
||||
}
|
||||
|
||||
//Accélération du temps de construction
|
||||
$sec /= VITESSE;
|
||||
//Accélération du temps de construction
|
||||
$sec /= VITESSE;
|
||||
|
||||
if ($demolition)
|
||||
return $sec * Donnees::coeff_demolition;
|
||||
else
|
||||
return $sec;
|
||||
}
|
||||
if ($demolition) {
|
||||
return $sec * Donnees::coeff_demolition;
|
||||
} else {
|
||||
return $sec;
|
||||
}
|
||||
}
|
||||
|
||||
public static function type($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
return 1;
|
||||
case 6:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
return 2;
|
||||
case 5:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
return 4;
|
||||
return 6;
|
||||
default:
|
||||
trigger_error("Bâtiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
public static function type($id)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
return 1;
|
||||
case 6:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
return 2;
|
||||
case 5:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
return 4;
|
||||
return 6;
|
||||
default:
|
||||
trigger_error("Bâtiment ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "batimentcovieux4.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "cristaloo3.png";
|
||||
break;
|
||||
case 2:
|
||||
return "powersupplycoviejq1.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "solaire.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "sanstitrevi7.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "oeilduprophetewj6.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "covielabocn5.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "chantierterrestrehg1.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "sanstitretruecolor09zn6.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "caserncov0ry.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "stockagebasement1cs10bl.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "ordianteur_hologramme.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "mine_m.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "mine_c.png";
|
||||
break;
|
||||
case 2:
|
||||
return "synchroniseur.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "centrale solaire.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "centrale electrique.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "baseradardl3.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "recherches.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "chantierterrestrecopybj8.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "chantier spatial.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "ecole militaire.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "stockage.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "search0yp.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant") {
|
||||
switch ($id) {
|
||||
case 0:
|
||||
return "batimentcovieux4.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "cristaloo3.png";
|
||||
break;
|
||||
case 2:
|
||||
return "powersupplycoviejq1.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "solaire.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "sanstitrevi7.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "oeilduprophetewj6.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "covielabocn5.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "chantierterrestrehg1.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "sanstitretruecolor09zn6.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "caserncov0ry.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "stockagebasement1cs10bl.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "ordianteur_hologramme.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
} elseif ($planete->race == "humain") {
|
||||
switch ($id) {
|
||||
case 0:
|
||||
return "mine_m.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "mine_c.png";
|
||||
break;
|
||||
case 2:
|
||||
return "synchroniseur.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "centrale solaire.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "centrale electrique.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "baseradardl3.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "recherches.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "chantierterrestrecopybj8.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "chantier spatial.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "ecole militaire.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "stockage.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "search0yp.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
} else {
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededBatiments =
|
||||
array (
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("batiments", 3, 12),
|
||||
array("batiments_max", 4, 4)
|
||||
),
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("technologies", 2,3)
|
||||
),
|
||||
array(
|
||||
array("technologies", 2,4)
|
||||
),
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("technologies", 1,12)
|
||||
),
|
||||
0,
|
||||
array(
|
||||
array("technologies", 3,8)
|
||||
),
|
||||
array(
|
||||
array("technologies", 7,12)
|
||||
),
|
||||
array(
|
||||
array("technologies", 3,6)
|
||||
),
|
||||
array(
|
||||
array("technologies", 3,7)
|
||||
),
|
||||
0
|
||||
);
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededBatiments =
|
||||
array(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("batiments", 3, 12),
|
||||
array("batiments_max", 4, 4)
|
||||
),
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("technologies", 2,3)
|
||||
),
|
||||
array(
|
||||
array("technologies", 2,4)
|
||||
),
|
||||
0,
|
||||
0,
|
||||
array(
|
||||
array("technologies", 1,12)
|
||||
),
|
||||
0,
|
||||
array(
|
||||
array("technologies", 3,8)
|
||||
),
|
||||
array(
|
||||
array("technologies", 7,12)
|
||||
),
|
||||
array(
|
||||
array("technologies", 3,6)
|
||||
),
|
||||
array(
|
||||
array("technologies", 3,7)
|
||||
),
|
||||
0
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededBatiments[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededBatiments[$id], $planete);
|
||||
}
|
||||
if ($print) {
|
||||
return dDonnees::print_neededCheck($neededBatiments[$id], $planete);
|
||||
} else {
|
||||
return dDonnees::neededCheck($neededBatiments[$id], $planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,299 +3,293 @@ require_once("Class/Donnees/interface.php");
|
|||
|
||||
class dCaserne implements Donnees
|
||||
{
|
||||
public static function metal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$metal = 80;
|
||||
break;
|
||||
case 1:
|
||||
$metal = 110;
|
||||
break;
|
||||
case 2:
|
||||
$metal = 150;
|
||||
break;
|
||||
case 3:
|
||||
$metal = 220;
|
||||
break;
|
||||
case 4:
|
||||
$metal = 180;
|
||||
break;
|
||||
case 5:
|
||||
$metal = 25000;
|
||||
break;
|
||||
case 6:
|
||||
$metal = 100;
|
||||
break;
|
||||
case 7:
|
||||
$metal = 90;
|
||||
break;
|
||||
case 8:
|
||||
$metal = 300;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function metal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$metal = 80;
|
||||
break;
|
||||
case 1:
|
||||
$metal = 110;
|
||||
break;
|
||||
case 2:
|
||||
$metal = 150;
|
||||
break;
|
||||
case 3:
|
||||
$metal = 220;
|
||||
break;
|
||||
case 4:
|
||||
$metal = 180;
|
||||
break;
|
||||
case 5:
|
||||
$metal = 25000;
|
||||
break;
|
||||
case 6:
|
||||
$metal = 100;
|
||||
break;
|
||||
case 7:
|
||||
$metal = 90;
|
||||
break;
|
||||
case 8:
|
||||
$metal = 300;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$metal *= 0.9;
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1) {
|
||||
$metal *= 0.9;
|
||||
}
|
||||
|
||||
return $metal * $nombre;
|
||||
}
|
||||
return $metal * $nombre;
|
||||
}
|
||||
|
||||
public static function cristal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = 45;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 90;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 105;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 150;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 100;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 10000;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 100;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 105;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 250;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function cristal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$cristal = 45;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 90;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 105;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 150;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 100;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 10000;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 100;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 105;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 250;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$cristal *= 0.9;
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1) {
|
||||
$cristal *= 0.9;
|
||||
}
|
||||
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 20;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function hydrogene($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 20;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$hydrogene *= 0.9;
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1) {
|
||||
$hydrogene *= 0.9;
|
||||
}
|
||||
|
||||
return $hydrogene * $nombre;
|
||||
}
|
||||
return $hydrogene * $nombre;
|
||||
}
|
||||
|
||||
public static function credits($id, $nombre, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public static function credits($id, $nombre, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function temps($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$temps = 60;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 1:
|
||||
$temps = 240;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 2:
|
||||
$temps = 240;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 3:
|
||||
$temps = 720;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 4:
|
||||
$temps = 300;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 5:
|
||||
$temps = 29700;
|
||||
$moins = 10;
|
||||
break;
|
||||
case 6:
|
||||
$temps = 90;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 7:
|
||||
$temps = 90;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 8:
|
||||
$temps = 900;
|
||||
$moins = 5;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function temps($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$temps = 60;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 1:
|
||||
$temps = 240;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 2:
|
||||
$temps = 240;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 3:
|
||||
$temps = 720;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 4:
|
||||
$temps = 300;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 5:
|
||||
$temps = 29700;
|
||||
$moins = 10;
|
||||
break;
|
||||
case 6:
|
||||
$temps = 90;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 7:
|
||||
$temps = 90;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 8:
|
||||
$temps = 900;
|
||||
$moins = 5;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte de la vitesse
|
||||
$temps /= VITESSE;
|
||||
//On tient compte de la vitesse
|
||||
$temps /= VITESSE;
|
||||
|
||||
//On tient compte des bonus
|
||||
return ceil($temps/pow(1.25, ($planete->batiments[9] - $moins))) * $nombre;
|
||||
}
|
||||
//On tient compte des bonus
|
||||
return ceil($temps/pow(1.25, ($planete->batiments[9] - $moins))) * $nombre;
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
array('','','','','','','','','');
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "grunt1.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "jackal.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "94990342wb4.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "98004530fx3.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "88091275ja8.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "hunter1.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "81770345oo4.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "88218731ts1.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "72188202fg9.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
return "marines.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "marinehf0.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "grenadier.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "TCAO2.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "sniper.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "spartan.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "ingenieurs.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "exosquelettehbpb2.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant") {
|
||||
array('','','','','','','','','');
|
||||
switch ($id) {
|
||||
case 0:
|
||||
return "grunt1.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "jackal.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "94990342wb4.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "98004530fx3.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "88091275ja8.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "hunter1.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "81770345oo4.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "88218731ts1.jpg";
|
||||
break;
|
||||
case 8:
|
||||
return "72188202fg9.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
} elseif ($planete->race == "humain") {
|
||||
switch ($id) {
|
||||
case 0:
|
||||
return "marines.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "marinehf0.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "grenadier.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "TCAO2.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "sniper.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "spartan.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "ingenieurs.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "exosquelettehbpb2.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
} else {
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededCaserne =
|
||||
array(
|
||||
array(
|
||||
array('batiments', 9, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 10)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 5)
|
||||
)
|
||||
);
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededCaserne =
|
||||
array(
|
||||
array(
|
||||
array('batiments', 9, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 10)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 9, 5)
|
||||
)
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededCaserne[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededCaserne[$id], $planete);
|
||||
}
|
||||
if ($print) {
|
||||
return dDonnees::print_neededCheck($neededCaserne[$id], $planete);
|
||||
} else {
|
||||
return dDonnees::neededCheck($neededCaserne[$id], $planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,202 +1,217 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
interface Donnees
|
||||
{
|
||||
const image_covenant_default = "../covenant_na.jpg";
|
||||
const image_humain_default = "../humain_na.jpg";
|
||||
const image_covenant_default = "../covenant_na.jpg";
|
||||
const image_humain_default = "../humain_na.jpg";
|
||||
|
||||
const coeff_demolition = 0.6;
|
||||
const coeff_demolition = 0.6;
|
||||
|
||||
public static function metal($id, $niveau, surface $planete);
|
||||
public static function cristal($id, $niveau, surface $planete);
|
||||
public static function hydrogene($id, $niveau, surface $planete);
|
||||
public static function credits($id, $niveau, surface $planete);
|
||||
public static function temps($id, $niveau, surface $planete);
|
||||
public static function metal($id, $niveau, surface $planete);
|
||||
public static function cristal($id, $niveau, surface $planete);
|
||||
public static function hydrogene($id, $niveau, surface $planete);
|
||||
public static function credits($id, $niveau, surface $planete);
|
||||
public static function temps($id, $niveau, surface $planete);
|
||||
|
||||
public static function image($id, surface $planete);
|
||||
public static function image($id, surface $planete);
|
||||
|
||||
public static function needed($id, surface $planete, $print = false);
|
||||
public static function needed($id, surface $planete, $print = false);
|
||||
}
|
||||
|
||||
class dDonnees{
|
||||
static function tailleFile(surface $planete)
|
||||
{
|
||||
//On calcul la taille maximale de la file d'attente
|
||||
if (!empty($planete->technologies[1]))
|
||||
{
|
||||
if (($planete->technologies[1] &131072) == 131072) return 5;
|
||||
elseif (($planete->technologies[1] &65536) == 65536) return 4;
|
||||
elseif (($planete->technologies[1] &32768) == 32768) return 3;
|
||||
else return 2;
|
||||
}
|
||||
else return 3; //Au cas où il n'y ait pas de technologie sur le lieu, on fixe la taille de la file d'attente
|
||||
}
|
||||
class dDonnees
|
||||
{
|
||||
public static function tailleFile(surface $planete)
|
||||
{
|
||||
//On calcul la taille maximale de la file d'attente
|
||||
if (!empty($planete->technologies[1])) {
|
||||
if (($planete->technologies[1] &131072) == 131072) {
|
||||
return 5;
|
||||
} elseif (($planete->technologies[1] &65536) == 65536) {
|
||||
return 4;
|
||||
} elseif (($planete->technologies[1] &32768) == 32768) {
|
||||
return 3;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
} else {
|
||||
return 3;
|
||||
} //Au cas où il n'y ait pas de technologie sur le lieu, on fixe la taille de la file d'attente
|
||||
}
|
||||
|
||||
|
||||
static function neededCheck($tableau, surface $planete)
|
||||
{
|
||||
if (!is_array($tableau)) return true;
|
||||
else
|
||||
{
|
||||
foreach ($tableau as $need)
|
||||
{
|
||||
switch($need[0])
|
||||
{
|
||||
case 'batiments':
|
||||
if (get_class($planete) == "Planete" && $planete->batiments[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'batiments_max':
|
||||
if (get_class($planete) == "Planete" && $planete->batiments[$need[1]] > $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'technologies':
|
||||
if (((int)$planete->technologies[$need[1]]& dTechnologies::idToBit($need[2])) == 0)
|
||||
return false;
|
||||
break;
|
||||
case 'casernes':
|
||||
if ($planete->casernes[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'terrestres':
|
||||
if ($planete->terrestres[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
case 'vaisseaux':
|
||||
if ($planete->vaisseaux[$need[1]] < $need[2])
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static function neededCheck($tableau, surface $planete)
|
||||
{
|
||||
if (!is_array($tableau)) {
|
||||
return true;
|
||||
} else {
|
||||
foreach ($tableau as $need) {
|
||||
switch ($need[0]) {
|
||||
case 'batiments':
|
||||
if (get_class($planete) == "Planete" && $planete->batiments[$need[1]] < $need[2]) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'batiments_max':
|
||||
if (get_class($planete) == "Planete" && $planete->batiments[$need[1]] > $need[2]) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'technologies':
|
||||
if (((int)$planete->technologies[$need[1]]& dTechnologies::idToBit($need[2])) == 0) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'casernes':
|
||||
if ($planete->casernes[$need[1]] < $need[2]) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'terrestres':
|
||||
if ($planete->terrestres[$need[1]] < $need[2]) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'vaisseaux':
|
||||
if ($planete->vaisseaux[$need[1]] < $need[2]) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static function print_neededCheck($tableau, surface $planete)
|
||||
{
|
||||
global $LANG;
|
||||
$race = $planete->race;
|
||||
if (!is_array($tableau)) return 'Débloqué';
|
||||
else
|
||||
{
|
||||
$return = '';
|
||||
foreach ($tableau as $need)
|
||||
{
|
||||
switch($need[0])
|
||||
{
|
||||
case 'batiments':
|
||||
if ($planete->batiments[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' niveau '.$need[2].' (batiment)</span><br />';
|
||||
else
|
||||
$return .= ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' niveau '.$need[2].' (batiment)<br />';
|
||||
break;
|
||||
case 'batiments_max':
|
||||
if ($planete->batiments[$need[1]] > $need[2])
|
||||
$return .= '<span class="lack">'.ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' < niveau '.($need[2]+1).' (batiment)</span><br />';
|
||||
else
|
||||
$return .= ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' < niveau '.($need[2]+1).' (batiment)<br />';
|
||||
break;
|
||||
case 'technologies':
|
||||
if (((int)$planete->technologies[$need[1]]& dTechnologies::idToBit($need[2])) == 0)
|
||||
$return .= '<span class="lack">'.$LANG[$race]["technologies"]["noms_sing"][$need[1]][$need[2]].' (technologie)</span><br />';
|
||||
else
|
||||
$return .= $LANG[$race]["technologies"]["noms_sing"][$need[1]][$need[2]].' (technologie)<br />';
|
||||
break;
|
||||
case 'casernes':
|
||||
if ($planete->casernes[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["caserne"]["noms_pluriel"][$need[1]].' (unité de la caserne)</span><br />';
|
||||
else
|
||||
$return .= $need[2].' '.$LANG[$race]["caserne"]["noms_pluriel"][$need[1]].' (unité de la caserne)<br />';
|
||||
break;
|
||||
case 'terrestres':
|
||||
if ($planete->terrestres[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["terrestre"]["noms_pluriel"][$need[1]].' (unité du chantier terrestre)</span><br />';
|
||||
else
|
||||
$return .= $need[2].' '.$LANG[$race]["terrestre"]["noms_pluriel"][$need[1]].' (unité du chantier terrestre)<br />';
|
||||
break;
|
||||
case 'vaisseaux':
|
||||
if ($planete->vaisseaux[$need[1]] < $need[2])
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["vaisseaux"]["noms_pluriel"][$need[1]].' (unité du chantier spatial)</span><br />';
|
||||
else
|
||||
$return .= $need[2].' '.$LANG[$race]["vaisseaux"]["noms_pluriel"][$need[1]].' (unité du chantier spatial)<br />';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
public static function print_neededCheck($tableau, surface $planete)
|
||||
{
|
||||
global $LANG;
|
||||
$race = $planete->race;
|
||||
if (!is_array($tableau)) {
|
||||
return 'Débloqué';
|
||||
} else {
|
||||
$return = '';
|
||||
foreach ($tableau as $need) {
|
||||
switch ($need[0]) {
|
||||
case 'batiments':
|
||||
if ($planete->batiments[$need[1]] < $need[2]) {
|
||||
$return .= '<span class="lack">'.ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' niveau '.$need[2].' (batiment)</span><br />';
|
||||
} else {
|
||||
$return .= ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' niveau '.$need[2].' (batiment)<br />';
|
||||
}
|
||||
break;
|
||||
case 'batiments_max':
|
||||
if ($planete->batiments[$need[1]] > $need[2]) {
|
||||
$return .= '<span class="lack">'.ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' < niveau '.($need[2]+1).' (batiment)</span><br />';
|
||||
} else {
|
||||
$return .= ucfirst($LANG[$race]["batiments"]["noms_sing"][$need[1]]).' < niveau '.($need[2]+1).' (batiment)<br />';
|
||||
}
|
||||
break;
|
||||
case 'technologies':
|
||||
if (((int)$planete->technologies[$need[1]]& dTechnologies::idToBit($need[2])) == 0) {
|
||||
$return .= '<span class="lack">'.$LANG[$race]["technologies"]["noms_sing"][$need[1]][$need[2]].' (technologie)</span><br />';
|
||||
} else {
|
||||
$return .= $LANG[$race]["technologies"]["noms_sing"][$need[1]][$need[2]].' (technologie)<br />';
|
||||
}
|
||||
break;
|
||||
case 'casernes':
|
||||
if ($planete->casernes[$need[1]] < $need[2]) {
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["caserne"]["noms_pluriel"][$need[1]].' (unité de la caserne)</span><br />';
|
||||
} else {
|
||||
$return .= $need[2].' '.$LANG[$race]["caserne"]["noms_pluriel"][$need[1]].' (unité de la caserne)<br />';
|
||||
}
|
||||
break;
|
||||
case 'terrestres':
|
||||
if ($planete->terrestres[$need[1]] < $need[2]) {
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["terrestre"]["noms_pluriel"][$need[1]].' (unité du chantier terrestre)</span><br />';
|
||||
} else {
|
||||
$return .= $need[2].' '.$LANG[$race]["terrestre"]["noms_pluriel"][$need[1]].' (unité du chantier terrestre)<br />';
|
||||
}
|
||||
break;
|
||||
case 'vaisseaux':
|
||||
if ($planete->vaisseaux[$need[1]] < $need[2]) {
|
||||
$return .= '<span class="lack">'.$need[2].' '.$LANG[$race]["vaisseaux"]["noms_pluriel"][$need[1]].' (unité du chantier spatial)</span><br />';
|
||||
} else {
|
||||
$return .= $need[2].' '.$LANG[$race]["vaisseaux"]["noms_pluriel"][$need[1]].' (unité du chantier spatial)<br />';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
static function nameVAR($name)
|
||||
{
|
||||
if ($name == "alli_batiments")
|
||||
return "alli_batiments";
|
||||
elseif ($name == "batiments")
|
||||
return "batiments";
|
||||
elseif ($name == "technologies")
|
||||
return "technologies";
|
||||
elseif ($name == "casernes")
|
||||
return "caserne";
|
||||
elseif ($name == "terrestres")
|
||||
return "terrestre";
|
||||
elseif ($name == "vaisseaux")
|
||||
return "spatial";
|
||||
elseif ($name == "coeff_bat")
|
||||
return "coeff";
|
||||
}
|
||||
public static function nameVAR($name)
|
||||
{
|
||||
if ($name == "alli_batiments") {
|
||||
return "alli_batiments";
|
||||
} elseif ($name == "batiments") {
|
||||
return "batiments";
|
||||
} elseif ($name == "technologies") {
|
||||
return "technologies";
|
||||
} elseif ($name == "casernes") {
|
||||
return "caserne";
|
||||
} elseif ($name == "terrestres") {
|
||||
return "terrestre";
|
||||
} elseif ($name == "vaisseaux") {
|
||||
return "spatial";
|
||||
} elseif ($name == "coeff_bat") {
|
||||
return "coeff";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static function capaciteVilles(surface $planete)
|
||||
{
|
||||
return $planete->cases * pow($planete->batiments[17], -3) + 10;
|
||||
}
|
||||
public static function capaciteVilles(surface $planete)
|
||||
{
|
||||
return $planete->cases * pow($planete->batiments[17], -3) + 10;
|
||||
}
|
||||
|
||||
static function nameVilles($level)
|
||||
{
|
||||
switch ($level)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return "Poste d'observation taille ".($level+1);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return "Poste avancé taille ".($level-2);
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return "Colonie taille ".($level-5);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return "Ville taille ".($level-8);
|
||||
break;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return "Cité taille ".($level-12);
|
||||
break;
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
return "Grande cité taille ".($level-15);
|
||||
break;
|
||||
case 19:
|
||||
return "Mégapole";
|
||||
break;
|
||||
case 20:
|
||||
return "Mégalopole";
|
||||
break;
|
||||
default:
|
||||
trigger_error("Taille de ville incorrect !");
|
||||
}
|
||||
}
|
||||
public static function nameVilles($level)
|
||||
{
|
||||
switch ($level) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return "Poste d'observation taille ".($level+1);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
return "Poste avancé taille ".($level-2);
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
return "Colonie taille ".($level-5);
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
return "Ville taille ".($level-8);
|
||||
break;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return "Cité taille ".($level-12);
|
||||
break;
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
return "Grande cité taille ".($level-15);
|
||||
break;
|
||||
case 19:
|
||||
return "Mégapole";
|
||||
break;
|
||||
case 20:
|
||||
return "Mégalopole";
|
||||
break;
|
||||
default:
|
||||
trigger_error("Taille de ville incorrect !");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -3,475 +3,468 @@ require_once("Class/Donnees/interface.php");
|
|||
|
||||
class dTerrestre implements Donnees
|
||||
{
|
||||
public static function metal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = 300;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 600;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 950;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 240;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 260;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 500;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 230;
|
||||
break;
|
||||
case 9:
|
||||
$cristal = 650;
|
||||
break;
|
||||
case 10:
|
||||
$cristal = 1750;
|
||||
break;
|
||||
case 11:
|
||||
$cristal = 3750;
|
||||
break;
|
||||
case 12:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 13:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 14:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 15:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$unite." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function metal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$cristal = 300;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 600;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 950;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 240;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 260;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 500;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 230;
|
||||
break;
|
||||
case 9:
|
||||
$cristal = 650;
|
||||
break;
|
||||
case 10:
|
||||
$cristal = 1750;
|
||||
break;
|
||||
case 11:
|
||||
$cristal = 3750;
|
||||
break;
|
||||
case 12:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 13:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 14:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 15:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$unite." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$cristal *= 0.9;
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1) {
|
||||
$cristal *= 0.9;
|
||||
}
|
||||
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
|
||||
public static function cristal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$cristal = 300;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 600;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 950;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 240;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 260;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 500;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 230;
|
||||
break;
|
||||
case 9:
|
||||
$cristal = 650;
|
||||
break;
|
||||
case 10:
|
||||
$cristal = 1750;
|
||||
break;
|
||||
case 11:
|
||||
$cristal = 3750;
|
||||
break;
|
||||
case 12:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 13:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 14:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 15:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function cristal($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$cristal = 300;
|
||||
break;
|
||||
case 1:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 2:
|
||||
$cristal = 600;
|
||||
break;
|
||||
case 3:
|
||||
$cristal = 950;
|
||||
break;
|
||||
case 4:
|
||||
$cristal = 240;
|
||||
break;
|
||||
case 5:
|
||||
$cristal = 260;
|
||||
break;
|
||||
case 6:
|
||||
$cristal = 420;
|
||||
break;
|
||||
case 7:
|
||||
$cristal = 500;
|
||||
break;
|
||||
case 8:
|
||||
$cristal = 230;
|
||||
break;
|
||||
case 9:
|
||||
$cristal = 650;
|
||||
break;
|
||||
case 10:
|
||||
$cristal = 1750;
|
||||
break;
|
||||
case 11:
|
||||
$cristal = 3750;
|
||||
break;
|
||||
case 12:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 13:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 14:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
case 15:
|
||||
$cristal = 9500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$cristal *= 0.9;
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1) {
|
||||
$cristal *= 0.9;
|
||||
}
|
||||
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
return $cristal * $nombre;
|
||||
}
|
||||
|
||||
public static function hydrogene($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 9:
|
||||
$hydrogene = 80;
|
||||
break;
|
||||
case 10:
|
||||
$hydrogene = 100;
|
||||
break;
|
||||
case 11:
|
||||
$hydrogene = 120;
|
||||
break;
|
||||
case 12:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 13:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 14:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 15:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function hydrogene($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 1:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 2:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 3:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 4:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 5:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 6:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 7:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 8:
|
||||
$hydrogene = 0;
|
||||
break;
|
||||
case 9:
|
||||
$hydrogene = 80;
|
||||
break;
|
||||
case 10:
|
||||
$hydrogene = 100;
|
||||
break;
|
||||
case 11:
|
||||
$hydrogene = 120;
|
||||
break;
|
||||
case 12:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 13:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 14:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
case 15:
|
||||
$hydrogene = 1500;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1)
|
||||
$hydrogene *= 0.9;
|
||||
//On tient compte des bonus
|
||||
if (isset($planete->politique) && $planete->politique == 1) {
|
||||
$hydrogene *= 0.9;
|
||||
}
|
||||
|
||||
return $hydrogene * $nombre;
|
||||
}
|
||||
return $hydrogene * $nombre;
|
||||
}
|
||||
|
||||
public static function credits($id, $nombre, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public static function credits($id, $nombre, surface $planete)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function temps($id, $nombre, surface $planete)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
$temps = 720;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 1:
|
||||
$temps = 2040;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 2:
|
||||
$temps = 7200;
|
||||
$moins = 4;
|
||||
break;
|
||||
case 3:
|
||||
$temps = 3960;
|
||||
$moins = 6;
|
||||
break;
|
||||
case 4:
|
||||
$temps = 600;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 5:
|
||||
$temps = 1080;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 6:
|
||||
$temps = 2160;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 7:
|
||||
$temps = 4680;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 8:
|
||||
$temps = 1080;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 9:
|
||||
$temps = 2040;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 10:
|
||||
$temps = 7200;
|
||||
$moins = 4;
|
||||
break;
|
||||
case 11:
|
||||
$temps = 3960;
|
||||
$moins = 7;
|
||||
break;
|
||||
case 12:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 13:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 14:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 15:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
public static function temps($id, $nombre, surface $planete)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
$temps = 720;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 1:
|
||||
$temps = 2040;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 2:
|
||||
$temps = 7200;
|
||||
$moins = 4;
|
||||
break;
|
||||
case 3:
|
||||
$temps = 3960;
|
||||
$moins = 6;
|
||||
break;
|
||||
case 4:
|
||||
$temps = 600;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 5:
|
||||
$temps = 1080;
|
||||
$moins = 2;
|
||||
break;
|
||||
case 6:
|
||||
$temps = 2160;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 7:
|
||||
$temps = 4680;
|
||||
$moins = 5;
|
||||
break;
|
||||
case 8:
|
||||
$temps = 1080;
|
||||
$moins = 1;
|
||||
break;
|
||||
case 9:
|
||||
$temps = 2040;
|
||||
$moins = 3;
|
||||
break;
|
||||
case 10:
|
||||
$temps = 7200;
|
||||
$moins = 4;
|
||||
break;
|
||||
case 11:
|
||||
$temps = 3960;
|
||||
$moins = 7;
|
||||
break;
|
||||
case 12:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 13:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 14:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
case 15:
|
||||
$temps = 3960;
|
||||
$moins = 9;
|
||||
break;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//On tient compte de la vitesse
|
||||
$temps /= VITESSE;
|
||||
//On tient compte de la vitesse
|
||||
$temps /= VITESSE;
|
||||
|
||||
//On tient compte des bonus
|
||||
return ceil($temps/pow(1.25, ($planete->batiments[7] - $moins))) * $nombre;
|
||||
}
|
||||
//On tient compte des bonus
|
||||
return ceil($temps/pow(1.25, ($planete->batiments[7] - $moins))) * $nombre;
|
||||
}
|
||||
|
||||
public static function type($id)
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return true;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return false;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
public static function type($id)
|
||||
{
|
||||
switch ($id) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return true;
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
return false;
|
||||
default:
|
||||
trigger_error("Unité ".$id." introuvable dans les données", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
//Unités terrestres
|
||||
case 0:
|
||||
return "bansheeqp0.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "spirit1.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "phantomfu2.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "boardingcraft.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "ghostic1.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "shadow.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "spectre.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "wraith.jpg";
|
||||
break;
|
||||
public static function image($id, surface $planete)
|
||||
{
|
||||
if ($planete->race == "covenant") {
|
||||
switch ($id) {
|
||||
//Unités terrestres
|
||||
case 0:
|
||||
return "bansheeqp0.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "spirit1.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "phantomfu2.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "boardingcraft.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "ghostic1.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "shadow.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "spectre.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "wraith.jpg";
|
||||
break;
|
||||
|
||||
//Défenses
|
||||
case 8:
|
||||
return "shade.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "defcovie.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "tourellebarreau.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "tourelle.jpg";
|
||||
break;
|
||||
case 12:
|
||||
return "lanceur_torpilles.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
}
|
||||
elseif ($planete->race == "humain")
|
||||
{
|
||||
switch($id)
|
||||
{
|
||||
//Unités terrestres
|
||||
case 0:
|
||||
return "csnusparrowhawkkp4.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "pelican.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "csnushortswordad3.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "albatross.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "warthog-vrl.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "M12G1_LAAV_Warthog.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "M12A1_LAAV_Warthog.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "scorpionN.jpg";
|
||||
break;
|
||||
//Défenses
|
||||
case 8:
|
||||
return "shade.jpg";
|
||||
break;
|
||||
case 9:
|
||||
return "defcovie.jpg";
|
||||
break;
|
||||
case 10:
|
||||
return "tourellebarreau.jpg";
|
||||
break;
|
||||
case 11:
|
||||
return "tourelle.jpg";
|
||||
break;
|
||||
case 12:
|
||||
return "lanceur_torpilles.jpg";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_covenant_default;
|
||||
} elseif ($planete->race == "humain") {
|
||||
switch ($id) {
|
||||
//Unités terrestres
|
||||
case 0:
|
||||
return "csnusparrowhawkkp4.jpg";
|
||||
break;
|
||||
case 1:
|
||||
return "pelican.jpg";
|
||||
break;
|
||||
case 2:
|
||||
return "csnushortswordad3.jpg";
|
||||
break;
|
||||
case 3:
|
||||
return "albatross.jpg";
|
||||
break;
|
||||
case 4:
|
||||
return "warthog-vrl.jpg";
|
||||
break;
|
||||
case 5:
|
||||
return "M12G1_LAAV_Warthog.jpg";
|
||||
break;
|
||||
case 6:
|
||||
return "M12A1_LAAV_Warthog.jpg";
|
||||
break;
|
||||
case 7:
|
||||
return "scorpionN.jpg";
|
||||
break;
|
||||
|
||||
//Défenses
|
||||
case 8:
|
||||
//return "";
|
||||
break;
|
||||
case 9:
|
||||
//return "";
|
||||
break;
|
||||
case 10:
|
||||
//return "";
|
||||
break;
|
||||
case 11:
|
||||
//return "";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
}
|
||||
else
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
//Défenses
|
||||
case 8:
|
||||
//return "";
|
||||
break;
|
||||
case 9:
|
||||
//return "";
|
||||
break;
|
||||
case 10:
|
||||
//return "";
|
||||
break;
|
||||
case 11:
|
||||
//return "";
|
||||
break;
|
||||
}
|
||||
return Donnees::image_humain_default;
|
||||
} else {
|
||||
trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededTerrestre = array(
|
||||
array(
|
||||
array('batiments', 7, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 6)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 5)
|
||||
),
|
||||
//Défenses
|
||||
array(
|
||||
array('batiments', 7, 1),
|
||||
array('technologies', 6, 0)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3),
|
||||
array('technologies', 6, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4),
|
||||
array('technologies', 6, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4),
|
||||
array('technologies', 6, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 6)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 10),
|
||||
array('technologies', 7, 11)
|
||||
)
|
||||
);
|
||||
public static function needed($id, surface $planete, $print = false)
|
||||
{
|
||||
$neededTerrestre = array(
|
||||
array(
|
||||
array('batiments', 7, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 6)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 5)
|
||||
),
|
||||
//Défenses
|
||||
array(
|
||||
array('batiments', 7, 1),
|
||||
array('technologies', 6, 0)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 3),
|
||||
array('technologies', 6, 3)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4),
|
||||
array('technologies', 6, 1)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 4),
|
||||
array('technologies', 6, 4)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 2)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 5)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 8),
|
||||
array('technologies', 6, 6)
|
||||
),
|
||||
array(
|
||||
array('batiments', 7, 10),
|
||||
array('technologies', 7, 11)
|
||||
)
|
||||
);
|
||||
|
||||
if ($print)
|
||||
return dDonnees::print_neededCheck($neededTerrestre[$id], $planete);
|
||||
else
|
||||
return dDonnees::neededCheck($neededTerrestre[$id], $planete);
|
||||
}
|
||||
if ($print) {
|
||||
return dDonnees::print_neededCheck($neededTerrestre[$id], $planete);
|
||||
} else {
|
||||
return dDonnees::neededCheck($neededTerrestre[$id], $planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,255 +3,249 @@ require_once("Class/File/interface.php");
|
|||
|
||||
class FileAlliancesBatiments extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object, $type = null)
|
||||
{
|
||||
$c = 0;
|
||||
if (isset($type))
|
||||
{
|
||||
if (!isset($type) || $type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, true)));
|
||||
}
|
||||
}
|
||||
if (!isset($type) || !$type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
public function nbObjectInFile($object, $type = null)
|
||||
{
|
||||
$c = 0;
|
||||
if (isset($type)) {
|
||||
if (!isset($type) || $type) {
|
||||
foreach ($this->files as $file) {
|
||||
$c += count(array_keys($file, array($object, true)));
|
||||
}
|
||||
}
|
||||
if (!isset($type) || !$type) {
|
||||
foreach ($this->files as $file) {
|
||||
$c += count(array_keys($file, array($object, false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
public function addObjet($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete)) {
|
||||
throw new ExceptionHB(1, 1);
|
||||
}
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dAlliancesBatiments::needed($object, $planete))
|
||||
throw new ExceptionHB(1, 2);
|
||||
//Validation des conditions de construction
|
||||
if (!dAlliancesBatiments::needed($object, $planete)) {
|
||||
throw new ExceptionHB(1, 2);
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de démolition du même bâtiment
|
||||
if ($this->nbObjectInFile($object, true) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
//On vérifie qu'il n'y ait pas une demande de démolition du même bâtiment
|
||||
if ($this->nbObjectInFile($object, true) >= 1) {
|
||||
throw new ExceptionHB(1, 7);
|
||||
}
|
||||
|
||||
//Calcul du prochain niveau du batiment
|
||||
$nextLvl = $planete->batiments[$object] + $this->nbObjectInFile($object, false) + 1;
|
||||
//Calcul du prochain niveau du batiment
|
||||
$nextLvl = $planete->batiments[$object] + $this->nbObjectInFile($object, false) + 1;
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dAlliancesBatiments::metal($object, $nextLvl, $planete), dAlliancesBatiments::cristal($object, $nextLvl, $planete), dAlliancesBatiments::hydrogene($object, $nextLvl, $planete), dAlliancesBatiments::credits($object, $nextLvl, $planete)))
|
||||
{
|
||||
$this->files[$lieu][] = array($object, false);
|
||||
$planete->addModif("file_bat");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(1, 4);
|
||||
}
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dAlliancesBatiments::metal($object, $nextLvl, $planete), dAlliancesBatiments::cristal($object, $nextLvl, $planete), dAlliancesBatiments::hydrogene($object, $nextLvl, $planete), dAlliancesBatiments::credits($object, $nextLvl, $planete))) {
|
||||
$this->files[$lieu][] = array($object, false);
|
||||
$planete->addModif("file_bat");
|
||||
return true;
|
||||
} else {
|
||||
throw new ExceptionHB(1, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
public function addDemolition($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete)) {
|
||||
throw new ExceptionHB(1, 1);
|
||||
}
|
||||
|
||||
//On vérifie que le niveau actuel du batiment ne soit non nul
|
||||
if ($planete->batiments[$object] <= $this->nbObjectInFile($object, false))
|
||||
throw new ExceptionHB(1, 6);
|
||||
//On vérifie que le niveau actuel du batiment ne soit non nul
|
||||
if ($planete->batiments[$object] <= $this->nbObjectInFile($object, false)) {
|
||||
throw new ExceptionHB(1, 6);
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de construction du même bâtiment
|
||||
if ($this->nbObjectInFile($object, false) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
//On vérifie qu'il n'y ait pas une demande de construction du même bâtiment
|
||||
if ($this->nbObjectInFile($object, false) >= 1) {
|
||||
throw new ExceptionHB(1, 7);
|
||||
}
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, true);
|
||||
$this->files[$lieu][] = array($object, true);
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id])) {
|
||||
throw new ExceptionHB(1, 5);
|
||||
}
|
||||
|
||||
//On récupère le type de batiment
|
||||
$object = $this->files[$lieu][$id][0];
|
||||
//On récupère le type de batiment
|
||||
$object = $this->files[$lieu][$id][0];
|
||||
|
||||
//On gère les démolition
|
||||
//@todo -cFileBatiments Est-ce vraiment utile de calculer le niveau du batiment en cas de démolition ?
|
||||
if ($this->files[$lieu][$id][1])
|
||||
$lvlAnnule = $planete->batiments[$object] - $this->nbObjectInFile($object, true) + 1;
|
||||
else
|
||||
$lvlAnnule = $planete->batiments[$object] + $this->nbObjectInFile($object, false);
|
||||
//On gère les démolition
|
||||
//@todo -cFileBatiments Est-ce vraiment utile de calculer le niveau du batiment en cas de démolition ?
|
||||
if ($this->files[$lieu][$id][1]) {
|
||||
$lvlAnnule = $planete->batiments[$object] - $this->nbObjectInFile($object, true) + 1;
|
||||
} else {
|
||||
$lvlAnnule = $planete->batiments[$object] + $this->nbObjectInFile($object, false);
|
||||
}
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier batiment en lice
|
||||
if ($id == $this->findFirstKey($lieu))
|
||||
$this->times[$lieu] = time();
|
||||
//On met à jour le temps si on vient d'annuler le premier batiment en lice
|
||||
if ($id == $this->findFirstKey($lieu)) {
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
if (!$this->files[$lieu][$id][1])
|
||||
{
|
||||
//On redonne 60% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0)
|
||||
$planete->addRessources(dAlliancesBatiments::metal($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::cristal($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::hydrogene($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::credits($object, $lvlAnnule, $planete)*0.6);
|
||||
else
|
||||
$planete->addRessources(dAlliancesBatiments::metal($object, $lvlAnnule, $planete), dAlliancesBatiments::cristal($object, $lvlAnnule, $planete), dAlliancesBatiments::hydrogene($object, $lvlAnnule, $planete), dAlliancesBatiments::credits($object, $lvlAnnule, $planete));
|
||||
}
|
||||
if (!$this->files[$lieu][$id][1]) {
|
||||
//On redonne 60% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0) {
|
||||
$planete->addRessources(dAlliancesBatiments::metal($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::cristal($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::hydrogene($object, $lvlAnnule, $planete)*0.6, dAlliancesBatiments::credits($object, $lvlAnnule, $planete)*0.6);
|
||||
} else {
|
||||
$planete->addRessources(dAlliancesBatiments::metal($object, $lvlAnnule, $planete), dAlliancesBatiments::cristal($object, $lvlAnnule, $planete), dAlliancesBatiments::hydrogene($object, $lvlAnnule, $planete), dAlliancesBatiments::credits($object, $lvlAnnule, $planete));
|
||||
}
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element) {
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gère les démolitions
|
||||
if ($element[1])
|
||||
{
|
||||
//On récupère le niveau actuel du batiment
|
||||
$lvl = $planete->batiments[$element[0]];
|
||||
//On gère les démolitions
|
||||
if ($element[1]) {
|
||||
//On récupère le niveau actuel du batiment
|
||||
$lvl = $planete->batiments[$element[0]];
|
||||
|
||||
//On calcul le temps de démolition nécessaire (60% du niveau actuel)
|
||||
$tempsNecessaire = dAlliancesBatiments::temps($element[0], $lvl, $planete, true);
|
||||
//On calcul le temps de démolition nécessaire (60% du niveau actuel)
|
||||
$tempsNecessaire = dAlliancesBatiments::temps($element[0], $lvl, $planete, true);
|
||||
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
$metal = dAlliancesBatiments::metal($element[0], $lvl, $planete);
|
||||
$cristal = dAlliancesBatiments::cristal($element[0], $lvl, $planete);
|
||||
$hydrogene = dAlliancesBatiments::hydrogene($element[0], $lvl, $planete);
|
||||
if ($tempsEcoule >= $tempsNecessaire) {
|
||||
$metal = dAlliancesBatiments::metal($element[0], $lvl, $planete);
|
||||
$cristal = dAlliancesBatiments::cristal($element[0], $lvl, $planete);
|
||||
$hydrogene = dAlliancesBatiments::hydrogene($element[0], $lvl, $planete);
|
||||
|
||||
//On redonne 70% des ressources du batiment au joueur
|
||||
$planete->addRessources($metal*0.7, $cristal*0.7, $hydrogene*0.7);
|
||||
//On redonne 70% des ressources du batiment au joueur
|
||||
$planete->addRessources($metal*0.7, $cristal*0.7, $hydrogene*0.7);
|
||||
|
||||
//On retire un niveau au batiment
|
||||
$planete->batiments[$element[0]]--;
|
||||
//On retire un niveau au batiment
|
||||
$planete->batiments[$element[0]]--;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On retire les points
|
||||
$planete->addPoints($metal, $cristal, $hydrogene, 0, true);
|
||||
//On retire les points
|
||||
$planete->addPoints($metal, $cristal, $hydrogene, 0, true);
|
||||
|
||||
unset($metal, $cristal, $hydrogene);
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du niveau du batiment
|
||||
$lvl = $planete->batiments[$element[0]] + 1;
|
||||
unset($metal, $cristal, $hydrogene);
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} else { //Cas de la construction
|
||||
//Récupération du niveau du batiment
|
||||
$lvl = $planete->batiments[$element[0]] + 1;
|
||||
|
||||
$tempsNecessaire = dAlliancesBatiments::temps($element[0], $lvl, $planete);
|
||||
$tempsNecessaire = dAlliancesBatiments::temps($element[0], $lvl, $planete);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->batiments[$element[0]]++;
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire) {
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->batiments[$element[0]]++;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dAlliancesBatiments::metal($element[0], $planete->batiments[$element[0]], $planete), dAlliancesBatiments::cristal($element[0], $planete->batiments[$element[0]], $planete), dAlliancesBatiments::hydrogene($element[0], $planete->batiments[$element[0]], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dAlliancesBatiments::metal($element[0], $planete->batiments[$element[0]], $planete), dAlliancesBatiments::cristal($element[0], $planete->batiments[$element[0]], $planete), dAlliancesBatiments::hydrogene($element[0], $planete->batiments[$element[0]], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function printFile(SURFACE $planete, $lieu = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
public function printFile(SURFACE $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
if (isset($lieu) && $lieu != $keyF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[1]) //Cas d'une démolition
|
||||
{
|
||||
$temps = dAlliancesBatiments::temps($element[0], $planete->batiments[$element[0]], $planete, true);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
else //Cas d'une construction
|
||||
{
|
||||
$temps = dAlliancesBatiments::temps($element[0], $planete->batiments[$element[0]]+1, $planete);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[1]) { //Cas d'une démolition
|
||||
$temps = dAlliancesBatiments::temps($element[0], $planete->batiments[$element[0]], $planete, true);
|
||||
if ($prems) {
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
} else { //Cas d'une construction
|
||||
$temps = dAlliancesBatiments::temps($element[0], $planete->batiments[$element[0]]+1, $planete);
|
||||
if ($prems) {
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,266 +3,258 @@ require_once("Class/File/interface.php");
|
|||
|
||||
class FileBatiments extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object, $type = null)
|
||||
{
|
||||
$c = 0;
|
||||
if (!isset($object))
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count($file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($type) || $type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, true)));
|
||||
}
|
||||
}
|
||||
if (!isset($type) || !$type)
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($object, false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
public function nbObjectInFile($object, $type = null)
|
||||
{
|
||||
$c = 0;
|
||||
if (!isset($object)) {
|
||||
foreach ($this->files as $file) {
|
||||
$c += count($file);
|
||||
}
|
||||
} else {
|
||||
if (!isset($type) || $type) {
|
||||
foreach ($this->files as $file) {
|
||||
$c += count(array_keys($file, array($object, true)));
|
||||
}
|
||||
}
|
||||
if (!isset($type) || !$type) {
|
||||
foreach ($this->files as $file) {
|
||||
$c += count(array_keys($file, array($object, false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
public function addObjet($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete)) {
|
||||
throw new ExceptionHB(1, 1);
|
||||
}
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dBatiments::needed($object, $planete))
|
||||
throw new ExceptionHB(1, 2);
|
||||
//Validation des conditions de construction
|
||||
if (!dBatiments::needed($object, $planete)) {
|
||||
throw new ExceptionHB(1, 2);
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de démolition du même bâtiment
|
||||
if ($this->nbObjectInFile($object, true) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
//On vérifie qu'il n'y ait pas une demande de démolition du même bâtiment
|
||||
if ($this->nbObjectInFile($object, true) >= 1) {
|
||||
throw new ExceptionHB(1, 7);
|
||||
}
|
||||
|
||||
//On vérifie qu'il reste suffisamment de place sur la planète
|
||||
if ($planete->casesRest <= 0 || $planete->casesRest <= $this->nbObjectInFile(null))
|
||||
throw new ExceptionHB(1, 0);
|
||||
//On vérifie qu'il reste suffisamment de place sur la planète
|
||||
if ($planete->casesRest <= 0 || $planete->casesRest <= $this->nbObjectInFile(null)) {
|
||||
throw new ExceptionHB(1, 0);
|
||||
}
|
||||
|
||||
//Calcul du prochain niveau du batiment
|
||||
$nextLvl = $planete->batiments[$object] + $this->nbObjectInFile($object, false) + 1;
|
||||
//Calcul du prochain niveau du batiment
|
||||
$nextLvl = $planete->batiments[$object] + $this->nbObjectInFile($object, false) + 1;
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dBatiments::metal($object, $nextLvl, $planete), dBatiments::cristal($object, $nextLvl, $planete), dBatiments::hydrogene($object, $nextLvl, $planete), dBatiments::credits($object, $nextLvl, $planete)))
|
||||
{
|
||||
$this->files[$lieu][] = array($object, false);
|
||||
$planete->addModif("file_bat");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(1, 4);
|
||||
}
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dBatiments::metal($object, $nextLvl, $planete), dBatiments::cristal($object, $nextLvl, $planete), dBatiments::hydrogene($object, $nextLvl, $planete), dBatiments::credits($object, $nextLvl, $planete))) {
|
||||
$this->files[$lieu][] = array($object, false);
|
||||
$planete->addModif("file_bat");
|
||||
return true;
|
||||
} else {
|
||||
throw new ExceptionHB(1, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(1, 1);
|
||||
public function addDemolition($object, $nombre, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete)) {
|
||||
throw new ExceptionHB(1, 1);
|
||||
}
|
||||
|
||||
//On vérifie que le niveau actuel du batiment ne soit non nul
|
||||
if ($planete->batiments[$object] <= $this->nbObjectInFile($object, false))
|
||||
throw new ExceptionHB(1, 6);
|
||||
//On vérifie que le niveau actuel du batiment ne soit non nul
|
||||
if ($planete->batiments[$object] <= $this->nbObjectInFile($object, false)) {
|
||||
throw new ExceptionHB(1, 6);
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une demande de construction du même bâtiment
|
||||
if ($this->nbObjectInFile($object, false) >= 1)
|
||||
throw new ExceptionHB(1, 7);
|
||||
//On vérifie qu'il n'y ait pas une demande de construction du même bâtiment
|
||||
if ($this->nbObjectInFile($object, false) >= 1) {
|
||||
throw new ExceptionHB(1, 7);
|
||||
}
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, true);
|
||||
$this->files[$lieu][] = array($object, true);
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id])) {
|
||||
throw new ExceptionHB(1, 5);
|
||||
}
|
||||
|
||||
//On récupère le type de batiment
|
||||
$object = $this->files[$lieu][$id][0];
|
||||
//On récupère le type de batiment
|
||||
$object = $this->files[$lieu][$id][0];
|
||||
|
||||
//On gère les démolition
|
||||
//@todo -cFileBatiments Est-ce vraiment utile de calculer le niveau du batiment en cas de démolition ?
|
||||
if ($this->files[$lieu][$id][1])
|
||||
$lvlAnnule = $planete->batiments[$object] - $this->nbObjectInFile($object, true) + 1;
|
||||
else
|
||||
$lvlAnnule = $planete->batiments[$object] + $this->nbObjectInFile($object, false);
|
||||
//On gère les démolition
|
||||
//@todo -cFileBatiments Est-ce vraiment utile de calculer le niveau du batiment en cas de démolition ?
|
||||
if ($this->files[$lieu][$id][1]) {
|
||||
$lvlAnnule = $planete->batiments[$object] - $this->nbObjectInFile($object, true) + 1;
|
||||
} else {
|
||||
$lvlAnnule = $planete->batiments[$object] + $this->nbObjectInFile($object, false);
|
||||
}
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier batiment en lice
|
||||
if ($id == $this->findFirstKey($lieu))
|
||||
$this->times[$lieu] = time();
|
||||
//On met à jour le temps si on vient d'annuler le premier batiment en lice
|
||||
if ($id == $this->findFirstKey($lieu)) {
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
|
||||
$planete->addModif("file_bat");
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
if (!$this->files[$lieu][$id][1])
|
||||
{
|
||||
//On redonne 60% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0)
|
||||
$planete->addRessources(dBatiments::metal($object, $lvlAnnule, $planete)*0.6, dBatiments::cristal($object, $lvlAnnule, $planete)*0.6, dBatiments::hydrogene($object, $lvlAnnule, $planete)*0.6, dBatiments::credits($object, $lvlAnnule, $planete)*0.6);
|
||||
else
|
||||
$planete->addRessources(dBatiments::metal($object, $lvlAnnule, $planete), dBatiments::cristal($object, $lvlAnnule, $planete), dBatiments::hydrogene($object, $lvlAnnule, $planete), dBatiments::credits($object, $lvlAnnule, $planete));
|
||||
}
|
||||
if (!$this->files[$lieu][$id][1]) {
|
||||
//On redonne 60% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0) {
|
||||
$planete->addRessources(dBatiments::metal($object, $lvlAnnule, $planete)*0.6, dBatiments::cristal($object, $lvlAnnule, $planete)*0.6, dBatiments::hydrogene($object, $lvlAnnule, $planete)*0.6, dBatiments::credits($object, $lvlAnnule, $planete)*0.6);
|
||||
} else {
|
||||
$planete->addRessources(dBatiments::metal($object, $lvlAnnule, $planete), dBatiments::cristal($object, $lvlAnnule, $planete), dBatiments::hydrogene($object, $lvlAnnule, $planete), dBatiments::credits($object, $lvlAnnule, $planete));
|
||||
}
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element) {
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gère les démolitions
|
||||
if ($element[1])
|
||||
{
|
||||
//On récupère le niveau actuel du batiment
|
||||
$lvl = $planete->batiments[$element[0]];
|
||||
//On gère les démolitions
|
||||
if ($element[1]) {
|
||||
//On récupère le niveau actuel du batiment
|
||||
$lvl = $planete->batiments[$element[0]];
|
||||
|
||||
//On calcul le temps de démolition nécessaire (60% du niveau actuel)
|
||||
$tempsNecessaire = dBatiments::temps($element[0], $lvl, $planete, true);
|
||||
//On calcul le temps de démolition nécessaire (60% du niveau actuel)
|
||||
$tempsNecessaire = dBatiments::temps($element[0], $lvl, $planete, true);
|
||||
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
$metal = dBatiments::metal($element[0], $lvl, $planete);
|
||||
$cristal = dBatiments::cristal($element[0], $lvl, $planete);
|
||||
$hydrogene = dBatiments::hydrogene($element[0], $lvl, $planete);
|
||||
if ($tempsEcoule >= $tempsNecessaire) {
|
||||
$metal = dBatiments::metal($element[0], $lvl, $planete);
|
||||
$cristal = dBatiments::cristal($element[0], $lvl, $planete);
|
||||
$hydrogene = dBatiments::hydrogene($element[0], $lvl, $planete);
|
||||
|
||||
//On redonne 70% des ressources du batiment au joueur
|
||||
$planete->addRessources($metal*0.7, $cristal*0.7, $hydrogene*0.7);
|
||||
//On redonne 70% des ressources du batiment au joueur
|
||||
$planete->addRessources($metal*0.7, $cristal*0.7, $hydrogene*0.7);
|
||||
|
||||
//On retire un niveau au batiment
|
||||
$planete->batiments[$element[0]]--;
|
||||
//On retire un niveau au batiment
|
||||
$planete->batiments[$element[0]]--;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On retire les points
|
||||
$planete->addPoints($metal, $cristal, $hydrogene, 0, true);
|
||||
//On retire les points
|
||||
$planete->addPoints($metal, $cristal, $hydrogene, 0, true);
|
||||
|
||||
unset($metal, $cristal, $hydrogene);
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du niveau du batiment
|
||||
$lvl = $planete->batiments[$element[0]] + 1;
|
||||
unset($metal, $cristal, $hydrogene);
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} else { //Cas de la construction
|
||||
//Récupération du niveau du batiment
|
||||
$lvl = $planete->batiments[$element[0]] + 1;
|
||||
|
||||
$tempsNecessaire = dBatiments::temps($element[0], $lvl, $planete);
|
||||
$tempsNecessaire = dBatiments::temps($element[0], $lvl, $planete);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->batiments[$element[0]]++;
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire) {
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->batiments[$element[0]]++;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("batiments", $element[0]));
|
||||
$planete->addModif("file_bat");
|
||||
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dBatiments::metal($element[0], $planete->batiments[$element[0]], $planete), dBatiments::cristal($element[0], $planete->batiments[$element[0]], $planete), dBatiments::hydrogene($element[0], $planete->batiments[$element[0]], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dBatiments::metal($element[0], $planete->batiments[$element[0]], $planete), dBatiments::cristal($element[0], $planete->batiments[$element[0]], $planete), dBatiments::hydrogene($element[0], $planete->batiments[$element[0]], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function printFile(SURFACE $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
public function printFile(SURFACE $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
if (isset($lieu) && $lieu != $keyF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[1]) //Cas d'une démolition
|
||||
{
|
||||
$temps = dBatiments::temps($element[0], $planete->batiments[$element[0]], $planete, true);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
else //Cas d'une construction
|
||||
{
|
||||
$temps = dBatiments::temps($element[0], $planete->batiments[$element[0]]+1, $planete);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[1]) { //Cas d'une démolition
|
||||
$temps = dBatiments::temps($element[0], $planete->batiments[$element[0]], $planete, true);
|
||||
if ($prems) {
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
} else { //Cas d'une construction
|
||||
$temps = dBatiments::temps($element[0], $planete->batiments[$element[0]]+1, $planete);
|
||||
if ($prems) {
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,307 +3,304 @@ require_once("Class/File/interface.php");
|
|||
|
||||
class FileCaserne extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
{
|
||||
foreach($this->files[$lieu] as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu)) {
|
||||
if (!empty($this->files[$lieu])) {
|
||||
foreach ($this->files[$lieu] as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
foreach($file as $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach ($this->files as $key => $file) {
|
||||
foreach ($file as $element) {
|
||||
if ($element[0] == $object) {
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999) {
|
||||
throw new ExceptionHB(3, 8);
|
||||
}
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dCaserne::needed($object, $planete))
|
||||
throw new ExceptionHB(3, 2);
|
||||
//Validation des conditions de construction
|
||||
if (!dCaserne::needed($object, $planete)) {
|
||||
throw new ExceptionHB(3, 2);
|
||||
}
|
||||
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu))
|
||||
throw new ExceptionHB(3, 1);
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu)) {
|
||||
throw new ExceptionHB(3, 1);
|
||||
}
|
||||
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dCaserne::metal($object, 1, $planete)) > 0)
|
||||
$metal = $planete->metal/$metal;
|
||||
else
|
||||
$metal = $nombre;
|
||||
if (($cristal = dCaserne::cristal($object, 1, $planete)) > 0)
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
else
|
||||
$cristal = $nombre;
|
||||
if (($hydrogene = dCaserne::hydrogene($object, 1, $planete)) > 0)
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
else
|
||||
$hydrogene = $nombre;
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dCaserne::metal($object, 1, $planete)) > 0) {
|
||||
$metal = $planete->metal/$metal;
|
||||
} else {
|
||||
$metal = $nombre;
|
||||
}
|
||||
if (($cristal = dCaserne::cristal($object, 1, $planete)) > 0) {
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
} else {
|
||||
$cristal = $nombre;
|
||||
}
|
||||
if (($hydrogene = dCaserne::hydrogene($object, 1, $planete)) > 0) {
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
} else {
|
||||
$hydrogene = $nombre;
|
||||
}
|
||||
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dCaserne::metal($object, $nombre, $planete), dCaserne::cristal($object, $nombre, $planete), dCaserne::hydrogene($object, $nombre, $planete), dCaserne::credits($object, $nombre, $planete)))
|
||||
{
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]]))
|
||||
{
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dCaserne::metal($object, $nombre, $planete), dCaserne::cristal($object, $nombre, $planete), dCaserne::hydrogene($object, $nombre, $planete), dCaserne::credits($object, $nombre, $planete))) {
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if (isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]])) {
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
} else {
|
||||
if (!isset($lieu)) {
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_cas");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
$planete->addModif("file_cas");
|
||||
return true;
|
||||
} else {
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu)))
|
||||
throw new ExceptionHB(3, 1);
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu))) {
|
||||
throw new ExceptionHB(3, 1);
|
||||
}
|
||||
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999) {
|
||||
throw new ExceptionHB(3, 8);
|
||||
}
|
||||
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->casernes[$object] < $nombre)
|
||||
throw new ExceptionHB(3, 6);
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->casernes[$object] < $nombre) {
|
||||
throw new ExceptionHB(3, 6);
|
||||
}
|
||||
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
if (!isset($lieu)) {
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey))
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
else
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if (isset($sauvLastKey)) {
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
} else {
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_cas");
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id])) {
|
||||
throw new ExceptionHB(1, 5);
|
||||
}
|
||||
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre)
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre) {
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
}
|
||||
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre)
|
||||
$this->times[$lieu] = time();
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre) {
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
|
||||
$planete->addModif("file_cas");
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
if (!$this->files[$lieu][$id][2])
|
||||
$planete->addRessources(dCaserne::metal($objet, $nombre, $planete), dCaserne::cristal($objet, $nombre, $planete), dCaserne::hydrogene($objet, $nombre, $planete), dCaserne::credits($objet, $nombre, $planete));
|
||||
if (!$this->files[$lieu][$id][2]) {
|
||||
$planete->addRessources(dCaserne::metal($objet, $nombre, $planete), dCaserne::cristal($objet, $nombre, $planete), dCaserne::hydrogene($objet, $nombre, $planete), dCaserne::credits($objet, $nombre, $planete));
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax)
|
||||
unset($this->files[$lieu][$id]);
|
||||
else
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
$planete->addModif("file_cas");
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax) {
|
||||
unset($this->files[$lieu][$id]);
|
||||
} else {
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
}
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach ($file as $keyE => $element) {
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gére les licenciments !
|
||||
if ($element[2])
|
||||
{
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->casernes[$element[0]] <= 0)
|
||||
{
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_cas");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dCaserne::temps($element[0], 1, $planete) * 0.6;
|
||||
//On gére les licenciments !
|
||||
if ($element[2]) {
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->casernes[$element[0]] <= 0) {
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_cas");
|
||||
} else {
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dCaserne::temps($element[0], 1, $planete) * 0.6;
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->casernes[$element[0]]);
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->casernes[$element[0]]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dCaserne::metal($element[0], $nbUnitee, $planete)*0.7, dCaserne::cristal($element[0], $nbUnitee, $planete)*0.7, dCaserne::hydrogene($element[0], $nbUnitee, $planete)*0.7, dCaserne::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0) {
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dCaserne::metal($element[0], $nbUnitee, $planete)*0.7, dCaserne::cristal($element[0], $nbUnitee, $planete)*0.7, dCaserne::hydrogene($element[0], $nbUnitee, $planete)*0.7, dCaserne::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
|
||||
//On retire les unités
|
||||
$planete->casernes[$element[0]] -= $nbUnitee;
|
||||
//On retire les unités
|
||||
$planete->casernes[$element[0]] -= $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
else
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1]) {
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
} else {
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
}
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("casernes", $element[0]));
|
||||
$planete->addModif("file_cas");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("casernes", $element[0]));
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
return false;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dCaserne::temps($element[0], 1, $planete);
|
||||
if ($nbUnitee < $element[1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { //Cas de la construction
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dCaserne::temps($element[0], 1, $planete);
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->casernes[$element[0]] += $nbUnitee;
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0) {
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->casernes[$element[0]] += $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
else
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1]) {
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
} else {
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
}
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("casernes", $element[0]));
|
||||
$planete->addModif("file_cas");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("casernes", $element[0]));
|
||||
$planete->addModif("file_cas");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
break;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nbUnitee < $element[1]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function printFile(SURFACE $planete, $lieu = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
public function printFile(SURFACE $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
if (isset($lieu) && $lieu != $keyF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[2])
|
||||
{
|
||||
$temps = dCaserne::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
else
|
||||
{
|
||||
$temps = dCaserne::temps($element[0], 1, $planete);
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[2]) {
|
||||
$temps = dCaserne::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems) {
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
} else {
|
||||
$temps_moins = 0;
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
} else {
|
||||
$temps = dCaserne::temps($element[0], 1, $planete);
|
||||
if ($prems) {
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
} else {
|
||||
$temps_moins = 0;
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,113 +1,113 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
interface File
|
||||
{
|
||||
public function objectInFile($object);
|
||||
public function nbObjectInFile($object);
|
||||
public function addObjet($object, $nombre, surface $planete);
|
||||
public function addDemolition($object, $nombre, surface $planete);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete);
|
||||
public function ready(surface $planete);
|
||||
public function objectInFile($object);
|
||||
public function nbObjectInFile($object);
|
||||
public function addObjet($object, $nombre, surface $planete);
|
||||
public function addDemolition($object, $nombre, surface $planete);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete);
|
||||
public function ready(surface $planete);
|
||||
|
||||
public function printFile(surface $planete, $lieu = NULL);
|
||||
public function printFile(surface $planete, $lieu = null);
|
||||
}
|
||||
|
||||
class FileCommun
|
||||
{
|
||||
protected $files = array();
|
||||
protected $times = array();
|
||||
protected $simultane;
|
||||
protected $files = array();
|
||||
protected $times = array();
|
||||
protected $simultane;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->times[] = time();
|
||||
$this->simultane = 1;
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
$this->times[] = time();
|
||||
$this->simultane = 1;
|
||||
}
|
||||
|
||||
function refreshTime($lieu)
|
||||
{
|
||||
if (empty($this->files[$lieu]) || count($this->files[$lieu]) < 1)
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
public function refreshTime($lieu)
|
||||
{
|
||||
if (empty($this->files[$lieu]) || count($this->files[$lieu]) < 1) {
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
}
|
||||
|
||||
function reajusteVacances($timelost)
|
||||
{
|
||||
foreach($this->times as $key => $time)
|
||||
$this->times[$key] += $timelost;
|
||||
public function reajusteVacances($timelost)
|
||||
{
|
||||
foreach ($this->times as $key => $time) {
|
||||
$this->times[$key] += $timelost;
|
||||
}
|
||||
|
||||
return serialize($this);
|
||||
}
|
||||
return serialize($this);
|
||||
}
|
||||
|
||||
function hasObject()
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
if (count($file) > 0)
|
||||
return true;
|
||||
}
|
||||
public function hasObject()
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if (count($file) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkMaxSize(surface $planete, $lieu = null)
|
||||
{
|
||||
$nombre = 0;
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
$nombre = count($this->files[$lieu]);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$nombre += count($file);
|
||||
}
|
||||
}
|
||||
public function checkMaxSize(surface $planete, $lieu = null)
|
||||
{
|
||||
$nombre = 0;
|
||||
if (isset($lieu)) {
|
||||
if (!empty($this->files[$lieu])) {
|
||||
$nombre = count($this->files[$lieu]);
|
||||
}
|
||||
} else {
|
||||
foreach ($this->files as $file) {
|
||||
$nombre += count($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ($nombre < dDonnees::tailleFile($planete));
|
||||
}
|
||||
return ($nombre < dDonnees::tailleFile($planete));
|
||||
}
|
||||
|
||||
function findShorter()
|
||||
{
|
||||
$short = 0;
|
||||
$value = 99;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
if ($key >= $this->simultane)
|
||||
break;
|
||||
public function findShorter()
|
||||
{
|
||||
$short = 0;
|
||||
$value = 99;
|
||||
foreach ($this->files as $key => $file) {
|
||||
if ($key >= $this->simultane) {
|
||||
break;
|
||||
}
|
||||
|
||||
$count = count($file);
|
||||
if ($value > $count)
|
||||
{
|
||||
$value = $count;
|
||||
$short = $key;
|
||||
}
|
||||
}
|
||||
$count = count($file);
|
||||
if ($value > $count) {
|
||||
$value = $count;
|
||||
$short = $key;
|
||||
}
|
||||
}
|
||||
|
||||
return $short;
|
||||
}
|
||||
return $short;
|
||||
}
|
||||
|
||||
function findFirstKey($lieu)
|
||||
{
|
||||
foreach($this->files[$lieu] as $key => $file)
|
||||
return $key;
|
||||
}
|
||||
public function findFirstKey($lieu)
|
||||
{
|
||||
foreach ($this->files[$lieu] as $key => $file) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function DEBUG__print()
|
||||
{
|
||||
var_dump($this);
|
||||
var_dump($this->files);
|
||||
}
|
||||
public function DEBUG__print()
|
||||
{
|
||||
var_dump($this);
|
||||
var_dump($this->files);
|
||||
}
|
||||
|
||||
function DEBUG__setTime($lieu, $moins)
|
||||
{
|
||||
$this->times[$lieu] -= $moins;
|
||||
public function DEBUG__setTime($lieu, $moins)
|
||||
{
|
||||
$this->times[$lieu] -= $moins;
|
||||
|
||||
return $this->times[$lieu];
|
||||
}
|
||||
return $this->times[$lieu];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,307 +3,304 @@ require_once("Class/File/interface.php");
|
|||
|
||||
class FileSpatial extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
{
|
||||
foreach($this->files[$lieu] as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu)) {
|
||||
if (!empty($this->files[$lieu])) {
|
||||
foreach ($this->files[$lieu] as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
foreach($file as $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach ($this->files as $key => $file) {
|
||||
foreach ($file as $element) {
|
||||
if ($element[0] == $object) {
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999) {
|
||||
throw new ExceptionHB(3, 8);
|
||||
}
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dSpatial::needed($object, $planete))
|
||||
throw new ExceptionHB(3, 2);
|
||||
//Validation des conditions de construction
|
||||
if (!dSpatial::needed($object, $planete)) {
|
||||
throw new ExceptionHB(3, 2);
|
||||
}
|
||||
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu))
|
||||
throw new ExceptionHB(3, 1);
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu)) {
|
||||
throw new ExceptionHB(3, 1);
|
||||
}
|
||||
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dSpatial::metal($object, 1, $planete)) > 0)
|
||||
$metal = $planete->metal/$metal;
|
||||
else
|
||||
$metal = $nombre;
|
||||
if (($cristal = dSpatial::cristal($object, 1, $planete)) > 0)
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
else
|
||||
$cristal = $nombre;
|
||||
if (($hydrogene = dSpatial::hydrogene($object, 1, $planete)) > 0)
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
else
|
||||
$hydrogene = $nombre;
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dSpatial::metal($object, 1, $planete)) > 0) {
|
||||
$metal = $planete->metal/$metal;
|
||||
} else {
|
||||
$metal = $nombre;
|
||||
}
|
||||
if (($cristal = dSpatial::cristal($object, 1, $planete)) > 0) {
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
} else {
|
||||
$cristal = $nombre;
|
||||
}
|
||||
if (($hydrogene = dSpatial::hydrogene($object, 1, $planete)) > 0) {
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
} else {
|
||||
$hydrogene = $nombre;
|
||||
}
|
||||
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dSpatial::metal($object, $nombre, $planete), dSpatial::cristal($object, $nombre, $planete), dSpatial::hydrogene($object, $nombre, $planete), dSpatial::credits($object, $nombre, $planete)))
|
||||
{
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]]))
|
||||
{
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dSpatial::metal($object, $nombre, $planete), dSpatial::cristal($object, $nombre, $planete), dSpatial::hydrogene($object, $nombre, $planete), dSpatial::credits($object, $nombre, $planete))) {
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if (isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]])) {
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
} else {
|
||||
if (!isset($lieu)) {
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_vais");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
$planete->addModif("file_vais");
|
||||
return true;
|
||||
} else {
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu)))
|
||||
throw new ExceptionHB(3, 1);
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu))) {
|
||||
throw new ExceptionHB(3, 1);
|
||||
}
|
||||
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999) {
|
||||
throw new ExceptionHB(3, 8);
|
||||
}
|
||||
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->vaisseaux[$object] < $nombre)
|
||||
throw new ExceptionHB(3, 6);
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->vaisseaux[$object] < $nombre) {
|
||||
throw new ExceptionHB(3, 6);
|
||||
}
|
||||
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
if (!isset($lieu)) {
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey))
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
else
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if (isset($sauvLastKey)) {
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
} else {
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_vais");
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id])) {
|
||||
throw new ExceptionHB(1, 5);
|
||||
}
|
||||
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre)
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre) {
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
}
|
||||
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre)
|
||||
$this->times[$lieu] = time();
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre) {
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
|
||||
$planete->addModif("file_vais");
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
if (!$this->files[$lieu][$id][2])
|
||||
$planete->addRessources(dSpatial::metal($objet, $nombre, $planete), dSpatial::cristal($objet, $nombre, $planete), dSpatial::hydrogene($objet, $nombre, $planete), dSpatial::credits($objet, $nombre, $planete));
|
||||
if (!$this->files[$lieu][$id][2]) {
|
||||
$planete->addRessources(dSpatial::metal($objet, $nombre, $planete), dSpatial::cristal($objet, $nombre, $planete), dSpatial::hydrogene($objet, $nombre, $planete), dSpatial::credits($objet, $nombre, $planete));
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax)
|
||||
unset($this->files[$lieu][$id]);
|
||||
else
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
$planete->addModif("file_vais");
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax) {
|
||||
unset($this->files[$lieu][$id]);
|
||||
} else {
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
}
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach ($file as $keyE => $element) {
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gére les licenciments !
|
||||
if ($element[2])
|
||||
{
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->vaisseaux[$element[0]] <= 0)
|
||||
{
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_vais");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dSpatial::temps($element[0], 1, $planete) * 0.6;
|
||||
//On gére les licenciments !
|
||||
if ($element[2]) {
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->vaisseaux[$element[0]] <= 0) {
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_vais");
|
||||
} else {
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dSpatial::temps($element[0], 1, $planete) * 0.6;
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->vaisseaux[$element[0]]);
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->vaisseaux[$element[0]]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dSpatial::metal($element[0], $nbUnitee, $planete)*0.7, dSpatial::cristal($element[0], $nbUnitee, $planete)*0.7, dSpatial::hydrogene($element[0], $nbUnitee, $planete)*0.7, dSpatial::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0) {
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dSpatial::metal($element[0], $nbUnitee, $planete)*0.7, dSpatial::cristal($element[0], $nbUnitee, $planete)*0.7, dSpatial::hydrogene($element[0], $nbUnitee, $planete)*0.7, dSpatial::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
|
||||
//On retire les unités
|
||||
$planete->vaisseaux[$element[0]] -= $nbUnitee;
|
||||
//On retire les unités
|
||||
$planete->vaisseaux[$element[0]] -= $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
else
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1]) {
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
} else {
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
}
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("vaisseaux", $element[0]));
|
||||
$planete->addModif("file_vais");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("vaisseaux", $element[0]));
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
return false;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dSpatial::temps($element[0], 1, $planete);
|
||||
if ($nbUnitee < $element[1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { //Cas de la construction
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dSpatial::temps($element[0], 1, $planete);
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->vaisseaux[$element[0]] += $nbUnitee;
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0) {
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->vaisseaux[$element[0]] += $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
else
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1]) {
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
} else {
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
}
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("vaisseaux", $element[0]));
|
||||
$planete->addModif("file_vais");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("vaisseaux", $element[0]));
|
||||
$planete->addModif("file_vais");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
break;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nbUnitee < $element[1]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function printFile(SURFACE $planete, $lieu = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
public function printFile(SURFACE $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
if (isset($lieu) && $lieu != $keyF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[2])
|
||||
{
|
||||
$temps = dSpatial::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
else
|
||||
{
|
||||
$temps = dSpatial::temps($element[0], 1, $planete);
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[2]) {
|
||||
$temps = dSpatial::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems) {
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
} else {
|
||||
$temps_moins = 0;
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
} else {
|
||||
$temps = dSpatial::temps($element[0], 1, $planete);
|
||||
if ($prems) {
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
} else {
|
||||
$temps_moins = 0;
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems);
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -5,159 +5,160 @@ require_once("Class/File/interface.php");
|
|||
|
||||
class FileTechnologies extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function objectInFile($object)
|
||||
{
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($branche, $tech = null)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $file)
|
||||
{
|
||||
$c += count(array_keys($file, array($branche, $tech)));
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
public function nbObjectInFile($branche, $tech = null)
|
||||
{
|
||||
$c = 0;
|
||||
foreach ($this->files as $file) {
|
||||
$c += count(array_keys($file, array($branche, $tech)));
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($branche, $tech, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete))
|
||||
throw new ExceptionHB(4, 1);
|
||||
public function addObjet($branche, $tech, surface $planete)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete)) {
|
||||
throw new ExceptionHB(4, 1);
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une recherche de la même technologie
|
||||
if ($this->nbObjectInFile($branche, $tech) >= 1)
|
||||
throw new ExceptionHB(4, 7);
|
||||
//On vérifie qu'il n'y ait pas une recherche de la même technologie
|
||||
if ($this->nbObjectInFile($branche, $tech) >= 1) {
|
||||
throw new ExceptionHB(4, 7);
|
||||
}
|
||||
|
||||
//On vérifie que la technologie ne soit pas déjà développée
|
||||
if (dTechnologies::idToBit($tech) & $planete->technologies[$branche])
|
||||
throw new ExceptionHB(4, 7);
|
||||
//On vérifie que la technologie ne soit pas déjà développée
|
||||
if (dTechnologies::idToBit($tech) & $planete->technologies[$branche]) {
|
||||
throw new ExceptionHB(4, 7);
|
||||
}
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dTechnologies::needed(array($branche, $tech), $planete))
|
||||
throw new ExceptionHB(4, 2);
|
||||
//Validation des conditions de construction
|
||||
if (!dTechnologies::needed(array($branche, $tech), $planete)) {
|
||||
throw new ExceptionHB(4, 2);
|
||||
}
|
||||
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dTechnologies::metal($branche, $tech, $planete), dTechnologies::cristal($branche, $tech, $planete), dTechnologies::hydrogene($branche, $tech, $planete), dTechnologies::credits($branche, $tech, $planete)))
|
||||
{
|
||||
$this->files[$lieu][] = array($branche, $tech);
|
||||
$planete->addModif("file_tech");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(4, 4);
|
||||
}
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dTechnologies::metal($branche, $tech, $planete), dTechnologies::cristal($branche, $tech, $planete), dTechnologies::hydrogene($branche, $tech, $planete), dTechnologies::credits($branche, $tech, $planete))) {
|
||||
$this->files[$lieu][] = array($branche, $tech);
|
||||
$planete->addModif("file_tech");
|
||||
return true;
|
||||
} else {
|
||||
throw new ExceptionHB(4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre = 1, surface $planete)
|
||||
{
|
||||
trigger_error("Pas de démolition possible pour les technologies");
|
||||
}
|
||||
public function addDemolition($object, $nombre = 1, surface $planete)
|
||||
{
|
||||
trigger_error("Pas de démolition possible pour les technologies");
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre = 1, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(4, 5);
|
||||
public function delObjet($id, $nombre = 1, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id])) {
|
||||
throw new ExceptionHB(4, 5);
|
||||
}
|
||||
|
||||
//On récupère la branche et l'id de la technologie
|
||||
$branche = $this->files[$lieu][$id][0];
|
||||
$tech = $this->files[$lieu][$id][1];
|
||||
//On récupère la branche et l'id de la technologie
|
||||
$branche = $this->files[$lieu][$id][0];
|
||||
$tech = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler la première recherche en lice
|
||||
if ($tech == $this->findFirstKey($lieu))
|
||||
$this->times[$lieu] = time();
|
||||
//On met à jour le temps si on vient d'annuler la première recherche en lice
|
||||
if ($tech == $this->findFirstKey($lieu)) {
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
|
||||
$planete->addModif("file_tech");
|
||||
$planete->addModif("file_tech");
|
||||
|
||||
//On redonne 70% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0)
|
||||
$planete->addRessources(dTechnologies::metal($branche, $tech, $planete)*0.7, dTechnologies::cristal($branche, $tech, $planete)*0.7, dTechnologies::hydrogene($branche, $tech, $planete)*0.7, dTechnologies::credits($branche, $tech, $planete)*0.7);
|
||||
else
|
||||
$planete->addRessources(dTechnologies::metal($branche, $tech, $planete), dTechnologies::cristal($branche, $tech, $planete), dTechnologies::hydrogene($branche, $tech, $planete), dTechnologies::credits($branche, $tech, $planete));
|
||||
//On redonne 70% des ressources au joueur si c'est la première construction dans la file d'attente
|
||||
if ($id == 0) {
|
||||
$planete->addRessources(dTechnologies::metal($branche, $tech, $planete)*0.7, dTechnologies::cristal($branche, $tech, $planete)*0.7, dTechnologies::hydrogene($branche, $tech, $planete)*0.7, dTechnologies::credits($branche, $tech, $planete)*0.7);
|
||||
} else {
|
||||
$planete->addRessources(dTechnologies::metal($branche, $tech, $planete), dTechnologies::cristal($branche, $tech, $planete), dTechnologies::hydrogene($branche, $tech, $planete), dTechnologies::credits($branche, $tech, $planete));
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
//Effacement de la file
|
||||
unset($this->files[$lieu][$id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(surface $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de recherche
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
public function ready(surface $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de recherche
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
//On parcourt la file
|
||||
foreach ($file as $keyE => $element) {
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
$tempsNecessaire = dTechnologies::temps($element[0], $element[1], $planete);
|
||||
$tempsNecessaire = dTechnologies::temps($element[0], $element[1], $planete);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire)
|
||||
{
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->technologies[$element[0]] = $planete->technologies[$element[0]] | dTechnologies::idToBit($element[1]);
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($tempsEcoule >= $tempsNecessaire) {
|
||||
//On ajoute un niveau au batiment
|
||||
$planete->technologies[$element[0]] = $planete->technologies[$element[0]] | dTechnologies::idToBit($element[1]);
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$this->times[$keyF] += $tempsNecessaire;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModifUser(array("technologies", $element[0]));
|
||||
$planete->addModif("file_tech");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModifUser(array("technologies", $element[0]));
|
||||
$planete->addModif("file_tech");
|
||||
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dTechnologies::metal($element[0], $element[0], $planete), dTechnologies::cristal($element[0], $element[1], $planete), dTechnologies::hydrogene($element[0], $element[1], $planete), dTechnologies::credits($element[0], $element[1], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//On ajoute les points
|
||||
$planete->addPoints(dTechnologies::metal($element[0], $element[0], $planete), dTechnologies::cristal($element[0], $element[1], $planete), dTechnologies::hydrogene($element[0], $element[1], $planete), dTechnologies::credits($element[0], $element[1], $planete));
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function printFile(surface $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
public function printFile(surface $planete, $lieu = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
if (isset($lieu) && $lieu != $keyF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
$temps = dTechnologies::temps($element[0], $element[1], $planete);
|
||||
if ($prems)
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element) {
|
||||
$temps = dTechnologies::temps($element[0], $element[1], $planete);
|
||||
if ($prems) {
|
||||
$temps -= time() - $this->times[$keyF];
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], ceil($temps), $prems);
|
||||
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -3,307 +3,304 @@ require_once("Class/File/interface.php");
|
|||
|
||||
class FileTerrestre extends FileCommun implements File
|
||||
{
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu))
|
||||
{
|
||||
if (!empty($this->files[$lieu]))
|
||||
{
|
||||
foreach($this->files[$lieu] as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function objectInFile($object, $lieu = null)
|
||||
{
|
||||
if (isset($lieu)) {
|
||||
if (!empty($this->files[$lieu])) {
|
||||
foreach ($this->files[$lieu] as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($lieu, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[0] == $object) {
|
||||
return array($keyF, $keyE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach($this->files as $key => $file)
|
||||
{
|
||||
foreach($file as $element)
|
||||
{
|
||||
if ($element[0] == $object)
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
public function nbObjectInFile($object)
|
||||
{
|
||||
$c = 0;
|
||||
foreach ($this->files as $key => $file) {
|
||||
foreach ($file as $element) {
|
||||
if ($element[0] == $object) {
|
||||
$c += $element[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
public function addObjet($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999) {
|
||||
throw new ExceptionHB(3, 8);
|
||||
}
|
||||
|
||||
//Validation des conditions de construction
|
||||
if (!dTerrestre::needed($object, $planete))
|
||||
throw new ExceptionHB(3, 2);
|
||||
//Validation des conditions de construction
|
||||
if (!dTerrestre::needed($object, $planete)) {
|
||||
throw new ExceptionHB(3, 2);
|
||||
}
|
||||
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu))
|
||||
throw new ExceptionHB(3, 1);
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!($sauvLastKey = $this->objectInFile($object, $lieu)) && !$this->checkMaxSize($planete, $lieu)) {
|
||||
throw new ExceptionHB(3, 1);
|
||||
}
|
||||
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dTerrestre::metal($object, 1, $planete)) > 0)
|
||||
$metal = $planete->metal/$metal;
|
||||
else
|
||||
$metal = $nombre;
|
||||
if (($cristal = dTerrestre::cristal($object, 1, $planete)) > 0)
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
else
|
||||
$cristal = $nombre;
|
||||
if (($hydrogene = dTerrestre::hydrogene($object, 1, $planete)) > 0)
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
else
|
||||
$hydrogene = $nombre;
|
||||
//On tronque au maximum d'unités constructible sur la planète
|
||||
if (($metal = dTerrestre::metal($object, 1, $planete)) > 0) {
|
||||
$metal = $planete->metal/$metal;
|
||||
} else {
|
||||
$metal = $nombre;
|
||||
}
|
||||
if (($cristal = dTerrestre::cristal($object, 1, $planete)) > 0) {
|
||||
$cristal = $planete->cristal/$cristal;
|
||||
} else {
|
||||
$cristal = $nombre;
|
||||
}
|
||||
if (($hydrogene = dTerrestre::hydrogene($object, 1, $planete)) > 0) {
|
||||
$hydrogene = $planete->hydrogene/$hydrogene;
|
||||
} else {
|
||||
$hydrogene = $nombre;
|
||||
}
|
||||
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
$nombre = floor(min($nombre, $metal, $cristal, $hydrogene));
|
||||
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dTerrestre::metal($object, $nombre, $planete), dTerrestre::cristal($object, $nombre, $planete), dTerrestre::hydrogene($object, $nombre, $planete), dTerrestre::credits($object, $nombre, $planete)))
|
||||
{
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]]))
|
||||
{
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
//On vérifie qu'il y ait assez de ressources sur la planète
|
||||
if ($planete->checkAndRetireRessources(dTerrestre::metal($object, $nombre, $planete), dTerrestre::cristal($object, $nombre, $planete), dTerrestre::hydrogene($object, $nombre, $planete), dTerrestre::credits($object, $nombre, $planete))) {
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if (isset($sauvLastKey) && isset($this->files[$sauvLastKey[0]][$sauvLastKey[1]])) {
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($sauvLastKey[0]);
|
||||
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
} else {
|
||||
if (!isset($lieu)) {
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_ter");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
$planete->addModif("file_ter");
|
||||
return true;
|
||||
} else {
|
||||
throw new ExceptionHB(3, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu)))
|
||||
throw new ExceptionHB(3, 1);
|
||||
public function addDemolition($object, $nombre, surface $planete, $lieu = null)
|
||||
{
|
||||
//On vérifie que l'on ne dépasse pas la taille maximale de la file
|
||||
if (!$this->checkMaxSize($planete, $lieu) && !($sauvLastKey = $this->objectInFile($object, $lieu))) {
|
||||
throw new ExceptionHB(3, 1);
|
||||
}
|
||||
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999)
|
||||
throw new ExceptionHB(3, 8);
|
||||
//Vérification du nombre passé en entrée
|
||||
if (!is_numeric($nombre) || $nombre < 0 || $nombre > 99999) {
|
||||
throw new ExceptionHB(3, 8);
|
||||
}
|
||||
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->terrestres[$object] < $nombre)
|
||||
throw new ExceptionHB(3, 6);
|
||||
//On vérifie que le nombre d'unité actuel soit non nul
|
||||
if ($planete->terrestres[$object] < $nombre) {
|
||||
throw new ExceptionHB(3, 6);
|
||||
}
|
||||
|
||||
if (!isset($lieu))
|
||||
{
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
if (!isset($lieu)) {
|
||||
//On recherche le lieu ayant le moins de construction en cours
|
||||
$lieu = $this->findShorter();
|
||||
}
|
||||
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
//On rafraîchit le temps de la file si aucun objet n'est en file d'attente
|
||||
$this->refreshTime($lieu);
|
||||
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if(isset($sauvLastKey))
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
else
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
//Si il existe déjà l'objet en file d'attente, on l'ajoute
|
||||
if (isset($sauvLastKey)) {
|
||||
$this->files[$sauvLastKey[0]][$sauvLastKey[1]][1] += $nombre;
|
||||
} else {
|
||||
$this->files[$lieu][] = array($object, $nombre, false);
|
||||
}
|
||||
|
||||
$planete->addModif("file_ter");
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id]))
|
||||
throw new ExceptionHB(1, 5);
|
||||
public function delObjet($id, $nombre, $lieu, surface $planete)
|
||||
{
|
||||
//Vérification de l'existance de l'objet en file d'attente
|
||||
if (empty($this->files[$lieu][$id])) {
|
||||
throw new ExceptionHB(1, 5);
|
||||
}
|
||||
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre)
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
//Si $nombre est supérieur au nombre présent dans la file, on le réduit
|
||||
if ($this->files[$lieu][$id][1] < $nombre) {
|
||||
$nombre = $this->files[$lieu][$id][1];
|
||||
}
|
||||
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
//On récupère les informations disponibles
|
||||
$objet = $this->files[$lieu][$id][0];
|
||||
$nombreMax = $this->files[$lieu][$id][1];
|
||||
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre)
|
||||
$this->times[$lieu] = time();
|
||||
//On met à jour le temps si on vient d'annuler le premier groupe d'unités en lice
|
||||
if ($id == $this->findFirstKey($lieu) && $nombreMax == $nombre) {
|
||||
$this->times[$lieu] = time();
|
||||
}
|
||||
|
||||
$planete->addModif("file_ter");
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
if (!$this->files[$lieu][$id][2])
|
||||
$planete->addRessources(dTerrestre::metal($objet, $nombre, $planete), dTerrestre::cristal($objet, $nombre, $planete), dTerrestre::hydrogene($objet, $nombre, $planete), dTerrestre::credits($objet, $nombre, $planete));
|
||||
if (!$this->files[$lieu][$id][2]) {
|
||||
$planete->addRessources(dTerrestre::metal($objet, $nombre, $planete), dTerrestre::cristal($objet, $nombre, $planete), dTerrestre::hydrogene($objet, $nombre, $planete), dTerrestre::credits($objet, $nombre, $planete));
|
||||
}
|
||||
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax)
|
||||
unset($this->files[$lieu][$id]);
|
||||
else
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
$planete->addModif("file_ter");
|
||||
//Effacement de la file
|
||||
if ($nombre >= $nombreMax) {
|
||||
unset($this->files[$lieu][$id]);
|
||||
} else {
|
||||
$this->files[$lieu][$id][1] -= $nombre;
|
||||
}
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach($this->files as $keyF => $file)
|
||||
{
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0)
|
||||
continue;
|
||||
public function ready(SURFACE $planete)
|
||||
{
|
||||
//On parcourt la liste des lieux de construction
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
//On vérifie qu'il y a bien des éléments dans cette file d'attente
|
||||
if (count($file) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach($file as $keyE => $element)
|
||||
{
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
//On parcourt la liste à la recherche des unités terminées dans l'ordre
|
||||
foreach ($file as $keyE => $element) {
|
||||
//Calcul du temps écoulé depuis le dernier entraînement
|
||||
$tempsEcoule = time() - $this->times[$keyF];
|
||||
|
||||
//On gére les licenciments !
|
||||
if ($element[2])
|
||||
{
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->terrestres[$element[0]] <= 0)
|
||||
{
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_ter");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dTerrestre::temps($element[0], 1, $planete) * 0.6;
|
||||
//On gére les licenciments !
|
||||
if ($element[2]) {
|
||||
//On vérifie qu'il reste des unités du type sur la planète
|
||||
if ($planete->terrestres[$element[0]] <= 0) {
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
$planete->addModif("file_ter");
|
||||
} else {
|
||||
//Récupération de 60% du temps nécessaire
|
||||
$tempsNecessaire = dTerrestre::temps($element[0], 1, $planete) * 0.6;
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->terrestres[$element[0]]);
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1], $planete->terrestres[$element[0]]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dTerrestre::metal($element[0], $nbUnitee, $planete)*0.7, dTerrestre::cristal($element[0], $nbUnitee, $planete)*0.7, dTerrestre::hydrogene($element[0], $nbUnitee, $planete)*0.7, dTerrestre::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0) {
|
||||
//On redonne 70% des ressources de l'unité au joueur
|
||||
$planete->addRessources(dTerrestre::metal($element[0], $nbUnitee, $planete)*0.7, dTerrestre::cristal($element[0], $nbUnitee, $planete)*0.7, dTerrestre::hydrogene($element[0], $nbUnitee, $planete)*0.7, dTerrestre::credits($element[0], $nbUnitee, $planete)*0.7);
|
||||
|
||||
//On retire les unités
|
||||
$planete->terrestres[$element[0]] -= $nbUnitee;
|
||||
//On retire les unités
|
||||
$planete->terrestres[$element[0]] -= $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
else
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1]) {
|
||||
unset($this->filefiles[$keyF][$keyE]);
|
||||
} else {
|
||||
$this->file[$key][1] -= $nbUnitee;
|
||||
}
|
||||
$this->timefiles[$keyF] += $tempsNecessaire*$nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("terrestres", $element[0]));
|
||||
$planete->addModif("file_ter");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("terrestres", $element[0]));
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
return false;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //Cas de la construction
|
||||
{
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dTerrestre::temps($element[0], 1, $planete);
|
||||
if ($nbUnitee < $element[1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour cette unité, on annule toutes les suivantes
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { //Cas de la construction
|
||||
//Récupération du temps nécessaire
|
||||
$tempsNecessaire = dTerrestre::temps($element[0], 1, $planete);
|
||||
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
//Calcul du nombre d'unités maximum
|
||||
$nbUnitee = min(floor($tempsEcoule/$tempsNecessaire), $element[1]);
|
||||
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0)
|
||||
{
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->terrestres[$element[0]] += $nbUnitee;
|
||||
//Si le temps écoulé est suffisant
|
||||
if ($nbUnitee > 0) {
|
||||
//On ajoute le nombre d'unités
|
||||
$planete->terrestres[$element[0]] += $nbUnitee;
|
||||
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1])
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
else
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
//On efface l'entrée de la file et on met à jour le temps de la file
|
||||
if ($nbUnitee >= $element[1]) {
|
||||
unset($this->files[$keyF][$keyE]);
|
||||
} else {
|
||||
$this->files[$keyF][$keyE][1] -= $nbUnitee;
|
||||
}
|
||||
$this->times[$keyF] += $tempsNecessaire * $nbUnitee;
|
||||
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("terrestres", $element[0]));
|
||||
$planete->addModif("file_ter");
|
||||
//On demande la mise à jour des champs modifiés
|
||||
$planete->addModif(array("terrestres", $element[0]));
|
||||
$planete->addModif("file_ter");
|
||||
|
||||
if ($nbUnitee < $element[1])
|
||||
break;
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nbUnitee < $element[1]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Si le temps écoulé n'est pas suffisant pour ce batiment, on annule tous les suivants
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function printFile(SURFACE $planete, $lieux = NULL)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file)
|
||||
{
|
||||
if (isset($lieu) && $lieu != $keyF)
|
||||
continue;
|
||||
public function printFile(SURFACE $planete, $lieux = null)
|
||||
{
|
||||
$out = array();
|
||||
foreach ($this->files as $keyF => $file) {
|
||||
if (isset($lieu) && $lieu != $keyF) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element)
|
||||
{
|
||||
if ($element[2])
|
||||
{
|
||||
$temps = dTerrestre::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems, dTerrestre::type($element[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$temps = dTerrestre::temps($element[0], 1, $planete);
|
||||
if ($prems)
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
else
|
||||
$temps_moins = 0;
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems, dTerrestre::type($element[0]));
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
$prems = true;
|
||||
foreach ($file as $keyE => $element) {
|
||||
if ($element[2]) {
|
||||
$temps = dTerrestre::temps($element[0], 1, $planete) * 0.6;
|
||||
if ($prems) {
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
} else {
|
||||
$temps_moins = 0;
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems, dTerrestre::type($element[0]));
|
||||
} else {
|
||||
$temps = dTerrestre::temps($element[0], 1, $planete);
|
||||
if ($prems) {
|
||||
$temps_moins = time() - $this->times[$keyF];
|
||||
} else {
|
||||
$temps_moins = 0;
|
||||
}
|
||||
$out[$keyF][$keyE] = array($element[0], $element[1], $element[2], ceil($temps * $element[1] - $temps_moins), ceil($temps - $temps_moins), $prems, dTerrestre::type($element[0]));
|
||||
}
|
||||
$prems = false;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -59,22 +59,22 @@
|
|||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_SLICE', 1);
|
||||
define('SERVICES_JSON_SLICE', 1);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_STR', 2);
|
||||
define('SERVICES_JSON_IN_STR', 2);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_ARR', 3);
|
||||
define('SERVICES_JSON_IN_ARR', 3);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_OBJ', 4);
|
||||
define('SERVICES_JSON_IN_OBJ', 4);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
|
|
@ -114,48 +114,48 @@ define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
|
|||
*/
|
||||
class Services_JSON
|
||||
{
|
||||
/**
|
||||
* constructs a new JSON instance
|
||||
*
|
||||
* @param int $use object behavior flags; combine with boolean-OR
|
||||
*
|
||||
* possible values:
|
||||
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
||||
* "{...}" syntax creates associative arrays
|
||||
* instead of objects in decode().
|
||||
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
||||
* Values which can't be encoded (e.g. resources)
|
||||
* appear as NULL instead of throwing errors.
|
||||
* By default, a deeply-nested resource will
|
||||
* bubble up with an error, so all return values
|
||||
* from encode() should be checked with isError()
|
||||
*/
|
||||
function Services_JSON($use = 0)
|
||||
/**
|
||||
* constructs a new JSON instance
|
||||
*
|
||||
* @param int $use object behavior flags; combine with boolean-OR
|
||||
*
|
||||
* possible values:
|
||||
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
||||
* "{...}" syntax creates associative arrays
|
||||
* instead of objects in decode().
|
||||
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
||||
* Values which can't be encoded (e.g. resources)
|
||||
* appear as NULL instead of throwing errors.
|
||||
* By default, a deeply-nested resource will
|
||||
* bubble up with an error, so all return values
|
||||
* from encode() should be checked with isError()
|
||||
*/
|
||||
public function Services_JSON($use = 0)
|
||||
{
|
||||
$this->use = $use;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-16 char to one UTF-8 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf16 UTF-16 character
|
||||
* @return string UTF-8 character
|
||||
* @access private
|
||||
*/
|
||||
function utf162utf8($utf16)
|
||||
/**
|
||||
* convert a string from one UTF-16 char to one UTF-8 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf16 UTF-16 character
|
||||
* @return string UTF-8 character
|
||||
* @access private
|
||||
*/
|
||||
public function utf162utf8($utf16)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
||||
}
|
||||
|
||||
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
|
||||
|
||||
switch(true) {
|
||||
switch (true) {
|
||||
case ((0x7F & $bytes) == $bytes):
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
|
|
@ -179,25 +179,25 @@ class Services_JSON
|
|||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-8 char to one UTF-16 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf8 UTF-8 character
|
||||
* @return string UTF-16 character
|
||||
* @access private
|
||||
*/
|
||||
function utf82utf16($utf8)
|
||||
/**
|
||||
* convert a string from one UTF-8 char to one UTF-16 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf8 UTF-8 character
|
||||
* @return string UTF-16 character
|
||||
* @access private
|
||||
*/
|
||||
public function utf82utf16($utf8)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
||||
}
|
||||
|
||||
switch(strlen($utf8)) {
|
||||
switch (strlen($utf8)) {
|
||||
case 1:
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
|
|
@ -223,18 +223,18 @@ class Services_JSON
|
|||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* encodes an arbitrary variable into JSON format
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
function encode($var)
|
||||
/**
|
||||
* encodes an arbitrary variable into JSON format
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
public function encode($var)
|
||||
{
|
||||
switch (gettype($var)) {
|
||||
case 'boolean':
|
||||
|
|
@ -260,7 +260,6 @@ class Services_JSON
|
|||
* escaping with a slash or encoding to UTF-8 where necessary
|
||||
*/
|
||||
for ($c = 0; $c < $strlen_var; ++$c) {
|
||||
|
||||
$ord_var_c = ord($var{$c});
|
||||
|
||||
switch (true) {
|
||||
|
|
@ -304,9 +303,12 @@ class Services_JSON
|
|||
case (($ord_var_c & 0xF0) == 0xE0):
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}));
|
||||
$char = pack(
|
||||
'C*',
|
||||
$ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2})
|
||||
);
|
||||
$c += 2;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
|
|
@ -315,10 +317,13 @@ class Services_JSON
|
|||
case (($ord_var_c & 0xF8) == 0xF0):
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}));
|
||||
$char = pack(
|
||||
'C*',
|
||||
$ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3})
|
||||
);
|
||||
$c += 3;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
|
|
@ -327,11 +332,14 @@ class Services_JSON
|
|||
case (($ord_var_c & 0xFC) == 0xF8):
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}));
|
||||
$char = pack(
|
||||
'C*',
|
||||
$ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4})
|
||||
);
|
||||
$c += 4;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
|
|
@ -340,12 +348,15 @@ class Services_JSON
|
|||
case (($ord_var_c & 0xFE) == 0xFC):
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}),
|
||||
ord($var{$c + 5}));
|
||||
$char = pack(
|
||||
'C*',
|
||||
$ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}),
|
||||
ord($var{$c + 5})
|
||||
);
|
||||
$c += 5;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
|
|
@ -376,12 +387,14 @@ class Services_JSON
|
|||
|
||||
// treat as a JSON object
|
||||
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($var),
|
||||
array_values($var));
|
||||
$properties = array_map(
|
||||
array($this, 'name_value'),
|
||||
array_keys($var),
|
||||
array_values($var)
|
||||
);
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
foreach ($properties as $property) {
|
||||
if (Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
|
@ -392,8 +405,8 @@ class Services_JSON
|
|||
// treat it like a regular array
|
||||
$elements = array_map(array($this, 'encode'), $var);
|
||||
|
||||
foreach($elements as $element) {
|
||||
if(Services_JSON::isError($element)) {
|
||||
foreach ($elements as $element) {
|
||||
if (Services_JSON::isError($element)) {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
|
@ -403,12 +416,14 @@ class Services_JSON
|
|||
case 'object':
|
||||
$vars = get_object_vars($var);
|
||||
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($vars),
|
||||
array_values($vars));
|
||||
$properties = array_map(
|
||||
array($this, 'name_value'),
|
||||
array_keys($vars),
|
||||
array_values($vars)
|
||||
);
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
foreach ($properties as $property) {
|
||||
if (Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
|
@ -422,35 +437,35 @@ class Services_JSON
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* array-walking function for use in generating JSON-formatted name-value pairs
|
||||
*
|
||||
* @param string $name name of key to use
|
||||
* @param mixed $value reference to an array element to be encoded
|
||||
*
|
||||
* @return string JSON-formatted name-value pair, like '"name":value'
|
||||
* @access private
|
||||
*/
|
||||
function name_value($name, $value)
|
||||
/**
|
||||
* array-walking function for use in generating JSON-formatted name-value pairs
|
||||
*
|
||||
* @param string $name name of key to use
|
||||
* @param mixed $value reference to an array element to be encoded
|
||||
*
|
||||
* @return string JSON-formatted name-value pair, like '"name":value'
|
||||
* @access private
|
||||
*/
|
||||
public function name_value($name, $value)
|
||||
{
|
||||
$encoded_value = $this->encode($value);
|
||||
|
||||
if(Services_JSON::isError($encoded_value)) {
|
||||
if (Services_JSON::isError($encoded_value)) {
|
||||
return $encoded_value;
|
||||
}
|
||||
|
||||
return $this->encode(strval($name)) . ':' . $encoded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* reduce a string by removing leading and trailing comments and whitespace
|
||||
*
|
||||
* @param $str string string value to strip of comments and whitespace
|
||||
*
|
||||
* @return string string value stripped of comments and whitespace
|
||||
* @access private
|
||||
*/
|
||||
function reduce_string($str)
|
||||
/**
|
||||
* reduce a string by removing leading and trailing comments and whitespace
|
||||
*
|
||||
* @param $str string string value to strip of comments and whitespace
|
||||
*
|
||||
* @return string string value stripped of comments and whitespace
|
||||
* @access private
|
||||
*/
|
||||
public function reduce_string($str)
|
||||
{
|
||||
$str = preg_replace(array(
|
||||
|
||||
|
|
@ -469,19 +484,19 @@ class Services_JSON
|
|||
return trim($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* decodes a JSON string into appropriate variable
|
||||
*
|
||||
* @param string $str JSON-formatted string
|
||||
*
|
||||
* @return mixed number, boolean, string, array, or object
|
||||
* corresponding to given JSON input string.
|
||||
* See argument 1 to Services_JSON() above for object-output behavior.
|
||||
* Note that decode() always returns strings
|
||||
* in ASCII or UTF-8 format!
|
||||
* @access public
|
||||
*/
|
||||
function decode($str)
|
||||
/**
|
||||
* decodes a JSON string into appropriate variable
|
||||
*
|
||||
* @param string $str JSON-formatted string
|
||||
*
|
||||
* @return mixed number, boolean, string, array, or object
|
||||
* corresponding to given JSON input string.
|
||||
* See argument 1 to Services_JSON() above for object-output behavior.
|
||||
* Note that decode() always returns strings
|
||||
* in ASCII or UTF-8 format!
|
||||
* @access public
|
||||
*/
|
||||
public function decode($str)
|
||||
{
|
||||
$str = $this->reduce_string($str);
|
||||
|
||||
|
|
@ -509,7 +524,6 @@ class Services_JSON
|
|||
return ((float)$str == (integer)$str)
|
||||
? (integer)$str
|
||||
: (float)$str;
|
||||
|
||||
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
|
||||
// STRINGS RETURNED IN UTF-8 FORMAT
|
||||
$delim = substr($str, 0, 1);
|
||||
|
|
@ -518,7 +532,6 @@ class Services_JSON
|
|||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c < $strlen_chrs; ++$c) {
|
||||
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
$ord_chrs_c = ord($chrs{$c});
|
||||
|
||||
|
|
@ -602,11 +615,9 @@ class Services_JSON
|
|||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $utf8;
|
||||
|
||||
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
|
||||
// array, or object notation
|
||||
|
||||
|
|
@ -633,10 +644,8 @@ class Services_JSON
|
|||
if ($chrs == '') {
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} else {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -645,7 +654,6 @@ class Services_JSON
|
|||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c <= $strlen_chrs; ++$c) {
|
||||
|
||||
$top = end($stk);
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
|
||||
|
|
@ -659,7 +667,6 @@ class Services_JSON
|
|||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
// we are in an array, so just push an element onto the stack
|
||||
array_push($arr, $this->decode($slice));
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
// we are in an object, so figure
|
||||
// out the property name and set an
|
||||
|
|
@ -688,14 +695,11 @@ class Services_JSON
|
|||
$obj->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
|
||||
// found a quote, and we are not inside a string
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
|
||||
//print("Found start of string at {$c}\n");
|
||||
|
||||
//print("Found start of string at {$c}\n");
|
||||
} elseif (($chrs{$c} == $top['delim']) &&
|
||||
($top['what'] == SERVICES_JSON_IN_STR) &&
|
||||
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
|
||||
|
|
@ -703,59 +707,49 @@ class Services_JSON
|
|||
// we know that it's not escaped becase there is _not_ an
|
||||
// odd number of backslashes at the end of the string so far
|
||||
array_pop($stk);
|
||||
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
||||
|
||||
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
||||
} elseif (($chrs{$c} == '[') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-bracket, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of array at {$c}\n");
|
||||
|
||||
//print("Found start of array at {$c}\n");
|
||||
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
|
||||
// found a right-bracket, and we're in an array
|
||||
array_pop($stk);
|
||||
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
} elseif (($chrs{$c} == '{') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-brace, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of object at {$c}\n");
|
||||
|
||||
//print("Found start of object at {$c}\n");
|
||||
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
|
||||
// found a right-brace, and we're in an object
|
||||
array_pop($stk);
|
||||
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
} elseif (($substr_chrs_c_2 == '/*') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a comment start, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
|
||||
$c++;
|
||||
//print("Found start of comment at {$c}\n");
|
||||
|
||||
//print("Found start of comment at {$c}\n");
|
||||
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
|
||||
// found a comment end, and we're in one now
|
||||
array_pop($stk);
|
||||
$c++;
|
||||
|
||||
for ($i = $top['where']; $i <= $c; ++$i)
|
||||
for ($i = $top['where']; $i <= $c; ++$i) {
|
||||
$chrs = substr_replace($chrs, ' ', $i, 1);
|
||||
}
|
||||
|
||||
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -763,7 +757,7 @@ class Services_JSON
|
|||
/**
|
||||
* @todo Ultimately, this should just call PEAR::isError()
|
||||
*/
|
||||
function isError($data, $code = null)
|
||||
public function isError($data, $code = null)
|
||||
{
|
||||
if (class_exists('pear')) {
|
||||
return PEAR::isError($data, $code);
|
||||
|
|
@ -777,16 +771,18 @@ class Services_JSON
|
|||
}
|
||||
|
||||
if (class_exists('PEAR_Error')) {
|
||||
|
||||
class Services_JSON_Error extends PEAR_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
public function Services_JSON_Error(
|
||||
$message = 'unknown error',
|
||||
$code = null,
|
||||
$mode = null,
|
||||
$options = null,
|
||||
$userinfo = null
|
||||
) {
|
||||
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
|
|
@ -794,13 +790,13 @@ if (class_exists('PEAR_Error')) {
|
|||
*/
|
||||
class Services_JSON_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
|
||||
public function Services_JSON_Error(
|
||||
$message = 'unknown error',
|
||||
$code = null,
|
||||
$mode = null,
|
||||
$options = null,
|
||||
$userinfo = null
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -8,133 +8,149 @@
|
|||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class Alliance extends SURFACE{
|
||||
var $id,
|
||||
$race,
|
||||
$fondateur,
|
||||
$sante,
|
||||
$nom,
|
||||
$tag,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$nom_asteroide,
|
||||
$image_asteroide,
|
||||
$debris_met,
|
||||
$debris_cri,
|
||||
$credits,
|
||||
$metal,
|
||||
$cristal,
|
||||
$hydrogene;
|
||||
class Alliance extends SURFACE
|
||||
{
|
||||
public $id;
|
||||
public $race;
|
||||
public $fondateur;
|
||||
public $sante;
|
||||
public $nom;
|
||||
public $tag;
|
||||
public $galaxie;
|
||||
public $ss;
|
||||
public $nom_asteroide;
|
||||
public $image_asteroide;
|
||||
public $debris_met;
|
||||
public $debris_cri;
|
||||
public $credits;
|
||||
public $metal;
|
||||
public $cristal;
|
||||
public $hydrogene;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de l'alliance à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function Alliance($id = 0){
|
||||
if (!empty($id)) {
|
||||
global $var___db, $config, $table_alliances;
|
||||
global $alli_batimentVAR, $spatialVAR;
|
||||
$bdd = new bdd();
|
||||
$bdd->connexion();
|
||||
$bdd->escape($id);
|
||||
$alli = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($alli)) {
|
||||
$this->id = $alli["id"];
|
||||
$this->race = $alli["race"];
|
||||
$this->fondateur = $alli["fondateur"];
|
||||
$this->sante = $alli["sante"];
|
||||
$this->nom = $alli["nom"];
|
||||
$this->tag = $alli["tag"];
|
||||
$this->galaxie = $alli["galaxie"];
|
||||
$this->ss = $alli["ss"];
|
||||
$this->position = $alli["wing"];
|
||||
$this->nom_asteroide = $alli["nom_asteroide"];
|
||||
$this->image_asteroide = $alli["image_asteroide"];
|
||||
$this->debris_met = $alli["debris_met"];
|
||||
$this->debris_cri = $alli["debris_cri"];
|
||||
$this->credits = $alli["credits"];
|
||||
$this->metal = $alli["metal"];
|
||||
$this->cristal = $alli["cristal"];
|
||||
$this->hydrogene = $alli["hydrogene"];
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de l'alliance à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function Alliance($id = 0)
|
||||
{
|
||||
if (!empty($id)) {
|
||||
global $var___db, $config, $table_alliances;
|
||||
global $alli_batimentVAR, $spatialVAR;
|
||||
$bdd = new bdd();
|
||||
$bdd->connexion();
|
||||
$bdd->escape($id);
|
||||
$alli = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($alli)) {
|
||||
$this->id = $alli["id"];
|
||||
$this->race = $alli["race"];
|
||||
$this->fondateur = $alli["fondateur"];
|
||||
$this->sante = $alli["sante"];
|
||||
$this->nom = $alli["nom"];
|
||||
$this->tag = $alli["tag"];
|
||||
$this->galaxie = $alli["galaxie"];
|
||||
$this->ss = $alli["ss"];
|
||||
$this->position = $alli["wing"];
|
||||
$this->nom_asteroide = $alli["nom_asteroide"];
|
||||
$this->image_asteroide = $alli["image_asteroide"];
|
||||
$this->debris_met = $alli["debris_met"];
|
||||
$this->debris_cri = $alli["debris_cri"];
|
||||
$this->credits = $alli["credits"];
|
||||
$this->metal = $alli["metal"];
|
||||
$this->cristal = $alli["cristal"];
|
||||
$this->hydrogene = $alli["hydrogene"];
|
||||
|
||||
foreach($alli_batimentVAR as $bat){
|
||||
$this->batiments[] = $alli[$bat];
|
||||
}
|
||||
$this->file_bat = unserialize($alli["file_bat"]);
|
||||
foreach ($alli_batimentVAR as $bat) {
|
||||
$this->batiments[] = $alli[$bat];
|
||||
}
|
||||
$this->file_bat = unserialize($alli["file_bat"]);
|
||||
|
||||
foreach($spatialVAR as $vais){
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
}
|
||||
$this->file_vais = unserialize($alli["file_vais"]);
|
||||
foreach ($spatialVAR as $vais) {
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
}
|
||||
$this->file_vais = unserialize($alli["file_vais"]);
|
||||
|
||||
$this->actualiser();
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->actualiser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualise les ressources de la planète en fonction de la production et termine les files d'attentes.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function actualiser($actuFile = true){
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile) {
|
||||
$this->file_pret("alli_batiments");
|
||||
$this->file_pret("vaisseaux");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Actualise les ressources de la planète en fonction de la production et termine les files d'attentes.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function actualiser($actuFile = true)
|
||||
{
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile) {
|
||||
$this->file_pret("alli_batiments");
|
||||
$this->file_pret("vaisseaux");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct(){
|
||||
global $var___db, $config, $table_alliances;
|
||||
$nb = count($this->modif);
|
||||
$out = array();
|
||||
$bdd = new bdd();
|
||||
$bdd->connexion();
|
||||
for($i = 0; $i < $nb; $i++){
|
||||
if (!is_array($this->{$this->modif[$i]})) {
|
||||
$bdd->escape($this->{$this->modif[$i]});
|
||||
if (is_int($this->{$this->modif[$i]}) || is_float($this->{$this->modif[$i]})) $out[] .= $this->modif[$i]." = ".$this->{$this->modif[$i]};
|
||||
else $out[] .= $this->modif[$i]." = '".$this->{$this->modif[$i]}."'";
|
||||
}
|
||||
else {
|
||||
if (preg_match('#file#', $this->modif[$i])) {
|
||||
$prep = serialize($this->{$this->modif[$i]});
|
||||
$bdd->escape($prep);
|
||||
$out[] .= $this->modif[$i]." = '$prep'";
|
||||
}
|
||||
else {
|
||||
if ($this->modif[$i] == "batiments") $calc = "batiment";
|
||||
elseif ($this->modif[$i] == "alli_batiments") $calc = "alli_batiment";
|
||||
elseif ($this->modif[$i] == "technologies") $calc = "technolo";
|
||||
elseif ($this->modif[$i] == "casernes")$calc = "casernen";
|
||||
elseif ($this->modif[$i] == "terrestres") $calc = "nomterrn";
|
||||
elseif ($this->modif[$i] == "vaisseaux") $calc = "nomvaisn";
|
||||
elseif ($this->modif[$i] == "coeff_bat") $calc = "coeff";
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
global $var___db, $config, $table_alliances;
|
||||
$nb = count($this->modif);
|
||||
$out = array();
|
||||
$bdd = new bdd();
|
||||
$bdd->connexion();
|
||||
for ($i = 0; $i < $nb; $i++) {
|
||||
if (!is_array($this->{$this->modif[$i]})) {
|
||||
$bdd->escape($this->{$this->modif[$i]});
|
||||
if (is_int($this->{$this->modif[$i]}) || is_float($this->{$this->modif[$i]})) {
|
||||
$out[] .= $this->modif[$i]." = ".$this->{$this->modif[$i]};
|
||||
} else {
|
||||
$out[] .= $this->modif[$i]." = '".$this->{$this->modif[$i]}."'";
|
||||
}
|
||||
} else {
|
||||
if (preg_match('#file#', $this->modif[$i])) {
|
||||
$prep = serialize($this->{$this->modif[$i]});
|
||||
$bdd->escape($prep);
|
||||
$out[] .= $this->modif[$i]." = '$prep'";
|
||||
} else {
|
||||
if ($this->modif[$i] == "batiments") {
|
||||
$calc = "batiment";
|
||||
} elseif ($this->modif[$i] == "alli_batiments") {
|
||||
$calc = "alli_batiment";
|
||||
} elseif ($this->modif[$i] == "technologies") {
|
||||
$calc = "technolo";
|
||||
} elseif ($this->modif[$i] == "casernes") {
|
||||
$calc = "casernen";
|
||||
} elseif ($this->modif[$i] == "terrestres") {
|
||||
$calc = "nomterrn";
|
||||
} elseif ($this->modif[$i] == "vaisseaux") {
|
||||
$calc = "nomvaisn";
|
||||
} elseif ($this->modif[$i] == "coeff_bat") {
|
||||
$calc = "coeff";
|
||||
}
|
||||
|
||||
if (!isset(${$calc.'VAR'})) global ${$calc.'VAR'};
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
|
||||
$nombr = count(${$calc.'VAR'});
|
||||
for($j = 0; $j < $nombr; $j++){
|
||||
$bdd->escape($this->{$this->modif[$i]}[$j]);
|
||||
$out[] .= ${$calc.'VAR'}[$j]." = ".$this->{$this->modif[$i]}[$j]."";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out)) $plan = $bdd->unique_query("UPDATE $table_alliances SET ".implode(', ', $out)." WHERE id = ".$this->id.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
$nombr = count(${$calc.'VAR'});
|
||||
for ($j = 0; $j < $nombr; $j++) {
|
||||
$bdd->escape($this->{$this->modif[$i]}[$j]);
|
||||
$out[] .= ${$calc.'VAR'}[$j]." = ".$this->{$this->modif[$i]}[$j]."";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out)) {
|
||||
$plan = $bdd->unique_query("UPDATE $table_alliances SET ".implode(', ', $out)." WHERE id = ".$this->id.";");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -11,375 +11,359 @@ include_once("Class/surface.php");
|
|||
***************************************************************************/
|
||||
class Asteroide extends Surface
|
||||
{
|
||||
var $fondateur,
|
||||
$sante,
|
||||
$nom_alliance,
|
||||
$tag,
|
||||
$wing,
|
||||
$nom_asteroide,
|
||||
$image_asteroide,
|
||||
$position = 5,
|
||||
$cap = 123456789,
|
||||
$credits_alliance,
|
||||
$points_alliance,
|
||||
$url_chat,
|
||||
$url_forum,
|
||||
$details = array();
|
||||
public $fondateur;
|
||||
public $sante;
|
||||
public $nom_alliance;
|
||||
public $tag;
|
||||
public $wing;
|
||||
public $nom_asteroide;
|
||||
public $image_asteroide;
|
||||
public $position = 5;
|
||||
public $cap = 123456789;
|
||||
public $credits_alliance;
|
||||
public $points_alliance;
|
||||
public $url_chat;
|
||||
public $url_forum;
|
||||
public $details = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id = 0)
|
||||
{
|
||||
if (!empty($id)) {
|
||||
global $table_alliances, $SESS;
|
||||
global $alli_batimentsVAR, $spatialVAR;
|
||||
$bdd = new BDD();
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($id = 0)
|
||||
{
|
||||
if (!empty($id)) {
|
||||
global $table_alliances, $SESS;
|
||||
global $alli_batimentsVAR, $spatialVAR;
|
||||
$bdd = new BDD();
|
||||
|
||||
//On traite le cas où l'on envoie les coordonnées
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):?[Aa]?\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
die('Erreur #04 : Format de recherche d\'asteroide incorrect !');
|
||||
//On traite le cas où l'on envoie les coordonnées
|
||||
if (is_numeric($id)) {
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
} elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):?[Aa]?\]?$#', $id, $position)) {
|
||||
$plan = $bdd->unique_query("SELECT * FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$bdd->deconnexion();
|
||||
} else {
|
||||
die('Erreur #04 : Format de recherche d\'asteroide incorrect !');
|
||||
}
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
$this->id = $plan["id"];
|
||||
parent::User($SESS->values['id']); //On utilise le numéro d'utilisateur enregistré en session
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->points_alliance = @$plan["points_alliance"];
|
||||
$this->nom_asteroide = $plan["nom_asteroide"];
|
||||
$this->image = $this->image_asteroide = $plan["image_asteroide"];
|
||||
$this->debris_met = $plan["debris_met"];
|
||||
$this->debris_cri = $plan["debris_cri"];
|
||||
$this->metal = $plan["metal"];
|
||||
$this->cristal = $plan["cristal"];
|
||||
$this->hydrogene = $plan["hydrogene"];
|
||||
$this->credits_alliance = $plan["credits_alliance"];
|
||||
$this->fondateur = $plan["fondateur"];
|
||||
$this->nom_alliance = $plan["nom_alliance"];
|
||||
$this->wing = $plan["wing"];
|
||||
$this->tag = $plan["tag"];
|
||||
$this->url_forum = $plan["url_forum"];
|
||||
$this->url_chat = $plan["url_chat"];
|
||||
if (!empty($plan)) {
|
||||
$this->id = $plan["id"];
|
||||
parent::User($SESS->values['id']); //On utilise le numéro d'utilisateur enregistré en session
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->points_alliance = @$plan["points_alliance"];
|
||||
$this->nom_asteroide = $plan["nom_asteroide"];
|
||||
$this->image = $this->image_asteroide = $plan["image_asteroide"];
|
||||
$this->debris_met = $plan["debris_met"];
|
||||
$this->debris_cri = $plan["debris_cri"];
|
||||
$this->metal = $plan["metal"];
|
||||
$this->cristal = $plan["cristal"];
|
||||
$this->hydrogene = $plan["hydrogene"];
|
||||
$this->credits_alliance = $plan["credits_alliance"];
|
||||
$this->fondateur = $plan["fondateur"];
|
||||
$this->nom_alliance = $plan["nom_alliance"];
|
||||
$this->wing = $plan["wing"];
|
||||
$this->tag = $plan["tag"];
|
||||
$this->url_forum = $plan["url_forum"];
|
||||
$this->url_chat = $plan["url_chat"];
|
||||
|
||||
foreach($alli_batimentsVAR as $bat)
|
||||
$this->batiments[] = $plan[$bat];
|
||||
if (!empty($plan["file_bat"]))
|
||||
$this->file_bat = unserialize($plan["file_bat"]);
|
||||
else
|
||||
$this->file_bat = new FileAlliancesBatiments();
|
||||
foreach ($alli_batimentsVAR as $bat) {
|
||||
$this->batiments[] = $plan[$bat];
|
||||
}
|
||||
if (!empty($plan["file_bat"])) {
|
||||
$this->file_bat = unserialize($plan["file_bat"]);
|
||||
} else {
|
||||
$this->file_bat = new FileAlliancesBatiments();
|
||||
}
|
||||
|
||||
foreach($spatialVAR as $vais)
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
if (!empty($plan["file_vais"]))
|
||||
$this->file_vais = unserialize($plan["file_vais"]);
|
||||
else
|
||||
$this->file_vais = new FileSpatial('vaisseaux');
|
||||
foreach ($spatialVAR as $vais) {
|
||||
$this->vaisseaux[] = $plan[$vais];
|
||||
}
|
||||
if (!empty($plan["file_vais"])) {
|
||||
$this->file_vais = unserialize($plan["file_vais"]);
|
||||
} else {
|
||||
$this->file_vais = new FileSpatial('vaisseaux');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public function loadDetails()
|
||||
{
|
||||
global $table_alliances, $table_user;
|
||||
$bdd = new bdd();
|
||||
$this->details = array_merge($bdd->unique_query("SELECT presentation, message_inscription, texte_interne, port_chat, chan_chat, image, etat_inscription, defcon, defcon_txt FROM $table_alliances WHERE id = ".$this->id.";"), $bdd->unique_query("SELECT COUNT(id) AS nb_membres FROM $table_user WHERE id_alliance = ".$this->id.";"));
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
function loadDetails()
|
||||
{
|
||||
global $table_alliances, $table_user;
|
||||
$bdd = new bdd();
|
||||
$this->details = array_merge($bdd->unique_query("SELECT presentation, message_inscription, texte_interne, port_chat, chan_chat, image, etat_inscription, defcon, defcon_txt FROM $table_alliances WHERE id = ".$this->id.";"), $bdd->unique_query("SELECT COUNT(id) AS nb_membres FROM $table_user WHERE id_alliance = ".$this->id.";"));
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
public function actualiser($actuFile = true, $first = false)
|
||||
{
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile) {
|
||||
$this->file_bat->ready($this);
|
||||
$this->file_vais->ready($this);
|
||||
}
|
||||
}
|
||||
|
||||
function actualiser($actuFile = true, $first = false)
|
||||
{
|
||||
//Actualisation des files d'attentes
|
||||
if ($actuFile)
|
||||
{
|
||||
$this->file_bat->ready($this);
|
||||
$this->file_vais->ready($this);
|
||||
}
|
||||
}
|
||||
public function checkAndRetireRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
if ($this->metal >= $metal && $this->cristal >= $cristal && $this->hydrogene >= $hydrogene && $this->credits_alliance >= $credits) {
|
||||
$this->metal -= $metal;
|
||||
$this->cristal -= $cristal;
|
||||
$this->hydrogene -= $hydrogene;
|
||||
$this->credits -= $credits;
|
||||
|
||||
function checkAndRetireRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
if ($this->metal >= $metal && $this->cristal >= $cristal && $this->hydrogene >= $hydrogene && $this->credits_alliance >= $credits)
|
||||
{
|
||||
$this->metal -= $metal;
|
||||
$this->cristal -= $cristal;
|
||||
$this->hydrogene -= $hydrogene;
|
||||
$this->credits -= $credits;
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public function addRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
$perte = 0;
|
||||
|
||||
function addRessources($metal, $cristal, $hydrogene, $credits)
|
||||
{
|
||||
$perte = 0;
|
||||
$this->metal += $metal;
|
||||
if ($this->metal > $this->cap) {
|
||||
$perte += $this->metal - $this->cap;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
|
||||
$this->metal += $metal;
|
||||
if ($this->metal > $this->cap)
|
||||
{
|
||||
$perte += $this->metal - $this->cap;
|
||||
$this->metal = $this->cap;
|
||||
}
|
||||
$this->cristal += $cristal;
|
||||
if ($this->cristal > $this->cap) {
|
||||
$perte += $this->cristal - $this->cap;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
|
||||
$this->cristal += $cristal;
|
||||
if ($this->cristal > $this->cap)
|
||||
{
|
||||
$perte += $this->cristal - $this->cap;
|
||||
$this->cristal = $this->cap;
|
||||
}
|
||||
$this->hydrogene += $hydrogene;
|
||||
if ($this->hydrogene > $this->cap) {
|
||||
$perte += $this->hydrogene - $this->cap;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
|
||||
$this->hydrogene += $hydrogene;
|
||||
if ($this->hydrogene > $this->cap)
|
||||
{
|
||||
$perte += $this->hydrogene - $this->cap;
|
||||
$this->hydrogene = $this->cap;
|
||||
}
|
||||
$this->hydrogecredits_alliancene += $credits;
|
||||
|
||||
$this->hydrogecredits_alliancene += $credits;
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
$this->addModif("force");
|
||||
$this->addModif("credits_alliance");
|
||||
return $perte;
|
||||
}
|
||||
|
||||
return $perte;
|
||||
}
|
||||
public function addCreditsAlliance($credits)
|
||||
{
|
||||
$this->credits_alliance += $credits;
|
||||
$this->addModif("credits_alliance");
|
||||
|
||||
function addCreditsAlliance($credits)
|
||||
{
|
||||
$this->credits_alliance += $credits;
|
||||
$this->addModif("credits_alliance");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
public function addPoints($metal, $cristal, $hydrogene, $credits = 0, $demolition = false)
|
||||
{
|
||||
global $table_bourse_ressources;
|
||||
//On charge les 3 valeurs boursières
|
||||
$bdd = new BDD();
|
||||
$bourse = $bdd->query("SELECT dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
function addPoints($metal, $cristal, $hydrogene, $credits = 0, $demolition = false)
|
||||
{
|
||||
global $table_bourse_ressources;
|
||||
//On charge les 3 valeurs boursières
|
||||
$bdd = new BDD();
|
||||
$bourse = $bdd->query("SELECT dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($credits)) {
|
||||
//TODO Equivalence non prouvée entre $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7); et $credits/bourse_calcPrixBase($bourse[0]["dispo"], 1) * 0.7; dans le but de ne donner que 70% des points
|
||||
$metal += $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7);
|
||||
$cristal += $credits/bourse_calcPrixBase($bourse[1]["dispo"], 0.7);
|
||||
$hydrogene += $credits/bourse_calcPrixBase($bourse[2]["dispo"], 0.7);
|
||||
}
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
//TODO Equivalence non prouvée entre $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7); et $credits/bourse_calcPrixBase($bourse[0]["dispo"], 1) * 0.7; dans le but de ne donner que 70% des points
|
||||
$metal += $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7);
|
||||
$cristal += $credits/bourse_calcPrixBase($bourse[1]["dispo"], 0.7);
|
||||
$hydrogene += $credits/bourse_calcPrixBase($bourse[2]["dispo"], 0.7);
|
||||
}
|
||||
$points = bourse_calcPrixBase($bourse[0]["dispo"], $metal);
|
||||
$points += bourse_calcPrixBase($bourse[1]["dispo"], $cristal);
|
||||
$points += bourse_calcPrixBase($bourse[2]["dispo"], $hydrogene);
|
||||
|
||||
$points = bourse_calcPrixBase($bourse[0]["dispo"], $metal);
|
||||
$points += bourse_calcPrixBase($bourse[1]["dispo"], $cristal);
|
||||
$points += bourse_calcPrixBase($bourse[2]["dispo"], $hydrogene);
|
||||
if ($demolition) {
|
||||
$this->points_alliance -= intval($points);
|
||||
} else {
|
||||
$this->points_alliance += intval($points);
|
||||
}
|
||||
|
||||
if ($demolition)
|
||||
$this->points_alliance -= intval($points);
|
||||
else
|
||||
$this->points_alliance += intval($points);
|
||||
$this->addModif("points_alliance");
|
||||
}
|
||||
|
||||
$this->addModif("points_alliance");
|
||||
}
|
||||
public function creer($fondateur, $mere = false)
|
||||
{
|
||||
global $VAR, $table_alliances_creation;
|
||||
|
||||
function creer($fondateur, $mere = false)
|
||||
{
|
||||
global $VAR, $table_alliances_creation;
|
||||
$bdd = new BDD();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$fondateur->id_user." LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$bdd = new BDD();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$fondateur->id_user." LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
//On vérifie que l'alliance n'a pas déjà été créée
|
||||
if (empty($alliance)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//On vérifie que l'alliance n'a pas déjà été créée
|
||||
if (empty($alliance))
|
||||
return 1;
|
||||
//Définition des paramètres de l'utilisateur pour l'astéroide
|
||||
$this->fondateur = $alliance["fondateur"];
|
||||
$this->race = $fondateur->race;
|
||||
|
||||
//Définition des paramètres de l'utilisateur pour l'astéroide
|
||||
$this->fondateur = $alliance["fondateur"];
|
||||
$this->race = $fondateur->race;
|
||||
//Génération du nombre de case et de l'image en fonction de la position dans le système
|
||||
$this->sante = 1;
|
||||
$this->nom_alliance = $alliance["nom_alliance"];
|
||||
$this->tag = $alliance["tag"];
|
||||
$this->nom_asteroide = $alliance["nom_alliance"];
|
||||
$this->image_asteroide = mt_rand(1, 3);
|
||||
|
||||
//Génération du nombre de case et de l'image en fonction de la position dans le système
|
||||
$this->sante = 1;
|
||||
$this->nom_alliance = $alliance["nom_alliance"];
|
||||
$this->tag = $alliance["tag"];
|
||||
$this->nom_asteroide = $alliance["nom_alliance"];
|
||||
$this->image_asteroide = mt_rand(1,3);
|
||||
$this->modif = array("fondateur", "race", "nom_alliance", "galaxie", "ss", "tag", "nom_asteroide", "image_asteroide");
|
||||
}
|
||||
|
||||
$this->modif = array("fondateur", "race", "nom_alliance", "galaxie", "ss", "tag", "nom_asteroide", "image_asteroide");
|
||||
}
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (empty($this->ss) || empty($this->fondateur)) {
|
||||
return;
|
||||
}
|
||||
if (DEBUG) {
|
||||
var_dump($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
if (empty($this->ss) || empty($this->fondateur))
|
||||
return;
|
||||
if (DEBUG)
|
||||
var_dump($this);
|
||||
global $table_alliances;
|
||||
if (empty($this->id)) {
|
||||
$outNomChamps = array();
|
||||
$outValeurs = array();
|
||||
$bdd = new BDD();
|
||||
foreach ($this->modif as $modif) {
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif)) {
|
||||
if ($modif[0] == "batiments") {
|
||||
$calc = dDonnees::nameVAR("alli_batiments");
|
||||
} else {
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
}
|
||||
|
||||
global $table_alliances;
|
||||
if (empty($this->id))
|
||||
{
|
||||
$outNomChamps = array(); $outValeurs = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
if ($modif[0] == "batiments")
|
||||
$calc = dDonnees::nameVAR("alli_batiments");
|
||||
else
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$modif[1]];
|
||||
$outValeurs[] = $this->{$modif[0]}[$modif[1]];
|
||||
} elseif ($modif == "force") {
|
||||
$outNomChamps[] = "metal";
|
||||
$outNomChamps[] = "cristal";
|
||||
$outNomChamps[] = "hydrogene";
|
||||
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$modif[1]];
|
||||
$outValeurs[] = $this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
{
|
||||
$outNomChamps[] = "metal";
|
||||
$outNomChamps[] = "cristal";
|
||||
$outNomChamps[] = "hydrogene";
|
||||
$outValeurs[] = $this->metal;
|
||||
$outValeurs[] = $this->cristal;
|
||||
$outValeurs[] = $this->hydrogene;
|
||||
} elseif (!is_array($this->{$modif})) {
|
||||
$bdd->escape($this->{$modif});
|
||||
$outNomChamps[] = $modif;
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif})) {
|
||||
$outValeurs[] = $this->{$modif};
|
||||
} else {
|
||||
$outValeurs[] = "'".$this->{$modif}."'";
|
||||
}
|
||||
} else {
|
||||
if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments") {
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$outNomChamps[] = $modif;
|
||||
$outValeurs[] = "'$prep'";
|
||||
} else {
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
$outValeurs[] = $this->metal;
|
||||
$outValeurs[] = $this->cristal;
|
||||
$outValeurs[] = $this->hydrogene;
|
||||
}
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$outNomChamps[] = $modif;
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$outValeurs[] = $this->{$modif};
|
||||
else
|
||||
$outValeurs[] = "'".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($this->{$modif}) && $modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$outNomChamps[] = $modif;
|
||||
$outValeurs[] = "'$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
foreach ($this->{$modif} as $j => $value) {
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$j];
|
||||
$outValeurs[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//On supprime le lien de construction de l'alliance
|
||||
$bdd->query("DELETE FROM $table_alliances_creation WHERE fondateur = ".$this->fondateur.";");
|
||||
if ($bdd->affected() != 1) {
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : fondateur = ".$this->fondateur, 2);
|
||||
}
|
||||
//On ajout l'astéroide
|
||||
$bdd->query("INSERT INTO $table_alliances (".implode(', ', $outNomChamps).") VALUES (".implode(', ', $outValeurs).");");
|
||||
if ($bdd->affected() != 1) {
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : outNomChamps = ".serialize($outNomChamps)." ; outValeurs = ".serialize($outValeurs), 2);
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
} else {
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach ($this->modif as $modif) {
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif)) {
|
||||
if ($modif[0] == "batiments") {
|
||||
$calc = dDonnees::nameVAR("alli_batiments");
|
||||
} else {
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
}
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
{
|
||||
$outNomChamps[] = ${$calc.'VAR'}[$j];
|
||||
$outValeurs[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//On supprime le lien de construction de l'alliance
|
||||
$bdd->query("DELETE FROM $table_alliances_creation WHERE fondateur = ".$this->fondateur.";");
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : fondateur = ".$this->fondateur, 2);
|
||||
//On ajout l'astéroide
|
||||
$bdd->query("INSERT INTO $table_alliances (".implode(', ', $outNomChamps).") VALUES (".implode(', ', $outValeurs).");");
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : outNomChamps = ".serialize($outNomChamps)." ; outValeurs = ".serialize($outValeurs), 2);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modif as $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
if ($modif[0] == "batiments")
|
||||
$calc = dDonnees::nameVAR("alli_batiments");
|
||||
else
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
if (empty(${$calc.'VAR'})) {
|
||||
trigger_error('Impossible de trouver les données pour '.$modif[0], E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
if (empty(${$calc.'VAR'}))
|
||||
trigger_error('Impossible de trouver les données pour '.$modif[0], E_USER_ERROR);
|
||||
$out[] = ${$calc.'VAR'}[$modif[1]]." = ".$this->{$modif[0]}[$modif[1]];
|
||||
} elseif ($modif == "force") {
|
||||
$out[] = "metal = ".$this->metal;
|
||||
$out[] = "cristal = ".$this->cristal;
|
||||
$out[] = "hydrogene = ".$this->hydrogene;
|
||||
} elseif (!is_array($this->{$modif}) && !is_object($this->{$modif})) {
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif})) {
|
||||
$out[] = $modif." = ".$this->{$modif};
|
||||
} else {
|
||||
$out[] = $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
} else {
|
||||
if ($modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments") {
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $modif." = '$prep'";
|
||||
} else {
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
$out[] = ${$calc.'VAR'}[$modif[1]]." = ".$this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
{
|
||||
$out[] = "metal = ".$this->metal;
|
||||
$out[] = "cristal = ".$this->cristal;
|
||||
$out[] = "hydrogene = ".$this->hydrogene;
|
||||
}
|
||||
elseif (!is_array($this->{$modif}) && !is_object($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out[] = $modif." = ".$this->{$modif};
|
||||
else
|
||||
$out[] = $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $modif." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
foreach ($this->{$modif} as $j => $value) {
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out)) {
|
||||
$sql = "UPDATE $table_alliances SET ".implode(', ', $out)." WHERE id = ".$this->id.";";
|
||||
if (DEBUG) {
|
||||
echo '<br /><br />'.$sql;
|
||||
}
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1) {
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out), 2);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_alliances SET ".implode(', ', $out)." WHERE id = ".$this->id.";";
|
||||
if (DEBUG)
|
||||
echo '<br /><br />'.$sql;
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out), 2);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
parent::__destruct();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -6,37 +6,36 @@
|
|||
*/
|
||||
class Attaques
|
||||
{
|
||||
var $groupes = array();
|
||||
public $groupes = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
public function addGroupe($groupe)
|
||||
{
|
||||
$this->groupes[] = $groupe;
|
||||
}
|
||||
|
||||
function addGroupe($groupe)
|
||||
{
|
||||
$this->groupes[] = $groupe;
|
||||
}
|
||||
public function checkAllGroupes()
|
||||
{
|
||||
foreach ($groupes as $key => $groupe) {
|
||||
$this->checkGroupe($key);
|
||||
}
|
||||
}
|
||||
|
||||
function checkAllGroupes()
|
||||
{
|
||||
foreach ($groupes as $key => $groupe)
|
||||
$this->checkGroupe($key);
|
||||
}
|
||||
|
||||
function checkGroupe($id)
|
||||
{
|
||||
if (is_a($this->groupes[$id], "Groupe"))
|
||||
{
|
||||
if ($this->groupes[$id]->)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
$groupes[$id]->
|
||||
}
|
||||
public function checkGroupe($id)
|
||||
{
|
||||
// if (is_a($this->groupes[$id], "Groupe"))
|
||||
// {
|
||||
// if ($this->groupes[$id]->)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// $groupes[$id]->
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -4,187 +4,224 @@
|
|||
* Dernière édition le 21 Juillet 2008
|
||||
* Copyright Halo-Battle Tous droits réservés
|
||||
*/
|
||||
class Bourse{
|
||||
var $bd;
|
||||
class Bourse
|
||||
{
|
||||
public $bd;
|
||||
|
||||
var $id;
|
||||
var $nom;
|
||||
var $taxeA = 1.1;
|
||||
var $taxeV = 1.5;
|
||||
var $metal;
|
||||
var $cristal;
|
||||
var $actionsUser;
|
||||
var $user;
|
||||
public $id;
|
||||
public $nom;
|
||||
public $taxeA = 1.1;
|
||||
public $taxeV = 1.5;
|
||||
public $metal;
|
||||
public $cristal;
|
||||
public $actionsUser;
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param String $nom Nom de l'action
|
||||
* @param int $user ID du joueur à charger automatiquement
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function Bourse($nom = "", $user = 0){
|
||||
global $var___db, $config;
|
||||
$db = new bdd();
|
||||
$db->connexion();
|
||||
$this->bd = $db;
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param String $nom Nom de l'action
|
||||
* @param int $user ID du joueur à charger automatiquement
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
public function Bourse($nom = "", $user = 0)
|
||||
{
|
||||
global $var___db, $config;
|
||||
$db = new bdd();
|
||||
$db->connexion();
|
||||
$this->bd = $db;
|
||||
|
||||
if (!empty($nom)) {
|
||||
$this->loadAction($nom, "id");
|
||||
if (!empty($user)) $this->loadUser($user);
|
||||
}
|
||||
}
|
||||
if (!empty($nom)) {
|
||||
$this->loadAction($nom, "id");
|
||||
if (!empty($user)) {
|
||||
$this->loadUser($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function __destruct(){
|
||||
$this->bd->deconnexion();
|
||||
}
|
||||
public function __destruct()
|
||||
{
|
||||
$this->bd->deconnexion();
|
||||
}
|
||||
|
||||
function loadAction($nom, $type = "nom"){
|
||||
global $table_bourse;
|
||||
$this->bd->escape($nom);
|
||||
$act = $this->bd->unique_query("SELECT * FROM $table_bourse WHERE $type = '$nom';");
|
||||
if ($act) {
|
||||
$this->id = $act['id'];
|
||||
$this->nom = $act['nom'];
|
||||
$this->metal = $act['metal'];
|
||||
$this->cristal = $act['cristal'];
|
||||
}
|
||||
else erreur('Impossible de trouver cette action !', "red", '?p=bourse');
|
||||
}
|
||||
public function loadAction($nom, $type = "nom")
|
||||
{
|
||||
global $table_bourse;
|
||||
$this->bd->escape($nom);
|
||||
$act = $this->bd->unique_query("SELECT * FROM $table_bourse WHERE $type = '$nom';");
|
||||
if ($act) {
|
||||
$this->id = $act['id'];
|
||||
$this->nom = $act['nom'];
|
||||
$this->metal = $act['metal'];
|
||||
$this->cristal = $act['cristal'];
|
||||
} else {
|
||||
erreur('Impossible de trouver cette action !', "red", '?p=bourse');
|
||||
}
|
||||
}
|
||||
|
||||
function loadUser($user, $type = "id"){
|
||||
global $table_user;
|
||||
$this->bd->escape($user);
|
||||
$act = $this->bd->unique_query("SELECT id, bourse FROM $table_user WHERE $type = '$user';");
|
||||
$this->user = $act['id'];
|
||||
$this->traitUser($act['bourse']);
|
||||
}
|
||||
public function loadUser($user, $type = "id")
|
||||
{
|
||||
global $table_user;
|
||||
$this->bd->escape($user);
|
||||
$act = $this->bd->unique_query("SELECT id, bourse FROM $table_user WHERE $type = '$user';");
|
||||
$this->user = $act['id'];
|
||||
$this->traitUser($act['bourse']);
|
||||
}
|
||||
|
||||
function traitUser($start){
|
||||
$end = array();
|
||||
$start = explode(';', $start);
|
||||
$cnt = count($start);
|
||||
for($i = 0; $i < $cnt; $i++){
|
||||
$tmp = explode(':', $start[$i]);
|
||||
if (!empty($tmp[1])) $end[$tmp[0]] = explode(',', $tmp[1]);
|
||||
else $end[$tmp[0]] = array();
|
||||
}
|
||||
$this->actionsUser = $end;
|
||||
}
|
||||
public function traitUser($start)
|
||||
{
|
||||
$end = array();
|
||||
$start = explode(';', $start);
|
||||
$cnt = count($start);
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
$tmp = explode(':', $start[$i]);
|
||||
if (!empty($tmp[1])) {
|
||||
$end[$tmp[0]] = explode(',', $tmp[1]);
|
||||
} else {
|
||||
$end[$tmp[0]] = array();
|
||||
}
|
||||
}
|
||||
$this->actionsUser = $end;
|
||||
}
|
||||
|
||||
function prixAchat($nb){
|
||||
return array(floor($this->metal * $nb * $this->taxeA), floor($this->cristal * $nb * $this->taxeA));
|
||||
}
|
||||
public function prixAchat($nb)
|
||||
{
|
||||
return array(floor($this->metal * $nb * $this->taxeA), floor($this->cristal * $nb * $this->taxeA));
|
||||
}
|
||||
|
||||
function prixVente($nb){
|
||||
if ($this->action() < $nb) $nb = $this->action();
|
||||
public function prixVente($nb)
|
||||
{
|
||||
if ($this->action() < $nb) {
|
||||
$nb = $this->action();
|
||||
}
|
||||
|
||||
return array(floor($this->metal * $nb / $this->taxeV), floor($this->cristal * $nb / $this->taxeV));
|
||||
}
|
||||
return array(floor($this->metal * $nb / $this->taxeV), floor($this->cristal * $nb / $this->taxeV));
|
||||
}
|
||||
|
||||
function addAction($nb){
|
||||
$ret = array(floor($this->metal * $nb * $this->taxeA), floor($this->cristal * $nb * $this->taxeA));
|
||||
public function addAction($nb)
|
||||
{
|
||||
$ret = array(floor($this->metal * $nb * $this->taxeA), floor($this->cristal * $nb * $this->taxeA));
|
||||
|
||||
$this->metal *= pow(1.1, $nb);
|
||||
$this->cristal *= pow(1.1, $nb);
|
||||
$this->metal *= pow(1.1, $nb);
|
||||
$this->cristal *= pow(1.1, $nb);
|
||||
|
||||
for($i = 0; $i < $nb; $i++){
|
||||
$this->actionsUser[$this->id][] = time();
|
||||
}
|
||||
for ($i = 0; $i < $nb; $i++) {
|
||||
$this->actionsUser[$this->id][] = time();
|
||||
}
|
||||
|
||||
$this->maj();
|
||||
return $ret;
|
||||
}
|
||||
$this->maj();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function delAction($nb){
|
||||
if ($this->action() < $nb) $nb = $this->action();
|
||||
public function delAction($nb)
|
||||
{
|
||||
if ($this->action() < $nb) {
|
||||
$nb = $this->action();
|
||||
}
|
||||
|
||||
$ret = array(floor($this->metal * $nb / $this->taxeV), floor($this->cristal * $nb / $this->taxeV));
|
||||
$ret = array(floor($this->metal * $nb / $this->taxeV), floor($this->cristal * $nb / $this->taxeV));
|
||||
|
||||
$this->metal /= pow(1.1, $nb);
|
||||
$this->cristal /= pow(1.1, $nb);
|
||||
$this->metal /= pow(1.1, $nb);
|
||||
$this->cristal /= pow(1.1, $nb);
|
||||
|
||||
for($i = 0; $i < $nb; $i++){
|
||||
unset($this->actionsUser[$this->id][$i]);
|
||||
}
|
||||
for ($i = 0; $i < $nb; $i++) {
|
||||
unset($this->actionsUser[$this->id][$i]);
|
||||
}
|
||||
|
||||
$this->maj();
|
||||
return $ret;
|
||||
}
|
||||
$this->maj();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function actionIn24Hours(){
|
||||
$nb = 0;
|
||||
if (isset($this->actionsUser[$this->id])) {
|
||||
$cnt = count($this->actionsUser[$this->id]);
|
||||
for($i = 0; $i < $cnt; $i++){
|
||||
if ($this->actionsUser[$this->id][$i] > time() - 86400) $nb++;
|
||||
}
|
||||
}
|
||||
return $nb;
|
||||
}
|
||||
public function actionIn24Hours()
|
||||
{
|
||||
$nb = 0;
|
||||
if (isset($this->actionsUser[$this->id])) {
|
||||
$cnt = count($this->actionsUser[$this->id]);
|
||||
for ($i = 0; $i < $cnt; $i++) {
|
||||
if ($this->actionsUser[$this->id][$i] > time() - 86400) {
|
||||
$nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $nb;
|
||||
}
|
||||
|
||||
function action(){
|
||||
if (isset($this->actionsUser[$this->id])) return count($this->actionsUser[$this->id]);
|
||||
else return 0;
|
||||
public function action()
|
||||
{
|
||||
if (isset($this->actionsUser[$this->id])) {
|
||||
return count($this->actionsUser[$this->id]);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public function maj()
|
||||
{
|
||||
$this->majBourse();
|
||||
$this->majUser();
|
||||
$this->fileSave();
|
||||
}
|
||||
|
||||
function maj(){
|
||||
$this->majBourse();
|
||||
$this->majUser();
|
||||
$this->fileSave();
|
||||
}
|
||||
public function majBourse()
|
||||
{
|
||||
global $table_bourse;
|
||||
|
||||
function majBourse(){
|
||||
global $table_bourse;
|
||||
$this->bd->query("UPDATE $table_bourse SET nom = '".$this->nom."', metal = '".$this->metal."', cristal = '".$this->cristal."' WHERE id = ".$this->id.";");
|
||||
}
|
||||
|
||||
$this->bd->query("UPDATE $table_bourse SET nom = '".$this->nom."', metal = '".$this->metal."', cristal = '".$this->cristal."' WHERE id = ".$this->id.";");
|
||||
}
|
||||
public function majUser()
|
||||
{
|
||||
global $table_user;
|
||||
|
||||
function majUser(){
|
||||
global $table_user;
|
||||
$champ = '';
|
||||
foreach ($this->actionsUser as $key => $cell) {
|
||||
if (count($cell) > 0) {
|
||||
if (empty($champ)) {
|
||||
$champ .= $key.':'.implode(',', $cell);
|
||||
} else {
|
||||
$champ .= ';'.$key.':'.implode(',', $cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$champ = '';
|
||||
foreach($this->actionsUser as $key => $cell) {
|
||||
if (count($cell) > 0) {
|
||||
if (empty($champ)) $champ .= $key.':'.implode(',', $cell);
|
||||
else $champ .= ';'.$key.':'.implode(',', $cell);
|
||||
}
|
||||
}
|
||||
$this->bd->query("UPDATE $table_user SET bourse = '$champ' WHERE id = ".$this->user.";");
|
||||
}
|
||||
|
||||
$this->bd->query("UPDATE $table_user SET bourse = '$champ' WHERE id = ".$this->user.";");
|
||||
}
|
||||
public function delUser($id = "")
|
||||
{
|
||||
if (!empty($id)) {
|
||||
$this->loadUser($id);
|
||||
}
|
||||
|
||||
function delUser($id = ""){
|
||||
if (!empty($id)) $this->loadUser($id);
|
||||
|
||||
$champ = '';
|
||||
foreach($this->actionsUser as $key => $cell) {
|
||||
$cnt = count($cell);
|
||||
if ($cnt > 0) {
|
||||
$this->loadAction($key, "id");
|
||||
$this->delAction($cnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
$champ = '';
|
||||
foreach ($this->actionsUser as $key => $cell) {
|
||||
$cnt = count($cell);
|
||||
if ($cnt > 0) {
|
||||
$this->loadAction($key, "id");
|
||||
$this->delAction($cnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fileSave(){
|
||||
$fichier = fopen(_FCORE."../game/cache/bourse/".$this->id.".".strftime('%Y%m%d').".bourse",'a+');
|
||||
fwrite($fichier, time().';'.$this->metal.';'.$this->cristal."\n");
|
||||
fclose($fichier);
|
||||
}
|
||||
public function fileSave()
|
||||
{
|
||||
$fichier = fopen(_FCORE."../game/cache/bourse/".$this->id.".".strftime('%Y%m%d').".bourse", 'a+');
|
||||
fwrite($fichier, time().';'.$this->metal.';'.$this->cristal."\n");
|
||||
fclose($fichier);
|
||||
}
|
||||
|
||||
|
||||
function newGroupe($nom, $metal, $cristal, $description = ""){
|
||||
global $table_bourse;
|
||||
public function newGroupe($nom, $metal, $cristal, $description = "")
|
||||
{
|
||||
global $table_bourse;
|
||||
|
||||
$this->bd->query("INSERT INTO $table_bourse (nom, metal, cristal, description) VALUES('$nom', '$metal', '$cristal', '$description');");
|
||||
}
|
||||
$this->bd->query("INSERT INTO $table_bourse (nom, metal, cristal, description) VALUES('$nom', '$metal', '$cristal', '$description');");
|
||||
}
|
||||
|
||||
function editGroupe($description){
|
||||
//TODO toute cette fonction !!
|
||||
}
|
||||
public function editGroupe($description)
|
||||
{
|
||||
//TODO toute cette fonction !!
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -9,254 +9,262 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
class Donnee
|
||||
{
|
||||
public static function donneeTechnologie($branche, $idTechnologie, $retour, Planete $planete)
|
||||
{
|
||||
static function donneeTechnologie($branche, $idTechnologie, $retour, Planete $planete)
|
||||
{
|
||||
//TODO : Faire un switch pour ne renvoyer le tableau que de la branche plutôt que ce tableau avec l'intégralité des branches.
|
||||
$technologies_donnees = array(
|
||||
//Industrie
|
||||
array(
|
||||
array(1, 0, 1000, 54000),
|
||||
array(2, 1, 2000, 90000),
|
||||
array(4, 3, 4000, 126000),
|
||||
array(8, 1, 4000, 126000),
|
||||
array(16, 1, 2000, 72000),
|
||||
array(32, 17, 4000, 108000),
|
||||
array(64, 49, 8000, 144000),
|
||||
array(128, 1, 2000, 72000),
|
||||
array(256, 129, 4000, 108000),
|
||||
array(512, 385, 8000, 144000),
|
||||
array(1024, 1, 2000, 72000),
|
||||
array(2048, 1025, 4000, 108000),
|
||||
array(4096, 3073, 8000, 144000),
|
||||
array(8192, 9, 3000, 126000),
|
||||
array(16384, 8201, 6000, 162000),
|
||||
array(32768, 24585, 12000, 198000),
|
||||
array(65536, 1169, 3000, 126000),
|
||||
array(131072, 66705, 6000, 162000),
|
||||
array(262144, 197777, 12000, 198000)
|
||||
),
|
||||
//Ingénieurie
|
||||
array(
|
||||
array(1, 0, 1000, 54000),
|
||||
array(2, 1, 2000, 90000),
|
||||
array(4, 3, 4000, 126000),
|
||||
array(8, 1, 2000, 90000),
|
||||
array(16, 9, 4000, 126000),
|
||||
array(32, 25, 8000, 162000),
|
||||
array(64, 9, 3000, 126000),
|
||||
array(128, 73, 6000, 162000),
|
||||
array(256, 201, 12000, 198000),
|
||||
array(512, 73, 4000, 162000),
|
||||
array(1024, 585, 8000, 198000),
|
||||
array(2048, 1609, 16000, 234000),
|
||||
array(4096, 0, 1000, 54000),
|
||||
array(8192, 4096, 2000, 90000),
|
||||
array(16384, 12288, 4000, 126000),
|
||||
array(32768, 4096, 2000, 54000),
|
||||
array(65536, 36864, 4000, 90000),
|
||||
array(131072, 102400, 8000, 126000),
|
||||
array(262144, 12288, 2000, 72000),
|
||||
array(524288, 274432, 4000, 108000),
|
||||
array(1048576, 798720, 8000, 144000),
|
||||
array(2097152, 274432, 2000, 54000),
|
||||
array(4194304, 2371584, 4000, 90000),
|
||||
array(8388608, 6565888, 8000, 126000),
|
||||
array(16777216, 28672, 2000, 54000),
|
||||
array(33554432, 16805888, 4000, 90000),
|
||||
array(67108864, 50360320, 8000, 126000),
|
||||
array(134217728, 28672, 3000, 90000),
|
||||
array(268435456, 134246400, 6000, 126000),
|
||||
array(536870912, 402681856, 12000, 162000)
|
||||
),
|
||||
//Ingénieurie 2
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 4000, 126000),
|
||||
array(16, 1, 4000, 126000),
|
||||
array(32, 25, 4000, 126000),
|
||||
array(64, 57, 8000, 162000),
|
||||
array(128, 121, 16000, 198000)
|
||||
),
|
||||
//Politique
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 2000, 72000),
|
||||
array(16, 9, 4000, 108000),
|
||||
array(32, 25, 8000, 144000),
|
||||
array(64, 9, 4000, 126000),
|
||||
array(128, 8, 6000, 162000),
|
||||
array(256, 9, 6000, 162000),
|
||||
array(512, 0, 1000, 90000),
|
||||
array(1024, 512, 2000, 90000),
|
||||
array(2048, 1536, 4000, 90000),
|
||||
array(4096, 512, 2000, 72000),
|
||||
array(8192, 4608, 4000, 108000),
|
||||
array(16384, 12800, 8000, 144000)
|
||||
),
|
||||
//TODO : Faire un switch pour ne renvoyer le tableau que de la branche plutôt que ce tableau avec l'intégralité des branches.
|
||||
$technologies_donnees = array(
|
||||
//Industrie
|
||||
array(
|
||||
array(1, 0, 1000, 54000),
|
||||
array(2, 1, 2000, 90000),
|
||||
array(4, 3, 4000, 126000),
|
||||
array(8, 1, 4000, 126000),
|
||||
array(16, 1, 2000, 72000),
|
||||
array(32, 17, 4000, 108000),
|
||||
array(64, 49, 8000, 144000),
|
||||
array(128, 1, 2000, 72000),
|
||||
array(256, 129, 4000, 108000),
|
||||
array(512, 385, 8000, 144000),
|
||||
array(1024, 1, 2000, 72000),
|
||||
array(2048, 1025, 4000, 108000),
|
||||
array(4096, 3073, 8000, 144000),
|
||||
array(8192, 9, 3000, 126000),
|
||||
array(16384, 8201, 6000, 162000),
|
||||
array(32768, 24585, 12000, 198000),
|
||||
array(65536, 1169, 3000, 126000),
|
||||
array(131072, 66705, 6000, 162000),
|
||||
array(262144, 197777, 12000, 198000)
|
||||
),
|
||||
//Ingénieurie
|
||||
array(
|
||||
array(1, 0, 1000, 54000),
|
||||
array(2, 1, 2000, 90000),
|
||||
array(4, 3, 4000, 126000),
|
||||
array(8, 1, 2000, 90000),
|
||||
array(16, 9, 4000, 126000),
|
||||
array(32, 25, 8000, 162000),
|
||||
array(64, 9, 3000, 126000),
|
||||
array(128, 73, 6000, 162000),
|
||||
array(256, 201, 12000, 198000),
|
||||
array(512, 73, 4000, 162000),
|
||||
array(1024, 585, 8000, 198000),
|
||||
array(2048, 1609, 16000, 234000),
|
||||
array(4096, 0, 1000, 54000),
|
||||
array(8192, 4096, 2000, 90000),
|
||||
array(16384, 12288, 4000, 126000),
|
||||
array(32768, 4096, 2000, 54000),
|
||||
array(65536, 36864, 4000, 90000),
|
||||
array(131072, 102400, 8000, 126000),
|
||||
array(262144, 12288, 2000, 72000),
|
||||
array(524288, 274432, 4000, 108000),
|
||||
array(1048576, 798720, 8000, 144000),
|
||||
array(2097152, 274432, 2000, 54000),
|
||||
array(4194304, 2371584, 4000, 90000),
|
||||
array(8388608, 6565888, 8000, 126000),
|
||||
array(16777216, 28672, 2000, 54000),
|
||||
array(33554432, 16805888, 4000, 90000),
|
||||
array(67108864, 50360320, 8000, 126000),
|
||||
array(134217728, 28672, 3000, 90000),
|
||||
array(268435456, 134246400, 6000, 126000),
|
||||
array(536870912, 402681856, 12000, 162000)
|
||||
),
|
||||
//Ingénieurie 2
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 4000, 126000),
|
||||
array(16, 1, 4000, 126000),
|
||||
array(32, 25, 4000, 126000),
|
||||
array(64, 57, 8000, 162000),
|
||||
array(128, 121, 16000, 198000)
|
||||
),
|
||||
//Politique
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 2000, 72000),
|
||||
array(16, 9, 4000, 108000),
|
||||
array(32, 25, 8000, 144000),
|
||||
array(64, 9, 4000, 126000),
|
||||
array(128, 8, 6000, 162000),
|
||||
array(256, 9, 6000, 162000),
|
||||
array(512, 0, 1000, 90000),
|
||||
array(1024, 512, 2000, 90000),
|
||||
array(2048, 1536, 4000, 90000),
|
||||
array(4096, 512, 2000, 72000),
|
||||
array(8192, 4608, 4000, 108000),
|
||||
array(16384, 12800, 8000, 144000)
|
||||
),
|
||||
|
||||
//Armement
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 1000, 54000),
|
||||
array(16, 9, 2000, 90000),
|
||||
array(32, 25, 4000, 126000),
|
||||
array(64, 9, 2000, 72000),
|
||||
array(128, 73, 4000, 108000),
|
||||
array(256, 201, 8000, 144000),
|
||||
array(512, 73, 2000, 90000),
|
||||
array(1024, 585, 4000, 126000),
|
||||
array(2048, 1609, 8000, 162000),
|
||||
array(4096, 1, 3000, 108000),
|
||||
array(8192, 4097, 6000, 144000),
|
||||
array(16384, 12289, 12000, 180000),
|
||||
array(32768, 4097, 3000, 126000),
|
||||
array(65536, 36865, 6000, 162000),
|
||||
array(131072, 102401, 12000, 198000)
|
||||
),
|
||||
//Défense
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 2000, 72000),
|
||||
array(16, 9, 4000, 108000),
|
||||
array(32, 25, 8000, 144000),
|
||||
array(64, 9, 3000, 108000),
|
||||
array(128, 73, 6000, 144000),
|
||||
array(256, 201, 12000, 180000),
|
||||
array(512, 0, 1000, 36000),
|
||||
array(1024, 512, 2000, 72000),
|
||||
array(2048, 1536, 4000, 108000),
|
||||
array(4096, 512, 2000, 72000),
|
||||
array(8192, 4608, 4000, 108000),
|
||||
array(16384, 12800, 8000, 144000),
|
||||
array(32768, 4608, 3000, 108000),
|
||||
array(65536, 37376, 6000, 144000),
|
||||
array(131072, 102912, 12000, 180000),
|
||||
array(262144, 512, 1000, 54000),
|
||||
array(524288, 262656, 2000, 90000),
|
||||
array(1048576, 786944, 4000, 126000),
|
||||
array(2097152, 262656, 2000, 90000),
|
||||
array(4194304, 2359808, 4000, 126000),
|
||||
array(8388608, 6554112, 8000, 162000),
|
||||
array(16777216, 2359808, 3000, 126000),
|
||||
array(33554432, 19137024, 6000, 162000),
|
||||
array(67108864, 52691456, 12000, 198000)
|
||||
),
|
||||
//Défense 2
|
||||
array(
|
||||
array(1, 0, 2000, 72000),
|
||||
array(2, 1, 4000, 144000),
|
||||
array(4, 3, 6000, 216000),
|
||||
array(8, 0, 2000, 72000),
|
||||
array(16, 8, 4000, 144000),
|
||||
array(32, 24, 6000, 216000),
|
||||
array(64, 27, 8000, 288000)
|
||||
),
|
||||
//Projets expérimentaux
|
||||
array(
|
||||
array(1, 0, 2000, 36000),
|
||||
array(2, 1, 4000, 72000),
|
||||
array(4, 2, 4000, 108000),
|
||||
array(8, 4, 6000, 144000),
|
||||
array(16, 8, 6000, 144000),
|
||||
array(32, 8, 8000, 180000),
|
||||
array(64, 32, 10000, 216000),
|
||||
array(128, 64, 10000, 234000),
|
||||
array(256, 128, 12000, 288000),
|
||||
array(512, 256, 14000, 324000),
|
||||
array(1024, 64, 14000, 342000),
|
||||
array(2048, 256, 16000, 360000),
|
||||
array(4096, 576, 18000, 396000),
|
||||
array(8192, 4096, 20000, 432000),
|
||||
array(16384, 8192, 22000, 504000)
|
||||
),
|
||||
//Technologie expansion
|
||||
array(
|
||||
array(1, 0, 4000, 54000),
|
||||
array(2, 1, 6000, 72000),
|
||||
array(4, 3, 8000, 90000),
|
||||
array(8, 7, 10000, 108000),
|
||||
array(16, 15, 12000, 126000),
|
||||
array(32, 31, 14000, 144000),
|
||||
array(64, 63, 16000, 162000),
|
||||
array(128, 127, 18000, 180000),
|
||||
array(256, 255, 20000, 198000),
|
||||
array(512, 511, 22000, 216000),
|
||||
array(1024, 1023, 24000, 234000),
|
||||
array(2048, 2047, 26000, 252000),
|
||||
array(4096, 4095, 28000, 270000),
|
||||
array(8192, 8191, 30000, 288000),
|
||||
array(16384, 16383, 32000, 306000),
|
||||
array(32768, 32767, 34000, 324000),
|
||||
array(65536, 65535, 36000, 342000),
|
||||
array(131072, 131071, 38000, 360000)
|
||||
)
|
||||
);
|
||||
//Armement
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 1000, 54000),
|
||||
array(16, 9, 2000, 90000),
|
||||
array(32, 25, 4000, 126000),
|
||||
array(64, 9, 2000, 72000),
|
||||
array(128, 73, 4000, 108000),
|
||||
array(256, 201, 8000, 144000),
|
||||
array(512, 73, 2000, 90000),
|
||||
array(1024, 585, 4000, 126000),
|
||||
array(2048, 1609, 8000, 162000),
|
||||
array(4096, 1, 3000, 108000),
|
||||
array(8192, 4097, 6000, 144000),
|
||||
array(16384, 12289, 12000, 180000),
|
||||
array(32768, 4097, 3000, 126000),
|
||||
array(65536, 36865, 6000, 162000),
|
||||
array(131072, 102401, 12000, 198000)
|
||||
),
|
||||
//Défense
|
||||
array(
|
||||
array(1, 0, 1000, 36000),
|
||||
array(2, 1, 2000, 72000),
|
||||
array(4, 3, 4000, 108000),
|
||||
array(8, 1, 2000, 72000),
|
||||
array(16, 9, 4000, 108000),
|
||||
array(32, 25, 8000, 144000),
|
||||
array(64, 9, 3000, 108000),
|
||||
array(128, 73, 6000, 144000),
|
||||
array(256, 201, 12000, 180000),
|
||||
array(512, 0, 1000, 36000),
|
||||
array(1024, 512, 2000, 72000),
|
||||
array(2048, 1536, 4000, 108000),
|
||||
array(4096, 512, 2000, 72000),
|
||||
array(8192, 4608, 4000, 108000),
|
||||
array(16384, 12800, 8000, 144000),
|
||||
array(32768, 4608, 3000, 108000),
|
||||
array(65536, 37376, 6000, 144000),
|
||||
array(131072, 102912, 12000, 180000),
|
||||
array(262144, 512, 1000, 54000),
|
||||
array(524288, 262656, 2000, 90000),
|
||||
array(1048576, 786944, 4000, 126000),
|
||||
array(2097152, 262656, 2000, 90000),
|
||||
array(4194304, 2359808, 4000, 126000),
|
||||
array(8388608, 6554112, 8000, 162000),
|
||||
array(16777216, 2359808, 3000, 126000),
|
||||
array(33554432, 19137024, 6000, 162000),
|
||||
array(67108864, 52691456, 12000, 198000)
|
||||
),
|
||||
//Défense 2
|
||||
array(
|
||||
array(1, 0, 2000, 72000),
|
||||
array(2, 1, 4000, 144000),
|
||||
array(4, 3, 6000, 216000),
|
||||
array(8, 0, 2000, 72000),
|
||||
array(16, 8, 4000, 144000),
|
||||
array(32, 24, 6000, 216000),
|
||||
array(64, 27, 8000, 288000)
|
||||
),
|
||||
//Projets expérimentaux
|
||||
array(
|
||||
array(1, 0, 2000, 36000),
|
||||
array(2, 1, 4000, 72000),
|
||||
array(4, 2, 4000, 108000),
|
||||
array(8, 4, 6000, 144000),
|
||||
array(16, 8, 6000, 144000),
|
||||
array(32, 8, 8000, 180000),
|
||||
array(64, 32, 10000, 216000),
|
||||
array(128, 64, 10000, 234000),
|
||||
array(256, 128, 12000, 288000),
|
||||
array(512, 256, 14000, 324000),
|
||||
array(1024, 64, 14000, 342000),
|
||||
array(2048, 256, 16000, 360000),
|
||||
array(4096, 576, 18000, 396000),
|
||||
array(8192, 4096, 20000, 432000),
|
||||
array(16384, 8192, 22000, 504000)
|
||||
),
|
||||
//Technologie expansion
|
||||
array(
|
||||
array(1, 0, 4000, 54000),
|
||||
array(2, 1, 6000, 72000),
|
||||
array(4, 3, 8000, 90000),
|
||||
array(8, 7, 10000, 108000),
|
||||
array(16, 15, 12000, 126000),
|
||||
array(32, 31, 14000, 144000),
|
||||
array(64, 63, 16000, 162000),
|
||||
array(128, 127, 18000, 180000),
|
||||
array(256, 255, 20000, 198000),
|
||||
array(512, 511, 22000, 216000),
|
||||
array(1024, 1023, 24000, 234000),
|
||||
array(2048, 2047, 26000, 252000),
|
||||
array(4096, 4095, 28000, 270000),
|
||||
array(8192, 8191, 30000, 288000),
|
||||
array(16384, 16383, 32000, 306000),
|
||||
array(32768, 32767, 34000, 324000),
|
||||
array(65536, 65535, 36000, 342000),
|
||||
array(131072, 131071, 38000, 360000)
|
||||
)
|
||||
);
|
||||
|
||||
if ($retour == "metal") return 0;
|
||||
elseif ($retour == "cristal") return 0;
|
||||
elseif ($retour == "hydrogene") return 0;
|
||||
elseif ($retour == "credits") return $technologies_donnees[$branche][$idTechnologie][2];
|
||||
elseif ($retour == "temps") return $technologies_donnees[$branche][$idTechnologie][3]/VITESSE;
|
||||
elseif ($retour == "needed") return $technologies_donnees[$branche][$idTechnologie][1];
|
||||
elseif ($retour == "id") return $technologies_donnees[$branche][$idTechnologie][0];
|
||||
elseif ($retour == "array") return array(0, 0, 0, $technologies_donnees[$branche][$idTechnologie][2], $technologies_donnees[$branche][$idTechnologie][3]/VITESSE);
|
||||
}
|
||||
|
||||
static function metalTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "metal", $planete);
|
||||
}
|
||||
|
||||
static function cristalTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "cristal", $planete);
|
||||
}
|
||||
|
||||
static function hydrogeneTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "hydrogene", $planete);
|
||||
}
|
||||
|
||||
static function creditsTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "credits", $planete);
|
||||
}
|
||||
|
||||
static function tempsTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "temps", $planete);
|
||||
}
|
||||
|
||||
static function idTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "id", $planete);
|
||||
}
|
||||
|
||||
static function neededTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
$neededTechnologies = Donnee::donneeTechnologie($branche, $idTechnologie, "needed", $planete);
|
||||
if (empty($neededTechnologies)) return true;
|
||||
if (is_array($neededTechnologies))
|
||||
{
|
||||
//TODO prévoir le besoin de plus d'une technologie pour la validation, dans une autre branche, batiment (?) ...
|
||||
die('TODO '.__LINE__.' in '.__FILE__);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((int)$planete->technologies[$branche]& $neededTechnologies) == $neededTechnologies)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($retour == "metal") {
|
||||
return 0;
|
||||
} elseif ($retour == "cristal") {
|
||||
return 0;
|
||||
} elseif ($retour == "hydrogene") {
|
||||
return 0;
|
||||
} elseif ($retour == "credits") {
|
||||
return $technologies_donnees[$branche][$idTechnologie][2];
|
||||
} elseif ($retour == "temps") {
|
||||
return $technologies_donnees[$branche][$idTechnologie][3]/VITESSE;
|
||||
} elseif ($retour == "needed") {
|
||||
return $technologies_donnees[$branche][$idTechnologie][1];
|
||||
} elseif ($retour == "id") {
|
||||
return $technologies_donnees[$branche][$idTechnologie][0];
|
||||
} elseif ($retour == "array") {
|
||||
return array(0, 0, 0, $technologies_donnees[$branche][$idTechnologie][2], $technologies_donnees[$branche][$idTechnologie][3]/VITESSE);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
public static function metalTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "metal", $planete);
|
||||
}
|
||||
|
||||
public static function cristalTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "cristal", $planete);
|
||||
}
|
||||
|
||||
public static function hydrogeneTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "hydrogene", $planete);
|
||||
}
|
||||
|
||||
public static function creditsTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "credits", $planete);
|
||||
}
|
||||
|
||||
public static function tempsTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "temps", $planete);
|
||||
}
|
||||
|
||||
public static function idTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
return Donnee::donneeTechnologie($branche, $idTechnologie, "id", $planete);
|
||||
}
|
||||
|
||||
public static function neededTechnologie($branche, $idTechnologie, Planete $planete)
|
||||
{
|
||||
$neededTechnologies = Donnee::donneeTechnologie($branche, $idTechnologie, "needed", $planete);
|
||||
if (empty($neededTechnologies)) {
|
||||
return true;
|
||||
}
|
||||
if (is_array($neededTechnologies)) {
|
||||
//TODO prévoir le besoin de plus d'une technologie pour la validation, dans une autre branche, batiment (?) ...
|
||||
die('TODO '.__LINE__.' in '.__FILE__);
|
||||
} else {
|
||||
if (((int)$planete->technologies[$branche]& $neededTechnologies) == $neededTechnologies) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -9,178 +9,166 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
class FlotteGroupee
|
||||
{
|
||||
var $id_flotte = 0,
|
||||
$nom,
|
||||
$end_planete,
|
||||
$time_end,
|
||||
$end_type,
|
||||
$ret_planete,
|
||||
$flottes = array(),
|
||||
$mission,
|
||||
$modifFlotte = array();
|
||||
{
|
||||
public $id_flotte = 0;
|
||||
public $nom;
|
||||
public $end_planete;
|
||||
public $time_end;
|
||||
public $end_type;
|
||||
public $ret_planete;
|
||||
public $flottes = array();
|
||||
public $mission;
|
||||
public $modifFlotte = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la flotte à importer
|
||||
* @param bool $verrou Booléen disant si la classe doit obtenir préalablement un verrou pour la flotte.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id = 0, $verrou = true)
|
||||
{
|
||||
if (!empty($id))
|
||||
{
|
||||
global $table_flottes_preparation;
|
||||
global $spatialVAR, $ressoVAR;
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la flotte à importer
|
||||
* @param bool $verrou Booléen disant si la classe doit obtenir préalablement un verrou pour la flotte.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($id = 0, $verrou = true)
|
||||
{
|
||||
if (!empty($id)) {
|
||||
global $table_flottes_preparation;
|
||||
global $spatialVAR, $ressoVAR;
|
||||
|
||||
$id = intval($id);
|
||||
$bdd = new BDD();
|
||||
$flotte = $bdd->unique_query("SELECT * FROM $table_flottes_preparation WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
$id = intval($id);
|
||||
$bdd = new BDD();
|
||||
$flotte = $bdd->unique_query("SELECT * FROM $table_flottes_preparation WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($flotte))
|
||||
{
|
||||
$this->id_flotte = $flotte["id"];
|
||||
$this->nom = $flotte["nom"];
|
||||
$this->end_planete = $flotte["end_planete"];
|
||||
$this->end_type = $flotte["end_type"];
|
||||
$this->time_end = $flotte["time_end"];
|
||||
$this->mission = $flotte["mission"];
|
||||
if (!empty($flotte)) {
|
||||
$this->id_flotte = $flotte["id"];
|
||||
$this->nom = $flotte["nom"];
|
||||
$this->end_planete = $flotte["end_planete"];
|
||||
$this->end_type = $flotte["end_type"];
|
||||
$this->time_end = $flotte["time_end"];
|
||||
$this->mission = $flotte["mission"];
|
||||
|
||||
if (empty($this->flottes)
|
||||
$this->flottes = array();
|
||||
else
|
||||
$this->flottes = unserialize($flotte["flottes"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($this->flottes)) {
|
||||
$this->flottes = array();
|
||||
} else {
|
||||
$this->flottes = unserialize($flotte["flottes"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function load_planete()
|
||||
{
|
||||
if (is_numeric($this->end_planete) && !empty($this->end_planete))
|
||||
{
|
||||
//On traite l'importation en fonction des types fornis
|
||||
if ($this->end_type == 0 || $this->end_type == 1)
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->end_planete)
|
||||
$this->end_planete = $planete;
|
||||
else
|
||||
$this->end_planete = new Planete($this->end_planete);
|
||||
}
|
||||
else
|
||||
{
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->end_planete)
|
||||
$this->end_planete = $planete;
|
||||
else
|
||||
$this->end_planete = new Asteroide($this->end_planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function load_planete()
|
||||
{
|
||||
if (is_numeric($this->end_planete) && !empty($this->end_planete)) {
|
||||
//On traite l'importation en fonction des types fornis
|
||||
if ($this->end_type == 0 || $this->end_type == 1) {
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "planete" && $planete->id == $this->end_planete) {
|
||||
$this->end_planete = $planete;
|
||||
} else {
|
||||
$this->end_planete = new Planete($this->end_planete);
|
||||
}
|
||||
} else {
|
||||
global $planete;
|
||||
//Si la planète est la même que celle du joueur actuel, on l'utilise, sinon, on la crée
|
||||
if (SURFACE == "asteroide" && $planete->id == $this->end_planete) {
|
||||
$this->end_planete = $planete;
|
||||
} else {
|
||||
$this->end_planete = new Asteroide($this->end_planete);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addFlotte($start_planete, $vitesse, $vaisseaux, $contenu_metal, $contenu_cristal, $contenu_hydrogene)
|
||||
{
|
||||
$this->flottes[] = array($start_planete->id_user, $start_planete->id, $vitesse, $vaisseaux, $contenu_metal, $contenu_cristal, $contenu_hydrogene);
|
||||
addModifFlotte("flottes");
|
||||
}
|
||||
public function addFlotte($start_planete, $vitesse, $vaisseaux, $contenu_metal, $contenu_cristal, $contenu_hydrogene)
|
||||
{
|
||||
$this->flottes[] = array($start_planete->id_user, $start_planete->id, $vitesse, $vaisseaux, $contenu_metal, $contenu_cristal, $contenu_hydrogene);
|
||||
addModifFlotte("flottes");
|
||||
}
|
||||
|
||||
function lancer()
|
||||
{
|
||||
public function lancer()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
public function addModifFlotte($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modifFlotte)) {
|
||||
$this->modifFlotte[] = $modif;
|
||||
}
|
||||
}
|
||||
|
||||
function addModifFlotte($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modifFlotte))
|
||||
$this->modifFlotte[] = $modif;
|
||||
}
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
global $table_flottes;
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct()
|
||||
{
|
||||
global $table_flottes;
|
||||
if ($this->modifFlotte === "DELETE") {
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_flottes WHERE id = ".$this->id_flotte.";");
|
||||
$bdd->deconnexion();
|
||||
} else {
|
||||
if (empty($this->id_flotte)) {
|
||||
if ($this->modifFlotte == "INSERT") {
|
||||
$out1 = '';
|
||||
$out2 = '';
|
||||
global $spatialVAR;
|
||||
foreach ($this->vaisseaux as $key => $vais) {
|
||||
$out1 .= ', '.$spatialVAR[$key];
|
||||
$out2 .= ', '.$vais;
|
||||
}
|
||||
$sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_type, start_planete, end_time, end_type, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_type."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_type."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
|
||||
if (DEBUG) {
|
||||
echo $sql;
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$bdd->query($sql);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
} elseif (isset($this->modifFlotte[0])) {
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach ($this->modifFlotte as $modif) {
|
||||
if (!is_array($this->{$modif})) {
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif})) {
|
||||
$out[] .= $modif." = ".$this->{$modif};
|
||||
} else {
|
||||
$bdd->escape($this->{$modif});
|
||||
$out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
} else {
|
||||
if ($modif == "contenu") {
|
||||
$calc = "resso";
|
||||
} elseif ($modif == "vaisseaux") {
|
||||
$calc = "nomvaisn";
|
||||
}
|
||||
|
||||
if ($this->modifFlotte === "DELETE")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_flottes WHERE id = ".$this->id_flotte.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($this->id_flotte))
|
||||
{
|
||||
if ($this->modifFlotte == "INSERT")
|
||||
{
|
||||
$out1 = ''; $out2 = '';
|
||||
global $spatialVAR;
|
||||
foreach ($this->vaisseaux as $key => $vais)
|
||||
{
|
||||
$out1 .= ', '.$spatialVAR[$key];
|
||||
$out2 .= ', '.$vais;
|
||||
}
|
||||
$sql = "INSERT INTO $table_flottes (id_user, mission, start_time, start_type, start_planete, end_time, end_type, end_planete, vitesse, contenu_metal, contenu_cristal, contenu_hydrogene, tactique, nom, nb_vais$out1) VALUES ('".$this->start_planete->id_user."', '".$this->mission."', '".$this->start_time."', '".$this->start_type."', '".$this->start_planete->id."', '".$this->end_time."', '".$this->end_type."', '".$this->end_planete."', '".$this->vitesse."', '".$this->contenu[0]."', '".$this->contenu[1]."', '".$this->contenu[2]."', '".$this->tactique."', '".$this->nom."', ".$this->nb_vais."$out2);";
|
||||
if (DEBUG) echo $sql;
|
||||
$bdd = new BDD();
|
||||
$bdd->query($sql);
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
elseif(isset($this->modifFlotte[0]))
|
||||
{
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modifFlotte as $modif)
|
||||
{
|
||||
if (!is_array($this->{$modif}))
|
||||
{
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif}))
|
||||
$out[] .= $modif." = ".$this->{$modif};
|
||||
else
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
$out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif == "contenu")
|
||||
$calc = "resso";
|
||||
elseif ($modif == "vaisseaux")
|
||||
$calc = "nomvaisn";
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
foreach (${$calc.'VAR'} as $key => $var) {
|
||||
$bdd->escape($this->{$modif}[$key]);
|
||||
$out[] = ${$calc.'VAR'}[$key]." = ".$this->{$modif}[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(${$calc.'VAR'} as $key => $var)
|
||||
{
|
||||
$bdd->escape($this->{$modif}[$key]);
|
||||
$out[] = ${$calc.'VAR'}[$key]." = ".$this->{$modif}[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out)) {
|
||||
$sql = "UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";";
|
||||
if (DEBUG) {
|
||||
var_dump($sql);
|
||||
}
|
||||
$bdd->query($sql);
|
||||
}
|
||||
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_flottes SET ".implode(', ', $out).", last = 0 WHERE id = ".$this->id_flotte.";";
|
||||
if (DEBUG) var_dump($sql);
|
||||
$bdd->query($sql);
|
||||
}
|
||||
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -9,145 +9,140 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
class ExceptionHB extends Exception {
|
||||
class ExceptionHB extends Exception
|
||||
{
|
||||
public function __construct($branche, $code = 0, $debug = true, $gerer = false)
|
||||
{
|
||||
if ($gerer) {
|
||||
parent::__construct($branche, $code);
|
||||
} else {
|
||||
if (is_numeric($branche)) {
|
||||
switch ($branche) {
|
||||
case 1:
|
||||
switch ($code) {
|
||||
case 0:
|
||||
$message = "La planète est pleine, vous ne pouvez plus construire de batiment dessus !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de batiments.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour construire ce bâtiment.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Le bâtiment dont vous demandez la construction est actuellement en démolition. Annulez la démolition pour lui ajouter l'aggrandir.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour construire ce bâtiment !";
|
||||
break;
|
||||
|
||||
public function __construct($branche, $code = 0, $debug = true, $gerer = false) {
|
||||
if ($gerer)
|
||||
parent::__construct($branche, $code);
|
||||
else
|
||||
{
|
||||
if (is_numeric($branche))
|
||||
{
|
||||
switch($branche)
|
||||
{
|
||||
case 1:
|
||||
switch($code)
|
||||
{
|
||||
case 0:
|
||||
$message = "La planète est pleine, vous ne pouvez plus construire de batiment dessus !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de batiments.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour construire ce bâtiment.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Le bâtiment dont vous demandez la construction est actuellement en démolition. Annulez la démolition pour lui ajouter l'aggrandir.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour construire ce bâtiment !";
|
||||
break;
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la construction de ce bâtiment, il n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la construction de ce bâtiment, il n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démolir ce batiment, il n'est pas encore construit !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "Le bâtiment dont vous demandez la démolition est actuellement en travaux. Annulez les travaux en cours pour pouvoir le démolir.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch ($code) {
|
||||
case 0:
|
||||
$message = "Cette technologie est déjà en file d'attente, soyez patient !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de technologies.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour rechercher cette technologie.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Vous possédez déjà cette technologie !";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les crédits ou ressources nécessaires pour rechercher cette technologie !";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démolir ce batiment, il n'est pas encore construit !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "Le bâtiment dont vous demandez la démolition est actuellement en travaux. Annulez les travaux en cours pour pouvoir le démolir.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch($code)
|
||||
{
|
||||
case 0:
|
||||
$message = "Cette technologie est déjà en file d'attente, soyez patient !";
|
||||
break;
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de technologies.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour rechercher cette technologie.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "Vous possédez déjà cette technologie !";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les crédits ou ressources nécessaires pour rechercher cette technologie !";
|
||||
break;
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la recherche de cette technologie, elle n'a pas été trouvée dans la file !";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch ($code) {
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus d'unités.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour entraîner ces unités.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "L'unité dont vous demandez l'entraînement est actuellement en démentellement. Annulez le démentellement pour l'entraîner de nouveau.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour entraîner cette unité !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la recherche de cette technologie, elle n'a pas été trouvée dans la file !";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch($code)
|
||||
{
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus d'unités.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour entraîner ces unités.";
|
||||
break;
|
||||
case 3:
|
||||
$message = "L'unité dont vous demandez l'entraînement est actuellement en démentellement. Annulez le démentellement pour l'entraîner de nouveau.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour entraîner cette unité !";
|
||||
break;
|
||||
case 5:
|
||||
$message = "Impossible d'annuler l'entraînement de cette unité, elle n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler l'entraînement de cette unité, elle n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démenteler autant d'unités !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "L'unité dont vous demandez le démentellement est actuellement en entraînement. Annulez l'entraînement en cours pour pouvoir la démenteller.";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$message = "Vous ne pouvez pas démenteler autant d'unités !";
|
||||
break;
|
||||
case 7:
|
||||
$message = "L'unité dont vous demandez le démentellement est actuellement en entraînement. Annulez l'entraînement en cours pour pouvoir la démenteller.";
|
||||
break;
|
||||
case 8:
|
||||
$message = "Dépassement de capacité.<br />Vous ne pouvez pas demander la construction d'autant d'unités en même temps.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
switch ($code) {
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de recherches.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour rechercher cette technologie.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour rechercher cette technologie !";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$message = "Dépassement de capacité.<br />Vous ne pouvez pas demander la construction d'autant d'unités en même temps.";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
switch($code)
|
||||
{
|
||||
case 1:
|
||||
$message = "La file d'attente est pleine, vous ne pouvez pas rajouter plus de recherches.";
|
||||
break;
|
||||
case 2:
|
||||
$message = "Vous n'avez pas les bâtiments et/ou technologies nécessaires pour rechercher cette technologie.";
|
||||
break;
|
||||
case 4:
|
||||
$message = "Vous n'avez pas les ressources nécessaire pour rechercher cette technologie !";
|
||||
break;
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la recherche de cette technologie, elle n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$message = "Impossible d'annuler la recherche de cette technologie, elle n'a pas été trouvé dans la file !";
|
||||
break;
|
||||
case 6:
|
||||
$message = "Il n'est pas possible d'annuler une technologie connue";
|
||||
break;
|
||||
case 7:
|
||||
$message = "Vous recherchez déjà cette technologie !";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$message = $branche;
|
||||
}
|
||||
|
||||
case 6:
|
||||
$message = "Il n'est pas possible d'annuler une technologie connue";
|
||||
break;
|
||||
case 7:
|
||||
$message = "Vous recherchez déjà cette technologie !";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
$message = $branche;
|
||||
if ($debug || empty($message)) {
|
||||
$message = "Erreur #".intval($branche)."/".$code." :<br />".$message;
|
||||
}
|
||||
|
||||
if ($debug || empty($message))
|
||||
$message = "Erreur #".intval($branche)."/".$code." :<br />".$message;
|
||||
|
||||
global $template, $page;
|
||||
if (!empty($page))
|
||||
$template->assign('page', $page);
|
||||
$template->assign('message', $message);
|
||||
$template->assign('couleur', 'red');
|
||||
$template->display('game/erreur.tpl');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
global $template, $page;
|
||||
if (!empty($page)) {
|
||||
$template->assign('page', $page);
|
||||
}
|
||||
$template->assign('message', $message);
|
||||
$template->assign('couleur', 'red');
|
||||
$template->display('game/erreur.tpl');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -5,32 +5,30 @@
|
|||
*/
|
||||
class Groupe
|
||||
{
|
||||
var $contenu = array(); //Tableau contenant les vaisseaux de l'utilisateur
|
||||
var $caracteristiques = array();
|
||||
var $example = array(
|
||||
array("somme boucliers", "somme pv", "nbVaisseauxInitiaux")
|
||||
);
|
||||
var $user; //Classe donnant des informations sur l'utilisateur de la flotte ou l'ID de l'utilisateur
|
||||
var $camp = 0; //Camp du groupe
|
||||
var $timestamp = 0; //TImestamp de la dernière attaque
|
||||
var $actions = array(); //Tableau des actions faite ou à faire
|
||||
var $action_encours = 0;
|
||||
public $contenu = array(); //Tableau contenant les vaisseaux de l'utilisateur
|
||||
public $caracteristiques = array();
|
||||
public $example = array(
|
||||
array("somme boucliers", "somme pv", "nbVaisseauxInitiaux")
|
||||
);
|
||||
public $user; //Classe donnant des informations sur l'utilisateur de la flotte ou l'ID de l'utilisateur
|
||||
public $camp = 0; //Camp du groupe
|
||||
public $timestamp = 0; //TImestamp de la dernière attaque
|
||||
public $actions = array(); //Tableau des actions faite ou à faire
|
||||
public $action_encours = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function regenereBoucliers()
|
||||
{
|
||||
foreach ($this->caracteristiques as $caracteristique)
|
||||
{
|
||||
if ($this->actions[$action_encours][0] == 2)
|
||||
$
|
||||
}
|
||||
}
|
||||
public function regenereBoucliers()
|
||||
{
|
||||
// foreach ($this->caracteristiques as $caracteristique)
|
||||
// {
|
||||
// if ($this->actions[$action_encours][0] == 2)
|
||||
// $
|
||||
// }
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -20,4 +20,3 @@ $PHPMAILER_LANG["connect_host"] = 'Erreur SMTP: Impossible de se connecter au se
|
|||
$PHPMAILER_LANG["file_access"] = 'Accès au fichier impossible: ';
|
||||
$PHPMAILER_LANG["file_open"] = 'File Error: Ne peut ouvrir le fichier: ';
|
||||
$PHPMAILER_LANG["encoding"] = 'Type d\'encodage inconnu : ';
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -7,397 +7,387 @@
|
|||
*/
|
||||
class Rapport
|
||||
{
|
||||
var $type = 0;
|
||||
var $var = array();
|
||||
var $utilA = 0;
|
||||
var $utilB = 0;
|
||||
var $timestamp = 0;
|
||||
public $type = 0;
|
||||
public $var = array();
|
||||
public $utilA = 0;
|
||||
public $utilB = 0;
|
||||
public $timestamp = 0;
|
||||
|
||||
var $titreA = "";
|
||||
var $titreB = "";
|
||||
var $rapportA = "";
|
||||
var $rapportB = "";
|
||||
public $titreA = "";
|
||||
public $titreB = "";
|
||||
public $rapportA = "";
|
||||
public $rapportB = "";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @access protected
|
||||
*/
|
||||
function Rapport($type, $utilA, $utilB, $time)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->utilA = $utilA;
|
||||
$this->utilB = $utilB;
|
||||
$this->timestamp = $time;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
* @access protected
|
||||
*/
|
||||
public function Rapport($type, $utilA, $utilB, $time)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->utilA = $utilA;
|
||||
$this->utilB = $utilB;
|
||||
$this->timestamp = $time;
|
||||
}
|
||||
|
||||
function addInfo($info, $id)
|
||||
{
|
||||
$this->var[$id] = $info;
|
||||
}
|
||||
public function addInfo($info, $id)
|
||||
{
|
||||
$this->var[$id] = $info;
|
||||
}
|
||||
|
||||
function sendRapport()
|
||||
{
|
||||
if (!empty($this->utilA) && !empty($this->rapportA))
|
||||
send_mp($this->utilA->id_user, $this->titreA, $this->rapportA, $this->timestamp);
|
||||
if (!empty($this->utilB) && !empty($this->rapportB))
|
||||
send_mp($this->utilB->id_user, $this->titreB, $this->rapportB, $this->timestamp);
|
||||
}
|
||||
public function sendRapport()
|
||||
{
|
||||
if (!empty($this->utilA) && !empty($this->rapportA)) {
|
||||
send_mp($this->utilA->id_user, $this->titreA, $this->rapportA, $this->timestamp);
|
||||
}
|
||||
if (!empty($this->utilB) && !empty($this->rapportB)) {
|
||||
send_mp($this->utilB->id_user, $this->titreB, $this->rapportB, $this->timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
function send()
|
||||
{
|
||||
if ($this->type == '3')
|
||||
$this->sendCombat();
|
||||
elseif ($this->type == '1')
|
||||
$this->sendTransport();
|
||||
elseif ($this->type == '2')
|
||||
$this->sendColonisation();
|
||||
elseif ($this->type == '4')
|
||||
$this->sendRecyclage();
|
||||
elseif ($this->type == '5')
|
||||
$this->sendEspionnage();
|
||||
elseif ($this->type == '6')
|
||||
$this->sendAlliance();
|
||||
elseif ($this->type == '7')
|
||||
$this->sendAlliance2();
|
||||
}
|
||||
public function send()
|
||||
{
|
||||
if ($this->type == '3') {
|
||||
$this->sendCombat();
|
||||
} elseif ($this->type == '1') {
|
||||
$this->sendTransport();
|
||||
} elseif ($this->type == '2') {
|
||||
$this->sendColonisation();
|
||||
} elseif ($this->type == '4') {
|
||||
$this->sendRecyclage();
|
||||
} elseif ($this->type == '5') {
|
||||
$this->sendEspionnage();
|
||||
} elseif ($this->type == '6') {
|
||||
$this->sendAlliance();
|
||||
} elseif ($this->type == '7') {
|
||||
$this->sendAlliance2();
|
||||
}
|
||||
}
|
||||
|
||||
function sendEspionnage()
|
||||
{
|
||||
global $LANG;
|
||||
public function sendEspionnage()
|
||||
{
|
||||
global $LANG;
|
||||
|
||||
//Différentiation entre les planètes et les astéroides
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$this->titreA = "Rapport d'espionnage de ".$this->var[0]->nom_asteroide." [".$this->var[0]->galaxie.":".$this->var[0]->ss.":A".$this->var[0]->position."]";
|
||||
$this->rapportA = "<strong>Espionnage de ".$this->var[0]->pseudo." sur ".$this->var[0]->nom_asteroide."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":A".$this->var[0]->position."]</strong><br /><br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->titreA = "Rapport d'espionnage de ".$this->var[0]->nom_planete." [".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."]";
|
||||
$this->rapportA = "<strong>Espionnage de ".$this->var[0]->pseudo." sur ".$this->var[0]->nom_planete."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."]</strong><br /><br />";
|
||||
}
|
||||
//Différentiation entre les planètes et les astéroides
|
||||
if (!isset($this->var[0]->nom_planete)) {
|
||||
$this->titreA = "Rapport d'espionnage de ".$this->var[0]->nom_asteroide." [".$this->var[0]->galaxie.":".$this->var[0]->ss.":A".$this->var[0]->position."]";
|
||||
$this->rapportA = "<strong>Espionnage de ".$this->var[0]->pseudo." sur ".$this->var[0]->nom_asteroide."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":A".$this->var[0]->position."]</strong><br /><br />";
|
||||
} else {
|
||||
$this->titreA = "Rapport d'espionnage de ".$this->var[0]->nom_planete." [".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."]";
|
||||
$this->rapportA = "<strong>Espionnage de ".$this->var[0]->pseudo." sur ".$this->var[0]->nom_planete."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."]</strong><br /><br />";
|
||||
}
|
||||
|
||||
if ($this->var[2] < 1)
|
||||
$this->rapportA .= "<em>Nos sondes n'ont pas pu récolter d'informations sur cette planète.</em>";
|
||||
else {
|
||||
//Ressources
|
||||
if ($this->var[2] > 1)
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th colspan=\"2\">Ressources sur la planète :</th></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["metal"]." :</td><td>".$this->var[0]->metal."</td></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["cristal"]." :</td><td>".$this->var[0]->cristal."</td></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["hydrogene"]." :</td><td>".$this->var[0]->hydrogene."</td></tr></table><br />";
|
||||
if ($this->var[2] < 1) {
|
||||
$this->rapportA .= "<em>Nos sondes n'ont pas pu récolter d'informations sur cette planète.</em>";
|
||||
} else {
|
||||
//Ressources
|
||||
if ($this->var[2] > 1) {
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th colspan=\"2\">Ressources sur la planète :</th></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["metal"]." :</td><td>".$this->var[0]->metal."</td></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["cristal"]." :</td><td>".$this->var[0]->cristal."</td></tr><tr><td>".$LANG[$this->var[0]->race]["ressources"]["noms"]["hydrogene"]." :</td><td>".$this->var[0]->hydrogene."</td></tr></table><br />";
|
||||
}
|
||||
|
||||
//Bâtiments
|
||||
if ($this->var[2] > 2)
|
||||
{
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Niveau</th><th>Bâtiment</th></tr>";
|
||||
foreach ($this->var[0]->batiments as $key => $batiment)
|
||||
{
|
||||
$this->rapportA .= "<tr><td>".rand($batiment * (1 - $this->var[1]), $batiment * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["batiments"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
//Bâtiments
|
||||
if ($this->var[2] > 2) {
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Niveau</th><th>Bâtiment</th></tr>";
|
||||
foreach ($this->var[0]->batiments as $key => $batiment) {
|
||||
$this->rapportA .= "<tr><td>".rand($batiment * (1 - $this->var[1]), $batiment * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["batiments"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
|
||||
//Flottes en orbite
|
||||
if ($this->var[2] > 3)
|
||||
{
|
||||
//Flottes en orbite
|
||||
if ($this->var[2] > 3) {
|
||||
}
|
||||
|
||||
}
|
||||
//Flottes au sol
|
||||
if ($this->var[2] > 5) {
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Nombre</th><th>Vaisseaux</th></tr>";
|
||||
foreach ($this->var[0]->vaisseaux as $key => $vaisseau) {
|
||||
$this->rapportA .= "<tr><td>".rand($vaisseau * (1 - $this->var[1]), $vaisseau * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["vaisseaux"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
|
||||
//Flottes au sol
|
||||
if ($this->var[2] > 5)
|
||||
{
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Nombre</th><th>Vaisseaux</th></tr>";
|
||||
foreach ($this->var[0]->vaisseaux as $key => $vaisseau)
|
||||
{
|
||||
$this->rapportA .= "<tr><td>".rand($vaisseau * (1 - $this->var[1]), $vaisseau * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["vaisseaux"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
//Défenses
|
||||
if ($this->var[2] > 4) {
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Nombre</th><th>Défenses</th></tr>";
|
||||
foreach ($this->var[0]->terrestres as $key => $unite) {
|
||||
if (!dTerrestre::type($key)) {
|
||||
$this->rapportA .= "<tr><td>".rand($unite * (1 - $this->var[1]), $unite * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["terrestre"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
}
|
||||
|
||||
//Défenses
|
||||
if ($this->var[2] > 4)
|
||||
{
|
||||
$this->rapportA .= "<table style=\"margin: auto;\"><tr><th>Nombre</th><th>Défenses</th></tr>";
|
||||
foreach ($this->var[0]->terrestres as $key => $unite)
|
||||
{
|
||||
if (!dTerrestre::type($key)) $this->rapportA .= "<tr><td>".rand($unite * (1 - $this->var[1]), $unite * (1 + $this->var[1]))."</td><td>".$LANG[$this->var[0]->race]["terrestre"]["noms_sing"][$key]."</td></tr>";
|
||||
}
|
||||
$this->rapportA .= "</table><br />";
|
||||
}
|
||||
}
|
||||
if ($this->var[3] >= 1) {
|
||||
$this->titreB = "Rapport de contre-espionnage";
|
||||
if (!isset($this->var[0]->nom_planete)) {
|
||||
$this->rapportB = "Nous venons d'apprendre que notre planète : ".$this->var[0]->nom_asteroide."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":A] a été la cible d'un espionnage de la part de ".$this->utilA->pseudo;
|
||||
} else {
|
||||
$this->rapportB = "Nous venons d'apprendre que notre planète : ".$this->var[0]->nom_planete."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."] a été la cible d'un espionnage de la part de ".$this->utilA->pseudo;
|
||||
}
|
||||
}
|
||||
$this->rapportA = $this->rapportA;
|
||||
}
|
||||
|
||||
if ($this->var[3] >= 1)
|
||||
{
|
||||
$this->titreB = "Rapport de contre-espionnage";
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
$this->rapportB = "Nous venons d'apprendre que notre planète : ".$this->var[0]->nom_asteroide."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":A] a été la cible d'un espionnage de la part de ".$this->utilA->pseudo;
|
||||
else
|
||||
$this->rapportB = "Nous venons d'apprendre que notre planète : ".$this->var[0]->nom_planete."[".$this->var[0]->galaxie.":".$this->var[0]->ss.":".$this->var[0]->position."] a été la cible d'un espionnage de la part de ".$this->utilA->pseudo;
|
||||
}
|
||||
$this->rapportA = $this->rapportA;
|
||||
}
|
||||
public function sendTransport()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete)) {
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$this->rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
$this->rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
} else {
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$this->rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
$this->rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
}
|
||||
|
||||
function sendTransport()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$this->rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
$this->rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$titre = 'Transport vers '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$this->rapportA = 'Vos vaisseaux ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilA->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
$this->rapportB = 'Les vaisseaux de '.$this->utilA->pseudo.' ont déposé '.$this->var[1][0].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["metal"].', '.$this->var[1][1].' de '.$LANG[$this->utilB->race]["ressources"]["noms"]["cristal"].' et '.$this->var[1][2].' d\''.$LANG[$this->utilB->race]["ressources"]["noms"]["hydrogene"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($this->rapportA);
|
||||
$db->escape($this->rapportB);
|
||||
|
||||
}
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$this->rapportA', '$temps');");
|
||||
if ($this->utilA->id_user != $this->utilB->id_user) {
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user.", '$titre', '$this->rapportB', '$temps');");
|
||||
}
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($this->rapportA);
|
||||
$db->escape($this->rapportB);
|
||||
public function sendColonisation()
|
||||
{
|
||||
$titre = 'Colonisation de ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].']';
|
||||
if (is_numeric($this->var[0][2])) {
|
||||
if ($this->var[1]) {
|
||||
$rapport = 'Votre vaisseau a atteint la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
} else {
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
} else {
|
||||
if ($this->var[1]) {
|
||||
$rapport = 'Votre vaisseau a atteint l\'astéroide ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
} else {
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
}
|
||||
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$this->rapportA', '$temps');");
|
||||
if ($this->utilA->id_user != $this->utilB->id_user) $db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user.", '$titre', '$this->rapportB', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendColonisation()
|
||||
{
|
||||
$titre = 'Colonisation de ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].']';
|
||||
if (is_numeric($this->var[0][2]))
|
||||
{
|
||||
if ($this->var[1])
|
||||
$rapport = 'Votre vaisseau a atteint la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
else
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->var[1])
|
||||
$rapport = 'Votre vaisseau a atteint l\'astéroide ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] et commence la colonisation.';
|
||||
else
|
||||
$rapport = 'Nous n\'avons pas pu coloniser la planète ['.$this->var[0][0].':'.$this->var[0][1].':'.$this->var[0][2].'] car lorsque nous sommes arrivé sur place, elle était déjà colonisée.';
|
||||
}
|
||||
public function sendRecyclage()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete)) {
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
} else {
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
$temps = $this->timestamp;
|
||||
|
||||
function sendRecyclage()
|
||||
{
|
||||
global $LANG;
|
||||
if (!isset($this->var[0]->nom_planete))
|
||||
{
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_asteroide.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_asteroide.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':A]</b><br /><br />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$titre = 'Recyclage de '.$this->var[0]->nom_planete.' ['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']';
|
||||
$rapport = 'Vos vaisseaux récoltent '.$this->var[1][0].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["metal"].' et '.$this->var[1][1].' de '.$LANG[$this->utilA->race]["ressources"]["noms"]["cristal"].' sur '.$this->var[0]->nom_planete.'['.$this->var[0]->galaxie.':'.$this->var[0]->ss.':'.$this->var[0]->position.']</b><br /><br />';
|
||||
}
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
$temps = $this->timestamp;
|
||||
public function sendCombat()
|
||||
{
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($titre);
|
||||
$db->escape($rapport);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$titre', '$rapport', '$temps');");
|
||||
$db->deconnexion();
|
||||
}
|
||||
$this->rapportA = new Smarty();
|
||||
$this->rapportB = new Smarty();
|
||||
|
||||
function sendCombat(){
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
$this->rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$this->rapportA = new Smarty();
|
||||
$this->rapportB = new Smarty();
|
||||
$this->rapportB->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportB->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportB->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportB->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$this->rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
$this->var[4]['pseudo'] = trouvNom($this->var[4]['id_user']);
|
||||
$this->var[5]['pseudo'] = trouvNom($this->var[5]['id_user']);
|
||||
|
||||
$this->rapportB->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportB->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportB->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportB->cache_dir = _FCORE.'templates/cache/';
|
||||
$this->rapportA->assign('tour', $this->var[3]);
|
||||
$this->rapportA->assign('EN', $this->var[4]);
|
||||
$this->rapportA->assign('flotte', $this->var[5]);
|
||||
$this->rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportA->assign('defenses1', $this->var[2]);
|
||||
$this->rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportA->assign('defenses2', $this->var[9]);
|
||||
|
||||
$this->var[4]['pseudo'] = trouvNom($this->var[4]['id_user']);
|
||||
$this->var[5]['pseudo'] = trouvNom($this->var[5]['id_user']);
|
||||
$this->rapportA->assign('termine', $this->var[6][0]);
|
||||
$this->rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportA->assign('pillage', $this->var[11]);
|
||||
|
||||
$this->rapportA->assign('tour', $this->var[3]);
|
||||
$this->rapportA->assign('EN', $this->var[4]);
|
||||
$this->rapportA->assign('flotte', $this->var[5]);
|
||||
$this->rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportA->assign('defenses1', $this->var[2]);
|
||||
$this->rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportA->assign('defenses2', $this->var[9]);
|
||||
$this->rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportA->assign('defBC', $defense_bc);
|
||||
$this->rapportA->assign('defPV', $defense_pv);
|
||||
$this->rapportA->assign('nextTour', $this->var[10]);
|
||||
|
||||
$this->rapportA->assign('termine', $this->var[6][0]);
|
||||
$this->rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportA->assign('pillage', $this->var[11]);
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('ressources', $ressourc);
|
||||
$this->rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
|
||||
$this->rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportA->assign('defBC', $defense_bc);
|
||||
$this->rapportA->assign('defPV', $defense_pv);
|
||||
$this->rapportA->assign('nextTour', $this->var[10]);
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportA->assign('nomdefEN', $nomterra);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('ressources', $ressourc);
|
||||
$this->rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportA->assign('nomdefEN', $nomterra);
|
||||
|
||||
$this->rapportA = $this->rapportA->fetch('game/ATrapport_combat.tpl');
|
||||
$this->rapportA = $this->rapportA->fetch('game/ATrapport_combat.tpl');
|
||||
|
||||
|
||||
$this->rapportB->assign('tour', $this->var[3]);
|
||||
$this->rapportB->assign('EN', $this->var[4]);
|
||||
$this->rapportB->assign('flotte', $this->var[5]);
|
||||
$this->rapportB->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportB->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportB->assign('defenses1', $this->var[2]);
|
||||
$this->rapportB->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportB->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportB->assign('defenses2', $this->var[9]);
|
||||
$this->rapportB->assign('tour', $this->var[3]);
|
||||
$this->rapportB->assign('EN', $this->var[4]);
|
||||
$this->rapportB->assign('flotte', $this->var[5]);
|
||||
$this->rapportB->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportB->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportB->assign('defenses1', $this->var[2]);
|
||||
$this->rapportB->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportB->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportB->assign('defenses2', $this->var[9]);
|
||||
|
||||
$this->rapportB->assign('termine', $this->var[6][0]);
|
||||
$this->rapportB->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportB->assign('matchnul', $this->var[6][2]);
|
||||
$this->rapportB->assign('pillage', $this->var[11]);
|
||||
$this->rapportB->assign('termine', $this->var[6][0]);
|
||||
$this->rapportB->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportB->assign('matchnul', $this->var[6][2]);
|
||||
$this->rapportB->assign('pillage', $this->var[11]);
|
||||
|
||||
$this->rapportB->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportB->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportB->assign('defBC', $defense_bc);
|
||||
$this->rapportB->assign('defPV', $defense_pv);
|
||||
$this->rapportB->assign('nextTour', $this->var[10]);
|
||||
$this->rapportB->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportB->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportB->assign('defBC', $defense_bc);
|
||||
$this->rapportB->assign('defPV', $defense_pv);
|
||||
$this->rapportB->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportB->assign('ressources', $ressourc);
|
||||
$this->rapportB->assign('nomvaisAT', $nomvaisa);
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportB->assign('ressources', $ressourc);
|
||||
$this->rapportB->assign('nomvaisAT', $nomvaisa);
|
||||
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportB->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportB->assign('nomdefEN', $nomterra);
|
||||
$race = trouvInfo($this->var[4]['id_user'], 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportB->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportB->assign('nomdefEN', $nomterra);
|
||||
|
||||
$this->rapportB = $this->rapportB->fetch('game/ENrapport_combat.tpl');
|
||||
$this->rapportB = $this->rapportB->fetch('game/ENrapport_combat.tpl');
|
||||
|
||||
|
||||
$this->titreA = 'Combat contre '.$this->var[4]['pseudo'];
|
||||
$this->titreB = 'Combat contre '.$this->var[5]['pseudo'];
|
||||
$temps = $this->timestamp;
|
||||
$db = new bdd();
|
||||
$db->connexion();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->titreB);
|
||||
$db->escape($this->rapportA);
|
||||
$db->escape($this->rapportB);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user."', '$this->titreB', '$this->rapportB', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
$this->titreA = 'Combat contre '.$this->var[4]['pseudo'];
|
||||
$this->titreB = 'Combat contre '.$this->var[5]['pseudo'];
|
||||
$temps = $this->timestamp;
|
||||
$db = new bdd();
|
||||
$db->connexion();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->titreB);
|
||||
$db->escape($this->rapportA);
|
||||
$db->escape($this->rapportB);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilB->id_user."', '$this->titreB', '$this->rapportB', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function show(){
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
public function show()
|
||||
{
|
||||
include(_FCORE."../game/vars.php");
|
||||
include_once(_FCORE."../game/function.php");
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
|
||||
$this->rapportA = new Smarty();
|
||||
$this->rapportA = new Smarty();
|
||||
|
||||
$this->rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
$this->rapportA->template_dir = _FCORE.'templates/templates/';
|
||||
$this->rapportA->compile_dir = _FCORE.'templates/templates_c/';
|
||||
$this->rapportA->config_dir = _FCORE.'templates/configs/';
|
||||
$this->rapportA->cache_dir = _FCORE.'templates/cache/';
|
||||
|
||||
$this->rapportA->assign('tour', $this->var[3]);
|
||||
$this->rapportA->assign('EN', $this->var[4]);
|
||||
$this->rapportA->assign('flotte', $this->var[5]);
|
||||
$this->rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportA->assign('defenses1', $this->var[2]);
|
||||
$this->rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportA->assign('defenses2', $this->var[9]);
|
||||
$this->rapportA->assign('tour', $this->var[3]);
|
||||
$this->rapportA->assign('EN', $this->var[4]);
|
||||
$this->rapportA->assign('flotte', $this->var[5]);
|
||||
$this->rapportA->assign('vaisseaux1', $this->var[0]);
|
||||
$this->rapportA->assign('vaisseaux2', $this->var[1]);
|
||||
$this->rapportA->assign('defenses1', $this->var[2]);
|
||||
$this->rapportA->assign('vaisseaux3', $this->var[7]);
|
||||
$this->rapportA->assign('vaisseaux4', $this->var[8]);
|
||||
$this->rapportA->assign('defenses2', $this->var[9]);
|
||||
|
||||
$this->rapportA->assign('termine', $this->var[6][0]);
|
||||
$this->rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportA->assign('pillage', $this->var[11]);
|
||||
$this->rapportA->assign('debris', $this->var[12]);
|
||||
$this->rapportA->assign('infoPLUS', $this->var[14]);
|
||||
//$this->rapportA->assign('infoPLUS2', $this->var[15]);
|
||||
$this->rapportA->assign('termine', $this->var[6][0]);
|
||||
$this->rapportA->assign('attaquantG', $this->var[6][1]);
|
||||
$this->rapportA->assign('pillage', $this->var[11]);
|
||||
$this->rapportA->assign('debris', $this->var[12]);
|
||||
$this->rapportA->assign('infoPLUS', $this->var[14]);
|
||||
//$this->rapportA->assign('infoPLUS2', $this->var[15]);
|
||||
|
||||
$this->rapportA->assign('page', 'simulation');
|
||||
$this->rapportA->assign('enligne', $this->var[13][0]);
|
||||
$this->rapportA->assign('infos', $this->var[13][1]);
|
||||
$this->rapportA->assign('nbinfos', $this->var[13][2]);
|
||||
$this->rapportA->assign('count', $this->var[13][3]);
|
||||
$this->rapportA->assign('version', $this->var[13][4]);
|
||||
$this->rapportA->assign('tpsdejeu', $this->var[13][5]);
|
||||
$this->rapportA->assign('page', 'simulation');
|
||||
$this->rapportA->assign('enligne', $this->var[13][0]);
|
||||
$this->rapportA->assign('infos', $this->var[13][1]);
|
||||
$this->rapportA->assign('nbinfos', $this->var[13][2]);
|
||||
$this->rapportA->assign('count', $this->var[13][3]);
|
||||
$this->rapportA->assign('version', $this->var[13][4]);
|
||||
$this->rapportA->assign('tpsdejeu', $this->var[13][5]);
|
||||
|
||||
$this->rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportA->assign('defBC', $defense_bc);
|
||||
$this->rapportA->assign('defPV', $defense_pv);
|
||||
$this->rapportA->assign('nextTour', $this->var[10]);
|
||||
$this->rapportA->assign('vaisBC', $nomvais_bc);
|
||||
$this->rapportA->assign('vaisPV', $nomvais_pv);
|
||||
$this->rapportA->assign('defBC', $defense_bc);
|
||||
$this->rapportA->assign('defPV', $defense_pv);
|
||||
$this->rapportA->assign('nextTour', $this->var[10]);
|
||||
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('ressources', $ressourc);
|
||||
$this->rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
$this->rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportA->assign('nomdefEN', $nomterra);
|
||||
$this->rapportA->assign('race', $race);
|
||||
$race = trouvInfo($this->utilA, 'race');
|
||||
include(_FCORE."../game/noms.php");
|
||||
$this->rapportA->assign('ressources', $ressourc);
|
||||
$this->rapportA->assign('nomvaisAT', $nomvaisa);
|
||||
$this->rapportA->assign('nomvaisEN', $nomvaisa);
|
||||
array_splice($nomterra, 0, 8);
|
||||
$this->rapportA->assign('nomdefEN', $nomterra);
|
||||
$this->rapportA->assign('race', $race);
|
||||
|
||||
return $this->rapportA->fetch('game/SIMrapport_combat.tpl');
|
||||
return $this->rapportA;
|
||||
}
|
||||
return $this->rapportA->fetch('game/SIMrapport_combat.tpl');
|
||||
return $this->rapportA;
|
||||
}
|
||||
|
||||
function sendAlliance()
|
||||
{
|
||||
$this->titreA = 'Déclaration officielle de votre alliance !';
|
||||
$this->rapportA = 'Félicitations, votre alliance a recueilli suffisament de signature, sa déclaration est maintenant officielle !<br /><br />Vous pouvez dès maintenant administrer votre alliance en vous rendant sur la page Alliance.';
|
||||
public function sendAlliance()
|
||||
{
|
||||
$this->titreA = 'Déclaration officielle de votre alliance !';
|
||||
$this->rapportA = 'Félicitations, votre alliance a recueilli suffisament de signature, sa déclaration est maintenant officielle !<br /><br />Vous pouvez dès maintenant administrer votre alliance en vous rendant sur la page Alliance.';
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
$db = new BDD();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
|
||||
function sendAlliance2()
|
||||
{
|
||||
$this->titreA = 'Fondation de votre alliance !';
|
||||
$this->rapportA = 'Pour terminer la création de votre alliance, trouvez 4 joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature : <a href="?p=alliances&q=signer&i='.$this->var[0].'">http://'.$_SERVER['HTTP_HOST'].'/?p=alliances&q=signer&i='.$this->var[0].'</a>';
|
||||
public function sendAlliance2()
|
||||
{
|
||||
$this->titreA = 'Fondation de votre alliance !';
|
||||
$this->rapportA = 'Pour terminer la création de votre alliance, trouvez 4 joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature : <a href="?p=alliances&q=signer&i='.$this->var[0].'">http://'.$_SERVER['HTTP_HOST'].'/?p=alliances&q=signer&i='.$this->var[0].'</a>';
|
||||
|
||||
$temps = $this->timestamp;
|
||||
$temps = $this->timestamp;
|
||||
|
||||
$db = new BDD();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
$db = new BDD();
|
||||
$db->escape($this->titreA);
|
||||
$db->escape($this->rapportA);
|
||||
$db->query("INSERT INTO ".$this->table." (destinataire, sujet, contenu, temps) VALUES(".$this->utilA->id_user.", '$this->titreA', '$this->rapportA', '$temps')");
|
||||
$db->deconnexion();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -27,26 +27,26 @@ class SMTP
|
|||
* SMTP server port
|
||||
* @var int
|
||||
*/
|
||||
var $SMTP_PORT = 25;
|
||||
public $SMTP_PORT = 25;
|
||||
|
||||
/**
|
||||
* SMTP reply line ending
|
||||
* @var string
|
||||
*/
|
||||
var $CRLF = "\r\n";
|
||||
public $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Sets whether debugging is turned on
|
||||
* @var bool
|
||||
*/
|
||||
var $do_debug; # the level of debug to perform
|
||||
public $do_debug; # the level of debug to perform
|
||||
|
||||
/**#@+
|
||||
* @access private
|
||||
*/
|
||||
var $smtp_conn; # the socket to the server
|
||||
var $error; # error if any on the last call
|
||||
var $helo_rply; # the reply the server sent to us for HELO
|
||||
public $smtp_conn; # the socket to the server
|
||||
public $error; # error if any on the last call
|
||||
public $helo_rply; # the reply the server sent to us for HELO
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +54,8 @@ class SMTP
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function SMTP() {
|
||||
public function SMTP()
|
||||
{
|
||||
$this->smtp_conn = 0;
|
||||
$this->error = null;
|
||||
$this->helo_rply = null;
|
||||
|
|
@ -79,12 +80,13 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Connect($host,$port=0,$tval=30) {
|
||||
public function Connect($host, $port=0, $tval=30)
|
||||
{
|
||||
# set the error val to null so there is no confusion
|
||||
$this->error = null;
|
||||
|
||||
# make sure we are __not__ connected
|
||||
if($this->connected()) {
|
||||
if ($this->connected()) {
|
||||
# ok we are connected! what should we do?
|
||||
# for now we will just give an error saying we
|
||||
# are already connected
|
||||
|
|
@ -93,7 +95,7 @@ class SMTP
|
|||
return false;
|
||||
}
|
||||
|
||||
if(empty($port)) {
|
||||
if (empty($port)) {
|
||||
$port = $this->SMTP_PORT;
|
||||
}
|
||||
|
||||
|
|
@ -104,11 +106,11 @@ class SMTP
|
|||
$errstr, # error message if any
|
||||
$tval); # give up after ? secs
|
||||
# verify we connected properly
|
||||
if(empty($this->smtp_conn)) {
|
||||
if (empty($this->smtp_conn)) {
|
||||
$this->error = array("error" => "Failed to connect to server",
|
||||
"errno" => $errno,
|
||||
"errstr" => $errstr);
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": $errstr ($errno)" . $this->CRLF;
|
||||
}
|
||||
|
|
@ -118,8 +120,9 @@ class SMTP
|
|||
# sometimes the SMTP server takes a little longer to respond
|
||||
# so we will give it a longer timeout for the first read
|
||||
// Windows still does not have support for this timeout function
|
||||
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||
socket_set_timeout($this->smtp_conn, $tval, 0);
|
||||
if (substr(PHP_OS, 0, 3) != "WIN") {
|
||||
socket_set_timeout($this->smtp_conn, $tval, 0);
|
||||
}
|
||||
|
||||
# get any announcement stuff
|
||||
$announce = $this->get_lines();
|
||||
|
|
@ -128,7 +131,7 @@ class SMTP
|
|||
//if(function_exists("socket_set_timeout"))
|
||||
// socket_set_timeout($this->smtp_conn, 0, 100000);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
|
||||
}
|
||||
|
||||
|
|
@ -141,19 +144,20 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Authenticate($username, $password) {
|
||||
public function Authenticate($username, $password)
|
||||
{
|
||||
// Start authentication
|
||||
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "AUTH LOGIN" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($code != 334) {
|
||||
if ($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "AUTH not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -164,14 +168,14 @@ class SMTP
|
|||
fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($code != 334) {
|
||||
if ($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "Username not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -182,14 +186,14 @@ class SMTP
|
|||
fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($code != 235) {
|
||||
if ($code != 235) {
|
||||
$this->error =
|
||||
array("error" => "Password not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -204,13 +208,14 @@ class SMTP
|
|||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function Connected() {
|
||||
if(!empty($this->smtp_conn)) {
|
||||
public function Connected()
|
||||
{
|
||||
if (!empty($this->smtp_conn)) {
|
||||
$sock_status = socket_get_status($this->smtp_conn);
|
||||
if($sock_status["eof"]) {
|
||||
if ($sock_status["eof"]) {
|
||||
# hmm this is an odd situation... the socket is
|
||||
# valid but we aren't connected anymore
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE:" . $this->CRLF .
|
||||
"EOF caught while checking if connected";
|
||||
}
|
||||
|
|
@ -229,10 +234,11 @@ class SMTP
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function Close() {
|
||||
public function Close()
|
||||
{
|
||||
$this->error = null; # so there is no confusion
|
||||
$this->helo_rply = null;
|
||||
if(!empty($this->smtp_conn)) {
|
||||
if (!empty($this->smtp_conn)) {
|
||||
# close the connection and cleanup
|
||||
fclose($this->smtp_conn);
|
||||
$this->smtp_conn = 0;
|
||||
|
|
@ -263,30 +269,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Data($msg_data) {
|
||||
public function Data($msg_data)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Data() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"DATA" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "DATA" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 354) {
|
||||
if ($code != 354) {
|
||||
$this->error =
|
||||
array("error" => "DATA command not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -304,9 +311,9 @@ class SMTP
|
|||
# line. NOTE: this does not count towards are limit.
|
||||
|
||||
# normalize the line breaks so we know the explode works
|
||||
$msg_data = str_replace("\r\n","\n",$msg_data);
|
||||
$msg_data = str_replace("\r","\n",$msg_data);
|
||||
$lines = explode("\n",$msg_data);
|
||||
$msg_data = str_replace("\r\n", "\n", $msg_data);
|
||||
$msg_data = str_replace("\r", "\n", $msg_data);
|
||||
$lines = explode("\n", $msg_data);
|
||||
|
||||
# we need to find a good way to determine is headers are
|
||||
# in the msg_data or if it is a straight msg body
|
||||
|
|
@ -315,43 +322,42 @@ class SMTP
|
|||
# does not contain a space then it _should_ be a header
|
||||
# and we can process all lines before a blank "" line as
|
||||
# headers.
|
||||
$field = substr($lines[0],0,strpos($lines[0],":"));
|
||||
$field = substr($lines[0], 0, strpos($lines[0], ":"));
|
||||
$in_headers = false;
|
||||
if(!empty($field) && !strstr($field," ")) {
|
||||
if (!empty($field) && !strstr($field, " ")) {
|
||||
$in_headers = true;
|
||||
}
|
||||
|
||||
$max_line_length = 998; # used below; set here for ease in change
|
||||
|
||||
while(list(,$line) = @each($lines)) {
|
||||
while (list(, $line) = @each($lines)) {
|
||||
$lines_out = null;
|
||||
if($line == "" && $in_headers) {
|
||||
if ($line == "" && $in_headers) {
|
||||
$in_headers = false;
|
||||
}
|
||||
# ok we need to break this line up into several
|
||||
# smaller lines
|
||||
while(strlen($line) > $max_line_length) {
|
||||
$pos = strrpos(substr($line,0,$max_line_length)," ");
|
||||
$lines_out[] = substr($line,0,$pos);
|
||||
$line = substr($line,$pos + 1);
|
||||
while (strlen($line) > $max_line_length) {
|
||||
$pos = strrpos(substr($line, 0, $max_line_length), " ");
|
||||
$lines_out[] = substr($line, 0, $pos);
|
||||
$line = substr($line, $pos + 1);
|
||||
# if we are processing headers we need to
|
||||
# add a LWSP-char to the front of the new line
|
||||
# rfc 822 on long msg headers
|
||||
if($in_headers) {
|
||||
if ($in_headers) {
|
||||
$line = "\t" . $line;
|
||||
}
|
||||
}
|
||||
$lines_out[] = $line;
|
||||
|
||||
# now send the lines to the server
|
||||
while(list(,$line_out) = @each($lines_out)) {
|
||||
if(strlen($line_out) > 0)
|
||||
{
|
||||
if(substr($line_out, 0, 1) == ".") {
|
||||
while (list(, $line_out) = @each($lines_out)) {
|
||||
if (strlen($line_out) > 0) {
|
||||
if (substr($line_out, 0, 1) == ".") {
|
||||
$line_out = "." . $line_out;
|
||||
}
|
||||
}
|
||||
fputs($this->smtp_conn,$line_out . $this->CRLF);
|
||||
fputs($this->smtp_conn, $line_out . $this->CRLF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -360,18 +366,18 @@ class SMTP
|
|||
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "DATA not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -396,30 +402,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return string array
|
||||
*/
|
||||
function Expand($name) {
|
||||
public function Expand($name)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Expand() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
|
||||
fputs($this->smtp_conn, "EXPN " . $name . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "EXPN not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -427,9 +434,9 @@ class SMTP
|
|||
}
|
||||
|
||||
# parse the reply and place in our array to return to user
|
||||
$entries = explode($this->CRLF,$rply);
|
||||
while(list(,$l) = @each($entries)) {
|
||||
$list[] = substr($l,4);
|
||||
$entries = explode($this->CRLF, $rply);
|
||||
while (list(, $l) = @each($entries)) {
|
||||
$list[] = substr($l, 4);
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
|
@ -447,10 +454,11 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Hello($host="") {
|
||||
public function Hello($host="")
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Hello() without being connected");
|
||||
return false;
|
||||
|
|
@ -458,17 +466,17 @@ class SMTP
|
|||
|
||||
# if a hostname for the HELO wasn't specified determine
|
||||
# a suitable one to send
|
||||
if(empty($host)) {
|
||||
if (empty($host)) {
|
||||
# we need to determine some sort of appopiate default
|
||||
# to send to the server
|
||||
$host = "localhost";
|
||||
}
|
||||
|
||||
// Send extended hello first (RFC 2821)
|
||||
if(!$this->SendHello("EHLO", $host))
|
||||
{
|
||||
if(!$this->SendHello("HELO", $host))
|
||||
if (!$this->SendHello("EHLO", $host)) {
|
||||
if (!$this->SendHello("HELO", $host)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -479,22 +487,23 @@ class SMTP
|
|||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
function SendHello($hello, $host) {
|
||||
public function SendHello($hello, $host)
|
||||
{
|
||||
fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => $hello . " not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -521,35 +530,36 @@ class SMTP
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function Help($keyword="") {
|
||||
public function Help($keyword="")
|
||||
{
|
||||
$this->error = null; # to avoid confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Help() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
$extra = "";
|
||||
if(!empty($keyword)) {
|
||||
if (!empty($keyword)) {
|
||||
$extra = " " . $keyword;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
|
||||
fputs($this->smtp_conn, "HELP" . $extra . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 211 && $code != 214) {
|
||||
if ($code != 211 && $code != 214) {
|
||||
$this->error =
|
||||
array("error" => "HELP not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -573,30 +583,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Mail($from) {
|
||||
public function Mail($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Mail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "MAIL FROM:<" . $from . ">" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "MAIL not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -615,30 +626,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Noop() {
|
||||
public function Noop()
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Noop() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"NOOP" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "NOOP" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "NOOP not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -658,42 +670,43 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Quit($close_on_error=true) {
|
||||
public function Quit($close_on_error=true)
|
||||
{
|
||||
$this->error = null; # so there is no confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Quit() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
# send the quit command to the server
|
||||
fputs($this->smtp_conn,"quit" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "quit" . $this->CRLF);
|
||||
|
||||
# get any good-bye messages
|
||||
$byemsg = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
|
||||
}
|
||||
|
||||
$rval = true;
|
||||
$e = null;
|
||||
|
||||
$code = substr($byemsg,0,3);
|
||||
if($code != 221) {
|
||||
$code = substr($byemsg, 0, 3);
|
||||
if ($code != 221) {
|
||||
# use e as a tmp var cause Close will overwrite $this->error
|
||||
$e = array("error" => "SMTP server rejected quit command",
|
||||
"smtp_code" => $code,
|
||||
"smtp_rply" => substr($byemsg,4));
|
||||
"smtp_rply" => substr($byemsg, 4));
|
||||
$rval = false;
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $e["error"] . ": " .
|
||||
$byemsg . $this->CRLF;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($e) || $close_on_error) {
|
||||
if (empty($e) || $close_on_error) {
|
||||
$this->Close();
|
||||
}
|
||||
|
||||
|
|
@ -712,30 +725,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Recipient($to) {
|
||||
public function Recipient($to)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Recipient() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "RCPT TO:<" . $to . ">" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250 && $code != 251) {
|
||||
if ($code != 250 && $code != 251) {
|
||||
$this->error =
|
||||
array("error" => "RCPT not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -756,30 +770,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Reset() {
|
||||
public function Reset()
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Reset() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RSET" . $this->CRLF);
|
||||
fputs($this->smtp_conn, "RSET" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "RSET failed",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -805,30 +820,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Send($from) {
|
||||
public function Send($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Send() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
|
||||
fputs($this->smtp_conn, "SEND FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SEND not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -853,30 +869,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function SendAndMail($from) {
|
||||
public function SendAndMail($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called SendAndMail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
|
||||
fputs($this->smtp_conn, "SAML FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SAML not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -901,30 +918,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function SendOrMail($from) {
|
||||
public function SendOrMail($from)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called SendOrMail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
|
||||
fputs($this->smtp_conn, "SOML FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
if ($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SOML not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -946,10 +964,11 @@ class SMTP
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function Turn() {
|
||||
public function Turn()
|
||||
{
|
||||
$this->error = array("error" => "This method, TURN, of the SMTP ".
|
||||
"is not implemented");
|
||||
if($this->do_debug >= 1) {
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -968,30 +987,31 @@ class SMTP
|
|||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
function Verify($name) {
|
||||
public function Verify($name)
|
||||
{
|
||||
$this->error = null; # so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
if (!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Verify() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
|
||||
fputs($this->smtp_conn, "VRFY " . $name . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
$code = substr($rply, 0, 3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
if ($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
|
||||
}
|
||||
|
||||
if($code != 250 && $code != 251) {
|
||||
if ($code != 250 && $code != 251) {
|
||||
$this->error =
|
||||
array("error" => "VRFY failed on name '$name'",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
"smtp_msg" => substr($rply, 4));
|
||||
if ($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] .
|
||||
": " . $rply . $this->CRLF;
|
||||
}
|
||||
|
|
@ -1013,27 +1033,26 @@ class SMTP
|
|||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
function get_lines() {
|
||||
public function get_lines()
|
||||
{
|
||||
$data = "";
|
||||
while($str = fgets($this->smtp_conn,515)) {
|
||||
if($this->do_debug >= 4) {
|
||||
while ($str = fgets($this->smtp_conn, 515)) {
|
||||
if ($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data was \"$data\"" .
|
||||
$this->CRLF;
|
||||
echo "SMTP -> get_lines(): \$str is \"$str\"" .
|
||||
$this->CRLF;
|
||||
}
|
||||
$data .= $str;
|
||||
if($this->do_debug >= 4) {
|
||||
if ($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
|
||||
}
|
||||
# if the 4th character is a space then we are done reading
|
||||
# so just break the loop
|
||||
if(substr($str,3,1) == " ") { break; }
|
||||
if (substr($str, 3, 1) == " ") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -11,33 +11,33 @@ include_once("Class/user.php");
|
|||
***************************************************************************/
|
||||
class SURFACE extends User
|
||||
{
|
||||
var $id = 0,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$image,
|
||||
$debris_met,
|
||||
$debris_cri,
|
||||
$metal,
|
||||
$cristal,
|
||||
$hydrogene,
|
||||
$alert_ressources = array(false, false, false),
|
||||
$timestamp,
|
||||
$file_bat,
|
||||
$file_vais,
|
||||
$isolement = false,
|
||||
$batiments = array(),
|
||||
$vaisseaux = array(),
|
||||
$modif = array();
|
||||
public $id = 0;
|
||||
public $galaxie;
|
||||
public $ss;
|
||||
public $image;
|
||||
public $debris_met;
|
||||
public $debris_cri;
|
||||
public $metal;
|
||||
public $cristal;
|
||||
public $hydrogene;
|
||||
public $alert_ressources = array(false, false, false);
|
||||
public $timestamp;
|
||||
public $file_bat;
|
||||
public $file_vais;
|
||||
public $isolement = false;
|
||||
public $batiments = array();
|
||||
public $vaisseaux = array();
|
||||
public $modif = array();
|
||||
|
||||
function isolement()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public function isolement()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
function addModif($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modif))
|
||||
$this->modif[] = $modif;
|
||||
}
|
||||
public function addModif($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modif)) {
|
||||
$this->modif[] = $modif;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,46 +1,41 @@
|
|||
<?php
|
||||
class TinyAsteroide
|
||||
{
|
||||
var $id = 0,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$nom_asteroide;
|
||||
{
|
||||
public $id = 0;
|
||||
public $galaxie;
|
||||
public $ss;
|
||||
public $nom_asteroide;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_alliances;
|
||||
$bdd = new BDD();
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($id)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_alliances;
|
||||
$bdd = new BDD();
|
||||
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de l'asteroide
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$aste = $bdd->unique_query("SELECT id, galaxie, ss, nom_asteroide FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):?[Aa]?\]?$#', $id, $position))
|
||||
{
|
||||
$aste = $bdd->unique_query("SELECT id, galaxie, ss, nom_asteroide FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
trigger_error('Erreur #04 : Format de recherche d\'astéroide incorrect !', E_USER_ERROR);
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de l'asteroide
|
||||
if (is_numeric($id)) {
|
||||
$aste = $bdd->unique_query("SELECT id, galaxie, ss, nom_asteroide FROM $table_alliances WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
} elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):?[Aa]?\]?$#', $id, $position)) {
|
||||
$aste = $bdd->unique_query("SELECT id, galaxie, ss, nom_asteroide FROM $table_alliances WHERE galaxie = ".$position[1]." AND ss = ".$position[2].";");
|
||||
$bdd->deconnexion();
|
||||
} else {
|
||||
trigger_error('Erreur #04 : Format de recherche d\'astéroide incorrect !', E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (!empty($aste))
|
||||
{
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $aste["id"];
|
||||
$this->galaxie = $aste["galaxie"];
|
||||
$this->ss = $aste["ss"];
|
||||
$this->nom_asteroide = $aste["nom_asteroide"];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
if (!empty($aste)) {
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $aste["id"];
|
||||
$this->galaxie = $aste["galaxie"];
|
||||
$this->ss = $aste["ss"];
|
||||
$this->nom_asteroide = $aste["nom_asteroide"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +1,43 @@
|
|||
<?php
|
||||
class TinyPlanete{
|
||||
var $id = 0,
|
||||
$galaxie,
|
||||
$ss,
|
||||
$position,
|
||||
$nom_planete;
|
||||
<?php
|
||||
class TinyPlanete
|
||||
{
|
||||
public $id = 0;
|
||||
public $galaxie;
|
||||
public $ss;
|
||||
public $position;
|
||||
public $nom_planete;
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __construct($id)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_planete;
|
||||
$bdd = new bdd();
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($id)
|
||||
{
|
||||
//Récupération du nom des tables utilisées et connexion à la base de données
|
||||
global $table_planete;
|
||||
$bdd = new bdd();
|
||||
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de la planète
|
||||
if (is_numeric($id))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position))
|
||||
{
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
trigger_error('Erreur #04 : Format de recherche de planete incorrect !', E_USER_ERROR);
|
||||
//On traite le cas où l'on recoit l'ID ou les coordonnées de la planète
|
||||
if (is_numeric($id)) {
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
} elseif (preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', $id, $position)) {
|
||||
$plan = $bdd->unique_query("SELECT id, galaxie, ss, position, nom_planete FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
} else {
|
||||
trigger_error('Erreur #04 : Format de recherche de planete incorrect !', E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (!empty($plan))
|
||||
{
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $plan["id"];
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->position = $plan["position"];
|
||||
$this->nom_planete = $plan["nom_planete"];
|
||||
}
|
||||
}
|
||||
if (!empty($plan)) {
|
||||
//Chargement des données depuis le résultat de la base de données
|
||||
$this->id = $plan["id"];
|
||||
$this->galaxie = $plan["galaxie"];
|
||||
$this->ss = $plan["ss"];
|
||||
$this->position = $plan["position"];
|
||||
$this->nom_planete = $plan["nom_planete"];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -11,201 +11,210 @@ include_once("Class/tinyasteroide.php");
|
|||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
class User{
|
||||
var $id_user,
|
||||
$pseudo,
|
||||
$auth_level,
|
||||
$options,
|
||||
$race,
|
||||
$alliance,
|
||||
$id_alliance,
|
||||
$id_grade_alliance,
|
||||
$permissions_alliance,
|
||||
$mv,
|
||||
$mail,
|
||||
$envoyerMail,
|
||||
$last_visite,
|
||||
$points,
|
||||
$place_points,
|
||||
$technologies = array(),
|
||||
$credits,
|
||||
$politique,
|
||||
$politique_lastchange,
|
||||
$destinationsFavoris,
|
||||
$amis = array(),
|
||||
$combatAT_tactique,
|
||||
$combatDE_tactique,
|
||||
$modifUser = array();
|
||||
class User
|
||||
{
|
||||
public $id_user;
|
||||
public $pseudo;
|
||||
public $auth_level;
|
||||
public $options;
|
||||
public $race;
|
||||
public $alliance;
|
||||
public $id_alliance;
|
||||
public $id_grade_alliance;
|
||||
public $permissions_alliance;
|
||||
public $mv;
|
||||
public $mail;
|
||||
public $envoyerMail;
|
||||
public $last_visite;
|
||||
public $points;
|
||||
public $place_points;
|
||||
public $technologies = array();
|
||||
public $credits;
|
||||
public $politique;
|
||||
public $politique_lastchange;
|
||||
public $destinationsFavoris;
|
||||
public $amis = array();
|
||||
public $combatAT_tactique;
|
||||
public $combatDE_tactique;
|
||||
public $modifUser = array();
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function User($id = 0){
|
||||
if (!empty($id)) {
|
||||
global $technologiesVAR, $table_user;
|
||||
$bdd = new bdd();
|
||||
$bdd->escape($id);
|
||||
$user = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($user)) {
|
||||
$this->id_user = $user["id"];
|
||||
$this->pseudo = $user["pseudo"];
|
||||
$this->auth_level = $user["auth_level"];
|
||||
$this->race = $user["race"];
|
||||
$this->options = @intval($user["options"]);
|
||||
$this->mv = $user["mv"];
|
||||
$this->id_alliance = $user["id_alliance"];
|
||||
$this->id_grade_alliance = $user["id_grade_alliance"];
|
||||
$this->mail = $user["mail"];
|
||||
$this->envoyerMail = $user["envoyerMail"];
|
||||
$this->last_visite = $user["last_visite"];
|
||||
$this->points = $user["points"];
|
||||
$this->place_points = $user["place_points"];
|
||||
$this->credits = $user["credits"];
|
||||
$this->politique = $user["politique"];
|
||||
$this->politique_lastchange = $user["politique_lastchange"];
|
||||
if (!empty($user["amis"])) $this->amis = unserialize($user["amis"]);
|
||||
else $this->amis = array();
|
||||
if (!empty($user["destinationsFavoris"])) $this->destinationsFavoris = unserialize($user["destinationsFavoris"]);
|
||||
else $this->destinationsFavoris = array();
|
||||
$this->combatAT_tactique = $user["combatAT_tactique"];
|
||||
$this->combatDE_tactique = $user["combatDE_tactique"];
|
||||
/**
|
||||
* Constructeur
|
||||
* @param int $id id de la planète à importer
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function User($id = 0)
|
||||
{
|
||||
if (!empty($id)) {
|
||||
global $technologiesVAR, $table_user;
|
||||
$bdd = new bdd();
|
||||
$bdd->escape($id);
|
||||
$user = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($user)) {
|
||||
$this->id_user = $user["id"];
|
||||
$this->pseudo = $user["pseudo"];
|
||||
$this->auth_level = $user["auth_level"];
|
||||
$this->race = $user["race"];
|
||||
$this->options = @intval($user["options"]);
|
||||
$this->mv = $user["mv"];
|
||||
$this->id_alliance = $user["id_alliance"];
|
||||
$this->id_grade_alliance = $user["id_grade_alliance"];
|
||||
$this->mail = $user["mail"];
|
||||
$this->envoyerMail = $user["envoyerMail"];
|
||||
$this->last_visite = $user["last_visite"];
|
||||
$this->points = $user["points"];
|
||||
$this->place_points = $user["place_points"];
|
||||
$this->credits = $user["credits"];
|
||||
$this->politique = $user["politique"];
|
||||
$this->politique_lastchange = $user["politique_lastchange"];
|
||||
if (!empty($user["amis"])) {
|
||||
$this->amis = unserialize($user["amis"]);
|
||||
} else {
|
||||
$this->amis = array();
|
||||
}
|
||||
if (!empty($user["destinationsFavoris"])) {
|
||||
$this->destinationsFavoris = unserialize($user["destinationsFavoris"]);
|
||||
} else {
|
||||
$this->destinationsFavoris = array();
|
||||
}
|
||||
$this->combatAT_tactique = $user["combatAT_tactique"];
|
||||
$this->combatDE_tactique = $user["combatDE_tactique"];
|
||||
|
||||
foreach($technologiesVAR as $tech){
|
||||
$this->technologies[] = intval($user[$tech]);
|
||||
}
|
||||
foreach ($technologiesVAR as $tech) {
|
||||
$this->technologies[] = intval($user[$tech]);
|
||||
}
|
||||
|
||||
//Si l'ID d'alliance est défini, on charge l'alliance
|
||||
if (!empty($this->id_alliance))
|
||||
$this->alliance = new TinyAsteroide($this->id_alliance);
|
||||
}
|
||||
else die('Erreur #01 : Utilisateur recherché introuvable dans la base de données. Contactez le support technique ('.$config['mail_support'].') au plus vite en précisant le code d\'erreur.');
|
||||
}
|
||||
}
|
||||
//Si l'ID d'alliance est défini, on charge l'alliance
|
||||
if (!empty($this->id_alliance)) {
|
||||
$this->alliance = new TinyAsteroide($this->id_alliance);
|
||||
}
|
||||
} else {
|
||||
die('Erreur #01 : Utilisateur recherché introuvable dans la base de données. Contactez le support technique ('.$config['mail_support'].') au plus vite en précisant le code d\'erreur.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadPermissions($fondateur = 0)
|
||||
{
|
||||
if ($fondateur == $this->id_user)
|
||||
$this->permissions_alliance = 1023;
|
||||
else
|
||||
{
|
||||
global $table_alliances_grade;
|
||||
$bdd = new BDD();
|
||||
$grade = $bdd->unique_query("SELECT * FROM $table_alliances_grade WHERE id = ".$this->id_grade_alliance.";");
|
||||
$bdd->deconnexion();
|
||||
public function loadPermissions($fondateur = 0)
|
||||
{
|
||||
if ($fondateur == $this->id_user) {
|
||||
$this->permissions_alliance = 1023;
|
||||
} else {
|
||||
global $table_alliances_grade;
|
||||
$bdd = new BDD();
|
||||
$grade = $bdd->unique_query("SELECT * FROM $table_alliances_grade WHERE id = ".$this->id_grade_alliance.";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$this->permissions_alliance = intval($grade['auth']);
|
||||
}
|
||||
}
|
||||
$this->permissions_alliance = intval($grade['auth']);
|
||||
}
|
||||
}
|
||||
|
||||
function addPoints($metal, $cristal, $hydrogene, $credits = 0, $demolition = false)
|
||||
{
|
||||
global $table_bourse_ressources;
|
||||
//On charge les 3 valeurs boursières
|
||||
$bdd = new BDD();
|
||||
$bourse = $bdd->query("SELECT dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
public function addPoints($metal, $cristal, $hydrogene, $credits = 0, $demolition = false)
|
||||
{
|
||||
global $table_bourse_ressources;
|
||||
//On charge les 3 valeurs boursières
|
||||
$bdd = new BDD();
|
||||
$bourse = $bdd->query("SELECT dispo FROM $table_bourse_ressources;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($credits))
|
||||
{
|
||||
//TODO Equivalence non prouvée entre $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7); et $credits/bourse_calcPrixBase($bourse[0]["dispo"], 1) * 0.7; dans le but de ne donner que 70% des points
|
||||
$metal += $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7);
|
||||
$cristal += $credits/bourse_calcPrixBase($bourse[1]["dispo"], 0.7);
|
||||
$hydrogene += $credits/bourse_calcPrixBase($bourse[2]["dispo"], 0.7);
|
||||
}
|
||||
if (!empty($credits)) {
|
||||
//TODO Equivalence non prouvée entre $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7); et $credits/bourse_calcPrixBase($bourse[0]["dispo"], 1) * 0.7; dans le but de ne donner que 70% des points
|
||||
$metal += $credits/bourse_calcPrixBase($bourse[0]["dispo"], 0.7);
|
||||
$cristal += $credits/bourse_calcPrixBase($bourse[1]["dispo"], 0.7);
|
||||
$hydrogene += $credits/bourse_calcPrixBase($bourse[2]["dispo"], 0.7);
|
||||
}
|
||||
|
||||
$points = bourse_calcPrixBase($bourse[0]["dispo"], $metal);
|
||||
$points += bourse_calcPrixBase($bourse[1]["dispo"], $cristal);
|
||||
$points += bourse_calcPrixBase($bourse[2]["dispo"], $hydrogene);
|
||||
$points = bourse_calcPrixBase($bourse[0]["dispo"], $metal);
|
||||
$points += bourse_calcPrixBase($bourse[1]["dispo"], $cristal);
|
||||
$points += bourse_calcPrixBase($bourse[2]["dispo"], $hydrogene);
|
||||
|
||||
if ($demolition)
|
||||
$this->points -= intval($points);
|
||||
else
|
||||
$this->points += intval($points);
|
||||
if ($demolition) {
|
||||
$this->points -= intval($points);
|
||||
} else {
|
||||
$this->points += intval($points);
|
||||
}
|
||||
|
||||
$this->addModifUser("points");
|
||||
}
|
||||
$this->addModifUser("points");
|
||||
}
|
||||
|
||||
function addCredits($credits)
|
||||
{
|
||||
$this->credits += $credits;
|
||||
$this->addModifUser("credits");
|
||||
public function addCredits($credits)
|
||||
{
|
||||
$this->credits += $credits;
|
||||
$this->addModifUser("credits");
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function addModifUser($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modifUser))
|
||||
$this->modifUser[] = $modif;
|
||||
}
|
||||
public function addModifUser($modif)
|
||||
{
|
||||
if (!in_array($modif, $this->modifUser)) {
|
||||
$this->modifUser[] = $modif;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function __destruct(){
|
||||
global $table_user;
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach($this->modifUser as $key => $modif)
|
||||
{
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif))
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
/**
|
||||
* Destructeur
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
global $table_user;
|
||||
$out = array();
|
||||
$bdd = new BDD();
|
||||
foreach ($this->modifUser as $key => $modif) {
|
||||
//On gère les champs variables tableaux
|
||||
if (is_array($modif)) {
|
||||
$calc = dDonnees::nameVAR($modif[0]);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
if (empty(${$calc.'VAR'}))
|
||||
trigger_error('Impossible de trouver les données pour '.$modif[0], E_USER_ERROR);
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
if (empty(${$calc.'VAR'})) {
|
||||
trigger_error('Impossible de trouver les données pour '.$modif[0], E_USER_ERROR);
|
||||
}
|
||||
|
||||
$out[] = ${$calc.'VAR'}[$modif[1]]." = ".$this->{$modif[0]}[$modif[1]];
|
||||
}
|
||||
elseif ($modif == "force")
|
||||
$out[] = " ";
|
||||
elseif (!is_array($this->{$modif}))
|
||||
{
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif})) $out[] .= $modif." = ".$this->{$modif};
|
||||
else $out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments")
|
||||
{
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $modif." = '$prep'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
$out[] = ${$calc.'VAR'}[$modif[1]]." = ".$this->{$modif[0]}[$modif[1]];
|
||||
} elseif ($modif == "force") {
|
||||
$out[] = " ";
|
||||
} elseif (!is_array($this->{$modif})) {
|
||||
$bdd->escape($this->{$modif});
|
||||
if (is_int($this->{$modif}) || is_float($this->{$modif})) {
|
||||
$out[] .= $modif." = ".$this->{$modif};
|
||||
} else {
|
||||
$out[] .= $modif." = '".$this->{$modif}."'";
|
||||
}
|
||||
} else {
|
||||
if ($modif != "coeff_bat" && $modif != "vaisseaux" && $modif != "terrestres" && $modif != "casernes" && $modif != "technologies" && $modif != "batiments") {
|
||||
$prep = serialize($this->{$modif});
|
||||
$bdd->escape($prep);
|
||||
$out[] = $modif." = '$prep'";
|
||||
} else {
|
||||
$calc = dDonnees::nameVAR($modif);
|
||||
|
||||
if (!isset(${$calc.'VAR'}))
|
||||
global ${$calc.'VAR'};
|
||||
if (!isset(${$calc.'VAR'})) {
|
||||
global ${$calc.'VAR'};
|
||||
}
|
||||
|
||||
foreach($this->{$modif} as $j => $value)
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out))
|
||||
{
|
||||
$sql = "UPDATE $table_user SET ".implode(', ', $out)." WHERE id = ".$this->id_user.";";
|
||||
if (DEBUG)
|
||||
echo '<br /><br />'.$sql;
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1)
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out)." avec l'ID ".$this->id_user, 2);
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
foreach ($this->{$modif} as $j => $value) {
|
||||
$out[] = ${$calc.'VAR'}[$j]." = ".$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($out)) {
|
||||
$sql = "UPDATE $table_user SET ".implode(', ', $out)." WHERE id = ".$this->id_user.";";
|
||||
if (DEBUG) {
|
||||
echo '<br /><br />'.$sql;
|
||||
}
|
||||
$bdd->query($sql);
|
||||
if ($bdd->affected() != 1) {
|
||||
elog($bdd->affected()." champ(s) affecté(s) par la requête du fichier ".__FILE__." à la ligne ".__LINE__.", données : out = ".serialize($out)." avec l'ID ".$this->id_user, 2);
|
||||
}
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$pagea = 'accueil';
|
||||
$titre = 'Accueil administration';
|
||||
|
|
@ -13,4 +16,3 @@ $bdd->deconnexion();
|
|||
$template->assign('nbMail', $mail['nombre']);
|
||||
$template->assign('nbPilori', $pilori['nombre']);
|
||||
$template->assign('news', $news);
|
||||
?>
|
||||
|
|
@ -1,52 +1,51 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'print';
|
||||
$titre = 'Vérification alliance';
|
||||
|
||||
$template->assign('linkpage', 'valliances');
|
||||
$template->assign('linkpage', 'valliances');
|
||||
|
||||
if (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] != 'id') {
|
||||
$pagea = 'print_key';
|
||||
$id_plan = $_GET['id'];
|
||||
$key = $_GET['key'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->escape($key);
|
||||
$reqA = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$req = $chapeau->unique_query("DESCRIBE $table_alliances $key;");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $reqA);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $_GET['key']);
|
||||
$pagea = 'print_key';
|
||||
$id_plan = $_GET['id'];
|
||||
$key = $_GET['key'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->escape($key);
|
||||
$reqA = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$req = $chapeau->unique_query("DESCRIBE $table_alliances $key;");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $reqA);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $_GET['key']);
|
||||
} elseif (!empty($_GET['id'])) {
|
||||
$id_plan = $_GET['id'];
|
||||
if (isset($_POST['key']) && isset($_POST['mod'])) {
|
||||
$key = $_POST['key'];
|
||||
$mod = $_POST['mod'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($mod);
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->query("UPDATE $table_alliances SET $key = '$mod' WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
}
|
||||
$chapeau->connexion();
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
} elseif (!empty($_GET['name'])) {
|
||||
$name = $_GET['name'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($name);
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE nom = '$name';");
|
||||
$chapeau->deconnexion();
|
||||
header('Location: admin.php?p=valliances&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
elseif (!empty($_GET['id'])) {
|
||||
$id_plan = $_GET['id'];
|
||||
if (isset($_POST['key']) && isset($_POST['mod'])) {
|
||||
$key = $_POST['key'];
|
||||
$mod = $_POST['mod'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($mod);
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->query("UPDATE $table_alliances SET $key = '$mod' WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
}
|
||||
$chapeau->connexion();
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
}
|
||||
elseif (!empty($_GET['name'])) {
|
||||
$name = $_GET['name'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($name);
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE nom = '$name';");
|
||||
$chapeau->deconnexion();
|
||||
header('Location: admin.php?p=valliances&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,74 +1,69 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'bandeau';
|
||||
$titre = 'Bandeau d\'information';
|
||||
|
||||
//Ajout d'une information
|
||||
if (!empty($_GET['i']) && $_GET['i'] == 'add' && !empty($_POST['texte']) && isset($_POST['color']))
|
||||
{
|
||||
$texte = gpc('texte', 'post');
|
||||
$color = gpc('color', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($texte);
|
||||
$bdd->escape($color);
|
||||
$bdd->query("INSERT INTO $table_infoshead (texte, color) VALUES ('$texte', '$color');");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($_GET['i']) && $_GET['i'] == 'add' && !empty($_POST['texte']) && isset($_POST['color'])) {
|
||||
$texte = gpc('texte', 'post');
|
||||
$color = gpc('color', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($texte);
|
||||
$bdd->escape($color);
|
||||
$bdd->query("INSERT INTO $table_infoshead (texte, color) VALUES ('$texte', '$color');");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
}
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
}
|
||||
//Modification
|
||||
elseif (!empty($_GET['i']))
|
||||
{
|
||||
$id = intval(gpc('i'));
|
||||
if (!empty($_POST['texte']) && isset($_POST['color']))
|
||||
{
|
||||
$texte = gpc('texte', 'post');
|
||||
$color = gpc('color', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($texte);
|
||||
$bdd->escape($color);
|
||||
$bdd->query("UPDATE $table_infoshead SET texte = '$texte', color = '$color' WHERE id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_infoshead WHERE id = '$id';");
|
||||
$reqTT = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id ASC;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('mod', $req);
|
||||
$template->assign('tableau', $reqTT);
|
||||
$template->assign('id', $id);
|
||||
}
|
||||
elseif (!empty($_GET['i'])) {
|
||||
$id = intval(gpc('i'));
|
||||
if (!empty($_POST['texte']) && isset($_POST['color'])) {
|
||||
$texte = gpc('texte', 'post');
|
||||
$color = gpc('color', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($texte);
|
||||
$bdd->escape($color);
|
||||
$bdd->query("UPDATE $table_infoshead SET texte = '$texte', color = '$color' WHERE id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_infoshead WHERE id = '$id';");
|
||||
$reqTT = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id ASC;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('mod', $req);
|
||||
$template->assign('tableau', $reqTT);
|
||||
$template->assign('id', $id);
|
||||
}
|
||||
//Demande de suppression
|
||||
elseif (!empty($_GET['d']))
|
||||
{
|
||||
$id = intval(gpc('d'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_infoshead WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
}
|
||||
elseif (!empty($_GET['d'])) {
|
||||
$id = intval(gpc('d'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_infoshead WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
}
|
||||
//Demande de mise à jour du cache
|
||||
elseif (isset($_GET['actuCache']))
|
||||
{
|
||||
Cache::del('headerNB');
|
||||
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Récupération des lignes du bandeau
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id ASC;");
|
||||
$bdd->deconnexion();
|
||||
elseif (isset($_GET['actuCache'])) {
|
||||
Cache::del('headerNB');
|
||||
|
||||
header('Location: admin.php?p=bandeau');
|
||||
exit;
|
||||
} else {
|
||||
//Récupération des lignes du bandeau
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id ASC;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('id', "add");
|
||||
}
|
||||
?>
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('id', "add");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,26 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($_POST["req"]))
|
||||
$req = stripslashes(gpc("req", "post"));
|
||||
elseif (!empty($_GET["req"]))
|
||||
$req = gpc("req");
|
||||
else
|
||||
$req = "SHOW TABLES;";
|
||||
if (!empty($_POST["req"])) {
|
||||
$req = stripslashes(gpc("req", "post"));
|
||||
} elseif (!empty($_GET["req"])) {
|
||||
$req = gpc("req");
|
||||
} else {
|
||||
$req = "SHOW TABLES;";
|
||||
}
|
||||
|
||||
$bdd = new BDD();
|
||||
$template->assign("reponses", $bdd->query($req));
|
||||
$template->assign("erreur", $bdd->erreur());
|
||||
$template->assign("affected", $bdd->affected());
|
||||
$bdd->deconnexion();
|
||||
$bdd = new BDD();
|
||||
$template->assign("reponses", $bdd->query($req));
|
||||
$template->assign("erreur", $bdd->erreur());
|
||||
$template->assign("affected", $bdd->affected());
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (preg_match("#show tables#i", $req))
|
||||
$template->assign("lien", "SELECT * FROM ");
|
||||
if (preg_match("#show tables#i", $req)) {
|
||||
$template->assign("lien", "SELECT * FROM ");
|
||||
}
|
||||
|
||||
$pagea = 'bdd';
|
||||
$titre = 'Administration de la base de données';
|
||||
?>
|
||||
|
|
@ -1,73 +1,68 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'demarrage';
|
||||
$titre = 'Page de démarrage';
|
||||
|
||||
if (!empty($_GET['i']) && $_GET['i'] == 'add' && !empty($_POST['contenu']) && isset($_POST['titre']))
|
||||
{
|
||||
$titre = gpc('titre', 'post');
|
||||
$contenu = gpc('contenu', 'post');
|
||||
$time = time();
|
||||
$bdd = new BDD();
|
||||
$bdd ->escape($titre);
|
||||
$bdd ->escape($contenu);
|
||||
$bdd ->query("INSERT INTO $table_messages_demarrage (titre, contenu, time) VALUES ('$titre', '$contenu', $time);");
|
||||
$bdd ->deconnexion();
|
||||
if (!empty($_GET['i']) && $_GET['i'] == 'add' && !empty($_POST['contenu']) && isset($_POST['titre'])) {
|
||||
$titre = gpc('titre', 'post');
|
||||
$contenu = gpc('contenu', 'post');
|
||||
$time = time();
|
||||
$bdd = new BDD();
|
||||
$bdd ->escape($titre);
|
||||
$bdd ->escape($contenu);
|
||||
$bdd ->query("INSERT INTO $table_messages_demarrage (titre, contenu, time) VALUES ('$titre', '$contenu', $time);");
|
||||
$bdd ->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
}
|
||||
elseif (!empty($_GET['i']))
|
||||
{
|
||||
$id = intval(gpc('i'));
|
||||
if (!empty($_POST['contenu']) && isset($_POST['titre']))
|
||||
{
|
||||
$titre = gpc('titre', 'post');
|
||||
$texte = gpc('contenu', 'post');
|
||||
$time = time();
|
||||
$reset = gpc('reset', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($titre);
|
||||
$bdd->escape($texte);
|
||||
if (!empty($reset))
|
||||
$bdd->query("UPDATE $table_messages_demarrage SET contenu = '$texte', titre = '$titre', time = $time WHERE id = $id;");
|
||||
else
|
||||
$bdd->query("UPDATE $table_messages_demarrage SET contenu = '$texte', titre = '$titre' WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
} elseif (!empty($_GET['i'])) {
|
||||
$id = intval(gpc('i'));
|
||||
if (!empty($_POST['contenu']) && isset($_POST['titre'])) {
|
||||
$titre = gpc('titre', 'post');
|
||||
$texte = gpc('contenu', 'post');
|
||||
$time = time();
|
||||
$reset = gpc('reset', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($titre);
|
||||
$bdd->escape($texte);
|
||||
if (!empty($reset)) {
|
||||
$bdd->query("UPDATE $table_messages_demarrage SET contenu = '$texte', titre = '$titre', time = $time WHERE id = $id;");
|
||||
} else {
|
||||
$bdd->query("UPDATE $table_messages_demarrage SET contenu = '$texte', titre = '$titre' WHERE id = $id;");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$template->assign('mod', $bdd->unique_query("SELECT * FROM $table_messages_demarrage WHERE id = '$id';"));
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_messages_demarrage;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', $id);
|
||||
}
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$template->assign('mod', $bdd->unique_query("SELECT * FROM $table_messages_demarrage WHERE id = '$id';"));
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_messages_demarrage;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', $id);
|
||||
}
|
||||
//Suppression d'un message
|
||||
elseif (!empty($_GET['d']))
|
||||
{
|
||||
$id = intval(gpc('d'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_messages_demarrage WHERE id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
}
|
||||
elseif (!empty($_GET['d'])) {
|
||||
$id = intval(gpc('d'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_messages_demarrage WHERE id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
}
|
||||
//Demande de mise à jour du cache
|
||||
elseif (isset($_GET['actuCache']))
|
||||
{
|
||||
Cache::del('headerNB');
|
||||
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_messages_demarrage;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', 'add');
|
||||
}
|
||||
?>
|
||||
elseif (isset($_GET['actuCache'])) {
|
||||
Cache::del('headerNB');
|
||||
|
||||
header('Location: admin.php?p=demarrage');
|
||||
exit;
|
||||
} else {
|
||||
$bdd = new BDD();
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_messages_demarrage;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', 'add');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,32 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'vflotte';
|
||||
$titre = 'Vérification flottes';
|
||||
|
||||
//Vérification des flottes
|
||||
if (!isset($_GET['ceil'])) $_GET['ceil'] = 5000;
|
||||
if (!isset($_GET['ceil'])) {
|
||||
$_GET['ceil'] = 5000;
|
||||
}
|
||||
|
||||
$bdd = new BDD();
|
||||
$res = $bdd->query("SELECT * FROM `$table_flottes` ORDER BY `start_time` DESC");
|
||||
$bdd->deconnexion();
|
||||
$tableau = array();
|
||||
if (isset($resultat))
|
||||
foreach($resultat as $res) {
|
||||
$user_source = infoPlan($resultat['end_galaxie'], $resultat['end_ss'], $resultat['end_position'], 'id_user');
|
||||
if ($resultat['contenu_metal'] + $resultat['contenu_cristal'] + $resultat['contenu_hydrogene'] >= $_GET['ceil']) $color = 'FF0000';
|
||||
elseif ($user_source != $resultat['id_user']) $color = 'DFBF00';
|
||||
else $color = false;
|
||||
$tableau[] = array(trouvNom($user_source), trouvNom($resultat['id_user']), infoPlan($resultat['start_galaxie'], $resultat['start_ss'], $resultat['start_position'], 'nom_planete'), '['.$resultat['start_galaxie'].':'.$resultat['start_ss'].':'.$resultat['start_position'].']', infoPlan($resultat['end_galaxie'], $resultat['end_ss'], $resultat['end_position'], 'nom_planete'), '['.$resultat['end_galaxie'].':'.$resultat['end_ss'].':'.$resultat['end_position'].']', $resultat['start_time'], '<acronym title="!!!Détail vaisseaux">'.$resultat['nb_vais'].'</acronym>', $resultat['vitesse'], $resultat['contenu_metal'], $resultat['contenu_cristal'], $resultat['contenu_hydrogene'], $color);
|
||||
if (isset($resultat)) {
|
||||
foreach ($resultat as $res) {
|
||||
$user_source = infoPlan($resultat['end_galaxie'], $resultat['end_ss'], $resultat['end_position'], 'id_user');
|
||||
if ($resultat['contenu_metal'] + $resultat['contenu_cristal'] + $resultat['contenu_hydrogene'] >= $_GET['ceil']) {
|
||||
$color = 'FF0000';
|
||||
} elseif ($user_source != $resultat['id_user']) {
|
||||
$color = 'DFBF00';
|
||||
} else {
|
||||
$color = false;
|
||||
}
|
||||
$tableau[] = array(trouvNom($user_source), trouvNom($resultat['id_user']), infoPlan($resultat['start_galaxie'], $resultat['start_ss'], $resultat['start_position'], 'nom_planete'), '['.$resultat['start_galaxie'].':'.$resultat['start_ss'].':'.$resultat['start_position'].']', infoPlan($resultat['end_galaxie'], $resultat['end_ss'], $resultat['end_position'], 'nom_planete'), '['.$resultat['end_galaxie'].':'.$resultat['end_ss'].':'.$resultat['end_position'].']', $resultat['start_time'], '<acronym title="!!!Détail vaisseaux">'.$resultat['nb_vais'].'</acronym>', $resultat['vitesse'], $resultat['contenu_metal'], $resultat['contenu_cristal'], $resultat['contenu_hydrogene'], $color);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('flottes', $tableau);
|
||||
?>
|
||||
|
|
@ -1,30 +1,27 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$titre = "Création d'inscription";
|
||||
$pagea = "inscription";
|
||||
|
||||
if (!empty($_POST["HB_pseudo"]) && !empty($_POST["race"]))
|
||||
{
|
||||
if (empty($_POST["HB_conf"]) && empty($_POST["HB_mdp"]))
|
||||
$_POST["HB_mdp"] = $_POST["HB_conf"] = gen_mdp(9);
|
||||
if (!empty($_POST["HB_pseudo"]) && !empty($_POST["race"])) {
|
||||
if (empty($_POST["HB_conf"]) && empty($_POST["HB_mdp"])) {
|
||||
$_POST["HB_mdp"] = $_POST["HB_conf"] = gen_mdp(9);
|
||||
}
|
||||
|
||||
if ($_POST['HB_conf'] == $_POST['HB_mdp'] && !empty($_POST['HB_mdp']))
|
||||
{
|
||||
$_POST['HB_mdp'] = cxor(gpc("HB_mdp", "post"), sha1(gpc("HB_pseudo", "post").'£'.gpc("race", "post")));
|
||||
$cds = sha1(gpc("HB_pseudo", "post").'$'.gpc("race", "post").'£'.gpc("HB_mdp", "post").'#'.gpc("HB_mail", "post").'ß'.time().'Ó'.$_SERVER['HTTP_USER_AGENT'].'♀☻'.$_SERVER['REMOTE_ADDR'].gpc("HB_placement", "post"));
|
||||
if (empty($_POST['mailler']))
|
||||
erreur('MDP: <em>'.gpc("HB_conf", "post").'</em><br />URL : <a href="?p=njoueur&nom='.gpc("HB_pseudo", "post").'&race='.gpc("race", "post").'&mdp='.strhex(gpc("HB_mdp", "post")).'&mail='.gpc("HB_mail", "post").'&ti='.time().'&placement='.gpc("HB_placement", "post").'&cds='.$cds.'">Lien</a><br /><br />L\'inscription doit avoir lieu par vous même en raison des procédures de sécurités !', "white");
|
||||
else
|
||||
{
|
||||
if (send_mail(gpc("HB_mail", "post"), "Halo-Battle :: Inscription sur le serveur ".$VAR['serveur_name'], "Bonjour ".gpc("HB_pseudo", "post")." et bienvenue dans l'univers d'Halo-Battle !\n\nNous sommes ravi de vous annoncer qu'un opérateur vient de vous créer un compte sur le serveur ".$VAR['serveur_name'].".\n\nVoici le mot de passe qui vous servira à vous connecter à ce serveur : ".gpc("HB_conf", "post")."\n\nA bientôt,\nLe staff de Halo-Battle"))
|
||||
{
|
||||
|
||||
}
|
||||
header('Location: admin.php?p=njoueur&nom='.gpc("HB_pseudo", "post").'&race='.gpc("race", "post").'&mdp='.strhex(gpc("HB_mdp", "post")).'&mail='.gpc("HB_mail", "post").'&ti='.time().'&placement='.gpc("HB_placement", "post").'&cds='.$cds);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
erreur('Mot de passe incorrect !');
|
||||
if ($_POST['HB_conf'] == $_POST['HB_mdp'] && !empty($_POST['HB_mdp'])) {
|
||||
$_POST['HB_mdp'] = cxor(gpc("HB_mdp", "post"), sha1(gpc("HB_pseudo", "post").'£'.gpc("race", "post")));
|
||||
$cds = sha1(gpc("HB_pseudo", "post").'$'.gpc("race", "post").'£'.gpc("HB_mdp", "post").'#'.gpc("HB_mail", "post").'ß'.time().'Ó'.$_SERVER['HTTP_USER_AGENT'].'♀☻'.$_SERVER['REMOTE_ADDR'].gpc("HB_placement", "post"));
|
||||
if (empty($_POST['mailler'])) {
|
||||
erreur('MDP: <em>'.gpc("HB_conf", "post").'</em><br />URL : <a href="?p=njoueur&nom='.gpc("HB_pseudo", "post").'&race='.gpc("race", "post").'&mdp='.strhex(gpc("HB_mdp", "post")).'&mail='.gpc("HB_mail", "post").'&ti='.time().'&placement='.gpc("HB_placement", "post").'&cds='.$cds.'">Lien</a><br /><br />L\'inscription doit avoir lieu par vous même en raison des procédures de sécurités !', "white");
|
||||
} else {
|
||||
if (send_mail(gpc("HB_mail", "post"), "Halo-Battle :: Inscription sur le serveur ".$VAR['serveur_name'], "Bonjour ".gpc("HB_pseudo", "post")." et bienvenue dans l'univers d'Halo-Battle !\n\nNous sommes ravi de vous annoncer qu'un opérateur vient de vous créer un compte sur le serveur ".$VAR['serveur_name'].".\n\nVoici le mot de passe qui vous servira à vous connecter à ce serveur : ".gpc("HB_conf", "post")."\n\nA bientôt,\nLe staff de Halo-Battle")) {
|
||||
}
|
||||
header('Location: admin.php?p=njoueur&nom='.gpc("HB_pseudo", "post").'&race='.gpc("race", "post").'&mdp='.strhex(gpc("HB_mdp", "post")).'&mail='.gpc("HB_mail", "post").'&ti='.time().'&placement='.gpc("HB_placement", "post").'&cds='.$cds);
|
||||
}
|
||||
} else {
|
||||
erreur('Mot de passe incorrect !');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,61 +1,63 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'vip';
|
||||
$titre = 'Vérification IP';
|
||||
|
||||
$timelimit = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d"), date("Y"))); //2008-06-17 18:15:00
|
||||
$page = gpc('v');
|
||||
if (empty($page) || !is_numeric($page))
|
||||
$page = 0;
|
||||
if (empty($page) || !is_numeric($page)) {
|
||||
$page = 0;
|
||||
}
|
||||
|
||||
$act = gpc('act');
|
||||
if ($act == 'multiok')
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$user = intval(gpc('util'));
|
||||
$bdd->query("UPDATE $table_user SET multi = '1' WHERE id = ".$user.";");
|
||||
$bdd->deconnexion();
|
||||
unset($user);
|
||||
if ($act == 'multiok') {
|
||||
$bdd = new BDD();
|
||||
$user = intval(gpc('util'));
|
||||
$bdd->query("UPDATE $table_user SET multi = '1' WHERE id = ".$user.";");
|
||||
$bdd->deconnexion();
|
||||
unset($user);
|
||||
}
|
||||
|
||||
$trace = 'absent pour plus de rapidité';
|
||||
|
||||
$bdd = new BDD();
|
||||
if (isset($_GET['ip']))
|
||||
{
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE ip = '".gpc('ip')."' ORDER BY ip ASC;");
|
||||
$trace = gethostbyaddr($req[0]['ip']);
|
||||
if (isset($_GET['ip'])) {
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE ip = '".gpc('ip')."' ORDER BY ip ASC;");
|
||||
$trace = gethostbyaddr($req[0]['ip']);
|
||||
} elseif (isset($_GET['util']) && isset($_GET['comp'])) {
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE id_util = ".intval(gpc('util'))." OR id_util = ".intval(gpc('comp'))." ORDER BY ip ASC;");
|
||||
} elseif (isset($_GET['util'])) {
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE id_util = '".intval(gpc('util'))."' ORDER BY ip ASC;");
|
||||
} elseif (isset($_GET['tri'])) {
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id ORDER BY ".gpc('tri')." ASC;");
|
||||
} else {
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE R.time > '$timelimit 00:00:00' ORDER BY R.ip ASC LIMIT ".($page*75).",75;");
|
||||
}
|
||||
elseif (isset($_GET['util']) && isset($_GET['comp']))
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE id_util = ".intval(gpc('util'))." OR id_util = ".intval(gpc('comp'))." ORDER BY ip ASC;");
|
||||
elseif (isset($_GET['util']))
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE id_util = '".intval(gpc('util'))."' ORDER BY ip ASC;");
|
||||
elseif (isset($_GET['tri']))
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id ORDER BY ".gpc('tri')." ASC;");
|
||||
else
|
||||
$req = $bdd->query("SELECT R.id, R.id_util, R.time, R.ip, U.pseudo, U.mv, U.multi FROM $table_registre_identification R INNER JOIN $table_user U ON R.id_util = U.id WHERE R.time > '$timelimit 00:00:00' ORDER BY R.ip ASC LIMIT ".($page*75).",75;");
|
||||
//SELECT last_ip,COUNT(*) FROM user GROUP BY last_ip HAVING COUNT(*)>1
|
||||
$nbpage = $bdd->unique_query("SELECT COUNT(id) AS nb FROM $table_registre_identification WHERE time > '$timelimit 00:00:00';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$anc = array('ip' => 0, 'id_util' => 0);
|
||||
$tableau = array();
|
||||
if (isset($resultat))
|
||||
foreach($req as $resultat)
|
||||
{
|
||||
if ($resultat['mv'] == 3)
|
||||
$color = 'DFBF00';
|
||||
elseif ($resultat['multi'] == 1 && $anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util'])
|
||||
$color = 'EE66EE';
|
||||
elseif ($anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util'])
|
||||
$color = 'FF0000';
|
||||
else
|
||||
$color = false;
|
||||
if (isset($resultat)) {
|
||||
foreach ($req as $resultat) {
|
||||
if ($resultat['mv'] == 3) {
|
||||
$color = 'DFBF00';
|
||||
} elseif ($resultat['multi'] == 1 && $anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util']) {
|
||||
$color = 'EE66EE';
|
||||
} elseif ($anc['ip'] == $resultat['ip'] && $anc['id_util'] != $resultat['id_util']) {
|
||||
$color = 'FF0000';
|
||||
} else {
|
||||
$color = false;
|
||||
}
|
||||
|
||||
$tableau[] = array($resultat['ip'], $trace, $resultat['id_util'], $resultat['pseudo'], $resultat['time'], $resultat['mv'], $color);
|
||||
$anc = $resultat;
|
||||
$tableau[] = array($resultat['ip'], $trace, $resultat['id_util'], $resultat['pseudo'], $resultat['time'], $resultat['mv'], $color);
|
||||
$anc = $resultat;
|
||||
}
|
||||
}
|
||||
$template->assign('ips', $tableau);
|
||||
$template->assign('numpage', $page);
|
||||
$template->assign('nbpage', floor($nbpage['nb']/75));
|
||||
?>
|
||||
|
|
@ -1,98 +1,94 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'print';
|
||||
$titre = 'Vérification joueur';
|
||||
|
||||
$template->assign('linkpage', 'vjoueurs');
|
||||
$template->assign('linkpage', 'vjoueurs');
|
||||
|
||||
//Changement du nom d'utilisateur
|
||||
if (!empty($_GET['id']) && !empty($_POST['key']) && !empty($_POST['mod']) && $_POST['key'] == 'pseudo')
|
||||
{
|
||||
$id_plan = intval(gpc('id'));
|
||||
$mod = gpc('mod', 'post');
|
||||
if (!empty($_GET['id']) && !empty($_POST['key']) && !empty($_POST['mod']) && $_POST['key'] == 'pseudo') {
|
||||
$id_plan = intval(gpc('id'));
|
||||
$mod = gpc('mod', 'post');
|
||||
|
||||
$liste = "abcdefghijklmnopqrstuvwxyz./!*123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$code = '';
|
||||
while(strlen($code) <= 8)
|
||||
$code .= $liste[rand(0,64)];
|
||||
$liste = "abcdefghijklmnopqrstuvwxyz./!*123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$code = '';
|
||||
while (strlen($code) <= 8) {
|
||||
$code .= $liste[rand(0, 64)];
|
||||
}
|
||||
|
||||
$mdp = mdp($mod, $code);
|
||||
$mdp = mdp($mod, $code);
|
||||
|
||||
$bdd = new BDD();
|
||||
$reqMail = $bdd->unique_query("SELECT mail FROM $table_user WHERE id = $id_plan;");
|
||||
$bdd->escape($mod);
|
||||
$reqPseudo = $bdd->query("SELECT mail FROM $table_user WHERE pseudo = '$mod';");
|
||||
if ($reqPseudo !== NULL)
|
||||
erreur('Nom d\'utilisateur déjà utilisé. Impossible de faire le changement !');
|
||||
$bdd->query("UPDATE $table_user SET pseudo = '$mod', mdp = '".$mdp[0]."', mdp_var = '".$mdp[1]."' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$bdd = new BDD();
|
||||
$reqMail = $bdd->unique_query("SELECT mail FROM $table_user WHERE id = $id_plan;");
|
||||
$bdd->escape($mod);
|
||||
$reqPseudo = $bdd->query("SELECT mail FROM $table_user WHERE pseudo = '$mod';");
|
||||
if ($reqPseudo !== null) {
|
||||
erreur('Nom d\'utilisateur déjà utilisé. Impossible de faire le changement !');
|
||||
}
|
||||
$bdd->query("UPDATE $table_user SET pseudo = '$mod', mdp = '".$mdp[0]."', mdp_var = '".$mdp[1]."' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if(send_mail($reqMail['mail'], "Nouveau nom d'utilisateur", "Bonjour ".$mod.",\n\nVous recevez ce mail suite au changement de votre nom d'utilisateur sur le serveur ".$VAR["serveur_name"].".\nCe changement a été effectué par un opérateur de la galaxie, sur votre demande ou dans le cadre des règles du jeu.\nDe plus, pour votre sécurité, un nouveau mot de passe vous a été automatiquement attribué.\n\nVos nouvelles informations personnelles sont les suivantes :\n\tNom d'utilisateur : ".$mod."\n\tMot de passe : '.$code.'\n\nVotre ancien nom d'utilisateur et mot de passe ne sont plus valide à partir de maintenant et vous devez utiliser les données ci-dessus pour vous connecter.\n\nSi vous rencontrez des problèmes suites à ce changement, n'hésitez pas à contacter l'opérateur qui suivit votre demande.\n\nPour votre sécurité, nous vous rappelons qu'il est dangeureux de conserver un mail contenant des données personnelles. Pensez donc à supprimer ce mail une fois que vous vous serez connecté au jeu.\n\nL'équipe d'Halo-Battle"))
|
||||
erreur("Nom d'utilisateur mis à jour avec succès. Un mail a été envoyé à l'utilisateur contenant un nouveau mot de passe.", "green");
|
||||
else
|
||||
erreur("Une erreur est survenue lors de l'envoie du mail.");
|
||||
}
|
||||
if (send_mail($reqMail['mail'], "Nouveau nom d'utilisateur", "Bonjour ".$mod.",\n\nVous recevez ce mail suite au changement de votre nom d'utilisateur sur le serveur ".$VAR["serveur_name"].".\nCe changement a été effectué par un opérateur de la galaxie, sur votre demande ou dans le cadre des règles du jeu.\nDe plus, pour votre sécurité, un nouveau mot de passe vous a été automatiquement attribué.\n\nVos nouvelles informations personnelles sont les suivantes :\n\tNom d'utilisateur : ".$mod."\n\tMot de passe : '.$code.'\n\nVotre ancien nom d'utilisateur et mot de passe ne sont plus valide à partir de maintenant et vous devez utiliser les données ci-dessus pour vous connecter.\n\nSi vous rencontrez des problèmes suites à ce changement, n'hésitez pas à contacter l'opérateur qui suivit votre demande.\n\nPour votre sécurité, nous vous rappelons qu'il est dangeureux de conserver un mail contenant des données personnelles. Pensez donc à supprimer ce mail une fois que vous vous serez connecté au jeu.\n\nL'équipe d'Halo-Battle")) {
|
||||
erreur("Nom d'utilisateur mis à jour avec succès. Un mail a été envoyé à l'utilisateur contenant un nouveau mot de passe.", "green");
|
||||
} else {
|
||||
erreur("Une erreur est survenue lors de l'envoie du mail.");
|
||||
}
|
||||
}
|
||||
//Changement du mot de passe
|
||||
elseif (!empty($_GET['id']) && !empty($_POST['key']) && !empty($_POST['mod']) && $_POST['key'] == 'mdp')
|
||||
{
|
||||
$id_plan = intval(gpc('id'));
|
||||
$mod = gpc('mod', 'post');
|
||||
elseif (!empty($_GET['id']) && !empty($_POST['key']) && !empty($_POST['mod']) && $_POST['key'] == 'mdp') {
|
||||
$id_plan = intval(gpc('id'));
|
||||
$mod = gpc('mod', 'post');
|
||||
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT pseudo, mdp_var FROM $table_user WHERE id = $id_plan;");
|
||||
$mdp = mdp($req["pseudo"], $mod, $req["mdp_var"]);
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT pseudo, mdp_var FROM $table_user WHERE id = $id_plan;");
|
||||
$mdp = mdp($req["pseudo"], $mod, $req["mdp_var"]);
|
||||
|
||||
$bdd->query("UPDATE $table_user SET mdp = '$mdp' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$bdd->query("UPDATE $table_user SET mdp = '$mdp' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
erreur("Mot de passe changé avec succès.<br />Pensez à avertir l'utilisateur de ce changement !", "green");
|
||||
}
|
||||
elseif (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] != 'id' && $_GET['key'] != 'mdpNOUV' && $_GET['key'] != 'auth_level' && $_GET['key'] != 'mdp_var')
|
||||
{
|
||||
$pagea = 'print_key';
|
||||
$id_plan = intval(gpc('id'));
|
||||
$key = gpc('key');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($key);
|
||||
$reqJ = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_plan;");
|
||||
$req = $bdd->unique_query("DESCRIBE $table_user $key;");
|
||||
$bdd->deconnexion();
|
||||
erreur("Mot de passe changé avec succès.<br />Pensez à avertir l'utilisateur de ce changement !", "green");
|
||||
} elseif (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] != 'id' && $_GET['key'] != 'mdpNOUV' && $_GET['key'] != 'auth_level' && $_GET['key'] != 'mdp_var') {
|
||||
$pagea = 'print_key';
|
||||
$id_plan = intval(gpc('id'));
|
||||
$key = gpc('key');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($key);
|
||||
$reqJ = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_plan;");
|
||||
$req = $bdd->unique_query("DESCRIBE $table_user $key;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('tableau', $reqJ);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $key);
|
||||
}
|
||||
elseif (!empty($_GET['id']))
|
||||
{
|
||||
$id_plan = intval(gpc('id'));
|
||||
if (isset($_POST['key']) && isset($_POST['mod']))
|
||||
{
|
||||
$key = gpc('key', 'post');
|
||||
$mod = gpc('mod', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($mod);
|
||||
$bdd->escape($key);
|
||||
$bdd->query("UPDATE $table_user SET $key = '$mod' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('tableau', $reqJ);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $key);
|
||||
} elseif (!empty($_GET['id'])) {
|
||||
$id_plan = intval(gpc('id'));
|
||||
if (isset($_POST['key']) && isset($_POST['mod'])) {
|
||||
$key = gpc('key', 'post');
|
||||
$mod = gpc('mod', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($mod);
|
||||
$bdd->escape($key);
|
||||
$bdd->query("UPDATE $table_user SET $key = '$mod' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
}
|
||||
elseif (!empty($_GET['name']))
|
||||
{
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
header('Location: admin.php?p=vjoueurs&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
$pagea = 'print_choixU';
|
||||
?>
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
} elseif (!empty($_GET['name'])) {
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
header('Location: admin.php?p=vjoueurs&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,49 +1,57 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'mail_liste';
|
||||
$titre = 'Demandes et problèmes de la galaxie';
|
||||
|
||||
$template->assign('linkpage', 'courrier');
|
||||
$template->assign('linkpage', 'courrier');
|
||||
|
||||
if (!empty($_GET['w']) || !empty($_GET['x'])) {
|
||||
if (!empty($_GET['w'])) $id = $_GET['w'];
|
||||
else $id = $_GET['x'];
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$req = $bdd->unique_query("SELECT $table_user.pseudo, $table_ope_mail.statut, $table_ope_mail.time, $table_ope_mail.titre, $table_ope_mail.contenu, $table_ope_mail.id FROM $table_ope_mail INNER JOIN $table_user ON $table_user.id = $table_ope_mail.id_user WHERE $table_ope_mail.id = '$id';");
|
||||
if ($req['statut'] >= 6) $bdd->query("UPDATE $table_ope_mail SET statut = '0' WHERE id = '$id';");
|
||||
else $bdd->query("UPDATE $table_ope_mail SET statut = statut + 1 WHERE id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($_GET['w'])) {
|
||||
$id = $_GET['w'];
|
||||
} else {
|
||||
$id = $_GET['x'];
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$req = $bdd->unique_query("SELECT $table_user.pseudo, $table_ope_mail.statut, $table_ope_mail.time, $table_ope_mail.titre, $table_ope_mail.contenu, $table_ope_mail.id FROM $table_ope_mail INNER JOIN $table_user ON $table_user.id = $table_ope_mail.id_user WHERE $table_ope_mail.id = '$id';");
|
||||
if ($req['statut'] >= 6) {
|
||||
$bdd->query("UPDATE $table_ope_mail SET statut = '0' WHERE id = '$id';");
|
||||
} else {
|
||||
$bdd->query("UPDATE $table_ope_mail SET statut = statut + 1 WHERE id = '$id';");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (isset($_GET['x'])) header('Location: admin.php?p=courrier&v='.$id);
|
||||
else header('Location: admin.php?p=courrier');
|
||||
exit;
|
||||
}
|
||||
elseif (!empty($_GET['v'])) {
|
||||
$id = $_GET['v'];
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$req = $bdd->unique_query("SELECT $table_user.pseudo, $table_ope_mail.statut, $table_ope_mail.time, $table_ope_mail.titre, $table_ope_mail.contenu, $table_ope_mail.id FROM $table_ope_mail INNER JOIN $table_user ON $table_user.id = $table_ope_mail.id_user WHERE $table_ope_mail.id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
if (isset($_GET['x'])) {
|
||||
header('Location: admin.php?p=courrier&v='.$id);
|
||||
} else {
|
||||
header('Location: admin.php?p=courrier');
|
||||
}
|
||||
exit;
|
||||
} elseif (!empty($_GET['v'])) {
|
||||
$id = $_GET['v'];
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$req = $bdd->unique_query("SELECT $table_user.pseudo, $table_ope_mail.statut, $table_ope_mail.time, $table_ope_mail.titre, $table_ope_mail.contenu, $table_ope_mail.id FROM $table_ope_mail INNER JOIN $table_user ON $table_user.id = $table_ope_mail.id_user WHERE $table_ope_mail.id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('req', $req);
|
||||
$template->assign('id', $id);
|
||||
$pagea = 'mail_view';
|
||||
}
|
||||
elseif (!empty($_GET['d']) && $sess->level >= 5) {
|
||||
$id = $_GET['d'];
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$bdd->query("DELETE FROM $table_ope_mail WHERE id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('req', $req);
|
||||
$template->assign('id', $id);
|
||||
$pagea = 'mail_view';
|
||||
} elseif (!empty($_GET['d']) && $sess->level >= 5) {
|
||||
$id = $_GET['d'];
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($id);
|
||||
$bdd->query("DELETE FROM $table_ope_mail WHERE id = '$id';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=courrier');
|
||||
exit;
|
||||
header('Location: admin.php?p=courrier');
|
||||
exit;
|
||||
} else {
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT $table_user.pseudo, $table_ope_mail.statut, $table_ope_mail.time, $table_ope_mail.titre, $table_ope_mail.contenu, $table_ope_mail.id FROM $table_ope_mail INNER JOIN $table_user ON $table_user.id = $table_ope_mail.id_user ORDER BY $table_ope_mail.time DESC;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('mails', $req);
|
||||
}
|
||||
else {
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT $table_user.pseudo, $table_ope_mail.statut, $table_ope_mail.time, $table_ope_mail.titre, $table_ope_mail.contenu, $table_ope_mail.id FROM $table_ope_mail INNER JOIN $table_user ON $table_user.id = $table_ope_mail.id_user ORDER BY $table_ope_mail.time DESC;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('mails', $req);
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,24 +1,25 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'mail_mass';
|
||||
$titre = 'Envoie de mail en masse aux joueurs de la galaxie';
|
||||
|
||||
$template->assign('linkpage', 'mail_mass');
|
||||
$template->assign('linkpage', 'mail_mass');
|
||||
|
||||
if (!empty($_POST['sujet']) || !empty($_POST['message'])) {
|
||||
$sujet = "Halo-Battle :: ".gpc('sujet', 'post');
|
||||
$message = gpc('message', 'post');
|
||||
$bdd = new BDD();
|
||||
$users = $bdd->query("SELECT pseudo, mail FROM $table_user;");
|
||||
$bdd->deconnexion();
|
||||
$sujet = "Halo-Battle :: ".gpc('sujet', 'post');
|
||||
$message = gpc('message', 'post');
|
||||
$bdd = new BDD();
|
||||
$users = $bdd->query("SELECT pseudo, mail FROM $table_user;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
foreach($users as $user)
|
||||
{
|
||||
$messageJ = str_replace('$pseudo', $user["pseudo"], $message);
|
||||
send_mail($user["mail"], $sujet, $messageJ);
|
||||
//print 'Mail : '.$user["mail"].' ; sujet : '.$sujet.' ; message : '.$messageJ.'<br />';
|
||||
}
|
||||
foreach ($users as $user) {
|
||||
$messageJ = str_replace('$pseudo', $user["pseudo"], $message);
|
||||
send_mail($user["mail"], $sujet, $messageJ);
|
||||
//print 'Mail : '.$user["mail"].' ; sujet : '.$sujet.' ; message : '.$messageJ.'<br />';
|
||||
}
|
||||
|
||||
erreur("Tous les mails ont été envoyés avec succès.", "green");
|
||||
erreur("Tous les mails ont été envoyés avec succès.", "green");
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,77 +1,69 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'print';
|
||||
$titre = 'Vérification planète';
|
||||
|
||||
$template->assign('linkpage', 'vplanetes');
|
||||
$template->assign('linkpage', 'vplanetes');
|
||||
|
||||
if (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] == 'hash_planete')
|
||||
{
|
||||
$id_plan = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("UPDATE $table_planete SET hash_planete = SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)) WHERE id = $id_plan;");
|
||||
if (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] == 'hash_planete') {
|
||||
$id_plan = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("UPDATE $table_planete SET hash_planete = SHA1(CONCAT('g',planete.galaxie,'s',planete.ss,'p',planete.position)) WHERE id = $id_plan;");
|
||||
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
}
|
||||
elseif (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] != 'id')
|
||||
{
|
||||
$pagea = 'print_key';
|
||||
$id_plan = intval(gpc('id'));
|
||||
$key = intval(gpc('key'));
|
||||
$bdd = new BDD();
|
||||
$reqp = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id_plan;");
|
||||
$req = $bdd->unique_query("DESCRIBE $table_planete $key;");
|
||||
$bdd->deconnexion();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
} elseif (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] != 'id') {
|
||||
$pagea = 'print_key';
|
||||
$id_plan = intval(gpc('id'));
|
||||
$key = intval(gpc('key'));
|
||||
$bdd = new BDD();
|
||||
$reqp = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id_plan;");
|
||||
$req = $bdd->unique_query("DESCRIBE $table_planete $key;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('tableau', $reqp);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $_GET['key']);
|
||||
}
|
||||
elseif (!empty($_GET['id']))
|
||||
{
|
||||
$id_plan = intval(gpc('id'));
|
||||
if (isset($_POST['key']) && isset($_POST['mod']) && $_POST['key'] != 'id')
|
||||
{
|
||||
$key = gpc('key', 'post');
|
||||
$mod = gpc('mod', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($key);
|
||||
$bdd->escape($mod);
|
||||
$bdd->query("UPDATE $table_planete SET $key = '$mod' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
}
|
||||
elseif (isset($_GET['amas']) && isset($_GET['ss']) && !empty($_GET['pos']))
|
||||
{
|
||||
$amas = intval(gpc('amas'));
|
||||
$ss = intval(gpc('ss'));
|
||||
$pos = intval(gpc('pos'));
|
||||
$template->assign('tableau', $reqp);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $_GET['key']);
|
||||
} elseif (!empty($_GET['id'])) {
|
||||
$id_plan = intval(gpc('id'));
|
||||
if (isset($_POST['key']) && isset($_POST['mod']) && $_POST['key'] != 'id') {
|
||||
$key = gpc('key', 'post');
|
||||
$mod = gpc('mod', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($key);
|
||||
$bdd->escape($mod);
|
||||
$bdd->query("UPDATE $table_planete SET $key = '$mod' WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_planete WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
} elseif (isset($_GET['amas']) && isset($_GET['ss']) && !empty($_GET['pos'])) {
|
||||
$amas = intval(gpc('amas'));
|
||||
$ss = intval(gpc('ss'));
|
||||
$pos = intval(gpc('pos'));
|
||||
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_planete WHERE galaxie = $amas AND ss = $ss AND position = $pos;");
|
||||
$bdd->deconnexion();
|
||||
header('Location: '.$VAR["menu"]["vplanetes"].'&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
elseif (isset($_GET['format']))
|
||||
{
|
||||
preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', gpc('format'), $position);
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_planete WHERE galaxie = $amas AND ss = $ss AND position = $pos;");
|
||||
$bdd->deconnexion();
|
||||
header('Location: '.$VAR["menu"]["vplanetes"].'&id='.$req['id']);
|
||||
exit;
|
||||
} elseif (isset($_GET['format'])) {
|
||||
preg_match('#^\[?([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\]?$#', gpc('format'), $position);
|
||||
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
header('Location: '.$VAR["menu"]["vplanetes"].'&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
$pagea = 'print_choixP';
|
||||
?>
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_planete WHERE galaxie = ".$position[1]." AND ss = ".$position[2]." AND position = ".$position[3].";");
|
||||
$bdd->deconnexion();
|
||||
header('Location: '.$VAR["menu"]["vplanetes"].'&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'print_choixP';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,42 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$titre = 'Prise de contrôle d\'un joueur';
|
||||
$pagea = 'erreur';
|
||||
|
||||
$template->assign('linkpage', 'cjoueurs');
|
||||
$template->assign('linkpage', 'cjoueurs');
|
||||
|
||||
if ($SESS->level >= 5 && !empty($_GET['id']))
|
||||
{
|
||||
$name = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT id, pseudo, auth_level FROM $table_user WHERE id = $name;");
|
||||
$bdd->deconnexion();
|
||||
if ($req['auth_level'] >= $SESS->level)
|
||||
$template->assign('message', 'Vous ne pouvez pas prendre le contrôle de cet utilisateur !');
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$reqPl = $bdd->unique_query("SELECT id, nom_planete FROM $table_planete WHERE id_user = '".$req['id']."' LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($SESS->level >= 5 && !empty($_GET['id'])) {
|
||||
$name = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT id, pseudo, auth_level FROM $table_user WHERE id = $name;");
|
||||
$bdd->deconnexion();
|
||||
if ($req['auth_level'] >= $SESS->level) {
|
||||
$template->assign('message', 'Vous ne pouvez pas prendre le contrôle de cet utilisateur !');
|
||||
} else {
|
||||
$bdd->reconnexion();
|
||||
$reqPl = $bdd->unique_query("SELECT id, nom_planete FROM $table_planete WHERE id_user = '".$req['id']."' LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (empty($SESS->values['souscontrole'])) $SESS->values['souscontrole'] = array($SESS->values['id'], $SESS->values['idPlan']);
|
||||
$SESS->values['id'] = $req['id'];
|
||||
$SESS->values['idPlan'] = $reqPl['id'];
|
||||
$SESS->put();
|
||||
if (empty($SESS->values['souscontrole'])) {
|
||||
$SESS->values['souscontrole'] = array($SESS->values['id'], $SESS->values['idPlan']);
|
||||
}
|
||||
$SESS->values['id'] = $req['id'];
|
||||
$SESS->values['idPlan'] = $reqPl['id'];
|
||||
$SESS->put();
|
||||
|
||||
$template->assign('message', 'Vous contrôlez maintenant le joueur '.$req['pseudo'].'.<br />Planète '.$reqPl['nom_planete'].' sélectionnée !');
|
||||
}
|
||||
}
|
||||
elseif (!empty($_GET['name']))
|
||||
{
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
header('Location: admin.php?p=cjoueurs&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
$pagea = 'print_choixU';
|
||||
?>
|
||||
$template->assign('message', 'Vous contrôlez maintenant le joueur '.$req['pseudo'].'.<br />Planète '.$reqPl['nom_planete'].' sélectionnée !');
|
||||
}
|
||||
} elseif (!empty($_GET['name'])) {
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
header('Location: admin.php?p=cjoueurs&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'vide';
|
||||
$titre = 'Mise à jour de la liste des proxys';
|
||||
|
||||
function traiterfichier($uri, &$list)
|
||||
{
|
||||
$fp = fopen($uri, "r");
|
||||
while (!feof($fp))
|
||||
{
|
||||
$buffer = fgets($fp);
|
||||
if (preg_match("#^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}#", $buffer, $match))
|
||||
$list[] = $match[0];
|
||||
//$list[] = substr($buffer, 0, strpos($buffer, ":"));
|
||||
}
|
||||
fclose($fp);
|
||||
$fp = fopen($uri, "r");
|
||||
while (!feof($fp)) {
|
||||
$buffer = fgets($fp);
|
||||
if (preg_match("#^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}#", $buffer, $match)) {
|
||||
$list[] = $match[0];
|
||||
}
|
||||
//$list[] = substr($buffer, 0, strpos($buffer, ":"));
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
$list = array();
|
||||
|
|
@ -39,4 +42,3 @@ $bdd->query("INSERT INTO proxy_list VALUES ('".implode("'),('", $list)."');");
|
|||
$bdd->deconnexion();
|
||||
|
||||
erreur("Procédure terminée, ".count($list)." proxys listés.", "green");
|
||||
?>
|
||||
|
|
@ -1,31 +1,31 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'rapports';
|
||||
$titre = 'Afficher les rapports d\'un joueur';
|
||||
|
||||
$template->assign('linkpage', 'vrapports');
|
||||
$template->assign('linkpage', 'vrapports');
|
||||
|
||||
if (!empty($_GET['id']))
|
||||
{
|
||||
$id_user = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT * FROM $table_mail WHERE destinataire = $id_user AND expediteur = '' ORDER BY temps DESC;");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($_GET['id'])) {
|
||||
$id_user = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT * FROM $table_mail WHERE destinataire = $id_user AND expediteur = '' ORDER BY temps DESC;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_user);
|
||||
$template->assign('script', '<script>for (j=0; document.getElementsByName(j)[0]; j++) hide(document.getElementsByName(j)[0]);</script>');
|
||||
}
|
||||
elseif (!empty($_GET['name'])) {
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_user WHERE pseudo = '".$name."';");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_user);
|
||||
$template->assign('script', '<script>for (j=0; document.getElementsByName(j)[0]; j++) hide(document.getElementsByName(j)[0]);</script>');
|
||||
} elseif (!empty($_GET['name'])) {
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_user WHERE pseudo = '".$name."';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=vrapports&id='.$req['id']);
|
||||
exit;
|
||||
header('Location: admin.php?p=vrapports&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
else
|
||||
$pagea = 'print_choixU';
|
||||
?>
|
||||
|
|
@ -1,45 +1,41 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$titre = 'Sanction joueur';
|
||||
$pagea = 'erreur';
|
||||
|
||||
$template->assign('linkpage', 'sjoueurs');
|
||||
$template->assign('linkpage', 'sjoueurs');
|
||||
|
||||
if (!empty($_GET['id']) && !empty($_GET['sanc']) && (!empty($_GET['raisonmv']) || $_GET['sanc'] < 0))
|
||||
{
|
||||
$raisonmv = gpc('raisonmv');
|
||||
$id_plan = intval(gpc('id'));
|
||||
$sanc = gpc('sanc');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($raisonmv);
|
||||
|
||||
if ($sanc == 'definitif' || $sanc== 'définitif' || $sanc == 'd')
|
||||
{
|
||||
$bdd->query("UPDATE $table_user SET mv = '3', raisonmv = '$raisonmv', operateurmv = $id_user WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($_GET['id']) && !empty($_GET['sanc']) && (!empty($_GET['raisonmv']) || $_GET['sanc'] < 0)) {
|
||||
$raisonmv = gpc('raisonmv');
|
||||
$id_plan = intval(gpc('id'));
|
||||
$sanc = gpc('sanc');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($raisonmv);
|
||||
|
||||
if ($sanc == 'definitif' || $sanc== 'définitif' || $sanc == 'd') {
|
||||
$bdd->query("UPDATE $table_user SET mv = '3', raisonmv = '$raisonmv', operateurmv = $id_user WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('message', 'Le joueur a été banni définitivement !');
|
||||
}
|
||||
else
|
||||
{
|
||||
$time = time() + $sanc * 86400 - 259200;
|
||||
$bdd->query("UPDATE $table_user SET mv = '2', last_visite = $time, raisonmv = '$raisonmv', operateurmv = $id_user WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('message', 'Le joueur a été banni définitivement !');
|
||||
} else {
|
||||
$time = time() + $sanc * 86400 - 259200;
|
||||
$bdd->query("UPDATE $table_user SET mv = '2', last_visite = $time, raisonmv = '$raisonmv', operateurmv = $id_user WHERE id = $id_plan;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('message', 'Le joueur a été placé en mode vacances !');
|
||||
}
|
||||
}
|
||||
elseif (!empty($_GET['name']) && !empty($_GET['sanc']) && isset($_GET['raisonmv']))
|
||||
{
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('message', 'Le joueur a été placé en mode vacances !');
|
||||
}
|
||||
} elseif (!empty($_GET['name']) && !empty($_GET['sanc']) && isset($_GET['raisonmv'])) {
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT id FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: '.$VAR["menu"]["sjoueur"].'&sanc='.gpc('sanc').'&raisonmv='.gpc('raisonmv').'&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
$pagea = 'sanctionU_choix';
|
||||
?>
|
||||
header('Location: '.$VAR["menu"]["sjoueur"].'&sanc='.gpc('sanc').'&raisonmv='.gpc('raisonmv').'&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'sanctionU_choix';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,54 +1,53 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'print';
|
||||
$titre = 'Vue des futurs alliances';
|
||||
|
||||
$template->assign('linkpage', 'snalliances');
|
||||
$template->assign('linkpage', 'snalliances');
|
||||
|
||||
//TODO tout est à faire
|
||||
|
||||
if (!empty($_GET['id']) && !empty($_GET['key']) && $_GET['key'] != 'id') {
|
||||
$pagea = 'print_key';
|
||||
$id_plan = $_GET['id'];
|
||||
$key = $_GET['key'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->escape($key);
|
||||
$reqA = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$req = $chapeau->unique_query("DESCRIBE $table_alliances $key;");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $reqA);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $_GET['key']);
|
||||
$pagea = 'print_key';
|
||||
$id_plan = $_GET['id'];
|
||||
$key = $_GET['key'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->escape($key);
|
||||
$reqA = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$req = $chapeau->unique_query("DESCRIBE $table_alliances $key;");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $reqA);
|
||||
$template->assign('type', explode('(', $req['Type']));
|
||||
$template->assign('idPlan', $id_plan);
|
||||
$template->assign('key', $_GET['key']);
|
||||
} elseif (!empty($_GET['id'])) {
|
||||
$id_plan = $_GET['id'];
|
||||
if (isset($_POST['key']) && isset($_POST['mod'])) {
|
||||
$key = $_POST['key'];
|
||||
$mod = $_POST['mod'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($mod);
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->query("UPDATE $table_alliances SET $key = '$mod' WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
}
|
||||
$chapeau->connexion();
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
} elseif (!empty($_GET['name'])) {
|
||||
$name = $_GET['name'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($name);
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE nom = '$name';");
|
||||
$chapeau->deconnexion();
|
||||
header('Location: admin.php?p=valliances&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
elseif (!empty($_GET['id'])) {
|
||||
$id_plan = $_GET['id'];
|
||||
if (isset($_POST['key']) && isset($_POST['mod'])) {
|
||||
$key = $_POST['key'];
|
||||
$mod = $_POST['mod'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($mod);
|
||||
$chapeau->escape($id_plan);
|
||||
$chapeau->query("UPDATE $table_alliances SET $key = '$mod' WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
}
|
||||
$chapeau->connexion();
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE id = '$id_plan';");
|
||||
$chapeau->deconnexion();
|
||||
$template->assign('tableau', $req);
|
||||
$template->assign('idPlan', $id_plan);
|
||||
}
|
||||
elseif (!empty($_GET['name'])) {
|
||||
$name = $_GET['name'];
|
||||
$chapeau->connexion();
|
||||
$chapeau->escape($name);
|
||||
$req = $chapeau->unique_query("SELECT * FROM $table_alliances WHERE nom = '$name';");
|
||||
$chapeau->deconnexion();
|
||||
header('Location: admin.php?p=valliances&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,41 +1,37 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$titre = '!!! Supprimer joueur !!!';
|
||||
$pagea = 'erreur';
|
||||
|
||||
$template->assign('linkpage', 'djoueurs');
|
||||
$template->assign('linkpage', 'djoueurs');
|
||||
|
||||
if ($SESS->level >= 5 && !empty($_GET['id']))
|
||||
{
|
||||
$id = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id;");
|
||||
if ($req && $req["auth_level"] < 4)
|
||||
{
|
||||
$bdd->query("DELETE FROM $table_mail WHERE destinataire = $id;");
|
||||
$bdd->query("DELETE FROM $table_user WHERE id = $id;");
|
||||
$bdd->query("DELETE FROM $table_flottes WHERE id_user = $id;");
|
||||
$bdd->query("DELETE FROM $table_planete WHERE id_user = $id;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('message', 'Le joueur '.$id.' ('.$req['pseudo'].') a été supprimé du jeu ainsi que toutes les données le concernant !<br />Vérifiez qu\'il ne soit pas fondateur d\'une alliance ou d\'une mission groupée.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
$template->assign('message', 'Le joueur n\'a pas été trouvé ou vous n\'avez pas les permissions de le supprimer !');
|
||||
}
|
||||
}
|
||||
elseif (!empty($_GET['name']))
|
||||
{
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
if ($SESS->level >= 5 && !empty($_GET['id'])) {
|
||||
$id = intval(gpc('id'));
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE id = $id;");
|
||||
if ($req && $req["auth_level"] < 4) {
|
||||
$bdd->query("DELETE FROM $table_mail WHERE destinataire = $id;");
|
||||
$bdd->query("DELETE FROM $table_user WHERE id = $id;");
|
||||
$bdd->query("DELETE FROM $table_flottes WHERE id_user = $id;");
|
||||
$bdd->query("DELETE FROM $table_planete WHERE id_user = $id;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('message', 'Le joueur '.$id.' ('.$req['pseudo'].') a été supprimé du jeu ainsi que toutes les données le concernant !<br />Vérifiez qu\'il ne soit pas fondateur d\'une alliance ou d\'une mission groupée.');
|
||||
} else {
|
||||
$bdd->deconnexion();
|
||||
$template->assign('message', 'Le joueur n\'a pas été trouvé ou vous n\'avez pas les permissions de le supprimer !');
|
||||
}
|
||||
} elseif (!empty($_GET['name'])) {
|
||||
$name = gpc('name');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($name);
|
||||
$req = $bdd->unique_query("SELECT * FROM $table_user WHERE pseudo = '$name';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: '.$VAR["menu"]["djoueurs"].'&id='.$req['id']);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
$pagea = 'print_choixU';
|
||||
?>
|
||||
header('Location: '.$VAR["menu"]["djoueurs"].'&id='.$req['id']);
|
||||
exit;
|
||||
} else {
|
||||
$pagea = 'print_choixU';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +1,67 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$pagea = 'version';
|
||||
$titre = 'Versions';
|
||||
|
||||
//Ajout d'une version
|
||||
if (!empty($_GET['i']) && $_GET['i'] == 'add' && $SESS->level >= 7 && !empty($_POST['version']) && !empty($_POST['contenu']))
|
||||
{
|
||||
$version = gpc('version', 'post');
|
||||
$contenu = gpc('contenu', 'post');
|
||||
$temps = time();
|
||||
$nom_user = trouvNom($SESS->values['id']);
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($version);
|
||||
$bdd->escape($contenu);
|
||||
$bdd->escape($nom_user);
|
||||
$bdd->query("INSERT INTO $table_version (version, contenu, temps, pseudo) VALUES ('$version', '$contenu', $temps, '$nom_user');");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($_GET['i']) && $_GET['i'] == 'add' && $SESS->level >= 7 && !empty($_POST['version']) && !empty($_POST['contenu'])) {
|
||||
$version = gpc('version', 'post');
|
||||
$contenu = gpc('contenu', 'post');
|
||||
$temps = time();
|
||||
$nom_user = trouvNom($SESS->values['id']);
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($version);
|
||||
$bdd->escape($contenu);
|
||||
$bdd->escape($nom_user);
|
||||
$bdd->query("INSERT INTO $table_version (version, contenu, temps, pseudo) VALUES ('$version', '$contenu', $temps, '$nom_user');");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
}
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
}
|
||||
//Modification d'une version
|
||||
elseif (!empty($_GET['i']))
|
||||
{
|
||||
$id = intval(gpc('i'));
|
||||
if (!empty($_POST['version']) && !empty($_POST['contenu'])) {
|
||||
$version = gpc('version', 'post');
|
||||
$contenu = gpc('contenu', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($version);
|
||||
$bdd->escape($contenu);
|
||||
$bdd->query("UPDATE $table_version SET version = '$version', contenu = '$contenu' WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
elseif (!empty($_GET['i'])) {
|
||||
$id = intval(gpc('i'));
|
||||
if (!empty($_POST['version']) && !empty($_POST['contenu'])) {
|
||||
$version = gpc('version', 'post');
|
||||
$contenu = gpc('contenu', 'post');
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($version);
|
||||
$bdd->escape($contenu);
|
||||
$bdd->query("UPDATE $table_version SET version = '$version', contenu = '$contenu' WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$template->assign('mod', $bdd->unique_query("SELECT * FROM $table_version WHERE id = '$id';"));
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_version ORDER BY temps DESC;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', $id);
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
}
|
||||
$bdd = new BDD();
|
||||
$template->assign('mod', $bdd->unique_query("SELECT * FROM $table_version WHERE id = '$id';"));
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_version ORDER BY temps DESC;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', $id);
|
||||
}
|
||||
//Suppression d'une version
|
||||
elseif (!empty($_GET['d']) && $SESS->level >= 7)
|
||||
{
|
||||
$id = intval(gpc('d'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_version WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
elseif (!empty($_GET['d']) && $SESS->level >= 7) {
|
||||
$id = intval(gpc('d'));
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM $table_version WHERE id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
}
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
}
|
||||
//Demande de mise à jour du cache
|
||||
elseif (isset($_GET['actuCache']))
|
||||
{
|
||||
Cache::del('versionsDATA');
|
||||
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_version ORDER BY temps DESC;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', 'add');
|
||||
}
|
||||
?>
|
||||
elseif (isset($_GET['actuCache'])) {
|
||||
Cache::del('versionsDATA');
|
||||
|
||||
header('Location: admin.php?p=version');
|
||||
exit;
|
||||
} else {
|
||||
$bdd = new BDD();
|
||||
$template->assign('tableau', $bdd->query("SELECT * FROM $table_version ORDER BY temps DESC;"));
|
||||
$bdd->deconnexion();
|
||||
$template->assign('id', 'add');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($sess->values["connected"]) && !defined("xCSRF"))
|
||||
define("xCSRF", true);
|
||||
if (empty($sess->values["connected"]) && !defined("xCSRF")) {
|
||||
define("xCSRF", true);
|
||||
}
|
||||
|
||||
//A passer a True pour dev tranquillou (pas d'envois de mail, pas de https,...)
|
||||
define("DEV", getenv("DEV"));
|
||||
|
|
@ -21,22 +24,21 @@ $SESS = new Session();
|
|||
|
||||
//Extraction des données en cache pour le header, sinon création du cache
|
||||
$header = Cache::read("headerNB");
|
||||
if (empty($header))
|
||||
{
|
||||
$bdd = new BDD();
|
||||
if (empty($header)) {
|
||||
$bdd = new BDD();
|
||||
|
||||
$nbcovie = $bdd->unique_query("SELECT COUNT(id) AS covenants FROM $table_user WHERE race = 'covenant';");
|
||||
$nbhumain = $bdd->unique_query("SELECT COUNT(id) AS humains FROM $table_user WHERE race = 'humain';");
|
||||
$enligne = $bdd->unique_query("SELECT COUNT(session) AS enligne FROM sessions WHERE active = true AND var != '0';");
|
||||
$infos = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id DESC;");
|
||||
$msgdem = $bdd->unique_query("SELECT titre FROM $table_messages_demarrage ORDER BY id DESC LIMIT 1;");
|
||||
$nbcovie = $bdd->unique_query("SELECT COUNT(id) AS covenants FROM $table_user WHERE race = 'covenant';");
|
||||
$nbhumain = $bdd->unique_query("SELECT COUNT(id) AS humains FROM $table_user WHERE race = 'humain';");
|
||||
$enligne = $bdd->unique_query("SELECT COUNT(session) AS enligne FROM sessions WHERE active = true AND var != '0';");
|
||||
$infos = $bdd->query("SELECT * FROM $table_infoshead ORDER BY id DESC;");
|
||||
$msgdem = $bdd->unique_query("SELECT titre FROM $table_messages_demarrage ORDER BY id DESC LIMIT 1;");
|
||||
|
||||
$bdd->deconnexion();
|
||||
$bdd->deconnexion();
|
||||
|
||||
Cache::set("headerNB", array("count" => array($nbcovie["covenants"], $nbhumain["humains"], "cette", $enligne["enligne"]), "infos" => $infos, "messagedemarrage" => $msgdem["titre"]));
|
||||
unset($nbcovie, $nbhumain, $enligne, $infos, $msgdem, $bdd);
|
||||
Cache::set("headerNB", array("count" => array($nbcovie["covenants"], $nbhumain["humains"], "cette", $enligne["enligne"]), "infos" => $infos, "messagedemarrage" => $msgdem["titre"]));
|
||||
unset($nbcovie, $nbhumain, $enligne, $infos, $msgdem, $bdd);
|
||||
|
||||
$header = Cache::read("headerNB");
|
||||
$header = Cache::read("headerNB");
|
||||
}
|
||||
$template->assign("header", $header);
|
||||
$template->assign("version", $VAR["version"]);
|
||||
|
|
@ -49,15 +51,18 @@ define("debut_d_univers", true); //Constante pour savoir si l'on offre ou pas un
|
|||
define("nb_signatures", 4);
|
||||
|
||||
//Si l'on est pas connecté, on garde le header pour comparer lors de la connexion
|
||||
if (!empty($sess->values["connected"]))
|
||||
unset($header);
|
||||
if (!empty($sess->values["connected"])) {
|
||||
unset($header);
|
||||
}
|
||||
|
||||
//Evite les attaques CSRF
|
||||
if (DEV) { $protocole = "http"; } else { $protocole = "https"; }
|
||||
if (!empty($_SERVER["HTTP_REFERER"]) && !(preg_match('#^'.$protocole.'://'.$_SERVER['HTTP_HOST'].'#', $_SERVER["HTTP_REFERER"]) && defined("xCSRF")))
|
||||
{
|
||||
elog("Possibilité d'attaque CSRF\n".var_export($_REQUEST, TRUE), 2);
|
||||
unset($_POST, $_GET);
|
||||
$_GET = $_POST = array();
|
||||
if (DEV) {
|
||||
$protocole = "http";
|
||||
} else {
|
||||
$protocole = "https";
|
||||
}
|
||||
if (!empty($_SERVER["HTTP_REFERER"]) && !(preg_match('#^'.$protocole.'://'.$_SERVER['HTTP_HOST'].'#', $_SERVER["HTTP_REFERER"]) && defined("xCSRF"))) {
|
||||
elog("Possibilité d'attaque CSRF\n".var_export($_REQUEST, true), 2);
|
||||
unset($_POST, $_GET);
|
||||
$_GET = $_POST = array();
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,25 +1,26 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('INDEX') || INDEX != 2)
|
||||
{
|
||||
//On inclut les classes de données
|
||||
require_once("Class/Donnees/interface.php");
|
||||
require_once("Class/Donnees/alliances_batiments.php");
|
||||
require_once("Class/Donnees/batiments.php");
|
||||
require_once("Class/Donnees/caserne.php");
|
||||
require_once("Class/Donnees/technologies.php");
|
||||
require_once("Class/Donnees/terrestre.php");
|
||||
require_once("Class/Donnees/spatial.php");
|
||||
if (!defined('INDEX') || INDEX != 2) {
|
||||
//On inclut les classes de données
|
||||
require_once("Class/Donnees/interface.php");
|
||||
require_once("Class/Donnees/alliances_batiments.php");
|
||||
require_once("Class/Donnees/batiments.php");
|
||||
require_once("Class/Donnees/caserne.php");
|
||||
require_once("Class/Donnees/technologies.php");
|
||||
require_once("Class/Donnees/terrestre.php");
|
||||
require_once("Class/Donnees/spatial.php");
|
||||
|
||||
//On inclut les classes de file d'attente
|
||||
require_once("Class/File/interface.php");
|
||||
require_once("Class/File/alliances_batiments.php");
|
||||
require_once("Class/File/batiments.php");
|
||||
require_once("Class/File/caserne.php");
|
||||
require_once("Class/File/technologies.php");
|
||||
require_once("Class/File/terrestre.php");
|
||||
require_once("Class/File/spatial.php");
|
||||
//On inclut les classes de file d'attente
|
||||
require_once("Class/File/interface.php");
|
||||
require_once("Class/File/alliances_batiments.php");
|
||||
require_once("Class/File/batiments.php");
|
||||
require_once("Class/File/caserne.php");
|
||||
require_once("Class/File/technologies.php");
|
||||
require_once("Class/File/terrestre.php");
|
||||
require_once("Class/File/spatial.php");
|
||||
}
|
||||
|
||||
//On déffinit les constantes de correspondance Champs/Array
|
||||
|
|
@ -30,4 +31,3 @@ $caserneVAR = array("soldat1", "soldat2", "soldat3", "soldat4", "sniper", "spart
|
|||
$spatialVAR = array("vaisseau_1", "vaisseau_2", "vaisseau_3", "vaisseau_4", "vaisseau_5", "vaisseau_6", "vaisseau_7", "vaisseau_8", "vaisseau_9", "vaisseau_10", "vaisseau_11", "vaisseau_12", "vaisseau_13", "vaisseau_14");
|
||||
$terrestreVAR = array("vais_0", "vais_1", "vais_2", "vais_3", "vcl_1", "vcl_2", "vcl_3", "vcl_4", "def_1", "def_2", "def_3", "def_4", "def_5", "def_6", "def_7", "def_8");
|
||||
$coeffVAR = array("coeff_mine_m", "coeff_mine_c", "coeff_mine_h", "coeff_centrale_s", "coeff_centrale_f");
|
||||
?>
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE (id_user = ".$planete->id_user." OR end_planete = ".$planete->id." OR id_alliance = ".$planete->id_alliance." OR end_planete = ".$planete->id_alliance.") AND (start_time + end_time) <= ".time()." AND last < ".(time()-10).";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($flottes))
|
||||
{
|
||||
foreach($flottes as $flotte)
|
||||
{
|
||||
$flotte = new Flotte($flotte['id']);
|
||||
$flotte->check_mission();
|
||||
}
|
||||
if (!empty($flottes)) {
|
||||
foreach ($flottes as $flotte) {
|
||||
$flotte = new Flotte($flotte['id']);
|
||||
$flotte->check_mission();
|
||||
}
|
||||
}
|
||||
|
||||
unset($flottes, $flotte);
|
||||
?>
|
||||
|
|
@ -1,312 +1,322 @@
|
|||
<?php
|
||||
function trouvNom($id_user)
|
||||
{
|
||||
global $table_user;
|
||||
$bdd = new BDD();
|
||||
$resultat = $bdd->unique_query("SELECT pseudo FROM $table_user WHERE id = $id_user;");
|
||||
$bdd->deconnexion();
|
||||
return $resultat['pseudo'];
|
||||
global $table_user;
|
||||
$bdd = new BDD();
|
||||
$resultat = $bdd->unique_query("SELECT pseudo FROM $table_user WHERE id = $id_user;");
|
||||
$bdd->deconnexion();
|
||||
return $resultat['pseudo'];
|
||||
}
|
||||
|
||||
function linkNom($id_user)
|
||||
{
|
||||
if (is_numeric($id_user)) $nom = trouvNom($id_user);
|
||||
else $id_user = trouvId($id_user);
|
||||
return '<a href="?p=util&i='.$id_user.'">'.$nom.'</a>';
|
||||
if (is_numeric($id_user)) {
|
||||
$nom = trouvNom($id_user);
|
||||
} else {
|
||||
$id_user = trouvId($id_user);
|
||||
}
|
||||
return '<a href="?p=util&i='.$id_user.'">'.$nom.'</a>';
|
||||
}
|
||||
|
||||
function trouvInfoUser($info, $type, $donnees)
|
||||
{
|
||||
global $table_user;
|
||||
$bdd = new BDD();
|
||||
$resultat = $bdd->unique_query("SELECT ".implode(',', $donnees)." FROM $table_user WHERE $type = '$info';");
|
||||
$bdd->deconnexion();
|
||||
global $table_user;
|
||||
$bdd = new BDD();
|
||||
$resultat = $bdd->unique_query("SELECT ".implode(',', $donnees)." FROM $table_user WHERE $type = '$info';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
return $resultat;
|
||||
return $resultat;
|
||||
}
|
||||
|
||||
function affTemp($secondes)
|
||||
{
|
||||
$heures = intval($secondes/3600);
|
||||
$minutes = intval($secondes/60-($heures*60));
|
||||
if ($minutes < 10) $minutes = '0'.$minutes;
|
||||
$seconde = $secondes-($heures*3600)-($minutes*60);
|
||||
if ($seconde < 10) $seconde = '0'.$seconde;
|
||||
$heures = intval($secondes/3600);
|
||||
$minutes = intval($secondes/60-($heures*60));
|
||||
if ($minutes < 10) {
|
||||
$minutes = '0'.$minutes;
|
||||
}
|
||||
$seconde = $secondes-($heures*3600)-($minutes*60);
|
||||
if ($seconde < 10) {
|
||||
$seconde = '0'.$seconde;
|
||||
}
|
||||
|
||||
return $heures.':'.$minutes.':'.$seconde;
|
||||
return $heures.':'.$minutes.':'.$seconde;
|
||||
}
|
||||
|
||||
function sec($time)
|
||||
{
|
||||
$output = '';
|
||||
$tab = array ('jour' => '86400', 'heure' => '3600', 'minute' => '60', 'seconde' => '1');
|
||||
foreach ($tab as $key => $value) {
|
||||
$compteur = 0;
|
||||
while ($time > ($value-1)) {
|
||||
$time = $time - $value;
|
||||
$compteur++;
|
||||
}
|
||||
if ($compteur != 0) {
|
||||
$output .= $compteur.' '.$key;
|
||||
if ($compteur > 1) $output .= 's';
|
||||
if ($value != 1) $output .= ' ';
|
||||
}
|
||||
}
|
||||
if (empty($output)) return 'Instantané';
|
||||
else return $output;
|
||||
$output = '';
|
||||
$tab = array('jour' => '86400', 'heure' => '3600', 'minute' => '60', 'seconde' => '1');
|
||||
foreach ($tab as $key => $value) {
|
||||
$compteur = 0;
|
||||
while ($time > ($value-1)) {
|
||||
$time = $time - $value;
|
||||
$compteur++;
|
||||
}
|
||||
if ($compteur != 0) {
|
||||
$output .= $compteur.' '.$key;
|
||||
if ($compteur > 1) {
|
||||
$output .= 's';
|
||||
}
|
||||
if ($value != 1) {
|
||||
$output .= ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($output)) {
|
||||
return 'Instantané';
|
||||
} else {
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
function txtmission($mission)
|
||||
{
|
||||
if ($mission == 0)
|
||||
return 'Stationner';
|
||||
elseif ($mission == 1)
|
||||
return 'Transporter';
|
||||
elseif ($mission == 2)
|
||||
return 'Coloniser';
|
||||
elseif ($mission == 3)
|
||||
return 'Attaquer';
|
||||
elseif ($mission == 4)
|
||||
return 'Recycler';
|
||||
elseif ($mission == 5)
|
||||
return 'Espionner';
|
||||
elseif ($mission == 6)
|
||||
return 'Retour';
|
||||
else
|
||||
return 'Erreur';
|
||||
if ($mission == 0) {
|
||||
return 'Stationner';
|
||||
} elseif ($mission == 1) {
|
||||
return 'Transporter';
|
||||
} elseif ($mission == 2) {
|
||||
return 'Coloniser';
|
||||
} elseif ($mission == 3) {
|
||||
return 'Attaquer';
|
||||
} elseif ($mission == 4) {
|
||||
return 'Recycler';
|
||||
} elseif ($mission == 5) {
|
||||
return 'Espionner';
|
||||
} elseif ($mission == 6) {
|
||||
return 'Retour';
|
||||
} else {
|
||||
return 'Erreur';
|
||||
}
|
||||
}
|
||||
|
||||
function pillage($metal, $cristal, $hydrogene, $vfm)
|
||||
{
|
||||
$Qm = $metal / $vfm;
|
||||
$Qc = $cristal / $vfm;
|
||||
$Qh = $hydrogene / $vfm;
|
||||
$Qm = $metal / $vfm;
|
||||
$Qc = $cristal / $vfm;
|
||||
$Qh = $hydrogene / $vfm;
|
||||
|
||||
$somme = $Qm + $Qc + $Qh;
|
||||
$somme = $Qm + $Qc + $Qh;
|
||||
|
||||
if ($somme < 2)
|
||||
{
|
||||
$Fm = $metal / 2;
|
||||
$Fc = $cristal / 2;
|
||||
$Fh = $hydrogene / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$Fm = $Qm / $somme * $vfm;
|
||||
$Fc = $Qc / $somme * $vfm;
|
||||
$Fh = $Qh / $somme * $vfm;
|
||||
}
|
||||
if ($somme < 2) {
|
||||
$Fm = $metal / 2;
|
||||
$Fc = $cristal / 2;
|
||||
$Fh = $hydrogene / 2;
|
||||
} else {
|
||||
$Fm = $Qm / $somme * $vfm;
|
||||
$Fc = $Qc / $somme * $vfm;
|
||||
$Fh = $Qh / $somme * $vfm;
|
||||
}
|
||||
|
||||
return array(floor($Fm), floor($Fc), floor($Fh));
|
||||
return array(floor($Fm), floor($Fc), floor($Fh));
|
||||
}
|
||||
|
||||
function send_mail($admail, $sujet, $corps)
|
||||
{
|
||||
require_once("Class/phpmailer.php");
|
||||
require_once("Class/phpmailer.php");
|
||||
|
||||
$mail = new PHPmailer();
|
||||
$mail->SetLanguage('fr', ONYX."/include/Class/");
|
||||
$mail->IsSMTP();
|
||||
$mail->CharSet = "utf-8";
|
||||
$mail->Host='mail2.power-heberg.net';
|
||||
$mail->From='no-reply@anomaly-concepts.com';
|
||||
$mail->FromName='Halo-Battle';
|
||||
$mail->SMTPAuth=true;
|
||||
$mail->Username='no-reply@anomaly-concepts.com';
|
||||
$mail->Password='balamb468';
|
||||
$mail = new PHPmailer();
|
||||
$mail->SetLanguage('fr', ONYX."/include/Class/");
|
||||
$mail->IsSMTP();
|
||||
$mail->CharSet = "utf-8";
|
||||
$mail->Host='mail2.power-heberg.net';
|
||||
$mail->From='no-reply@anomaly-concepts.com';
|
||||
$mail->FromName='Halo-Battle';
|
||||
$mail->SMTPAuth=true;
|
||||
$mail->Username='no-reply@anomaly-concepts.com';
|
||||
$mail->Password='balamb468';
|
||||
|
||||
$mail->AddAddress($admail);
|
||||
$mail->AddReplyTo('nemunaire@anomaly-concepts.com');
|
||||
$mail->Subject = $sujet;
|
||||
$mail->Body = $corps;
|
||||
$mail->AddAddress($admail);
|
||||
$mail->AddReplyTo('nemunaire@anomaly-concepts.com');
|
||||
$mail->Subject = $sujet;
|
||||
$mail->Body = $corps;
|
||||
|
||||
$return = $mail->Send();
|
||||
$mail->SmtpClose();
|
||||
$return = $mail->Send();
|
||||
$mail->SmtpClose();
|
||||
|
||||
return $return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
function send_mailHTML($admail, $sujet, $corps)
|
||||
{
|
||||
require_once("Class/phpmailer.php");
|
||||
require_once("Class/phpmailer.php");
|
||||
|
||||
$mail = new PHPmailer();
|
||||
$mail->SetLanguage('fr', ONYX."/include/Class/");
|
||||
$mail->IsSMTP();
|
||||
$mail->IsHTML(true);
|
||||
$mail->Host='mail2.power-heberg.net';
|
||||
$mail->From='no-reply@anomaly-concepts.com';
|
||||
$mail->FromName='Halo-Battle';
|
||||
$mail->SMTPAuth=true;
|
||||
$mail->Username='no-reply@anomaly-concepts.com';
|
||||
$mail->Password='balamb468';
|
||||
$mail = new PHPmailer();
|
||||
$mail->SetLanguage('fr', ONYX."/include/Class/");
|
||||
$mail->IsSMTP();
|
||||
$mail->IsHTML(true);
|
||||
$mail->Host='mail2.power-heberg.net';
|
||||
$mail->From='no-reply@anomaly-concepts.com';
|
||||
$mail->FromName='Halo-Battle';
|
||||
$mail->SMTPAuth=true;
|
||||
$mail->Username='no-reply@anomaly-concepts.com';
|
||||
$mail->Password='balamb468';
|
||||
|
||||
$mail->AddAddress($admail);
|
||||
$mail->AddReplyTo('nemunaire@anomaly-concepts.com');
|
||||
$mail->Subject = 'Halo-Battle :: '.$sujet;
|
||||
$mail->Body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Halo-Battle :: '.$sujet.'</title></head><body><p>'.$corps.'<br /><br />A bientôt dans Halo-Battle,<br />Le staff</p></body></html>';
|
||||
$mail->AddAddress($admail);
|
||||
$mail->AddReplyTo('nemunaire@anomaly-concepts.com');
|
||||
$mail->Subject = 'Halo-Battle :: '.$sujet;
|
||||
$mail->Body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Halo-Battle :: '.$sujet.'</title></head><body><p>'.$corps.'<br /><br />A bientôt dans Halo-Battle,<br />Le staff</p></body></html>';
|
||||
|
||||
$return = $mail->Send();
|
||||
$mail->SmtpClose();
|
||||
$return = $mail->Send();
|
||||
$mail->SmtpClose();
|
||||
|
||||
return $return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
function erreur($message, $color = "red", $lien = "", $temps = 2500)
|
||||
{
|
||||
global $template, $page, $SESS;
|
||||
global $template, $page, $SESS;
|
||||
|
||||
if (!empty($page))
|
||||
$template->assign('page', $page);
|
||||
if (!empty($page)) {
|
||||
$template->assign('page', $page);
|
||||
}
|
||||
|
||||
$template->assign('message', $message);
|
||||
$template->assign('couleur',$color);
|
||||
$template->assign('message', $message);
|
||||
$template->assign('couleur', $color);
|
||||
|
||||
if (!empty($lien))
|
||||
$template->assign('scripth','<meta http-equiv="refresh" content="'.($temps/1000).'; url='.$lien.'" />');
|
||||
if (!empty($lien)) {
|
||||
$template->assign('scripth', '<meta http-equiv="refresh" content="'.($temps/1000).'; url='.$lien.'" />');
|
||||
}
|
||||
|
||||
//Si le joueur est connecté, on affiche la page d'erreur du jeu, sinon on afficher la page du cms
|
||||
if (isset($SESS->values['connected']) && $SESS->values['connected'])
|
||||
$template->display('game/erreur.tpl');
|
||||
else
|
||||
$template->display('cms/erreur.tpl');
|
||||
exit;
|
||||
//Si le joueur est connecté, on affiche la page d'erreur du jeu, sinon on afficher la page du cms
|
||||
if (isset($SESS->values['connected']) && $SESS->values['connected']) {
|
||||
$template->display('game/erreur.tpl');
|
||||
} else {
|
||||
$template->display('cms/erreur.tpl');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
function send_mp($joueur, $titre, $message, $temps = 0, $emetteur = 0, $type = 0)
|
||||
{
|
||||
global $table_mail, $VAR;
|
||||
if (empty($temps))
|
||||
$temps = time();
|
||||
$mail = false;
|
||||
if (!is_numeric($joueur))
|
||||
{
|
||||
$joueur = trouvInfoUser($joueur, "pseudo", array("id", "mail", "envoyerMail"));
|
||||
if (($emetteur == 0 && $joueur["envoyerMail"]& 1) || ($emetteur != 0 && $joueur["envoyerMail"]& 2))
|
||||
$mail = $joueur["mail"];
|
||||
else
|
||||
$mail = false;
|
||||
global $table_mail, $VAR;
|
||||
if (empty($temps)) {
|
||||
$temps = time();
|
||||
}
|
||||
$mail = false;
|
||||
if (!is_numeric($joueur)) {
|
||||
$joueur = trouvInfoUser($joueur, "pseudo", array("id", "mail", "envoyerMail"));
|
||||
if (($emetteur == 0 && $joueur["envoyerMail"]& 1) || ($emetteur != 0 && $joueur["envoyerMail"]& 2)) {
|
||||
$mail = $joueur["mail"];
|
||||
} else {
|
||||
$mail = false;
|
||||
}
|
||||
|
||||
$joueur = $joueur["id"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$joueur = trouvInfoUser($joueur, "id", array("id", "mail", "envoyerMail"));
|
||||
if (($emetteur == 0 && $joueur["envoyerMail"]& 1) || ($emetteur != 0 && $joueur["envoyerMail"]& 2))
|
||||
$mail = $joueur["mail"];
|
||||
else
|
||||
$mail = false;
|
||||
$joueur = $joueur["id"];
|
||||
} else {
|
||||
$joueur = trouvInfoUser($joueur, "id", array("id", "mail", "envoyerMail"));
|
||||
if (($emetteur == 0 && $joueur["envoyerMail"]& 1) || ($emetteur != 0 && $joueur["envoyerMail"]& 2)) {
|
||||
$mail = $joueur["mail"];
|
||||
} else {
|
||||
$mail = false;
|
||||
}
|
||||
|
||||
$joueur = $joueur["id"];
|
||||
}
|
||||
if (!is_numeric($emetteur))
|
||||
{
|
||||
$emetteur = trouvInfoUser($emetteur, "pseudo", array("id"));
|
||||
$emetteur = $emetteur['id'];
|
||||
}
|
||||
if (!empty($joueur))
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($joueur);
|
||||
$bdd->escape($titre);
|
||||
$bdd->escape($message);
|
||||
$bdd->query("INSERT INTO $table_mail (destinataire, expediteur, type, sujet, contenu, temps) VALUES($joueur, $emetteur, $type, '$titre', '$message', $temps);");
|
||||
$bdd->deconnexion();
|
||||
$joueur = $joueur["id"];
|
||||
}
|
||||
if (!is_numeric($emetteur)) {
|
||||
$emetteur = trouvInfoUser($emetteur, "pseudo", array("id"));
|
||||
$emetteur = $emetteur['id'];
|
||||
}
|
||||
if (!empty($joueur)) {
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($joueur);
|
||||
$bdd->escape($titre);
|
||||
$bdd->escape($message);
|
||||
$bdd->query("INSERT INTO $table_mail (destinataire, expediteur, type, sujet, contenu, temps) VALUES($joueur, $emetteur, $type, '$titre', '$message', $temps);");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($mail)
|
||||
{
|
||||
if ($emetteur == 0)
|
||||
send_mail($mail, "Halo-Battle :: Nouveau rapport", "Bonjour,\n\nVous recevez ce courriel suite à l'arrivée d'un nouveau rapport reçu sur votre compte de jeu du serveur ".$VAR['serveur_name'].". Le rapport concerne : \"".$titre."\". Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.\n\nhttp://".$_SERVER['HTTP_HOST']."/".$VAR["first_page"].$VAR["menu"]["messages"]."&n=recus\n\nVous pouvez désactiver ses notifications via les options de votre compte dans l'onglet \"notifications\"\n\nA bientôt dans Halo-Battle,\nLe Staff");
|
||||
else
|
||||
send_mail($mail, "Halo-Battle :: Nouveau message privé", "Bonjour,\n\nVous recevez ce courriel suite à l'arrivée d'un nouveau message privé reçu sur votre compte de jeu du serveur ".$VAR['serveur_name'].". Le sujet de ce message est : \"".$titre."\". Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.\n\nhttp://".$_SERVER['HTTP_HOST']."/".$VAR["first_page"].$VAR["menu"]["messages"]."&n=recus\n\nVous pouvez désactiver ses notifications via les options de votre compte dans l'onglet \"notifications\"\n\nA bientôt dans Halo-Battle,\nLe Staff");
|
||||
}
|
||||
}
|
||||
if ($mail) {
|
||||
if ($emetteur == 0) {
|
||||
send_mail($mail, "Halo-Battle :: Nouveau rapport", "Bonjour,\n\nVous recevez ce courriel suite à l'arrivée d'un nouveau rapport reçu sur votre compte de jeu du serveur ".$VAR['serveur_name'].". Le rapport concerne : \"".$titre."\". Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.\n\nhttp://".$_SERVER['HTTP_HOST']."/".$VAR["first_page"].$VAR["menu"]["messages"]."&n=recus\n\nVous pouvez désactiver ses notifications via les options de votre compte dans l'onglet \"notifications\"\n\nA bientôt dans Halo-Battle,\nLe Staff");
|
||||
} else {
|
||||
send_mail($mail, "Halo-Battle :: Nouveau message privé", "Bonjour,\n\nVous recevez ce courriel suite à l'arrivée d'un nouveau message privé reçu sur votre compte de jeu du serveur ".$VAR['serveur_name'].". Le sujet de ce message est : \"".$titre."\". Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.\n\nhttp://".$_SERVER['HTTP_HOST']."/".$VAR["first_page"].$VAR["menu"]["messages"]."&n=recus\n\nVous pouvez désactiver ses notifications via les options de votre compte dans l'onglet \"notifications\"\n\nA bientôt dans Halo-Battle,\nLe Staff");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function gen_mdp($nbchar)
|
||||
{
|
||||
$liste = "abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$code = "";
|
||||
for($i = 0; $i < $nbchar; $i++)
|
||||
{
|
||||
$code .= $liste[rand(0,60)];
|
||||
}
|
||||
$liste = "abcdefghijklmnopqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$code = "";
|
||||
for ($i = 0; $i < $nbchar; $i++) {
|
||||
$code .= $liste[rand(0, 60)];
|
||||
}
|
||||
|
||||
return $code;
|
||||
return $code;
|
||||
}
|
||||
|
||||
function check_mdp($mdp, $pseudo = null, $conf=null)
|
||||
{
|
||||
if (isset($conf) && $conf !== $mdp)
|
||||
return "Le mot de passe et sa confirmation sont différent";
|
||||
elseif (strlen($mdp) < 7)
|
||||
return "Mot de passe trop court, il doit faire au moins 7 caractères.";
|
||||
elseif (ctype_digit($mdp))
|
||||
return "Le mot de passe ne doit pas contenir que des chiffres";
|
||||
elseif (!empty($pseudo) && strpos($mdp, $pseudo))
|
||||
return "Votre mot de passe ne doit pas être une partie de votre nom d'utilisateur";
|
||||
elseif (!empty($pseudo) && strpos($pseudo, $mdp))
|
||||
return "Votre nom d'utilisateur ne doit pas être une partie de votre mot de passe";
|
||||
elseif (strpos($mdp, "halo"))
|
||||
return "Le mot de passe ne peut pas contenir le mot halo !";
|
||||
elseif (preg_match("#azer|qwer|zert|wert|erty|rtyu|tyui|yuio|uiop|poiu|oiuy|iuyt|uytr|ytre|trez|trew|reza|rewq|qsdf|asdf|sdfg|dfgh|fghj|ghjk|hjkl|jklm|mlkj|lkjh|kjhg|jhgf|hgfd|gfds|fdsq|fdsa|wxcv|vcxw|xcvb|bvcx|cvbn|nbvc|vbnm|mnbv|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210|012#iU", $mdp, $osef))
|
||||
return "Ayez plus de créativité pour définir votre mot de passe, les lettres ou chiffres du clavier qui se suivent ne sont pas une bonne sécurité !";
|
||||
else
|
||||
return $mdp;
|
||||
if (isset($conf) && $conf !== $mdp) {
|
||||
return "Le mot de passe et sa confirmation sont différent";
|
||||
} elseif (strlen($mdp) < 7) {
|
||||
return "Mot de passe trop court, il doit faire au moins 7 caractères.";
|
||||
} elseif (ctype_digit($mdp)) {
|
||||
return "Le mot de passe ne doit pas contenir que des chiffres";
|
||||
} elseif (!empty($pseudo) && strpos($mdp, $pseudo)) {
|
||||
return "Votre mot de passe ne doit pas être une partie de votre nom d'utilisateur";
|
||||
} elseif (!empty($pseudo) && strpos($pseudo, $mdp)) {
|
||||
return "Votre nom d'utilisateur ne doit pas être une partie de votre mot de passe";
|
||||
} elseif (strpos($mdp, "halo")) {
|
||||
return "Le mot de passe ne peut pas contenir le mot halo !";
|
||||
} elseif (preg_match("#azer|qwer|zert|wert|erty|rtyu|tyui|yuio|uiop|poiu|oiuy|iuyt|uytr|ytre|trez|trew|reza|rewq|qsdf|asdf|sdfg|dfgh|fghj|ghjk|hjkl|jklm|mlkj|lkjh|kjhg|jhgf|hgfd|gfds|fdsq|fdsa|wxcv|vcxw|xcvb|bvcx|cvbn|nbvc|vbnm|mnbv|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210|012#iU", $mdp, $osef)) {
|
||||
return "Ayez plus de créativité pour définir votre mot de passe, les lettres ou chiffres du clavier qui se suivent ne sont pas une bonne sécurité !";
|
||||
} else {
|
||||
return $mdp;
|
||||
}
|
||||
}
|
||||
|
||||
function mdp($nom, $mdp, $alea = null)
|
||||
{
|
||||
if (empty($alea))
|
||||
{
|
||||
$alea = substr(random(1024), 0, 255);
|
||||
return array(hash('whirlpool', cxor(strtoupper($nom).':'.$mdp.'♂♪',$alea)), $alea);
|
||||
}
|
||||
else
|
||||
return hash('whirlpool', cxor(strtoupper($nom).':'.$mdp.'♂♪',$alea));
|
||||
if (empty($alea)) {
|
||||
$alea = substr(random(1024), 0, 255);
|
||||
return array(hash('whirlpool', cxor(strtoupper($nom).':'.$mdp.'♂♪', $alea)), $alea);
|
||||
} else {
|
||||
return hash('whirlpool', cxor(strtoupper($nom).':'.$mdp.'♂♪', $alea));
|
||||
}
|
||||
}
|
||||
|
||||
function redirection($url)
|
||||
{
|
||||
header('Location: '.$url);
|
||||
print '<meta http-equiv="refresh" content="0; url='.$url.'" />';
|
||||
exit;
|
||||
header('Location: '.$url);
|
||||
print '<meta http-equiv="refresh" content="0; url='.$url.'" />';
|
||||
exit;
|
||||
}
|
||||
|
||||
function slots($id_user)
|
||||
{
|
||||
global $table_flottes, $table_planete;
|
||||
global $table_flottes, $table_planete;
|
||||
|
||||
$bdd = new BDD();
|
||||
$flottes = $bdd->unique_query("SELECT COUNT(id) AS cnt FROM $table_flottes WHERE id_user = $id_user;");
|
||||
$colonies = $bdd->unique_query("SELECT COUNT(id) AS cnt FROM $table_planete WHERE id_user = $id_user;");
|
||||
$bdd->deconnexion();
|
||||
$bdd = new BDD();
|
||||
$flottes = $bdd->unique_query("SELECT COUNT(id) AS cnt FROM $table_flottes WHERE id_user = $id_user;");
|
||||
$colonies = $bdd->unique_query("SELECT COUNT(id) AS cnt FROM $table_planete WHERE id_user = $id_user;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
return (ceil(count($colonies["cnt"])/2 + 1) - $flottes["cnt"]);
|
||||
return (ceil(count($colonies["cnt"])/2 + 1) - $flottes["cnt"]);
|
||||
}
|
||||
|
||||
function limite($txt, $limit)
|
||||
{
|
||||
if (strlen($txt) > $limit)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
if (strlen($txt) > $limit) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function bourse_calcPrixBase($dispo, $nb = 1000, $rate = 2)
|
||||
{
|
||||
if ($nb > 1000)
|
||||
{
|
||||
$prix = 0;
|
||||
for($i = 0; $i < $nb; $i+=1000)
|
||||
{
|
||||
$prix += bourse_calcPrixBase($dispo-$i, 1000, $rate);
|
||||
}
|
||||
$prix += bourse_calcPrixBase($dispo-$i, $dispo%1000, $rate);
|
||||
return $prix;
|
||||
}
|
||||
else
|
||||
return ceil(pow($dispo, -0.1) * $nb * $rate);
|
||||
//return pow($dispo, -0.1) * 200; //Prix de base ...
|
||||
if ($nb > 1000) {
|
||||
$prix = 0;
|
||||
for ($i = 0; $i < $nb; $i+=1000) {
|
||||
$prix += bourse_calcPrixBase($dispo-$i, 1000, $rate);
|
||||
}
|
||||
$prix += bourse_calcPrixBase($dispo-$i, $dispo%1000, $rate);
|
||||
return $prix;
|
||||
} else {
|
||||
return ceil(pow($dispo, -0.1) * $nb * $rate);
|
||||
}
|
||||
//return pow($dispo, -0.1) * 200; //Prix de base ...
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$page = 'accueil';
|
||||
$titre = 'Accueil';
|
||||
|
||||
|
|
@ -10,30 +13,26 @@ $bdd->reconnexion();
|
|||
//On regarde si le joueur a une flotte en vue
|
||||
$radar = array();
|
||||
$detect = 86400;
|
||||
foreach($queryPlanetes as $planeteJoueur)
|
||||
{
|
||||
$end_id = $planeteJoueur['id'];
|
||||
$radar[] = array($bdd->query("SELECT F.mission, F.start_planete, F.start_time, F.end_time, F.start_time + F.end_time - ".time()." AS arrive_time, P.nom_planete, P.galaxie as start_galaxie, P.ss as start_ss, P.position as start_position, U.pseudo FROM $table_flottes F INNER JOIN $table_planete P ON P.id = F.start_planete INNER JOIN $table_user U ON U.id = P.id_user WHERE F.statut != '1' AND F.end_planete = '$end_id' AND F.id_user != $id_user AND F.start_time + F.end_time - ".time()." <= $detect;"), array($planeteJoueur['nom_planete'], $planeteJoueur['galaxie'], $planeteJoueur['ss'], $planeteJoueur['position']));
|
||||
}
|
||||
foreach ($queryPlanetes as $planeteJoueur) {
|
||||
$end_id = $planeteJoueur['id'];
|
||||
$radar[] = array($bdd->query("SELECT F.mission, F.start_planete, F.start_time, F.end_time, F.start_time + F.end_time - ".time()." AS arrive_time, P.nom_planete, P.galaxie as start_galaxie, P.ss as start_ss, P.position as start_position, U.pseudo FROM $table_flottes F INNER JOIN $table_planete P ON P.id = F.start_planete INNER JOIN $table_user U ON U.id = P.id_user WHERE F.statut != '1' AND F.end_planete = '$end_id' AND F.id_user != $id_user AND F.start_time + F.end_time - ".time()." <= $detect;"), array($planeteJoueur['nom_planete'], $planeteJoueur['galaxie'], $planeteJoueur['ss'], $planeteJoueur['position']));
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
$template->assign('radar',$radar);
|
||||
$template->assign('radar', $radar);
|
||||
//$template->assign('alliance', $alli);
|
||||
unset($nbPlan, $end_id, $radar, $alli);
|
||||
|
||||
if (SURFACE == "planete") {
|
||||
//Affichage des informations sur la planète
|
||||
$template->assign('diametre', $planete->cases * 92);
|
||||
$template->assign('points', $planete->points);
|
||||
$template->assign('fileBat', $planete->file_bat->printFile($planete));
|
||||
$template->assign('fileCas', $planete->file_cas->printFile($planete));
|
||||
$template->assign('fileVais', $planete->file_vais->printFile($planete));
|
||||
$template->assign('fileTer', $planete->file_ter->printFile($planete));
|
||||
$template->assign('fileTech', $planete->file_tech->printFile($planete));
|
||||
//Affichage des informations sur la planète
|
||||
$template->assign('diametre', $planete->cases * 92);
|
||||
$template->assign('points', $planete->points);
|
||||
$template->assign('fileBat', $planete->file_bat->printFile($planete));
|
||||
$template->assign('fileCas', $planete->file_cas->printFile($planete));
|
||||
$template->assign('fileVais', $planete->file_vais->printFile($planete));
|
||||
$template->assign('fileTer', $planete->file_ter->printFile($planete));
|
||||
$template->assign('fileTech', $planete->file_tech->printFile($planete));
|
||||
} else {
|
||||
//On charge l'utilisateur pour récupérer son pseudo et l'afficher sur la page d'accueil
|
||||
$planete->fondateur = new User($planete->fondateur);
|
||||
$planete->loadDetails();
|
||||
}
|
||||
else
|
||||
{
|
||||
//On charge l'utilisateur pour récupérer son pseudo et l'afficher sur la page d'accueil
|
||||
$planete->fondateur = new User($planete->fondateur);
|
||||
$planete->loadDetails();
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($_GET['v']))
|
||||
if (!empty($_GET['v'])) {
|
||||
include('game/alliances/voir.php');
|
||||
elseif (!empty($_GET['signer']))
|
||||
} elseif (!empty($_GET['signer'])) {
|
||||
include('game/alliances/signer.php');
|
||||
elseif (!empty($planete->id_alliance))
|
||||
{
|
||||
$SESS->values['idPlan'] = 0;
|
||||
$SESS->values['idAsteroide'] = $planete->id_alliance;
|
||||
$SESS->values['isolement'] = 0;
|
||||
$SESS->put();
|
||||
redirection("?p=accueil");
|
||||
}
|
||||
elseif (!empty($_GET['postuler']))
|
||||
} elseif (!empty($planete->id_alliance)) {
|
||||
$SESS->values['idPlan'] = 0;
|
||||
$SESS->values['idAsteroide'] = $planete->id_alliance;
|
||||
$SESS->values['isolement'] = 0;
|
||||
$SESS->put();
|
||||
redirection("?p=accueil");
|
||||
} elseif (!empty($_GET['postuler'])) {
|
||||
include('game/alliances/postuler.php');
|
||||
else
|
||||
} else {
|
||||
include('game/alliances/sans.php');
|
||||
?>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$planete->loadDetails();
|
||||
if (!empty($planete->url_chat))
|
||||
{
|
||||
//On vérifie que le joueur ait les permissions requises
|
||||
if ($planete->permissions_alliance &256)
|
||||
$page = "alliance/chat_irc";
|
||||
else
|
||||
erreur("Vous n'avez pas le grade requis pour accéder au chat de l'alliance.");
|
||||
if (!empty($planete->url_chat)) {
|
||||
//On vérifie que le joueur ait les permissions requises
|
||||
if ($planete->permissions_alliance &256) {
|
||||
$page = "alliance/chat_irc";
|
||||
} else {
|
||||
erreur("Vous n'avez pas le grade requis pour accéder au chat de l'alliance.");
|
||||
}
|
||||
} else {
|
||||
$page = "alliance/chat_ajax";
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = "alliance/chat_ajax";
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,310 +1,277 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$gestion = strtolower(gpc("g"));
|
||||
if ($gestion == "grades")
|
||||
{
|
||||
$page = 'alliance/gestion_grades';
|
||||
if ($gestion == "grades") {
|
||||
$page = 'alliance/gestion_grades';
|
||||
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &128))
|
||||
erreur("Vous n'avez pas le grade nécessaire pour modifier les grades !");
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &128)) {
|
||||
erreur("Vous n'avez pas le grade nécessaire pour modifier les grades !");
|
||||
}
|
||||
|
||||
$id = intval(gpc("i"));
|
||||
$del = intval(gpc("d"));
|
||||
$id = intval(gpc("i"));
|
||||
$del = intval(gpc("d"));
|
||||
|
||||
if (!empty($id) && gpc("nom", "post"))
|
||||
{
|
||||
$nom = gpc("nom", "post");
|
||||
$auth = intval(gpc("gbats", "post")) + intval(gpc("gvais", "post"))*2 + intval(gpc("gflot", "post"))*4 + intval(gpc("gdipl", "post"))*8 + intval(gpc("gcred", "post"))*16 + intval(gpc("gmemb", "post"))*32 + intval(gpc("gwing", "post"))*64 + intval(gpc("galli", "post"))*128 + intval(gpc("gchat", "post"))*256 + intval(gpc("gmess", "post"))*512;
|
||||
if (!empty($id) && gpc("nom", "post")) {
|
||||
$nom = gpc("nom", "post");
|
||||
$auth = intval(gpc("gbats", "post")) + intval(gpc("gvais", "post"))*2 + intval(gpc("gflot", "post"))*4 + intval(gpc("gdipl", "post"))*8 + intval(gpc("gcred", "post"))*16 + intval(gpc("gmemb", "post"))*32 + intval(gpc("gwing", "post"))*64 + intval(gpc("galli", "post"))*128 + intval(gpc("gchat", "post"))*256 + intval(gpc("gmess", "post"))*512;
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom);
|
||||
$bdd->query("UPDATE $table_alliances_grade SET nom = '$nom', auth = $auth WHERE id = $id AND id_alliance = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom);
|
||||
$bdd->query("UPDATE $table_alliances_grade SET nom = '$nom', auth = $auth WHERE id = $id AND id_alliance = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=gestion&g=grades');
|
||||
exit;
|
||||
}
|
||||
elseif (gpc("nom", "post"))
|
||||
{
|
||||
$nom = gpc("nom", "post");
|
||||
$auth = intval(gpc("gbats", "post")) + intval(gpc("gvais", "post"))*2 + intval(gpc("gflot", "post"))*4 + intval(gpc("gdipl", "post"))*8 + intval(gpc("gcred", "post"))*16 + intval(gpc("gmemb", "post"))*32 + intval(gpc("gwing", "post"))*64 + intval(gpc("galli", "post"))*128;
|
||||
header('Location: ?p=gestion&g=grades');
|
||||
exit;
|
||||
} elseif (gpc("nom", "post")) {
|
||||
$nom = gpc("nom", "post");
|
||||
$auth = intval(gpc("gbats", "post")) + intval(gpc("gvais", "post"))*2 + intval(gpc("gflot", "post"))*4 + intval(gpc("gdipl", "post"))*8 + intval(gpc("gcred", "post"))*16 + intval(gpc("gmemb", "post"))*32 + intval(gpc("gwing", "post"))*64 + intval(gpc("galli", "post"))*128;
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom);
|
||||
$bdd->query("INSERT INTO $table_alliances_grade (id_alliance, nom, auth) VALUES (".$planete->id.", '$nom', $auth);");
|
||||
$bdd->deconnexion();
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom);
|
||||
$bdd->query("INSERT INTO $table_alliances_grade (id_alliance, nom, auth) VALUES (".$planete->id.", '$nom', $auth);");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=gestion&g=grades');
|
||||
exit;
|
||||
}
|
||||
elseif (!empty($id))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$grade = $bdd->unique_query("SELECT id, nom, auth FROM $table_alliances_grade WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("grade_mod", $grade);
|
||||
}
|
||||
elseif (!empty($del))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$grade = $bdd->query("DELETE FROM $table_alliances_grade WHERE id_alliance = ".$planete->id." AND id = $del;");
|
||||
$bdd->deconnexion();
|
||||
header('Location: ?p=gestion&g=grades');
|
||||
exit;
|
||||
} elseif (!empty($id)) {
|
||||
$bdd->reconnexion();
|
||||
$grade = $bdd->unique_query("SELECT id, nom, auth FROM $table_alliances_grade WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("grade_mod", $grade);
|
||||
} elseif (!empty($del)) {
|
||||
$bdd->reconnexion();
|
||||
$grade = $bdd->query("DELETE FROM $table_alliances_grade WHERE id_alliance = ".$planete->id." AND id = $del;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=gestion&g=grades');
|
||||
exit;
|
||||
}
|
||||
header('Location: ?p=gestion&g=grades');
|
||||
exit;
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$grades = $bdd->query("SELECT id, id_alliance, nom, auth FROM $table_alliances_grade WHERE id_alliance = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("grades", $grades);
|
||||
$bdd->reconnexion();
|
||||
$grades = $bdd->query("SELECT id, id_alliance, nom, auth FROM $table_alliances_grade WHERE id_alliance = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("grades", $grades);
|
||||
|
||||
unset($grades, $id, $del);
|
||||
}
|
||||
unset($grades, $id, $del);
|
||||
} elseif ($gestion == "alliance" || ($gestion == "wings" && !empty($planete->wing))) {
|
||||
$page = 'alliance/gestion_alliance';
|
||||
|
||||
elseif ($gestion == "alliance" || ($gestion == "wings" && !empty($planete->wing)))
|
||||
{
|
||||
$page = 'alliance/gestion_alliance';
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &128)) {
|
||||
erreur("Vous n'avez pas le grade nécessaire pour modifier les paramètres de l'alliance !");
|
||||
}
|
||||
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &128))
|
||||
erreur("Vous n'avez pas le grade nécessaire pour modifier les paramètres de l'alliance !");
|
||||
if (isset($_POST["asteroide_name"])) {
|
||||
$asteroide_name = gpc("asteroide_name", "post");
|
||||
$planete->nom_asteroide = $asteroide_name;
|
||||
$planete->modif[] = "nom_asteroide";
|
||||
} elseif (isset($_POST["texte_interne"])) {
|
||||
$texte_interne = gpc("texte_interne", "post");
|
||||
$defcon = intval(gpc("defcon", "post"));
|
||||
$defcon_txt = gpc("defcon_txt", "post");
|
||||
|
||||
if (isset($_POST["asteroide_name"]))
|
||||
{
|
||||
$asteroide_name = gpc("asteroide_name", "post");
|
||||
$planete->nom_asteroide = $asteroide_name;
|
||||
$planete->modif[] = "nom_asteroide";
|
||||
}
|
||||
elseif (isset($_POST["texte_interne"]))
|
||||
{
|
||||
$texte_interne = gpc("texte_interne", "post");
|
||||
$defcon = intval(gpc("defcon", "post"));
|
||||
$defcon_txt = gpc("defcon_txt", "post");
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($texte_interne);
|
||||
$bdd->escape($defcon_txt);
|
||||
$bdd->query("UPDATE $table_alliances SET texte_interne = '$texte_interne', defcon = $defcon, defcon_txt = '$defcon_txt' WHERE id = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
} elseif (isset($_POST["url_forum"])) {
|
||||
$url_forum = gpc("url_forum", "post");
|
||||
$url_chat = gpc("url_chat", "post");
|
||||
$port_chat = intval(gpc("port_chat", "post"));
|
||||
$chan_chat = gpc("chan_chat", "post");
|
||||
$pass_chat = gpc("pass_chat", "post");
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($texte_interne);
|
||||
$bdd->escape($defcon_txt);
|
||||
$bdd->query("UPDATE $table_alliances SET texte_interne = '$texte_interne', defcon = $defcon, defcon_txt = '$defcon_txt' WHERE id = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (isset($_POST["url_forum"]))
|
||||
{
|
||||
$url_forum = gpc("url_forum", "post");
|
||||
$url_chat = gpc("url_chat", "post");
|
||||
$port_chat = intval(gpc("port_chat", "post"));
|
||||
$chan_chat = gpc("chan_chat", "post");
|
||||
$pass_chat = gpc("pass_chat", "post");
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($url_forum);
|
||||
$bdd->escape($url_chat);
|
||||
$bdd->escape($chan_chat);
|
||||
$bdd->escape($pass_chat);
|
||||
$bdd->query("UPDATE $table_alliances SET url_forum = '$url_forum', url_chat = '$url_chat', port_chat = $port_chat, chan_chat = '$chan_chat', pass_chat = '$pass_chat' WHERE id = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
} elseif (isset($_POST["message_inscription"])) {
|
||||
$etatinscriptions = intval(gpc("etatinscriptions", "post"));
|
||||
$message_inscription = gpc("message_inscription", "post");
|
||||
$presentation = gpc("presentation", "post");
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($url_forum);
|
||||
$bdd->escape($url_chat);
|
||||
$bdd->escape($chan_chat);
|
||||
$bdd->escape($pass_chat);
|
||||
$bdd->query("UPDATE $table_alliances SET url_forum = '$url_forum', url_chat = '$url_chat', port_chat = $port_chat, chan_chat = '$chan_chat', pass_chat = '$pass_chat' WHERE id = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (isset($_POST["message_inscription"]))
|
||||
{
|
||||
$etatinscriptions = intval(gpc("etatinscriptions", "post"));
|
||||
$message_inscription = gpc("message_inscription", "post");
|
||||
$presentation = gpc("presentation", "post");
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($url_forum);
|
||||
$bdd->escape($url_chat);
|
||||
$bdd->escape($chan_chat);
|
||||
$bdd->query("UPDATE $table_alliances SET etatinscriptions = '$etatinscriptions', message_inscription = '$message_inscription', presentation = '$presentation' WHERE id = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
} elseif (isset($_POST["newfondateur"]) && $planete->fondateur == $planete->id_user) {
|
||||
//On vérifie que le joueur demandé existe bien et fasse bien parti de l'alliance
|
||||
$bdd->reconnexion();
|
||||
$membre = $bdd->unique_query("SELECT id_alliance FROM $table_user WHERE id != ".intval(gpc('newfondateur', 'post')).";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($url_forum);
|
||||
$bdd->escape($url_chat);
|
||||
$bdd->escape($chan_chat);
|
||||
$bdd->query("UPDATE $table_alliances SET etatinscriptions = '$etatinscriptions', message_inscription = '$message_inscription', presentation = '$presentation' WHERE id = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (isset($_POST["newfondateur"]) && $planete->fondateur == $planete->id_user)
|
||||
{
|
||||
//On vérifie que le joueur demandé existe bien et fasse bien parti de l'alliance
|
||||
$bdd->reconnexion();
|
||||
$membre = $bdd->unique_query("SELECT id_alliance FROM $table_user WHERE id != ".intval(gpc('newfondateur', 'post')).";");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($membre)) {
|
||||
$planete->fondateur = intval(gpc('newfondateur', 'post'));
|
||||
$planete->modif[] = "fondateur";
|
||||
erreur("Fondateur changé avec succès.", "green");
|
||||
} else {
|
||||
erreur("Impossible de donner les droits de fondateur à ce joueur !");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($membre))
|
||||
{
|
||||
$planete->fondateur = intval(gpc('newfondateur', 'post'));
|
||||
$planete->modif[] = "fondateur";
|
||||
erreur("Fondateur changé avec succès.", "green");
|
||||
}
|
||||
else
|
||||
erreur("Impossible de donner les droits de fondateur à ce joueur !");
|
||||
}
|
||||
$planete->loadDetails();
|
||||
|
||||
$planete->loadDetails();
|
||||
//On charge la liste des utilisateurs de l'alliance si besoin
|
||||
$bdd->reconnexion();
|
||||
$membres = $bdd->query("SELECT id, pseudo FROM $table_user WHERE id_alliance = ".$planete->id." AND id != ".$planete->fondateur.";");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("membres", $membres);
|
||||
unset($membres);
|
||||
} elseif ($gestion == "wings") {
|
||||
$page = 'alliance/gestion_wing';
|
||||
|
||||
//On charge la liste des utilisateurs de l'alliance si besoin
|
||||
$bdd->reconnexion();
|
||||
$membres = $bdd->query("SELECT id, pseudo FROM $table_user WHERE id_alliance = ".$planete->id." AND id != ".$planete->fondateur.";");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("membres", $membres);
|
||||
unset($membres);
|
||||
}
|
||||
elseif ($gestion == "wings")
|
||||
{
|
||||
$page = 'alliance/gestion_wing';
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &64)) {
|
||||
erreur("Vous n'avez pas le grade nécessaire pour gérer les wings !");
|
||||
}
|
||||
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &64))
|
||||
erreur("Vous n'avez pas le grade nécessaire pour gérer les wings !");
|
||||
if (!empty($_POST["nom"])) {
|
||||
$fondateur = gpc("fondateur", "post");
|
||||
$nom = gpc("nom", "post");
|
||||
$tag = strtoupper(gpc("tag", "post"));
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($fondateur);
|
||||
$bdd->escape($nom);
|
||||
$bdd->escape($tag);
|
||||
$user = $bdd->unique_query("SELECT id, pseudo FROM $table_user WHERE pseudo = '$fondateur' AND id_alliance = 0;");
|
||||
$alliances = $bdd->query("SELECT id FROM $table_alliances WHERE nom_alliance = '$nom' OR tag = '$tag';");
|
||||
$wings = $bdd->unique_query("SELECT COUNT(id) AS nb FROM $table_alliances WHERE galaxie = ".$planete->galaxie." AND ss = ".$planete->ss.";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($_POST["nom"]))
|
||||
{
|
||||
$fondateur = gpc("fondateur", "post");
|
||||
$nom = gpc("nom", "post");
|
||||
$tag = strtoupper(gpc("tag", "post"));
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($fondateur);
|
||||
$bdd->escape($nom);
|
||||
$bdd->escape($tag);
|
||||
$user = $bdd->unique_query("SELECT id, pseudo FROM $table_user WHERE pseudo = '$fondateur' AND id_alliance = 0;");
|
||||
$alliances = $bdd->query("SELECT id FROM $table_alliances WHERE nom_alliance = '$nom' OR tag = '$tag';");
|
||||
$wings = $bdd->unique_query("SELECT COUNT(id) AS nb FROM $table_alliances WHERE galaxie = ".$planete->galaxie." AND ss = ".$planete->ss.";");
|
||||
$bdd->deconnexion();
|
||||
if (!empty($alliances)) {
|
||||
erreur("Une alliance porte déjà ce nom ou ce tag. Veuillez en choisir un autre.");
|
||||
} elseif (!empty($user)) {
|
||||
$race = gpc("race", "post");
|
||||
if (!preg_match("#^[A-Za-z0-9èéàùûüôöç'_ -]{5,24}$#ui", $nom)) {
|
||||
erreur("Le nom d'alliance que vous avez choisi n'est pas valide :<br />il doit avoir entre 5 et 24 caractères (certains accents sont autorisés, mais aucun caractères spéciaux) !", "red");
|
||||
} elseif (!preg_match("#^[A-Za-z0-9]{3,5}$#ui", $tag)) {
|
||||
erreur("Le tag de wing que vous avez choisi n'est pas valide :<br />il doit avoir entre 3 et 5 lettres (sans accents) ou chiffres !", "red");
|
||||
} elseif ($race != "humain" && $race != "covenant") {
|
||||
erreur("La race de la wing est incorrecte !");
|
||||
}
|
||||
|
||||
if (!empty($alliances))
|
||||
erreur("Une alliance porte déjà ce nom ou ce tag. Veuillez en choisir un autre.");
|
||||
elseif (!empty($user))
|
||||
{
|
||||
$race = gpc("race", "post");
|
||||
if (!preg_match("#^[A-Za-z0-9èéàùûüôöç'_ -]{5,24}$#ui", $nom))
|
||||
erreur("Le nom d'alliance que vous avez choisi n'est pas valide :<br />il doit avoir entre 5 et 24 caractères (certains accents sont autorisés, mais aucun caractères spéciaux) !", "red");
|
||||
elseif (!preg_match("#^[A-Za-z0-9]{3,5}$#ui", $tag))
|
||||
erreur("Le tag de wing que vous avez choisi n'est pas valide :<br />il doit avoir entre 3 et 5 lettres (sans accents) ou chiffres !", "red");
|
||||
elseif ($race != "humain" && $race != "covenant")
|
||||
erreur("La race de la wing est incorrecte !");
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($race);
|
||||
$bdd->query("INSERT INTO $table_alliances (race, sante, nom_alliance, tag, galaxie, ss, wing) VALUES ('$race', 1, '$nom', '$tag', ".$planete->galaxie.", ".$planete->ss.", ".$wings['nb'].")");
|
||||
$affected = $bdd->affected();
|
||||
$bdd->deconnexion();
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($race);
|
||||
$bdd->query("INSERT INTO $table_alliances (race, sante, nom_alliance, tag, galaxie, ss, wing) VALUES ('$race', 1, '$nom', '$tag', ".$planete->galaxie.", ".$planete->ss.", ".$wings['nb'].")");
|
||||
$affected = $bdd->affected();
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($affected)
|
||||
{
|
||||
send_mp($user['id'], "Création d'une wing pour l'alliance [".$planete->tag."] ".$planete->nom_alliance, "L'alliance [".$planete->tag."] ".$planete->nom_alliance." vous propose de devenir capitaine de la wing [".$tag."] ".$nom.".<br /><br />Si vous acceptez le poste, cliquez sur le lien suivant : <a href=\"\">ce lien</a>");
|
||||
erreur("Un message vient d'être envoyé à ".$user["pseudo"].". Lorsqu'il aura accepté son poste, la création de la wing sera terminée et les premiers membres pourront s'y inscrire.", "green");
|
||||
}
|
||||
else
|
||||
erreur("Une erreur s'est produite lors de la création de la wing. Si le problème percisite, contacter un opérateur.");
|
||||
}
|
||||
else
|
||||
erreur("Impossible de trouver le nom de ce joueur. Vérifiez que celui-ci n'appartient actuellement à aucune alliance.<br />Impossible de créer une wing sans fondateur valide.");
|
||||
}
|
||||
if ($affected) {
|
||||
send_mp($user['id'], "Création d'une wing pour l'alliance [".$planete->tag."] ".$planete->nom_alliance, "L'alliance [".$planete->tag."] ".$planete->nom_alliance." vous propose de devenir capitaine de la wing [".$tag."] ".$nom.".<br /><br />Si vous acceptez le poste, cliquez sur le lien suivant : <a href=\"\">ce lien</a>");
|
||||
erreur("Un message vient d'être envoyé à ".$user["pseudo"].". Lorsqu'il aura accepté son poste, la création de la wing sera terminée et les premiers membres pourront s'y inscrire.", "green");
|
||||
} else {
|
||||
erreur("Une erreur s'est produite lors de la création de la wing. Si le problème percisite, contacter un opérateur.");
|
||||
}
|
||||
} else {
|
||||
erreur("Impossible de trouver le nom de ce joueur. Vérifiez que celui-ci n'appartient actuellement à aucune alliance.<br />Impossible de créer une wing sans fondateur valide.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//On charge la liste des wings
|
||||
$bdd->reconnexion();
|
||||
$wings = $bdd->query("SELECT A.id, A.race, A.nom_alliance, A.tag, COUNT(U.id) AS nbMembres, V.id AS id_fondateur, V.pseudo AS pseudo_fondateur FROM $table_alliances A LEFT JOIN $table_user U ON U.id_alliance = A.id LEFT JOIN $table_user V ON V.id = A.fondateur WHERE galaxie = ".$planete->galaxie." AND ss = ".$planete->ss." AND wing != 0 GROUP BY A.id;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("wings", $wings);
|
||||
unset($wings);
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 'alliance/gestion_membres';
|
||||
$gestion = "membres";
|
||||
//On charge la liste des wings
|
||||
$bdd->reconnexion();
|
||||
$wings = $bdd->query("SELECT A.id, A.race, A.nom_alliance, A.tag, COUNT(U.id) AS nbMembres, V.id AS id_fondateur, V.pseudo AS pseudo_fondateur FROM $table_alliances A LEFT JOIN $table_user U ON U.id_alliance = A.id LEFT JOIN $table_user V ON V.id = A.fondateur WHERE galaxie = ".$planete->galaxie." AND ss = ".$planete->ss." AND wing != 0 GROUP BY A.id;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("wings", $wings);
|
||||
unset($wings);
|
||||
} else {
|
||||
$page = 'alliance/gestion_membres';
|
||||
$gestion = "membres";
|
||||
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &32))
|
||||
erreur("Vous n'avez pas le grade nécessaire pour modifier les membres !");
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &32)) {
|
||||
erreur("Vous n'avez pas le grade nécessaire pour modifier les membres !");
|
||||
}
|
||||
|
||||
//Acceptation ou refus des postulants
|
||||
if (!empty($_GET["pa"]))
|
||||
{
|
||||
$id = intval(gpc("pa"));
|
||||
$bdd->reconnexion();
|
||||
$user = $bdd->unique_query("SELECT U.id_alliance, U.pseudo, U.id AS id_user FROM $table_alliances_attente A INNER JOIN $table_user U ON A.id_user = U.id WHERE A.id_alliance = ".$planete->id." AND A.id = $id;");
|
||||
//Acceptation ou refus des postulants
|
||||
if (!empty($_GET["pa"])) {
|
||||
$id = intval(gpc("pa"));
|
||||
$bdd->reconnexion();
|
||||
$user = $bdd->unique_query("SELECT U.id_alliance, U.pseudo, U.id AS id_user FROM $table_alliances_attente A INNER JOIN $table_user U ON A.id_user = U.id WHERE A.id_alliance = ".$planete->id." AND A.id = $id;");
|
||||
|
||||
if (empty($user))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de trouver la candidature. Si le problème perciste, contactez un opérateur.");
|
||||
}
|
||||
elseif (!empty($user['id_alliance']))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Le joueur pour lequel vous souhaitez valider la condidature est actuellement dans une autre alliance. Vous ne pouvez donc pas l'accepter immédiatement.");
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->query("UPDATE $table_user SET id_alliance = ".$planete->id.", id_grade_alliance = 0 WHERE id = ".$user["id_user"].";");
|
||||
if ($bdd->affected())
|
||||
{
|
||||
$bdd->query("DELETE FROM $table_alliances_attente WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
send_mp($user["id_user"], "Candidature pour l'alliance [".$planete->tag."] ".$planete->nom_alliance, "Félicitations vous faites maintenant parti de l'alliance [".$planete->tag."] ".$planete->nom_alliance.".<br /><br />Après examen de votre candidature, le responsable du recrutement a jugé bon de vous accepter au sein de l'alliance.<br />Vous en faites donc désormais parti. Il ne vous reste plus qu'à vous démarquer pour monter dans les grades.<br /><br />Bon jeu !");
|
||||
erreur("Membre ajouté à l'alliance avec succès.<br />Un message privé vient de lui être envoyé afin de l'informer de la nouvelle.", "green");
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Une erreur s'est produite lors de l'ajout du joueur dans les membres de l'alliance.<br />Si le problème perciste, contactez un opérateur.");
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (!empty($_GET["pr"]))
|
||||
{
|
||||
$id = intval(gpc("pr"));
|
||||
$bdd->reconnexion();
|
||||
$user = $bdd->unique_query("SELECT U.id AS id_user FROM $table_alliances_attente A INNER JOIN $table_user U ON A.id_user = U.id WHERE A.id_alliance = ".$planete->id." AND A.id = $id;");
|
||||
$bdd->query("DELETE FROM $table_alliances_attente WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
if (empty($user)) {
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de trouver la candidature. Si le problème perciste, contactez un opérateur.");
|
||||
} elseif (!empty($user['id_alliance'])) {
|
||||
$bdd->deconnexion();
|
||||
erreur("Le joueur pour lequel vous souhaitez valider la condidature est actuellement dans une autre alliance. Vous ne pouvez donc pas l'accepter immédiatement.");
|
||||
} else {
|
||||
$bdd->query("UPDATE $table_user SET id_alliance = ".$planete->id.", id_grade_alliance = 0 WHERE id = ".$user["id_user"].";");
|
||||
if ($bdd->affected()) {
|
||||
$bdd->query("DELETE FROM $table_alliances_attente WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
send_mp($user["id_user"], "Candidature pour l'alliance [".$planete->tag."] ".$planete->nom_alliance, "Félicitations vous faites maintenant parti de l'alliance [".$planete->tag."] ".$planete->nom_alliance.".<br /><br />Après examen de votre candidature, le responsable du recrutement a jugé bon de vous accepter au sein de l'alliance.<br />Vous en faites donc désormais parti. Il ne vous reste plus qu'à vous démarquer pour monter dans les grades.<br /><br />Bon jeu !");
|
||||
erreur("Membre ajouté à l'alliance avec succès.<br />Un message privé vient de lui être envoyé afin de l'informer de la nouvelle.", "green");
|
||||
} else {
|
||||
$bdd->deconnexion();
|
||||
erreur("Une erreur s'est produite lors de l'ajout du joueur dans les membres de l'alliance.<br />Si le problème perciste, contactez un opérateur.");
|
||||
}
|
||||
}
|
||||
} elseif (!empty($_GET["pr"])) {
|
||||
$id = intval(gpc("pr"));
|
||||
$bdd->reconnexion();
|
||||
$user = $bdd->unique_query("SELECT U.id AS id_user FROM $table_alliances_attente A INNER JOIN $table_user U ON A.id_user = U.id WHERE A.id_alliance = ".$planete->id." AND A.id = $id;");
|
||||
$bdd->query("DELETE FROM $table_alliances_attente WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
send_mp($user["id_user"], "Candidature pour l'alliance [".$planete->tag."] ".$planete->nom_alliance, "Nous avons le regret de vous annoncer que l'alliance [".$planete->tag."] ".$planete->nom_alliance." a refusé votre candidature.<br /><br />Après examen de votre candidature, le responsable du recrutement a jugé bon de vous écarter de l'alliance.<br />Pour plus d'informations, veuillez contacter directement le responsable du recrutement.");
|
||||
erreur("Candidature refusée.<br />Un message privé vient d'être envoyé au joueur afin de l'informer de la nouvelle.", "orange");
|
||||
}
|
||||
//Gestion des exclusions de l'alliance
|
||||
elseif (!empty($_GET["u"]))
|
||||
{
|
||||
$id = intval(gpc("u"));
|
||||
if ($planete->fondateur == $id)
|
||||
erreur("Vous ne pouvez pas exclure le fondateur de sa propre alliance.<br />En cas de problème avec le fondateur, veuillez contacter un opérateur.");
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("UPDATE $table_user SET id_alliance = 0, id_grade_alliance = 0 WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
send_mp($user["id_user"], "Candidature pour l'alliance [".$planete->tag."] ".$planete->nom_alliance, "Nous avons le regret de vous annoncer que l'alliance [".$planete->tag."] ".$planete->nom_alliance." a refusé votre candidature.<br /><br />Après examen de votre candidature, le responsable du recrutement a jugé bon de vous écarter de l'alliance.<br />Pour plus d'informations, veuillez contacter directement le responsable du recrutement.");
|
||||
erreur("Candidature refusée.<br />Un message privé vient d'être envoyé au joueur afin de l'informer de la nouvelle.", "orange");
|
||||
}
|
||||
//Gestion des exclusions de l'alliance
|
||||
elseif (!empty($_GET["u"])) {
|
||||
$id = intval(gpc("u"));
|
||||
if ($planete->fondateur == $id) {
|
||||
erreur("Vous ne pouvez pas exclure le fondateur de sa propre alliance.<br />En cas de problème avec le fondateur, veuillez contacter un opérateur.");
|
||||
}
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("UPDATE $table_user SET id_alliance = 0, id_grade_alliance = 0 WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($bdd->affected())
|
||||
{
|
||||
send_mp($id, "Exclusion de votre alliance [".$planete->tag."] ".$planete->nom_alliance, "Vous vennez d'être exclus de votre alliance [".$planete->tag."] ".$planete->nom_alliance."<br />Pour plus d'informations, veuillez contacter directement le responsable du recrutement.");
|
||||
erreur("Membre renvoyé.<br />Un message privé vient de lui être envoyé afin de l'informer de la nouvelle.", "orange");
|
||||
}
|
||||
else
|
||||
erreur("Membre introuvable !");
|
||||
}
|
||||
if ($bdd->affected()) {
|
||||
send_mp($id, "Exclusion de votre alliance [".$planete->tag."] ".$planete->nom_alliance, "Vous vennez d'être exclus de votre alliance [".$planete->tag."] ".$planete->nom_alliance."<br />Pour plus d'informations, veuillez contacter directement le responsable du recrutement.");
|
||||
erreur("Membre renvoyé.<br />Un message privé vient de lui être envoyé afin de l'informer de la nouvelle.", "orange");
|
||||
} else {
|
||||
erreur("Membre introuvable !");
|
||||
}
|
||||
}
|
||||
|
||||
$id = intval(gpc("i"));
|
||||
if (!empty($id))
|
||||
{
|
||||
$grade = intval(gpc('grade', 'post'));
|
||||
$id = intval(gpc("i"));
|
||||
if (!empty($id)) {
|
||||
$grade = intval(gpc('grade', 'post'));
|
||||
|
||||
$bdd->reconnexion();
|
||||
$gradet = $bdd->unique_query("SELECT id FROM $table_alliances_grade WHERE id_alliance = ".$planete->id." AND id = $grade;");
|
||||
if (!empty($gradet) || $grade == 0)
|
||||
$bdd->query("UPDATE $table_user SET id_grade_alliance = $grade WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
$bdd->deconnexion();
|
||||
$bdd->reconnexion();
|
||||
$gradet = $bdd->unique_query("SELECT id FROM $table_alliances_grade WHERE id_alliance = ".$planete->id." AND id = $grade;");
|
||||
if (!empty($gradet) || $grade == 0) {
|
||||
$bdd->query("UPDATE $table_user SET id_grade_alliance = $grade WHERE id_alliance = ".$planete->id." AND id = $id;");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=gestion&g=membres');
|
||||
exit;
|
||||
}
|
||||
header('Location: ?p=gestion&g=membres');
|
||||
exit;
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$membres = $bdd->query("SELECT id, pseudo, race, last_visite, id_grade_alliance FROM $table_user WHERE id_alliance = ".$planete->id.";");
|
||||
$grades = $bdd->query("SELECT id, id_alliance, nom, auth FROM $table_alliances_grade WHERE id_alliance = ".$planete->id.";");
|
||||
$postulants = $bdd->query("SELECT A.id, A.timestamp, A.message, U.pseudo, U.id AS id_user FROM $table_alliances_attente A INNER JOIN $table_user U ON A.id_user = U.id WHERE A.id_alliance = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("membres", $membres);
|
||||
$template->assign("grades", $grades);
|
||||
$template->assign("postulants", $postulants);
|
||||
$bdd->reconnexion();
|
||||
$membres = $bdd->query("SELECT id, pseudo, race, last_visite, id_grade_alliance FROM $table_user WHERE id_alliance = ".$planete->id.";");
|
||||
$grades = $bdd->query("SELECT id, id_alliance, nom, auth FROM $table_alliances_grade WHERE id_alliance = ".$planete->id.";");
|
||||
$postulants = $bdd->query("SELECT A.id, A.timestamp, A.message, U.pseudo, U.id AS id_user FROM $table_alliances_attente A INNER JOIN $table_user U ON A.id_user = U.id WHERE A.id_alliance = ".$planete->id.";");
|
||||
$bdd->deconnexion();
|
||||
$template->assign("membres", $membres);
|
||||
$template->assign("grades", $grades);
|
||||
$template->assign("postulants", $postulants);
|
||||
|
||||
unset($membres, $grades, $grade, $id, $postulants);
|
||||
unset($membres, $grades, $grade, $id, $postulants);
|
||||
}
|
||||
|
||||
$template->assign("onglet", $gestion);
|
||||
unset($gestion);
|
||||
?>
|
||||
|
|
@ -1,94 +1,93 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$page = 'messagerie';
|
||||
$titre = 'Messagerie d\'alliance';
|
||||
$template->assign("link_P", "alli_messagerie");
|
||||
$template->assign("titreR", $titre);
|
||||
|
||||
//On interdit l'accès à la messagerie en cas de prise de contrôle d'un joueur
|
||||
if (!empty($sess->values['souscontrole'][0]))
|
||||
erreur('Vous êtes en mode prise de contrôle, vous ne pouvez pas accèder aux messages privés des joueurs.');
|
||||
if (!empty($sess->values['souscontrole'][0])) {
|
||||
erreur('Vous êtes en mode prise de contrôle, vous ne pouvez pas accèder aux messages privés des joueurs.');
|
||||
}
|
||||
|
||||
if ($id = intval(gpc('avertir')))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("UPDATE $table_alliances_mail SET statut = 1 WHERE destinataire = ".$planete->id." AND id = $id;");
|
||||
if ($bdd->affected())
|
||||
erreur('La demande de vérification de contenu par les opérateurs a été transmise avec succès.', 'green', '?p=messagerie');
|
||||
else
|
||||
erreur('Une demande est déjà en cours ou vous n\'êtes pas autorisé à avertir ce message.', 'red', '?p=messagerie');
|
||||
$bdd->deconnexion();
|
||||
if ($id = intval(gpc('avertir'))) {
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("UPDATE $table_alliances_mail SET statut = 1 WHERE destinataire = ".$planete->id." AND id = $id;");
|
||||
if ($bdd->affected()) {
|
||||
erreur('La demande de vérification de contenu par les opérateurs a été transmise avec succès.', 'green', '?p=messagerie');
|
||||
} else {
|
||||
erreur('Une demande est déjà en cours ou vous n\'êtes pas autorisé à avertir ce message.', 'red', '?p=messagerie');
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
//On récupére l'onglet demandé
|
||||
$onglet = gpc('n');
|
||||
$template->assign('onglet', $onglet);
|
||||
|
||||
if ($onglet == "rapports")
|
||||
{
|
||||
//Demande de supression des messages
|
||||
if (!empty($_POST))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
foreach($_POST as $value)
|
||||
$bdd->query("UPDATE $table_alliances_mail SET vu = 's' WHERE destinataire = ".$planete->id." AND id = ".intval($value).";");
|
||||
$bdd->deconnexion();
|
||||
if ($onglet == "rapports") {
|
||||
//Demande de supression des messages
|
||||
if (!empty($_POST)) {
|
||||
$bdd->reconnexion();
|
||||
foreach ($_POST as $value) {
|
||||
$bdd->query("UPDATE $table_alliances_mail SET vu = 's' WHERE destinataire = ".$planete->id." AND id = ".intval($value).";");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=messagerie&n='.$onglet);
|
||||
exit;
|
||||
}
|
||||
header('Location: ?p=messagerie&n='.$onglet);
|
||||
exit;
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT * FROM $table_alliances_mail WHERE destinataire = ".$planete->id." AND expediteur = false AND vu != 's' ORDER BY id DESC;");
|
||||
$bdd->query("UPDATE $table_alliances_mail SET vu = 0 WHERE destinataire = ".$planete->id." AND expediteur = false AND vu != 's';");
|
||||
$bdd->deconnexion();
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT * FROM $table_alliances_mail WHERE destinataire = ".$planete->id." AND expediteur = false AND vu != 's' ORDER BY id DESC;");
|
||||
$bdd->query("UPDATE $table_alliances_mail SET vu = 0 WHERE destinataire = ".$planete->id." AND expediteur = false AND vu != 's';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('messages', $data);
|
||||
}
|
||||
elseif ($onglet == "send")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS destinataire FROM $table_alliances_mail M INNER JOIN $table_user U ON U.id = M.destinataire WHERE M.expediteur = ".$planete->id." ORDER BY M.id DESC;");
|
||||
$bdd->deconnexion();
|
||||
$template->assign('messages', $data);
|
||||
} elseif ($onglet == "send") {
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS destinataire FROM $table_alliances_mail M INNER JOIN $table_user U ON U.id = M.destinataire WHERE M.expediteur = ".$planete->id." ORDER BY M.id DESC;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign('messages', $data);
|
||||
}
|
||||
elseif ($onglet == "envoyer")
|
||||
{
|
||||
$page = 'envoyer';
|
||||
$titre = 'Envoyer un message';
|
||||
$template->assign('messages', $data);
|
||||
} elseif ($onglet == "envoyer") {
|
||||
$page = 'envoyer';
|
||||
$titre = 'Envoyer un message';
|
||||
|
||||
if (!empty($_POST['objet']) && !empty($_POST['destinataire']) && !empty($_POST['message']))
|
||||
{
|
||||
$utils = explode(';', gpc('destinataire', 'post'));
|
||||
$nbutil = count($utils);
|
||||
if (!empty($_POST['objet']) && !empty($_POST['destinataire']) && !empty($_POST['message'])) {
|
||||
$utils = explode(';', gpc('destinataire', 'post'));
|
||||
$nbutil = count($utils);
|
||||
|
||||
$time = time();
|
||||
$message = htmlspecialchars(gpc('message', 'post'));
|
||||
$objet = htmlspecialchars(gpc('objet', 'post'));
|
||||
$time = time();
|
||||
$message = htmlspecialchars(gpc('message', 'post'));
|
||||
$objet = htmlspecialchars(gpc('objet', 'post'));
|
||||
|
||||
if (strlen($message) > 99999)
|
||||
erreur('Le contenu de votre message est trop long. Limite : 99 999 caractères.');
|
||||
if (empty($utils))
|
||||
erreur('Aucun utilisateur sélectionné.');
|
||||
if (strlen($message) > 99999) {
|
||||
erreur('Le contenu de votre message est trop long. Limite : 99 999 caractères.');
|
||||
}
|
||||
if (empty($utils)) {
|
||||
erreur('Aucun utilisateur sélectionné.');
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($message);
|
||||
$bdd->escape($objet);
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($message);
|
||||
$bdd->escape($objet);
|
||||
|
||||
$introuv = array();
|
||||
foreach($utils as $util)
|
||||
{
|
||||
if (empty($util))
|
||||
continue;
|
||||
$util = trim($util);
|
||||
$bdd->escape($util);
|
||||
$introuv = array();
|
||||
foreach ($utils as $util) {
|
||||
if (empty($util)) {
|
||||
continue;
|
||||
}
|
||||
$util = trim($util);
|
||||
$bdd->escape($util);
|
||||
|
||||
if ($util != $planete->pseudo && $env = $bdd->unique_query("SELECT id, pseudo, mail, envoyerMail FROM $table_user WHERE pseudo = '$util';"))
|
||||
{
|
||||
$bdd->query("INSERT INTO $table_alliances_mail (destinataire, expediteur, sujet, contenu, temps) VALUES(".$env['id'].", ".$planete->id_user.", '$objet', '$message', $time);");
|
||||
if ($env["envoyerMail"]& 2 && !empty($env["mail"]))
|
||||
send_mail($env["mail"], "Halo-Battle :: Nouveau message privé", 'Bonjour '.$env["pseudo"].',
|
||||
if ($util != $planete->pseudo && $env = $bdd->unique_query("SELECT id, pseudo, mail, envoyerMail FROM $table_user WHERE pseudo = '$util';")) {
|
||||
$bdd->query("INSERT INTO $table_alliances_mail (destinataire, expediteur, sujet, contenu, temps) VALUES(".$env['id'].", ".$planete->id_user.", '$objet', '$message', $time);");
|
||||
if ($env["envoyerMail"]& 2 && !empty($env["mail"])) {
|
||||
send_mail($env["mail"], "Halo-Battle :: Nouveau message privé", 'Bonjour '.$env["pseudo"].',
|
||||
|
||||
Vous recevez ce courriel suite à l\'arrivée d\'un nouveau message privé reçu sur votre compte de jeu du serveur '.$VAR['serveur_name'].'. Le sujet de ce message est : "'.$objet.'" et a été envoyé par '.$planete->pseudo.'. Vous pouvez utiliser le lien suivant pour voir le message ou vous connecter.
|
||||
|
||||
|
|
@ -98,74 +97,76 @@ elseif ($onglet == "envoyer")
|
|||
|
||||
A bientôt dans Halo-Battle,
|
||||
Le Staff');
|
||||
}
|
||||
else
|
||||
$introuv[] = htmlentities($util);
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
} else {
|
||||
$introuv[] = htmlentities($util);
|
||||
}
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($introuv[0]))
|
||||
erreur('Impossible de trouver le/les destinataire(s) suivant(s) : '.implode(', ', $introuv).'.<br />Les autres ont bien reçu votre message.', "red", '?p=messagerie&n=envoyer');
|
||||
else
|
||||
erreur('Votre message a été envoyé avec succès.', "green", '?p=messagerie');
|
||||
}
|
||||
if (!empty($introuv[0])) {
|
||||
erreur('Impossible de trouver le/les destinataire(s) suivant(s) : '.implode(', ', $introuv).'.<br />Les autres ont bien reçu votre message.', "red", '?p=messagerie&n=envoyer');
|
||||
} else {
|
||||
erreur('Votre message a été envoyé avec succès.', "green", '?p=messagerie');
|
||||
}
|
||||
}
|
||||
|
||||
$amis = array();
|
||||
$amisn = array();
|
||||
$bdd->reconnexion();
|
||||
foreach($planete->amis as $ami) {
|
||||
$res = $bdd->unique_query("SELECT pseudo FROM $table_user WHERE id = ".$ami.";");
|
||||
if ($res != false) {
|
||||
$amis[] = $res['pseudo'];
|
||||
$amisn[] = $ami;
|
||||
}
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
$template->assign('amis', $amis);
|
||||
$template->assign('amisn', $amisn);
|
||||
$amis = array();
|
||||
$amisn = array();
|
||||
$bdd->reconnexion();
|
||||
foreach ($planete->amis as $ami) {
|
||||
$res = $bdd->unique_query("SELECT pseudo FROM $table_user WHERE id = ".$ami.";");
|
||||
if ($res != false) {
|
||||
$amis[] = $res['pseudo'];
|
||||
$amisn[] = $ami;
|
||||
}
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
$template->assign('amis', $amis);
|
||||
$template->assign('amisn', $amisn);
|
||||
|
||||
if (isset($_GET['d'])) $template->assign('destinataire', gpc('d'));
|
||||
if (isset($_GET['o'])) $template->assign('objet', gpc('o'));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Demande de supression des messages
|
||||
if (!empty($_POST))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
foreach($_POST as $value)
|
||||
$bdd->query("DELETE FROM $table_alliances_mail WHERE destinataire = ".$planete->id_user." AND id = ".intval($value).";");
|
||||
$bdd->deconnexion();
|
||||
if (isset($_GET['d'])) {
|
||||
$template->assign('destinataire', gpc('d'));
|
||||
}
|
||||
if (isset($_GET['o'])) {
|
||||
$template->assign('objet', gpc('o'));
|
||||
}
|
||||
} else {
|
||||
//Demande de supression des messages
|
||||
if (!empty($_POST)) {
|
||||
$bdd->reconnexion();
|
||||
foreach ($_POST as $value) {
|
||||
$bdd->query("DELETE FROM $table_alliances_mail WHERE destinataire = ".$planete->id_user." AND id = ".intval($value).";");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
header('Location: ?p=messagerie&n='.$onglet);
|
||||
exit;
|
||||
}
|
||||
header('Location: ?p=messagerie&n='.$onglet);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($SESS->level >= 3)
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS expediteur FROM $table_alliances_mail M INNER JOIN $table_user U ON U.id = M.expediteur WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$bdd->query("UPDATE $table_alliances_mail M SET vu = 0 WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
//Calcul du nombre total de message enregistré
|
||||
$nbmax = $bdd->query("SELECT COUNT(id) as nb FROM $table_alliances_mail M WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS expediteur FROM $table_alliances_mail M INNER JOIN $table_user U ON U.id = M.expediteur WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC LIMIT 50;");
|
||||
$bdd->query("UPDATE $table_alliances_mail M SET vu = 0 WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC LIMIT 50;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
if ($SESS->level >= 3) {
|
||||
$bdd->reconnexion();
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS expediteur FROM $table_alliances_mail M INNER JOIN $table_user U ON U.id = M.expediteur WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$bdd->query("UPDATE $table_alliances_mail M SET vu = 0 WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$bdd->deconnexion();
|
||||
} else {
|
||||
$bdd->reconnexion();
|
||||
//Calcul du nombre total de message enregistré
|
||||
$nbmax = $bdd->query("SELECT COUNT(id) as nb FROM $table_alliances_mail M WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC;");
|
||||
$data = $bdd->query("SELECT M.*, U.pseudo AS expediteur FROM $table_alliances_mail M INNER JOIN $table_user U ON U.id = M.expediteur WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC LIMIT 50;");
|
||||
$bdd->query("UPDATE $table_alliances_mail M SET vu = 0 WHERE M.destinataire = ".$planete->id_user." AND M.expediteur != false ORDER BY M.id DESC LIMIT 50;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
if ($SESS->level < 3 && $nbmax > $bdd->num_rows)
|
||||
$template->assign('avertissement', '<p style="color: red;"><b>Vous avez des messages en attente de réception. Libérez de la place dans votre messagerie pour les afficher.</b></p>');
|
||||
if ($SESS->level < 3 && $nbmax > $bdd->num_rows) {
|
||||
$template->assign('avertissement', '<p style="color: red;"><b>Vous avez des messages en attente de réception. Libérez de la place dans votre messagerie pour les afficher.</b></p>');
|
||||
}
|
||||
|
||||
$template->assign('messages', $data);
|
||||
$template->assign('messages', $data);
|
||||
}
|
||||
|
||||
unset($onglet, $data, $nbmax);
|
||||
|
||||
if ($bdd->num_rows)
|
||||
$template->assign('IM', $bdd->num_rows);
|
||||
?>
|
||||
if ($bdd->num_rows) {
|
||||
$template->assign('IM', $bdd->num_rows);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,39 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval(gpc('postuler'));
|
||||
$message = gpc('motivation', 'post');
|
||||
$page = 'alliance/nm_postuler';
|
||||
|
||||
if (!empty($message))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($message);
|
||||
$postul = $bdd->unique_query("SELECT id FROM $table_alliances_attente WHERE id_alliance = $id AND id_membre = ".$planete->id_user." LIMIT 1;");
|
||||
if (empty($postul))
|
||||
$bdd->query("INSERT INTO $table_alliances_attente (id_alliance, id_user, timestamp, message) VALUES ($id, ".$planete->id_user.", ".time().", '$message');");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (empty($postul))
|
||||
erreur("Votre demande d'adhésion a été envoyée avec succès, vous aurez une réponse dès qu'un dirigeant de l'alliance se connectera.", "green", $VAR["menu"]["alliance"]."&v=".$id, 5000);
|
||||
else
|
||||
redirection($VAR["menu"]["alliance"]."&postuler=".$id);
|
||||
if (!empty($message)) {
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($message);
|
||||
$postul = $bdd->unique_query("SELECT id FROM $table_alliances_attente WHERE id_alliance = $id AND id_membre = ".$planete->id_user." LIMIT 1;");
|
||||
if (empty($postul)) {
|
||||
$bdd->query("INSERT INTO $table_alliances_attente (id_alliance, id_user, timestamp, message) VALUES ($id, ".$planete->id_user.", ".time().", '$message');");
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$postul = $bdd->unique_query("SELECT id FROM $table_alliances_attente WHERE id_alliance = $id AND id_membre = ".$planete->id_user." LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
$bdd->deconnexion();
|
||||
|
||||
|
||||
if (!empty($postul))
|
||||
erreur("Vous avez déjà une candidature en cours pour cette alliance !", "red", $VAR["menu"]["alliance"]."&v=".$id, 3000);
|
||||
elseif (!empty($alliance))
|
||||
$template->assign("alliance", $alliance);
|
||||
else
|
||||
redirection($VAR["menu"]["alliance"]);
|
||||
if (empty($postul)) {
|
||||
erreur("Votre demande d'adhésion a été envoyée avec succès, vous aurez une réponse dès qu'un dirigeant de l'alliance se connectera.", "green", $VAR["menu"]["alliance"]."&v=".$id, 5000);
|
||||
} else {
|
||||
redirection($VAR["menu"]["alliance"]."&postuler=".$id);
|
||||
}
|
||||
?>
|
||||
} else {
|
||||
$bdd->reconnexion();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$postul = $bdd->unique_query("SELECT id FROM $table_alliances_attente WHERE id_alliance = $id AND id_membre = ".$planete->id_user." LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
|
||||
if (!empty($postul)) {
|
||||
erreur("Vous avez déjà une candidature en cours pour cette alliance !", "red", $VAR["menu"]["alliance"]."&v=".$id, 3000);
|
||||
} elseif (!empty($alliance)) {
|
||||
$template->assign("alliance", $alliance);
|
||||
} else {
|
||||
redirection($VAR["menu"]["alliance"]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,129 +1,120 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$act = gpc('q');
|
||||
|
||||
if ($act == "fonder")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
//On regarde si le joueur n'est pas déjà en train de fonder une alliance
|
||||
if (!$alli = $bdd->query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." OR signatures LIKE '%;".$planete->id_user.";%';"))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
$page = 'alliance/nm_fonder';
|
||||
if ($act == "fonder") {
|
||||
$bdd->reconnexion();
|
||||
//On regarde si le joueur n'est pas déjà en train de fonder une alliance
|
||||
if (!$alli = $bdd->query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." OR signatures LIKE '%;".$planete->id_user.";%';")) {
|
||||
$bdd->deconnexion();
|
||||
$page = 'alliance/nm_fonder';
|
||||
|
||||
$nom = gpc('nom', 'post');
|
||||
$tag = gpc('tag', 'post');
|
||||
if (!empty($nom) || !empty($tag))
|
||||
{
|
||||
//Vérifications
|
||||
if (!preg_match("#^[A-Za-z0-9èéàùûüôöç'_ -]{5,42}$#ui", $nom))
|
||||
erreur("Le nom d'alliance que vous avez choisi n'est pas valide :<br />il doit avoir entre 5 et 42 caractères (certains accents sont autorisés, mais aucun caractères spéciaux) !", "red");
|
||||
elseif (!preg_match("#^[A-Za-z0-9]{3,5}$#ui", $tag))
|
||||
erreur("Le tag d'alliance que vous avez choisi n'est pas valide :<br />il doit avoir entre 3 et 5 lettres (sans accents) ou chiffres !", "red");
|
||||
$nom = gpc('nom', 'post');
|
||||
$tag = gpc('tag', 'post');
|
||||
if (!empty($nom) || !empty($tag)) {
|
||||
//Vérifications
|
||||
if (!preg_match("#^[A-Za-z0-9èéàùûüôöç'_ -]{5,42}$#ui", $nom)) {
|
||||
erreur("Le nom d'alliance que vous avez choisi n'est pas valide :<br />il doit avoir entre 5 et 42 caractères (certains accents sont autorisés, mais aucun caractères spéciaux) !", "red");
|
||||
} elseif (!preg_match("#^[A-Za-z0-9]{3,5}$#ui", $tag)) {
|
||||
erreur("Le tag d'alliance que vous avez choisi n'est pas valide :<br />il doit avoir entre 3 et 5 lettres (sans accents) ou chiffres !", "red");
|
||||
}
|
||||
|
||||
$lien = sha1($tag.'Hb$'.$nom.'☺Ø'.$planete->id_user.'‘«'.$planete->race);
|
||||
$lien = sha1($tag.'Hb$'.$nom.'☺Ø'.$planete->id_user.'‘«'.$planete->race);
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom);
|
||||
$bdd->escape($tag);
|
||||
$utilise = $bdd->query("SELECT id FROM $table_alliances WHERE nom_alliance = '$nom' OR tag = '$tag' OR fondateur = ".$planete->id_user." UNION SELECT id FROM $table_alliances_creation WHERE nom_alliance = '$nom' OR tag = '$tag' OR fondateur = ".$planete->id_user.";");
|
||||
if (empty($utilise))
|
||||
$bdd->query("INSERT INTO $table_alliances_creation (tag, nom_alliance, fondateur, lien) VALUES ('$tag', '$nom', ".$planete->id_user.", '$lien');");
|
||||
$bdd->deconnexion();
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom);
|
||||
$bdd->escape($tag);
|
||||
$utilise = $bdd->query("SELECT id FROM $table_alliances WHERE nom_alliance = '$nom' OR tag = '$tag' OR fondateur = ".$planete->id_user." UNION SELECT id FROM $table_alliances_creation WHERE nom_alliance = '$nom' OR tag = '$tag' OR fondateur = ".$planete->id_user.";");
|
||||
if (empty($utilise)) {
|
||||
$bdd->query("INSERT INTO $table_alliances_creation (tag, nom_alliance, fondateur, lien) VALUES ('$tag', '$nom', ".$planete->id_user.", '$lien');");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($utilise))
|
||||
erreur("Le nom ou le tag que vous avez choisi est déjà utilisé par une alliance.", "red");
|
||||
else
|
||||
{
|
||||
send_mp($planete->id_user, "Fondation de votre alliance !", 'Pour terminer la création de votre alliance, trouvez au moins '.nb_signatures.' joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature :<br /><a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>');
|
||||
erreur('Votre alliance a bien été créée.<br />Il ne vous reste plus qu\'à trouver au moins '.nb_signatures.' signatures pour finir la création de votre alliance.<br /><br />Le lien permettant à vos quatres personnes de signer est <a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>', "green");
|
||||
}
|
||||
}
|
||||
unset($nom, $tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 'alliance/nm_statut';
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE id = ".$alli[0]["id"].";");
|
||||
if (!empty($utilise)) {
|
||||
erreur("Le nom ou le tag que vous avez choisi est déjà utilisé par une alliance.", "red");
|
||||
} else {
|
||||
send_mp($planete->id_user, "Fondation de votre alliance !", 'Pour terminer la création de votre alliance, trouvez au moins '.nb_signatures.' joueurs de cette galaxie sans alliance pour leur faire signer votre traité de fondation d\'alliance.<br /><br />Lien de signature :<br /><a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>');
|
||||
erreur('Votre alliance a bien été créée.<br />Il ne vous reste plus qu\'à trouver au moins '.nb_signatures.' signatures pour finir la création de votre alliance.<br /><br />Le lien permettant à vos quatres personnes de signer est <a href="'.$VAR["menu"]["alliance"].'&signer='.$lien.'">http://'.$_SERVER['HTTP_HOST'].'/'.$VAR["first_page"].''.$VAR["menu"]["alliance"].'&signer='.$lien.'</a>', "green");
|
||||
}
|
||||
}
|
||||
unset($nom, $tag);
|
||||
} else {
|
||||
$page = 'alliance/nm_statut';
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE id = ".$alli[0]["id"].";");
|
||||
|
||||
$signatures = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
$signaturesExport = implode(' OR id = ', $signatures);
|
||||
$pseudos = $bdd->query("SELECT pseudo FROM $table_user WHERE id = ".$signaturesExport.";");
|
||||
$bdd->deconnexion();
|
||||
$signatures = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
$signaturesExport = implode(' OR id = ', $signatures);
|
||||
$pseudos = $bdd->query("SELECT pseudo FROM $table_user WHERE id = ".$signaturesExport.";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (gpc('r') == "quit")
|
||||
{
|
||||
if ($alliance["fondateur"] == $planete->id_user)
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("DELETE FROM $table_alliances_creation WHERE id = ".$alli[0]["id"].";");
|
||||
$bdd->deconnexion();
|
||||
if (gpc('r') == "quit") {
|
||||
if ($alliance["fondateur"] == $planete->id_user) {
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("DELETE FROM $table_alliances_creation WHERE id = ".$alli[0]["id"].";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
foreach ($signatures as $id_user)
|
||||
{
|
||||
send_mp($id_user, "Annulation de la fondation de votre alliance !", "Le fondateur de l'alliance pour laquelle vous avez signée vient d'annuler sa création.");
|
||||
}
|
||||
foreach ($signatures as $id_user) {
|
||||
send_mp($id_user, "Annulation de la fondation de votre alliance !", "Le fondateur de l'alliance pour laquelle vous avez signée vient d'annuler sa création.");
|
||||
}
|
||||
|
||||
send_mp($planete->id_user, "Annulation de la fondation de votre alliance !", "Vous vennez d'annuler la création de votre alliance.");
|
||||
erreur("Votre alliance vient d'être supprimée", "green");
|
||||
}
|
||||
else
|
||||
{
|
||||
$keys = array_keys($signatures, $planete->id_user);
|
||||
foreach ($keys as $key)
|
||||
unset($signatures[$key]);
|
||||
send_mp($planete->id_user, "Annulation de la fondation de votre alliance !", "Vous vennez d'annuler la création de votre alliance.");
|
||||
erreur("Votre alliance vient d'être supprimée", "green");
|
||||
} else {
|
||||
$keys = array_keys($signatures, $planete->id_user);
|
||||
foreach ($keys as $key) {
|
||||
unset($signatures[$key]);
|
||||
}
|
||||
|
||||
$signatures = ";".implode(';', $signatures).";";
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($signatures);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '$signatures' WHERE id = ".$alliance["id"].";");
|
||||
$bdd->deconnexion();
|
||||
$signatures = ";".implode(';', $signatures).";";
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($signatures);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '$signatures' WHERE id = ".$alliance["id"].";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
send_mp($planete->id_user, "Annulation de la signature pour votre alliance !", "Vous vennez d'annuler votre signature pour l'alliance ".$alliance["nom"]);
|
||||
erreur("Votre signature a été rayée.", "green");
|
||||
}
|
||||
}
|
||||
send_mp($planete->id_user, "Annulation de la signature pour votre alliance !", "Vous vennez d'annuler votre signature pour l'alliance ".$alliance["nom"]);
|
||||
erreur("Votre signature a été rayée.", "green");
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("signatures", $signatures);
|
||||
$template->assign("pseudos", $pseudos);
|
||||
$template->assign("nbSignatures", count($signatures));
|
||||
}
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("signatures", $signatures);
|
||||
$template->assign("pseudos", $pseudos);
|
||||
$template->assign("nbSignatures", count($signatures));
|
||||
}
|
||||
} elseif (!empty($_POST['search_tag']) || !empty($_POST['search_nom'])) {
|
||||
$page = 'alliance/nm_search';
|
||||
|
||||
$tag = gpc('search_tag', 'post');
|
||||
$nom = str_replace("*", "%", gpc('search_nom', 'post'));
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($tag);
|
||||
$bdd->escape($nom);
|
||||
$rech1 = $bdd->query("SELECT id, tag, nom_alliance, race, etat_inscription FROM $table_alliances WHERE tag LIKE '$tag%' AND nom_alliance LIKE '%$nom%';");
|
||||
$rech2 = $bdd->query("SELECT lien AS id, tag, nom_alliance, 0 AS race, 2 AS etat_inscription FROM $table_alliances_creation WHERE tag LIKE '$tag%' AND nom_alliance LIKE '%$nom%';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($rech1) && !empty($rech2)) {
|
||||
$recherche = array_merge($rech1, $rech2);
|
||||
} elseif (!empty($rech2)) {
|
||||
$recherche = $rech2;
|
||||
} else {
|
||||
$recherche = $rech1;
|
||||
}
|
||||
|
||||
if ($bdd->num_rows == 1) {
|
||||
redirection($VAR["menu"]["alliance"]."&v=".$recherche[0]['id']);
|
||||
} elseif ($bdd->num_rows == 0) {
|
||||
erreur("Aucune alliance ne correspond à ces critères de recherche", "", $VAR["menu"]["alliance"]);
|
||||
}
|
||||
|
||||
$template->assign("recherches", $recherche);
|
||||
unset($nom, $tag, $recherche);
|
||||
} else {
|
||||
$bdd->reconnexion();
|
||||
$template->assign("fondation", $bdd->query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." OR signatures LIKE '%;".$planete->id_user.";%';"));
|
||||
$page = 'alliance/nm_accueil';
|
||||
}
|
||||
elseif (!empty($_POST['search_tag']) || !empty($_POST['search_nom']))
|
||||
{
|
||||
$page = 'alliance/nm_search';
|
||||
|
||||
$tag = gpc('search_tag', 'post');
|
||||
$nom = str_replace("*", "%", gpc('search_nom', 'post'));
|
||||
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($tag);
|
||||
$bdd->escape($nom);
|
||||
$rech1 = $bdd->query("SELECT id, tag, nom_alliance, race, etat_inscription FROM $table_alliances WHERE tag LIKE '$tag%' AND nom_alliance LIKE '%$nom%';");
|
||||
$rech2 = $bdd->query("SELECT lien AS id, tag, nom_alliance, 0 AS race, 2 AS etat_inscription FROM $table_alliances_creation WHERE tag LIKE '$tag%' AND nom_alliance LIKE '%$nom%';");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($rech1) && !empty($rech2))
|
||||
$recherche = array_merge($rech1, $rech2);
|
||||
elseif (!empty($rech2))
|
||||
$recherche = $rech2;
|
||||
else
|
||||
$recherche = $rech1;
|
||||
|
||||
if ($bdd->num_rows == 1)
|
||||
redirection($VAR["menu"]["alliance"]."&v=".$recherche[0]['id']);
|
||||
elseif ($bdd->num_rows == 0)
|
||||
erreur("Aucune alliance ne correspond à ces critères de recherche", "", $VAR["menu"]["alliance"]);
|
||||
|
||||
$template->assign("recherches", $recherche);
|
||||
unset($nom, $tag, $recherche);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$template->assign("fondation", $bdd->query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." OR signatures LIKE '%;".$planete->id_user.";%';"));
|
||||
$page = 'alliance/nm_accueil';
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,98 +1,93 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$hash = gpc('signer');
|
||||
|
||||
$page = 'alliance/nm_signer';
|
||||
if (!empty($planete->id_alliance))
|
||||
erreur("Vous êtes déjà dans une alliance, vous ne pouvez pas ratifier d'alliance !", "red");
|
||||
elseif (!empty($_POST["sign"]))
|
||||
{
|
||||
if (trim(strtolower(gpc("sign", "post"))) == "oui")
|
||||
{
|
||||
$hash = intval($hash);
|
||||
$bdd->reconnexion();
|
||||
$ratifier = $bdd->unique_query("SELECT id, fondateur, signatures FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
if (!empty($ratifier))
|
||||
{
|
||||
$ratifier["signatures"] = explode(';', substr($ratifier["signatures"], 1), -1);
|
||||
unset($ratifier["signatures"][array_search($planete->id_user, $ratifier["signatures"])]);
|
||||
if (count($ratifier["signatures"]) == 0)
|
||||
$ratifier["signatures"] = "";
|
||||
else
|
||||
$ratifier["signatures"] = ';'.implode(';', $ratifier["signatures"]).';';
|
||||
$bdd->escape($ratifier["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$ratifier["signatures"]."' WHERE id = ".$ratifier["id"].";");
|
||||
}
|
||||
if (!empty($planete->id_alliance)) {
|
||||
erreur("Vous êtes déjà dans une alliance, vous ne pouvez pas ratifier d'alliance !", "red");
|
||||
} elseif (!empty($_POST["sign"])) {
|
||||
if (trim(strtolower(gpc("sign", "post"))) == "oui") {
|
||||
$hash = intval($hash);
|
||||
$bdd->reconnexion();
|
||||
$ratifier = $bdd->unique_query("SELECT id, fondateur, signatures FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
if (!empty($ratifier)) {
|
||||
$ratifier["signatures"] = explode(';', substr($ratifier["signatures"], 1), -1);
|
||||
unset($ratifier["signatures"][array_search($planete->id_user, $ratifier["signatures"])]);
|
||||
if (count($ratifier["signatures"]) == 0) {
|
||||
$ratifier["signatures"] = "";
|
||||
} else {
|
||||
$ratifier["signatures"] = ';'.implode(';', $ratifier["signatures"]).';';
|
||||
}
|
||||
$bdd->escape($ratifier["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$ratifier["signatures"]."' WHERE id = ".$ratifier["id"].";");
|
||||
}
|
||||
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE id = $hash;");
|
||||
if (!empty($alliance["signatures"]))
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
else
|
||||
$alliance["signatures"] = array();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE id = $hash;");
|
||||
if (!empty($alliance["signatures"])) {
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
} else {
|
||||
$alliance["signatures"] = array();
|
||||
}
|
||||
|
||||
$alliance["signatures"][] = $planete->id_user;
|
||||
$newnb = count($alliance["signatures"]);
|
||||
$alliance["signatures"] = ';'.implode(';', $alliance["signatures"]).';';
|
||||
$bdd->escape($alliance["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$alliance["signatures"]."' WHERE id = $hash;");
|
||||
if (debut_d_univers) //Si on est en début d'univers, on recherche une planète du joueur fondateur
|
||||
$planete_fondateur = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$alliance["fondateur"]." ORDER BY id ASC LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($newnb >= nb_signatures)
|
||||
{
|
||||
if (debut_d_univers && $newnb == nb_signatures && empty($planete_fondateur->vaisseaux[2]))
|
||||
{
|
||||
//On donne un vaisseau de colonisation au fondateur
|
||||
$planete_fondateur = new Planete($planete_fondateur["id"]);
|
||||
$planete_fondateur->vaisseaux[2]++;
|
||||
unset($planete_fondateur);
|
||||
$alliance["signatures"][] = $planete->id_user;
|
||||
$newnb = count($alliance["signatures"]);
|
||||
$alliance["signatures"] = ';'.implode(';', $alliance["signatures"]).';';
|
||||
$bdd->escape($alliance["signatures"]);
|
||||
$bdd->query("UPDATE $table_alliances_creation SET signatures = '".$alliance["signatures"]."' WHERE id = $hash;");
|
||||
if (debut_d_univers) { //Si on est en début d'univers, on recherche une planète du joueur fondateur
|
||||
$planete_fondateur = $bdd->unique_query("SELECT id FROM $table_planete WHERE id_user = ".$alliance["fondateur"]." ORDER BY id ASC LIMIT 1;");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
if ($newnb >= nb_signatures) {
|
||||
if (debut_d_univers && $newnb == nb_signatures && empty($planete_fondateur->vaisseaux[2])) {
|
||||
//On donne un vaisseau de colonisation au fondateur
|
||||
$planete_fondateur = new Planete($planete_fondateur["id"]);
|
||||
$planete_fondateur->vaisseaux[2]++;
|
||||
unset($planete_fondateur);
|
||||
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Pour vous féliciter, le conseil intergalactique a décidé de vous offrir un vaisseau de colonisation pour aller coloniser un astéroide afin d'implanter votre alliance.");
|
||||
}
|
||||
else
|
||||
//TODO refaire un message plus RP
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Envoyez-en un dès maintenant !");
|
||||
}
|
||||
else
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.");
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Pour vous féliciter, le conseil intergalactique a décidé de vous offrir un vaisseau de colonisation pour aller coloniser un astéroide afin d'implanter votre alliance.");
|
||||
} else {
|
||||
//TODO refaire un message plus RP
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.<br /><br />Vous avez suffisamment de signatures pour coloniser un astéroïde. Envoyez-en un dès maintenant !");
|
||||
}
|
||||
} else {
|
||||
send_mp($alliance["fondateur"], "Nouvelle signature pour votre alliance !", $planete->pseudo." vient de ratifier votre alliance, portant ainsi à ".$newnb." le nombre de signatures.");
|
||||
}
|
||||
|
||||
erreur("Votre signature a bien été prise en compte !", "green");
|
||||
}
|
||||
else
|
||||
redirection($VAR["menu"]["alliance"]);
|
||||
erreur("Votre signature a bien été prise en compte !", "green");
|
||||
} else {
|
||||
redirection($VAR["menu"]["alliance"]);
|
||||
}
|
||||
} else {
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($hash);
|
||||
$fonder = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." LIMIT 1;");
|
||||
if (!empty($fonder)) {
|
||||
$bdd->deconnexion();
|
||||
erreur("Vous ne pouvez pas ratifier d'alliance car vous en fonder actuellement une !", "red");
|
||||
}
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE lien = '$hash';");
|
||||
$ratifier = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($alliance) && sha1($alliance['tag'].'Hb$'.$alliance['nom_alliance'].'☺Ø'.$alliance['fondateur'].'‘«'.$planete->race) == $hash) {
|
||||
if (!empty($alliance["signatures"])) {
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
if (in_array($planete->id_user, $alliance["signatures"])) {
|
||||
erreur("Vous avez déjà ratifier cette alliance !");
|
||||
}
|
||||
$alliance["nbsignatures"] = count($alliance["signatures"]);
|
||||
} else {
|
||||
$alliance["nbsignatures"] = 0;
|
||||
}
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("ratifier", $ratifier);
|
||||
} elseif (!empty($alliance)) {
|
||||
erreur("Impossible de ratifier cette alliance.<br />Vous n'êtes peut-être pas de la même race que le fondateur.", 'red', $VAR["menu"]["alliance"], 4000);
|
||||
} else {
|
||||
erreur("Vous ne pouvez plus signer pour cette alliance !", 'red', $_SERVER["HTTP_REFERER"], 4000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($hash);
|
||||
$fonder = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user." LIMIT 1;");
|
||||
if (!empty($fonder))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Vous ne pouvez pas ratifier d'alliance car vous en fonder actuellement une !", "red");
|
||||
}
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE lien = '$hash';");
|
||||
$ratifier = $bdd->unique_query("SELECT * FROM $table_alliances_creation WHERE signatures LIKE '%;".$planete->id_user.";%' LIMIT 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($alliance) && sha1($alliance['tag'].'Hb$'.$alliance['nom_alliance'].'☺Ø'.$alliance['fondateur'].'‘«'.$planete->race) == $hash)
|
||||
{
|
||||
if (!empty($alliance["signatures"]))
|
||||
{
|
||||
$alliance["signatures"] = explode(';', substr($alliance["signatures"], 1), -1);
|
||||
if (in_array($planete->id_user, $alliance["signatures"]))
|
||||
erreur("Vous avez déjà ratifier cette alliance !");
|
||||
$alliance["nbsignatures"] = count($alliance["signatures"]);
|
||||
}
|
||||
else
|
||||
$alliance["nbsignatures"] = 0;
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("ratifier", $ratifier);
|
||||
}
|
||||
elseif (!empty($alliance))
|
||||
erreur("Impossible de ratifier cette alliance.<br />Vous n'êtes peut-être pas de la même race que le fondateur.", 'red', $VAR["menu"]["alliance"], 4000);
|
||||
else
|
||||
erreur("Vous ne pouvez plus signer pour cette alliance !", 'red', $_SERVER["HTTP_REFERER"], 4000);
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval(gpc('v'));
|
||||
$page = 'alliance/view';
|
||||
|
|
@ -7,19 +10,19 @@ $page = 'alliance/view';
|
|||
$bdd->reconnexion();
|
||||
$alliance = $bdd->unique_query("SELECT * FROM $table_alliances WHERE id = $id;");
|
||||
$nbmembres = $bdd->unique_query("SELECT COUNT(id) AS nbmembres FROM $table_user WHERE id_alliance = $id;");
|
||||
if ($planete->id_alliance == $id)
|
||||
if ($planete->id_alliance == $id) {
|
||||
$grade = $bdd->unique_query("SELECT nom FROM $table_alliances_grade WHERE id = ".$planete->id_grade_alliance.";");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($alliance))
|
||||
{
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("nbmembres", $nbmembres['nbmembres']);
|
||||
if (empty($grade))
|
||||
$template->assign("grade", "Invité");
|
||||
else
|
||||
$template->assign("grade", $grade["nom"]);
|
||||
if (!empty($alliance)) {
|
||||
$template->assign("alliance", $alliance);
|
||||
$template->assign("nbmembres", $nbmembres['nbmembres']);
|
||||
if (empty($grade)) {
|
||||
$template->assign("grade", "Invité");
|
||||
} else {
|
||||
$template->assign("grade", $grade["nom"]);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
redirection($VAR["menu"]["alliance"]);
|
||||
?>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,46 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ./'.$VAR['first_page']);
|
||||
exit;
|
||||
}
|
||||
$page = 'arbre';
|
||||
$titre = 'Arbre des technologies';
|
||||
|
||||
if (empty($_GET['q']))
|
||||
$_GET['q'] = '';
|
||||
if (empty($_GET['q'])) {
|
||||
$_GET['q'] = '';
|
||||
}
|
||||
$template->assign('defaut', gpc('q'));
|
||||
|
||||
//Récupération et vérification de la race voulue ou définition d'une race par défaut
|
||||
if (empty($_GET['r']) || (gpc('r') != 'humain' && gpc('r') != 'covenant'))
|
||||
$_GET['r'] = $planete->race;
|
||||
if (empty($_GET['r']) || (gpc('r') != 'humain' && gpc('r') != 'covenant')) {
|
||||
$_GET['r'] = $planete->race;
|
||||
}
|
||||
|
||||
$race = gpc('r');
|
||||
$template->assign('raceAff', $race);
|
||||
|
||||
if (SURFACE == "asteroide")
|
||||
{
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $id => $batiment)
|
||||
{
|
||||
if (!empty($LANG[$race]["alli_batiments"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => dAlliancesBatiments::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
}
|
||||
else
|
||||
{
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $id => $batiment)
|
||||
{
|
||||
if (!empty($LANG[$race]["batiments"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => dBatiments::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
if (SURFACE == "asteroide") {
|
||||
$TEMP_liste = array();
|
||||
foreach ($planete->batiments as $id => $batiment) {
|
||||
if (!empty($LANG[$race]["alli_batiments"]["noms_sing"][$id])) {
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => dAlliancesBatiments::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
} else {
|
||||
$TEMP_liste = array();
|
||||
foreach ($planete->batiments as $id => $batiment) {
|
||||
if (!empty($LANG[$race]["batiments"]["noms_sing"][$id])) {
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $batiment,
|
||||
'etat' => dBatiments::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -55,37 +57,36 @@ else
|
|||
$template->assign('technologies',$TEMP_technologies);
|
||||
*/
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->casernes as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["caserne"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dCaserne::needed($id, $planete, true)
|
||||
);
|
||||
foreach ($planete->casernes as $id => $unite) {
|
||||
if (!empty($LANG[$race]["caserne"]["noms_sing"][$id])) {
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dCaserne::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
$template->assign('caserne', $TEMP_liste);
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->terrestres as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["terrestre"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dTerrestre::needed($id, $planete, true)
|
||||
);
|
||||
foreach ($planete->terrestres as $id => $unite) {
|
||||
if (!empty($LANG[$race]["terrestre"]["noms_sing"][$id])) {
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dTerrestre::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->vaisseaux as $id => $unite)
|
||||
{
|
||||
if (!empty($LANG[$race]["vaisseaux"]["noms_sing"][$id]))
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dSpatial::needed($id, $planete, true)
|
||||
);
|
||||
foreach ($planete->vaisseaux as $id => $unite) {
|
||||
if (!empty($LANG[$race]["vaisseaux"]["noms_sing"][$id])) {
|
||||
$TEMP_liste[$id] = array(
|
||||
'niveau' => $unite,
|
||||
'etat' => dSpatial::needed($id, $planete, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
$template->assign('vaisseaux', $TEMP_liste);
|
||||
|
||||
unset($TEMP_liste, $id, $unite);
|
||||
?>
|
||||
|
|
@ -1,97 +1,92 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$titre = 'Bâtiments';
|
||||
|
||||
//Si l'on est sur un astéroide, on vérifie que le joueur ait les permissions nécessaire
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &1))
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des bâtiments de l'astéroide.");
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &1)) {
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des bâtiments de l'astéroide.");
|
||||
}
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['c']))
|
||||
{
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if(gpc('c') == 6 && $planete->file_tech->hasObject())
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
if (isset($_GET['c'])) {
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if (gpc('c') == 6 && $planete->file_tech->hasObject()) {
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
}
|
||||
|
||||
$planete->file_bat->addObjet(intval(gpc('c')), 1, $planete);
|
||||
$planete->file_bat->addObjet(intval(gpc('c')), 1, $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
//Lancement d'une déconstruction
|
||||
if (isset($_GET['d']))
|
||||
{
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if($_GET['d'] == 6 && $planete->file_tech->hasObject())
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
if (isset($_GET['d'])) {
|
||||
//On vérifie qu'il n'y ait pas de technologie en cours de recherche si l'on veut améliorer le centre de recherche
|
||||
if ($_GET['d'] == 6 && $planete->file_tech->hasObject()) {
|
||||
erreur('Une technologie est en cours de recherche dans votre laboratoire, vous ne pouvez pas faire de travaux !');
|
||||
}
|
||||
|
||||
$planete->file_bat->addDemolition(intval(gpc('d')), 1, $planete);
|
||||
$planete->file_bat->addDemolition(intval(gpc('d')), 1, $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$planete->file_bat->delObjet(intval(gpc('b')), 1, intval(gpc('a')), $planete);
|
||||
if (isset($_GET['a']) && isset($_GET['b'])) {
|
||||
$planete->file_bat->delObjet(intval(gpc('b')), 1, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['batiments']);
|
||||
redirection($VAR['menu']['batiments']);
|
||||
}
|
||||
|
||||
if (SURFACE == "planete")
|
||||
{
|
||||
$page = 'batiments';
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $i => $niveau)
|
||||
{
|
||||
//On vérifie le type par rapport à l'onglet
|
||||
if (isset($_GET["n"]) && !(intval($_GET["n"])& dBatiments::type($i)))
|
||||
continue;
|
||||
if (SURFACE == "planete") {
|
||||
$page = 'batiments';
|
||||
$TEMP_liste = array();
|
||||
foreach ($planete->batiments as $i => $niveau) {
|
||||
//On vérifie le type par rapport à l'onglet
|
||||
if (isset($_GET["n"]) && !(intval($_GET["n"])& dBatiments::type($i))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Si l'on est pas sur la planète mère, on désactive le laboratoire
|
||||
if ($i == 6 && $queryPlanetes[0]['id'] != $planete->id)
|
||||
continue;
|
||||
//Si l'on est pas sur la planète mère, on désactive le laboratoire
|
||||
if ($i == 6 && $queryPlanetes[0]['id'] != $planete->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($LANG[$planete->race]['batiments']['noms_sing'][$i]) && dBatiments::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dBatiments::image($i, $planete),
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => dBatiments::metal($i, $niveau+1, $planete),
|
||||
'nec_cristal' => dBatiments::cristal($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => dBatiments::hydrogene($i, $niveau+1, $planete),
|
||||
'temps' => sec(dBatiments::temps($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 'batiments_alli';
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->batiments as $i => $niveau)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['alli_batiments']['noms_sing'][$i]) && dAlliancesBatiments::needed($i, $planete) && $niveau < 6)
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dAlliancesBatiments::image($i, $planete),
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => dAlliancesBatiments::metal($i, $niveau+1, $planete),
|
||||
'nec_cristal' => dAlliancesBatiments::cristal($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => dAlliancesBatiments::hydrogene($i, $niveau+1, $planete),
|
||||
'nec_credits' => dAlliancesBatiments::credits($i, $niveau+1, $planete),
|
||||
'temps' => sec(dAlliancesBatiments::temps($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!empty($LANG[$planete->race]['batiments']['noms_sing'][$i]) && dBatiments::needed($i, $planete)) {
|
||||
$TEMP_liste[] = array(
|
||||
'id' => $i,
|
||||
'image' => dBatiments::image($i, $planete),
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => dBatiments::metal($i, $niveau+1, $planete),
|
||||
'nec_cristal' => dBatiments::cristal($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => dBatiments::hydrogene($i, $niveau+1, $planete),
|
||||
'temps' => sec(dBatiments::temps($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$page = 'batiments_alli';
|
||||
$TEMP_liste = array();
|
||||
foreach ($planete->batiments as $i => $niveau) {
|
||||
if (!empty($LANG[$planete->race]['alli_batiments']['noms_sing'][$i]) && dAlliancesBatiments::needed($i, $planete) && $niveau < 6) {
|
||||
$TEMP_liste[] = array(
|
||||
'id' => $i,
|
||||
'image' => dAlliancesBatiments::image($i, $planete),
|
||||
'niveau' => $niveau,
|
||||
'nec_metal' => dAlliancesBatiments::metal($i, $niveau+1, $planete),
|
||||
'nec_cristal' => dAlliancesBatiments::cristal($i, $niveau+1, $planete),
|
||||
'nec_hydrogene' => dAlliancesBatiments::hydrogene($i, $niveau+1, $planete),
|
||||
'nec_credits' => dAlliancesBatiments::credits($i, $niveau+1, $planete),
|
||||
'temps' => sec(dAlliancesBatiments::temps($i, $niveau+1, $planete)),
|
||||
'enfile' => $planete->file_bat->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$template->assign('batiments', $TEMP_liste);
|
||||
$template->assign('onglet', gpc("n"));
|
||||
$template->assign('files', $planete->file_bat->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $niveau, $i);
|
||||
?>
|
||||
|
|
@ -1,63 +1,64 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$page = 'carte';
|
||||
$titre = 'Carte spatiale';
|
||||
|
||||
//Récupération d'un numéro d'amas à regarder
|
||||
if (isset($_GET['amas']))
|
||||
$g = intval(gpc('amas'));
|
||||
elseif (isset($_GET['galaxie']))
|
||||
$g = intval(gpc('galaxie'));
|
||||
else
|
||||
$g = $planete->galaxie;
|
||||
if (isset($_GET['amas'])) {
|
||||
$g = intval(gpc('amas'));
|
||||
} elseif (isset($_GET['galaxie'])) {
|
||||
$g = intval(gpc('galaxie'));
|
||||
} else {
|
||||
$g = $planete->galaxie;
|
||||
}
|
||||
|
||||
//Validation du numéro de l'amas
|
||||
if ($planete->auth_level >= 5 && $g <= 0)
|
||||
$g = 0;
|
||||
elseif ($g < 1)
|
||||
$g = 1;
|
||||
if ($g > $VAR['nb_amas'])
|
||||
$g = 1;
|
||||
if ($planete->auth_level >= 5 && $g <= 0) {
|
||||
$g = 0;
|
||||
} elseif ($g < 1) {
|
||||
$g = 1;
|
||||
}
|
||||
if ($g > $VAR['nb_amas']) {
|
||||
$g = 1;
|
||||
}
|
||||
|
||||
//Récupération d'un numéro de système à regarder
|
||||
if (isset($_GET['systeme']))
|
||||
$s = intval(gpc('systeme'));
|
||||
elseif (isset($_GET['ss']))
|
||||
$s = intval(gpc('ss'));
|
||||
else
|
||||
$s = $planete->ss;
|
||||
if (isset($_GET['systeme'])) {
|
||||
$s = intval(gpc('systeme'));
|
||||
} elseif (isset($_GET['ss'])) {
|
||||
$s = intval(gpc('ss'));
|
||||
} else {
|
||||
$s = $planete->ss;
|
||||
}
|
||||
|
||||
//Validation du numéro de système
|
||||
if ($s < 1)
|
||||
$s = 1;
|
||||
if ($s > $VAR['nb_systeme'])
|
||||
$s = $VAR['nb_systeme'];
|
||||
if ($s < 1) {
|
||||
$s = 1;
|
||||
}
|
||||
if ($s > $VAR['nb_systeme']) {
|
||||
$s = $VAR['nb_systeme'];
|
||||
}
|
||||
|
||||
//Calcul des prochains amas et systèmes
|
||||
if ($s == 1 && $g > 1)
|
||||
{
|
||||
$Gmu = $g - 1;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
if ($s == 1 && $g > 1) {
|
||||
$Gmu = $g - 1;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
} elseif ($s == 1) {
|
||||
$Gmu = 15;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
} else {
|
||||
$Gmu = $g;
|
||||
$Smu = $s - 1;
|
||||
}
|
||||
elseif ($s == 1)
|
||||
{
|
||||
$Gmu = 15;
|
||||
$Smu = $VAR['nb_systeme'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$Gmu = $g;
|
||||
$Smu = $s - 1;
|
||||
}
|
||||
if ($s == $VAR['nb_systeme'])
|
||||
{
|
||||
$Gpu = $g + 1;
|
||||
$Spu = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$Gpu = $g;
|
||||
$Spu = $s + 1;
|
||||
if ($s == $VAR['nb_systeme']) {
|
||||
$Gpu = $g + 1;
|
||||
$Spu = 1;
|
||||
} else {
|
||||
$Gpu = $g;
|
||||
$Spu = $s + 1;
|
||||
}
|
||||
|
||||
//Erreur au cas où la zone soit trop lointaine par rapport au niveau de la technologie
|
||||
|
|
@ -66,37 +67,32 @@ else
|
|||
|
||||
//Génération de la carte à afficher
|
||||
$TEMP_carte = array();
|
||||
for ($i = 1; $i <= $VAR['nb_planete']; $i++)
|
||||
{
|
||||
//Cas d'un système à astéroïde
|
||||
if ($s%5 == 2 && $i == ceil($VAR['nb_planete']/2))
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$d = $bdd->unique_query("SELECT race, nom_asteroide, debris_met, debris_cri, nom_alliance, image, tag, fondateur FROM $table_alliances WHERE galaxie = $g AND ss = $s;");
|
||||
$bdd->deconnexion();
|
||||
if($d)
|
||||
$TEMP_carte[] = array('A', $d['nom_asteroide'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['nom_alliance'], $d['tag'], $d['image'], 0);
|
||||
else
|
||||
$TEMP_carte[] = array('A');
|
||||
}
|
||||
for ($i = 1; $i <= $VAR['nb_planete']; $i++) {
|
||||
//Cas d'un système à astéroïde
|
||||
if ($s%5 == 2 && $i == ceil($VAR['nb_planete']/2)) {
|
||||
$bdd->reconnexion();
|
||||
$d = $bdd->unique_query("SELECT race, nom_asteroide, debris_met, debris_cri, nom_alliance, image, tag, fondateur FROM $table_alliances WHERE galaxie = $g AND ss = $s;");
|
||||
$bdd->deconnexion();
|
||||
if ($d) {
|
||||
$TEMP_carte[] = array('A', $d['nom_asteroide'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['nom_alliance'], $d['tag'], $d['image'], 0);
|
||||
} else {
|
||||
$TEMP_carte[] = array('A');
|
||||
}
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->query("SELECT id FROM $table_planete WHERE galaxie = $g AND ss = $s AND position = $i;");
|
||||
if($resultat)
|
||||
{
|
||||
$d = $bdd->unique_query("SELECT P.nom_planete, P.image, P.debris_met, P.debris_cri, U.pseudo, U.race, U.politique, U.id_alliance, A.tag FROM $table_planete P INNER JOIN $table_user U ON U.id = P.id_user LEFT OUTER JOIN $table_alliances A ON A.id = U.id_alliance WHERE P.galaxie = $g AND P.ss = $s AND P.position = $i;");
|
||||
$bdd->deconnexion();
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->query("SELECT id FROM $table_planete WHERE galaxie = $g AND ss = $s AND position = $i;");
|
||||
if ($resultat) {
|
||||
$d = $bdd->unique_query("SELECT P.nom_planete, P.image, P.debris_met, P.debris_cri, U.pseudo, U.race, U.politique, U.id_alliance, A.tag FROM $table_planete P INNER JOIN $table_user U ON U.id = P.id_user LEFT OUTER JOIN $table_alliances A ON A.id = U.id_alliance WHERE P.galaxie = $g AND P.ss = $s AND P.position = $i;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$TEMP_carte[] = array($i, $d['nom_planete'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['pseudo'], $d['tag'], $d['image'], $d['politique']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
$TEMP_carte[] = array($i);
|
||||
}
|
||||
$TEMP_carte[] = array($i, $d['nom_planete'], $d['debris_met'], $d['debris_cri'], $d['race'], $d['pseudo'], $d['tag'], $d['image'], $d['politique']);
|
||||
} else {
|
||||
$bdd->deconnexion();
|
||||
$TEMP_carte[] = array($i);
|
||||
}
|
||||
}
|
||||
$template->assign('carte', $TEMP_carte);
|
||||
$template->assign('position', array($g, $s, $Gpu, $Spu, $Gmu, $Smu));
|
||||
|
||||
unset($TEMP_carte, $g, $s, $Gpu, $Spu, $Gmu, $Smu, $resultat, $d, $i);
|
||||
?>
|
||||
|
|
@ -1,51 +1,52 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$page = 'caserne';
|
||||
$titre = $LANG[$planete->race]['batiments']['noms_sing'][9];
|
||||
|
||||
//Vérification que le joueur ait bien une caserne avant d'afficher la page
|
||||
if ($planete->batiments[9] <= 0)
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['batiments']['noms_sing'][9], "red", '?p=batiments', 3500);
|
||||
if ($planete->batiments[9] <= 0) {
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['batiments']['noms_sing'][9], "red", '?p=batiments', 3500);
|
||||
}
|
||||
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[9] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
if ($lieu >= $planete->batiments[9] || $lieu < 0) {
|
||||
$lieu = 0;
|
||||
}
|
||||
|
||||
//Lancement d'un nouvel entrainement
|
||||
if (isset($_GET['c']) && ($id = intval(gpc('c'))) >= 0 && $nbc = floor(gpc('cas'.$id, 'post')))
|
||||
{
|
||||
$planete->file_cas->addObjet($id, $nbc, $planete, $lieu);
|
||||
if (isset($_GET['c']) && ($id = intval(gpc('c'))) >= 0 && $nbc = floor(gpc('cas'.$id, 'post'))) {
|
||||
$planete->file_cas->addObjet($id, $nbc, $planete, $lieu);
|
||||
|
||||
redirection($VAR['menu']['caserne']."&k=".$lieu);
|
||||
redirection($VAR['menu']['caserne']."&k=".$lieu);
|
||||
}
|
||||
//Annulation d'un entrainement
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_cas->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
if (isset($_GET['a']) && isset($_GET['b'])) {
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) {
|
||||
$n = 1;
|
||||
}
|
||||
$planete->file_cas->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['caserne']."&k=".$lieu);
|
||||
redirection($VAR['menu']['caserne']."&k=".$lieu);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->casernes as $i => $nombre)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['caserne']['noms_sing'][$i]) && dCaserne::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dCaserne::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dCaserne::metal($i, 1, $planete),
|
||||
'nec_cristal' => dCaserne::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dCaserne::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dCaserne::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_cas->objectInFile($i)
|
||||
);
|
||||
}
|
||||
foreach ($planete->casernes as $i => $nombre) {
|
||||
if (!empty($LANG[$planete->race]['caserne']['noms_sing'][$i]) && dCaserne::needed($i, $planete)) {
|
||||
$TEMP_liste[] = array(
|
||||
'id' => $i,
|
||||
'image' => dCaserne::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dCaserne::metal($i, 1, $planete),
|
||||
'nec_cristal' => dCaserne::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dCaserne::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dCaserne::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_cas->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
|
|
@ -53,4 +54,3 @@ $template->assign('lieu', $lieu);
|
|||
$template->assign('files', $planete->file_cas->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau);
|
||||
?>
|
||||
|
|
@ -1,69 +1,70 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$page = 'chantierspatial';
|
||||
if (SURFACE == "planete")
|
||||
$titre = ucfirst($LANG[$planete->race]['batiments']['noms_sing'][8]);
|
||||
else
|
||||
$titre = ucfirst($LANG[$planete->race]['alli_batiments']['noms_sing'][3]);
|
||||
if (SURFACE == "planete") {
|
||||
$titre = ucfirst($LANG[$planete->race]['batiments']['noms_sing'][8]);
|
||||
} else {
|
||||
$titre = ucfirst($LANG[$planete->race]['alli_batiments']['noms_sing'][3]);
|
||||
}
|
||||
|
||||
//Si l'on est sur un astéroide, on vérifie que le joueur ait les permissions nécessaire
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &2))
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des vaisseaux de l'astéroide.");
|
||||
if (SURFACE == "asteroide" && !($planete->permissions_alliance &2)) {
|
||||
erreur("Vous n'avez pas le grade requis pour vous occuper des vaisseaux de l'astéroide.");
|
||||
}
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if (SURFACE == "planete" && $planete->batiments[8] <= 0)
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][8], "red", '?p=batiments', 3500);
|
||||
elseif(SURFACE == "asteroide" && $planete->batiments[3] <= 0)
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['alli_batiments']['noms_sing'][3], "red", '?p=batiments', 3500);
|
||||
|
||||
if (SURFACE == "planete")
|
||||
{
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[8] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
if (SURFACE == "planete" && $planete->batiments[8] <= 0) {
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][8], "red", '?p=batiments', 3500);
|
||||
} elseif (SURFACE == "asteroide" && $planete->batiments[3] <= 0) {
|
||||
erreur('Vous devez d\'abord construire une '.$LANG[$planete->race]['alli_batiments']['noms_sing'][3], "red", '?p=batiments', 3500);
|
||||
}
|
||||
elseif (SURFACE == "asteroide")
|
||||
{
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[3] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
|
||||
if (SURFACE == "planete") {
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[8] || $lieu < 0) {
|
||||
$lieu = 0;
|
||||
}
|
||||
} elseif (SURFACE == "asteroide") {
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[3] || $lieu < 0) {
|
||||
$lieu = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('vais'.$id, 'post')))
|
||||
{
|
||||
$planete->file_vais->addObjet($id, $nbv, $planete, $lieu);
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('vais'.$id, 'post'))) {
|
||||
$planete->file_vais->addObjet($id, $nbv, $planete, $lieu);
|
||||
|
||||
redirection($VAR['menu']['chantierspatial']."&k=".$lieu);
|
||||
redirection($VAR['menu']['chantierspatial']."&k=".$lieu);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_vais->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
if (isset($_GET['a']) && isset($_GET['b'])) {
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) {
|
||||
$n = 1;
|
||||
}
|
||||
$planete->file_vais->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu']['chantierspatial']."&k=".$lieu);
|
||||
redirection($VAR['menu']['chantierspatial']."&k=".$lieu);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->vaisseaux as $i => $nombre)
|
||||
{
|
||||
if (!empty($LANG[$planete->race]['vaisseaux']['noms_sing'][$i]) && dSpatial::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dSpatial::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dSpatial::metal($i, 1, $planete),
|
||||
'nec_cristal' => dSpatial::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dSpatial::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dSpatial::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_vais->objectInFile($i)
|
||||
);
|
||||
}
|
||||
foreach ($planete->vaisseaux as $i => $nombre) {
|
||||
if (!empty($LANG[$planete->race]['vaisseaux']['noms_sing'][$i]) && dSpatial::needed($i, $planete)) {
|
||||
$TEMP_liste[] = array(
|
||||
'id' => $i,
|
||||
'image' => dSpatial::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dSpatial::metal($i, 1, $planete),
|
||||
'nec_cristal' => dSpatial::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dSpatial::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dSpatial::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_vais->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('vaisseaux', $TEMP_liste);
|
||||
|
|
@ -71,4 +72,3 @@ $template->assign('lieu', $lieu);
|
|||
$template->assign('files', $planete->file_vais->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau);
|
||||
?>
|
||||
|
|
@ -1,58 +1,60 @@
|
|||
<?php
|
||||
if(!defined('ONYX'))
|
||||
exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$page = $p;
|
||||
$onglet = gpc('n');
|
||||
if (!empty($onglet))
|
||||
$template->assign('onglet', $onglet);
|
||||
else
|
||||
$template->assign('onglet', "unites");
|
||||
if (!empty($onglet)) {
|
||||
$template->assign('onglet', $onglet);
|
||||
} else {
|
||||
$template->assign('onglet', "unites");
|
||||
}
|
||||
$titre = ucfirst($LANG[$planete->race]['batiments']['noms_sing'][7]);
|
||||
|
||||
//Vérification que le joueur ait bien un labo avant d'afficher la page
|
||||
if ($planete->batiments[7] <= 0)
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][7], "red", '?p=batiments', 3500);
|
||||
if ($planete->batiments[7] <= 0) {
|
||||
erreur('Vous devez d\'abord construire un '.$LANG[$planete->race]['batiments']['noms_sing'][7], "red", '?p=batiments', 3500);
|
||||
}
|
||||
|
||||
$lieu = intval(gpc("k"));
|
||||
if ($lieu >= $planete->batiments[7] || $lieu < 0)
|
||||
$lieu = 0;
|
||||
if ($lieu >= $planete->batiments[7] || $lieu < 0) {
|
||||
$lieu = 0;
|
||||
}
|
||||
|
||||
//Lancement d'une nouvelle construction
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('terr'.$id, 'post')))
|
||||
{
|
||||
$planete->file_ter->addObjet($id, $nbv, $planete, $lieu);
|
||||
if (isset($_GET['v']) && ($id = intval(gpc('v'))) >= 0 && $nbv = floor(gpc('terr'.$id, 'post'))) {
|
||||
$planete->file_ter->addObjet($id, $nbv, $planete, $lieu);
|
||||
|
||||
redirection($VAR['menu'][$p].'&k='.$lieu.'&n='.$onglet);
|
||||
redirection($VAR['menu'][$p].'&k='.$lieu.'&n='.$onglet);
|
||||
}
|
||||
//Annulation d'une nouvelle construction
|
||||
if (isset($_GET['a']) && isset($_GET['b']))
|
||||
{
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) $n = 1;
|
||||
$planete->file_ter->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
if (isset($_GET['a']) && isset($_GET['b'])) {
|
||||
$n = intval(gpc('s'));
|
||||
if (empty($n)) {
|
||||
$n = 1;
|
||||
}
|
||||
$planete->file_ter->delObjet(intval(gpc('b')), $n, intval(gpc('a')), $planete);
|
||||
|
||||
redirection($VAR['menu'][$p].'&k='.$lieu.'&n='.$onglet);
|
||||
redirection($VAR['menu'][$p].'&k='.$lieu.'&n='.$onglet);
|
||||
}
|
||||
|
||||
$TEMP_liste = array();
|
||||
foreach($planete->terrestres as $i => $nombre)
|
||||
{
|
||||
$type = dTerrestre::type($i);
|
||||
foreach ($planete->terrestres as $i => $nombre) {
|
||||
$type = dTerrestre::type($i);
|
||||
|
||||
if (!empty($LANG[$planete->race]['terrestre']['noms_sing'][$i]) && (($onglet == "defenses" && !$type) || ($onglet != "defenses" && $type)) && dTerrestre::needed($i, $planete))
|
||||
{
|
||||
$TEMP_liste[] = array (
|
||||
'id' => $i,
|
||||
'image' => dTerrestre::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dTerrestre::metal($i, 1, $planete),
|
||||
'nec_cristal' => dTerrestre::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dTerrestre::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dTerrestre::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_ter->objectInFile($i)
|
||||
);
|
||||
}
|
||||
if (!empty($LANG[$planete->race]['terrestre']['noms_sing'][$i]) && (($onglet == "defenses" && !$type) || ($onglet != "defenses" && $type)) && dTerrestre::needed($i, $planete)) {
|
||||
$TEMP_liste[] = array(
|
||||
'id' => $i,
|
||||
'image' => dTerrestre::image($i, $planete),
|
||||
'nombre' => $nombre,
|
||||
'nec_metal' => dTerrestre::metal($i, 1, $planete),
|
||||
'nec_cristal' => dTerrestre::cristal($i, 1, $planete),
|
||||
'nec_hydrogene' => dTerrestre::hydrogene($i, 1, $planete),
|
||||
'temps' => sec(dTerrestre::temps($i, 1, $planete)),
|
||||
'enfile' => $planete->file_ter->objectInFile($i)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('unites', $TEMP_liste);
|
||||
|
|
@ -60,4 +62,3 @@ $template->assign('lieu', $lieu);
|
|||
$template->assign('files', $planete->file_ter->printFile($planete));
|
||||
|
||||
unset($TEMP_liste, $i, $n, $niveau, $onglet, $type);
|
||||
?>
|
||||
|
|
@ -1,153 +1,133 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "planete") { header('Location: ./'.$VAR['first_page']); exit; }
|
||||
if (!defined('INDEX') || SURFACE != "planete") {
|
||||
header('Location: ./'.$VAR['first_page']);
|
||||
exit;
|
||||
}
|
||||
$page = 'description';
|
||||
$titre = 'Détails';
|
||||
|
||||
function tableauProd($ibat,$nivo)
|
||||
function tableauProd($ibat, $nivo)
|
||||
{
|
||||
$return = array();
|
||||
$c = $nivo-2 < 1 ? 1 : $nivo-2;
|
||||
$a = $c + 6;
|
||||
$return = array();
|
||||
$c = $nivo-2 < 1 ? 1 : $nivo-2;
|
||||
$a = $c + 6;
|
||||
|
||||
if ($ibat == 0)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 52 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 52 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
if ($ibat == 0) {
|
||||
for ($c; $c < $a; $c++) {
|
||||
$production = ceil(pow(1.1, $c) * 52 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 52 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 1)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 34 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 34 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
} elseif ($ibat == 1) {
|
||||
for ($c; $c < $a; $c++) {
|
||||
$production = ceil(pow(1.1, $c) * 34 * $c);
|
||||
$production_diff = ceil(pow(1.1, $c) * 34 * $c) - ceil(pow(1.1, $nivo) * 52 * $nivo);
|
||||
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
$energie = ceil(exp(0.28*$c)*10);
|
||||
$energie_diff = ceil(exp(0.28*$c)*10) - ceil(exp(0.28*$nivo)*10);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 2)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(pow(1.1, $c) * 21 * ($c + 0.7));
|
||||
$production_diff = ceil(pow(1.1, $c) * 21 * ($c + 0.7)) - ceil(pow(1.1, $nivo) * 21 * ($nivo + 0.7));
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
} elseif ($ibat == 2) {
|
||||
for ($c; $c < $a; $c++) {
|
||||
$production = ceil(pow(1.1, $c) * 21 * ($c + 0.7));
|
||||
$production_diff = ceil(pow(1.1, $c) * 21 * ($c + 0.7)) - ceil(pow(1.1, $nivo) * 21 * ($nivo + 0.7));
|
||||
|
||||
$energie = ceil(exp(0.2849*$c)*13);
|
||||
$energie_diff = ceil(exp(0.2849*$c)*13) - ceil(exp(0.2849*$nivo)*13);
|
||||
$energie = ceil(exp(0.2849*$c)*13);
|
||||
$energie_diff = ceil(exp(0.2849*$c)*13) - ceil(exp(0.2849*$nivo)*13);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 3)
|
||||
{
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(exp(0.28*$c)*22);
|
||||
$production_diff = ceil(exp(0.28*$c)*22) - ceil(exp(0.28*$nivo)*22);
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
} elseif ($ibat == 3) {
|
||||
for ($c; $c < $a; $c++) {
|
||||
$production = ceil(exp(0.28*$c)*22);
|
||||
$production_diff = ceil(exp(0.28*$c)*22) - ceil(exp(0.28*$nivo)*22);
|
||||
|
||||
$return[] = array($c, $production, 0, $production_diff, 0);
|
||||
}
|
||||
}
|
||||
elseif ($ibat == 4) {
|
||||
for ($c; $c < $a; $c++)
|
||||
{
|
||||
$production = ceil(exp(0.297*$c)*25);
|
||||
$production_diff = ceil(exp(0.297*$c)*25) - ceil(exp(0.297*$nivo)*25);
|
||||
$return[] = array($c, $production, 0, $production_diff, 0);
|
||||
}
|
||||
} elseif ($ibat == 4) {
|
||||
for ($c; $c < $a; $c++) {
|
||||
$production = ceil(exp(0.297*$c)*25);
|
||||
$production_diff = ceil(exp(0.297*$c)*25) - ceil(exp(0.297*$nivo)*25);
|
||||
|
||||
$energie = ceil(pow(1.34,($c-1)) * 9);
|
||||
$energie_diff = ceil(pow(1.34,($c-1)) * 9) - ceil(pow(1.34,($nivo-1)) * 9);
|
||||
$energie = ceil(pow(1.34, ($c-1)) * 9);
|
||||
$energie_diff = ceil(pow(1.34, ($c-1)) * 9) - ceil(pow(1.34, ($nivo-1)) * 9);
|
||||
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
$return[] = array($c, $production, $energie, $production_diff, $energie_diff);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
if (empty($_GET['r']) || ($_GET['r'] != 'humain' && $_GET['r'] != 'covenant'))
|
||||
$_GET['r'] = $planete->race;
|
||||
if (empty($_GET['r']) || ($_GET['r'] != 'humain' && $_GET['r'] != 'covenant')) {
|
||||
$_GET['r'] = $planete->race;
|
||||
}
|
||||
$race = gpc('r');
|
||||
$template->assign('raceAff', $race);
|
||||
|
||||
if (isset($_GET['t']) && is_numeric($_GET['t']) && !empty($LANG[$race]["technologies"]["noms_sing"][$_GET['b']][$_GET['t']]))
|
||||
{
|
||||
$template->assign('type', 'technologies');
|
||||
$b = intval(gpc('b'));
|
||||
$t = intval(gpc('t'));
|
||||
$template->assign('branche', $b);
|
||||
$template->assign('id', $t);
|
||||
if (isset($_GET['t']) && is_numeric($_GET['t']) && !empty($LANG[$race]["technologies"]["noms_sing"][$_GET['b']][$_GET['t']])) {
|
||||
$template->assign('type', 'technologies');
|
||||
$b = intval(gpc('b'));
|
||||
$t = intval(gpc('t'));
|
||||
$template->assign('branche', $b);
|
||||
$template->assign('id', $t);
|
||||
|
||||
$template->assign('ressourcesNext', array(Donnee::creditsTechnologie($b, $t, $planete), Donnee::tempsTechnologie($b, $t, $planete)));
|
||||
$template->assign('ressourcesNext', array(Donnee::creditsTechnologie($b, $t, $planete), Donnee::tempsTechnologie($b, $t, $planete)));
|
||||
|
||||
$template->assign('etat', Donnee::print_neededTechnologie($b, $t, $planete, $race));
|
||||
$template->assign('etat', Donnee::print_neededTechnologie($b, $t, $planete, $race));
|
||||
} elseif (isset($_GET['b']) && is_numeric($_GET['b']) && !empty($LANG[$race]["batiments"]["noms_sing"][$_GET['b']])) {
|
||||
$template->assign('type', 'batiments');
|
||||
$t = intval(gpc('b'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dBatiments::image($t, $planete));
|
||||
$template->assign('tableau_prod', tableauProd($t, $planete->batiments[$t]));
|
||||
|
||||
$n = $planete->batiments[$t] + 1;
|
||||
$template->assign('ressourcesNext', array(dBatiments::metal($t, $n, $planete), dBatiments::cristal($t, $n, $planete), dBatiments::hydrogene($t, $n, $planete), dBatiments::temps($t, $n, $planete)));
|
||||
|
||||
$template->assign('etat', dBatiments::needed($t, $planete, true));
|
||||
} elseif (isset($_GET['v']) && is_numeric($_GET['v']) && !empty($LANG[$race]["vaisseaux"]["noms_sing"][$_GET['v']])) {
|
||||
$template->assign('type', 'vaisseaux');
|
||||
$t = intval(gpc('v'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dSpatial::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dSpatial::metal($t, 1, $planete), dSpatial::cristal($t, 1, $planete), dSpatial::hydrogene($t, 1, $planete), dSpatial::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dSpatial::needed($t, $planete, $race));
|
||||
$template->assign('caract', array($nomvais_at[$t], $nomvais_bc[$t], $nomvais_pv[$t], $nomvais_rs[$t]));
|
||||
} elseif (isset($_GET['d']) && is_numeric($_GET['d']) && !empty($LANG[$race]["terrestre"]["noms_sing"][$_GET['d']])) {
|
||||
$template->assign('type', 'terrestre');
|
||||
$t = gpc('d');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dTerrestre::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dTerrestre::metal($t, 1, $planete), dTerrestre::cristal($t, 1, $planete), dTerrestre::hydrogene($t, 1, $planete), dTerrestre::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dTerrestre::needed($t, $planete, true));
|
||||
if ($t-8 >= 0) {
|
||||
$t -= 8;
|
||||
$template->assign('caract', array($defense_at[$t], $defense_bc[$t], $defense_pv[$t]));
|
||||
}
|
||||
} elseif (isset($_GET['c']) && is_numeric($_GET['c']) && !empty($LANG[$race]["caserne"]["noms_sing"][$_GET['c']])) {
|
||||
$template->assign('type', 'caserne');
|
||||
$t = gpc('c');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dCaserne::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dCaserne::metal($t, 1, $planete), dCaserne::cristal($t, 1, $planete), dCaserne::hydrogene($t, 1, $planete), dCaserne::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dCaserne::needed($t, $planete, true));
|
||||
$template->assign('caract', array('!!', '!!', '!!'));
|
||||
} else {
|
||||
redirection('?p=accueil');
|
||||
}
|
||||
elseif (isset($_GET['b']) && is_numeric($_GET['b']) && !empty($LANG[$race]["batiments"]["noms_sing"][$_GET['b']]))
|
||||
{
|
||||
$template->assign('type', 'batiments');
|
||||
$t = intval(gpc('b'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dBatiments::image($t, $planete));
|
||||
$template->assign('tableau_prod', tableauProd($t, $planete->batiments[$t]));
|
||||
|
||||
$n = $planete->batiments[$t] + 1;
|
||||
$template->assign('ressourcesNext', array(dBatiments::metal($t, $n, $planete), dBatiments::cristal($t, $n, $planete), dBatiments::hydrogene($t, $n, $planete), dBatiments::temps($t, $n, $planete)));
|
||||
|
||||
$template->assign('etat', dBatiments::needed($t, $planete, true));
|
||||
}
|
||||
elseif (isset($_GET['v']) && is_numeric($_GET['v']) && !empty($LANG[$race]["vaisseaux"]["noms_sing"][$_GET['v']]))
|
||||
{
|
||||
$template->assign('type', 'vaisseaux');
|
||||
$t = intval(gpc('v'));
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dSpatial::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dSpatial::metal($t, 1, $planete), dSpatial::cristal($t, 1, $planete), dSpatial::hydrogene($t, 1, $planete), dSpatial::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dSpatial::needed($t, $planete, $race));
|
||||
$template->assign('caract', array($nomvais_at[$t], $nomvais_bc[$t], $nomvais_pv[$t], $nomvais_rs[$t]));
|
||||
}
|
||||
elseif (isset($_GET['d']) && is_numeric($_GET['d']) && !empty($LANG[$race]["terrestre"]["noms_sing"][$_GET['d']]))
|
||||
{
|
||||
$template->assign('type', 'terrestre');
|
||||
$t = gpc('d');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dTerrestre::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dTerrestre::metal($t, 1, $planete), dTerrestre::cristal($t, 1, $planete), dTerrestre::hydrogene($t, 1, $planete), dTerrestre::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dTerrestre::needed($t, $planete, true));
|
||||
if ($t-8 >= 0)
|
||||
{
|
||||
$t -= 8;
|
||||
$template->assign('caract', array($defense_at[$t], $defense_bc[$t], $defense_pv[$t]));
|
||||
}
|
||||
}
|
||||
elseif (isset($_GET['c']) && is_numeric($_GET['c']) && !empty($LANG[$race]["caserne"]["noms_sing"][$_GET['c']]))
|
||||
{
|
||||
$template->assign('type', 'caserne');
|
||||
$t = gpc('c');
|
||||
$template->assign('id', $t);
|
||||
$template->assign('image', dCaserne::image($t, $planete));
|
||||
|
||||
$template->assign('ressourcesNext', array(dCaserne::metal($t, 1, $planete), dCaserne::cristal($t, 1, $planete), dCaserne::hydrogene($t, 1, $planete), dCaserne::temps($t, 1, $planete)));
|
||||
|
||||
$template->assign('etat', dCaserne::needed($t, $planete, true));
|
||||
$template->assign('caract', array('!!', '!!', '!!'));
|
||||
}
|
||||
else
|
||||
redirection('?p=accueil');
|
||||
|
||||
unset($t, $race);
|
||||
?>
|
||||
|
|
@ -1,199 +1,174 @@
|
|||
<?php
|
||||
if(!defined('INDEX') || SURFACE != "asteroide") { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX') || SURFACE != "asteroide") {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$onglet = strtolower(gpc('o'));
|
||||
if ($onglet == "new")
|
||||
{
|
||||
$page = "diplomatie/nouveau";
|
||||
if ($onglet == "new") {
|
||||
$page = "diplomatie/nouveau";
|
||||
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &8))
|
||||
erreur("Vous n'avez pas le grade nécessaire pour créer des pactes !");
|
||||
//On vérifie que le joueur ait les permissions pour modifier les grades
|
||||
if (!($planete->permissions_alliance &8)) {
|
||||
erreur("Vous n'avez pas le grade nécessaire pour créer des pactes !");
|
||||
}
|
||||
|
||||
$type = intval(gpc("type", 'post'));
|
||||
$nom_alli = gpc("nom_alli", 'post');
|
||||
if (isset($_POST["type"]) && !empty($nom_alli) && $type >= 0 && $type < 5)
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom_alli);
|
||||
$alli = $bdd->unique_query("SELECT id FROM $table_alliances WHERE nom_alliance LIKE '$nom_alli';");
|
||||
if (empty($alli))
|
||||
erreur("Impossible de trouver cette alliance. Vérifiez le nom !");
|
||||
//On détecte tous les types de pactes en cas de guerre (pour éviter d'attaquer avec un pacte de non agression !
|
||||
if ($type)
|
||||
$pacte = $bdd->query("SELECT id FROM $table_alliances_pactes WHERE type = $type AND time_fin = 0 AND (accepte = 0 OR accepte = 1) AND ((id_alliance1 = ".$planete->id." AND id_alliance2 = ".$alli['id'].") OR (id_alliance2 = ".$planete->id." AND id_alliance1 = ".$alli['id']."));");
|
||||
else
|
||||
$pacte = $bdd->query("SELECT id FROM $table_alliances_pactes WHERE time_fin = 0 AND (accepte = 0 OR accepte = 1) AND ((id_alliance1 = ".$planete->id." AND id_alliance2 = ".$alli['id'].") OR (id_alliance2 = ".$planete->id." AND id_alliance1 = ".$alli['id']."));");
|
||||
$type = intval(gpc("type", 'post'));
|
||||
$nom_alli = gpc("nom_alli", 'post');
|
||||
if (isset($_POST["type"]) && !empty($nom_alli) && $type >= 0 && $type < 5) {
|
||||
$bdd->reconnexion();
|
||||
$bdd->escape($nom_alli);
|
||||
$alli = $bdd->unique_query("SELECT id FROM $table_alliances WHERE nom_alliance LIKE '$nom_alli';");
|
||||
if (empty($alli)) {
|
||||
erreur("Impossible de trouver cette alliance. Vérifiez le nom !");
|
||||
}
|
||||
//On détecte tous les types de pactes en cas de guerre (pour éviter d'attaquer avec un pacte de non agression !
|
||||
if ($type) {
|
||||
$pacte = $bdd->query("SELECT id FROM $table_alliances_pactes WHERE type = $type AND time_fin = 0 AND (accepte = 0 OR accepte = 1) AND ((id_alliance1 = ".$planete->id." AND id_alliance2 = ".$alli['id'].") OR (id_alliance2 = ".$planete->id." AND id_alliance1 = ".$alli['id']."));");
|
||||
} else {
|
||||
$pacte = $bdd->query("SELECT id FROM $table_alliances_pactes WHERE time_fin = 0 AND (accepte = 0 OR accepte = 1) AND ((id_alliance1 = ".$planete->id." AND id_alliance2 = ".$alli['id'].") OR (id_alliance2 = ".$planete->id." AND id_alliance1 = ".$alli['id']."));");
|
||||
}
|
||||
|
||||
if (!empty($pacte) && !$type)
|
||||
erreur("Avant de déclarer une guerre, veuillez abroger tous vos pactes de paix !");
|
||||
elseif (!empty($pacte))
|
||||
erreur("Vous avez déjà un pacte similaire avec cette alliance !");
|
||||
if (!empty($pacte) && !$type) {
|
||||
erreur("Avant de déclarer une guerre, veuillez abroger tous vos pactes de paix !");
|
||||
} elseif (!empty($pacte)) {
|
||||
erreur("Vous avez déjà un pacte similaire avec cette alliance !");
|
||||
}
|
||||
|
||||
if ($type)
|
||||
$bdd->query("INSERT INTO $table_alliances_pactes (id_alliance1, id_alliance2, type, time_creation) VALUES (".$planete->id.", ".$alli['id'].", $type, ".time().");");
|
||||
else
|
||||
$bdd->query("INSERT INTO $table_alliances_pactes (id_alliance1, id_alliance2, type, time_creation, accepte) VALUES (".$planete->id.", ".$alli['id'].", $type, ".time().", 1);");
|
||||
$bdd->deconnexion();
|
||||
if ($type) {
|
||||
$bdd->query("INSERT INTO $table_alliances_pactes (id_alliance1, id_alliance2, type, time_creation) VALUES (".$planete->id.", ".$alli['id'].", $type, ".time().");");
|
||||
} else {
|
||||
$bdd->query("INSERT INTO $table_alliances_pactes (id_alliance1, id_alliance2, type, time_creation, accepte) VALUES (".$planete->id.", ".$alli['id'].", $type, ".time().", 1);");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($type)
|
||||
erreur("La demande de pacte a bien été enregistrée.", "green");
|
||||
else
|
||||
erreur("La déclaration a bien été enregistrée.", "green");
|
||||
}
|
||||
elseif(!empty($_GET['c']))
|
||||
{
|
||||
$id = intval(gpc('c'));
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->unique_query("SELECT id_alliance1, id_alliance2, accepte FROM $table_alliances_pactes WHERE id = $id AND (id_alliance2 = ".$planete->id." OR id_alliance1 = ".$planete->id.") AND type = 0;");
|
||||
if (!isset($demand['accepte']) || ($demand['accepte'] == 1 && $planete->id == $demand['id_alliance2']) || ($demand['accepte'] == 2 && $planete->id == $demand['id_alliance1']))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de demander le cesser le feu, n'êtes-vous pas dans la position du demandeur !");
|
||||
}
|
||||
elseif ($demand['accepte'] == 0)
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Une demande de cesser le feu est déjà en cours !");
|
||||
}
|
||||
elseif ($demand['accepte'] == 1)
|
||||
{
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 0 WHERE id = $id AND id_alliance1 = ".$planete->id." AND accepte = 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($type) {
|
||||
erreur("La demande de pacte a bien été enregistrée.", "green");
|
||||
} else {
|
||||
erreur("La déclaration a bien été enregistrée.", "green");
|
||||
}
|
||||
} elseif (!empty($_GET['c'])) {
|
||||
$id = intval(gpc('c'));
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->unique_query("SELECT id_alliance1, id_alliance2, accepte FROM $table_alliances_pactes WHERE id = $id AND (id_alliance2 = ".$planete->id." OR id_alliance1 = ".$planete->id.") AND type = 0;");
|
||||
if (!isset($demand['accepte']) || ($demand['accepte'] == 1 && $planete->id == $demand['id_alliance2']) || ($demand['accepte'] == 2 && $planete->id == $demand['id_alliance1'])) {
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de demander le cesser le feu, n'êtes-vous pas dans la position du demandeur !");
|
||||
} elseif ($demand['accepte'] == 0) {
|
||||
$bdd->deconnexion();
|
||||
erreur("Une demande de cesser le feu est déjà en cours !");
|
||||
} elseif ($demand['accepte'] == 1) {
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 0 WHERE id = $id AND id_alliance1 = ".$planete->id." AND accepte = 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
erreur("La demande de cesser le feu a bien été transmise.", "green");
|
||||
}
|
||||
elseif ($demand['accepte'] == 2)
|
||||
{
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 0, id_alliance2 = id_alliance1, id_alliance1 = ".$planete->id." WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 2;");
|
||||
$bdd->deconnexion();
|
||||
erreur("La demande de cesser le feu a bien été transmise.", "green");
|
||||
} elseif ($demand['accepte'] == 2) {
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 0, id_alliance2 = id_alliance1, id_alliance1 = ".$planete->id." WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 2;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
erreur("La demande de cesser le feu a bien été transmise.", "green");
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($onglet == "archives")
|
||||
{
|
||||
$page = "diplomatie/archives";
|
||||
erreur("La demande de cesser le feu a bien été transmise.", "green");
|
||||
}
|
||||
}
|
||||
} elseif ($onglet == "archives") {
|
||||
$page = "diplomatie/archives";
|
||||
|
||||
$bdd->reconnexion();
|
||||
$guerres = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 0 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
$bdd->reconnexion();
|
||||
$guerres = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 0 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 0 AND P.id_alliance2 = ".$planete->id." AND accepte = 1 AND time_fin != 0 ORDER BY nom_alliance DESC;");
|
||||
$pna = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 1 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
$pna = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 1 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 1 AND P.id_alliance2 = ".$planete->id." AND accepte = 1 AND time_fin != 0 ORDER BY nom_alliance DESC;");
|
||||
$pc = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 2 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
$pc = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 2 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 2 AND P.id_alliance2 = ".$planete->id." AND accepte = 1 AND time_fin != 0 ORDER BY nom_alliance DESC;");
|
||||
$pm = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 3 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
$pm = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 3 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND time_fin != 0
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 3 AND P.id_alliance2 = ".$planete->id." AND accepte = 1 AND time_fin != 0 ORDER BY nom_alliance DESC;");
|
||||
$bdd->deconnexion();
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign("pnas", $pna);
|
||||
$template->assign("guerres", $guerres);
|
||||
$template->assign("pcs", $pc);
|
||||
$template->assign("pms", $pm);
|
||||
}
|
||||
elseif ($onglet == "encours")
|
||||
{
|
||||
$page = "diplomatie/encours";
|
||||
$template->assign("pnas", $pna);
|
||||
$template->assign("guerres", $guerres);
|
||||
$template->assign("pcs", $pc);
|
||||
$template->assign("pms", $pm);
|
||||
} elseif ($onglet == "encours") {
|
||||
$page = "diplomatie/encours";
|
||||
|
||||
$bdd->reconnexion();
|
||||
$guerres = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 0 AND P.id_alliance1 = ".$planete->id." AND (time_fin = 0 OR time_fin > ".time().")
|
||||
$bdd->reconnexion();
|
||||
$guerres = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 0 AND P.id_alliance1 = ".$planete->id." AND (time_fin = 0 OR time_fin > ".time().")
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 0 AND P.id_alliance2 = ".$planete->id." AND (time_fin = 0 OR time_fin > ".time().")
|
||||
ORDER BY nom_alliance DESC;");
|
||||
$pna = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 1 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
$pna = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 1 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 1 AND P.id_alliance2 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
ORDER BY nom_alliance DESC;");
|
||||
$pc = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 2 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
$pc = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 2 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 2 AND P.id_alliance2 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
ORDER BY nom_alliance DESC;");
|
||||
$pm = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 3 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
$pm = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.type = 3 AND P.id_alliance1 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.type = 3 AND P.id_alliance2 = ".$planete->id." AND accepte = 1 AND (time_fin = 0 OR time_fin > ".time().")
|
||||
ORDER BY nom_alliance DESC;");
|
||||
$bdd->deconnexion();
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign("pnas", $pna);
|
||||
$template->assign("guerres", $guerres);
|
||||
$template->assign("pcs", $pc);
|
||||
$template->assign("pms", $pm);
|
||||
}
|
||||
else
|
||||
{
|
||||
$onglet = "actus";
|
||||
$page = "diplomatie/general";
|
||||
$template->assign("pnas", $pna);
|
||||
$template->assign("guerres", $guerres);
|
||||
$template->assign("pcs", $pc);
|
||||
$template->assign("pms", $pm);
|
||||
} else {
|
||||
$onglet = "actus";
|
||||
$page = "diplomatie/general";
|
||||
|
||||
if ($planete->permissions_alliance &8)
|
||||
{
|
||||
if (!empty($_GET['a']))
|
||||
{
|
||||
$id = intval(gpc('a'));
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->unique_query("SELECT type FROM $table_alliances_pactes WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
if (!isset($demand['type']))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de trouver le pacte !");
|
||||
}
|
||||
elseif ($demand['type'] == 0)
|
||||
{
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 1, time_fin = ".time()." WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("C'est la fin de la guerre, vous vennez d'accepter le cesser le feu !", "orange", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 1, time_creation = ".time()." WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("Le pacte a bien été accepté.", "green", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
}
|
||||
elseif (!empty($_GET['r']))
|
||||
{
|
||||
$id = intval(gpc('r'));
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->unique_query("SELECT type FROM $table_alliances_pactes WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
if (!isset($demand['type']))
|
||||
{
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de trouver le pacte !");
|
||||
}
|
||||
elseif ($demand['type'] == 0)
|
||||
{
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 2 WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("La guerre continue, vous vennez de refuser le cesser le feu !<br />Se sera désormais à vous de proposer un cesser le feu à la fin de la guerre.", "orange", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 2 WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("Le pacte a bien été refusé.", "orange", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
}
|
||||
elseif (!empty($_GET['s']))
|
||||
{
|
||||
$id = intval(gpc('s'));
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET time_fin = ".time()." WHERE id = $id AND (id_alliance2 = ".$planete->id." OR id_alliance1 = ".$planete->id.") AND accepte = 1;");
|
||||
$bdd->deconnexion();
|
||||
if ($planete->permissions_alliance &8) {
|
||||
if (!empty($_GET['a'])) {
|
||||
$id = intval(gpc('a'));
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->unique_query("SELECT type FROM $table_alliances_pactes WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
if (!isset($demand['type'])) {
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de trouver le pacte !");
|
||||
} elseif ($demand['type'] == 0) {
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 1, time_fin = ".time()." WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("C'est la fin de la guerre, vous vennez d'accepter le cesser le feu !", "orange", $VAR['menu']['diplomatie']);
|
||||
} else {
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 1, time_creation = ".time()." WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("Le pacte a bien été accepté.", "green", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
} elseif (!empty($_GET['r'])) {
|
||||
$id = intval(gpc('r'));
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->unique_query("SELECT type FROM $table_alliances_pactes WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
if (!isset($demand['type'])) {
|
||||
$bdd->deconnexion();
|
||||
erreur("Impossible de trouver le pacte !");
|
||||
} elseif ($demand['type'] == 0) {
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 2 WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("La guerre continue, vous vennez de refuser le cesser le feu !<br />Se sera désormais à vous de proposer un cesser le feu à la fin de la guerre.", "orange", $VAR['menu']['diplomatie']);
|
||||
} else {
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET accepte = 2 WHERE id = $id AND id_alliance2 = ".$planete->id." AND accepte = 0;");
|
||||
$bdd->deconnexion();
|
||||
erreur("Le pacte a bien été refusé.", "orange", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
} elseif (!empty($_GET['s'])) {
|
||||
$id = intval(gpc('s'));
|
||||
$bdd->reconnexion();
|
||||
$bdd->query("UPDATE $table_alliances_pactes SET time_fin = ".time()." WHERE id = $id AND (id_alliance2 = ".$planete->id." OR id_alliance1 = ".$planete->id.") AND accepte = 1;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
erreur("Le pacte a bien été abrogé.", "orange", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
}
|
||||
erreur("Le pacte a bien été abrogé.", "orange", $VAR['menu']['diplomatie']);
|
||||
}
|
||||
}
|
||||
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.id_alliance2 = ".$planete->id." AND accepte = 0 ORDER BY time_demand DESC;");
|
||||
$actus_alli = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.id_alliance1 = ".$planete->id."
|
||||
$bdd->reconnexion();
|
||||
$demand = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.id_alliance2 = ".$planete->id." AND accepte = 0 ORDER BY time_demand DESC;");
|
||||
$actus_alli = $bdd->query("SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 WHERE P.id_alliance1 = ".$planete->id."
|
||||
UNION SELECT P.*, A.nom_alliance, A.tag, A.id AS alliance_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance1 WHERE P.id_alliance2 = ".$planete->id." AND P.accepte != 0
|
||||
ORDER BY time_demand DESC LIMIT 5;");
|
||||
$actus_world = $bdd->query("SELECT P.*, A.tag AS tag1, A.nom_alliance AS nom_alliance1, A.id AS alliance1_id, B.tag AS tag2, B.nom_alliance AS nom_alliance2, B.id AS alliance2_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 INNER JOIN $table_alliances B ON B.id = P.id_alliance1 WHERE P.accepte = 1 AND P.id_alliance1 != ".$planete->id." AND P.id_alliance2 != ".$planete->id." ORDER BY time_demand DESC LIMIT 5;");
|
||||
$bdd->deconnexion();
|
||||
$actus_world = $bdd->query("SELECT P.*, A.tag AS tag1, A.nom_alliance AS nom_alliance1, A.id AS alliance1_id, B.tag AS tag2, B.nom_alliance AS nom_alliance2, B.id AS alliance2_id FROM $table_alliances_pactes P INNER JOIN $table_alliances A ON A.id = P.id_alliance2 INNER JOIN $table_alliances B ON B.id = P.id_alliance1 WHERE P.accepte = 1 AND P.id_alliance1 != ".$planete->id." AND P.id_alliance2 != ".$planete->id." ORDER BY time_demand DESC LIMIT 5;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$template->assign("demandes", $demand);
|
||||
$template->assign("actus_alli", $actus_alli);
|
||||
$template->assign("actus_world", $actus_world);
|
||||
unset($demand);
|
||||
$template->assign("demandes", $demand);
|
||||
$template->assign("actus_alli", $actus_alli);
|
||||
$template->assign("actus_world", $actus_world);
|
||||
unset($demand);
|
||||
}
|
||||
|
||||
$template->assign("onglet", $onglet);
|
||||
unset($onglet);
|
||||
?>
|
||||
|
|
@ -1,22 +1,29 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$titre = 'Flottes';
|
||||
$page = 'flotte'; //Définition d'un nom de page inexistant, mais permet de passer le nom de l'onglet dans une erreur
|
||||
include_once("Class/flotte.php");
|
||||
|
||||
//Création de flotte : envoi final
|
||||
if (!empty($_POST['cds']) && !empty($SESS->values["prepFlottes"][$_POST['cds']]))
|
||||
require('game/flottes/envoyer.php');
|
||||
if (!empty($_POST['cds']) && !empty($SESS->values["prepFlottes"][$_POST['cds']])) {
|
||||
require('game/flottes/envoyer.php');
|
||||
}
|
||||
//Restauration d'une flotte sauvegardée
|
||||
elseif (isset($_GET['c']) && !empty($SESS->values["prepFlottes"][$_GET['c']]))
|
||||
require('game/flottes/restaure.php');
|
||||
elseif (isset($_GET['c']) && !empty($SESS->values["prepFlottes"][$_GET['c']])) {
|
||||
require('game/flottes/restaure.php');
|
||||
}
|
||||
//Création de flotte : page 2
|
||||
elseif (!empty($_POST['envoie']) || !empty($_POST['groupe']))
|
||||
require('game/flottes/preparer.php');
|
||||
elseif (!empty($_POST['envoie']) || !empty($_POST['groupe'])) {
|
||||
require('game/flottes/preparer.php');
|
||||
}
|
||||
//Affichage du détail d'une flotte
|
||||
elseif (!empty($_GET['n']))
|
||||
require('game/flottes/details.php');
|
||||
elseif (!empty($_GET['n'])) {
|
||||
require('game/flottes/details.php');
|
||||
}
|
||||
//Affichage de la page générale
|
||||
else
|
||||
require('game/flottes/principal.php');
|
||||
?>
|
||||
else {
|
||||
require('game/flottes/principal.php');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,46 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
$idN = intval(gpc('n'));
|
||||
$idN = intval(gpc('n'));
|
||||
|
||||
$flotteN = new Flotte($idN, false);
|
||||
$flotteN->load_planete();
|
||||
$flotteN = new Flotte($idN, false);
|
||||
$flotteN->load_planete();
|
||||
|
||||
if ($flotteN->id_flotte == 0 || $flotteN->start_planete->id_user != $planete->id_user)
|
||||
erreur('Impossible de trouver cette flotte !', "red", '?p=flotte', 1500);
|
||||
else
|
||||
{
|
||||
//Changement du nom de la flotte
|
||||
if (!empty($_POST['nomflotte']))
|
||||
{
|
||||
$nouvNom = gpc('nomflotte', 'post');
|
||||
$flotteN->nom = $nouvNom;
|
||||
$flotteN->addModifFlotte("nom");
|
||||
if ($flotteN->id_flotte == 0 || $flotteN->start_planete->id_user != $planete->id_user) {
|
||||
erreur('Impossible de trouver cette flotte !', "red", '?p=flotte', 1500);
|
||||
} else {
|
||||
//Changement du nom de la flotte
|
||||
if (!empty($_POST['nomflotte'])) {
|
||||
$nouvNom = gpc('nomflotte', 'post');
|
||||
$flotteN->nom = $nouvNom;
|
||||
$flotteN->addModifFlotte("nom");
|
||||
|
||||
redirection("?p=flotte&n=".$idN);
|
||||
}
|
||||
redirection("?p=flotte&n=".$idN);
|
||||
}
|
||||
|
||||
//Annulation de la mission
|
||||
if (isset($_GET['a']) && isset($SESS->values['ret_fleet']) && $_GET['a'] == $SESS->values['ret_fleet'])
|
||||
{
|
||||
//Calcul du temps passé depuis le lancement de la flotte
|
||||
$tpsDD = time() - $flotteN->start_time;
|
||||
if ($flotteN->mission == '6')
|
||||
erreur('Votre flotte est déjà en train de revenir !', 'red', '?p=flotte&n='.$idN, 1500);
|
||||
elseif ($flotteN->end_time > $tpsDD)
|
||||
{
|
||||
$bdd->query("UPDATE $table_flottes SET mission = '6', effectue = '1', end_time = $tpsDD, end_galaxie = start_galaxie, end_ss = start_ss, end_position = start_position WHERE id_user = ".$planete->id_user." AND id = $idN;");
|
||||
redirection("?p=flotte&n=".$idN);
|
||||
}
|
||||
else
|
||||
erreur('Impossible d\'annuler la mission, elle a déjà commencée.', "red", '?p=flotte&n='.$idN, 1500);
|
||||
}
|
||||
|
||||
$SESS->values['ret_fleet'] = md5('HB.fleet_'.rand().'☺ß☻');
|
||||
$SESS->put();
|
||||
|
||||
$template->assign('ret_fleet', $SESS->values['ret_fleet']);
|
||||
$template->assign('flotte', $flotteN);
|
||||
$page = 'flotten';
|
||||
}
|
||||
//Annulation de la mission
|
||||
if (isset($_GET['a']) && isset($SESS->values['ret_fleet']) && $_GET['a'] == $SESS->values['ret_fleet']) {
|
||||
//Calcul du temps passé depuis le lancement de la flotte
|
||||
$tpsDD = time() - $flotteN->start_time;
|
||||
if ($flotteN->mission == '6') {
|
||||
erreur('Votre flotte est déjà en train de revenir !', 'red', '?p=flotte&n='.$idN, 1500);
|
||||
} elseif ($flotteN->end_time > $tpsDD) {
|
||||
$bdd->query("UPDATE $table_flottes SET mission = '6', effectue = '1', end_time = $tpsDD, end_galaxie = start_galaxie, end_ss = start_ss, end_position = start_position WHERE id_user = ".$planete->id_user." AND id = $idN;");
|
||||
redirection("?p=flotte&n=".$idN);
|
||||
} else {
|
||||
erreur('Impossible d\'annuler la mission, elle a déjà commencée.', "red", '?p=flotte&n='.$idN, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
$SESS->values['ret_fleet'] = md5('HB.fleet_'.rand().'☺ß☻');
|
||||
$SESS->put();
|
||||
|
||||
$template->assign('ret_fleet', $SESS->values['ret_fleet']);
|
||||
$template->assign('flotte', $flotteN);
|
||||
$page = 'flotten';
|
||||
}
|
||||
|
||||
unset($idN, $flotteN, $nouvNom, $tpsDD);
|
||||
?>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
//Récupération des informations envoyées
|
||||
$idPrep = gpc("cds", "post");
|
||||
|
|
@ -8,10 +11,11 @@ $SESS->values["prepFlottes"][$idPrep]['nom'] = gpc('nomflotte', 'post');
|
|||
$SESS->values["prepFlottes"][$idPrep]['end_galaxie'] = $end_galaxie = intval(gpc('amas', 'post'));
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_systeme'] = $end_ss = intval(gpc('ss', 'post'));
|
||||
$end_pos = gpc('pos', 'post');
|
||||
if ($end_pos != "A")
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = floor($end_pos);
|
||||
else
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = $end_pos;
|
||||
if ($end_pos != "A") {
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = floor($end_pos);
|
||||
} else {
|
||||
$SESS->values["prepFlottes"][$idPrep]['end_position'] = $end_pos;
|
||||
}
|
||||
$SESS->values["prepFlottes"][$idPrep]['embarquer'] = array($EBmetal = floor(str_replace(' ', '', gpc('metal', 'post'))), $EBcristal = floor(str_replace(' ', '', gpc('cristal', 'post'))), $EBhydrogene = floor(str_replace(' ', '', gpc('hydrogene', 'post'))));
|
||||
$SESS->values["prepFlottes"][$idPrep]['mission'] = $mission = intval(gpc('mission', 'post'));
|
||||
$SESS->values["prepFlottes"][$idPrep]['vitesse'] = $vitesse = intval(gpc('vitesse', 'post'));
|
||||
|
|
@ -20,137 +24,140 @@ $SESS->values["prepFlottes"][$idPrep]['vitesse'] = $vitesse = intval(gpc('vitess
|
|||
$SESS->put();
|
||||
|
||||
//Vérification du nombre de vaisseaux sur la planète
|
||||
foreach ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'] as $key => $vaisseau)
|
||||
{
|
||||
//On vérifie qu'il y a suffisamment de vaisseaux sur la planète
|
||||
if ($planete->vaisseaux[$key] < $vaisseau)
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", $VAR["menu"]["flotte"]);
|
||||
foreach ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'] as $key => $vaisseau) {
|
||||
//On vérifie qu'il y a suffisamment de vaisseaux sur la planète
|
||||
if ($planete->vaisseaux[$key] < $vaisseau) {
|
||||
erreur('Vous n\'avez pas assez de vaisseaux sur cette planète pour envoyer cette flotte !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
}
|
||||
|
||||
//Vérification des conditions de mission
|
||||
if ($mission <= 0 || $mission > 7 || ($SESS->values["prepFlottes"][$idPrep]['type'] == 3 && $mission != 3 && $mission != 2))
|
||||
erreur("La mission sélectionnée est incorrecte !", "red", $VAR["menu"]["flotte"]);
|
||||
if ($mission <= 0 || $mission > 7 || ($SESS->values["prepFlottes"][$idPrep]['type'] == 3 && $mission != 3 && $mission != 2)) {
|
||||
erreur("La mission sélectionnée est incorrecte !", "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//Vérification que le nombre de slots ne soit pas dépassé
|
||||
if (slots($planete->id_user) <= 0)
|
||||
erreur('Vous ne pouvez pas envoyer plus de flottes simultanément.', "red", $VAR["menu"]["flotte"]);
|
||||
if (slots($planete->id_user) <= 0) {
|
||||
erreur('Vous ne pouvez pas envoyer plus de flottes simultanément.', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//Vérifications en cas de mission colonisation
|
||||
if ($mission == 2)
|
||||
{
|
||||
//On vérifie la mission, si elle est de coloniser, il faut qu'il y ait des vaisseaux de colonisation
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][2] <= 0)
|
||||
erreur('Vous ne pouvez pas coloniser sans vaisseau de colonisation !', "red", $VAR["menu"]["flotte"]);
|
||||
if ($mission == 2) {
|
||||
//On vérifie la mission, si elle est de coloniser, il faut qu'il y ait des vaisseaux de colonisation
|
||||
if ($SESS->values["prepFlottes"][$idPrep]['vaisseaux'][2] <= 0) {
|
||||
erreur('Vous ne pouvez pas coloniser sans vaisseau de colonisation !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//On vérifie qu'une colonisation d'asteroide soit bien faite par un fondateur d'alliance en cours de création
|
||||
if ($end_pos == "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user.";");
|
||||
$bdd->deconnexion();
|
||||
if (!$resultat)
|
||||
erreur('Fonder d\'abord une alliance avant de coloniser un astéroide !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
//On vérifie qu'une colonisation d'asteroide soit bien faite par un fondateur d'alliance en cours de création
|
||||
if ($end_pos == "A") {
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id FROM $table_alliances_creation WHERE fondateur = ".$planete->id_user.";");
|
||||
$bdd->deconnexion();
|
||||
if (!$resultat) {
|
||||
erreur('Fonder d\'abord une alliance avant de coloniser un astéroide !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//On vérifie que les attaques soient bien activées
|
||||
if ($mission == 3 && !$VAR["attaques"])
|
||||
erreur('Les attaques sont désactivées pour le moment. Pour plus d\'informations, <a href="'.$VAR["menu"]["forums"].'">consultez le forum</a>.', "red", $VAR["menu"]["flotte"], 5000);
|
||||
if ($mission == 3 && !$VAR["attaques"]) {
|
||||
erreur('Les attaques sont désactivées pour le moment. Pour plus d\'informations, <a href="'.$VAR["menu"]["forums"].'">consultez le forum</a>.', "red", $VAR["menu"]["flotte"], 5000);
|
||||
}
|
||||
|
||||
//On vérifie la mission, si elle est de recycler, il faut qu'il y ait des reclycleurs
|
||||
if ($mission == 4 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][3] <= 0)
|
||||
erreur('Vous ne pouvez pas recycler sans recycleur !', "red", $VAR["menu"]["flotte"]);
|
||||
if ($mission == 4 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][3] <= 0) {
|
||||
erreur('Vous ne pouvez pas recycler sans recycleur !', "red", $VAR["menu"]["flotte"]);
|
||||
}
|
||||
|
||||
//On vérifie la mission, si elle est d'espionner, il faut qu'il y ait des sondes
|
||||
if ($mission == 5 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][6] <= 0 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][13] <= 0)
|
||||
erreur('Vous ne pouvez pas espionner sans sonde d\'espionnage !', "red", '?p=flotte');
|
||||
if ($mission == 5 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][6] <= 0 && $SESS->values["prepFlottes"][$idPrep]['vaisseaux'][13] <= 0) {
|
||||
erreur('Vous ne pouvez pas espionner sans sonde d\'espionnage !', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//Vérification que la destination ne soit pas en dehors de la galaxie
|
||||
if ($end_galaxie > $VAR['nb_amas'] || $end_ss > $VAR['nb_systeme'] || $end_galaxie < 0 || $end_ss < 1 || (($end_pos > $VAR['nb_planete'] || $end_pos < 1) && $end_pos != "A") || ($end_galaxie < 1 && $SESS->level < 6))
|
||||
erreur('La destination de la flotte n\'est pas correcte.', "red", '?p=flotte');
|
||||
if ($end_galaxie > $VAR['nb_amas'] || $end_ss > $VAR['nb_systeme'] || $end_galaxie < 0 || $end_ss < 1 || (($end_pos > $VAR['nb_planete'] || $end_pos < 1) && $end_pos != "A") || ($end_galaxie < 1 && $SESS->level < 6)) {
|
||||
erreur('La destination de la flotte n\'est pas correcte.', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//On vérifie que l'on possède assez de ressources
|
||||
if ((!empty($EBmetal) && !$EBmetal > $planete->metal) || (!empty($EBcristal) && !$EBcristal > $planete->cristal) || (!empty($EBhydrogene) && !$EBhydrogene > $planete->hydrogene))
|
||||
erreur('Vous ne pouvez pas envoyer plus de ressources que vous n\'en posséder.', "red", '?p=flotte');
|
||||
if ((!empty($EBmetal) && !$EBmetal > $planete->metal) || (!empty($EBcristal) && !$EBcristal > $planete->cristal) || (!empty($EBhydrogene) && !$EBhydrogene > $planete->hydrogene)) {
|
||||
erreur('Vous ne pouvez pas envoyer plus de ressources que vous n\'en posséder.', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//On vérifie que l'on n'envoie pas des ressources négatives
|
||||
if ((!empty($EBmetal) && $EBmetal < 0) || (!empty($EBcristal) && $EBcristal < 0) || (!empty($EBhydrogene) && $EBhydrogene < 0))
|
||||
erreur('Vous avez spécifié des valeurs de ressources à embarquer incorrectes !', "red", '?p=flotte', 4000);
|
||||
if ((!empty($EBmetal) && $EBmetal < 0) || (!empty($EBcristal) && $EBcristal < 0) || (!empty($EBhydrogene) && $EBhydrogene < 0)) {
|
||||
erreur('Vous avez spécifié des valeurs de ressources à embarquer incorrectes !', "red", '?p=flotte', 4000);
|
||||
}
|
||||
|
||||
//On vérifie la vitesse de la flotte
|
||||
if (!is_numeric($vitesse) || $vitesse < 0 || $vitesse > 100)
|
||||
erreur('La vitesse de votre flotte est incorrecte !', "red", '?p=flotte');
|
||||
if (!is_numeric($vitesse) || $vitesse < 0 || $vitesse > 100) {
|
||||
erreur('La vitesse de votre flotte est incorrecte !', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
|
||||
//Recherche de la planète ou de l'astéroïde
|
||||
if ($end_pos == "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id AS id_user, debris_met, debris_cri FROM $table_alliances WHERE galaxie = $end_galaxie AND ss = $end_ss;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id_user, debris_met, debris_cri FROM $table_planete WHERE galaxie = $end_galaxie AND ss = $end_ss AND position = $end_pos;");
|
||||
$bdd->deconnexion();
|
||||
if ($end_pos == "A") {
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id AS id_user, debris_met, debris_cri FROM $table_alliances WHERE galaxie = $end_galaxie AND ss = $end_ss;");
|
||||
$bdd->deconnexion();
|
||||
} else {
|
||||
$bdd->reconnexion();
|
||||
$resultat = $bdd->unique_query("SELECT id, id_user, debris_met, debris_cri FROM $table_planete WHERE galaxie = $end_galaxie AND ss = $end_ss AND position = $end_pos;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
//On vérifie qu'il n'y ait pas une interaction entre deux multi-comptes
|
||||
if (count($multi) > 1 && ($mission == 1 || $mission == 6 || $mission == 7))
|
||||
{
|
||||
foreach($multi as $test)
|
||||
{
|
||||
if ($test['id_util'] == $resultat['id_user'])
|
||||
erreur('Vous ne pouvez pas avoir d\'interaction avec ce joueur pour raison de multi-compte (voir page d\'accueil).');
|
||||
}
|
||||
if (count($multi) > 1 && ($mission == 1 || $mission == 6 || $mission == 7)) {
|
||||
foreach ($multi as $test) {
|
||||
if ($test['id_util'] == $resultat['id_user']) {
|
||||
erreur('Vous ne pouvez pas avoir d\'interaction avec ce joueur pour raison de multi-compte (voir page d\'accueil).');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($mission == 1 && !$resultat)
|
||||
erreur('Impossible de transporter des ressources vers la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
elseif ($mission == 2 && $resultat)
|
||||
{
|
||||
if ($end_pos != "A")
|
||||
erreur('La planète que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
else
|
||||
erreur('L\'astéroide que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
if ($mission == 1 && !$resultat) {
|
||||
erreur('Impossible de transporter des ressources vers la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
} elseif ($mission == 2 && $resultat) {
|
||||
if ($end_pos != "A") {
|
||||
erreur('La planète que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
} else {
|
||||
erreur('L\'astéroide que vous voulez coloniser est déjà habitée.', "red", '?p=flotte', 3000);
|
||||
}
|
||||
}
|
||||
//Si la mission est d'attaquer, on vérifie que le joueur cible ne soit pas ne mode vacances ou qu'il soit tout jeune
|
||||
elseif ($mission == 3 && $end_pos != "A")
|
||||
{
|
||||
$bdd->reconnexion();
|
||||
$resultatu = $bdd->unique_query("SELECT mv, time_inscription FROM $table_user WHERE id = ".$resultat['id_user'].";");
|
||||
$bdd->deconnexion();
|
||||
elseif ($mission == 3 && $end_pos != "A") {
|
||||
$bdd->reconnexion();
|
||||
$resultatu = $bdd->unique_query("SELECT mv, time_inscription FROM $table_user WHERE id = ".$resultat['id_user'].";");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if ($resultatu['mv'] > 0)
|
||||
erreur('Le joueur que vous tentez d\'attaquer est actuellement en mode vacances, vous ne pouvez donc pas l\'attaquer avant son retour de vacances.', "red", '?p=flotte', 3000); //TODO Mettre le numéro du mode vacances et non > 0 !!!
|
||||
elseif ($resultatu['time_inscription'] + 604800 > time())
|
||||
erreur('Le joueur que vous tentez d\'attaquer s\'est inscrit récemment, laissez-lui le temps de se préparer au combat !', "red", '?p=flotte', 3000);
|
||||
elseif (!$resultat)
|
||||
erreur('La planète que vous tentez d\'attaquer est inhabitée.', "red", '?p=flotte');
|
||||
elseif ($resultat['id_user'] == $planete->id_user)
|
||||
erreur('La planète que vous tentez d\'attaquer vous appartient.', "red", '?p=flotte');
|
||||
}
|
||||
elseif ($mission == 4 && ($resultat['debris_met'] <= 0 || $resultat['debris_cri'] <= 0) && empty($SESS->values['forceFlotte']))
|
||||
{
|
||||
$SESS->values['forceFlotte'] = true;
|
||||
$SESS->put();
|
||||
erreur('Il n\'y a rien à recycler sur la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'].<br />Vous pouvez forcer le lancement de la flotte en rechargeant cette page.', "orange");
|
||||
if ($resultatu['mv'] > 0) {
|
||||
erreur('Le joueur que vous tentez d\'attaquer est actuellement en mode vacances, vous ne pouvez donc pas l\'attaquer avant son retour de vacances.', "red", '?p=flotte', 3000);
|
||||
} //TODO Mettre le numéro du mode vacances et non > 0 !!!
|
||||
elseif ($resultatu['time_inscription'] + 604800 > time()) {
|
||||
erreur('Le joueur que vous tentez d\'attaquer s\'est inscrit récemment, laissez-lui le temps de se préparer au combat !', "red", '?p=flotte', 3000);
|
||||
} elseif (!$resultat) {
|
||||
erreur('La planète que vous tentez d\'attaquer est inhabitée.', "red", '?p=flotte');
|
||||
} elseif ($resultat['id_user'] == $planete->id_user) {
|
||||
erreur('La planète que vous tentez d\'attaquer vous appartient.', "red", '?p=flotte');
|
||||
}
|
||||
} elseif ($mission == 4 && ($resultat['debris_met'] <= 0 || $resultat['debris_cri'] <= 0) && empty($SESS->values['forceFlotte'])) {
|
||||
$SESS->values['forceFlotte'] = true;
|
||||
$SESS->put();
|
||||
erreur('Il n\'y a rien à recycler sur la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'].<br />Vous pouvez forcer le lancement de la flotte en rechargeant cette page.', "orange");
|
||||
}
|
||||
//TODO Autoriser l'espionnage sur les planètes inhabités
|
||||
elseif ($mission == 5)
|
||||
{
|
||||
if (!$resultat)
|
||||
erreur('Impossible d\'espionner la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
elseif ($end_pos != "A" && $resultat['id_user'] == $planete->id_user)
|
||||
erreur('La planète que vous désirez espionner vous appartient !', "red", '?p=flotte', 3000);
|
||||
elseif ($mission == 5) {
|
||||
if (!$resultat) {
|
||||
erreur('Impossible d\'espionner la planète ['.$end_galaxie.':'.$end_ss.':'.$end_pos.'] car elle est inhabitée.', "red", '?p=flotte', 4000);
|
||||
} elseif ($end_pos != "A" && $resultat['id_user'] == $planete->id_user) {
|
||||
erreur('La planète que vous désirez espionner vous appartient !', "red", '?p=flotte', 3000);
|
||||
}
|
||||
} elseif ($mission == 6 && $resultat['id_user'] != $planete->id_user && $resultat['id_user'] != $planete->id_alliance) {
|
||||
erreur('La planète sur laquelle vous désirez stationner ne vous appartient pas.', "red", '?p=flotte', 3000);
|
||||
} elseif ($mission == 7 && !$resultat) {
|
||||
erreur('La planète sur laquelle vous désirez donner vos vaisseaux n\'existe pas.', "red", '?p=flotte', 3000);
|
||||
}
|
||||
|
||||
elseif ($mission == 6 && $resultat['id_user'] != $planete->id_user && $resultat['id_user'] != $planete->id_alliance)
|
||||
erreur('La planète sur laquelle vous désirez stationner ne vous appartient pas.', "red", '?p=flotte', 3000);
|
||||
elseif ($mission == 7 && !$resultat)
|
||||
erreur('La planète sur laquelle vous désirez donner vos vaisseaux n\'existe pas.', "red", '?p=flotte', 3000);
|
||||
|
||||
|
||||
//Création de la flotte
|
||||
$flotte = new flotte();
|
||||
|
|
@ -159,4 +166,3 @@ $SESS->values["prepFlottes"][$idPrep]["statut"] = 2;
|
|||
$SESS->put();
|
||||
|
||||
erreur('Votre flotte a été envoyée avec succès.', "green", '?p=flotte', 4000);
|
||||
?>
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
|
||||
//Génération d'un ID unique pour identifier la flotte durant sa création
|
||||
$idPrep = random();
|
||||
|
|
@ -9,29 +12,29 @@ $SESS->values["prepFlottes"][$idPrep] = array();
|
|||
|
||||
//On récupère les vaisseaux à envoyer
|
||||
$nombreVaisseau = 0;
|
||||
foreach ($planete->vaisseaux as $key => $vaisseau)
|
||||
{
|
||||
$v = gpc('v'.$key, 'post');
|
||||
if (!is_numeric($v) || $v < 0)
|
||||
$v = 0;
|
||||
foreach ($planete->vaisseaux as $key => $vaisseau) {
|
||||
$v = gpc('v'.$key, 'post');
|
||||
if (!is_numeric($v) || $v < 0) {
|
||||
$v = 0;
|
||||
}
|
||||
|
||||
$SESS->values["prepFlottes"][$idPrep]['vaisseaux'][$key] = $v;
|
||||
$nombreVaisseau += $v;
|
||||
$SESS->values["prepFlottes"][$idPrep]['vaisseaux'][$key] = $v;
|
||||
$nombreVaisseau += $v;
|
||||
}
|
||||
//On vérifie que l'utilisateur a bien envoyé plus d'un vaisseau
|
||||
if ($nombreVaisseau <= 0)
|
||||
{
|
||||
unset($SESS->values["prepFlottes"][$idPrep]);
|
||||
erreur('Vous devez envoyer au moins un vaisseau.', "red", '?p=flotte');
|
||||
if ($nombreVaisseau <= 0) {
|
||||
unset($SESS->values["prepFlottes"][$idPrep]);
|
||||
erreur('Vous devez envoyer au moins un vaisseau.', "red", '?p=flotte');
|
||||
}
|
||||
|
||||
//On définit le type de la flotte (utilisateur ou alliance)
|
||||
if (!empty($_POST['envoie']))
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 1;
|
||||
elseif (!empty($_POST['groupe']))
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 2;
|
||||
else
|
||||
die ('Erreur !');
|
||||
if (!empty($_POST['envoie'])) {
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 1;
|
||||
} elseif (!empty($_POST['groupe'])) {
|
||||
$SESS->values["prepFlottes"][$idPrep]['type'] = 2;
|
||||
} else {
|
||||
die('Erreur !');
|
||||
}
|
||||
|
||||
//On enregistre les paramètres en session
|
||||
$SESS->values["prepFlottes"][$idPrep]['nbVaisseaux'] = $nombreVaisseau;
|
||||
|
|
@ -44,4 +47,3 @@ unset($nombreVaisseau, $key, $vaisseau, $v);
|
|||
|
||||
header('Location: ?p=flotte&c='.$idPrep);
|
||||
exit;
|
||||
?>
|
||||
|
|
@ -1,87 +1,89 @@
|
|||
<?php
|
||||
if(!defined('INDEX')) { header('Location: ../'); exit; }
|
||||
if (!defined('INDEX')) {
|
||||
header('Location: ../');
|
||||
exit;
|
||||
}
|
||||
$page = 'flotte1';
|
||||
|
||||
//Demande de mise à jour des tactiques par défaut
|
||||
$attaque = gpc('attaque', 'post');
|
||||
$defense = gpc('defense', 'post');
|
||||
if (is_numeric($attaque) && is_numeric($defense))
|
||||
{
|
||||
$chang = false;
|
||||
if (($attaque != $planete->combatAT_tactique) && (($attaque == 1 && $planete->technologies[3] & 4096) || ($attaque == 2 && $planete->technologies[3] & 8192) || ($attaque == 3 && $planete->technologies[3] & 16384) || $attaque == 0))
|
||||
{
|
||||
$planete->combatAT_tactique = $attaque;
|
||||
$planete->addModifUser('combatAT_tactique');
|
||||
$chang = true;
|
||||
}
|
||||
if (($defense != $planete->combatDE_tactique) && (($defense == 1 && $planete->technologies[3] & 4096) || ($defense == 2 && $planete->technologies[3] & 8192) || ($defense == 3 && $planete->technologies[3] & 16384) || $defense == 0))
|
||||
{
|
||||
$planete->combatDE_tactique = $defense;
|
||||
$planete->addModifUser('combatDE_tactique');
|
||||
$chang = true;
|
||||
}
|
||||
|
||||
if ($chang)
|
||||
erreur('Tactiques mises à jour avec succès.', 'green', '?p=flotte', 1100);
|
||||
}
|
||||
unset($attaque, $defense, $chang);
|
||||
//Demande de mise à jour des tactiques par défaut
|
||||
$attaque = gpc('attaque', 'post');
|
||||
$defense = gpc('defense', 'post');
|
||||
if (is_numeric($attaque) && is_numeric($defense)) {
|
||||
$chang = false;
|
||||
if (($attaque != $planete->combatAT_tactique) && (($attaque == 1 && $planete->technologies[3] & 4096) || ($attaque == 2 && $planete->technologies[3] & 8192) || ($attaque == 3 && $planete->technologies[3] & 16384) || $attaque == 0)) {
|
||||
$planete->combatAT_tactique = $attaque;
|
||||
$planete->addModifUser('combatAT_tactique');
|
||||
$chang = true;
|
||||
}
|
||||
if (($defense != $planete->combatDE_tactique) && (($defense == 1 && $planete->technologies[3] & 4096) || ($defense == 2 && $planete->technologies[3] & 8192) || ($defense == 3 && $planete->technologies[3] & 16384) || $defense == 0)) {
|
||||
$planete->combatDE_tactique = $defense;
|
||||
$planete->addModifUser('combatDE_tactique');
|
||||
$chang = true;
|
||||
}
|
||||
|
||||
if ($chang) {
|
||||
erreur('Tactiques mises à jour avec succès.', 'green', '?p=flotte', 1100);
|
||||
}
|
||||
}
|
||||
unset($attaque, $defense, $chang);
|
||||
|
||||
//Affichage des flottes en cours dans la galaxie
|
||||
$bdd->reconnexion();
|
||||
if (SURFACE == "asteroide")
|
||||
$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE id_alliance = ".$planete->id.";");
|
||||
else
|
||||
$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE id_user = ".$planete->id_user.";");
|
||||
$bdd->deconnexion();
|
||||
//Affichage des flottes en cours dans la galaxie
|
||||
$bdd->reconnexion();
|
||||
if (SURFACE == "asteroide") {
|
||||
$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE id_alliance = ".$planete->id.";");
|
||||
} else {
|
||||
$flottes = $bdd->query("SELECT id FROM $table_flottes WHERE id_user = ".$planete->id_user.";");
|
||||
}
|
||||
$bdd->deconnexion();
|
||||
|
||||
//Extraction des flottes en cours
|
||||
if ($flottes)
|
||||
{
|
||||
foreach ($flottes as $key => $flotte)
|
||||
{
|
||||
$flottes[$key] = new Flotte($flotte['id']);
|
||||
$flottes[$key]->load_planete();
|
||||
}
|
||||
$template->assign('flottesEC', $flottes);
|
||||
}
|
||||
//Extraction des flottes en cours
|
||||
if ($flottes) {
|
||||
foreach ($flottes as $key => $flotte) {
|
||||
$flottes[$key] = new Flotte($flotte['id']);
|
||||
$flottes[$key]->load_planete();
|
||||
}
|
||||
$template->assign('flottesEC', $flottes);
|
||||
}
|
||||
|
||||
//Calcul du nombre de slot disponible et vérouillage de l'envoie si besoin
|
||||
if ($flottes)
|
||||
$nbFlottes = count($flottes);
|
||||
else
|
||||
//Calcul du nombre de slot disponible et vérouillage de l'envoie si besoin
|
||||
if ($flottes) {
|
||||
$nbFlottes = count($flottes);
|
||||
} else {
|
||||
$nbFlottes = 0;
|
||||
if (SURFACE == "asteroide")
|
||||
{
|
||||
if ($planete->batiments[2] == 1)
|
||||
$slots = 1;
|
||||
elseif ($planete->batiments[2] == 2)
|
||||
$slots = 2;
|
||||
elseif ($planete->batiments[2] == 3)
|
||||
$slots = 4;
|
||||
elseif ($planete->batiments[2] == 4)
|
||||
$slots = 7;
|
||||
elseif ($planete->batiments[2] == 5)
|
||||
$slots = 14;
|
||||
else
|
||||
$slots = 0;
|
||||
}
|
||||
if (SURFACE == "asteroide") {
|
||||
if ($planete->batiments[2] == 1) {
|
||||
$slots = 1;
|
||||
} elseif ($planete->batiments[2] == 2) {
|
||||
$slots = 2;
|
||||
} elseif ($planete->batiments[2] == 3) {
|
||||
$slots = 4;
|
||||
} elseif ($planete->batiments[2] == 4) {
|
||||
$slots = 7;
|
||||
} elseif ($planete->batiments[2] == 5) {
|
||||
$slots = 14;
|
||||
} else {
|
||||
$slots = 0;
|
||||
}
|
||||
|
||||
$slots -= $nbFlottes;
|
||||
}
|
||||
else
|
||||
$slots = count($queryPlanetes)-$nbFlottes;
|
||||
$slots -= $nbFlottes;
|
||||
} else {
|
||||
$slots = count($queryPlanetes)-$nbFlottes;
|
||||
}
|
||||
|
||||
if ($slots > 0)
|
||||
//$template->assign('action', '<input class="submit" name="envoie" type="submit" value="Envoyer flotte" /> <input class="submit" name="groupe" type="submit" value="Envoye groupé" />');
|
||||
$template->assign('action', '<input class="submit" name="envoie" type="submit" value="Ok" />');
|
||||
else
|
||||
$template->assign('action', '<span class="lack">Nombre de flottes maximum simultanées atteint</span>');
|
||||
if ($slots > 0) {
|
||||
//$template->assign('action', '<input class="submit" name="envoie" type="submit" value="Envoyer flotte" /> <input class="submit" name="groupe" type="submit" value="Envoye groupé" />');
|
||||
$template->assign('action', '<input class="submit" name="envoie" type="submit" value="Ok" />');
|
||||
} else {
|
||||
$template->assign('action', '<span class="lack">Nombre de flottes maximum simultanées atteint</span>');
|
||||
}
|
||||
|
||||
$template->assign('nbflotte', $nbFlottes);
|
||||
$template->assign('nbflottemax', $slots + $nbFlottes);
|
||||
$template->assign('nbflotte', $nbFlottes);
|
||||
$template->assign('nbflottemax', $slots + $nbFlottes);
|
||||
|
||||
//Affichage des flottes en préparation
|
||||
if (isset($SESS->values["prepFlottes"]))
|
||||
$template->assign('flottesEP', $SESS->values["prepFlottes"]);
|
||||
//Affichage des flottes en préparation
|
||||
if (isset($SESS->values["prepFlottes"])) {
|
||||
$template->assign('flottesEP', $SESS->values["prepFlottes"]);
|
||||
}
|
||||
|
||||
unset($nbFlottes, $slots, $flottes, $flotte, $key);
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue