MediaWiki API result
This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.
Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.
See the complete documentation, or the API help for more information.
{
"batchcomplete": "",
"continue": {
"gapcontinue": "Test-de-la-solution-fichier-texte",
"continue": "gapcontinue||"
},
"warnings": {
"main": {
"*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."
},
"revisions": {
"*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."
}
},
"query": {
"pages": {
"179": {
"pageid": 179,
"ns": 0,
"title": "Script requete",
"revisions": [
{
"contentformat": "text/x-wiki",
"contentmodel": "wikitext",
"*": "<syntaxhighlight lang=\"php\">\n <?php\n \n function add_book($login, $ID, $start_date, $end_date, $aircraft_num, $member_num, $slot_type, $inst_num, $free_seats, $comments)\n {\n $now = date(\"Y-m-d G:i:s\");\n $query = 'insert into journal values (\\''.$login.'\\', null, \\''.$now.'\\', \\'book_Alone\\', \\'record_book\\')';\n mysql_query($query);\n \n $num_log = mysql_insert_id();\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'ID\\', \\''.$ID.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'START_DATE\\', \\''.$start_date.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'END_DATE\\', \\''.$end_date.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'AIRCRAFT_NUM\\', \\''.$aircraft_num.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'MEMBER_NUM\\', \\''.$member_num.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'SLOT_TYPE\\', \\''.$slot_type.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'INST_NUM\\', \\''.$inst_num.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'FREE_SEATS\\', \\''.$free_seats.'\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'booking\\', \\'comments\\', \\''.$comments.'\\')';\n mysql_query($query);\n }\n \n function delete_book($login, $ID)\n {\n $now = date(\"Y-m-d G:i:s\");\n $query = 'insert into journal values (\\''.$login.'\\', null, \\''.$now.'\\', \\'book_Alone\\', \\'delete_book\\')';\n mysql_query($query);\n \n $num_log = mysql_insert_id();\n \n $query = 'insert into log values ('.$num_log.', \\'delete\\', \\'booking\\', \\'ID\\', \\''.$ID.'\\')';\n mysql_query($query);\n }\n \n function clean_log()\n {\n $query = 'delete from log';\n mysql_query($query);\n \n $query = 'delete from journal';\n mysql_query($query);\n }\n \n function create_aircraft($login)\n {\n $now = date(\"Y-m-d G:i:s\");\n $query = 'insert into journal values (\\''.$login.'\\', null, \\''.$now.'\\', \\'book_Alone\\', \\'add_modify_aircraft\\')';\n mysql_query($query);\n $num_log = mysql_insert_id();\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'aircraft\\', \\'NUM\\', \\'1\\')';\n mysql_query($query);\n \n $query = 'insert into log values ('.$num_log.', \\'insert\\', \\'aircraft\\', \\'CALLSIGN\\', \\'B-52\\')';\n mysql_query($query);\n }\n \n function requete()\n {\n $query = 'select\n L_add_modify_aircraft_CALLSIGN.field_value,\n L_record_book_START_DATE.field_value,\n L_record_book_END_DATE.field_value,\n J_delete_book.date_log\n\n from\n journal J_delete_book,\n journal J_add_modify_aircraft,\n journal J_record_book,\n log L_delete_book,\n log L_add_modify_aircraft_NUM,\n log L_add_modify_aircraft_CALLSIGN,\n log L_record_book_ID,\n log L_record_book_START_DATE,\n log L_record_book_END_DATE,\n log L_record_book_AIRCRAFT_NUM\n\n where \n J_delete_book.action = \\'delete_book\\'\n and J_add_modify_aircraft.action = \\'add_modify_aircraft\\'\n and J_record_book.action = \\'record_book\\'\n \n and J_delete_book.login = \\'mezza\\'\n and J_record_book.login = \\'mezza\\'\n \n and J_delete_book.num_log = L_delete_book.num_log\n and J_add_modify_aircraft.num_log = L_add_modify_aircraft_NUM.num_log\n and J_add_modify_aircraft.num_log = L_add_modify_aircraft_CALLSIGN.num_log\n and J_record_book.num_log = L_record_book_ID.num_log\n and J_record_book.num_log = L_record_book_START_DATE.num_log\n and J_record_book.num_log = L_record_book_END_DATE.num_log\n and J_record_book.num_log = L_record_book_AIRCRAFT_NUM.num_log\n \n and L_delete_book.table_name = \\'booking\\'\n and L_delete_book.field_name = \\'ID\\'\n and L_record_book_ID.table_name = \\'booking\\'\n and L_record_book_ID.field_name = \\'ID\\'\n and L_delete_book.field_value = L_record_book_ID.field_value\n \n and L_record_book_AIRCRAFT_NUM.table_name = \\'booking\\'\n and L_record_book_AIRCRAFT_NUM.field_name = \\'AIRCRAFT_NUM\\'\n and L_add_modify_aircraft_NUM.table_name = \\'aircraft\\'\n and L_add_modify_aircraft_NUM.field_name = \\'NUM\\'\n and L_record_book_AIRCRAFT_NUM.field_value = L_add_modify_aircraft_NUM.field_value\n \n and L_add_modify_aircraft_CALLSIGN.table_name = \\'aircraft\\'\n and L_add_modify_aircraft_CALLSIGN.field_name = \\'CALLSIGN\\'\n \n and L_record_book_START_DATE.table_name = \\'booking\\'\n and L_record_book_START_DATE.field_name = \\'START_DATE\\'\n \n and L_record_book_END_DATE.table_name = \\'booking\\'\n and L_record_book_END_DATE.field_name = \\'END_DATE\\'\n \n and L_record_book_START_DATE.field_value > J_delete_book.date_log\n and date_sub(L_record_book_START_DATE.field_value, interval 1 day) < J_delete_book.date_log';\n \n $result = mysql_query($query);\n if($result)\n {\n echo 'aircraft -- start_date -- end_date -- delete_date<br>';\n while($name_row = mysql_fetch_row($result))\n {\n \t echo $name_row[0].' -- '.$name_row[1].' -- '.$name_row[2].' -- '.$name_row[3].'<br>';\n }\n }\n else\n {\n echo 'La requete a \u00e9chou\u00e9.<br>';\n }\n }\n \n /********\n * main *\n ********/\n \n mysql_connect('localhost', 'mezza', '');\n mysql_select_db('openflyers');\n \n clean_log();\n \n create_aircraft('mezza');\n add_book('mezza', 1, '2006-06-01 00:00:00', '2006-06-02 00:00:00', 1, 1, 1, 1, 1, 'no comment');\n add_book('mezza', 2, '2006-06-03 00:00:00', '2006-06-05 00:00:00', 1, 1, 1, 1, 1, 'no comment');\n add_book('mezza', 3, '2006-06-20 20:00:00', '2006-06-22 21:00:00', 1, 1, 1, 1, 1, 'no comment');\n add_book('mezza', 4, '2006-06-25 00:00:00', '2006-06-25 10:00:00', 1, 1, 1, 1, 1, 'no comment');\n add_book('mezza', 5, '2006-06-19 22:00:00', '2006-06-21 14:00:00', 1, 1, 1, 1, 1, 'no comment');\n delete_book('mezza', 1);\n delete_book('mezza', 2);\n delete_book('mezza', 3);\n delete_book('mezza', 4);\n delete_book('mezza', 5);\n \n requete();\n ?>\n</php>"
}
]
},
"177": {
"pageid": 177,
"ns": 0,
"title": "Test de la solution fichier XML",
"revisions": [
{
"contentformat": "text/x-wiki",
"contentmodel": "wikitext",
"*": "=Test=\nUn script a \u00e9t\u00e9 utilis\u00e9 pour cr\u00e9er un fichier de logs de 30000 entr\u00e9es.\n\n #!/bin/bash\n i=0\n \n echo \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\" > logs.xml\n echo \"<!DOCTYPE logs SYSTEM \\\"logs.dtd\\\">\" >> logs.xml\n echo \"<logs>\" >> logs.xml\n \n while [ $i -lt 10000 ]\n do\n echo \" <log>\" >> logs.xml\n echo \" <date>`date`</date>\" >> logs.xml\n echo \" <login>login$i</login>\" >> logs.xml\n echo \" <droits>droits</droits>\" >> logs.xml\n echo \" <operation>connexion</operation>\" >> logs.xml\n echo \" <tables>\" >> logs.xml\n echo \" </tables>\" >> logs.xml\n echo \" </log>\" >> logs.xml\n \n echo \" <log>\" >> logs.xml\n echo \" <date>`date`</date>\" >> logs.xml\n echo \" <login>login$i</login>\" >> logs.xml\n echo \" <droits>droits</droits>\" >> logs.xml\n echo \" <operation>modification</operation>\" >> logs.xml\n echo \" <tables>\" >> logs.xml\n echo \" <tab id=\\\"table1\\\">\" >> logs.xml\n echo \" <champ id=\\\"champ1\\\">valeur1</champ>\" >> logs.xml\n echo \" </tab>\" >> logs.xml\n echo \" <tab id=\\\"table2\\\">\" >> logs.xml\n echo \" <champ id=\\\"champ2\\\">valeur2</champ>\" >> logs.xml\n echo \" </tab>\" >> logs.xml\n echo \" </tables>\" >> logs.xml\n echo \" </log>\" >> logs.xml\n \n echo \" <log>\" >> logs.xml\n echo \" <date>`date`</date>\" >> logs.xml\n echo \" <login>login$i</login>\" >> logs.xml\n echo \" <droits>droits</droits>\" >> logs.xml\n echo \" <operation>deconnexion</operation>\" >> logs.xml\n echo \" <tables>\" >> logs.xml\n echo \" </tables>\" >> logs.xml\n echo \" </log>\" >> logs.xml\n \n i=$(($i+1))\n done\n \n echo \"</logs>\" >> logs.xml\n\nLa DTD utilis\u00e9e pour le fichier XML \u00e9tant la suivante :\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!ELEMENT logs (log*)>\n <!ELEMENT log (date, login, droits, operation, tables)>\n <!ELEMENT date (#PCDATA)>\n <!ELEMENT login (#PCDATA)>\n <!ELEMENT droits (#PCDATA)>\n <!ELEMENT operation (#PCDATA)>\n <!ELEMENT tables (tab*)>\n <!ELEMENT tab (champ*)>\n <!ATTLIST tab id CDATA #REQUIRED>\n <!ELEMENT champ (#PCDATA)>\n <!ATTLIST champ id CDATA #REQUIRED>\n\nTemps n\u00e9cessaire \u00e0 la cr\u00e9ation du fichier de logs : 1 minute 31 secondes.\n\nEnsuite, un script PHP est utilis\u00e9 pour faire une requ\u00e8te sur le fichier logs.xml cr\u00e9\u00e9 et pour chronometrer le temps necessaire \u00e0 l'obtention du r\u00e9sultat.\nLa requ\u00e8te consiste \u00e0 demander combien d'op\u00e9rations ont \u00e9t\u00e9 effectu\u00e9es par la personne ayant l'identifiant 'login15'.\n\n <?php\n $temps = microtime();\n $temps = explode(' ', $temps);\n $debut = $temps[1] + $temps[0];\n \n $file = \"logs.xml\";\n $depth = array();\n $last_name = \"\";\n $n = 0;\n \n function startElement($parser, $name, $attrs)\n {\n global $depth;\n global $last_name;\n $last_name = $name;\n $depth[$parser]++;\n }\n \n function endElement($parser, $name)\n {\n global $depth;\n $depth[$parser]--;\n }\n \n function characterData($parser, $data)\n {\n global $n;\n global $depth;\n global $last_name;\n if(($last_name == \"LOGIN\") && ($data == \"login15\"))\n {\n $n++;\n }\n }\n \n $xml_parser = xml_parser_create();\n xml_set_element_handler($xml_parser, \"startElement\", \"endElement\");\n xml_set_character_data_handler($xml_parser, \"characterData\");\n \n if(!($fp = fopen($file, \"r\")))\n {\n die(\"could not open XML input\");\n }\n \n while($data = fread($fp, 4096))\n {\n if(!xml_parse($xml_parser, $data, feof($fp)))\n {\n die(sprintf(\"XML error : %s at line %d\", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));\n }\n }\n \n echo 'Nombre d\\'op\u00e9rations effectu\u00e9es par login15 : '.$n.'<br>';\n xml_parser_free($xml_parser);\n \n $temps = microtime();\n $temps = explode(' ', $temps);\n $fin = $temps[1] + $temps[0];\n echo 'Page g\u00e9n\u00e9r\u00e9e en '.round(($fin - $debut), 6).' secondes.';\n ?>\n\n=R\u00e9sultat=\nNombre d'op\u00e9rations eff\u00e9ctu\u00e9es par login15 : 3\n\nLe r\u00e9sultat est exact.\n\n*taille du fichier log : 6.8 Mo\n*temps de traitement de la requ\u00e8te : 5.8 s"
}
]
}
}
}
}