* 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: databases.php 2459 2009-08-10 21:20:41Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @package Portal
 */
require_once 'include/global.php';
REST::require_method('GET', 'HEAD');
$user_id = Portal_User::current()->user_id();
$result = Portal_MySQL::query(<<<EOS
SELECT DISTINCT `name` FROM `Database`
WHERE `is_shared` > 0
   OR `user_id` = {$user_id}
EOS
);
$action = REST::htmlspecialchars($_SERVER['REQUEST_URI']);
$directory = RESTDir::factory('Available databases (by name)');
while ($row = $result->fetch_row()) {
    $directory->line($row[0] . '/');
}
$directory->end();
<?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();
 * 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: index.php 2471 2009-08-17 20:09:55Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @package Portal
 */
require_once 'include/global.php';
REST::require_method('GET', 'HEAD');
$d = RESTDir::factory();
$d->line('applications/');
$d->line('databases/');
$d->line('databaseTypes/');
//$d->line('delegation/');
$d->line('jobstates/');
//$d->line('login');
$d->line('register');
$d->line('usage');
$d->end();
示例#4
0
文件: tokens.php 项目: sara-nl/ToPoS
<h3>Populate this pool with numbers</h3>
<form action="./" method="post">
<input type="text" name="ntokens"/> #tokens<br/>
<input type="text" name="offset"/> offset<br/>
<input type="submit" value="Populate"/>
</form>
<h3>Move tokens into this pool</h3>
<form action="./" method="post">
<input type="text" name="pool"/> Source pool name<br/>
<input type="text" name="tokens"/> Token IDs (separated by anything)<br/>
<input type="submit" value="Move"/>
</form>
<h3>Create tokens from a parameter list</h3>
<form action="./" method="post">
<textarea name="tokens"></textarea><br/>
<input type="submit" value="Create"/>
</form>
<h3>Create tokens from files</h3>
<form action="./" method="post" enctype="multipart/form-data">
<input type="file" name="create[]" /> File 1<br />
<input type="file" name="create[]" /> File 2<br />
<input type="file" name="create[]" /> File <i>n</i><br />
<input type="submit" value="Post file(s)" />
</form>
EOS;
$directory = RESTDir::factory('Tokens')->setForm($form);
header('X-Token-Count: ' . $result->num_rows);
while ($row = $result->fetch_row()) {
    $directory->line($row[0], array('Size' => $row[1] . ' B', 'Content-Type' => $row[2], 'Original Name' => $row[3], 'LockTokenHTML' => $row[5] > 0 ? "<a href=\"../locks/{$row[4]}\">{$row[4]}</a>" : '', 'Timeout' => $row[5] > 0 ? sprintf('%d:%02d:%02d', $row[5] / 3600, $row[5] / 60 % 60, $row[5] % 60) : '', 'Created' => Topos::sortable_date($row[8]), 'Leases' => $row[7], 'LockDescription' => $row[5] > 0 ? $row[6] : ''));
}
$directory->end();
FROM `Pools` NATURAL JOIN `Tokens`
WHERE `poolName`  = {$escPool};
EOS;
list($ntokens, $nlocks) = Topos::query($query)->fetch_row();
$form = <<<EOS
<h2>Forms</h2>
<h3>Delete</h3>
<form action="./?http_method=DELETE" method="post">
<input type="submit" value="Delete this pool"/>
</form>
<h3>Getting the next token</h3>
<form action="nextToken" method="get">
<input type="text" name="token"/> Token value RegExp<br/>
<input type="text" name="timeout"/> Timeout in seconds (leave empty for shared tokens)<br/>
<input type="text" name="description"/> Lock description (leave empty for shared tokens)<br/>
<input type="submit" value="Get next token"/>
</form>
<h3>Progress bar</h3>
<form action="progress" method="get">
<input type="text" name="total"/> Total number of tokens<br/>
<input type="submit" value="Show progress bar"/>
</form>
EOS;
$t_pool = htmlentities($TOPOS_POOL);
$directory = RESTDir::factory('Pool "' . htmlspecialchars($TOPOS_POOL, ENT_QUOTES, 'UTF-8') . '"')->setForm($form)->setHeaders('Size', 'Description');
$directory->line('tokens/', array('Size' => (int) $ntokens . ' tokens'));
$directory->line('locks/', array('Size' => (int) $nlocks . ' locks'));
$directory->line('nextToken');
#$directory->line('tarball', array('Description' => 'all tokens in a single file'));
$directory->line('progress', array('Description' => 'a progress bar'));
$directory->end();
<?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$
 **************************************************************************/
require_once 'include/global.php';
REST::require_method('HEAD', 'GET');
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    REST::fatal(REST::HTTP_NOT_MODIFIED);
}
$directory = RESTDir::factory()->setHeaders('Description');
$directory->line('pools/', array('Description' => 'A list of all pools. Forbidden for most users, for security reasons.'));
$directory->line('newPool', array('Description' => 'Redirects to a new, empty pool.'));
$directory->line('reference_manual', array('Description' => 'The official reference manual for this version of ToPoS.'));
$directory->end();
 * 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: databases_versions.php 2459 2009-08-10 21:20:41Z pieterb $
 **************************************************************************/
/**
 * File documentation.
 * @package Portal
 */
require_once 'include/global.php';
REST::require_method('GET', 'HEAD');
$user_id = Portal_User::current()->user_id();
$path_info = Portal::path_info();
$dbname = Portal_MySQL::escape_string($path_info[0]);
$result = Portal_MySQL::query(<<<EOS
SELECT DISTINCT(`version`) FROM `Database`
WHERE `name` = {$dbname}
  AND ( `is_shared` > 0 OR `user_id` = {$user_id} );
EOS
);
$directory = RESTDir::factory("{$path_info['0']}: available versions");
while ($row = $result->fetch_row()) {
    $directory->line($row[0] . '/');
}
$directory->end();
 *
 * 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.
 **************************************************************************/
require_once 'include/global.php';
REST::require_method('HEAD', 'GET');
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    REST::fatal(REST::HTTP_NOT_MODIFIED);
}
$directory = RESTDir::factory()->setHeaders('Description')->setForm(<<<EOS
<form action="" method="get" onsubmit="this.action = '/catchplus/' + this.elements.handle.value; this.elements.handle.parentNode.removeChild(this.elements.handle); return true;">
<h2>Resolve a handle</h2>
<div>
Handle: <input type="text" name="handle" />
<input type="checkbox" id="id_handle" name="redirect" value="no" />No redirect<br />
<input type="submit" />
</div>
</form>
EOS
);
#$directory->line( '10574/',           array( 'Description' => 'Everything within this prefix' ) );
$directory->line('reference_manual', array('Description' => 'The official reference manual for this service'));
$directory->line('search', array('Description' => 'Search for a set of handles'));
$directory->end();
    if ($content_type == 'text/plain') {
        REST::header(array('status' => REST::HTTP_CREATED, 'Location' => $fullurl, 'Content-Type' => 'text/plain; charset=US-ASCII'));
        echo $fullurl;
        exit;
    }
    REST::header(array('status' => REST::HTTP_CREATED, 'Location' => $fullurl, 'Content-Type' => REST::best_xhtml_type() . '; charset=US-ASCII'));
    echo Portal::html_start('New database created') . "<a href=\"{$htmlurl}\" rel=\"child\" rev=\"index\">{$htmlurl}</a>" . Portal::html_end();
    exit;
}
REST::require_method('GET', 'HEAD');
$options = '';
foreach (Portal_DB::databaseTypeIDs() as $databaseTypeID) {
    $databaseTypeName = Portal_DB::databaseTypeName($databaseTypeID);
    $options .= "\n<option value=\"{$databaseTypeName}\">{$databaseTypeName}</option>";
}
$directory = RESTDir::factory("{$path_info[0]}, version {$path_info[1]}")->setForm(<<<EOS
<h1>Database upload</h1>
<form method="post" action="./" enctype="multipart/form-data">
<input type="file" name="dbfile" /><br />
<input type="checkbox" name="shared" value="1" /> Share this database with others<br />
Database type: <select name="type">
{$options}
</select><br />
<input type="submit" value="Upload" />
</form>
EOS
);
$user_id = Portal_User::current()->user_id();
$result = Portal_MySQL::query(<<<EOS
SELECT `user_name`, `database_id`, `type` FROM `Database` LEFT JOIN `User` USING(`user_id`)
WHERE `name` = {$dbname}