} foreach ($rows[0] as $key => $value) { $vm[$key] = $value; } foreach ($rows as $row) { require_once LIBRARIES . 'solusvm.class.php'; $svm = new SolusVM(); $svm->setProtocol($vm['is_https'] ? 'https' : 'http'); $svm->setHost($vm['host']); $svm->setPort($vm['port']); $svm->setKey($vm['key']); $svm->setHash($vm['hash']); switch ($action) { case 'boot': $result = $svm->boot(); $message = str_replace('%name%', $vm['label'], VM_HAS_BEEN_BOOTED); break; case 'reboot': $result = $svm->reboot(); $message = str_replace('%name%', $vm['label'], VM_HAS_BEEN_REBOOTED); break; case 'shutdown': $result = $svm->shutdown(); $message = str_replace('%name%', $vm['label'], VM_HAS_BEEN_SHUTDOWN); break; } if (!$result || $result['status'] != 'success') { die(json_encode(array('status' => 'error', 'message' => '<p class="red">' . CONNECTION_ERROR_WHEN_ACCESSING . '</p>'))); } die(json_encode(array('status' => 'ok', 'message' => '<p class="green">' . $message . '</p>'))); }