#*********************************************************************************************
#                                 Fait par JGP SOLDAT
#                               Maintenu par Kana-chan
#                             Pour l'Alliance Francophone
#                             Version 4.00, le 21 mai 2007 
#                           Première version 27 janvier 2001 
#
#                     (Programme de création de la page score2.html)
#
#*********************************************************************************************

use Socket;
use DBI;
use Encode qw(decode encode);

$maintenu = "<a href=\"/code/fahCode.7z\" target=\"_blank\">Kana-chan</a> avec l'aimable participation de Dylav de Zebulon.fr";
$destWWW = "/var/www/html";
$homeWWW = "/"; #"https://fah.chezmks.fr";

$test = 0;

sub place {
  local ($tot, $val, $record) = @_;
  return (($tot-$val+$record)-1);
}

sub format_number {
  local ($number) = @_;
  my $number_str = "".$number."";
  my $cpt_pl = length($number_str)-1;
  my $cpt_nb = 1;
  while ( $cpt_pl >= 0 ) {
    if ( $cpt_nb == 3 ) {
    if ( $cpt_pl > 0 and substr($number_str, $cpt_pl-1, 1) ne "-" ) {
      substr($number_str, $cpt_pl, 1) = "&#160;".substr($number_str, $cpt_pl, 1);
        $cpt_nb = 0;
      }
  }
  $cpt_nb++;
  $cpt_pl--;
  }
  return $number_str;
}

# Parametres de connection a la base de donnees
$bd    = '/tmp/memory/fah.db';
$identifiant = '';      # identifiant
$motdepasse  = '';

# Connection a la base de donnees mysql
print("Connexion a la base de donnees $bd\n");
$db = DBI->connect(
        "DBI:SQLite:dbname=$bd",
        $identifiant, $motdepasse, {RaiseError => 1}
      ) or die "Connection impossible a la base de donnees $bd !\n $! \n $@\n$DBI::errstr";

open(file, "pos1.res"); $b = <file>; close(file);

$ip_fah = "https://foldingathome.org/";
$ip6 = "https://www.alliancefrancophone.org";
$version = "7.10";

open(message, '>:utf8', "message_score.res");

$compte_message = 0;
 
open(file, '>:utf8', "$destWWW/score2.html");
@mois = ('janvier','f&eacute;vrier','mars','avril','mai','juin','juillet','ao&ucirc;t','septembre','octobre','novembre','d&eacute;cembre');
@jour = ('dimanche','lundi','mardi','mercredi','jeudi','vendredi','samedi');
($sec,$min,$heure,$jour,$mois,$annee,$jour2) = (localtime(time))[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0".$sec; }
if ($min < 10) { $min = "0".$min; }
if ($heure < 10) { $heure = "0".$heure; }
if ($jour < 10) { $jour = "0".$jour; }
$annee += "1900";

($GMsec,$GMmin,$GMheure,$GMjour,$GMmois,$GMannee,$GMjour2) = (gmtime(time))[0,1,2,3,4,5,6];
if ($GMsec < 10) { $GMsec = "0$GMsec"; }
if ($GMmin < 10) { $GMmin = "0$GMmin"; }
if ($GMheure < 10) { $GMheure = "0$GMheure"; }
if ($GMjour < 10) { $GMjour = "0$GMjour"; }
$GMannee += "1900";

# $url_javascript = "http://fah-web2.stanford.edu/cgi-bin/main.py?qtype=teampage&teamnum=";
$url_javascript = "https://stats.foldingathome.org/team/";
$url_fichier_plat = "https://apps.foldingathome.org/teamstats/";
$url_seoc_team = "https://folding.extremeoverclocking.com/team_summary.php?t=";

@couleur_fond = ('#8CD4F6', '#C2B998', '#C1A0B9', '#C4C7C4', '#DAC7C3', '#A2BFE4', '#AADFAA');

$t0 = 0;
$t1 = 0;
$t2 = 0;
$t3 = 0;
$t4 = 0;

# --- section <head> -----------------------------------------------------

print file ("<!DOCTYPE html>\n");
print file ("<html>\n");
print file ("<head>\n");
print file ("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF8\">\n");
print file ("<title>Classement des &eacute;quipes chez Folding\@home</title>\n");
print file ("<meta name=\"Author\" lang=\"fr, en-us\" content=\"JGP SOLDAT\">\n");
print file ("<meta name=\"Description\" content=\"Statistiques des performances de l'Alliance Francophone\">\n");
print file ("<meta name=\"Keywords\" LANG=\"fr\" content=\"JGP SOLDAT, calcul distribué, Folding\@home, Foldingathome, Stanford, Forum, Alliance Francophone, Québec, Quebec, France, français, francais, Folding at Home\">\n");
print file ("<meta name=\"Identifier-URL\" content=\"".$homeWWW."\">\n");
print file ("<meta name=\"Publisher\" content=\"JGP SOLDAT\">\n");
print file ("<link rel=\"stylesheet\" href=\"./site/StatStyle.css\" type=\"text/css\">\n");
print file ("<style>\n");
print file (".alliance  {background-color:#BDF !important;color:#800 !important}\n");
print file (".all-col2  {color:#800 !important}\n");
print file (".corps th {background-color:".$couleur_fond[$jour2]."}\n");
print file ("</style>\n");
print file ("</head>\n");

# --- section <body> -----------------------------------------------------

print file ("<body>\n");
print file ("<div id=\"container\">\n");
print file ("<div id=\"header\">\n");
print file ("<div id=\"logo\">\n");
print file ("<div class=\"wrapper\">\n");
print file ("<a href=\"".$ip6."\"><img style=\"width:1050px\" src=\"./site/images_site/logo_1050.png\" title=\"Statistiques de l'Alliance Francophone - Folding\@home\"></a>\n");
print file ("</div>\n");
print file ("</div>\n");
print file ("</div>\n");
print file ("<div id=\"main\">\n");
print file ("<div id=\"navbar\">\n");
print file ("<ul class=\"nav\">\n");
print file ("<!--li><a href=\"https://www.alliancefrancophone.org/\">Accueil de l'Alliance</a></li-->\n");
print file ("<li><a href=\"../index.html\">Accueil des stats</a></li>\n");
print file ("<li><a href=\"../Alliance.html\">Classement membres de l'AF</a></li>\n");
print file ("<li><a href=\"../miniteam.html\">Classement mini-teams</a></li>\n");
print file ("<li><a href=\"./site/TeamsStats.html\">Statistiques</a></li>\n");
print file ("<li><a href=\"./site/TeamsPays.html\">Mini-teams pays</a></li>\n");
print file ("<li><a href=\"./site/TeamsActives.html\">Mini-teams actives</a></li>\n");
print file ("<li><a href=\"./site/TeamsSommeil.html\">Mini-teams en sommeil</a></li>\n");
print file ("<li><a href=\"https://forum.alliancefrancophone.org/\">Forum de l'Alliance</a></li>\n");
print file ("</ul>\n");
print file ("</div>\n");
print file ("<div id=\"content\">\n");
print file ("<a id=\"top\" name=\"top\"></a>\n");
print file ("<div class=\"parag\"><h4>Les 100 meilleures &eacute;quipes chez<br>&nbsp;</h4></div>\n");
print file ("<div class=\"parag\"><a href=\"".$ip_fah."\" target=\"_blank\"><img src=\"./images/folding5.gif\"></a></div>\n");
print file ("<br><br><p class=\"MAJ\">Mis &agrave; jour le ".$jour[$jour2]." ".$jour." ".$mois[$mois]." ".$annee." &agrave; ");
print file ("$heure:$min, heure de Paris ($GMheure:$GMmin GMT)</p>\n");

$ErrNum = 0;
$membre = 0;
$donner = "pos_general, numeroteam, score, wu, rec";
print("SELECT pos_general,numeroteam,score FROM equipe WHERE rec = ".$b."\n");
$do = $db->prepare("SELECT pos_general,numeroteam,score FROM equipe WHERE rec = ".$b);
$ErrNum = $do->execute() or die $DBI::errstr;
while ($ErrNum >= 0 and my @data = $do->fetchrow_array()) {
  $tri[$data[0]] = $data[1];
  $score0{$data[1]} = $data[2];
  if ($test == 1) {
    print ("Position[".$data[0]."]=".$tri[$data[0]]." ==> Score [".$score0{$data[1]}."]\n");
  }
  $membre++;
}

$ErrNum = 0;
if ($test == 1) { print("SELECT numeroteam,score FROM equipe WHERE rec = ".($b-1)."\n"); }
$do = $db->prepare("SELECT numeroteam,score FROM equipe WHERE rec = ".($b-1));
$ErrNum = $do->execute() or die $DBI::errstr;
while ($ErrNum >= 0 and my @data = $do->fetchrow_array()) {
  $score0_tmp = $score0{$data[0]};
  if ($score0_tmp > 0) {
    $diff_score{$data[0]} = $score0_tmp-$data[1];
    if ($test == 1) {
      print ("Team diff score [".$data[0]."]=".$diff_score{$data[0]}." (".$score0_tmp."-".$data[1].")\n");
    }
  }
}

my @keys = sort { $diff_score{$b} <=> $diff_score{$a} } keys(%diff_score);
$cpt=1;
foreach $key (@keys) {
  $placeJ1{$key} = $cpt;
  $cpt++;
  if ($test == 1) { print ("Team [".$key."] is [".$placeJ1{$key}."]\n"); }
}

$actuelle = 9;
$b1 = $b-$actuelle;
if ($b1 < 0) {
  $b1 = 0;
}

$url = 0;
open(file_team, "url_team.team");
my @liste = <file_team>;
print("\nLISTE de URL = ".@liste."\n");
close(file_team);
foreach $line (@liste) {
  if ($line ne "\r\n") {
    $url++;
    ($nom_team[$url], $url_team[$url]) = split(/\|/,$line,2);
    $url_team[$url] =~ s/\n//g;
    $url_team[$url] =~ s/\r//g;
    if ($test == 1) {
      print $url.": ".$nom_team[$url];
      $tmp = 30-length ($url.") ".$nom_team[$url]);
      print(" " x $tmp);
      print $url_team[$url]."\n";
    }
  }
}

$max1 = 0;
$mon1 = 0;
$max2 = 0;
$mon2 = 0;
$max3 = 0;
$mon3 = 0;
$num = 0;
$num1 = 0;
$allo = 0;
$nouv = 0;
print("\nmembre = ".$membre."\n");
while ($num < $membre) {
  if ($num1 >= 200) {
    print file ("\n</table>");
    $num1 = 0;
  }

# --- entêtes du tableau -------------------------------------------------

  if ($num1 == 0) {
   print file ("<table class=\"corps\">\n");
   print file ("<tr>\n");
   print file ("<th rowspan=\"2\">Pos</th>\n");
   print file ("<th rowspan=\"2\" colspan=\"2\">Noms d'&eacute;quipes</th>\n");
   print file ("<th rowspan=\"2\">Points</th>\n");
   print file ("<th rowspan=\"2\">WU</th>\n");
   print file ("<th colspan=\"9\">Production</th>\n");
   print file ("<th colspan=\"8\">+/- Folding</th>\n");
   print file ("</tr>\n");
   print file ("<tr>\n");
   print file ("<th colspan=\"2\">&nbsp;J&nbsp;</th><th>J-1</th><th>J-2</th><th>J-3</th><th>J-4</th><th>J-5</th><th>J-6</th><th>Semaine</th>\n");
   print file ("<th>&nbsp;J&nbsp;</th><th>J-1</th><th>J-2</th><th>J-3</th><th>J-4</th><th>J-5</th><th>J-6</th><th>Semaine</th>\n");
   print file ("</tr>\n");
  }
  $num++;

  $cpt = 0;
  while ($cpt < $actuelle+1) {
    $score[$cpt] = -1;
    $posg[$cpt] = 0;
    $cpt++;
  }
  
  if ($test == 1) { print("SELECT numeroteam,rec,pos_general,score,wu FROM equipe WHERE numeroteam = '".$tri[$num]."' AND rec BETWEEN ".$b1." AND ".$b."\n"); }
  $do = $db->prepare("SELECT numeroteam,rec,pos_general,score,wu FROM equipe WHERE numeroteam = '".$tri[$num]."' AND rec BETWEEN ".$b1." AND ".$b);
  $ErrNum = $do->execute() or die $DBI::errstr;
  $compte = 0;
  while ($ErrNum >= 0 and my @data = $do->fetchrow_array()) {
    if ($test == 1) { print("Equipe [".$data[0]."]: "); }
    if ($tri[$num] == $data[0]) {
      $compte++;
      $rec = place($actuelle+1, $b, $data[1]);
      if ($test == 1) { print("Record [".$rec."]= [".$data[1]."]\n"); }
      $numeroteam[$rec] = $data[0];
      $nom[$rec] =~ s/;/ /g;
      $posg[$rec] = $data[2];
      $score[$rec] = int($data[3]);
      $wu[$rec] = $data[4];
      $cpuhour[$rec] = 0;
    } else {
      if ($test == 1) { print("\n"); }
    }
  }
  
  if ($test == 1) { print("==> Record [".$rec."]: SELECT nomteam FROM liste_equipe WHERE numeroteam = '".$numeroteam[$rec]."'\n"); }
  $do = $db->prepare("SELECT nomteam FROM liste_equipe WHERE numeroteam = '".$numeroteam[$rec]."'");
  $ErrNum = $do->execute() or die $DBI::errstr;
  while ($ErrNum >= 0 and my @data = $do->fetchrow_array()) {
    $nom = $data[0];
    $nom1 = $nom;
  }
  
  if ($test == 1) { 
    print($posg[$rec]." ".$nom." ");
    $tmp = 50-length($posg[$rec]." ".$nom." ");
    print(" " x $tmp);
    print("Points= ".$score[$rec]."\n");
  }
  
  $memoire = 0;
  if ($score[0] == -1) { $score[0] = 0; $memoire = 0; } else { $memoire = $score[0]; }
  if ($score[1] == -1) { $score[1] = $memoire; } else { $memoire = $score[1]; }
  if ($score[2] == -1) { $score[2] = $memoire; } else { $memoire = $score[2]; }
  if ($score[3] == -1) { $score[3] = $memoire; } else { $memoire = $score[3]; }
  if ($score[4] == -1) { $score[4] = $memoire; } else { $memoire = $score[4]; }
  if ($score[5] == -1) { $score[5] = $memoire; } else { $memoire = $score[5]; }
  if ($score[6] == -1) { $score[6] = $memoire; } else { $memoire = $score[6]; }
  if ($score[7] == -1) { $score[7] = $memoire; } else { $memoire = $score[7]; }
  if ($score[8] == -1) { $score[8] = $memoire; } else { $memoire = $score[8]; }
  if ($compte > 1) { $u1 = $score[9]-$score[8]; } else { $u1 = 0; }   
  if ($compte > 2) { $u2 = $score[8]-$score[7]; } else { $u2 = 0; }
  if ($compte > 3) { $u3 = $score[7]-$score[6]; } else { $u3 = 0; }
  if ($compte > 4) { $u4 = $score[6]-$score[5]; } else { $u4 = 0; }
  if ($compte > 5) { $u5 = $score[5]-$score[4]; } else { $u5 = 0; }
  if ($compte > 6) { $u6 = $score[4]-$score[3]; } else { $u6 = 0; }
  if ($compte > 7) { $u7 = $score[3]-$score[2]; } else { $u7 = 0; }
  $u8 = $u1+$u2+$u3+$u4+$u5+$u6+$u7;

  $f_u1 = format_number($u1);
  $f_u2 = format_number($u2);
  $f_u3 = format_number($u3);
  $f_u4 = format_number($u4);
  $f_u5 = format_number($u5);
  $f_u6 = format_number($u6);
  $f_u7 = format_number($u7);
  $f_u8 = format_number($u8);

  $tri2[$num] = $u1;
  $nom1[$num] = $nom;
  $tp = $posg[$actuelle];
  $f_tp = format_number($tp);
  if ($tp > 0) {
    if ($u1 > $max1) { $max3 = $max2; $mon3 = $mon2; $max2 = $max1; $mon2 = $mon1; $max1 = $u1; $mon1 = $num; }
    elsif ($u1 > $max2 and $u1 < $max1) { $max3 = $max2; $mon3 = $mon2; $max2 = $u1; $mon2 = $num; }
    elsif ($u1 > $max3 and $u1 < $max2 and $u1 < $max1) { $max3 = $u1; $mon3 = $num; }
  }
  @team = split(/T/, $numeroteam[$rec]);

# --- ligne d'une team ---------------------------------------------------
  $is_alliance = 0;
  if ($nom eq "Alliance Francophone") {
    $is_alliance = 1;
  }
  if ($is_alliance == 0) { print file ("<tr>\n"); }
  else                   { print file ("<tr class=\"alliance\" id=\"AF\">\n"); }
  
  print file ("<td class=\"right\"><a ");
  if ($is_alliance != 0) { print file ("class=\"alliance\" "); }
  print file ("href=\"".$url_javascript.$team[1]."\" target=\"_blank\">$f_tp</a></td>\n");

  $tmp = 1;
  while ($tmp <= $url) { 
    if ($nom =~ /$nom_team[$tmp]/) {
      $allo1 = "<a ";
      if ($is_alliance != 0) { $allo1 .= "class=\"alliance\" "; }
      $allo1 .= "href=\"".$url_team[$tmp]."\" target=\"_blank\">".$nom_team[$tmp]."</a>";
      $nom =~ s/$nom_team[$tmp]/$allo1/g;
    }
    $tmp++;
  }

  if ($is_alliance == 0) { print file ("<td>\n"); }
  elsif ($compte < 7)    { print file ("<td class=\"bleu\">$nom</td>\n"); }
  else                   { print file ("<td class=\"all-col2\">"); }
  
  if ($score[$actuelle-1] == 0 or $posg[$actuelle-1] == 0) {
    $allo++;
    print file ("$nom&nbsp;<img src=\"images/jgp_new.gif\"></td>\n");
    #--------------------------------------------------    MESSAGES    --------------------------------------------------
    #----------------------------- Nouvelle équipe dans le top 100 du classement des équipes ----------------------------
    #--------------------------------------------------------------------------------------------------------------------
    if ($compte_message == 0) {
      print message ("<u>Changement au classement mondial des &eacute;quipes</u> :<br>\n");
    }
    $compte_message++;
    print message ("L'&eacute;quipe <strong>".$nom."</strong> est apparue aujourd'hui au ");
    if ($tp == 1) {
      print message ("1<sup>er</sup>");
    } elsif ($tp == 2) {
      print message ("2<sup>nd</sup>");
    } else {
      print message ($tp."<sup>&egrave;me</sup>");
    }
    print message (" rang du top 100.<br>\n");
  } elsif ( $u1 > 0 and $u2 == 0 and $u3 == 0 and $u4 == 0 and $u5 == 0 and $u6 == 0 and $u7 == 0 ) {
    $nouv++;
    print file ("$nom</td>\n");
  } elsif ( $u8 <= 0 ) {
    print file ("$nom&nbsp;<img src=\"images/jgp_bye.gif\"></td>\n");
  } else {
    print file ("$nom&nbsp;</td>\n");
  }
  print file ("<td><a href=\"".$url_fichier_plat."/team".$team[1].".txt\" target=\"_blank\"><img src=\"images/icon1.gif\"></a></td>\n"); 

  $p8 = 0;
  if ($posg[8] > 0 and $compte > 1) { $p1 = $posg[8]-$posg[9]; $p8 = $p8+$p1; } else { $p1 = "???"; $posg[8] = $posg[9]; } 
  if ($posg[7] > 0 and $compte > 2) { $p2 = $posg[7]-$posg[8]; $p8 = $p8+$p2; } else { $p2 = "???"; $posg[7] = $posg[8]; }
  if ($posg[6] > 0 and $compte > 3) { $p3 = $posg[6]-$posg[7]; $p8 = $p8+$p3; } else { $p3 = "???"; $posg[6] = $posg[7]; }
  if ($posg[5] > 0 and $compte > 4) { $p4 = $posg[5]-$posg[6]; $p8 = $p8+$p4; } else { $p4 = "???"; $posg[5] = $posg[6]; }
  if ($posg[4] > 0 and $compte > 5) { $p5 = $posg[4]-$posg[5]; $p8 = $p8+$p5; } else { $p5 = "???"; $posg[4] = $posg[5]; }
  if ($posg[3] > 0 and $compte > 6) { $p6 = $posg[3]-$posg[4]; $p8 = $p8+$p6; } else { $p6 = "???"; $posg[3] = $posg[4]; }
  if ($posg[2] > 0 and $compte > 7) { $p7 = $posg[2]-$posg[3]; $p8 = $p8+$p7; } else { $p7 = "???"; $posg[2] = $posg[3]; }

  $f_p1 = format_number($p1);
  $f_p2 = format_number($p2);
  $f_p3 = format_number($p3);
  $f_p4 = format_number($p4);
  $f_p5 = format_number($p5);
  $f_p6 = format_number($p6);
  $f_p7 = format_number($p7);
  $f_p8 = format_number($p8);

  $f_score_actuelle = format_number($score[$actuelle]);
  print file ("<td class=\"right\"><a ");
  if ($is_alliance != 0) { print file ("class=\"alliance\" "); }
  print file ("href=\"".$url_seoc_team.$team[1]."\" target=\"_blank\">".$f_score_actuelle."</a></td>\n");
  
  $f_wu_actuelle = format_number($wu[$actuelle]);
  print file ("<td class=\"right\">$f_wu_actuelle</td>\n");

  print file ("<td class=\"right\">$f_u1</td>\n");
  if ($diff_score{$numeroteam[$rec]} > 0) {
    print file ("<td class=\"right\"><font color=\"darkgreen\">".$placeJ1{$numeroteam[$rec]}."</font></td>\n");
  } else {
    print file ("<td class=\"right\">&nbsp;</td>\n");
  }
  print file ("<td class=\"right\">$f_u2</td>\n");
  print file ("<td class=\"right\">$f_u3</td>\n");
  print file ("<td class=\"right\">$f_u4</td>\n");
  print file ("<td class=\"right\">$f_u5</td>\n");
  print file ("<td class=\"right\">$f_u6</td>\n");
  print file ("<td class=\"right\">$f_u7</td>\n");
  print file ("<td class=\"right\">$f_u8</td>\n");

  print file ("<td class=\"right\">$f_p1</td>\n");
  print file ("<td class=\"right\">$f_p2</td>\n");
  print file ("<td class=\"right\">$f_p3</td>\n");
  print file ("<td class=\"right\">$f_p4</td>\n");
  print file ("<td class=\"right\">$f_p5</td>\n");
  print file ("<td class=\"right\">$f_p6</td>\n");
  print file ("<td class=\"right\">$f_p7</td>\n");
  print file ("<td class=\"right\">$f_p8</td>\n");
  print file ("</tr>");

  #--------------------------------------------------------------------------------------------------------------------
  #--------------------------------------------------    MESSAGES    --------------------------------------------------
  #------------------------------ Changement de position dans le classement des équipes -------------------------------
  #--------------------------------------------------------------------------------------------------------------------
  if ($posg[8] > $posg[9] and $tp < 30) {
    if ($compte_message == 0) {
      print message ("<u>Changement au classement mondial des &eacute;quipes</u> :<br>\n");
    }
    $compte_message++; 
    print message ("L'&eacute;quipe <strong>".$nom."</strong> grimpe au ");
    if ($tp == 1) {
      print message ("1<sup>er</sup>");
    } elsif ($tp == 2) {
      print message ("2<sup>nd</sup>");
    } else {
      print message ($tp."<sup>&egrave;me</sup>");
    }
    print message (" rang du top 30.<br>\n");
  }
  # print ("$nom,  classement aujourd'hui= $posg[$b],  classement hier= $posg[$b-1]\n");

  $num1++;
}

print file ("</table>\n");
print file ("<br>\n");

# --- podium -------------------------------------------------------------

print file ("<table class=\"podium\"><tr>\n");
print file ("<td></td><td><em><u>Le podium du jour</u></em></td>\n");
print file ("</tr>\n");

if ($tri2[$mon1] != 0) {
  $f_tri2_num = format_number($tri2[$mon1]);
  print file ("<tr><td><img src=\"images/premier.gif\"></td><td><strong>".$nom1[$mon1]."</strong></td><td>".$f_tri2_num." points</td></tr>\n");
}

if ($tri2[$mon2] != 0) {
  $f_tri2_num = format_number($tri2[$mon2]);
  print file ("<tr><td><img src=\"images/deuxieme.gif\"></td><td><strong>".$nom1[$mon2]."</strong></td><td>".$f_tri2_num." points</td></tr>\n");
}

if ($tri2[$mon3] != 0) {
  $f_tri2_num = format_number($tri2[$mon3]);
  print file ("<tr><td><img src=\"images/trois.gif\"></td><td><strong>".$nom1[$mon3]."</strong></td><td>".$f_tri2_num." points</td></tr>\n");
}
print file ("</table>\n");

# --- bas de page --------------------------------------------------------

print file ("</div>\n</div>\n<div id =\"footer\">\n");
print file ("<div class=\"row_latest\">\n<div class=\"latest\">\n<div class=\"latest_text\">");
print file ("<p><a href=\"http://folding.fleucorp.net/installation.htm\" target=\"_blank\">Élaboré par JGP SOLDAT</a>&nbsp;-&nbsp;Maintenu par <a href=\"/code/fahCode.7z\" target=\"_blank\">Kana-chan</a> avec l'aimable participation de Dylav de Zebulon.fr&nbsp;-&nbsp;Version 7.10<a href=\"/\" class=\"top_button\">HOME</a><a href=\"#top\" class=\"top_button\">HAUT</a></p>\n");
print file ("</div>\n</div>\n</div>\n</div>\n</div>\n");

print file ("</body>\n");                              
print file ("</html>\n");                              

close(file);
print("\nFermeture du fichier score2.html");

close(message);

$db->disconnect();

open(file, "$destWWW/score2.html");
@copy = <file>;
close(file);
open(file, ">vieux/score2-".$b.".html");
print file (@copy);
close(file);

print("\nFin du traitement\n");
exit;
1;
