本文整理汇总了PHP中REST::urlencode方法的典型用法代码示例。如果您正苦于以下问题:PHP REST::urlencode方法的具体用法?PHP REST::urlencode怎么用?PHP REST::urlencode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类REST
的用法示例。
在下文中一共展示了REST::urlencode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: html_start
public static function html_start($title)
{
$title = REST::htmlspecialchars($title);
$t_index = REST::urlencode(dirname($_SERVER['REQUEST_URI']));
if ($t_index != '/') {
$t_index .= '/';
}
$t_index = REST::htmlspecialchars($t_index);
$portalurl = REST::htmlspecialchars(self::portalURL());
$retval = REST::xml_header() . <<<EOS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>{$title}</title>
<link rel="stylesheet" type="text/css" href="{$portalurl}style.css" />
<link rel="index" rev="child" type="application/xhtml+xml" href="{$t_index}" />
</head><body>
<div id="header"><p><a rel="index" rev="child" href="{$t_index}"><img border="0" src="{$portalurl}dirup.png"/> UP</a></p>
<h1>{$title}</h1></div>
EOS;
return $retval;
}
示例2: html_start
/**
* @param $title string Title in UTF-8
* @return string a piece of UTF-8 encoded XHTML, including XML and DOCTYPE
* headers.
*/
public static function html_start($title)
{
if (self::$html_start !== null) {
return call_user_func(self::$html_start, $title);
}
$t_title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
$t_index = REST::urlencode(dirname($_SERVER['REQUEST_URI']));
if ($t_index != '/') {
$t_index .= '/';
}
$t_stylesheet = self::$STYLESHEET ? self::$STYLESHEET : "{$t_index}style.css";
return REST::xml_header() . <<<EOS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>{$t_title}</title>
<link rel="stylesheet" type="text/css" href="{$t_stylesheet}" />
<link rel="index" rev="child" type="application/xhtml+xml" href="{$t_index}"/>
</head><body>
<div id="div_header">
<div id="div_index"><a rel="index" rev="child" href="{$t_index}">index</a></div>
<h1 id="h1_title">{$t_title}</h1>
</div>
EOS;
}
示例3: UNIX_TIMESTAMP
}
}
$result = Topos::query(<<<EOS
SELECT `tokenId`,
`tokenName`,
`tokenLockTimeout` - UNIX_TIMESTAMP(),
`tokenLockDescription`
FROM `Tokens`
WHERE `tokenLockUUID` = {$escLockUUID}
AND `tokenLockTimeout` > UNIX_TIMESTAMP();
EOS
);
if (!($row = $result->fetch_row())) {
REST::fatal(REST::HTTP_NOT_FOUND);
}
$tokenURL = Topos::urlbase() . 'pools/' . REST::urlencode($TOPOS_POOL) . '/tokens/' . $row[0];
$xhtmltype = REST::best_xhtml_type();
$bct = REST::best_content_type(array($xhtmltype => 1, 'text/plain' => 1), $xhtmltype);
if ($bct === 'text/plain') {
REST::header(array('Content-Type' => 'text/plain; charset=US-ASCII', 'Cache-Control' => 'no-cache'));
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
echo <<<EOS
TokenId: {$row[0]}
TokenName: {$row[1]}
TokenURL: {$tokenURL}
Timeout: {$row[2]}
Description: {$row[3]}
EOS;
exit;
示例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: while
$row = $result->fetch_row();
if ($row[0] === null) {
REST::fatal(REST::HTTP_NOT_FOUND, 'No token available');
}
Topos::real_query(<<<EOS
UPDATE `Pools`
SET `minLeases` = {$row[0]}
WHERE `poolId` = {$poolId};
EOS
);
}
// while
while ($row = $result->fetch_row()) {
Topos::real_query(<<<EOS
UPDATE `Tokens` SET `tokenLeases` = {$row[1]} + 1 {$timeout}
WHERE `tokenId` = {$row[0]} AND `tokenLeases` = {$row[1]};
EOS
);
if (Topos::mysqli()->affected_rows) {
break 2;
}
}
// while
}
// while
$url = Topos::urlbase() . 'pools/' . REST::urlencode($TOPOS_POOL) . '/tokens/' . $row[0];
if ($lockUUID) {
header("X-Topos-OpaqueLockToken: opaquelocktoken:{$lockUUID}");
header('X-Topos-LockURL: ' . Topos::urlbase() . 'pools/' . REST::urlencode($TOPOS_POOL) . '/locks/' . $lockUUID);
}
REST::redirect(REST::HTTP_SEE_OTHER, $url);
示例6: html_start
/**
* @param $title string title in UTF-8
*/
public static function html_start($title)
{
$t_title = htmlspecialchars($title, ENT_COMPAT, "UTF-8");
$t_index = REST::urlencode(dirname($_SERVER['REQUEST_URI']));
if ($t_index != '/') {
$t_index .= '/';
}
$t_stylesheet = self::urlbase() . 'style.css';
$t_icon = self::urlbase() . 'favicon.png';
return REST::xml_header() . <<<EOS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>{$t_title}</title>
<link rel="stylesheet" type="text/css" href="{$t_stylesheet}" />
<link rel="index" rev="child" type="application/xhtml+xml" href="{$t_index}"/>
<link rel="icon" type="image/png" href="{$t_icon}" />
</head><body>
<div id="div_header">
<div id="div_index"><a rel="index" rev="child" href="{$t_index}">index</a></div>
<h1>{$t_title}</h1>
</div>
EOS;
}
示例7: escapeshellarg
$filename = escapeshellarg(Portal::PROXY_DIR . $userdnmd5 . '.pem');
exec("echo {$password} | myproxy-logon -v -l {$username} -s {$server} -S -o {$filename} 2>&1", $output, $returnval);
$output = implode("\n", $output);
if (preg_match('/^(?:invalid pass phrase|No credentials exist for username .*)$/m', $output)) {
REST::fatal(REST::HTTP_UNAUTHORIZED, 'Invalid username and/or pass phrase');
}
if ($returnval) {
REST::fatal(REST::HTTP_BAD_REQUEST, '<pre>' . htmlentities($output) . '</pre>');
}
$escserver = Portal_MySQL::escape_string($_POST['server']);
$escusername = Portal_MySQL::escape_string($_POST['username']);
$escpassword = Portal_MySQL::escape_string($_POST['password']);
Portal_MySQL::real_query("UPDATE `User` SET `proxy_server` = {$escserver}, `proxy_username` = {$escusername}, `proxy_password` = {$escpassword} WHERE `user_dn_md5` = '{$userdnmd5}'");
$best_xhtml_type = REST::best_xhtml_type();
$type = REST::best_content_type(array($best_xhtml_type => 1.0, 'text/plain' => 1.0), $best_xhtml_type);
$relurl = REST::urlencode(dirname($_SERVER['REDIRECT_URL'])) . '/proxy';
REST::header(array('status' => REST::HTTP_CREATED, 'Location' => REST::urlbase() . $relurl, 'Content-Type' => "{$type}; charset=UTF-8"));
if ($type == 'text/plain') {
echo REST::urlbase() . $relurl;
} else {
echo Portal::html_start('Proxy created') . "<p><a href=\"proxy\">proxy</a></p>" . Portal::html_end();
}
exit;
}
REST::header(REST::best_xhtml_type() . "; charset=UTF-8");
$default_server = getenv('MYPROXY_SERVER');
echo Portal::html_start("myProxy") . <<<EOS
<form action="./myproxy" method="post">
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr><td>Username</td><td><input type="text" name="username" /></td></tr>
<tr><td>Password</td><td><input type="password" name="password" /></td></tr>
示例8: availableDatabases
/**
* Get a list of available databases, given a set of database types.
* @param $name... string the name(s) of the database types.
* @return string an x fragment, to be put inside a select element.
*/
public static function availableDatabases()
{
$dbTypes = func_get_args();
if (empty($dbTypes)) {
return array();
}
foreach ($dbTypes as $key => $value) {
$dbTypes[$key] = self::databaseTypeIDByName($value);
}
$dbTypes = implode(',', $dbTypes);
$user_id = Portal_User::current()->user_id();
$result = Portal_MySQL::query(<<<EOS
SELECT `d`.`name`, `d`.`version`, `d`.`type`, `u`.`user_name`, `d`.`database_id`
FROM `Database` AS d LEFT JOIN `User` AS u USING(`user_id`)
WHERE (`d`.`is_shared` > 0 OR `d`.`user_id` = {$user_id})
AND `d`.`type` IN({$dbTypes});
EOS
);
$sorter = array();
while ($row = $result->fetch_row()) {
$extension = self::databaseTypeExtension($row[2]);
$sorter[$row[3]]["{$row[0]}-{$row[1]}.{$extension}"] = REST::urlencode(Portal::portalURL() . 'databases/' . $row[0] . '/' . $row[1] . '/' . $row[4] . '.' . $extension);
}
$user_names = array_keys($sorter);
natsort($user_names);
$retval = '';
foreach ($user_names as $user_name) {
$retval .= "\n<optgroup label=\"" . htmlentities($user_name) . "\">";
$dbnames = array_keys($sorter[$user_name]);
natsort($dbnames);
foreach ($dbnames as $dbname) {
$retval .= "\n<option value=\"" . $sorter[$user_name][$dbname] . "\">{$dbname}</option>";
}
$retval .= "\n</optgroup>";
}
return $retval;
}