function create() { $ret = false; // Check if it passes the encryption proof $is = $_REQUEST['is']; $e = $_REQUEST['e']; $p = $_REQUEST['p']; $salt = "aB1cD2eF3G_&\$^%+"; $proof = md5($e . $is . $salt); if ($proof != $p) { die("Error: Illegal attempt."); } // Store params $instance = base64_decode($_REQUEST['is']); $name = base64_decode($_REQUEST['n']); $email = base64_decode($_REQUEST['e']); $password = $_REQUEST['w']; $source = base64_decode($_REQUEST['s']); $adword = base64_decode($_REQUEST['a']); // Initialize cupid $cupid = new Cupid(); $cupid->init(); // Create Instance if ($cupid->createInstance($instance, $email, $name, $password, $source, $adword)) { $ret = true; } else { // There was an error echo "Error: Instance creation unsuccessful"; } // Close connection $cupid->disconnect(); return $ret; }
function isInstanceReady($instance) { // Get Status $cupid = new Cupid(); $cupid->init(); $inst_status = $cupid->getInstanceStatus($instance); $cupid->disconnect(); // If the instance is Ready // -> Go to the Instance domain and begin // If the instance is not created // -> Go to Trial // If the instance is being set up // -> Continue with welcome $ret = ''; switch ($inst_status) { case 'INSTANCE_LIVE': // Do the redirect thing $ret = json_encode(array('ready' => true)); break; case 'INSTANCE_NEW': $ret = json_encode(array('ready' => false, 'status' => 'pending')); break; case 'INSTANCE_MAINTENANCE': $ret = json_encode(array('ready' => false, 'status' => 'down')); break; case 'NULL': // Do the redirect thing $ret = json_encode(array('ready' => true)); break; } return $ret; }