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