Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. {php}
  2. $customfields = $this->_tpl_vars["customfields"];
  3. foreach ($customfields AS $customfield) {
  4. if ($customfield["name"]=="APCIP") { $apcip = $customfield["value"]; }
  5. if ($customfield["name"]=="APCPort") { $apcport = $customfield["value"]; }
  6. if ($customfield["name"]=="GraphID") { $graphid = $customfield["value"]; }
  7. if ($customfield["name"]=="Username") { $username = $customfield["value"]; }
  8. if ($customfield["name"]=="Password") { $password = $customfield["value"]; }
  9. if ($customfield["name"]=="Server ID(s)") { $serverid = $customfield["value"]; }
  10. if ($customfield["name"]=="RDP / SSH Port") { $rdpssh = $customfield["value"]; }
  11. if ($customfield["name"]=="Server IP(s)") { $serverip = $customfield["value"]; }
  12. if ($customfield["name"]=="Hostname") { $hostname = $customfield["value"]; }
  13. if ($customfield["name"]=="Monitor Name") { $mon_name = $customfield["value"]; }
  14. if ($customfield["name"]=="Monitor Host") { $mon_host = $customfield["value"]; }
  15. if ($customfield["name"]=="Monitor Type") { $mon_port = $customfield["value"]; }
  16. if ($customfield["name"]=="Server Port(s)") { $switch_port = $customfield["value"]; }
  17. if ($customfield["name"]=="Monitor") { $monitorenable = $customfield["value"]; }
  18. if ($customfield["name"]=="Email for Alerts") { $mon_email = $customfield["value"]; }
  19. if ($customfield["name"]=="Mobile for Alerts") { $mon_mob = $customfield["value"]; }
  20. if ($customfield["name"]=="vserverid") { $vserverid = $customfield["value"]; }
  21. }
  22.  
  23. $filename = '/home/admin/domains/rr_users/'.$serverid.'';
  24.  
  25.  
  26. if (file_exists($filename)) {
  27. echo "To Prevent File System Corruption we now limit reboots to one per five minutes";
  28. $reboot_chk = "1";
  29. echo "reboot $reboot_chk";
  30. } else {
  31. echo "The file $filename does not exist";
  32. $reboot_chk = "0";
  33. }
  34.  
  35. if ($reboot_chk == 0 && $_REQUEST["controlaction"]) {
  36. $apcport = explode(',',$apcport);
  37. foreach ($apcport as $port) {
  38. $apcport = str_replace(',','',$port);
  39. $shell_command = "snmpset -v 1 -c WHMCS_Reboot000 $apcip 1.3.6.1.4.1.318.1.1.4.4.2.1.3.$apcport i ".$_REQUEST["controlaction"]; echo "<p align=center><b>Your power command has now been processed! Test Test</b><br /></p>";
  40. $return=array();
  41. exec($shell_command, $return);
  42. $time = time() - 3600;
  43. $filename = '/home/admin/domains/rr_users/'.$serverid.'';
  44. touch($filename, $time);
  45. echo "reboot $reboot_chk";
  46. }
  47. }
  48.  
  49. if ($reboot_chk == 1)
  50. {
  51. system("find /home/admin/domains/rr_users/ -mmin +6 -exec rm -f {} \;");
  52. }
  53. {/php}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement