Exemplo n.º 1
0
function deleteDirectory($dir)
{
    if (!file_exists($dir)) {
        return true;
    }
    if (!is_dir($dir)) {
        return unlink($dir);
    }
    foreach (scandir($dir) as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
            return false;
        }
    }
    return rmdir($dir);
}
//loop through all directories in sessions to see if they are older than 24 hours
foreach (glob("sessions/*") as $filename) {
    //86400 seconds is 24 hours
    if (filemtime($filename) < time() - 86400) {
        deleteDirectory($filename);
    }
}
//loop through all directories in cr2g server to see if they are older than 24 hours
//executes script on cr2g to do the clean up of all old sessions
$ssh->exec("cd /code/spopt-stable; python cleanup.py 1 tests/\n");
//function to parse final output file
parseOutput($session);
Exemplo n.º 2
0
function generateOptions($params)
{
    if ($_GET["page_id"] == PAGE_2) {
        $cmd = 'blender -b /usr/lib/blender/scripts/addons/blend.blend -P';
        $cmd .= ' /usr/lib/blender/scripts/addons/' . SCRIPT . ' -- ';
    } else {
        if ($_GET["page_id"] == PAGE_2_ALT) {
            $cmd = 'blender -b /usr/lib/blender/scripts/addons/blend.blend -P';
            $cmd .= ' /usr/lib/blender/scripts/addons/' . SCRIPT_ALT . ' -- ';
        }
    }
    $cmd .= "options.data " . formatParams($params);
    $output = array();
    exec($cmd, $output);
    $options = parseOutput($output);
    if ($options != false) {
        usort($options, 'compareSlack');
    }
    return $options;
}
$soap_do = curl_init("https://americas.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/AirService");
$header = array("Content-Type: text/xml;charset=UTF-8", "Accept: gzip,deflate", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: \"\"", "Authorization: Basic {$auth}", "Content-length: " . strlen($message));
//curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 30);
//curl_setopt($soap_do, CURLOPT_TIMEOUT, 30);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $message);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
// this will prevent the curl_exec to return result and will let us to capture output
$return = curl_exec($soap_do);
$file = "001-" . $Provider . "_AirAvailabilityRsp.xml";
// file name to save the response xml for test only(if you want to save the request/response)
$content = prettyPrint($return, $file);
parseOutput($content);
//print '<br>';
//echo $return;
//print '<br>';
//print_r(curl_getinfo($soap_do));
//Pretty print XML
function prettyPrint($result, $file)
{
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    $dom->loadXML($result);
    $dom->formatOutput = true;
    //call function to write request/response in file
    outputWriter($file, $dom->saveXML());
    return $dom->saveXML();
}
//Execute the Search request in the flow
include_once 'phpSample_index.php';
//
// Sample Hotel Search request parameters:
//
$CHECKINDATE = $_SESSION["CHECKIN"];
// Checkin Date
$CHECKOUTDATE = $_SESSION["CHECKOUT"];
// Checkout Date
$NUMADULTS = $_SESSION["NUMADULTS"];
//Common Parameters
$PROVIDER = $_SESSION["PROVIDER"];
$TARGETBRANCH = $_SESSION["TARGETBRANCH"];
$message = "";
// variable to store the request
parseOutput();
//Call the function to parse previous response
function parseOutput()
{
    //parse the Search response to get values to use in detail request
    //$hotelSearchRsp = file_get_contents('001_HotelAvailabilityRsp.xml');
    $hotelSearchRsp = $_SESSION["content"];
    //use this if response is not saved anywhere else use above variable
    $xml = simplexml_load_String("{$hotelSearchRsp}", null, null, 'SOAP', true);
    if (!$xml) {
        //trigger_error("Encoding Error!", E_USER_ERROR);
        header("Location: http://LocationOfErrorPage/projects/Hotel/error.php");
        //Use the Location of the error page
    }
    $Results = $xml->children('SOAP', true);
    foreach ($Results->children('SOAP', true) as $fault) {