Пример #1
0
function getDataJson()
{
    if (isset($_GET['sfrom'])) {
        $jordanGUID = $_GET['jordanGUID'];
        $domain = $_GET['domain'];
        $protocol = $_GET['protocol'];
        $path = $_GET['path'];
        $location = $protocol . $domain . $path;
        $sfrom = $_GET['sfrom'];
        initConnection($db_config);
        //redis 使用
        require '../Predis/Autoloader.php';
        Predis\Autoloader::register();
        $redis = new Predis\Client(array('database' => '0', 'host' => '49.4.129.122', 'port' => 6379));
        $datestr = date("Y_m_d_H");
        $tableName = "request_" . $datestr;
        if ($redis->get("tableName") != $tableName) {
            create_request($tableName);
            $redis->set("tableName", $tableName);
        }
        $request_datetime = date('Y-m-d H:i:s', time());
        writeLog('../logs/' . $tableName . '.log', "{$jordanGUID}\t{$domain}\t{$location}\t{$request_datetime}\n", "a");
        insert_request_entry($jordanGUID, $domain, $location, $sfrom, $request_datetime, $tableName);
        insert_request_entry($jordanGUID, $domain, $location, $sfrom, $request_datetime, "request");
        //echo "success";
    } else {
        //echo "failure";
    }
}
Пример #2
0
function insert_datastore($text)
{
    include_once "config.php";
    $scopes = ["https://www.googleapis.com/auth/datastore", "https://www.googleapis.com/auth/userinfo.email"];
    $client = new Google_Client();
    $client->setApplicationName($google_api_config['application-id']);
    $client->setAssertionCredentials(new Google_Auth_AssertionCredentials($google_api_config['service-account-name'], $scopes, $google_api_config['private-key']));
    $service = new Google_Service_Datastore($client);
    $service_dataset = $service->datasets;
    $dataset_id = $google_api_config['dataset-id'];
    $hashtext = $text . date("Y-m-d H:i:s");
    $hashkey = hash('adler32', $hashtext, false) . hash('crc32', $hashtext, false);
    try {
        $req = create_request($hashkey, $text);
        $service_dataset->commit($dataset_id, $req, []);
    } catch (Google_Exception $ex) {
        syslog(LOG_WARNING, 'Commit to Cloud Datastore exception: ' . $ex->getMessage());
    }
}
Пример #3
0
function test_requests_for_url($url, $context_type, $context_id)
{
    global $signer;
    $insert_result = create_request($url, $signer, $context_type, $context_id, RQ_REQUEST_TYPE::JOIN, 'foobar', '');
    error_log("IR = " . print_r($insert_result, true));
    $request_id = $insert_result;
    $rows = get_requests_for_context($url, $signer, $context_type, $context_id);
    dump_rows($rows);
    $rows = get_requests_by_user($url, $signer, $signer->account_id, $context_type, $context_id);
    dump_rows($rows);
    $row = get_request_by_id($url, $signer, $request_id, $context_type);
    dump_row($row);
    $num_pending = get_number_of_pending_requests_for_user($url, $signer, $signer->account_id, $context_type, $context_id);
    error_log("Num_pending(pre) = " . print_r($num_pending, true));
    $pending = get_pending_requests_for_user($url, $signer, $signer->account_id, $context_type, $context_id);
    dump_rows($pending);
    resolve_pending_request($url, $signer, $context_type, $request_id, RQ_REQUEST_STATUS::APPROVED, 'resolved');
    $num_pending = get_number_of_pending_requests_for_user($url, $signer, $signer->account_id, $context_type, $context_id);
    error_log("Num_pending(post) = " . print_r($num_pending, true));
}
Пример #4
0
// confirm member is not already in this project
$pids = get_projects_for_member($sa_url, $user, $user->account_id, true);
if (isset($pids) && !is_null($pids) && in_array($project_id, $pids)) {
    error_log($user->prettyName() . " already in project " . $project_id);
    $_SESSION['lasterror'] = "You are already in this project.";
    relative_redirect("project.php?project_id={$project_id}");
}
// confirm member has not already requested to join this project
$rpids = get_requests_by_user($sa_url, $user, $user->account_id, CS_CONTEXT_TYPE::PROJECT, $project_id, RQ_REQUEST_STATUS::PENDING);
if (in_array($project_id, $rpids)) {
    error_log($user->prettyName() . " already requested to join project " . $project_id);
    $_SESSION['lasterror'] = "You already requested to join that project.";
    relative_redirect('home.php');
}
if (isset($message) && !is_null($message) && (!isset($error) || is_null($error))) {
    $request_id = create_request($sa_url, $user, CS_CONTEXT_TYPE::PROJECT, $project_id, RQ_REQUEST_TYPE::JOIN, $message);
    // FIXME: sub handle-project-request.php with handle-project-request.php?project_id=$project_id&member_id=$user->account_id&request_id=$request_id
    //  $ind = strpos($message, "handle-project-request.php");
    $hostname = $_SERVER['SERVER_NAME'];
    $message .= "To handle my request, go to the GENI Portal here:\nhttps://{$hostname}/secure/handle-project-request.php?project_id={$project_id}&member_id=" . $user->account_id . "&request_id={$request_id}\n\nRemember that when you approve this request, you agree to take\nresponsibility for my use of GENI resources within the project. \nYou should not approve unsolicited requests to join your project.\n\nThank you,\n" . $user->prettyName() . "\n";
    //  $message = substr_replace($message, "handle-project-request.php?project_id=" . $project_id . "&member_id=" . $user->account_id . "&request_id=" . $request_id, $ind, strlen("handle-project-request.php"));
    // Log the request
    // contexts include project and member
    $project_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::PROJECT, $project_id);
    $member_attributes = get_attribute_for_context(CS_CONTEXT_TYPE::MEMBER, $user->account_id);
    $attributes = array_merge($project_attributes, $member_attributes);
    if (!isset($log_url)) {
        $log_url = get_first_service_of_type(SR_SERVICE_TYPE::LOGGING_SERVICE);
        if (!isset($log_url) || is_null($log_url) || $log_url == '') {
            error_log("Found no Log Service in SR!'");
        }
Пример #5
0
/**
 * @param array $params
 * @param $reattempts
 * @param $attempt
 * @return mixed
 */
function request_internal($aconnect, $params = array(), $reattempts, $attempt)
{
    $xmlresponse = create_request($aconnect, $params, true);
    $status = false;
    if (!empty($xmlresponse)) {
        $xml = new SimpleXMLElement($xmlresponse);
        $status = $xml->status[0]['code'];
    }
    if (0 != strcmp('ok', $status)) {
        // Handle various error codes
        // Internal-error is a server error, should reattempt the request.
        if (0 == strcmp('internal-error', $status)) {
            if ($attempt < $reattempts) {
                usleep(300000 * $attempt);
                $status = request_internal($aconnect, $params, $reattempts, $attempt + 1);
            }
        }
    }
    return $status;
}
Пример #6
0
 */
if (ENOLA_MODE == 'HTTP') {
    /*
     * Lee los controladores de la variable config. En caso de que no haya controladores avisa del error
     * Me quedo con el controlador que mapea
     */
    $controllers = $config['controllers'];
    $GLOBALS['controllers'] = $config['controllers'];
    $actual_controller = NULL;
    if (count($controllers) > 0) {
        $actual_controller = mapping_controller($controllers);
    } else {
        general_error('Controller Error', 'There isent define any controller');
    }
    //Creo el HTTP REQUEST correspondiente en base a la URL que mapeo
    create_request($actual_controller['url']);
    /*
     * Lee los filtros que se deben ejecutar antes del procesamiento de la variable config y delega trabajo a archivo filtros.php
     * En caso de que no haya filtros asignados no delega ningun trabajo
     */
    $filtros = $config['filters'];
    $GLOBALS['filters'] = $filtros;
    $filtros_despues = $config['filters_after_processing'];
    $GLOBALS['filters_after_processing'] = $filtros_despues;
    if (count($filtros) > 0) {
        execute_filters($filtros);
    }
    /**
     *Ejecuto el controlador correspondiente 
     */
    execute_controller($actual_controller);