htpasswd.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/adherents/htpasswd.php
  21. * \ingroup member
  22. * \brief Page d'export htpasswd du fichier des adherents
  23. * \author Rodolphe Quiedeville
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
  27. // Security check
  28. if (! $user->rights->adherent->export) accessforbidden();
  29. /*
  30. * View
  31. */
  32. llxHeader();
  33. $now=dol_now();
  34. if (empty($sortorder)) { $sortorder="ASC"; }
  35. if (empty($sortfield)) { $sortfield="d.login"; }
  36. if (! isset($statut))
  37. {
  38. $statut = 1 ;
  39. }
  40. if (! isset($cotis))
  41. {
  42. // by default, members must be up to date of subscription
  43. $cotis=1;
  44. }
  45. $sql = "SELECT d.login, d.pass, d.datefin";
  46. $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d ";
  47. $sql .= " WHERE d.statut = $statut ";
  48. if ($cotis==1)
  49. {
  50. $sql .= " AND datefin > '".$db->idate($now)."'";
  51. }
  52. $sql.= $db->order($sortfield, $sortorder);
  53. //$sql.=$db->plimit($conf->liste_limit, $offset);
  54. $resql = $db->query($sql);
  55. if ($resql)
  56. {
  57. $num = $db->num_rows($resql);
  58. $i = 0;
  59. print_barre_liste($langs->trans("HTPasswordExport"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0);
  60. print "<hr>\n";
  61. while ($i < $num)
  62. {
  63. $objp = $db->fetch_object($result);
  64. $htpass=crypt($objp->pass, makesalt());
  65. print $objp->login.":".$htpass."<br>\n";
  66. $i++;
  67. }
  68. print "<hr>\n";
  69. }
  70. else
  71. {
  72. dol_print_error($db);
  73. }
  74. // End of page
  75. llxFooter();
  76. $db->close();