本文整理汇总了PHP中DevblocksPlatform::getWebPath方法的典型用法代码示例。如果您正苦于以下问题:PHP DevblocksPlatform::getWebPath方法的具体用法?PHP DevblocksPlatform::getWebPath怎么用?PHP DevblocksPlatform::getWebPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DevblocksPlatform
的用法示例。
在下文中一共展示了DevblocksPlatform::getWebPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
function handleRequest(DevblocksHttpRequest $request)
{
$stack = $request->path;
$db = DevblocksPlatform::getDatabaseService();
// **** BEGIN AUTH
@($verb = $_SERVER['REQUEST_METHOD']);
@($header_date = $_SERVER['HTTP_DATE']);
@($header_signature = $_SERVER['HTTP_PORTSENSOR_AUTH']);
@($this->_payload = $this->_getRawPost());
@(list($auth_worker_email, $auth_signature) = explode(":", $header_signature, 2));
$url_parts = parse_url(DevblocksPlatform::getWebPath());
$url_path = $url_parts['path'];
$url_query = $this->_sortQueryString($_SERVER['QUERY_STRING']);
$string_to_sign_prefix = "{$verb}\n{$header_date}\n{$url_path}\n{$url_query}\n{$this->_payload}";
if (!$this->_validateRfcDate($header_date)) {
$this->_error("Access denied! (Invalid timestamp)");
}
// if(strpos($auth_access_key,'@')) { // WORKER-LEVEL AUTH
$results = DAO_Worker::getWhere(sprintf("%s = %s", DAO_Worker::EMAIL, $db->qstr($auth_worker_email)));
if (empty($results)) {
$this->_error("Access denied! (Invalid authentication)");
} else {
$worker = array_shift($results);
$this->setActiveWorker($worker);
}
if (null == $this->getActiveWorker()) {
$this->_error("Access denied! (Invalid worker)");
}
if (!$worker->hasPriv('plugin.usermeet.webapi')) {
$this->_error("Access denied! (No permission)");
}
$pass = $this->getActiveWorker()->pass;
$string_to_sign = "{$string_to_sign_prefix}\n{$pass}\n";
$compare_hash = base64_encode(sha1($string_to_sign, true));
if (0 != strcmp($auth_signature, $compare_hash)) {
$this->_error("Access denied! (Invalid password)");
}
// **** END APP AUTH
// Figure out our format by looking at the last path argument
@(list($command, $format) = explode('.', array_pop($stack)));
array_push($stack, $command);
$this->_format = $format;
// Call the verb as an action
$method = strtolower($verb) . 'Action';
if (method_exists($this, $method)) {
call_user_func(array(&$this, $method), $stack);
} else {
$this->_error("Invalid action.");
}
}
示例2: handleRequest
function handleRequest(DevblocksHttpRequest $request)
{
$stack = $request->path;
$db = DevblocksPlatform::getDatabaseService();
// **** BEGIN AUTH
@($verb = $_SERVER['REQUEST_METHOD']);
@($header_date = $_SERVER['HTTP_DATE']);
@($header_signature = $_SERVER['HTTP_CERB4_AUTH']);
@($this->_payload = $this->_getRawPost());
@(list($auth_access_key, $auth_signature) = explode(":", $header_signature, 2));
$url_parts = parse_url(DevblocksPlatform::getWebPath());
$url_path = $url_parts['path'];
$url_query = $this->_sortQueryString($_SERVER['QUERY_STRING']);
$string_to_sign_prefix = "{$verb}\n{$header_date}\n{$url_path}\n{$url_query}\n{$this->_payload}";
if (!$this->_validateRfcDate($header_date)) {
$this->_error("Access denied! (Invalid timestamp)");
}
if (strpos($auth_access_key, '@')) {
// WORKER-LEVEL AUTH
$workers = DAO_Worker::getAll();
foreach ($workers as $worker) {
/* @var $worker CerberusWorker */
if ($worker->email == $auth_access_key) {
$this->setActiveWorker($worker);
break;
}
}
if (null == $this->getActiveWorker()) {
$this->_error("Access denied! (Invalid worker)");
}
$pass = $this->getActiveWorker()->pass;
$string_to_sign = "{$string_to_sign_prefix}\n{$pass}\n";
$compare_hash = base64_encode(sha1($string_to_sign, true));
if (0 != strcmp($auth_signature, $compare_hash)) {
$this->_error("Access denied! (Invalid password)");
}
} else {
// APP-LEVEL AUTH
$stored_keychains = DAO_WebapiKey::getWhere(sprintf("%s = %s", DAO_WebapiKey::ACCESS_KEY, $db->qstr(str_replace(' ', '', $auth_access_key))));
/* @var $stored_keychain Model_WebApiKey */
if (!empty($stored_keychains)) {
@($stored_keychain = array_shift($stored_keychains));
@($auth_secret_key = $stored_keychain->secret_key);
@($auth_rights = $stored_keychain->rights);
$string_to_sign = "{$string_to_sign_prefix}\n{$auth_secret_key}\n";
$compare_hash = base64_encode(sha1($string_to_sign, true));
if (0 != strcmp($auth_signature, $compare_hash)) {
$this->_error("Access denied! (Invalid signature)");
}
// Check that this IP is allowed to perform the VERB
if (!$stored_keychain->isValidIp($_SERVER['REMOTE_ADDR'])) {
$this->_error(sprintf("Access denied! (IP %s not authorized)", $_SERVER['REMOTE_ADDR']));
}
} else {
$this->_error("Access denied! (Unknown access key)");
}
}
// **** END APP AUTH
// Figure out our format by looking at the last path argument
@(list($command, $format) = explode('.', array_pop($stack)));
array_push($stack, $command);
$this->_format = $format;
if (null != $this->getActiveWorker()) {
$method = strtolower($verb) . 'WorkerAction';
if (method_exists($this, $method)) {
call_user_func(array(&$this, $method), $stack);
}
} else {
$method = strtolower($verb) . 'Action';
if (method_exists($this, $method)) {
call_user_func(array(&$this, $method), $stack, $stored_keychain);
}
}
}