auth_export.php 1.8 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/auth.php");
  3. require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/languages/" . HTML_LANG . ".php");
  4. if (!defined("CONFIG")) die("Not defined");
  5. if (isset($_POST["ExportAuth"])) {
  6. print "login;ip;mac;comment;dns name;last_found;connected\n";
  7. if (isset($_POST["a_selected"]) and $_POST["a_selected"] * 1) {
  8. //export selected only
  9. $auth_id = $_POST["fid"];
  10. foreach ($auth_id as $key => $val) {
  11. if ($val) {
  12. $sSQL = "SELECT User_list.login, User_auth.ip, User_auth.mac, User_auth.comments, User_auth.dns_name, User_auth.last_found FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.id = " . $val;
  13. $record = get_record_sql($db_link, $sSQL);
  14. print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] . ';' . get_connection_string($db_link, $val)."\n";
  15. }
  16. }
  17. } else {
  18. //export all
  19. $ip_filter = '';
  20. $sort = 'User_auth.ip_int';
  21. if (!empty($_POST["ip-filter"])) { $ip_filter = $_POST['ip-filter']; }
  22. if (!empty($_POST["ip-sort"])) { $sort = $_POST['ip-sort']; }
  23. $sSQL = "SELECT User_auth.*, User_list.login, User_list.enabled as UEnabled, User_list.blocked as UBlocked FROM User_auth, User_list WHERE User_auth.user_id = User_list.id AND User_auth.deleted = 0 $ip_filter ORDER BY $sort";
  24. $auth_table = mysqli_query($db_link, $sSQL);
  25. while ($record = mysqli_fetch_array($auth_table)) {
  26. print $record['login'] . ';' . $record['ip'] . ';' . $record['mac'] . ';' . $record['comments'] . ';' . $record['dns_name'] . ';' . $record['last_found'] .';' . get_connection_string($db_link, $record['id']). "\n";
  27. }
  28. }
  29. }