index.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. $msg_error = "";
  5. if (isset($_POST["create"])) {
  6. $login = $_POST["newlogin"];
  7. if ($login) {
  8. $customer = get_record_sql($db_link,"Select * from Customers WHERE LCase(Login)=LCase('$login')");
  9. if (!empty($customer)) {
  10. $msg_error = "Login $login already exists!";
  11. LOG_INFO($db_link, $msg_error);
  12. unset($_POST);
  13. } else {
  14. $new['Login'] = $login;
  15. $new['api_key'] = randomPassword(20);
  16. LOG_INFO($db_link, "Create new login: $login");
  17. $id = insert_record($db_link, "Customers", $new);
  18. if (!empty($id)) { header("Location: editcustom.php?id=$id"); exit; }
  19. }
  20. }
  21. header("Location: " . $_SERVER["REQUEST_URI"]);
  22. exit;
  23. }
  24. if (isset($_POST["remove"])) {
  25. $fid = $_POST["fid"];
  26. foreach ($fid as $key => $val) {
  27. if ($val) {
  28. LOG_INFO($db_link, "Remove login with id: $val");
  29. delete_record($db_link, "Customers", "id=" . $val);
  30. }
  31. }
  32. header("Location: " . $_SERVER["REQUEST_URI"]);
  33. exit;
  34. }
  35. unset($_POST);
  36. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  37. print_control_submenu($page_url);
  38. ?>
  39. <div id="cont">
  40. <br>
  41. <form name="def" action="index.php" method="post">
  42. <b><?php echo WEB_custom_index_title; ?></b>
  43. <table class="data">
  44. <tr align="center">
  45. <td width="30"><input type="checkbox" onClick="checkAll(this.checked);"></td>
  46. <td><b>Login</b></td>
  47. </tr>
  48. <?php
  49. $users = get_records($db_link,'Customers','True ORDER BY Login');
  50. foreach ($users as $row) {
  51. $cl = "data";
  52. print "<tr align=center>\n";
  53. print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
  54. print "<td class=\"$cl\" align=left width=200><a href=editcustom.php?id=".$row['id'].">" . $row['Login'] . "</a></td>\n";
  55. }
  56. ?>
  57. </table>
  58. <table class="data">
  59. <tr>
  60. <td><input type=text name=newlogin value="Unknown"></td>
  61. <td><input type="submit" name="create" value="<?php echo WEB_btn_add; ?>"></td>
  62. <td align="right"><input type="submit" onclick="return confirm('<?php print WEB_btn_delete; ?>?')" name="remove" value="<?php print WEB_btn_remove; ?>"></td>
  63. </tr>
  64. </table>
  65. </form>
  66. <?php
  67. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  68. ?>