/**
  * Parses $_SERVER['PATH_INFO'] and returns an array.
  * @return array
  */
 public static function path_info()
 {
     if (self::$path_info === null) {
         self::$path_info = empty($_SERVER['PATH_INFO']) ? array() : explode('/', substr($_SERVER['PATH_INFO'], 1));
     }
     return self::$path_info;
 }
<?php

/*·*************************************************************************
 * Copyright ©2009 SARA Computing and Networking Services
 *                 Amsterdam, the Netherlands
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * $Id: applications_versions.php 2459 2009-08-10 21:20:41Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @package Portal
 */
require_once 'include/global.php';
require_once 'portal_app.php';
REST::require_method('GET', 'HEAD');
$directory = RESTDir::factory();
list($appname, $dummy) = Portal::path_info();
foreach (Portal_App::versions($appname) as $version) {
    $directory->line($version, array('Description' => "{$appname} version {$version}"));
}
$directory->end();
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * $Id: jobresult.php 2471 2009-08-17 20:09:55Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @package Portal
 */
require_once 'include/global.php';
REST::require_method('GET', 'HEAD', 'PUT');
$user_id = Portal_User::current()->user_id();
$path_info = Portal::path_info();
$jobid = $path_info[0];
$escjobid = Portal_MySQL::escape_string($jobid);
$escuserid = Portal_MySQL::escape_string($user_id);
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
    if (strpos(@$_SERVER['CONTENT_TYPE'], 'application/x-compressed-tar') !== 0) {
        REST::fatal(REST::HTTP_UNSUPPORTED_MEDIA_TYPE);
    }
    // The job wants to put its results on the portal server
    $tmpfilename = tempnam('/tmp', 'portal_');
    $tmpfile = fopen($tmpfilename, 'w');
    while (($block = fread(REST::inputhandle(), 8192)) !== "") {
        fwrite($tmpfile, $block);
    }
    fclose(REST::inputhandle());
    fclose($tmpfile);