1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| <?php
/*****************************/
//But : Script de migration de la table des utilisateurs (création du code SQL)
//Auteur : ***
//Date : 06.08.2009
/*****************************/
//URL et nom du fichier
$file = "membres.sql";
$gestion = fopen($file,"w");
//En cas de long travail, ne pas interrompre
set_time_limit(0);
//On récupère le code source de la page de chaque membre et on met chaque code dans une cellule du tableau
for ($i=1;$i<=1;$i++)
{
//Création des regex pour faire sortir les informations nécessaires :
$regex_user="#Nom de l'utilisateur : (.+)</legend>#";
$regex_mail="#name=\"email\" size=\"35\" maxlength=\"64\" value=\"(.+)\" /> <a#";
$regex_next_birthday_greeting="#\"next_birthday_greeting\" size=\"5\" maxlength=\"4\" value=\"(.+)\" /></td></tr><tr><td class=\"row1\"><span class=\"gen\">Si#";
$regex_signature="#name=\"signature\" rows=\"6\" cols=\"45\">(.+)</textarea></td></tr><tr><td> </td>#";
$regex_annee_naissance="#name=\"profile_field_4_-12\[\]\" style=\"width:50px\" size=\"5\" maxlength=\"4\" value=\"(.+)\" /><br /><em></em></td></tr><tr><td class=\"row1\"><span class=\"gen\">Age#";
$regex_localisation="#name=\"profile_field_13_-11\" style=\"width:250px\" value=\"(.+)\" /><br /><em></em></td></tr><tr><td class=\"row1\"><span class=\"gen\">Humeur#";
$regex_jour_birthday="#\"profile_field_4_-12\[\]\" size=\"1\">.*<option value=\"(.{0,2})\" selected=\"selected\">.{0,2}</option>.*</select> Mois#";
$regex_mois_birthday="#Mois <select class=\"gensmall\" id=\"profile_field_4_-12_1\" name=\"profile_field_4_-12\[\]\" size=\"1\">.*<option value=\"(.*)\" selected=\"selected\">.*</option>.*</select> Ann#";
$regex_annee_birthday="#Année <input type=\"text\" class=\"post\" id=\"profile_field_4_-12_0\" name=\"profile_field_4_-12\[\]\" style=\"width:50px\" size=\"5\" maxlength=\"4\" value=\"(.*)\" /><br /><em></em></td></tr><tr><td class=\"row1\"><span class=\"gen\">Age#";
//Récupération du code source
$code_source=file_get_contents("http://www.bibliojunior.ch/rafmos/temp.html");
//Extraction des informations
preg_match_all($regex_user, $code_source, $user);
preg_match_all($regex_mail, $code_source, $mail);
preg_match_all($regex_next_birthday_greeting, $code_source, $next_birthday_greeting);
preg_match_all($regex_signature, $code_source, $signature);
preg_match_all($regex_annee_naissance, $code_source, $annee_naissance);
preg_match_all($regex_localisation, $code_source, $localisation);
preg_match_all($regex_jour_birthday, $code_source, $jour_birthday);
preg_match_all($regex_mois_birthday, $code_source, $mois_birthday);
preg_match_all($regex_annee_birthday, $code_source, $annee_birthday);
//Création de tableaux avec les différentes informations
$user_list[] = $user[1][0];
$mail_list[] = $mail[1][0];
$next_birthday_greeting_list[] = $next_birthday_greeting[1][0];
$signature_list[] = $signature[1][0];
$annee_naissance_list[] = $annee_naissance[1][0];
$localisation_list[] = $localisation[1][0];
$jour_birthday_list[] = $jour_birthday[1][0];
$mois_birthday_list[] = $mois_birthday[1][0];
$annee_birthday_list[] = $annee_birthday[1][0];
}
print_r($annee_birthday_list);
echo "<br><br>";
print_r($mois_birthday_list);
?> |
Partager