PageRenderTime 57ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/admin.php

https://bitbucket.org/mw4rf/ajpsc-annuaire
PHP | 314 lines | 264 code | 31 blank | 19 comment | 13 complexity | d97eb76c2dad4a9aeea983fed5ef708f MD5 | raw file
  1. <?php
  2. // Annuaire Alumnii
  3. // Base de données et annuaire d'anciens étudiants.
  4. // Copyright (C) <2006> <Guillaume Florimond>
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. /* Protection première: isadmin()*/
  16. if(!isadmin())
  17. {
  18. dire("admin_badauth");
  19. }
  20. else //if(!isadmin())
  21. {
  22. // Inclure le fichier contenant les fonctions d'administration
  23. include("admin/adminfct.php");
  24. ?>
  25. <!-- En-tête -->
  26. <div class="container hero-unit">
  27. <h1><?php dire("admin_accueil"); ?></h1>
  28. <p style="color:#FF0000;"><?php dire("admin_accueil2"); ?></p>
  29. <p>
  30. <a class="btn btn-large btn-inverse" href="index.php?action=admindeco"><?php dire("admin_menu0a"); ?></a>
  31. </p>
  32. </div>
  33. <!-- Conteneur principal -->
  34. <div class="container">
  35. <ol>
  36. <!-- 2. Statistiques -->
  37. <li>
  38. <p>
  39. <span class="admintitre">
  40. <?php dire("admin_menu3a"); ?>
  41. </span>
  42. <br />
  43. <span class="adminsoustitre"><?php dire("admin_menu3b"); ?></span>
  44. </p>
  45. <!-- Liste des statistiques (conteneur principal) -->
  46. <ul>
  47. <?php connexion(); ?>
  48. <!-- Nombre de fiches -->
  49. <li>
  50. <?php
  51. dire("admin_menu3_1");
  52. //Combien d'enregistrements au total dans la table ? Réponse: $t
  53. $sql = "SELECT * FROM utilisateur;";
  54. $req = mysql_query($sql);
  55. $t = mysql_num_rows($req);
  56. echo ": ".$t;
  57. ?>
  58. </li>
  59. <!-- Taille de la base de données -->
  60. <li>
  61. <?php
  62. dire("admin_menu3_6");
  63. $sql = "SHOW TABLE STATUS;";
  64. $result = mysql_query($sql);
  65. $dbSize = 0; // quelle taille ?
  66. while ($row = mysql_fetch_array($result))
  67. {
  68. $dbSize += $row['Data_length'] + $row['Index_length'];
  69. }
  70. $dbSizeKo = file_size_info($dbSize);
  71. echo ": ".$dbSizeKo['size']." ".$dbSizeKo['type']." ($dbSize Octets)";
  72. ?>
  73. </li>
  74. <!-- Dernière fiche modifiée -->
  75. <li>
  76. <?php
  77. dire("admin_menu3_2");
  78. $sql = "SELECT * FROM utilisateur ORDER BY modif DESC;";
  79. $req = mysql_query($sql);
  80. while($data = mysql_fetch_assoc($req))
  81. {
  82. $id = $data["id"];
  83. $modif = formater_date($data["modif"],false);
  84. $nom = $data["nom"];
  85. $prenom = $data["prenom"];
  86. echo ": <a href=\"index.php?action=page_voir&id=$id\">$prenom $nom</a> ($modif)";
  87. break;
  88. }
  89. ?>
  90. </li>
  91. <!-- Adresse IP -->
  92. <li>
  93. <?php
  94. dire("admin_menu3_3");
  95. echo ": ".$_SERVER["REMOTE_ADDR"];
  96. ?>
  97. </li>
  98. <!-- Server Software -->
  99. <li>
  100. <?php
  101. dire("admin_menu3_4");
  102. echo ": ".$_SERVER["SERVER_SOFTWARE"];
  103. ?>
  104. </li>
  105. <!-- Langue -->
  106. <li>
  107. <?php
  108. dire("admin_menu3_5");
  109. echo ": ".$_SERVER["HTTP_ACCEPT_LANGUAGE"];
  110. ?>
  111. </li>
  112. <!-- Php info -->
  113. <li>
  114. <a href="admin/phpinfo.php">PHP Info</a>
  115. </li>
  116. </ul>
  117. </li>
  118. <!-- 3. Version Papier -->
  119. <li>
  120. <p>
  121. <span class="admintitre">
  122. <?php dire("admin_menu4a"); ?>
  123. </span>
  124. <br />
  125. <span class="adminsoustitre"><?php dire("admin_menu4b"); ?></span>
  126. </p>
  127. <ol>
  128. <!-- Aide -->
  129. <li>
  130. <a href="index.php?action=page_aide&page=faq#8.8"><?php dire("admin_menu4_0"); ?></a>
  131. </li>
  132. <!-- Exportation MySQL -->
  133. <li>
  134. <a href="export/csvexport.php"><?php dire("admin_menu4_1"); ?></a>
  135. </li>
  136. <!-- Modèles MS Word -->
  137. <li>
  138. <a href="msword/"><?php dire("admin_menu4_2"); ?></a>
  139. </li>
  140. </ol>
  141. </li>
  142. <!-- 4. Générer le hash SHA1 -->
  143. <li>
  144. <p>
  145. <span class="admintitre"><?php dire("admin_menu1a"); ?></span>
  146. <br />
  147. <span class="adminsoustitre"><?php dire("admin_menu1b"); ?></span>
  148. </p>
  149. <form id="sha1" name="sha1" method="post" action="index.php?action=admin&op=sha1">
  150. <input name="sha1phrase" type="text" size="30"
  151. value="<?php if(isset($_POST["sha1phrase"]))
  152. { echo stripslashes($_POST["sha1phrase"]); }
  153. ?>"
  154. />
  155. <input type="submit" name="Submit" value="<?php dire("admin_menu1c"); ?>" />
  156. </form>
  157. <?php
  158. // On affiche le hash sha1 après soumission du formulaire
  159. if(isset($_GET["op"]) and isset($_POST["sha1phrase"]) and $_GET["op"] == "sha1")
  160. {
  161. ?>
  162. <p>
  163. <?php dire("admin_resultat"); ?>:&nbsp;
  164. <span class="adminresultat">
  165. <?php echo sha1(stripslashes($_POST["sha1phrase"])); ?>
  166. </span>
  167. </p>
  168. <?php
  169. }
  170. ?>
  171. </li>
  172. <!-- 5. Insérer le hash SHA1 (réponse secrète) -->
  173. <li>
  174. <p>
  175. <span class="admintitre"><?php dire("admin_menu2a"); ?></span>
  176. <br />
  177. <span class="adminsoustitre"><?php dire("admin_menu2b"); ?></span>
  178. </p>
  179. <form id="sha1" name="sha1" method="post" action="index.php?action=admin&op=repsecrt">
  180. <b><?php dire("admin_menu2c"); ?></b>&nbsp;
  181. <input
  182. name="sha1hash"
  183. type="text"
  184. size="50"
  185. value="<?php
  186. if(isset($_POST["sha1phrase"]))
  187. { echo sha1(stripslashes($_POST["sha1phrase"])); }
  188. ?>" />
  189. <br />
  190. <?php dire("admin_menu2d"); ?>
  191. <input name="iduser" type="text" size="5" />
  192. <br />
  193. <input type="submit" name="Submit" value="<?php dire("admin_menu2e"); ?>" />
  194. </form>
  195. <?php
  196. // On affiche le résultat après soumission du formulaire
  197. if(isset($_GET["op"]) and isset($_POST["sha1hash"]) and isset($_POST["iduser"])
  198. and $_GET["op"] == "repsecrt")
  199. {
  200. if(changer_reponse_secrete($_POST["sha1hash"], $_POST["iduser"]))
  201. {
  202. ?>
  203. <p>
  204. <?php dire("admin_resultat"); ?>:&nbsp;
  205. <span class="adminresultat">
  206. <?php dire("admin_menu2f"); ?>
  207. </span>
  208. </p>
  209. <?php
  210. }
  211. else
  212. {
  213. dire("admin_erreur");
  214. }
  215. }
  216. ?>
  217. </li>
  218. <!-- 6. Question secrète -->
  219. <li>
  220. <p>
  221. <span class="admintitre">Changer la question d'un utilisateur</span>
  222. </p>
  223. <form id="sha1" name="sha1" method="post" action="index.php?action=admin&op=chquestion">
  224. Insérer la question suivante&nbsp;
  225. <input
  226. name="question"
  227. type="text"
  228. size="50"
  229. value="" />
  230. <br />
  231. <?php dire("admin_menu2d"); ?>
  232. <input name="iduser" type="text" size="5" />
  233. <br />
  234. <input type="submit" name="Submit" value="<?php dire("admin_menu2e"); ?>" />
  235. </form>
  236. <?php
  237. // On affiche le résultat après soumission du formulaire
  238. if(isset($_GET["op"]) and isset($_POST["sha1hash"]) and isset($_POST["iduser"])
  239. and $_GET["op"] == "repsecrt")
  240. {
  241. if(changer_reponse_secrete($_POST["sha1hash"], $_POST["iduser"]))
  242. {
  243. ?>
  244. <p>
  245. <?php dire("admin_resultat"); ?>:&nbsp;
  246. <span class="adminresultat">
  247. <?php dire("admin_menu2f"); ?>
  248. </span>
  249. </p>
  250. <?php
  251. }
  252. else
  253. {
  254. dire("admin_erreur");
  255. }
  256. }
  257. // Changer la question de l'utilisateur
  258. if(isset($_GET["op"]) and isset($_POST["question"]) and isset($_POST["iduser"])
  259. and $_GET["op"] == "chquestion")
  260. {
  261. if(changer_question($_POST["question"], $_POST["iduser"]))
  262. {
  263. ?>
  264. <p>
  265. La question a bien été changée !
  266. </p>
  267. <?php
  268. }
  269. else
  270. {
  271. dire("admin_erreur");
  272. }
  273. }
  274. ?>
  275. </li>
  276. <!-- FIN conteneur principal -->
  277. </div>
  278. <?php
  279. //--
  280. }
  281. ?>