Exemplo n.º 1
0
$moyFrancais = 0;
// moyenne pour l'informatique
$moyInfo = 0;
// entête HTML du tableau
echo "<table>\n\t   <tr>\n\t     <th>Nom</th>\n\t     <th>Français</th>\n\t     <th>Maths</th>\n\t     <th>Info</th>\n\t     <th>Moyenne</th>\n\t   </tr>";
// première boucle
$nbElem = count($tableau);
for ($i = 0; $i < $nbElem; $i++) {
    echo "<tr>";
    // pour la moyenne de l'élève
    $moyenne = 0;
    // boucle intérieure
    foreach ($tableau[$i] as $cle => $elem) {
        if ($cle == 'Nom') {
            echo '<td>' . $elem . '</td>
							  <td>' . getlogin($elem) . '</td>';
        } else {
            echo '<td bgcolor="' . getCouleur($elem) . '">' . $elem . "</td>";
        }
        //calcul des moyennes
        switch ($cle) {
            case 'Francais':
                $moyenne = $moyenne + $elem;
                $moyFrancais += $elem;
                //idem ligne du dessus
                break;
            case 'Maths':
                $moyenne = $moyenne + $elem;
                $moyMaths += $elem;
                //idem ligne du dessus
                break;
function dwellings_pvp_run()
{
    global $session, $badguy, $pvptime, $pvptimeout, $options;
    $pvptime = getsetting("pvptimeout", 600);
    $pvptimeout = date("Y-m-d H:i:s", strtotime("-{$pvptime} seconds"));
    $last = date("Y-m-d H:i:s", strtotime("-" . getsetting("LOGINTIMEOUT", 900) . " sec"));
    $ac = db_prefix("accounts");
    $mu = db_prefix("module_userprefs");
    $dw = db_prefix("dwellings");
    $cl = db_prefix("clans");
    $op = httpget('op');
    $dwid = httpget('dwid');
    page_header("Dwellings PvP");
    if ($op != "fight1" && $op != "fight") {
        require_once "modules/dwellings_pvp/run/case_{$op}.php";
    }
    if ($op == "fight1") {
        $name = rawurldecode(httpget('name'));
        require_once "modules/dwellings/lib.php";
        if (is_numeric($name)) {
            $name = getlogin($name);
        }
        require_once "lib/pvpsupport.php";
        $badguy = setup_target($name);
        require_once "lib/battle-skills.php";
        suspend_buffs("allowinpvp", "`&The gods prevent you from using any special abilities!`0");
        $session['user']['badguy'] = createstring($badguy);
        $session['user']['playerfights']--;
        $op = "fight";
    }
    if ($op == "fight") {
        $options['type'] = 'pvp';
        $battle = true;
    }
    if ($battle) {
        include "battle.php";
        if ($victory) {
            $killedin = sprintf("%s Dwellings", $session['user']['location']);
            require_once "lib/pvpsupport.php";
            pvpvictory($badguy, $killedin, $options);
            addnews("`4%s`3 defeated `4%s`3 while they were sleeping in their Dwelling.", $session['user']['name'], $badguy['creaturename']);
            $badguy = array();
            unsuspend_buffs("allowinpvp", "`&The gods have restored your special abilities!`0");
            addnav("Leave");
            addnav("Hamlet Registry", "runmodule.php?module=dwellings&op=list&ref=hamlet");
        } elseif ($defeat) {
            $killedin = sprintf("%s Dwellings", $session['user']['location']);
            require_once "lib/taunt.php";
            $taunt = select_taunt_array();
            require_once "lib/pvpsupport.php";
            pvpdefeat($badguy, $killedin, $taunt, $options);
            unsuspend_buffs("allowinpvp", "`&The gods have restored your special abilities!`0");
            addnews("`4%s`3 was defeated while attacking `4%s`3 as they were sleeping in their Dwelling.`n%s", $session['user']['name'], $badguy['creaturename'], $taunt);
            output("`n`n`&You are sure that someone, sooner or later, will stumble over your corpse and return it to %s for you.", $session['user']['location']);
            addnav("Return to the Shades", "shades.php");
        } else {
            $script = "runmodule.php?module=dwellings_pvp&op=fight";
            require_once "lib/fightnav.php";
            fightnav(false, false, $script);
        }
    }
    page_footer();
}