本文整理汇总了PHP中request_method函数的典型用法代码示例。如果您正苦于以下问题:PHP request_method函数的具体用法?PHP request_method怎么用?PHP request_method使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了request_method函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
// Get the requested method.
$this->method = request_method();
// Check to make sure the authentication credentials
// are valid.
$this->checkAuth($this->method);
// Detect the requested format.
$request_format = request_format();
$this->format = detect_format($request_format, $this->supported_formats, $this->default_format);
$this->parameters = $this->input->get();
switch ($this->method) {
case 'get':
$this->get();
break;
case 'post':
$this->post();
break;
default:
$error_code = "404";
$error_message = $error_code;
$error_message .= " Unsupported method: ";
$error_message .= $this->method;
show_error($error_message, $error_code);
break;
}
}
示例2: serve
public static function serve($query_string = false, $method = null, $payload = null, $check_perms = true)
{
if ($query_string) {
self::$mode = self::MODE_EXECUTE;
self::$query_string = $query_string;
self::$method = is_null($method) ? request_method() : $method;
//The payload must be specified, either through the query string or in the payload itself...
self::$payload = $payload;
} else {
self::$mode = self::MODE_REQUEST;
self::$query_string = $_SERVER['QUERY_STRING'];
self::$method = is_null($method) ? request_method() : $method;
///Payload is always set with _GET / _POST with requests
switch (self::$method) {
case 'GET':
self::$payload = array_map('stripslashes_deep', $_GET);
break;
case 'POST':
//Add GET variables as well. Should POST overwrites GET vars
self::$payload = array_map('stripslashes_deep', $_GET);
self::$payload = array_merge(self::$payload, array_map('stripslashes_deep', $_POST));
break;
}
}
self::$check_perms = $check_perms;
self::$ob_level = ob_get_level();
parse_str(self::$query_string, self::$query_vars);
if (empty(self::$payload) && !is_array(self::$payload)) {
self::$payload = array();
}
//Make sure that all of query string vars is in the payload.
if (self::$mode == self::MODE_EXECUTE && self::$method == 'GET') {
self::$payload = array_merge(self::$query_vars, self::$payload);
}
self::init();
self::start();
list($controller, $result) = self::action();
if ($controller instanceof AreaCtl) {
self::display($controller, $result);
}
if (self::$mode == self::MODE_EXECUTE) {
self::finish();
}
}
示例3: test_request_method
function test_request_method()
{
$env = env();
$env['SERVER']['REQUEST_METHOD'] = null;
assert_trigger_error("request_method");
$methods = request_methods();
foreach ($methods as $method) {
$env['SERVER']['REQUEST_METHOD'] = $method;
assert_equal(request_method($env), $method);
}
$env['SERVER']['REQUEST_METHOD'] = "POST";
$env['POST']['_method'] = "PUT";
assert_equal(request_method($env), "PUT");
$env['POST']['_method'] = "DELETE";
assert_equal(request_method($env), "DELETE");
$env['POST']['_method'] = "UNKOWN";
assert_trigger_error('request_method', array($env));
assert_false(request_method());
}
示例4: receive
public function receive() {
global $config, $user;
if (request_method() != 'post') {
redirect(s_link());
}
// Init member
$user->init();
if (!$user->is('member')) {
do_login();
}
$this->ref = request_var('ref', $user->d('session_page'), true);
if (preg_match('#([0-9a-z\-]+)\.(.*?)\.([a-z]+){1,3}(/(.*?))?$#i', $this->ref, $part) && ($part[1] != 'www')) {
$this->ref = '//' . $part[2] . '.' . $part[3] . '/a/' . $part[1] . $part[4];
}
$this->store();
redirect($this->ref);
}
示例5: run
/**
* Prepares the request cycle and runs the dispatcher.
*
* @param string $file Path to router script; should generally be __FILE__
*
* @return mixed
*/
function run($file)
{
if (php_sapi_name() === 'cli-server') {
config('_base_path', '');
if ($file != $_SERVER['SCRIPT_FILENAME']) {
return false;
}
}
foreach (array(400, 404, 405, 500, 503) as $code) {
if (error($code) === null) {
error($code, function ($message = null) use($code) {
header('Content-Type: text/plain');
echo $code, ' ', http_status($code);
if (isset($message)) {
echo "\n{$message}";
}
});
}
}
register_shutdown_function('shutdown');
ob_start();
dispatch(request_method(), request_path());
}
示例6: home
function home()
{
global $nucleo, $user;
$v = $this->control->__(array('a' => array('default' => 0)));
if (!$v['a'])
{
$nucleo->redirect($nucleo->link('radio'));
}
if (!$user->data['is_member'] || request_method() != 'post')
{
if ($v['a'])
{
$this->e('403 Forbidden.');
}
$nucleo->redirect($nucleo->link('radio'));
}
if (!$user->data['is_founder'])
{
$sql = 'SELECT *
FROM _team_members
WHERE team_id = 4
AND member_id = ' . (int) $user->data['user_id'];
if (!$this->_fieldrow($sql))
{
if ($v['a'])
{
$this->e('403 Forbidden.');
}
$nucleo->redirect($nucleo->link('radio'));
}
}
//
$connect_param = 'GET http://' . $nucleo->config['sc_stats_host'] . '/shoutcast/text/index.php?';
$connect_param.= 'server=' . $nucleo->config['sc_stats_ip'] . '&port=' . $nucleo->config['sc_stats_ipport'] . " HTTP/1.0\r\n";
$connect_param.= "User-Agent: StreamSolutions (Mozilla Compatible)\r\n\r\n";
$connect_recv = $this->sock($nucleo->config['sc_stats_host'], $connect_param, $nucleo->config['sc_stats_port']);
if (!$connect_recv)
{
$this->e('RADIO_UNAVAILABLE');
}
$response = array();
$lines = array_slice(split("\n", trim($connect_recv)), 8);
foreach ($lines as $line)
{
$e = explode('<SSTAG>', $line);
$response[$e[0]] = $e[1];
}
if ($response['server_status'] == $nucleo->config['sc_stats_down'])
{
$this->e('RADIO_UNAVAILABLE');
}
//
$kick_request = 'GET /admin.cgi?pass=' . $nucleo->config['sc_stats_key'] . '&mode=kicksrc' . " HTTP/1.0\r\n";
$kick_request.= "User-Agent: StreamSolutions (Mozilla Compatible)\r\n\r\n";
$this->e($kick_request . '/' . $nucleo->config['sc_stats_ip'] . '/' . $nucleo->config['sc_stats_ipport'] . '/');
$kick_recv = $this->sock($nucleo->config['sc_stats_ip'], $connect_param, $nucleo->config['sc_stats_ipport']);
if (!$kick_recv)
{
$this->e('RADIO_UNAVAILABLE');
}
$lines2 = split("\n", trim($kick_recv));
if (!isset($lines2[4]))
{
$lines2[4] = '';
}
// If successful
if (strstr($lines2[4], 'redirect'))
{
$insert = array(
'log_uid' => $user->data['user_id'],
'log_time' => time()
);
sql_insert('radio_dj_log', $insert);
}
$this->e('Disconnected.');
return;
}
示例7: request_is_patch
/**
* Checks if request method is PATCH
*
* @param string $env
* @return bool
*/
function request_is_patch($env = null)
{
return request_method($env) == "PATCH";
}
示例8: remove_first
if (startsWith(request_uri(), '/users/') && strlen(trim(request_uri(), '/')) > 5) {
$email = remove_first(request_uri(), '/users/');
if (!account_exists($email)) {
render('err404', null, false);
die;
}
if ($email !== user_email() && !is_reviewer()) {
render('err403', null, false);
die;
}
$data = account_data($email);
$email = $data['email'];
if (request_method() == 'GET') {
render('user', array('head_title' => $data['email'], 'user' => $data, 'user_apps' => app_get_user($data['email'], valid_bool(from($_REQUEST, 'show-deleted'))), 'is_self' => user_email() == $email));
} else {
if (request_method() == 'POST') {
$action = from($_REQUEST, 'action');
switch (strtolower($action)) {
case 'desc':
account_change_desc($email, from($_REQUEST, 'desc'));
redirect('/users/' . $email);
break;
case 'username':
account_change_username($email, from($_REQUEST, 'username'));
redirect('/users/' . $email);
break;
case 'group':
if (!is_admin()) {
render('err403', null, false);
die;
}
示例9: request_is_delete
/**
* Checks if request method is DELETE
*
* @param string $env
* @return bool
*/
function request_is_delete($env = null)
{
return request_method($env) == "DELETE";
}
示例10: dirname
<?php
require __DIR__ . '/../inc/core.php';
// PUT requests need to be redirected to push.php
if (request_method() === 'PUT') {
require __DIR__ . '/push.php';
die;
}
header('Content-Type: text/xml; charset=utf-8');
$base_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']);
echo "<" . "?xml version='1.0' encoding='utf-8' standalone='yes'?>";
?>
<service xml:base="<?php
echo $base_url;
?>
/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:app="http://www.w3.org/2007/app"
xmlns="http://www.w3.org/2007/app">
<workspace>
<atom:title>Default</atom:title>
<collection href="Packages">
<atom:title>Packages</atom:title>
</collection>
</workspace>
</service>
示例11: is_delete
function is_delete()
{
return request_method() == 'DELETE';
}
示例12: is_get
/**
* Запрошена ли страница методом GET
*
* @return bool
*/
function is_get()
{
return request_method() === 'get';
}
示例13: request_is
function request_is($method = "")
{
return strcasecmp($method, request_method()) == 0;
}
示例14: define
define('IN_APP', true);
require_once('./interfase/common.php');
require_once(ROOT . 'interfase/chat.php');
$keepalive = true;
$user->init();
$chat = new _chat();
if ($chat->_setup()) {
$mode = request_var('mode', '');
$csid = request_var('csid', '');
$s_process = in_array($mode, array('logout', 'send', 'get'));
if (request_method() == 'post' && !$s_process) {
redirect(s_link('chat', $chat->data['ch_int_name']));
}
if (!$user->data['is_member']) {
do_login('LOGIN_TO_CHAT');
}
if (!$chat->auth()) {
trigger_error('CHAT_NO_ACCESS');
}
$user->setup('chat');
if ($s_process && $mode == 'logout') {
return $chat->process_data($csid, $mode);
示例15: unlink
<?php
// Package was hit directly (ie. request to /id/version). Currently we only
// expect these to be DELETE requests.
require __DIR__ . '/../inc/core.php';
if (request_method() !== 'DELETE') {
api_error('405', 'Only DELETEs allowed here');
}
require_auth();
$id = $_GET['id'];
$version = $_GET['version'];
$path = get_package_path($id, $version);
if (file_exists($path)) {
unlink($path);
}
DB::deleteVersion($id, $version);