list_user.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <!-- Begin toolbar -->
  2. <div class="toolbar">
  3. <div class="toolbar-inner">
  4. <div class="toolbar-buttons">
  5. <a href="/add/user/" class="button button-secondary js-button-create">
  6. <i class="fas fa-circle-plus icon-green"></i><?= _("Add User") ?>
  7. </a>
  8. <a href="/list/package/" class="button button-secondary">
  9. <i class="fas fa-box-open icon-orange"></i><?= _("Packages") ?>
  10. </a>
  11. </div>
  12. <div class="toolbar-right">
  13. <div class="toolbar-sorting">
  14. <button class="toolbar-sorting-toggle js-toggle-sorting-menu" type="button" title="<?= _("Sort items") ?>">
  15. <?= _("Sort by") ?>:
  16. <span class="u-text-bold">
  17. <?php if ($_SESSION['userSortOrder'] === 'name') { $label = _('Name'); } else { $label = _('Date'); } ?>
  18. <?= $label ?> <i class="fas fa-arrow-down-a-z"></i>
  19. </span>
  20. </button>
  21. <ul class="toolbar-sorting-menu animate__animated animate__fadeIn js-sorting-menu u-hidden">
  22. <li data-entity="sort-bandwidth" data-sort-as-int="1">
  23. <span class="name"><?= _("Bandwidth") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  24. </li>
  25. <li data-entity="sort-date" data-sort-as-int="1">
  26. <span class="name <?php if ($_SESSION['userSortOrder'] === 'date') { echo 'active'; } ?>"><?= _("Date") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  27. </li>
  28. <li data-entity="sort-disk" data-sort-as-int="1">
  29. <span class="name"><?= _("Disk") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  30. </li>
  31. <li data-entity="sort-name">
  32. <span class="name <?php if ($_SESSION['userSortOrder'] === 'name') { echo 'active'; } ?>"><?= _("Name") ?> <i class="fas fa-arrow-down-a-z"></i></span><span class="up"><i class="fas fa-arrow-up-a-z"></i></span>
  33. </li>
  34. </ul>
  35. <form x-data x-bind="BulkEdit" action="/bulk/user/" method="post">
  36. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  37. <select class="form-select" name="action">
  38. <option value=""><?= _("Apply to selected") ?></option>
  39. <option value="rebuild"><?= _("Rebuild All") ?></option>
  40. <option value="rebuild user"><?= _("Rebuild User Profile") ?></option>
  41. <option value="rebuild web"><?= _("Rebuild Web Domains") ?></option>
  42. <option value="rebuild dns"><?= _("Rebuild DNS Zones") ?></option>
  43. <option value="rebuild mail"><?= _("Rebuild Mail Domains") ?></option>
  44. <option value="rebuild db"><?= _("Rebuild Databases") ?></option>
  45. <option value="rebuild cron"><?= _("Rebuild Cron Jobs") ?></option>
  46. <option value="update counters"><?= _("Update Usage Counters") ?></option>
  47. <option value="suspend"><?= _("Suspend") ?></option>
  48. <option value="unsuspend"><?= _("Unsuspend") ?></option>
  49. <option value="delete"><?= _("Delete") ?></option>
  50. </select>
  51. <button type="submit" class="toolbar-input-submit" title="<?= _("Apply to selected") ?>">
  52. <i class="fas fa-arrow-right"></i>
  53. </button>
  54. </form>
  55. </div>
  56. <div class="toolbar-search">
  57. <form action="/search/" method="get">
  58. <input type="hidden" name="token" value="<?= $_SESSION["token"] ?>">
  59. <input type="search" class="form-control js-search-input" name="q" value="<? echo isset($_POST['q']) ? htmlspecialchars($_POST['q']) : '' ?>" title="<?= _("Search") ?>">
  60. <button type="submit" class="toolbar-input-submit" title="<?= _("Search") ?>">
  61. <i class="fas fa-magnifying-glass"></i>
  62. </button>
  63. </form>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <!-- End toolbar -->
  69. <div class="container">
  70. <h1 class="u-text-center u-hide-desktop u-mt20 u-pr30 u-mb20 u-pl30"><?= _("Users") ?></h1>
  71. <div class="units-table js-units-container">
  72. <div class="units-table-header">
  73. <div class="units-table-cell">
  74. <input type="checkbox" class="js-toggle-all-checkbox" title="<?= _("Select all") ?>">
  75. </div>
  76. <div class="units-table-cell"><?= _("Name") ?></div>
  77. <div class="units-table-cell"></div>
  78. <div class="units-table-cell u-text-center"><?= _("Package") ?></div>
  79. <div class="units-table-cell u-text-center"><?= _("IPs") ?></div>
  80. <div class="units-table-cell u-text-center">
  81. <i class="fas fa-hard-drive" title="<?= _("Disk") ?>"></i>
  82. <span class="u-hidden-visually"><?= _("Disk") ?></span>
  83. </div>
  84. <div class="units-table-cell u-text-center">
  85. <i class="fas fa-right-left" title="<?= _("Bandwidth") ?>"></i>
  86. <span class="u-hidden-visually"><?= _("Bandwidth") ?></span>
  87. </div>
  88. <div class="units-table-cell compact u-text-center">
  89. <i class="fas fa-earth-americas" title="<?= _("Web Domains") ?>"></i>
  90. <span class="u-hidden-visually"><?= _("Web Domains") ?></span>
  91. </div>
  92. <div class="units-table-cell compact u-text-center">
  93. <i class="fas fa-book-atlas" title="<?= _("DNS Zones") ?>"></i>
  94. <span class="u-hidden-visually"><?= _("DNS Zones") ?></span>
  95. </div>
  96. <div class="units-table-cell compact u-text-center">
  97. <i class="fas fa-envelopes-bulk" title="<?= _("Mail Domains") ?>"></i>
  98. <span class="u-hidden-visually"><?= _("Mail Domains") ?></span>
  99. </div>
  100. <div class="units-table-cell compact u-text-center">
  101. <i class="fas fa-database" title="<?= _("Databases") ?>"></i>
  102. <span class="u-hidden-visually"><?= _("Databases") ?></span>
  103. </div>
  104. <div class="units-table-cell compact u-text-center">
  105. <i class="fas fa-file-zipper" title="<?= _("Backups") ?>"></i>
  106. <span class="u-hidden-visually"><?= _("Backups") ?></span>
  107. </div>
  108. </div>
  109. <!-- Begin user list item loop -->
  110. <?php
  111. foreach ($data as $key => $value) {
  112. ++$i;
  113. if ($data[$key]['SUSPENDED'] == 'yes') {
  114. $status = 'suspended';
  115. $spnd_action = 'unsuspend';
  116. $spnd_action_title = _('Unsuspend');
  117. $spnd_icon = 'fa-play';
  118. $spnd_icon_class = 'icon-green';
  119. $spnd_confirmation = _('Are you sure you want to unsuspend user %s?');
  120. } else {
  121. $status = 'active';
  122. $spnd_action = 'suspend';
  123. $spnd_action_title = _('Suspend');
  124. $spnd_icon = 'fa-pause';
  125. $spnd_icon_class = 'icon-highlight';
  126. $spnd_confirmation = _('Are you sure you want to suspend user %s?');
  127. }
  128. ?>
  129. <div class="units-table-row <?php if ($status == 'suspended') echo 'disabled'; ?> animate__animated animate__fadeIn js-unit <?php if (($_SESSION['POLICY_SYSTEM_HIDE_ADMIN'] === 'yes') && ($_SESSION['user'] !== 'admin') && ($key === 'admin')) { echo 'u-hidden'; } ?>"
  130. data-sort-date="<?= strtotime($data[$key]['DATE'].' '.$data[$key]['TIME']) ?>"
  131. data-sort-name="<?= strtolower($key) ?>"
  132. data-sort-bandwidth="<?= $data[$key]["U_BANDWIDTH"] ?>"
  133. data-sort-disk="<?= $data[$key]["U_DISK"] ?>">
  134. <div class="units-table-cell">
  135. <div>
  136. <input id="check<?= $i ?>" class="js-unit-checkbox" type="checkbox" title="<?= _("Select") ?>" name="user[]" value="<?= $key ?>">
  137. <label for="check<?= $i ?>" class="u-hide-desktop"><?= _("Select") ?></label>
  138. </div>
  139. </div>
  140. <div class="units-table-cell units-table-heading-cell">
  141. <span class="u-hide-desktop u-text-bold"><?= _("Name") ?>:</span>
  142. <?php if ($key == $user_plain) { ?>
  143. <a href="/edit/user/?user=<?= $key ?>&token=<?= $_SESSION["token"] ?>" title="<?= _("Edit User") ?>">
  144. <span class="u-text-bold">
  145. <?= $key ?>
  146. </span>
  147. (<?= $data[$key]["NAME"] ?>)
  148. </a>
  149. <?php } else { ?>
  150. <a href="/login/?loginas=<?= $key ?>&token=<?= $_SESSION["token"] ?>" title="<?= _("Log in as") ?> <?= $key ?>">
  151. <span class="u-text-bold">
  152. <?= $key ?>
  153. </span>
  154. (<?= $data[$key]["NAME"] ?>)
  155. </a>
  156. <?php } ?>
  157. <p class="u-max-width200 u-text-truncate">
  158. <span class="u-hide-desktop u-text-bold"><?= _("Email") ?>:</span>
  159. <span title="<?= $data[$key]["CONTACT"] ?>"><?= $data[$key]["CONTACT"] ?></span>
  160. </p>
  161. </div>
  162. <div class="units-table-cell">
  163. <ul class="units-table-row-actions">
  164. <?php if ($key == $user_plain) { ?>
  165. <li class="units-table-row-action">
  166. <i class="fas fa-user-check icon-dim" title="<?= $key ?> (<?= $data[$key]["NAME"] ?>)"></i>
  167. <span class="u-hide-desktop"><?= $key ?> (<?= $data[$key]["NAME"] ?>)</span>
  168. </li>
  169. <?php } else { ?>
  170. <li class="units-table-row-action">
  171. <a
  172. class="units-table-row-action-link"
  173. href="/login/?loginas=<?= $key ?>&token=<?= $_SESSION["token"] ?>"
  174. title="<?= _("Log in as") ?> <?= $key ?>"
  175. >
  176. <i class="fas fa-right-to-bracket icon-green"></i>
  177. <span class="u-hide-desktop"><?= _("Log in as") ?> <?= $key ?></span>
  178. </a>
  179. </li>
  180. <?php } ?>
  181. <?php if (!($_SESSION["userContext"] === "admin" && $key == "admin" && $_SESSION["user"] != "admin")) { ?>
  182. <li class="units-table-row-action shortcut-enter" data-key-action="href">
  183. <a
  184. class="units-table-row-action-link"
  185. href="/edit/user/?user=<?= $key ?>&token=<?= $_SESSION["token"] ?>"
  186. title="<?= _("Edit User") ?>"
  187. >
  188. <i class="fas fa-pencil icon-orange"></i>
  189. <span class="u-hide-desktop"><?= _("Edit User") ?></span>
  190. </a>
  191. </li>
  192. <?php } ?>
  193. <?php if (!($key == "admin" || $key == $user_plain)) { ?>
  194. <li class="units-table-row-action shortcut-s" data-key-action="js">
  195. <a
  196. class="units-table-row-action-link data-controls js-confirm-action"
  197. href="/<?= $spnd_action ?>/user/?user=<?= $key ?>&token=<?= $_SESSION["token"] ?>"
  198. title="<?= $spnd_action_title ?>"
  199. data-confirm-title="<?= $spnd_action_title ?>"
  200. data-confirm-message="<?= sprintf($spnd_confirmation, $key) ?>"
  201. >
  202. <i class="fas <?= $spnd_icon ?> <?= $spnd_icon_class ?>"></i>
  203. <span class="u-hide-desktop"><?= $spnd_action_title ?></span>
  204. </a>
  205. </li>
  206. <li class="units-table-row-action shortcut-delete" data-key-action="js">
  207. <a
  208. class="units-table-row-action-link data-controls js-confirm-action"
  209. href="/delete/user/?user=<?= $key ?>&token=<?= $_SESSION["token"] ?>"
  210. title="<?= _("Delete") ?>"
  211. data-confirm-title="<?= _("Delete") ?>"
  212. data-confirm-message="<?= sprintf(_("Are you sure you want to delete user %s?"), $key) ?>"
  213. >
  214. <i class="fas fa-trash icon-red"></i>
  215. <span class="u-hide-desktop"><?= _("Delete") ?></span>
  216. </a>
  217. </li>
  218. <?php } ?>
  219. </ul>
  220. </div>
  221. <div class="units-table-cell u-text-bold u-text-center-desktop">
  222. <span class="u-hide-desktop"><?= _("Package") ?>:</span>
  223. <?php if ($data[$key]["PACKAGE"] === "system") { ?>
  224. <?= $data[$key]["PACKAGE"] ?>
  225. <?php } else { ?>
  226. <a href="/edit/package/?package=<?= $data[$key]["PACKAGE"] ?>&token=<?= $_SESSION["token"] ?>" title="<?= _("Edit Package") ?>">
  227. <?= $data[$key]["PACKAGE"] ?>
  228. </a>
  229. <?php } ?>
  230. </div>
  231. <div class="units-table-cell u-text-center-desktop">
  232. <span class="u-hide-desktop u-text-bold"><?= _("IPs") ?>:</span>
  233. <?= $data[$key]["IP_OWNED"] ?>
  234. </div>
  235. <div class="units-table-cell u-text-center-desktop u-text-no-wrap">
  236. <span class="u-hide-desktop u-text-bold"><?= _("Disk") ?>:</span>
  237. <span class="u-text-bold">
  238. <?= humanize_usage_size($data[$key]["U_DISK"], 1) ?>
  239. </span>
  240. <span class="u-text-small">
  241. <?= humanize_usage_measure($data[$key]["U_DISK"]) ?>
  242. </span> /
  243. <span class="u-text-bold">
  244. <?= humanize_usage_size($data[$key]["DISK_QUOTA"], 1) ?>
  245. </span>
  246. <span class="u-text-small">
  247. <?= humanize_usage_measure($data[$key]["DISK_QUOTA"]) ?>
  248. </span>
  249. </div>
  250. <div class="units-table-cell u-text-center-desktop u-text-no-wrap">
  251. <span class="u-hide-desktop u-text-bold"><?= _("Bandwidth") ?>:</span>
  252. <span class="u-text-bold">
  253. <?= humanize_usage_size($data[$key]["U_BANDWIDTH"], 1) ?>
  254. </span>
  255. <span class="u-text-small">
  256. <?= humanize_usage_measure($data[$key]["U_BANDWIDTH"]) ?>
  257. </span> /
  258. <span class="u-text-bold">
  259. <?= humanize_usage_size($data[$key]["BANDWIDTH"], 1) ?>
  260. </span>
  261. <span class="u-text-small">
  262. <?= humanize_usage_measure($data[$key]["BANDWIDTH"]) ?>
  263. </span>
  264. </div>
  265. <div class="units-table-cell compact u-text-center-desktop">
  266. <span class="u-hide-desktop u-text-bold"><?= _("Web Domains") ?>:</span>
  267. <span class="badge">
  268. <?= $data[$key]["U_WEB_DOMAINS"] ?>
  269. </span>
  270. </div>
  271. <div class="units-table-cell compact u-text-center-desktop">
  272. <span class="u-hide-desktop u-text-bold"><?= _("DNS Zones") ?>:</span>
  273. <span class="badge">
  274. <?= $data[$key]["U_DNS_DOMAINS"] ?>
  275. </span>
  276. </div>
  277. <div class="units-table-cell compact u-text-center-desktop">
  278. <span class="u-hide-desktop u-text-bold"><?= _("Mail Domains") ?>:</span>
  279. <span class="badge">
  280. <?= $data[$key]["U_MAIL_DOMAINS"] ?>
  281. </span>
  282. </div>
  283. <div class="units-table-cell compact u-text-center-desktop">
  284. <span class="u-hide-desktop u-text-bold"><?= _("Databases") ?>:</span>
  285. <span class="badge">
  286. <?= $data[$key]["U_DATABASES"] ?>
  287. </span>
  288. </div>
  289. <div class="units-table-cell compact u-text-center-desktop">
  290. <span class="u-hide-desktop u-text-bold"><?= _("Backups") ?>:</span>
  291. <span class="badge">
  292. <?= $data[$key]["U_BACKUPS"] ?>
  293. </span>
  294. </div>
  295. </div>
  296. <?php } ?>
  297. </div>
  298. </div>
  299. <footer class="app-footer">
  300. <div class="container app-footer-inner">
  301. <p>
  302. <?php printf(ngettext("%d user account", "%d user accounts", $i), $i); ?>
  303. </p>
  304. </div>
  305. </footer>