本文整理匯總了PHP中phpbb\request\request_interface::header方法的典型用法代碼示例。如果您正苦於以下問題:PHP request_interface::header方法的具體用法?PHP request_interface::header怎麽用?PHP request_interface::header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phpbb\request\request_interface
的用法示例。
在下文中一共展示了request_interface::header方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
/**
* Edit an existing post
*
* @param int $post_id
* @return JsonResponse|Response
*/
public function edit($post_id)
{
if ($this->request->is_ajax() && !$this->request->header('X-PHPBB-USING-PLUPLOAD', false)) {
return $this->quick_edit($post_id);
}
if (!$this->auth->acl_get('u_titania_post')) {
return $this->controller_helper->needs_auth();
}
// Load the stuff we need
$post = $this->load_post($post_id);
// Check permissions
if (!$post->acl_get('edit')) {
return $this->controller_helper->needs_auth();
}
// Some more complicated permissions for stickes in support
$can_moderate_own = $this->auth->acl_get('u_titania_post_mod_own');
$is_moderator = $this->auth->acl_get('u_titania_mod_post_mod');
$is_author = false;
if ($post->post_type == TITANIA_SUPPORT) {
$is_author = $this->get_contrib($post->topic->parent_id)->is_author();
}
$can_lock_topic = $is_moderator || $is_author && $can_moderate_own;
$can_sticky = ($is_moderator || $is_author) && $post->post_id == $post->topic->topic_first_post_id;
$can_lock_post = $is_moderator && $post->post_user_id != $this->user->data['user_id'];
// Load the message object
$this->setup_message($post, array('lock' => $can_lock_post, 'sticky_topic' => $can_sticky, 'lock_topic' => $can_lock_topic));
// Call our common posting handler
$response = $this->common_post('edit', $post, $this->message);
if ($response) {
return $response;
}
// Common stuff
$this->template->assign_vars(array('S_POST_ACTION' => $post->get_url('edit'), 'L_POST_A' => $this->user->lang['EDIT_POST']));
return $this->controller_helper->render($this->template_file, 'EDIT_POST');
}
示例2: handle_form_action
/**
* Handle any upload/deletion requests.
*/
public function handle_form_action()
{
// First, we shall handle the items already attached
$attachments = $this->get_filtered_request_data();
$attached_ids = array_keys($attachments);
// Query the ones we must
$to_query = array_diff($attached_ids, $this->operator->get_all_ids());
if (!empty($to_query)) {
$this->operator->load($to_query, true);
}
$uploader_key = $this->request->header('X-PLUPLOAD_KEY', '');
$uploader_key = $uploader_key ?: $this->request->variable('uploader_key', '');
// Do not perform any actions without a valid key.
if (!check_link_hash($uploader_key, 'uploader_key')) {
return;
}
// Next, delete those requested
$delete_indices = $this->request->variable('delete_file', array(0 => 0));
if ($delete_indices) {
$this->handle_delete($delete_indices);
}
// set requested attachment as preview
$preview = $this->request->variable('set_preview_file' . $this->object_type, 0);
if ($preview) {
$this->operator->set_preview($preview);
}
if ($this->request->is_set($this->form_name, request_interface::FILES)) {
$this->handle_upload();
}
}
示例3: init_extractor
/**
* {@inheritdoc}
*/
public function init_extractor($format, $filename, $time, $download = false, $store = false)
{
$this->download = $download;
$this->store = $store;
$this->time = $time;
$this->format = $format;
switch ($format) {
case 'text':
$ext = '.sql';
$open = 'fopen';
$this->write = 'fwrite';
$this->close = 'fclose';
$mimetype = 'text/x-sql';
break;
case 'bzip2':
$ext = '.sql.bz2';
$open = 'bzopen';
$this->write = 'bzwrite';
$this->close = 'bzclose';
$mimetype = 'application/x-bzip2';
break;
case 'gzip':
$ext = '.sql.gz';
$open = 'gzopen';
$this->write = 'gzwrite';
$this->close = 'gzclose';
$mimetype = 'application/x-gzip';
break;
default:
throw new invalid_format_exception();
break;
}
if ($download === true) {
$name = $filename . $ext;
header('Cache-Control: private, no-cache');
header("Content-Type: {$mimetype}; name=\"{$name}\"");
header("Content-disposition: attachment; filename={$name}");
switch ($format) {
case 'bzip2':
ob_start();
break;
case 'gzip':
if (strpos($this->request->header('Accept-Encoding'), 'gzip') !== false && strpos(strtolower($this->request->header('User-Agent')), 'msie') === false) {
ob_start('ob_gzhandler');
} else {
$this->run_comp = true;
}
break;
}
}
if ($store === true) {
$file = $this->phpbb_root_path . 'store/' . $filename . $ext;
$this->fp = $open($file, 'w');
if (!$this->fp) {
trigger_error('FILE_WRITE_FAIL', E_USER_ERROR);
}
}
$this->is_initialized = true;
}
示例4: browser
private function browser()
{
if (!($user_agent = $this->request->header('User-Agent'))) {
$user_agent = $this->request->server('HTTP_USER_AGENT');
}
preg_match("/(MSIE|Firefox|iPhone|Android|BlackBerry|WindowsPhone|Symbian|Chrome|Netscape|Konqueror|SeaMonkey|K-Meleon|iPod|Opera Mini|Camino|Minefield|Iceweasel|Maxthon|Version)(?:\\/| )([0-9.]+)/", $user_agent, $browser_info);
list(, $browser, $version) = $browser_info;
if ($browser == 'Opera Mini') {
return 'Opera Mini ' . $version;
}
if (preg_match("/(Opera|OPR)(?:\\/| )([0-9.]+)/i", $user_agent, $opera)) {
return 'Opera ' . ($opera[2] != '9.80' ? $opera[2] : substr($user_agent, -5));
}
if (preg_match("/Nokia([0-9.]+)/i", $user_agent, $nokia)) {
return 'Nokia ' . $nokia[1];
}
if ($browser == 'MSIE') {
preg_match("/(Maxthon|Avant Browser|MyIE2)/i", $user_agent, $ie);
if ($ie) {
return $ie[1] . ' based on IE ' . $version;
}
return 'IE ' . $version;
}
if ($browser == 'Firefox') {
preg_match("/(Flock|Navigator|Epiphany)\\/([0-9.]+)/", $user_agent, $ff);
if ($ff) {
return $ff[1] . ' ' . $ff[2];
}
}
if ($browser == 'Version') {
return 'Safari ' . $version;
}
if (!$browser && strpos($user_agent, 'Gecko')) {
return 'Browser based on Gecko';
}
if (!$browser) {
$mobile_browser = '';
$browser_ary = array('Alcatel, Sony Ericsson, Motorola, Panasonic, Philips, Samsung, Sanyo, Sharp, Sony, Ericsson,
j2me, midp, wap, pda, series60, vodafone, mobile, phone, up.browser, up.link, xiino/i');
foreach ($browser_ary as $mobile_browser) {
if (stripos($user_agent, $mobile_browser) !== false) {
$version = $mobile_browser;
break;
}
}
$browser = 'Browser';
}
return $browser . ' ' . $version;
}
示例5: is_active
/**
* Checks whether the page request was sent by plupload or not
*
* @return bool
*/
public function is_active()
{
return $this->request->header('X-PHPBB-USING-PLUPLOAD', false);
}
示例6: get_header_variable
/**
* {@inheritdoc}
*/
public function get_header_variable($name, $default = '')
{
return $this->request->header($name, $default);
}