PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/adminfct.php

https://bitbucket.org/mw4rf/ajpsc-annuaire
PHP | 91 lines | 30 code | 21 blank | 40 comment | 4 complexity | 6cb148bc5c950ed854c8cdd588472b4e 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. /*
  16. Nom: changer_reponse_secrete
  17. But: Remplace la réponse secrète par le nouveau hash SHA1 pour l'utilisateur spécifié
  18. Info: Guillaume Florimond, 27/02/2007
  19. */
  20. function changer_reponse_secrete($sha1hash, $userid)
  21. {
  22. /* Protection */
  23. if(!isadmin()) return false;
  24. /* Connexion */
  25. connexion();
  26. // Anti injection
  27. $sha1hash = addslashes($sha1hash);
  28. /* Formulation de la requête */
  29. $sql = "UPDATE utilisateur SET secret_reponse='$sha1hash' WHERE id='$userid';";
  30. /* Exécution de la requête */
  31. mysql_query($sql) or die ("Erreur: ".$sql);
  32. /* Tout s'est bien passé: retour true */
  33. return true;
  34. }
  35. /*
  36. Nom: changer_question
  37. But: Change la question d'un utilisateur
  38. Info: Guillaume Florimond, 21/02/2013
  39. */
  40. function changer_question($question, $userid)
  41. {
  42. /* Protection */
  43. if(!isadmin()) return false;
  44. /* Connexion */
  45. connexion();
  46. // Anti injection
  47. $question = addslashes($question);
  48. /* Formulation de la requête */
  49. $sql = "UPDATE utilisateur SET secret_question='$question' WHERE id='$userid';";
  50. /* Exécution de la requête */
  51. mysql_query($sql) or die ("Erreur: ".$sql);
  52. /* Tout s'est bien passé: retour true */
  53. return true;
  54. }
  55. /*
  56. Nom: file_size_info
  57. But: Calcule la taille d'un fichier en octets
  58. Info: http://www.webmasterworld.com/forum88/2069.htm, 02/03/2007
  59. */
  60. function file_size_info($filesize)
  61. {
  62. $bytes = array('Octets', 'Ko', 'Mo', 'Go', 'To');
  63. if ($filesize < 1024) $filesize = 1;
  64. for ($i = 0; $filesize > 1024; $i++)
  65. $filesize /= 1024;
  66. $file_size_info['size'] = ceil($filesize);
  67. $file_size_info['type'] = $bytes[$i];
  68. return $file_size_info;
  69. }
  70. ?>