htpasswd.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 Export page htpasswd of the membership file
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
  26. // Security check
  27. if (!$user->rights->adherent->export) accessforbidden();
  28. /*
  29. * View
  30. */
  31. llxHeader();
  32. $now = dol_now();
  33. if (empty($sortorder)) { $sortorder = "ASC"; }
  34. if (empty($sortfield)) { $sortfield = "d.login"; }
  35. if (!isset($statut))
  36. {
  37. $statut = 1;
  38. }
  39. if (!isset($cotis))
  40. {
  41. // by default, members must be up to date of subscription
  42. $cotis = 1;
  43. }
  44. $sql = "SELECT d.login, d.pass, d.datefin";
  45. $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d ";
  46. $sql .= " WHERE d.statut = ".$statut;
  47. if ($cotis == 1)
  48. {
  49. $sql .= " AND datefin > '".$db->idate($now)."'";
  50. }
  51. $sql .= $db->order($sortfield, $sortorder);
  52. //$sql.=$db->plimit($conf->liste_limit, $offset);
  53. $resql = $db->query($sql);
  54. if ($resql)
  55. {
  56. $num = $db->num_rows($resql);
  57. $i = 0;
  58. print_barre_liste($langs->trans("HTPasswordExport"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0);
  59. print "<hr>\n";
  60. while ($i < $num)
  61. {
  62. $objp = $db->fetch_object($result);
  63. $htpass = crypt($objp->pass, makesalt());
  64. print $objp->login.":".$htpass."<br>\n";
  65. $i++;
  66. }
  67. print "<hr>\n";
  68. }
  69. else
  70. {
  71. dol_print_error($db);
  72. }
  73. // End of page
  74. llxFooter();
  75. $db->close();