Version 1.0a

This commit is contained in:
nemunaire 2008-11-17 12:00:00 +01:00
commit 6a19363758
908 changed files with 22193 additions and 17408 deletions

View file

@ -3,6 +3,7 @@
* class.combat.php
* -------------------
* begin : Samedi 26 janvier 2008
* update : Samedi 12 mai 2008
* email : nemunaire@gmail.com
*
*
@ -16,43 +17,95 @@ class Combat {
var $Ntour = 0;
var $ATtactique = 0;
var $ENtactique = 0;
var $timestamp = 0;
var $vaisContenu = 0;
var $vaisContenuM = 0;
var $vaisContenuC = 0;
var $vaisContenuH = 0;
var $debriM = 0;
var $debriC = 0;
/**
* Constructeur
* @param array $flotteAT tableau SQL des vaisseaux envoyés par l'attaquant
* @param array $flotteEN tableau SQL de la planète du défenseur
* @param array $defEN tableau SQL de la planète du défenseur
* @param array $flotteAT tableau SQL des vaisseaux envoyés par l'attaquant
* @param array $flotteEN tableau SQL de la planète du défenseur
* @param array $defEN tableau SQL de la planète du défenseur
*
* @return void
* @access public
*/
function Combat($flotteAT, $flotteEN, $defEN) {
include('includes/vars.php');
//Génération des vaisseaux attaquants
//Génération des vaisseaux attaquants
for ($i=1 ; $i<=12 ; $i++) {
if ($flotteAT['vaisseau'.$i] >= 1) {
$this->ATvais[] = array($i, $flotteAT['vaisseau'.$i], array(array($nomvais_pv[$i-1], $flotteAT['vaisseau'.$i])), array(array($nomvais_bc[$i-1], $flotteAT['vaisseau'.$i])));
if ($flotteAT['vaisseau_'.$i] >= 1) {
//Création des groupes
$nbvais = $flotteAT['vaisseau_'.$i];
$nbgroupes = floor(sqrt(ceil($nbvais/10)));
$nbvaispgroupe = floor($nbvais/$nbgroupes);
$nbrest = $nbvais - $nbvaispgroupe * $nbgroupes;
if (isset($groupe)) unset($groupe);
$groupe = array();
for ($j=0 ; $j < $nbgroupes ; $j++) {
if ($j == $nbgroupes) $nbvaispgroupe += $nbrest;
$groupe[] = array($nbvaispgroupe, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
}
$this->ATvais[] = array($i, $flotteAT['vaisseau_'.$i], $nbgroupes, $groupe);
}
}
//Génération des vaisseaux défenseurs
//Définition d'autres variables de la classe concernant la flotte
$this->refflotte = $flotteAT['id'];
$this->vaisContenu = $flotteAT['contenu_max'];
$this->vaisContenuM = $flotteAT['contenu_metal'];
$this->vaisContenuC = $flotteAT['contenu_cristal'];
$this->vaisContenuH = $flotteAT['contenu_hydrogene'];
$this->timestamp = $flotteAT['start_time'] + $flotteAT['end_time'];
//Génération des vaisseaux défenseurs
for ($i=1 ; $i<=12 ; $i++) {
if ($flotteEN['vaisseau_'.$i] >= 1) {
$this->ENvais[] = array($i, $flotteEN['vaisseau_'.$i], array(array($nomvais_pv[$i-1], $flotteEN['vaisseau_'.$i])), array(array($nomvais_bc[$i-1], $flotteEN['vaisseau_'.$i])));
//Création des groupes
$nbvais = $flotteEN['vaisseau_'.$i];
$nbgroupes = floor(sqrt(ceil($nbvais/10)));
$nbvaispgroupe = floor($nbvais/$nbgroupes);
$nbrest = $nbvais - $nbvaispgroupe * $nbgroupes;
if (isset($groupe)) unset($groupe);
$groupe = array();
for ($j=0 ; $j < $nbgroupes ; $j++) {
if ($j == $nbgroupes) $nbvaispgroupe += $nbrest;
$groupe[] = array($nbvaispgroupe, $nomvais_bc[$i-1], $nomvais_pv[$i-1]);
}
$this->ENvais[] = array($i, $flotteEN['vaisseau_'.$i], $nbgroupes, $groupe);
}
}
//Génération des défenses défenseurs
//Génération des défenses défenseurs
for ($i=1 ; $i<=5 ; $i++) {
if ($defEN['def_'.$i] >= 1) {
$this->ENdef[] = array($i, $defEN['def_'.$i], array(array($nomvais_pv[$i-1], $defEN['def_'.$i])), array(array($nomvais_bc[$i-1], $defEN['def_'.$i])));
//Création des groupes
$nbvais = $defEN['def_'.$i];
$nbgroupes = floor(sqrt(ceil($nbvais/10)));
$nbvaispgroupe = floor($nbvais/$nbgroupes);
$nbrest = $nbvais - $nbvaispgroupe * $nbgroupes;
if (isset($groupe)) unset($groupe);
$groupe = array();
for ($j=0 ; $j < $nbgroupes ; $j++) {
if ($j == $nbgroupes) $nbvaispgroupe += $nbrest;
$groupe[] = array($nbvaispgroupe, $defense_bc[$i-1], $defense_pv[$i-1]);
}
$this->ENdef[] = array($i, $defEN['def_'.$i], $nbgroupes, $groupe);
}
}
}
/**
* Change la tactique de l'attaquant
* @param int $tactique numéro de la tactique choisie
* @param int $tactique numéro de la tactique choisie
*
* @return void
* @access public
@ -62,8 +115,8 @@ class Combat {
}
/**
* Change la tactique du défenseur
* @param int $tactique numéro de la tactique choisie
* Change la tactique du défenseur
* @param int $tactique numéro de la tactique choisie
*
* @return void
* @access public
@ -73,12 +126,12 @@ class Combat {
}
/**
* Régénére les boucliers
* @param int $pourcentage pourcentage de régénération
* @param bool $attaquant régénére le bouclier de l'attaquant si true, sinon régénrére celui du défenseur
* @param bool $retour si true, renvoie true ou false si !le pourcentage a été consommé ou non, si false, retrourne ne nombre de pourcentage restant
* Régénére les boucliers
* @param int $pourcentage pourcentage de régénération
* @param bool $attaquant régénére le bouclier de l'attaquant si true, sinon régénrére celui du défenseur
* @param bool $retour si true, renvoie true ou false si !le pourcentage a été consommé ou non, si false, retrourne ne nombre de pourcentage restant
*
* @return float pourcentage non utilisé
* @return float pourcentage non utilisé
* @access public
*/
function regenereBC($pourcentage, $attaquant, $retour = false) {
@ -91,22 +144,23 @@ class Combat {
$type = $this->ATvais[$i][0]-1;
$maxbc = $nomvais_bc[$type];
$ajout = $maxbc*$pourcentage/100;
$norm += $maxbc * $this->ATvais[$i][1];
$cntbc = count($this->ATvais[$i][3]);
for ($j=0 ; $j<$cntbc ; $j++) {
if ($this->ATvais[$i][3][$j][0] < $maxbc) {
$this->ATvais[$i][3][$j][0] += $ajout;
$norm += $maxbc * $this->ATvais[$i][3][$j][0];
if ($this->ATvais[$i][3][$j][1] < $maxbc) {
$this->ATvais[$i][3][$j][1] += $ajout;
}
else $enplus += $ajout * $this->ATvais[$i][3][$j][1];
if ($this->ATvais[$i][3][$j][0] > $maxbc) {
$enplus += ($this->ATvais[$i][3][$j][0] - $maxbc)*$this->ATvais[$i][3][$j][1];
$this->ATvais[$i][3][$j][0] = $maxbc;
else $enplus += $ajout * $this->ATvais[$i][3][$j][0];
if ($this->ATvais[$i][3][$j][1] > $maxbc) {
$enplus += ($this->ATvais[$i][3][$j][1] - $maxbc)*$this->ATvais[$i][3][$j][0];
$this->ATvais[$i][3][$j][1] = $maxbc;
}
}
}
if ($retour) {
if($enplus/$norm == 1) return true;
if($enplus/$norm == 1) return $pourcentage;
else return false;
}
else return $enplus/$norm;
@ -119,23 +173,23 @@ class Combat {
$type = $this->ENvais[$i][0]-1;
$maxbc = $nomvais_bc[$type];
$ajout = $maxbc*$pourcentage/100;
$norm += $maxbc * $this->ENvais[$i][1];
$cntbc = count($this->ENvais[$i][3]);
for ($j=0 ; $j<$cntbc ; $j++) {
if ($this->ENvais[$i][3][$j][0] < $maxbc) {
$this->ENvais[$i][3][$j][0] += $ajout;
$norm += $maxbc * $this->ENvais[$i][3][$j][0];
if ($this->ENvais[$i][3][$j][1] < $maxbc) {
$this->ENvais[$i][3][$j][1] += $ajout;
}
else $enplus += $ajout * $this->ENvais[$i][3][$j][1];
if ($this->ENvais[$i][3][$j][0] > $maxbc) {
$enplus += ($this->ENvais[$i][3][$j][0] - $maxbc)*$this->ENvais[$i][3][$j][1];
$this->ENvais[$i][3][$j][0] = $maxbc;
else $enplus += $ajout * $this->ENvais[$i][3][$j][0];
if ($this->ENvais[$i][3][$j][1] > $maxbc) {
$enplus += ($this->ENvais[$i][3][$j][1] - $maxbc)*$this->ENvais[$i][3][$j][0];
$this->ENvais[$i][3][$j][1] = $maxbc;
}
}
}
$return = $enplus/$norm;
//Défenses
//Défenses
$count = count($this->ENdef);
$enplus = 0;
$norm = 0;
@ -143,29 +197,33 @@ class Combat {
$type = $this->ENdef[$i][0]-1;
$maxbc = $defense_bc[$type];
$ajout = $maxbc*$pourcentage/100;
$norm += $maxbc * $this->ENdef[$i][1];
$cntbc = count($this->ENdef[$i][3]);
for ($j=0 ; $j<$cntbc ; $j++) {
if ($this->ENdef[$i][3][$j][0] < $maxbc) {
$this->ENdef[$i][3][$j][0] += $ajout;
$norm += $maxbc * $this->ENdef[$i][3][$j][0];
if ($this->ENdef[$i][3][$j][1] < $maxbc) {
$this->ENdef[$i][3][$j][1] += $ajout;
}
else $enplus += $ajout * $this->ENdef[$i][3][$j][1];
if ($this->ENdef[$i][3][$j][0] > $maxbc) {
$enplus += ($this->ENdef[$i][3][$j][0] - $maxbc)*$this->ENdef[$i][3][$j][1];
$this->ENdef[$i][3][$j][0] = $maxbc;
else $enplus += $ajout * $this->ENdef[$i][3][$j][0];
if ($this->ENdef[$i][3][$j][1] > $maxbc) {
$enplus += ($this->ENdef[$i][3][$j][1] - $maxbc)*$this->ENdef[$i][3][$j][0];
$this->ENdef[$i][3][$j][1] = $maxbc;
}
}
}
$return += $enplus/$norm;
return $return/2;
if ($retour) {
if($enplus/$norm == 1) return $pourcentage;
else return false;
}
else return $return/2;
}
}
/**
* Calcul la puissance d'attaque disponible
* @param int $pourcentage pourcentage de régénération
* @param bool $attaquant calcul les points de l'attaquant si true, sinon calcul pour le défenseur
* @param int $pourcentage pourcentage de régénération
* @param bool $attaquant calcul les points de l'attaquant si true, sinon calcul pour le défenseur
*
* @return int points disponibles
* @access public
@ -189,7 +247,7 @@ class Combat {
$puissance += $maxat * $pourcentage/100 * $this->ENvais[$i][1];
}
//Défenses
//Défenses
$count = count($this->ENdef);
for ($i=0 ; $i<$count ; $i++) {
$maxat = $defense_at[$this->ENdef[$i][0]-1];
@ -202,77 +260,270 @@ class Combat {
/**
* Attaque les vaisseaux adverses
* @param int $points points d'attaque disponible pour l'attaque
* @param bool $attaquant attaque le défenseur si true, sinon attaque l'attaquant
* @param bool $attaquant attaque le défenseur si true, sinon attaque l'attaquant
*
* @return void
* @access public
*/
function attaquerVais($points, $attaquant) {
include('includes/vars.php');
if ($attaquant) {
while($points > 0) {
// Calcul du nombre de vaisseaux et défenses à attaquer
// Calcul du nombre de vaisseaux et défenses à attaquer
$nbvais = 0;
$nbgroupes = 0;
$nb = count($this->ENvais);
for ($i=0 ; $i<$nb ; $i++) {
$nbvais += $this->ENvais[$i][1];
$nbgroupes += $this->ENvais[$i][2];
}
$nb = count($this->ENdef);
for ($i=0 ; $i<$nb ; $i++) {
$nbvais += $this->ENdef[$i][1];
$nbgroupes += $this->ENdef[$i][2];
}
//S'il ne reste plus de vaisseaux et de défenses, on arrête la boucle
if ($nbvais < 0 || $points < 0) break;
//S'il ne reste plus de vaisseaux et de défenses, on arrête la boucle
if ($nbvais <= 0 || $nbgroupes <= 0 || $points <= 0) break;
//Calcul du nombre de points qui sera enlevé par vaisseau ou défense
$ppv = $points / $nbvais;
//Calcul du nombre de points qui sera enlevé par vaisseau ou défense
$ppv = $points / $nbgroupes;
$points = 0;
//On lance l'attaque
$nb = count($this->ENvais);
for ($i=0 ; $i<$nb ; $i++) {
$persage = 0; //Initialisation du nombre de point restant pour attaquer les PV
$nbpersage = 0; //Initialisation du nombre de vaisseaux affectuer par le persage
$nbj = count($this->ENvais[$i][3]); //Nombre de vaisseaux dans le groupe
//On lance l'attaque contre les vaisseaux
for ($j=0 ; $j<$nbgroupes ; $j++){
$k = rand(0, count($this->ENvais)-1);
$l = rand(0, count($this->ENvais[$k][3])-1);
//Attaque des boucliers
for ($j=0 ; $j<$nbj ; $j++) {
$this->ENvais[$i][3][$j][0] -= $ppv;
if ($this->ENvais[$i][3][$j][0] <= 0) {
$persage += abs($this->ENvais[$i][3][$j][0]);
$nbpersage += $this->ENvais[$i][3][$j][1];
$this->ENvais[$i][3][$j][0] = 0;
}
}
//Attaque des PV
while($persage > 0) {
$j = count($this->ENvais[$i][2])-1; //Nombre de vaisseaux dans le groupe
if ($this->ENvais[$i][2][$j][0] * $this->ENvais[$i][2][$j][1] < $persage * $nbpersage) { //Si il y a suffisament de point de persage pour détruire tous les vaisseaux de cette ligne
//On efface les vaisseaux du nombre total
$nbvais -= $this->ENvais[$i][2][$j][1];
$this->ENvais[$i][1] -= $this->ENvais[$i][2][$j][1];
//On efface le groupe
unset($this->ENvais[$i][2][$j]);
//S'il ne reste aucun vaisseaux du type, on le supprime
if ($j == 0 || $this->ENvais[$i][1] == 0) {
unset($this->ENvais[$i]);
$persage = 0;
$this->ENvais[$k][3][$l][1] -= $ppv;
if ($this->ENvais[$k][3][$l][1] < 0) {
$this->ENvais[$k][3][$l][2] -= abs($this->ENvais[$k][3][$l][1]);
$this->ENvais[$k][3][$l][1] = 0;
if ($this->ENvais[$k][3][$l][2] <= 0) {
$this->ENvais[$k][1] -= $this->ENvais[$k][3][$l][0];
$this->ENvais[$k][2] --;
unset($this->ENvais[$k][3][$l]);
$this->ENvais[$k][3] = array_merge($this->ENvais[$k][3]);
if (!count($this->ENvais[$k][3])) {
unset($this->ENvais[$k]);
$this->ENvais[$k] = array_merge($this->ENvais[$k]);
}
}
else { //Attaque vaisseau par vaisseau dans le groupe
$nbmod = floor(($this->ENvais[$i][2][$j][0] * $this->ENvais[$i][2][$j][1])/($persage * $nbpersage));
$this->ENvais[$i][1] -= $nbmod;
$nbvais -= $nbmod;
}
}
//On lance l'attaque contre les défenses
for ($j=0 ; $j<$nbgroupes ; $j++){
$k = rand(0, count($this->ENdef)-1);
$l = rand(0, count($this->ENdef[$k][3])-1);
$this->ENdef[$k][3][$l][1] -= $ppv;
if ($this->ENdef[$k][3][$l][1] < 0) {
$this->ENdef[$k][3][$l][2] -= abs($this->ENdef[$k][3][$l][1]);
$this->ENdef[$k][3][$l][1] = 0;
if ($this->ENdef[$k][3][$l][2] <= 0) {
$this->ENdef[$k][1] -= $this->ENdef[$k][3][$l][0];
$this->ENdef[$k][2] --;
unset($this->ENdef[$k][3][$l]);
$this->ENdef[$k][3] = array_merge($this->ENdef[$k][3]);
if (!count($this->ENdef[$k][3])) {
unset($this->ENdef[$k]);
$this->ENdef[$k] = array_merge($this->ENdef[$k]);
}
}
}
}
}
return count($this->ENvais) + count($this->ENdef);
}
else {
while($points > 0) {
// Calcul du nombre de vaisseaux et défenses à attaquer
$nbvais = 0;
$nbgroupes = 0;
$nb = count($this->ATvais);
for ($i=0 ; $i<$nb ; $i++) {
$nbvais += $this->ATvais[$i][1];
$nbgroupes += $this->ATvais[$i][2];
}
//S'il ne reste plus de vaisseaux et de défenses, on arrête la boucle
if ($nbvais <= 0 || $nbgroupes <= 0 || $points <= 0) break;
//Calcul du nombre de points qui sera enlevé par vaisseau ou défense
$ppv = $points / $nbvais;
$points = 0;
//On lance l'attaque
for ($j=0 ; $j<$nbgroupes ; $j++){
$k = rand(0, count($this->ENdef)-1);
$l = rand(0, count($this->ENdef[$k][3])-1);
$this->ENdef[$k][3][$l][1] -= $ppv;
if ($this->ENdef[$k][3][$l][1] < 0) {
$this->ENdef[$k][3][$l][2] -= abs($this->ENdef[$k][3][$l][1]);
$this->ENdef[$k][3][$l][1] = 0;
if ($this->ENdef[$k][3][$l][2] <= 0) {
$this->ENdef[$k][1] -= $this->ENdef[$k][3][$l][0];
$this->ENdef[$k][2] --;
unset($this->ENdef[$k][3][$l]);
$this->ENdef[$k][3] = array_merge($this->ENdef[$k][3]);
if (!count($this->ENdef[$k][3])) {
unset($this->ENdef[$k]);
$this->ENdef[$k] = array_merge($this->ENdef[$k]);
}
}
}
}
}
return count($this->ATvais);
}
}
function exportAT($pillage = false){
include('includes/vars.php');
$nb = count($this->ATvais);
$nbvais = 0; $vaisContenu = 0; $vaisseau_1 = 0; $vaisseau_2 = 0; $vaisseau_3 = 0; $vaisseau_4 = 0; $vaisseau_5 = 0; $vaisseau_6 = 0; $vaisseau_7 = 0; $vaisseau_8 = 0; $vaisseau_9 = 0; $vaisseau_10 = 0; $vaisseau_11 = 0; $vaisseau_12 = 0;
for($i=0 ; $i<$nb ; $i++) {
${'vaisseau_'.$this->ATvais[$i][0]} += $this->ATvais[$i][1];
$nbvais += $this->ATvais[$i][1];
$this->vaisContenu += $nomvais_rs[$this->ATvais[$i][0]-1];
}
$sommeCont = $this->vaisContenuM + $this->vaisContenuC + $this->vaisContenuH;
if ($sommeCont > $this->vaisContenu) {
$retirer = $sommeCont/$this->vaisContenu;
$this->vaisContenuM = floor($this->vaisContenuM/$retirer);
$this->vaisContenuC = floor($this->vaisContenuC/$retirer);
$this->vaisContenuH = floor($this->vaisContenuH/$retirer);
}
if ($pillage) {
$req = mysql_query("SELECT * FROM flottes WHERE `id` = '".$this->refflotte."'");
$resultat = mysql_fetch_array($req);
$reqDef = mysql_query("SELECT * FROM `planete` WHERE `galaxie` = '".$resultat['end_galaxie']."' AND `ss` = '".$resultat['end_ss']."' AND `position` = '".$resultat['end_position']."'") or die ("erreur sql ".mysql_error());
$resultatDef = mysql_fetch_array($reqDef);
$ressplus = pillage($resultatDef['metal'], $resultatDef['cristal'], $resultatDef['hydrogene'], $this->vaisContenu - $this->vaisContenuM - $this->vaisContenuC - $this->vaisContenuH);
$this->vaisContenuM += $ressplus[0];
$this->vaisContenuC += $ressplus[1];
$this->vaisContenuH += $ressplus[2];
}
return '`nb_vais` = \''.$nbvais.'\', `contenu_max` = \''.$this->vaisContenu.'\', `contenu_metal` = \''.$this->vaisContenuM.'\', `contenu_cristal` = \''.$this->vaisContenuC.'\', `contenu_hydrogene` = \''.$this->vaisContenuH.'\', `vaisseau_1` = \''.$vaisseau_1.'\', `vaisseau_2` = \''.$vaisseau_2.'\', `vaisseau_3` = \''.$vaisseau_3.'\', `vaisseau_4` = \''.$vaisseau_4.'\', `vaisseau_5` = \''.$vaisseau_5.'\', `vaisseau_6` = \''.$vaisseau_6.'\', `vaisseau_7` = \''.$vaisseau_7.'\', `vaisseau_8` = \''.$vaisseau_8.'\', `vaisseau_9` = \''.$vaisseau_9.'\', `vaisseau_10` = \''.$vaisseau_10.'\', `vaisseau_11` = \''.$vaisseau_11.'\', `vaisseau_12` = \''.$vaisseau_12.'\'';
}
function exportEN(){
$nb = count($this->ENvais);
$vaisseau_1 = 0; $vaisseau_2 = 0; $vaisseau_3 = 0; $vaisseau_4 = 0; $vaisseau_5 = 0; $vaisseau_6 = 0; $vaisseau_7 = 0; $vaisseau_8 = 0; $vaisseau_9 = 0; $vaisseau_10 = 0; $vaisseau_11 = 0; $vaisseau_12 = 0;
for($i=0 ; $i<$nb ; $i++) {
${'vaisseau_'.$this->ENvais[$i][0]} += $this->ENvais[$i][1];
}
$nb = count($this->ENdef);
$def_1 = 0; $def_2 = 0; $def_3 = 0; $def_4 = 0; $def_5 = 0;
for($i=0 ; $i<$nb ; $i++) {
${'def_'.$this->ENdef[$i][0]} += $this->ENdef[$i][1];
}
return '`vaisseau_1` = \''.$vaisseau_1.'\', `vaisseau_2` = \''.$vaisseau_2.'\', `vaisseau_3` = \''.$vaisseau_3.'\', `vaisseau_4` = \''.$vaisseau_4.'\', `vaisseau_5` = \''.$vaisseau_5.'\', `vaisseau_6` = \''.$vaisseau_6.'\', `vaisseau_7` = \''.$vaisseau_7.'\', `vaisseau_8` = \''.$vaisseau_8.'\', `vaisseau_9` = \''.$vaisseau_9.'\', `vaisseau_10` = \''.$vaisseau_10.'\', `vaisseau_11` = \''.$vaisseau_11.'\', `vaisseau_12` = \''.$vaisseau_12.'\', `def_1` = \''.$def_1.'\', `def_2` = \''.$def_2.'\', `def_3` = \''.$def_3.'\', `def_4` = \''.$def_4.'\', `def_5` = \''.$def_5.'\'';
}
function genRapport($fin, $ATgagnant = false){
$req = mysql_query("SELECT * FROM `flottes` WHERE `id` = '".$this->refflotte."'");
$resultat = mysql_fetch_array($req);
$reqDef = mysql_query("SELECT `id_user` FROM `planete` WHERE `galaxie` = '".$resultat['end_galaxie']."' AND `ss` = '".$resultat['end_ss']."' AND `position` = '".$resultat['end_position']."'") or die ("erreur sql ".mysql_error());
$resultatDef = mysql_fetch_array($reqDef);
if ($this->Ntour == 0) {
$rapportAT = '[b]Le combat contre '.trouvNom($resultatDef['id_user']).' est engagé ![/b]
';
$rapportEN = '[b]Un combat est engagé contre '.trouvNom($resultatDef['id_user']).' ![/b]
';
}
elseif ($fin) {
$rapportAT = '[b]Le combat contre '.trouvNom($resultatDef['id_user']).' est terminé ![/b]
';
$rapportEN = '[b]Le combat contre '.trouvNom($resultatDef['id_user']).' est terminé ![/b]
';
}
else {
$rapportAT = '[b]Suite du combat contre '.trouvNom($resultatDef['id_user']).' ![/b]
';
$rapportEN = '[b]Suite du combat contre '.trouvNom($resultatDef['id_user']).' ![/b]
';
}
$rapportAT .= 'Tactique lors de ce tour : '.txtTactique($this->ATtactique).'.
Lieux : ['.$resultat['end_galaxie'].':'.$resultat['end_ss'].':'.$resultat['end_position'].'] METTRE UN LIEN
Vaisseaux au début de notre côté :
Array
Vaisseaux adverse au début :
Array
Défenses adverse au début :
Array
Etat de notre flotte à la fin de ce tour :
Grand Array ^^
Etat de la flotte adverse à la fin de ce tour :
Grand Array ^^
';
$rapportEN .= 'Tactique lors de ce tour : '.txtTactique($this->ENtactique).'.
Lieux : ['.$resultat['end_galaxie'].':'.$resultat['end_ss'].':'.$resultat['end_position'].'] METTRE UN LIEN
Vaisseaux au début de notre côté :
Array
Défenses au début de notre côté :
Array
Vaisseaux adverse au début :
Array
Etat de notre flotte à la fin de ce tour :
Grand Array ^^
Etat de la flotte adverse à la fin de ce tour :
Grand Array ^^
';
if (floor($this->Ntour/2) == $this->Ntour/2 && !$fin) {
$rapportAT .= 'Vous pouvez profiter du temps de régénération des boucliers et des armes pour envoyer un nouvel ordre de tactique : Cliquez ici !
La prochaine attaque est prévue à '.date('/dm/ H:i:s', $this->timestamp+600);
$rapportEN .= 'Vous pouvez profiter du temps de régénération des boucliers et des armes pour envoyer un nouvel ordre de tactique : Cliquez ici !
La prochaine attaque est prévue à '.date('/dm/ H:i:s', $this->timestamp+300);
}
elseif (!$fin) {
$rapportAT .= 'Vous pouvez profiter du temps de régénération des boucliers et des armes pour envoyer un nouvel ordre de tactique : Cliquez ici !
La prochaine attaque est prévue à '.date('/dm/ H:i:s', $this->timestamp+300);
$rapportEN .= 'Vous pouvez profiter du temps de régénération des boucliers et des armes pour envoyer un nouvel ordre de tactique : Cliquez ici !
La prochaine attaque est prévue à '.date('/dm/ H:i:s', $this->timestamp+600);
}
elseif ($fin && $ATgagnant) {
$rapportAT .= 'Nous avons gagné le combat !
Nous repartons avec plein de choses.';
$rapportEN .= 'Nous n\'avons pas pu repousser l\'envahisseur qui repart avec plein de chose.';
}
elseif ($fin && !$ATgagnant) {
$rapportAT .= 'Nous avons perdu le combat !';
$rapportEN .= 'Nous avons pu repousser l\'envahisseur qui repart sans rien.';
}
return array(mysql_real_escape_string($rapportAT), mysql_real_escape_string($rapportEN), $resultat['id_user'], $resultatDef['id_user']);
}
}
?>

90
Class/class.gerefile.php Normal file
View file

@ -0,0 +1,90 @@
<?php
class gererFile {
var $file = array();
var $chaine = false;
var $timestamp = 0;
var $limite = 0;
function gererFile($limite) {
$this->limite = $limite;
}
function addObjet($objet,$nombre,$temps) {
$nbF = count($this->file);
if ($nbF >= $this->limite) return false;
$this->chaine = false;
if($nbF == 0) $this->timestamp = time();
if($nbF > 0 && $this->file[$nbF-1][0] == $objet) $this->file[$nbF-1][1] += $nombre;
else $this->file[] = array($objet, $nombre, $temps);
return true;
}
function existe($objet) {
$this->file = array_merge($this->file);
$nbF=count($this->file);
for ($i=0 ; $i<$nbF ; $i++){
if($objet == $this->file[$i][0]) return true;
}
return false;
}
function delobjet($objet, $nombre=1) {
$this->file = array_merge($this->file);
for($i=count($this->file)-1 ; $i>=0 ; $i--) {
if($this->file[$i][0] == $objet){
$nombre=min($nombre, $this->file[$i][1]);
$this->file[$i][1] -= $nombre;
if($this->file[$i][1]<=0) {
unset($this->file[$i]);
$this->file = array_merge($this->file);
}
}
}
return $nombre;
}
function pret() {
$out = array();
$nbF = count($this->file);
if ($nbF == 1 && $this->chaine) {
$nb = floor((time()-$this->timestamp)/$this->file[0][2]);
if ($nb > 0) {
$out[] = array($this->file[0][0], $nb);
$this->timestamp += $nb * $this->file[0][2];
}
}
elseif ($nbF != 0) {
$this->file = array_merge($this->file);
for($i=0 ; $i<$nbF ; $i++){
$tps = time() - $this->timestamp;
if($this->file[$i][1] * $this->file[$i][2] < $tps) {
$out[] = array($this->file[$i][0], $this->file[$i][1]);
$this->timestamp += $this->file[$i][1] * $this->file[$i][2];
unset($this->file[$i]);
}
elseif ($this->file[$i][2] < $tps) {
for($j=0 ; $j*$this->file[$i][2]<$tps ; $j++) {}
$j--;
$out[] = array($this->file[$i][0], $j);
$this->timestamp += $j * $this->file[$i][2];
$this->file[$i][1] -= $j;
break;
}
else {
return $out;
}
}
$this->file = array_merge($this->file);
}
return $out;
}
function export(){
$nbF = count($this->file);
$out = '';
for($i=0;$i<$nbF;$i++){
$out .= implode(',',$this->file[$i]).';';
}
return $out;
}
}

114
Class/class.rapport.php Normal file
View file

@ -0,0 +1,114 @@
<?php
/**
* Class Rapport
*
* Génération et envoie de rapport de mission de flotte
*
*/
class Rapport{
var $type = 0;
var $var = array();
var $utilA = 0;
var $utilB = 0;
var $timestamp = 0;
/**
* Constructor
* @access protected
*/
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;
}
function send(){
if ($this->type == '1') $this->sendCombat();
elseif ($this->type == '2') $this->sendTransport();
elseif ($this->type == '3') $this->sendColonisation();
elseif ($this->type == '4') $this->sendRecyclage();
elseif ($this->type == '5') $this->sendEspionnage();
elseif ($this->type == '6') $this->sendAlliance();
}
function sendEspionnage(){
include_once('includes/function.php');
$titreA = 'Rapport d\'espionnage de '.$this->var[0]['nom_planete'].' ['.$this->var[0]['galaxie'].':'.$this->var[0]['ss'].':'.$this->var[0]['position'].']';
$rapportA = '<b>Espionnage de '.trouvNom($this->utilB).' sur '.$this->var[0]['nom_planete'].'['.$this->var[0]['galaxie'].':'.$this->var[0]['ss'].':'.$this->var[0]['position'].']</b><br /><br />';
$race = trouvInfo($this->utilB, 'race');
$auth_level = 0;
include('includes/noms.php');
include('includes/vars.php');
if (isset($this->var[1]) && $this->var[1] == false) $rapportA .= '<i>Nos sondes n\'ont pas pu récolter d\'information sur cette planète.</i>';
else {
$rapportA .= '<table style="margin: auto;"><tr><th colspan="2">Ressources sur la planète :</th></tr><tr><td>Métal :</td><td>'.$this->var[0]['metal'].'</td></tr><tr><td>Cristal :</td><td>'.$this->var[0]['cristal'].'</td></tr><tr><td>Hydrogène :</td><td>'.$this->var[0]['hydrogene'].'</td></tr></table><br />';
if (isset($this->var[1]) && $this->var[1] == true) {
$rapportA .= '<table style="margin: auto;"><tr><th>Nombre</th><th>Vaisseaux</th></tr>';
$nbvais = count($nomvaisn);
for($i=1 ; $i<$nbvais ; $i++) {
if ($this->var[0]['vaisseau_'.$i] >= 1) $rapportA .= '<tr><td>'.$this->var[0]['vaisseau_'.$i].'</td><td>'.$nomvaisn[$i-1].'</td></tr>';
}
$rapportA .= '</table><br />';
}
if (isset($this->var[2]) && $this->var[2] == true) {
$rapportA .= '<table style="margin: auto;"><tr><th>Nombre</th><th>Défenses</th></tr>';
$nbdef = count($nomterrn) - 7;
for($i=1 ; $i<$nbdef ; $i++) {
if ($this->var[0]['def_'.$i] >= 1) $rapportA .= '<tr><td>'.$this->var[0]['def_'.$i].'</td><td>'.$nomterrn[$i+7].'</td></tr>';
}
$rapportA .= '</table><br />';
}
if (isset($this->var[3]) && $this->var[3] == true) {
$rapportA .= '<table style="margin: auto;"><tr><th>Niveau</th><th>Batiment</th></tr>';
$nbbat = count($batiment);
for($i=1 ; $i<$nbbat ; $i++) {
if ($this->var[0][$batimentVAR[$i-1]] >= 1) $rapportA .= '<tr><td>'.$this->var[0][$batimentVAR[$i-1]].'</td><td>'.$batiment[$i-1].'</td></tr>';
}
$rapportA .= '</table><br />';
}
if (isset($this->var[4]) && is_array($this->var[4])) {
$rapportA .= '<table style="margin: auto;"><tr><th>Niveau</th><th>Technologie</th></tr>';
$nbtec = count($technolo);
for($i=1 ; $i<$nbtec ; $i++) {
if ($this->var[4][$technoloVAR[$i-1]] >= 1) $rapportA .= '<tr><td>'.$this->var[4][$technoloVAR[$i-1]].'</td><td>'.$technolo[$i-1].'</td></tr>';
}
$rapportA .= '</table><br />';
}
if (isset($this->var[5]) && is_array($this->var[5])) {
//ISOLEMENT
}
}
$titreB = 'Rapport de contre-espionnage';
$rapportB = 'Nous vennons 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 '.trouvNom($this->utilA);
$titreA = mysql_real_escape_string($titreA);
$rapportA = mysql_real_escape_string($rapportA);
$titreB = mysql_real_escape_string($titreB);
$rapportB = mysql_real_escape_string($rapportB);
$temps = $this->timestamp;
mysql_query("INSERT INTO mail VALUES('', '1', '".trouvNom($this->utilA)."', '', '$titreA', '$rapportA', '$temps')");
mysql_query("INSERT INTO mail VALUES('', '1', '".trouvNom($this->utilB)."', '', '$titreB', '$rapportB', '$temps')");
}
function sendAlliance(){
include_once('includes/function.php');
$titreA = 'Déclaration officielle de votre alliance !';
$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 randant sur la page Alliance.';
$titreA = mysql_real_escape_string($titreA);
$rapportA = mysql_real_escape_string($rapportA);
$temps = $this->timestamp;
mysql_query("INSERT INTO mail VALUES('', '1', '".trouvNom($this->utilA)."', '', '$titreA', '$rapportA', '$temps')");
}
}
?>

View file

@ -28,13 +28,13 @@ class SMTP
* @var int
*/
var $SMTP_PORT = 25;
/**
* SMTP reply line ending
* @var string
*/
var $CRLF = "\r\n";
/**
* Sets whether debugging is turned on
* @var bool
@ -98,7 +98,7 @@ class SMTP
}
#connect to the smtp server
$this->smtp_conn = fsockopen($host, # the host of the server
@$this->smtp_conn = fsockopen($host, # the host of the server
$port, # the port to use
$errno, # error number if any
$errstr, # error message if any
@ -502,7 +502,7 @@ class SMTP
}
$this->helo_rply = $rply;
return true;
}

View file

@ -1,246 +0,0 @@
<?php
/***************************************************************************
* flottes.php
* ----------------
* begin : Samedi 8 décembre 2007
* copyright : (C) 2007 Halo-Battle
* email : nemunaire@gmail.com
*
* $Id: gererFile.php,v 1.0 08/12/2007 19:16:21 $
*
*
***************************************************************************/
/**
* Classe flotte. Par Némunaire de Halo-Battle
*
* Classe permettant la gestion simple d'une flotte
*
*/
class flotte {
var $vaisseaux = array(0,0,0,0,0,0,0,0,0,0,0,0); //Tableau contenant le nombre de vaisseaux par type
var $vaisseaux_fret = array(0,0,0); //Tableau contenant le nombre de ressources transporté par tous les vaisseaux, classé par type
var $fret_max = 0;
var $ressources_max = array(); //Tableau contenant le nombre de ressources maximal de ressoources que peut transporter un vaisseau particulier
var $vitesses_cd = array(); //Tableau des vitesses de courtes distances
var $vitesses_ld = array(); //Tableau des vitesses de longues distances
var $preparation_cd = array(); //Tableau des temps de préparation pour un déplacement courte distance
var $preparation_ld = array(); //Tableau des temps de préparation pour un déplacement longue distance
// var $chauffe_cd = array(); //Tableau des temps de chauffe pour un déplacement courte distance
var $chauffe_ld = array(); //Tableau des temps de chauffe pour un déplacement longue distance
var $vitesse_coefficient = 1;
var $vaisseaux_nombre = 0;
var $position_galaxie = 0;
var $position_systeme = 0;
var $position_planete = 0;
var $position_temps = 0;
var $destination_galaxie = 0;
var $destination_systeme = 0;
var $destination_planete = 0;
var $destination_temps = 0;
/**
* Constructeur. Définition du nombre de vaisseaux au départ
*
*/
function flotte($Tressources_max, $Tvitesses_cd, $Tvitesses_ld, $Tpreparation_cd, $Tpreparation_ld, $Tchauffe_ld, $vaisseau_1 = 0, $vaisseau_2 = 0, $vaisseau_3 = 0, $vaisseau_4 = 0, $vaisseau_5 = 0, $vaisseau_6 = 0, $vaisseau_7 = 0, $vaisseau_8 = 0, $vaisseau_9 = 0, $vaisseau_10 = 0, $vaisseau_11 = 0, $vaisseau_12 = 0) {
$this->vaisseaux[0] = $vaisseau_1; $this->vaisseaux[1] = $vaisseau_2; $this->vaisseaux[2] = $vaisseau_3; $this->vaisseaux[3] = $vaisseau_4; $this->vaisseaux[4] = $vaisseau_5; $this->vaisseaux[5] = $vaisseau_6; $this->vaisseaux[6] = $vaisseau_7; $this->vaisseaux[7] = $vaisseau_8; $this->vaisseaux[8] = $vaisseau_9; $this->vaisseaux[9] = $vaisseau_10; $this->vaisseaux[10] = $vaisseau_11; $this->vaisseaux[11] = $vaisseau_12;
$this->ressources_max = $Tressources_max;
$this->vitesses_cd = $Tvitesses_cd;
$this->vitesses_ld = $Tvitesses_ld;
$this->preparation_cd = $Tpreparation_cd;
$this->preparation_ld = $Tpreparation_ld;
$this->chauffe_ld = $Tchauffe_ld;
$this->calcFret();
}
/**
* Ajouter $nombre vaisseaux de type $type
*
*/
function addVaisseaux($type, $nombre) {
$type--;
$this->vaisseaux[$type] += $nombre;
$this->calcFret();
}
/**
* Supprime $nombre vaisseaux de type $type
*
*/
function delVaisseaux($type, $nombre) {
$type--;
$this->vaisseaux[$type] -= $nombre;
if ($this->vaisseaux[$type] < 0) $this->vaisseaux[$type] = 0;
$this->calcFret();
}
/**
* Vérifie qu'il reste assez de place dans les vaisseaux pour transporter $nombre de ressources du type $type
*
*/
function verifRessources($type, $nombre) {
$type--;
if ($type == 0) {
if ($this->vaisseaux_fret[$type]+$nombre+$this->vaisseaux_fret[$type+1]+$this->vaisseaux_fret[$type+2] > $this->fret_max) return false; // Retourne false si la quantité à ajouter est trop importante
else return true;
}
elseif ($type == 1) {
if ($this->vaisseaux_fret[$type]+$nombre+$this->vaisseaux_fret[$type+1]+$this->vaisseaux_fret[$type-1] > $this->fret_max) return false; // Retourne false si la quantité à ajouter est trop importante
else return true;
}
elseif ($type == 2) {
if ($this->vaisseaux_fret[$type]+$nombre+$this->vaisseaux_fret[$type-1]+$this->vaisseaux_fret[$type-2] > $this->fret_max) return false; // Retourne false si la quantité à ajouter est trop importante
else return true;
}
else return false;
}
/**
* Ajouter $nombre ressources de type $type
*
*/
function addRessources($type, $nombre) {
if ($this->verifRessources($type, $nombre) == true) {
$type--;
$this->vaisseaux_fret[$type] += $nombre;
return true;
}
else return false;
}
/**
* Enlève $nombre ressources de type $type
*
*/
function delRessources($type, $nombre) {
$type--;
$this->vaisseaux_fret[$type] -= $nombre;
if ($this->vaisseaux_fret[$type] < 0) $this->vaisseaux_fret[$type] = 0;
}
/**
* Enlève toutes les ressources de type $type
* Si $type = 0, enlève toutes les ressources
*
*/
function razRessources($type = 0) {
$type--;
if ($type == -1) $this->vaisseaux_fret = array(0,0,0);
else $this->vaisseaux_fret[$type] = 0;
}
/**
* Recalcul le nombre maximum de ressource que peuvent transporter tous les vaisseaux
*
*/
function calcFret() {
$cnt = count($this->vaisseaux);
for ($i=0 ; $i<$cnt ; $i++) {
$this->fret_max += $this->vaisseaux[$i] * $this->ressources_max[$i];
}
}
/**
* Fixer position de départ
*
*/
function fixePosition($galaxie, $systeme, $planete, $time = 0) {
if ($time == 0) $time = time();
$this->position_galaxie = $galaxie;
$this->position_systeme = $systeme;
$this->position_planete = $planete;
$this->position_temps = $time;
}
/**
* Déplacer la flotte vers une destination et calcul du temps de déplacement
*
*/
function deplacerFlotte($galaxie, $systeme, $planete, $coefficient = 1) {
$this->destination_galaxie = $galaxie;
$this->destination_systeme = $systeme;
$this->destination_planete = $planete;
$this->vitesse_coefficient = $coefficient;
$this->calcTemps();
}
/**
* Recalcul le temps de déplacement
*
*/
function calcTemps() {
$start_galaxie = $this->position_galaxie;
$start_ss = $this->position_systeme;
$start_position = $this->position_planete;
$end_galaxie = $this->destination_galaxie;
$end_ss = $this->destination_systeme;
$end_position = $this->destination_planete;
$AvaisType = ''; $AvaisVitesseC = ''; $AvaisVitesseL = ''; $AvaisPrepC = ''; $AvaisChauffe = ''; $AvaisContenu = 0;
for ($i=0 ; $i<=12 ; $i++) {
for ($j = 1; $j <= $this->vaisseaux[$i]; $j++) {
$AvaisType .= ($i).' ';
$AvaisVitesseC .= $this->vitesses_cd[$i].' ';
$AvaisVitesseL .= $this->vitesses_ld[$i].' ';
$AvaisPrepC .= $this->preparation_cd[$i].' ';
$AvaisPrepL .= $this->preparation_ld[$i].' ';
$AvaisChauffe .= $this->chauffe_ld[$i].' ';
}
}
$AvaisType = split(' ', trim($AvaisType)); $AvaisVitesseC = split(' ', trim($AvaisVitesseC)); $AvaisVitesseL = split(' ', trim($AvaisVitesseL)); $AvaisContenu = split(' ', trim($AvaisContenu)); $AvaisPrepC = split(' ', trim($AvaisPrepC)); $AvaisPrepL = split(' ', trim($AvaisPrepL)); $AvaisChauffe = split(' ', trim($AvaisChauffe));
if(min($AvaisVitesseL) != 0) {
$vitesse = min($AvaisVitesseL);
$preparation = max($AvaisPrepL);
$chauffe = max($AvaisChauffe);
}
else {
$vitesse = min($AvaisVitesseC);
$preparation = max($AvaisPrepC);
$chauffe = 0;
}
$this->vaisseaux_nombre = count($AvaisType);
$coefvitesse = $this->vitesse_coefficient;
if ($end_galaxie-$start_galaxie == 0 && $end_ss-$start_ss == 0 && $end_position-$start_position == 0) $temps = 0;
elseif ($end_galaxie-$start_galaxie == 0 && $end_ss-$start_ss == 0 && $chauffe == 0) $temps = $preparation+abs($end_position-$start_position)*$vitesse/12;
elseif ($end_galaxie-$start_galaxie == 0 && $chauffe == 0) $temps = $preparation+abs($end_ss-$start_ss)*$vitesse;
elseif ($chauffe == 0) $temps = $preparation+abs($end_galaxie-$start_galaxie)*$vitesse*300;
elseif ($end_galaxie-$start_galaxie == 0 && $end_ss-$start_ss == 0) $temps = $preparation+abs($end_position-$start_position)*($vitesse*2)/12+$preparation;
/*elseif ($end_galaxie-$start_galaxie == 0 && $end_ss-$start_ss <= $chauffe) $temps = abs($end_ss-$start_ss)*(($vitesse/$chauffe)*($chauffe-abs($end_ss-$start_ss))+$vitesse)+$preparation;
elseif ($end_galaxie-$start_galaxie == 0) $temps = $vitesse*abs($end_ss-$start_ss)+$vitesse*10+$preparation;*/
elseif ($end_galaxie-$start_galaxie == 0) $temps = (abs($end_ss-$start_ss)*(($vitesse/$chauffe)*((abs($chauffe-abs($end_ss-$start_ss))+($chauffe-abs($end_ss-$start_ss)))/2)+$vitesse))+(20-(abs($chauffe-abs($end_ss-$start_ss))+($chauffe-abs($end_ss-$start_ss)))/2)*54+$preparation;
else $temps = (($vitesse/$chauffe)*($chauffe-abs($end_galaxie-$start_galaxie))+$vitesse)*300+108+$preparation;
$this->destination_temps = $temps/$coefvitesse;
return $temps/$coefvitesse;
}
/**
* Calcul la consomation de la flotte
*
*/
function calcConso() {
return intval($this->destination_temps*$this->vaisseaux_nombre/20);
}
}
$race = 'humain';
$auth_level = 7;
include('../languages/fr_FR/noms.php');
$flotte = new flotte($nomvais_rs,$nomvais_dc,$nomvais_lc,$nomvais_pdc,$nomvais_pdl,$nomvais_cdl,0,0,0,4);
$flotte->addRessources(1,11);
$flotte->deplacerFlotte(1,1,1);
$flotte->calcTemps();
print_r ($flotte->calcConso());
?>

View file

@ -1,67 +0,0 @@
<?php
/***************************************************************************
* gererFile.php
* ------------------
* begin : Mardi 27 novembre 2007
* copyright : (C) 2007 Halo-Battle
* email : nemunaire@gmail.com
*
* $Id: gererFile.php,v 1.0 27/11/2007 23:08:30 $
*
*
***************************************************************************/
/**
* Classe gererFile. Par Némunaire de Halo-Battle
*
* Classe permettant la gestion simple d'une file d'attente de batiment
*
*/
class gererFile {
var $fileArray = array();
var $fileTexte = "";
var $tempsArray = array();
var $tempsTexte = "";
/**
* Constructeur. Définition des variables de file d'attente
*
*/
function gererFile($fileArray, $tempsArray) {
$this->fileArray = $fileArray;
$this->fileTexte = implode(' ',$fileArray);
$this->tempsArray = $tempsArray;
$this->tempsTexte = implode(' ',$tempsArray);
}
/**
* Ajouter une action à la file
*
*/
function add($file, $temps) {
$file = trim($file);
$temps = trim($temps);
$this->fileTexte .= ' '.$file;
$this->fileArray = explode(' ',$fileTexte);
$this->tempsTexte .= ' '.$temps;
$this->tempsArray = explode(' ',$tempsTexte);
}
/**
* Supprime une action de la file
*
*/
function delId($id) {
$pos = strpos(implode(',', $fileTec).',', $_GET['tec'].',');
$this->fileTexte .= ' '.$file;
$this->fileArray = explode(' ',$fileTexte);
$this->tempsTexte .= ' '.$temps;
$this->tempsArray = explode(' ',$tempsTexte);
}
}
$gestion = new gererFile(explode(' ','1 2 3 4 5'), explode(' ', '123 456 789 101112 131415 161718'));
$gestion->add('6', '192021');
print $gestion->fileTexte;
?>

View file

@ -1,6 +1,6 @@
<?php
/**
* PHPMailer language file.
* PHPMailer language file.
* English Version
*/
@ -13,11 +13,11 @@ $PHPMAILER_LANG["execute"] = 'Could not execute: ';
$PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
$PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
$PHPMAILER_LANG["recipients_failed"] = 'Erreur SMTP: The following ' .
'recipients failed: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
$PHPMAILER_LANG["data_not_accepted"] = 'Erreur SMTP: Données non acceptées.';
$PHPMAILER_LANG["connect_host"] = 'Erreur SMTP: Impossible de se connecter au serveur de mail.';
$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 : ';
?>

View file

@ -1,355 +0,0 @@
Received: from phpmailer ([127.0.0.1])
by 127.0.0.1 with HTTP (PHPMailer);
Tue, 22 Jan 2008 23:56:42 +0100
Date: Tue, 22 Jan 2008 23:56:42 +0100
Return-Path: nobody@example.com
To: Test User <admin@localhost>
Cc: Carbon User <newuser@localhost>
From: Unit Tester <unit_test@phpmailer.sf.net>
Reply-to: Reply Guy <no_reply@phpmailer.sf.net>
Subject: Unit Test: AltBody + Attachment
Message-ID: <a0169dc7929d1c609a827b4d1a0c3f74@127.0.0.1>
X-Priority: 3
X-Mailer: PHPMailer [version 1.71]
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="b1_a0169dc7929d1c609a827b4d1a0c3f74"
--b1_a0169dc7929d1c609a827b4d1a0c3f74
Content-Type: multipart/alternative;
boundary="b2_a0169dc7929d1c609a827b4d1a0c3f74"
--b2_a0169dc7929d1c609a827b4d1a0c3f74
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
This is the text part of the email.
--b2_a0169dc7929d1c609a827b4d1a0c3f74
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
This is the <b>HTML</b> part of the email.<br/><br/>---------------------<br/>Unit Test Information<br/>---------------------<br/>phpmailer version: 1.71<br/>Content Type: text/html<br/>Host: localhost<br/>Attachments:<br/><ul><li>Name: phpmailer_test.php, Encoding: base64, Type: application/octet-stream<br/></ul><br/>Changes<br/>-------<br/><ul><li>Sender was changed to [nobody@example.com]<br/><li>Mailer was changed to [smtp]<br/></ul><br/><br/>
--b2_a0169dc7929d1c609a827b4d1a0c3f74--
--b1_a0169dc7929d1c609a827b4d1a0c3f74
Content-Type: application/octet-stream; name="test_attach.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test_attach.txt"
PD9waHANCi8qKioqKioqKioqKioqKioqKioqDQogIFVuaXQgVGVzdA0KICBUeXBlOiBwaHBtYWls
ZXIgY2xhc3MNCioqKioqKioqKioqKioqKioqKioqLw0KDQokSU5DTFVERV9ESVIgPSAiLi4vIjsN
Cg0KcmVxdWlyZSgicGhwdW5pdC5waHAiKTsNCnJlcXVpcmUoJElOQ0xVREVfRElSIC4gImNsYXNz
LnBocG1haWxlci5waHAiKTsNCmVycm9yX3JlcG9ydGluZyhFX0FMTCk7DQoNCi8qKg0KICogUGVy
Zm9ybXMgYXV0aGVudGljYXRpb24gdGVzdHMNCiAqLw0KY2xhc3MgcGhwbWFpbGVyVGVzdCBleHRl
bmRzIFRlc3RDYXNlDQp7DQogICAgLyoqDQogICAgICogSG9sZHMgdGhlIGRlZmF1bHQgcGhwbWFp
bGVyIGluc3RhbmNlLg0KICAgICAqIEBwcml2YXRlDQogICAgICogQHR5cGUgb2JqZWN0DQogICAg
ICovDQogICAgdmFyICRNYWlsID0gZmFsc2U7DQoNCiAgICAvKioNCiAgICAgKiBIb2xkcyB0aGUg
U01UUCBtYWlsIGhvc3QuDQogICAgICogQHB1YmxpYw0KICAgICAqIEB0eXBlIHN0cmluZw0KICAg
ICAqLw0KICAgIHZhciAkSG9zdCA9ICIiOw0KDQogICAgLyoqDQogICAgICogSG9sZHMgdGhlIGNo
YW5nZSBsb2cuDQogICAgICogQHByaXZhdGUNCiAgICAgKiBAdHlwZSBzdHJpbmcgYXJyYXkNCiAg
ICAgKi8NCiAgICB2YXIgJENoYW5nZUxvZyA9IGFycmF5KCk7DQoNCiAgICAgLyoqDQogICAgICog
SG9sZHMgdGhlIG5vdGUgbG9nLg0KICAgICAqIEBwcml2YXRlDQogICAgICogQHR5cGUgc3RyaW5n
IGFycmF5DQogICAgICovDQogICAgdmFyICROb3RlTG9nID0gYXJyYXkoKTsNCg0KICAgIC8qKg0K
ICAgICAqIENsYXNzIGNvbnN0dWN0b3IuDQogICAgICovDQogICAgZnVuY3Rpb24gcGhwbWFpbGVy
VGVzdCgkbmFtZSkgew0KICAgICAgICAvKiBtdXN0IGRlZmluZSB0aGlzIGNvbnN0cnVjdG9yICov
DQogICAgICAgICR0aGlzLT5UZXN0Q2FzZSggJG5hbWUgKTsNCiAgICB9DQoNCiAgICAvKioNCiAg
ICAgKiBSdW4gYmVmb3JlIGVhY2ggdGVzdCBpcyBzdGFydGVkLg0KICAgICAqLw0KICAgIGZ1bmN0
aW9uIHNldFVwKCkgew0KICAgICAgICBnbG9iYWwgJGds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JtYWlsX2hvc3QiKTsgPz4iLz4NCjxw
Lz4NCjxpbnB1dCB0eXBlPSJzdWJtaXQiIHZhbHVlPSJSdW4gVGVzdCIvPg0KDQo8L2Zvcm0+DQo8
L2JvZHk+DQo8L2h0bWw+DQo=
--b1_a0169dc7929d1c609a827b4d1a0c3f74--

View file

@ -1,558 +0,0 @@
<?php
/*******************
Unit Test
Type: phpmailer class
********************/
$INCLUDE_DIR = "../";
require("phpunit.php");
require($INCLUDE_DIR . "class.phpmailer.php");
error_reporting(E_ALL);
/**
* Performs authentication tests
*/
class phpmailerTest extends TestCase
{
/**
* Holds the default phpmailer instance.
* @private
* @type object
*/
var $Mail = false;
/**
* Holds the SMTP mail host.
* @public
* @type string
*/
var $Host = "";
/**
* Holds the change log.
* @private
* @type string array
*/
var $ChangeLog = array();
/**
* Holds the note log.
* @private
* @type string array
*/
var $NoteLog = array();
/**
* Class constuctor.
*/
function phpmailerTest($name) {
/* must define this constructor */
$this->TestCase( $name );
}
/**
* Run before each test is started.
*/
function setUp() {
global $global_vars;
global $INCLUDE_DIR;
$this->Mail = new PHPMailer();
$this->Mail->Priority = 3;
$this->Mail->Encoding = "8bit";
$this->Mail->CharSet = "iso-8859-1";
$this->Mail->From = "unit_test@phpmailer.sf.net";
$this->Mail->FromName = "Unit Tester";
$this->Mail->Sender = "";
$this->Mail->Subject = "Unit Test";
$this->Mail->Body = "";
$this->Mail->AltBody = "";
$this->Mail->WordWrap = 0;
$this->Mail->Host = $global_vars["mail_host"];
$this->Mail->Port = 25;
$this->Mail->Helo = "localhost.localdomain";
$this->Mail->SMTPAuth = false;
$this->Mail->Username = "";
$this->Mail->Password = "";
$this->Mail->PluginDir = $INCLUDE_DIR;
$this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy");
$this->Mail->Sender = "nobody@example.com";
if(strlen($this->Mail->Host) > 0)
$this->Mail->Mailer = "smtp";
else
{
$this->Mail->Mailer = "mail";
$this->Sender = "unit_test@phpmailer.sf.net";
}
global $global_vars;
$this->SetAddress($global_vars["mail_to"], "Test User");
if(strlen($global_vars["mail_cc"]) > 0)
$this->SetAddress($global_vars["mail_cc"], "Carbon User", "cc");
}
/**
* Run after each test is completed.
*/
function tearDown() {
// Clean global variables
$this->Mail = NULL;
$this->ChangeLog = array();
$this->NoteLog = array();
}
/**
* Build the body of the message in the appropriate format.
* @private
* @returns void
*/
function BuildBody() {
$this->CheckChanges();
// Determine line endings for message
if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0)
{
$eol = "<br/>";
$bullet = "<li>";
$bullet_start = "<ul>";
$bullet_end = "</ul>";
}
else
{
$eol = "\n";
$bullet = " - ";
$bullet_start = "";
$bullet_end = "";
}
$ReportBody = "";
$ReportBody .= "---------------------" . $eol;
$ReportBody .= "Unit Test Information" . $eol;
$ReportBody .= "---------------------" . $eol;
$ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol;
$ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol;
if(strlen($this->Mail->Host) > 0)
$ReportBody .= "Host: " . $this->Mail->Host . $eol;
// If attachments then create an attachment list
if(count($this->Mail->attachment) > 0)
{
$ReportBody .= "Attachments:" . $eol;
$ReportBody .= $bullet_start;
for($i = 0; $i < count($this->Mail->attachment); $i++)
{
$ReportBody .= $bullet . "Name: " . $this->Mail->attachment[$i][1] . ", ";
$ReportBody .= "Encoding: " . $this->Mail->attachment[$i][3] . ", ";
$ReportBody .= "Type: " . $this->Mail->attachment[$i][4] . $eol;
}
$ReportBody .= $bullet_end . $eol;
}
// If there are changes then list them
if(count($this->ChangeLog) > 0)
{
$ReportBody .= "Changes" . $eol;
$ReportBody .= "-------" . $eol;
$ReportBody .= $bullet_start;
for($i = 0; $i < count($this->ChangeLog); $i++)
{
$ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" .
$this->ChangeLog[$i][1] . "]" . $eol;
}
$ReportBody .= $bullet_end . $eol . $eol;
}
// If there are notes then list them
if(count($this->NoteLog) > 0)
{
$ReportBody .= "Notes" . $eol;
$ReportBody .= "-----" . $eol;
$ReportBody .= $bullet_start;
for($i = 0; $i < count($this->NoteLog); $i++)
{
$ReportBody .= $bullet . $this->NoteLog[$i] . $eol;
}
$ReportBody .= $bullet_end;
}
// Re-attach the original body
$this->Mail->Body .= $eol . $eol . $ReportBody;
}
/**
* Check which default settings have been changed for the report.
* @private
* @returns void
*/
function CheckChanges() {
if($this->Mail->Priority != 3)
$this->AddChange("Priority", $this->Mail->Priority);
if($this->Mail->Encoding != "8bit")
$this->AddChange("Encoding", $this->Mail->Encoding);
if($this->Mail->CharSet != "iso-8859-1")
$this->AddChange("CharSet", $this->Mail->CharSet);
if($this->Mail->Sender != "")
$this->AddChange("Sender", $this->Mail->Sender);
if($this->Mail->WordWrap != 0)
$this->AddChange("WordWrap", $this->Mail->WordWrap);
if($this->Mail->Mailer != "mail")
$this->AddChange("Mailer", $this->Mail->Mailer);
if($this->Mail->Port != 25)
$this->AddChange("Port", $this->Mail->Port);
if($this->Mail->Helo != "localhost.localdomain")
$this->AddChange("Helo", $this->Mail->Helo);
if($this->Mail->SMTPAuth)
$this->AddChange("SMTPAuth", "true");
}
/**
* Adds a change entry.
* @private
* @returns void
*/
function AddChange($sName, $sNewValue) {
$cur = count($this->ChangeLog);
$this->ChangeLog[$cur][0] = $sName;
$this->ChangeLog[$cur][1] = $sNewValue;
}
/**
* Adds a simple note to the message.
* @public
* @returns void
*/
function AddNote($sValue) {
$this->NoteLog[] = $sValue;
}
/**
* Adds all of the addresses
* @public
* @returns void
*/
function SetAddress($sAddress, $sName = "", $sType = "to") {
switch($sType)
{
case "to":
$this->Mail->AddAddress($sAddress, $sName);
break;
case "cc":
$this->Mail->AddCC($sAddress, $sName);
break;
case "bcc":
$this->Mail->AddBCC($sAddress, $sName);
break;
}
}
/////////////////////////////////////////////////
// UNIT TESTS
/////////////////////////////////////////////////
/**
* Try a plain message.
*/
function test_WordWrap() {
$this->Mail->WordWrap = 40;
$my_body = "Here is the main body of this message. It should " .
"be quite a few lines. It should be wrapped at the " .
"40 characters. Make sure that it is.";
$nBodyLen = strlen($my_body);
$my_body .= "\n\nThis is the above body length: " . $nBodyLen;
$this->Mail->Body = $my_body;
$this->Mail->Subject .= ": Wordwrap";
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Try a plain message.
*/
function test_Low_Priority() {
$this->Mail->Priority = 5;
$this->Mail->Body = "Here is the main body. There should be " .
"a reply to address in this message.";
$this->Mail->Subject .= ": Low Priority";
$this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)");
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Simple plain file attachment test.
*/
function test_Multiple_Plain_FileAttachment() {
$this->Mail->Body = "Here is the text body";
$this->Mail->Subject .= ": Plain + Multiple FileAttachments";
if(!$this->Mail->AddAttachment("rocks.png"))
{
$this->assert(false, $this->Mail->ErrorInfo);
return;
}
if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt"))
{
$this->assert(false, $this->Mail->ErrorInfo);
return;
}
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Simple plain string attachment test.
*/
function test_Plain_StringAttachment() {
$this->Mail->Body = "Here is the text body";
$this->Mail->Subject .= ": Plain + StringAttachment";
$sAttachment = "These characters are the content of the " .
"string attachment.\nThis might be taken from a ".
"database or some other such thing. ";
$this->Mail->AddStringAttachment($sAttachment, "string_attach.txt");
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Plain quoted-printable message.
*/
function test_Quoted_Printable() {
$this->Mail->Body = "Here is the main body";
$this->Mail->Subject .= ": Plain + Quoted-printable";
$this->Mail->Encoding = "quoted-printable";
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Try a plain message.
*/
function test_Html() {
$this->Mail->IsHTML(true);
$this->Mail->Subject .= ": HTML only";
$this->Mail->Body = "This is a <b>test message</b> written in HTML. </br>" .
"Go to <a href=\"http://phpmailer.sourceforge.net/\">" .
"http://phpmailer.sourceforge.net/</a> for new versions of " .
"phpmailer. <p/> Thank you!";
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Simple HTML and attachment test
*/
function test_HTML_Attachment() {
$this->Mail->Body = "This is the <b>HTML</b> part of the email.";
$this->Mail->Subject .= ": HTML + Attachment";
$this->Mail->IsHTML(true);
if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt"))
{
$this->assert(false, $this->Mail->ErrorInfo);
return;
}
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* An embedded attachment test.
*/
function test_Embedded_Image() {
$this->Mail->Body = "Embedded Image: <img alt=\"phpmailer\" src=\"cid:my-attach\">" .
"Here is an image!</a>";
$this->Mail->Subject .= ": Embedded Image";
$this->Mail->IsHTML(true);
if(!$this->Mail->AddEmbeddedImage("rocks.png", "my-attach", "rocks.png",
"base64", "image/png"))
{
$this->assert(false, $this->Mail->ErrorInfo);
return;
}
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* An embedded attachment test.
*/
function test_Multi_Embedded_Image() {
$this->Mail->Body = "Embedded Image: <img alt=\"phpmailer\" src=\"cid:my-attach\">" .
"Here is an image!</a>";
$this->Mail->Subject .= ": Embedded Image + Attachment";
$this->Mail->IsHTML(true);
if(!$this->Mail->AddEmbeddedImage("rocks.png", "my-attach", "rocks.png",
"base64", "image/png"))
{
$this->assert(false, $this->Mail->ErrorInfo);
return;
}
if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt"))
{
$this->assert(false, $this->Mail->ErrorInfo);
return;
}
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Simple multipart/alternative test.
*/
function test_AltBody() {
$this->Mail->Body = "This is the <b>HTML</b> part of the email.";
$this->Mail->AltBody = "Here is the text body of this message. " .
"It should be quite a few lines. It should be wrapped at the " .
"40 characters. Make sure that it is.";
$this->Mail->WordWrap = 40;
$this->AddNote("This is a mulipart alternative email");
$this->Mail->Subject .= ": AltBody + Word Wrap";
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
/**
* Simple HTML and attachment test
*/
function test_AltBody_Attachment() {
$this->Mail->Body = "This is the <b>HTML</b> part of the email.";
$this->Mail->AltBody = "This is the text part of the email.";
$this->Mail->Subject .= ": AltBody + Attachment";
$this->Mail->IsHTML(true);
if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt"))
{
$this->assert(false, $this->Mail->ErrorInfo);
return;
}
$this->BuildBody();
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
$fp = fopen("message.txt", "w");
fwrite($fp, $this->Mail->CreateHeader() . $this->Mail->CreateBody());
fclose($fp);
}
function test_MultipleSend() {
$this->Mail->Body = "Sending two messages without keepalive";
$this->BuildBody();
$subject = $this->Mail->Subject;
$this->Mail->Subject = $subject . ": SMTP 1";
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
$this->Mail->Subject = $subject . ": SMTP 2";
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
}
function test_SmtpKeepAlive() {
$this->Mail->Body = "This was done using the SMTP keep-alive.";
$this->BuildBody();
$subject = $this->Mail->Subject;
$this->Mail->SMTPKeepAlive = true;
$this->Mail->Subject = $subject . ": SMTP keep-alive 1";
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
$this->Mail->Subject = $subject . ": SMTP keep-alive 2";
$this->assert($this->Mail->Send(), $this->Mail->ErrorInfo);
$this->Mail->SmtpClose();
}
function test_Error() {
$this->BuildBody();
$this->Mail->Subject .= ": This should not be sent";
$this->Mail->ClearAllRecipients(); // no addresses should cause an error
$this->assert($this->Mail->IsError() == false, "Error found");
$this->assert($this->Mail->Send() == false, "Send succeeded");
$this->assert($this->Mail->IsError(), "No error found");
$this->assertEquals('You must provide at least one ' .
'recipient email address.', $this->Mail->ErrorInfo);
}
}
/**
* Create and run test instance.
*/
if(isset($HTTP_GET_VARS))
$global_vars = $HTTP_GET_VARS;
else
$global_vars = $_REQUEST;
if(isset($global_vars["submitted"]))
{
echo "Test results:<br>";
$suite = new TestSuite( "phpmailerTest" );
$testRunner = new TestRunner;
$testRunner->run($suite);
echo "<hr noshade/>";
}
function get($sName) {
global $global_vars;
if(isset($global_vars[$sName]))
return $global_vars[$sName];
else
return "";
}
?>
<html>
<body>
<h3>phpmailer Unit Test</h3>
By entering a SMTP hostname it will automatically perform tests with SMTP.
<form name="phpmailer_unit" action="phpmailer_test.php" method="get">
<input type="hidden" name="submitted" value="1"/>
To Address: <input type="text" size="50" name="mail_to" value="<?php echo get("mail_to"); ?>"/>
<br/>
Cc Address: <input type="text" size="50" name="mail_cc" value="<?php echo get("mail_cc"); ?>"/>
<br/>
SMTP Hostname: <input type="text" size="50" name="mail_host" value="<?php echo get("mail_host"); ?>"/>
<p/>
<input type="submit" value="Run Test"/>
</form>
</body>
</html>

View file

@ -1,376 +0,0 @@
<?php
//
// PHP framework for testing, based on the design of "JUnit".
//
// Written by Fred Yankowski <fred@ontosys.com>
// OntoSys, Inc <http://www.OntoSys.com>
//
// $Id: phpunit.php,v 1.1 2002/03/30 19:32:17 bmatzelle Exp $
// Copyright (c) 2000 Fred Yankowski
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use, copy,
// modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
/*error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE |
E_CORE_ERROR | E_CORE_WARNING);*/
/*
interface Test {
function run(&$aTestResult);
function countTestCases();
}
*/
function trace($msg) {
return;
print($msg);
flush();
}
/*class Exception {
/* Emulate a Java exception, sort of... */
/*var $message;
function Exception($message) {
$this->message = $message;
}
function getMessage() {
return $this->message;
}
}*/
class Assert {
function assert($boolean, $message=0) {
if (! $boolean)
$this->fail($message);
}
function assertEquals($expected, $actual, $message=0) {
if ($expected != $actual) {
$this->failNotEquals($expected, $actual, "expected", $message);
}
}
function assertRegexp($regexp, $actual, $message=false) {
if (! preg_match($regexp, $actual)) {
$this->failNotEquals($regexp, $actual, "pattern", $message);
}
}
function failNotEquals($expected, $actual, $expected_label, $message=0) {
// Private function for reporting failure to match.
$str = $message ? ($message . ' ') : '';
$str .= "($expected_label/actual)<br>";
$htmlExpected = htmlspecialchars($expected);
$htmlActual = htmlspecialchars($actual);
$str .= sprintf("<pre>%s\n--------\n%s</pre>",
$htmlExpected, $htmlActual);
$this->fail($str);
}
}
class TestCase extends Assert /* implements Test */ {
/* Defines context for running tests. Specific context -- such as
instance variables, global variables, global state -- is defined
by creating a subclass that specializes the setUp() and
tearDown() methods. A specific test is defined by a subclass
that specializes the runTest() method. */
var $fName;
var $fResult;
var $fExceptions = array();
function TestCase($name) {
$this->fName = $name;
}
function run($testResult=0) {
/* Run this single test, by calling the run() method of the
TestResult object which will in turn call the runBare() method
of this object. That complication allows the TestResult object
to do various kinds of progress reporting as it invokes each
test. Create/obtain a TestResult object if none was passed in.
Note that if a TestResult object was passed in, it must be by
reference. */
if (! $testResult)
$testResult = $this->_createResult();
$this->fResult = $testResult;
$testResult->run(&$this);
$this->fResult = 0;
return $testResult;
}
function countTestCases() {
return 1;
}
function runTest() {
$name = $this->name();
// Since isset($this->$name) is false, no way to run defensive checks
$this->$name();
}
function setUp() /* expect override */ {
//print("TestCase::setUp()<br>\n");
}
function tearDown() /* possible override */ {
//print("TestCase::tearDown()<br>\n");
}
////////////////////////////////////////////////////////////////
function _createResult() /* protected */ {
/* override this to use specialized subclass of TestResult */
return new TestResult;
}
function fail($message=0) {
//printf("TestCase::fail(%s)<br>\n", ($message) ? $message : '');
/* JUnit throws AssertionFailedError here. We just record the
failure and carry on */
$this->fExceptions[] = new Exception(&$message);
}
function error($message) {
/* report error that requires correction in the test script
itself, or (heaven forbid) in this testing infrastructure */
printf('<b>ERROR: ' . $message . '</b><br>');
$this->fResult->stop();
}
function failed() {
return count($this->fExceptions);
}
function getExceptions() {
return $this->fExceptions;
}
function name() {
return $this->fName;
}
function runBare() {
$this->setup();
$this->runTest();
$this->tearDown();
}
}
class TestSuite /* implements Test */ {
/* Compose a set of Tests (instances of TestCase or TestSuite), and
run them all. */
var $fTests = array();
function TestSuite($classname=false) {
if ($classname) {
// Find all methods of the given class whose name starts with
// "test" and add them to the test suite. We are just _barely_
// able to do this with PHP's limited introspection... Note
// that PHP seems to store method names in lower case, and we
// have to avoid the constructor function for the TestCase class
// superclass. This will fail when $classname starts with
// "Test" since that will have a constructor method that will
// get matched below and then treated (incorrectly) as a test
// method. So don't name any TestCase subclasses as "Test..."!
if (floor(phpversion()) >= 4) {
// PHP4 introspection, submitted by Dylan Kuhn
$names = get_class_methods($classname);
while (list($key, $method) = each($names)) {
if (preg_match('/^test/', $method) && $method != "testcase") {
$this->addTest(new $classname($method));
}
}
}
else {
$dummy = new $classname("dummy");
$names = (array) $dummy;
while (list($key, $value) = each($names)) {
$type = gettype($value);
if ($type == "user function" && preg_match('/^test/', $key)
&& $key != "testcase") {
$this->addTest(new $classname($key));
}
}
}
}
}
function addTest($test) {
/* Add TestCase or TestSuite to this TestSuite */
$this->fTests[] = $test;
}
function run(&$testResult) {
/* Run all TestCases and TestSuites comprising this TestSuite,
accumulating results in the given TestResult object. */
reset($this->fTests);
while (list($na, $test) = each($this->fTests)) {
if ($testResult->shouldStop())
break;
$test->run(&$testResult);
}
}
function countTestCases() {
/* Number of TestCases comprising this TestSuite (including those
in any constituent TestSuites) */
$count = 0;
reset($fTests);
while (list($na, $test_case) = each($this->fTests)) {
$count += $test_case->countTestCases();
}
return $count;
}
}
class TestFailure {
/* Record failure of a single TestCase, associating it with the
exception(s) that occurred */
var $fFailedTestName;
var $fExceptions;
function TestFailure(&$test, &$exceptions) {
$this->fFailedTestName = $test->name();
$this->fExceptions = $exceptions;
}
function getExceptions() {
return $this->fExceptions;
}
function getTestName() {
return $this->fFailedTestName;
}
}
class TestResult {
/* Collect the results of running a set of TestCases. */
var $fFailures = array();
var $fRunTests = 0;
var $fStop = false;
function TestResult() { }
function _endTest($test) /* protected */ {
/* specialize this for end-of-test action, such as progress
reports */
}
function getFailures() {
return $this->fFailures;
}
function run($test) {
/* Run a single TestCase in the context of this TestResult */
$this->_startTest($test);
$this->fRunTests++;
$test->runBare();
/* this is where JUnit would catch AssertionFailedError */
$exceptions = $test->getExceptions();
if ($exceptions)
$this->fFailures[] = new TestFailure(&$test, &$exceptions);
$this->_endTest($test);
}
function countTests() {
return $this->fRunTests;
}
function shouldStop() {
return $this->fStop;
}
function _startTest($test) /* protected */ {
/* specialize this for start-of-test actions */
}
function stop() {
/* set indication that the test sequence should halt */
$fStop = true;
}
function countFailures() {
return count($this->fFailures);
}
}
class TextTestResult extends TestResult {
/* Specialize TestResult to produce text/html report */
function TextTestResult() {
$this->TestResult(); // call superclass constructor
}
function report() {
/* report result of test run */
$nRun = $this->countTests();
$nFailures = $this->countFailures();
printf("<p>%s test%s run<br>", $nRun, ($nRun == 1) ? '' : 's');
printf("%s failure%s.<br>\n", $nFailures, ($nFailures == 1) ? '' : 's');
if ($nFailures == 0)
return;
print("<ol>\n");
$failures = $this->getFailures();
while (list($i, $failure) = each($failures)) {
$failedTestName = $failure->getTestName();
printf("<li>%s\n", $failedTestName);
$exceptions = $failure->getExceptions();
print("<ul>");
while (list($na, $exception) = each($exceptions))
printf("<li>%s\n", $exception->getMessage());
print("</ul>");
}
print("</ol>\n");
}
function _startTest($test) {
printf("%s ", $test->name());
flush();
}
function _endTest($test) {
$outcome = $test->failed()
? "<font color=\"red\">FAIL</font>"
: "<font color=\"green\">ok</font>";
printf("$outcome<br>\n");
flush();
}
}
class TestRunner {
/* Run a suite of tests and report results. */
function run($suite) {
$result = new TextTestResult;
$suite->run($result);
$result->report();
}
}
?>

View file

@ -1 +0,0 @@
‰PNG