当前位置: 首页>>代码示例>>PHP>>正文


PHP check_link_hash函数代码示例

本文整理汇总了PHP中check_link_hash函数的典型用法代码示例。如果您正苦于以下问题:PHP check_link_hash函数的具体用法?PHP check_link_hash怎么用?PHP check_link_hash使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了check_link_hash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

 public function main($id, $mode)
 {
     global $db, $user, $src_admin_path, $src_root_path, $phpEx, $template, $request, $cache, $auth, $config;
     $this->db = $db;
     $this->user = $user;
     $this->template = $template;
     $this->request = $request;
     $this->cache = $cache;
     $this->auth = $auth;
     $this->config = $config;
     $this->src_root_path = $src_root_path;
     $this->php_ext = $phpEx;
     $this->default_style = $config['default_style'];
     $this->styles_path = $this->src_root_path . $this->styles_path_absolute . '/';
     $this->u_base_action = append_sid("{$src_admin_path}index.{$this->php_ext}", "i={$id}");
     $this->s_hidden_fields = array('mode' => $mode);
     $this->user->add_lang('acp/styles');
     $this->tpl_name = 'acp_styles';
     $this->page_title = 'ACP_CAT_STYLES';
     $this->mode = $mode;
     $action = $this->request->variable('action', '');
     $post_actions = array('install', 'activate', 'deactivate', 'uninstall');
     foreach ($post_actions as $key) {
         if ($this->request->is_set_post($key)) {
             $action = $key;
         }
     }
     // The uninstall action uses confirm_box() to verify the validity of the request,
     // so there is no need to check for a valid token here.
     if (in_array($action, $post_actions) && $action != 'uninstall') {
         $is_valid_request = check_link_hash($request->variable('hash', ''), $action) || check_form_key('styles_management');
         if (!$is_valid_request) {
             trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
         }
     }
     if ($action != '') {
         $this->s_hidden_fields['action'] = $action;
     }
     $this->template->assign_vars(array('U_ACTION' => $this->u_base_action, 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields)));
     // Execute actions
     switch ($action) {
         case 'install':
             $this->action_install();
             return;
         case 'uninstall':
             $this->action_uninstall();
             return;
         case 'activate':
             $this->action_activate();
             return;
         case 'deactivate':
             $this->action_deactivate();
             return;
         case 'details':
             $this->action_details();
             return;
         default:
             $this->frontend();
     }
 }
开发者ID:AkhilSharma,项目名称:Serbest,代码行数:60,代码来源:acp_styles.php

示例2: move

    /**
     * Update BBCode order fields in the db on move up/down
     *
     * @param string $action The action move_up|move_down
     * @return null
     * @access public
     */
    public function move($action)
    {
        $bbcode_id = $this->request->variable('id', 0);
        if (!check_link_hash($this->request->variable('hash', ''), $action . $bbcode_id)) {
            trigger_error($this->user->lang('FORM_INVALID'), E_USER_WARNING);
        }
        // Get current order
        $sql = 'SELECT bbcode_order
			FROM ' . BBCODES_TABLE . "\n\t\t\tWHERE bbcode_id = {$bbcode_id}";
        $result = $this->db->sql_query($sql);
        $current_order = (int) $this->db->sql_fetchfield('bbcode_order');
        $this->db->sql_freeresult($result);
        // First one can't be moved up
        if ($current_order <= 1 && $action == 'move_up') {
            return;
        }
        $order_total = $current_order * 2 + $this->increment($action);
        // Update the db
        $sql = 'UPDATE ' . BBCODES_TABLE . '
			SET bbcode_order = ' . $order_total . ' - bbcode_order
			WHERE ' . $this->db->sql_in_set('bbcode_order', array($current_order, $current_order + $this->increment($action)));
        $this->db->sql_query($sql);
        // Resync bbcode_order
        $this->resynchronize_bbcode_order();
        // return a JSON response if this was an AJAX request
        if ($this->request->is_ajax()) {
            $json_response = new \phpbb\json_response();
            $json_response->send(array('success' => (bool) $this->db->sql_affectedrows()));
        }
    }
开发者ID:corycubbage,项目名称:ShadoWorld,代码行数:37,代码来源:acp_manager.php

示例3: handle

 /**
  * {@inheritdoc}
  */
 public function handle($forum_id)
 {
     // Throw an exception for non-AJAX requests or invalid link requests
     if (!$this->request->is_ajax() || !$this->is_valid($forum_id) || !check_link_hash($this->request->variable('hash', ''), 'collapsible_' . $forum_id)) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     // Update the user's collapsed category data for the given forum
     $response = $this->operator->set_user_categories($forum_id);
     // Return a JSON response
     return new \Symfony\Component\HttpFoundation\JsonResponse(array('success' => $response));
 }
开发者ID:phpbb-addons,项目名称:collapsible-categories,代码行数:14,代码来源:main_controller.php

示例4: run_tool

 /**
  * Run requested tool.
  *
  * @param string $tool		Tool.
  * @param int $id			Revision id.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function run_tool($tool, $id)
 {
     if (!in_array($tool, array('automod', 'mpv', 'epv'))) {
         return $this->helper->error('INVALID_TOOL', 404);
     }
     // Check the hash first to avoid unnecessary queries.
     if (!check_link_hash($this->request->variable('hash', ''), 'queue_tool')) {
         return $this->helper->error('PAGE_REQUEST_INVALID');
     }
     $this->load_objects($id);
     if (!$this->contrib->type->acl_get('view')) {
         return $this->helper->needs_auth();
     }
     return $this->{$tool}();
 }
开发者ID:Sajaki,项目名称:customisation-db,代码行数:23,代码来源:tools.php

示例5: item_action

 /**
  * Delegates the requested action to the appropriate method.
  *
  * @param int $id			Attention item id.
  * @param string $action		Action.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function item_action($id, $action)
 {
     if (!in_array($action, array('approve', 'disapprove', 'close', 'delete'))) {
         return $this->helper->error('INVALID_ACTION', 404);
     }
     $this->user->add_lang('mcp');
     $this->load_item($id);
     if (!$this->check_auth(true)) {
         return $this->helper->needs_auth();
     }
     if (!check_link_hash($this->request->variable('hash', ''), 'attention_action')) {
         redirect($this->attention->get_report_url());
     }
     return $this->{$action}();
 }
开发者ID:Sajaki,项目名称:customisation-db,代码行数:23,代码来源:attention.php

示例6: move

    public function move($action)
    {
        if ($action == 'drag_drop') {
            if (!$this->request->is_ajax()) {
                return;
            }
            $tablename = $this->request->variable('tablename', '');
            $bbcodes_list = $this->request->variable($tablename, array(0 => ''));
            foreach ($bbcodes_list as $order => $bbcode_id) {
                if ($order == 0) {
                    continue;
                }
                $sql = 'UPDATE ' . BBCODES_TABLE . '
					SET bbcode_order = ' . $order . '
					WHERE bbcode_id = ' . (int) $bbcode_id;
                $this->db->sql_query($sql);
            }
            $this->resynchronize_bbcode_order();
            $json_response = new \phpbb\json_response();
            $json_response->send(array('success' => true));
        } else {
            $bbcode_id = $this->request->variable('id', 0);
            if (!check_link_hash($this->request->variable('hash', ''), $action . $bbcode_id)) {
                trigger_error($this->user->lang('FORM_INVALID'), E_USER_WARNING);
            }
            $sql = 'SELECT bbcode_order
				FROM ' . BBCODES_TABLE . "\n\t\t\t\tWHERE bbcode_id = {$bbcode_id}";
            $result = $this->db->sql_query($sql);
            $current_order = (int) $this->db->sql_fetchfield('bbcode_order');
            $this->db->sql_freeresult($result);
            if ($current_order <= 1 && $action == 'move_up') {
                return;
            }
            $order_total = $current_order * 2 + ($action == 'move_up' ? -1 : 1);
            $sql = 'UPDATE ' . BBCODES_TABLE . '
				SET bbcode_order = ' . $order_total . ' - bbcode_order
				WHERE bbcode_order IN (' . $current_order . ', ' . ($action == 'move_up' ? $current_order - 1 : $current_order + 1) . ')';
            $this->db->sql_query($sql);
            $this->resynchronize_bbcode_order();
            if ($this->request->is_ajax()) {
                $json_response = new \phpbb\json_response();
                $json_response->send(array('success' => (bool) $this->db->sql_affectedrows()));
            }
        }
    }
开发者ID:sq6jny,项目名称:ajaxchat,代码行数:45,代码来源:acp_manager.php

示例7: handle_subscriptions

 /**
  * Shorten the amount of code required for some places
  *
  * @param mixed $object_type
  * @param mixed $object_id
  * @param mixed $url
  */
 public static function handle_subscriptions($object_type, $object_id, $url)
 {
     if (!phpbb::$user->data['is_registered']) {
         // Cannot currently handle non-registered users
         return;
     }
     $subscribe = request_var('subscribe', '');
     if ($subscribe == 'subscribe' && check_link_hash(request_var('hash', ''), 'subscribe')) {
         titania_subscriptions::subscribe($object_type, $object_id);
     } else {
         if ($subscribe == 'unsubscribe' && check_link_hash(request_var('hash', ''), 'unsubscribe')) {
             titania_subscriptions::unsubscribe($object_type, $object_id);
         }
     }
     if (titania_subscriptions::is_subscribed($object_type, $object_id)) {
         phpbb::$template->assign_vars(array('IS_SUBSCRIBED' => true, 'U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'unsubscribe', 'hash' => generate_link_hash('unsubscribe')))));
     } else {
         phpbb::$template->assign_vars(array('U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'subscribe', 'hash' => generate_link_hash('subscribe')))));
     }
 }
开发者ID:Gfksx,项目名称:customisation-db,代码行数:27,代码来源:subscriptions.php

示例8: startTravelAction

 /**
  * Start travel
  *
  * @param $travel_id
  * @return void
  */
 public function startTravelAction($travel_id)
 {
     //Check the request
     if (!$this->is_valid($travel_id) || !check_link_hash($this->request->variable('hash', ''), 'travel_' . $travel_id)) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     //Load ConsimUser
     $consim_user = $this->userService->getCurrentUser();
     //Check, if user not active
     if ($consim_user->getActive()) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     //Get Infos about the Route
     $route = $this->routeService->findRoute($consim_user->getLocationId(), $travel_id);
     $now = time();
     $this->container->get('consim.core.entity.action')->setUserId($consim_user->getUserId())->setLocationId($consim_user->getLocationId())->setStartTime($now)->setEndTime($now + $route->getTime() / 10)->setRouteId($route->getId())->setResult('')->insert();
     //$consim_user->setLocation($travel_id);
     //$consim_user->save();
     //Reload the Consim Index
     redirect($this->helper->route('consim_core_index'));
 }
开发者ID:Tacitus89,项目名称:consim,代码行数:27,代码来源:RequestController.php

示例9: handle_subscriptions

 /**
  * Shorten the amount of code required for some places
  *
  * @param mixed $object_type
  * @param mixed $object_id
  * @param mixed $url
  * @param string $lang_key Language key to use in link
  */
 public function handle_subscriptions($object_type, $object_id, $url, $lang_key = 'SUBSCRIBE')
 {
     if (!$this->user->data['is_registered']) {
         // Cannot currently handle non-registered users
         return;
     }
     $action = $this->request->variable('subscribe', '');
     $action = in_array($action, array('subscribe', 'unsubscribe')) ? $action : false;
     $hash = $this->request->variable('hash', '');
     if ($action && check_link_hash($hash, $action)) {
         $this->{$action}($object_type, $object_id);
     }
     $is_subscribed = $this->is_subscribed($object_type, $object_id);
     $action = 'subscribe';
     if ($is_subscribed) {
         $action = 'unsubscribe';
         $lang_key = 'UN' . $lang_key;
     }
     $params = array('subscribe' => $action, 'hash' => generate_link_hash($action));
     $this->template->assign_vars(array('IS_SUBSCRIBED' => $is_subscribed, 'U_SUBSCRIBE' => $this->path_helper->append_url_params($url, $params), 'L_SUBSCRIBE_TYPE' => $this->user->lang($lang_key)));
 }
开发者ID:Sajaki,项目名称:customisation-db,代码行数:29,代码来源:subscriptions.php

示例10: close_announcement

 /**
  * Board Announcements controller accessed from the URL /boardannouncements/close
  *
  * @throws \phpbb\exception\http_exception An http exception
  * @return \Symfony\Component\HttpFoundation\JsonResponse A Symfony JSON Response object
  * @access public
  */
 public function close_announcement()
 {
     // Check the link hash to protect against CSRF/XSRF attacks
     if (!check_link_hash($this->request->variable('hash', ''), 'close_boardannouncement') || !$this->config['board_announcements_dismiss']) {
         throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION');
     }
     // Set a cookie
     $response = $this->set_board_announcement_cookie();
     // Close the announcement for registered users
     if ($this->user->data['is_registered']) {
         $response = $this->update_board_announcement_status();
     }
     // Send a JSON response if an AJAX request was used
     if ($this->request->is_ajax()) {
         return new \Symfony\Component\HttpFoundation\JsonResponse(array('success' => $response));
     }
     // Redirect the user back to their last viewed page (non-AJAX requests)
     $redirect = $this->request->variable('redirect', $this->user->data['session_page']);
     $redirect = reapply_sid($redirect);
     redirect($redirect);
     // We shouldn't get here, but throw an http exception just in case
     throw new \phpbb\exception\http_exception(500, 'GENERAL_ERROR');
 }
开发者ID:harsha-sira,项目名称:Online-Forum,代码行数:30,代码来源:controller.php

示例11: substr

$phpEx = substr(strrchr(__FILE__, '.'), 1);
include $phpbb_root_path . 'common.' . $phpEx;
include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
// Mark notifications read
if ($mark_notification = $request->variable('mark_notification', 0)) {
    if ($user->data['user_id'] == ANONYMOUS) {
        if ($request->is_ajax()) {
            trigger_error('LOGIN_REQUIRED');
        }
        login_box('', $user->lang['LOGIN_REQUIRED']);
    }
    if (check_link_hash($request->variable('hash', ''), 'mark_notification_read')) {
        /* @var $phpbb_notifications \phpbb\notification\manager */
        $phpbb_notifications = $phpbb_container->get('notification_manager');
        $notification = $phpbb_notifications->load_notifications(array('notification_id' => $mark_notification));
        if (isset($notification['notifications'][$mark_notification])) {
            $notification = $notification['notifications'][$mark_notification];
            $notification->mark_read();
            if ($request->is_ajax()) {
                $json_response = new \phpbb\json_response();
                $json_response->send(array('success' => true));
            }
            if ($redirect = $request->variable('redirect', '')) {
                redirect(append_sid($phpbb_root_path . $redirect));
            }
            redirect($notification->get_redirect_url());
        }
开发者ID:Alexey3112,项目名称:phpbb,代码行数:31,代码来源:index.php

示例12: append_sid

// General Viewtopic URL for return links
$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "f={$forum_id}&amp;t={$topic_id}" . ($start == 0 ? '' : "&amp;start={$start}") . (strlen($u_sort_param) ? "&amp;{$u_sort_param}" : '') . ($highlight_match ? "&amp;hilit={$highlight}" : ''));
// Are we watching this topic?
$s_watching_topic = array('link' => '', 'link_toggle' => '', 'title' => '', 'title_toggle' => '', 'is_watching' => false);
if ($config['allow_topic_notify']) {
    $notify_status = isset($topic_data['notify_status']) ? $topic_data['notify_status'] : null;
    watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']);
    // Reset forum notification if forum notify is set
    if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) {
        $s_watching_forum = $s_watching_topic;
        watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
    }
}
// Bookmarks
if ($config['allow_bookmarks'] && $user->data['is_registered'] && $request->variable('bookmark', 0)) {
    if (check_link_hash($request->variable('hash', ''), "topic_{$topic_id}")) {
        if (!$topic_data['bookmarked']) {
            $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array('user_id' => $user->data['user_id'], 'topic_id' => $topic_id));
            $db->sql_query($sql);
        } else {
            $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . "\n\t\t\t\tWHERE user_id = {$user->data['user_id']}\n\t\t\t\t\tAND topic_id = {$topic_id}";
            $db->sql_query($sql);
        }
        $message = $topic_data['bookmarked'] ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED'];
        if (!$request->is_ajax()) {
            $message .= '<br /><br />' . $user->lang('RETURN_TOPIC', '<a href="' . $viewtopic_url . '">', '</a>');
        }
    } else {
        $message = $user->lang['BOOKMARK_ERR'];
        if (!$request->is_ajax()) {
            $message .= '<br /><br />' . $user->lang('RETURN_TOPIC', '<a href="' . $viewtopic_url . '">', '</a>');
开发者ID:ramukumar555,项目名称:phpbb,代码行数:31,代码来源:viewtopic.php

示例13: main

 function main()
 {
     // Start the page
     global $config, $user, $template, $request, $phpbb_extension_manager, $db, $phpbb_root_path, $phpEx, $phpbb_log, $cache;
     $this->db = $db;
     $this->config = $config;
     $this->template = $template;
     $this->user = $user;
     $this->cache = $cache;
     $this->request = $request;
     $this->log = $phpbb_log;
     $user->add_lang(array('install', 'acp/extensions', 'migrator'));
     $this->page_title = 'ACP_EXTENSIONS';
     $action = $request->variable('action', 'list');
     $ext_name = $request->variable('ext_name', '');
     // What is a safe limit of execution time? Half the max execution time should be safe.
     $safe_time_limit = ini_get('max_execution_time') / 2;
     $start_time = time();
     // Cancel action
     if ($request->is_set_post('cancel')) {
         $action = 'list';
         $ext_name = '';
     }
     if (in_array($action, array('enable', 'disable', 'delete_data')) && !check_link_hash($request->variable('hash', ''), $action . '.' . $ext_name)) {
         trigger_error('FORM_INVALID', E_USER_WARNING);
     }
     // If they've specified an extension, let's load the metadata manager and validate it.
     if ($ext_name) {
         $md_manager = new \phpbb\extension\metadata_manager($ext_name, $config, $phpbb_extension_manager, $template, $user, $phpbb_root_path);
         try {
             $md_manager->get_metadata('all');
         } catch (\phpbb\extension\exception $e) {
             trigger_error($e, E_USER_WARNING);
         }
     }
     // What are we doing?
     switch ($action) {
         case 'set_config_version_check_force_unstable':
             $force_unstable = $this->request->variable('force_unstable', false);
             if ($force_unstable) {
                 $s_hidden_fields = build_hidden_fields(array('force_unstable' => $force_unstable));
                 confirm_box(false, $user->lang('EXTENSION_FORCE_UNSTABLE_CONFIRM'), $s_hidden_fields);
             } else {
                 $config->set('extension_force_unstable', false);
                 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
             }
             break;
         case 'list':
         default:
             if (confirm_box(true)) {
                 $config->set('extension_force_unstable', true);
                 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
             }
             $this->list_enabled_exts($phpbb_extension_manager);
             $this->list_disabled_exts($phpbb_extension_manager);
             $this->list_available_exts($phpbb_extension_manager);
             $this->template->assign_vars(array('U_VERSIONCHECK_FORCE' => $this->u_action . '&amp;action=list&amp;versioncheck_force=1', 'FORCE_UNSTABLE' => $config['extension_force_unstable'], 'U_ACTION' => $this->u_action));
             add_form_key('version_check_settings');
             $this->tpl_name = 'acp_ext_list';
             break;
         case 'enable_pre':
             if (!$md_manager->validate_dir()) {
                 trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if (!$md_manager->validate_enable()) {
                 trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             $extension = $phpbb_extension_manager->get_extension($ext_name);
             if (!$extension->is_enableable()) {
                 trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if ($phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             $this->tpl_name = 'acp_ext_enable';
             $template->assign_vars(array('PRE' => true, 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_ENABLE_CONFIRM', $md_manager->get_metadata('display-name')), 'U_ENABLE' => $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('enable.' . $ext_name)));
             break;
         case 'enable':
             if (!$md_manager->validate_dir()) {
                 trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if (!$md_manager->validate_enable()) {
                 trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             $extension = $phpbb_extension_manager->get_extension($ext_name);
             if (!$extension->is_enableable()) {
                 trigger_error($user->lang['EXTENSION_NOT_ENABLEABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
             }
             if ($phpbb_extension_manager->is_enabled($ext_name)) {
                 redirect($this->u_action);
             }
             try {
                 while ($phpbb_extension_manager->enable_step($ext_name)) {
                     // Are we approaching the time limit? If so we want to pause the update and continue after refreshing
                     if (time() - $start_time >= $safe_time_limit) {
                         $template->assign_var('S_NEXT_STEP', true);
                         meta_refresh(0, $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name) . '&amp;hash=' . generate_link_hash('enable.' . $ext_name));
                     }
                 }
                 $this->log->add('admin', $user->data['user_id'], $user->ip, 'LOG_EXT_ENABLE', time(), array($ext_name));
//.........这里部分代码省略.........
开发者ID:mike-a-b,项目名称:crossfit,代码行数:101,代码来源:acp_extensions.php

示例14: main

 public function main($id, $mode)
 {
     global $config, $template, $user, $request, $phpbb_container;
     global $phpbb_root_path, $phpEx;
     add_form_key('ucp_notification');
     $start = $request->variable('start', 0);
     $form_time = $request->variable('form_time', 0);
     $form_time = $form_time <= 0 || $form_time > time() ? time() : $form_time;
     /* @var $phpbb_notifications \phpbb\notification\manager */
     $phpbb_notifications = $phpbb_container->get('notification_manager');
     /* @var $pagination \phpbb\pagination */
     $pagination = $phpbb_container->get('pagination');
     switch ($mode) {
         case 'notification_options':
             $subscriptions = $phpbb_notifications->get_global_subscriptions(false);
             // Add/remove subscriptions
             if ($request->is_set_post('submit')) {
                 if (!check_form_key('ucp_notification')) {
                     trigger_error('FORM_INVALID');
                 }
                 $notification_methods = $phpbb_notifications->get_subscription_methods();
                 foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types) {
                     foreach ($subscription_types as $type => $data) {
                         foreach ($notification_methods as $method => $method_data) {
                             if ($request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type]))) {
                                 $phpbb_notifications->add_subscription($type, 0, $method_data['id']);
                             } else {
                                 if (!$request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) {
                                     $phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
                                 }
                             }
                         }
                         if ($request->is_set_post(str_replace('.', '_', $type) . '_notification') && !isset($subscriptions[$type])) {
                             $phpbb_notifications->add_subscription($type);
                         } else {
                             if (!$request->is_set_post(str_replace('.', '_', $type) . '_notification') && isset($subscriptions[$type])) {
                                 $phpbb_notifications->delete_subscription($type);
                             }
                         }
                     }
                 }
                 meta_refresh(3, $this->u_action);
                 $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                 trigger_error($message);
             }
             $this->output_notification_methods($phpbb_notifications, $template, $user, 'notification_methods');
             $this->output_notification_types($subscriptions, $phpbb_notifications, $template, $user, 'notification_types');
             $this->tpl_name = 'ucp_notifications';
             $this->page_title = 'UCP_NOTIFICATION_OPTIONS';
             break;
         case 'notification_list':
         default:
             // Mark all items read
             if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_notifications_read')) {
                 $phpbb_notifications->mark_notifications_read(false, false, $user->data['user_id'], $form_time);
                 meta_refresh(3, $this->u_action);
                 $message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'];
                 if ($request->is_ajax()) {
                     $json_response = new \phpbb\json_response();
                     $json_response->send(array('MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $message, 'success' => true));
                 }
                 $message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
                 trigger_error($message);
             }
             // Mark specific notifications read
             if ($request->is_set_post('submit')) {
                 if (!check_form_key('ucp_notification')) {
                     trigger_error('FORM_INVALID');
                 }
                 $mark_read = $request->variable('mark', array(0));
                 if (!empty($mark_read)) {
                     $phpbb_notifications->mark_notifications_read_by_id($mark_read, $form_time);
                 }
             }
             $notifications = $phpbb_notifications->load_notifications(array('start' => $start, 'limit' => $config['topics_per_page'], 'count_total' => true));
             foreach ($notifications['notifications'] as $notification) {
                 $template->assign_block_vars('notification_list', $notification->prepare_for_display());
             }
             $base_url = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=ucp_notifications&amp;mode=notification_list");
             $start = $pagination->validate_start($start, $config['topics_per_page'], $notifications['total_count']);
             $pagination->generate_template_pagination($base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start);
             $template->assign_vars(array('TOTAL_COUNT' => $notifications['total_count'], 'U_MARK_ALL' => $base_url . '&amp;mark=all&amp;token=' . generate_link_hash('mark_all_notifications_read')));
             $this->tpl_name = 'ucp_notifications';
             $this->page_title = 'UCP_NOTIFICATION_LIST';
             break;
     }
     $template->assign_vars(array('TITLE' => $user->lang($this->page_title), 'TITLE_EXPLAIN' => $user->lang($this->page_title . '_EXPLAIN'), 'MODE' => $mode, 'FORM_TIME' => time()));
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:88,代码来源:ucp_notifications.php

示例15: watch_topic_forum

/**
* Topic and forum watching common code
*/
function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
{
    global $template, $db, $user, $phpEx, $start, $phpbb_root_path;
    $table_sql = $mode == 'forum' ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
    $where_sql = $mode == 'forum' ? 'forum_id' : 'topic_id';
    $match_id = $mode == 'forum' ? $forum_id : $topic_id;
    $u_url = "uid={$user->data['user_id']}";
    $u_url .= $mode == 'forum' ? '&amp;f' : '&amp;f=' . $forum_id . '&amp;t';
    // Is user watching this thread?
    if ($user_id != ANONYMOUS) {
        $can_watch = true;
        if ($notify_status == 'unset') {
            $sql = "SELECT notify_status\n\t\t\t\tFROM {$table_sql}\n\t\t\t\tWHERE {$where_sql} = {$match_id}\n\t\t\t\t\tAND user_id = {$user_id}";
            $result = $db->sql_query($sql);
            $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
            $db->sql_freeresult($result);
        }
        if (!is_null($notify_status) && $notify_status !== '') {
            if (isset($_GET['unwatch'])) {
                $uid = request_var('uid', 0);
                if ($uid != $user_id) {
                    $redirect_url = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;start={$start}");
                    $message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                    trigger_error($message);
                }
                if ($_GET['unwatch'] == $mode) {
                    $is_watching = 0;
                    $sql = 'DELETE FROM ' . $table_sql . "\n\t\t\t\t\t\tWHERE {$where_sql} = {$match_id}\n\t\t\t\t\t\t\tAND user_id = {$user_id}";
                    $db->sql_query($sql);
                }
                $redirect_url = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;start={$start}");
                meta_refresh(3, $redirect_url);
                $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                trigger_error($message);
            } else {
                $is_watching = true;
                if ($notify_status) {
                    $sql = 'UPDATE ' . $table_sql . "\n\t\t\t\t\t\tSET notify_status = 0\n\t\t\t\t\t\tWHERE {$where_sql} = {$match_id}\n\t\t\t\t\t\t\tAND user_id = {$user_id}";
                    $db->sql_query($sql);
                }
            }
        } else {
            if (isset($_GET['watch'])) {
                $token = request_var('hash', '');
                $redirect_url = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;start={$start}");
                if ($_GET['watch'] == $mode && check_link_hash($token, "{$mode}_{$match_id}")) {
                    $is_watching = true;
                    $sql = 'INSERT INTO ' . $table_sql . " (user_id, {$where_sql}, notify_status)\n\t\t\t\t\t\tVALUES ({$user_id}, {$match_id}, 0)";
                    $db->sql_query($sql);
                    $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                } else {
                    $message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
                }
                meta_refresh(3, $redirect_url);
                trigger_error($message);
            } else {
                $is_watching = 0;
            }
        }
    } else {
        if (isset($_GET['unwatch']) && $_GET['unwatch'] == $mode) {
            login_box();
        } else {
            $can_watch = 0;
            $is_watching = 0;
        }
    }
    if ($can_watch) {
        $s_watching['link'] = append_sid("{$phpbb_root_path}view{$mode}.{$phpEx}", "{$u_url}={$match_id}&amp;" . ($is_watching ? 'unwatch' : 'watch') . "={$mode}&amp;start={$start}&amp;hash=" . generate_link_hash("{$mode}_{$match_id}"));
        $s_watching['title'] = $user->lang[($is_watching ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
        $s_watching['is_watching'] = $is_watching;
    }
    return;
}
开发者ID:ubick,项目名称:lorekeepers.org,代码行数:77,代码来源:functions_display.php


注:本文中的check_link_hash函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。