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