本文整理汇总了PHP中REST::http_date方法的典型用法代码示例。如果您正苦于以下问题:PHP REST::http_date方法的具体用法?PHP REST::http_date怎么用?PHP REST::http_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类REST
的用法示例。
在下文中一共展示了REST::http_date方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
<th class="modified">timestamp</th>
</tr>
EOS;
foreach ($handle->type as $idx => $type) {
if (strpos($type, 'HS_') === 0) {
continue;
}
echo '<tr><td class="idx">' . $idx . '</td><td class="type">' . htmlspecialchars($type, ENT_COMPAT, 'UTF-8') . '</td><td class="data">';
if ($type == 'URL' && REST::isValidURI($handle->data[$idx])) {
echo '<a href="' . $handle->data[$idx] . '">' . htmlspecialchars($handle->data[$idx]) . '</a>';
} elseif ($type == 'EMAIL') {
echo '<a href="mailto:' . $handle->data[$idx] . '">' . htmlspecialchars($handle->data[$idx]) . '</a>';
} else {
echo $handle->data[$idx] === mb_convert_encoding(mb_convert_encoding($handle->data[$idx], 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32') ? htmlspecialchars($handle->data[$idx], ENT_COMPAT, 'ISO-8859-1') : '<pre>' . htmlspecialchars(addcslashes($handle->data[$idx], "\\..\t\v....ÿ"), ENT_COMPAT, 'ISO-8859-1') . '</pre>';
}
echo '</td><td class="refs">' . htmlspecialchars($handle->refs[$idx]) . '</td><td class="modified">' . REST::http_date($handle->timestamp[$idx]) . "</td></tr>\n";
}
echo '</tbody></table>' . REST::html_end();
} elseif ($content_type == 'application/json') {
$json = array();
foreach ($handle->type as $idx => $type) {
if (strpos($type, 'HS_') !== 0) {
// Was: $type != 'HS_ADMIN'
$json[$idx] = array('type' => (string) $type, 'data' => (string) $handle->data[$idx], 'timestamp' => (int) $handle->timestamp[$idx], 'refs' => (string) $handle->refs[$idx]);
}
}
echo json_encode($json);
exit;
} elseif ($content_type == 'application/x-www-form-urlencoded') {
$pairs = array();
foreach ($handle->type as $idx => $type) {
示例2: tempnam
$tmpfilename = tempnam('/tmp', 'portal_');
$tmpfile = fopen($tmpfilename, 'w');
while (($block = fread(REST::inputhandle(), 8192)) !== "") {
fwrite($tmpfile, $block);
}
fclose(REST::inputhandle());
fclose($tmpfile);
if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] != filesize($tmpfilename)) {
unlink($tmpfilename);
REST::fatal(REST::HTTP_BAD_REQUEST, "Content-Length header doesn't match actual content length.");
}
if (!rename($tmpfilename, Portal::JOBRESULTS_DIR . $jobid)) {
unlink($tmpfilename);
REST::fatal(REST::HTTP_INTERNAL_SERVER_ERROR, "Couldn't store uploaded file.");
}
chmod(Portal::JOBRESULTS_DIR . $jobid, 0660);
REST::header(array('status' => REST::HTTP_NO_CONTENT));
exit;
}
// The user tries to get information about his jobs
if (file_exists($fullfilename = Portal::JOBRESULTS_DIR . $jobid)) {
// The job has finished and we have a result
$filename = basename($fullfilename);
$fileinfo = @stat($fullfilename);
REST::header(array('Content-Type' => 'application/x-compressed-tar', 'Content-Disposition' => "attachment; filename=\"{$filename}.tgz\"", 'Last-Modified' => REST::http_date($fileinfo['mtime']), 'Content-Length' => $fileinfo['size']));
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
readfile($fullfilename);
}
exit;
}
REST::fatal(REST::HTTP_NOT_FOUND);
示例3: IF
REST::fatal(REST::HTTP_NOT_FOUND);
}
}
REST::require_method('HEAD', 'GET');
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
REST::fatal(REST::HTTP_NOT_MODIFIED);
}
$query = <<<EOS
SELECT `tokenValue`, `tokenType`, `tokenCreated`, `tokenName`,
IF(`tokenLockTimeout` > UNIX_TIMESTAMP(),`tokenLockUUID`,NULL)
FROM `Pools` NATURAL JOIN `Tokens` NATURAL JOIN `TokenValues`
WHERE `poolName` = {$escPool}
AND `tokenId` = {$TOPOS_TOKEN};
EOS;
$result = Topos::query($query);
if (!($row = $result->fetch_row())) {
REST::fatal(REST::HTTP_NOT_FOUND);
}
$headers = array('Content-Type' => $row[1], 'Content-Length' => strlen($row[0]), 'Last-Modified' => REST::http_date($row[2]));
if (!empty($row[3])) {
$headers['Content-Disposition'] = 'inline; filename="' . $row[3] . '"';
}
if ($row[4]) {
$headers['X-Topos-OpaqueLockToken'] = "opaquelocktoken:{$row[4]}";
$headers['X-Topos-LockURL'] = Topos::urlbase() . 'pools/' . REST::urlencode($TOPOS_POOL) . '/locks/' . $row[4];
}
REST::header($headers);
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
echo $row[0];
示例4: IF
$result = Topos::query(<<<EOS
SELECT `tokenLength`, `tokenType`, `tokenCreated`, `tokenName`,
IF(`tokenLockTimeout` > UNIX_TIMESTAMP(), `tokenLockUUID`, NULL) AS 'tokenLockUUID', `tokenLeases`
FROM `Tokens`
WHERE `tokenId` = {$TOPOS_TOKEN}
AND `poolId` = {$poolId};
EOS
);
if (!($row = $result->fetch_array())) {
REST::fatal(REST::HTTP_NOT_FOUND);
}
$result = Topos::query(<<<EOS
SELECT `tokenValue` FROM `TokenValues`
WHERE `tokenId` = {$TOPOS_TOKEN}
EOS
);
$tokenValue = $result->fetch_row();
$tokenValue = $tokenValue[0];
$headers = array('Content-Type' => $row['tokenType'], 'Content-Length' => $row['tokenLength'], 'Last-Modified' => REST::http_date($row['tokenCreated']), 'X-Number-Of-Leases' => $row['tokenLeases']);
if (!empty($row['tokenName'])) {
$headers['Content-Disposition'] = 'inline; filename="' . $row['tokenName'] . '"';
}
if (array_key_exists('tokenLockUUID', $row)) {
$headers['X-Topos-OpaqueLockToken'] = "opaquelocktoken:{$row['tokenLockUUID']}";
$headers['X-Topos-LockURL'] = Topos::urlbase() . 'pools/' . REST::urlencode($TOPOS_POOL) . '/locks/' . $row['tokenLockUUID'];
}
REST::header($headers);
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
echo $tokenValue;
示例5: explode
}
REST::require_method('GET', 'HEAD');
$path_info = Portal::path_info();
if (count($path_info) != 3) {
REST::fatal(REST::HTTP_NOT_FOUND);
}
$file = explode('.', $path_info[2], 2);
if (!($database_id = (int) $file[0])) {
REST::fatal(REST::HTTP_NOT_FOUND);
}
$user_id = Portal_User::current()->user_id();
$result = Portal_MySQL::query(<<<EOS
SELECT `d`.`name`,
`d`.`version`,
`d`.`type`,
`d`.`checksum`,
`u`.`user_name`
FROM `Database` AS d LEFT JOIN `User` AS u USING(`user_id`)
WHERE `d`.`database_id` = {$database_id}
AND (`d`.`user_id` = {$user_id} OR `d`.`is_shared` = 1);
EOS
);
if (!($row = $result->fetch_row())) {
REST::fatal(REST::HTTP_NOT_FOUND);
}
$fileinfo = @stat($realfilepath);
$filename = "{$row[0]}-{$row[1]}." . Portal_DB::databaseTypeExtension($row[2]);
REST::header(array('Content-Type' => Portal_DB::databaseTypeContentType($row[2]), 'Content-Encoding' => 'identity', 'Content-Disposition' => "attachment; filename=\"{$filename}\"", 'Last-Modified' => REST::http_date($fileinfo['mtime']), 'ETag' => "\"{$row[3]}\"", 'X-Creator-Name' => $row[4], 'Content-Length' => $fileinfo['size']));
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
readfile($realfilepath);
}