case "register": if (isset($_POST["fname"]) && isset($_POST["lname"]) && isset($_POST["password"]) && isset($_POST["email"])) { return true; } return false; case "logout": return true; } } /* Switchboard block for the login script. -Checks to make sure the POST request is valid -Switches to the correct function, expects the "function" flag to be set in the POST body -Generally methods in this script are accessed via a form POST request */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (validatePost()) { session_start(); switch ($_POST["function"]) { case "login": doLogin(); break; case "register": doRegister(); break; case "logout": doLogout(); break; } } }
/** Handle POST data from form, and feed it into the session. Should only be called internally by RackTables upon clicking the View's submit button */ function discoverVMs() { global $profiler; $profiler->marker("begin discoverVMs"); global $sesskey; set_time_limit(300); // set session session_start(); // clear out the last run, to remove any accumulated detritus $_SESSION[$sesskey] = array(); // nope, we can't have broken anything just yet. $errors = FALSE; // switch on the import type switch ($_POST['importtype']) { case 'mass': $profiler->marker("discoverVMs - mass scan selected"); // validate and massage mass import data $postKeys = array("xenMasters", "xenUser", "xenPass"); $errors = validatePost($postKeys); if (!$errors) { // create masters array $tmpmasters = explode("\n", $_POST['xenMasters']); foreach ($tmpmasters as $master) { $new['host'] = $master; $new['user'] = $_POST['xenUser']; $new['pass'] = $_POST['xenPass']; $xenMasters[] = $new; $profiler->marker("discoverVMs - scheduled to check " . $new['host']); } //$_SESSION[$sesskey]['xenMasters'] = $xenMasters; } break; case 'perhost': $profiler->marker("discoverVMs - per-host scan selected"); // validate and massage per-host data $postKeys = array("masterlist"); $errors = validatePost($postKeys); if (!$errors) { // create masters array foreach ($_POST['masterlist'] as $masterjson) { $master = json_decode($masterjson); $new['host'] = $master->host; $new['user'] = $master->user; $new['pass'] = $master->pass; $xenMasters[] = $new; $profiler->marker("discoverVMs - scheduled to check " . $new['host']); } } break; case 'file': $_SESSION[$sesskey]['errors'][] = "File import not implemented!"; return FALSE; break; } // check for processing errors if ($errors) { // abandon ship! abort this function and show the errors. they're in the session, so no cleanup needed return FALSE; } else { // no errors? great! clear the errors list just in case the user corrected them from a previous run unset($_SESSION[$sesskey]['errors']); } // add the tags to our session so they persist $_SESSION[$sesskey]['vmpool_tag'] = $_POST['pooltags'][0]; $_SESSION[$sesskey]['vm_tag'] = $_POST['vmtags'][0]; $profiler->marker("discoverVMs - about to include xencrawl"); // import the xen library and init the crawler include dirname(__FILE__) . '/include/xencrawl.php'; $crawler = new XenCrawler(); // crawl the xen pool, and save it to the session foreach ($xenMasters as $master) { try { $profiler->marker("discoverVMs - crawling " . $master['host']); // attempt to crawl, and catch errors $_SESSION[$sesskey]['vms'][] = $crawler->crawl($master['host'], $master['user'], $master['pass']); $profiler->marker("discoverVMs - finished " . $master['host']); } catch (APIException $e) { // add the error to the list, and mooooove on $_SESSION[$sesskey]['errors'][] = "XENAPI Error from " . $master['host'] . " : " . $e->getMessage(); $profiler->marker("discoverVMs - Error crawling " . $master['host']); continue; } } $profiler->marker("end discoverVMs"); /* $_SESSION[$sesskey]['vms'] = array( array( "name" => "VMPoolSample01", "virtuals" => array( array("name" => "potato", "ip" => "172.16.1.1", "vmuuid" => "abcdef", "ostype" => "someOS") ) ) ); */ }
$text = strip_tags($text); $text = htmlspecialchars($text, ENT_QUOTES); return $text; //output clean text } /* Gather submitted payment card details send them for cleaning and validation*/ $cardType = validatePost($_POST['cardType']); $cardholderName = validatePost($_POST['cardholderName']); $cardNumber = validatePost($_POST['cardNumber']); $cardCVC = validatePost($_POST['cardCVC']); $cardexpDate_mo = validatePost($_POST['expDate_Month']); $cardexpDate_yr = validatePost($_POST['expDate_Year']); $cardExp = $cardexpDate_mo . $cardexpDate_yr; $cardstartDate_mo = validatePost($_POST['startDate_Month']); $cardstartDate_yr = validatePost($_POST['startDate_Year']); $cardStart = $cardstartDate_mo . $cardstartDate_yr; $cardIssue = validatePost($_POST['cardIssue']); $currency = new Currency(intval(isset($_POST['currency_payement']) ? $_POST['currency_payement'] : $cookie->id_currency)); $total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', '')); $ccpayment = new ccpayment(); if ($cart->id_customer == 0 or $cart->id_address_delivery == 0 or $cart->id_address_invoice == 0 or !$ccpayment->active) { Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1'); } $customer = new Customer((int) $cart->id_customer); //$ccpayment->validateOrder($cart->id, _PS_OS_PREPARATION_, $total, $ccpayment->displayName, NULL, NULL, $currency->id); //s$ccpayment->validateOrder((int)($cart->id), _PS_OS_PREPARATION_, $total, $ccpayment->displayName, NULL, $mailVars, (int)($currency->id), false, $customer->secure_key); $ccpayment->validateOrder((int) $cart->id, _PS_OS_PREPARATION_, $total, $ccpayment->displayName, NULL, array(), (int) $currency->id, false, $customer->secure_key); $order = new Order($ccpayment->currentOrder); echo $order->id; $ccpayment->writePaymentcarddetails($order->id, $cardType, $cardholderName, $cardNumber, $cardCVC, $cardExp, $cardStart, $cardIssue); Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $cart->id . '&id_module=' . $ccpayment->id . '&id_order=' . $ccpayment->currentOrder . '&key=' . $order->secure_key);