1
0

devices_apply.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. $page_url = null;
  6. if (getPOST("ApplyForAll", $page_url) !== null) {
  7. $dev_id = getPOST("fid", $page_url, []);
  8. $a_dev_type = (int)getPOST("a_dev_type", $page_url, 0);
  9. $a_device_model_id = (int)getPOST("a_device_model_id", $page_url, 0);
  10. $a_building_id = (int)getPOST("a_building_id", $page_url, 0);
  11. $a_snmp_version = (int)getPOST("a_snmp_version", $page_url, 0);
  12. $a_ro_community = trim(getPOST("a_ro_community", $page_url, 'public'));
  13. $a_rw_community = trim(getPOST("a_rw_community", $page_url, 'private'));
  14. $msg = "Massive change devices!";
  15. LOG_WARNING($db_link, $msg);
  16. $all_ok = true;
  17. foreach ($dev_id as $val) {
  18. $id = (int)$val;
  19. if ($id <= 0) {
  20. continue;
  21. }
  22. $device = [];
  23. if (getPOST("e_set_type", $page_url) !== null) {
  24. $device['device_type'] = $a_dev_type;
  25. }
  26. if (getPOST("e_set_model", $page_url) !== null) {
  27. $device['device_model_id'] = $a_device_model_id;
  28. $device['vendor_id'] = get_device_model_vendor($db_link, $a_device_model_id);
  29. }
  30. if (getPOST("e_set_snmp_version", $page_url) !== null) {
  31. $device['snmp_version'] = $a_snmp_version;
  32. }
  33. if (getPOST("e_set_ro_community", $page_url) !== null) {
  34. $device['community'] = $a_ro_community;
  35. }
  36. if (getPOST("e_set_rw_community", $page_url) !== null) {
  37. $device['rw_community'] = $a_rw_community;
  38. }
  39. if (getPOST("e_set_building", $page_url) !== null) {
  40. $device['building_id'] = $a_building_id;
  41. }
  42. if (!empty($device)) {
  43. $ret = update_record($db_link, "devices", "id = ?", $device, [$id]);
  44. if (!$ret) {
  45. $all_ok = false;
  46. }
  47. }
  48. }
  49. echo $all_ok ? "Success!" : "Fail!";
  50. }
  51. ?>