index.php 2.7 KB

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