<?php require 'api.php'; $solus = new Solus('http://defensiveservers.com', 'key', 'pass'); try { $db = new PDO('mysql:host=localhost;dbname=DBNAME;charset=utf8', 'DBUSER', 'DBPASS'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); } catch (PDOException $e) { die($e->getMessage()); } $nodeNames = array(8 => 5, 10 => 7, 11 => 8); $nodeIDs = array(8 => 0, 10 => 0, 11 => 0); $pGroupCount = array(5 => 0, 7 => 0, 8 => 0); $pGroupLimit = array(5 => 4, 7 => 4, 8 => 4); $planNames = array("KVM VPS Bronze" => 20, "KVM VPS Silver" => 40, "KVM VPS Gold" => 80, "KVM VPS Platinum" => 140); foreach ($nodeNames as $nID => $pID) { $ipcount = json_decode($solus->getNodeIPs($nID))->ipcount; if ($ipcount == 0) { $nodeIDs[$nID] = 1; } else { $nodeStats = json_decode($solus->nodeStats($nID)); $gbLeft = number_format($nodeStats->freedisk / 1048576, 2); foreach ($planNames as $planName => $planGB) { if ($gbLeft < $planGB) { echo "Stock 0 for {$planName} Group ID {$pID}<br />"; $stmt = $db->prepare("UPDATE `defensiv_whmcs`.`tblproducts` SET `qty` = '0' WHERE `configoption4` = ? AND `gid` = ?"); $stmt->execute(array($planName, $pID)); $pGroupCount[$pID]++; } else { echo "Stock <1 for {$planName} Groupe ID {$pID}<br />"; $stmt = $db->prepare("UPDATE `defensiv_whmcs`.`tblproducts` SET `qty` = '10' WHERE `name` = ? AND `gid` = ?");
<?php /** * @fileoverview * @author daxingplay<*****@*****.**> * @time: 1/26/14 11:22 * @description */ require_once "lib/solus.class.php"; if (!file_exists('./config.php')) { echo 'cannot find config file. please copy config.sample.php as config.php.'; exit; } $config = (require_once './config.php'); foreach ($config['servers'] as $server_config) { $server = new Solus($server_config['api'], $server_config['key'], $server_config['hash']); $status = $server->status(); $ip = $status['ipaddress']; $hostname = $status['hostname']; if ($status['statusmsg'] === 'online') { echo $hostname . ' is running.'; } else { echo $hostname . ' is down. trying to boot...'; $result = $server->boot(); if ($result) { echo $hostname . ' is running.'; } else { echo $hostname . ' boot failed.'; } } echo "\n";