[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\ucp\controller; 15 16 use phpbb\config\config; 17 use phpbb\event\dispatcher_interface; 18 use phpbb\language\language; 19 use phpbb\request\request_interface; 20 use phpbb\user; 21 22 class delete_cookies 23 { 24 /** @var config */ 25 private $config; 26 27 /** @var dispatcher_interface */ 28 private $dispatcher; 29 30 /** @var language */ 31 private $language; 32 33 /** @var request_interface */ 34 private $request; 35 36 /** @var user */ 37 private $user; 38 39 /** @var string phpBB root path */ 40 private $phpbb_root_path; 41 42 /** @var string PHP extension */ 43 private $php_ext; 44 45 /** 46 * Constructor for delete_cookies controller 47 * 48 * @param config $config 49 * @param dispatcher_interface $dispatcher 50 * @param language $language 51 * @param request_interface $request 52 * @param user $user 53 */ 54 public function __construct(config $config, dispatcher_interface $dispatcher, language $language, request_interface $request, user $user, string $phpbb_root_path, string $php_ext) 55 { 56 $this->config = $config; 57 $this->dispatcher = $dispatcher; 58 $this->language = $language; 59 $this->request = $request; 60 $this->user = $user; 61 $this->phpbb_root_path = $phpbb_root_path; 62 $this->php_ext = $php_ext; 63 } 64 65 /** 66 * Handle delete cookies requests 67 * 68 * @return void 69 */ 70 public function handle() 71 { 72 $this->language->add_lang(['ucp']); 73 74 // Delete Cookies with dynamic names (do NOT delete poll cookies) 75 if (confirm_box(true)) 76 { 77 $set_time = time() - 31536000; 78 79 foreach ($this->request->variable_names(request_interface::COOKIE) as $cookie_name) 80 { 81 // Only delete board cookies 82 if (strpos($cookie_name, $this->config['cookie_name'] . '_') !== 0) 83 { 84 continue; 85 } 86 87 $cookie_name = str_replace($this->config['cookie_name'] . '_', '', $cookie_name); 88 89 /** 90 * Event to save custom cookies from deletion 91 * 92 * @event core.ucp_delete_cookies 93 * @var string cookie_name Cookie name to checking 94 * @var bool retain_cookie Do we retain our cookie or not, true if retain 95 * @since 3.1.3-RC1 96 * @changed 3.3.13-RC1 Moved to new delete_cookies controller 97 */ 98 $retain_cookie = false; 99 $vars = ['cookie_name', 'retain_cookie']; 100 extract($this->dispatcher->trigger_event('core.ucp_delete_cookies', compact($vars))); 101 if ($retain_cookie) 102 { 103 continue; 104 } 105 106 // Polls are stored as {cookie_name}_poll_{topic_id}, cookie_name_ got removed, therefore checking for poll_ 107 if (strpos($cookie_name, 'poll_') !== 0) 108 { 109 $this->user->set_cookie($cookie_name, '', $set_time); 110 } 111 } 112 113 $this->user->set_cookie('track', '', $set_time); 114 $this->user->set_cookie('u', '', $set_time); 115 $this->user->set_cookie('k', '', $set_time); 116 $this->user->set_cookie('sid', '', $set_time); 117 118 // We destroy the session here, the user will be logged out nevertheless 119 $this->user->session_kill(); 120 $this->user->session_begin(); 121 122 meta_refresh(3, append_sid("{$this->phpbb_root_path}index.$this->php_ext")); 123 124 $message = $this->language->lang('COOKIES_DELETED') . '<br><br>' . $this->language->lang('RETURN_INDEX', '<a href="' . append_sid("{$this->phpbb_root_path}index.$this->php_ext") . '">', '</a>'); 125 trigger_error($message); 126 } 127 else 128 { 129 confirm_box(false, 'DELETE_COOKIES', ''); 130 } 131 132 redirect(append_sid("{$this->phpbb_root_path}index.$this->php_ext")); 133 } 134 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |