예제 #1
0
파일: exec.php 프로젝트: GElkayam/server
function parseInputObject(SimpleXMLElement $input = null)
{
    global $inFile;
    if (is_null($input)) {
        return null;
    }
    if (isset($input['null']) && $input['null']) {
        return KalturaClient::getKalturaNullValue();
    }
    $type = 'string';
    if (isset($input['objectType'])) {
        $type = strval($input['objectType']);
    }
    $value = strval($input);
    $matches = null;
    if (preg_match('/\\{prompt:([^}]+)\\}/', $value, $matches)) {
        $userInput = askForUserParameter($matches[1]);
        $value = preg_replace('/\\{prompt:[^}]+\\}/', $userInput, $value);
    }
    if (preg_match('/\\{php:([^}]+)\\}/', $value, $matches)) {
        $value = eval($matches[1]);
    }
    if (preg_match('/\\{variable:([^}]+)\\}/', $value, $matches)) {
        global $variables;
        $value = isset($variables[$matches[1]]) ? $variables[$matches[1]] : null;
    }
    if (isset($input['path'])) {
        $path = $input['path'];
        if (!file_exists($path)) {
            $path = dirname($inFile) . '/' . $path;
            if (!file_exists($path)) {
                echo "File [{$path}] could not be found\n";
                exit(-1);
            }
        }
        $value = file_get_contents($path);
    }
    switch ($type) {
        case 'string':
            return $value;
        case 'int':
            return intval($value);
        case 'bool':
            return (bool) $value;
        case 'file':
            if (file_exists($value)) {
                return realpath($value);
            }
            $value = dirname($inFile) . '/' . $value;
            if (file_exists($value)) {
                return realpath($value);
            }
            echo "File [{$value}] could not be found\n";
            exit(-1);
        case 'array':
            return parseInputArray($input->item);
    }
    if (!class_exists($type)) {
        echo "Type [{$type}] could not be found\n";
        exit(-1);
    }
    $object = new $type();
    $properties = $input->children();
    foreach ($properties as $property) {
        /* @var $property SimpleXMLElement */
        $propertyName = $property->getName();
        $object->{$propertyName} = parseInputObject($property);
    }
    return $object;
}
    $partnerId = intval($inXml->session->partnerId);
    $secret = strval($inXml->session->secret);
    $sessionType = intval($inXml->session->sessionType);
    $userId = isset($inXml->session->userId) ? strval($inXml->session->userId) : '';
    $expiry = isset($inXml->session->expiry) ? intval($inXml->session->expiry) : 86400;
    $privileges = isset($inXml->session->privileges) ? strval($inXml->session->privileges) : '';
    $email = isset($inXml->session->email) ? $inXml->session->email : null;
    $password = isset($inXml->session->password) ? $inXml->session->password : null;
    if ($secret) {
        $ks = generateSession($secret, $userId, $sessionType, $partnerId, $expiry, $privileges);
    } else {
        if (!$email) {
            $email = askForUserParameter('Partner email address:');
        }
        if (!$password) {
            $password = askForUserParameter('Partner password:'******'multirequest') {
        $client->startMultiRequest();
        foreach ($element->request as $request) {
            executeRequest($client, $request);
        }
        echo "Executing multirequest\n";
        $multiResponse = $client->doMultiRequest();