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


PHP user::set_cookie方法代码示例

本文整理汇总了PHP中phpbb\user::set_cookie方法的典型用法代码示例。如果您正苦于以下问题:PHP user::set_cookie方法的具体用法?PHP user::set_cookie怎么用?PHP user::set_cookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpbb\user的用法示例。


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

示例1: set_board_announcement_cookie

 /**
  * Set a cookie to keep an announcement closed
  *
  * @return bool True
  * @access protected
  */
 protected function set_board_announcement_cookie()
 {
     // Get board announcement data from the DB text object
     $announcement_timestamp = $this->config_text->get('announcement_timestamp');
     // Store the announcement timestamp/id in a cookie with a 1 year expiration
     $this->user->set_cookie('baid', $announcement_timestamp, strtotime('+1 year'));
     return true;
 }
开发者ID:harsha-sira,项目名称:Online-Forum,代码行数:14,代码来源:controller.php

示例2: toggle_edit_mode

 protected function toggle_edit_mode()
 {
     $edit_mode = $this->request->variable($this->config['cookie_name'] . '_sm_edit_mode', false, false, \phpbb\request\request_interface::COOKIE);
     if ($this->request->is_set('edit_mode')) {
         $edit_mode = $this->request->variable('edit_mode', false);
         $this->user->set_cookie('sm_edit_mode', $edit_mode, 0);
     }
     return $edit_mode;
 }
开发者ID:BogusCurry,项目名称:phpBB-ext-sitemaker,代码行数:9,代码来源:display.php

示例3: set_cookie_categories

 /**
  * {@inheritdoc}
  */
 public function set_cookie_categories($forum_id)
 {
     // Set the collapsed category data array
     $this->set_collapsed_categories($forum_id);
     // Update the cookie with json encoded array of collapsed category data
     $this->user->set_cookie('ccat', json_encode($this->collapsed_categories), strtotime('+1 year'));
     // As we are unable to check immediately if the cookie was set, return true anyway
     return true;
 }
开发者ID:phpbb-addons,项目名称:collapsible-categories,代码行数:12,代码来源:operator.php

示例4: submit

 /**
  * @param int  $user_id
  * @param bool $admin
  * @param bool $auto_login
  * @param bool $viewonline
  * @param string $class
  * @return \Symfony\Component\HttpFoundation\Response
  * @throws http_exception
  */
 public function submit($user_id, $admin, $auto_login, $viewonline, $class)
 {
     $this->user->add_lang_ext('paul999/tfa', 'common');
     if (!check_form_key('tfa_login_page')) {
         throw new http_exception(403, 'FORM_INVALID');
     }
     if (empty($this->user->data['tfa_random']) || $user_id != $this->user->data['tfa_uid']) {
         throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
     }
     $random = $this->request->variable('random', '');
     if ($this->user->data['tfa_random'] !== $random || strlen($random) !== 40) {
         throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
     }
     $sql_ary = array('tfa_random' => '', 'tfa_uid' => 0);
     $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\tWHERE\n\t\t\t\tsession_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND\n\t\t\t\tsession_user_id = '" . (int) $this->user->data['user_id'];
     $this->db->sql_query($sql);
     if (empty($class)) {
         throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
     }
     $module = $this->session_helper->findModule($class);
     if ($module == null) {
         throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
     }
     $redirect = $this->request->variable('redirect', "{$this->root_path}/index.{$this->php_ext}");
     try {
         if (!$module->login($user_id)) {
             $this->template->assign_var('S_ERROR', $this->user->lang('TFA_INCORRECT_KEY'));
             $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect);
         }
     } catch (http_exception $ex) {
         if ($ex->getStatusCode() == 400) {
             $this->template->assign_var('S_ERROR', $ex->getMessage());
             $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect);
         }
     }
     $old_session_id = $this->user->session_id;
     if ($admin) {
         $cookie_expire = time() - 31536000;
         $this->user->set_cookie('u', '', $cookie_expire);
         $this->user->set_cookie('sid', '', $cookie_expire);
     }
     $result = $this->user->session_create($user_id, $admin, $auto_login, $viewonline);
     // Successful session creation
     if ($result === true) {
         // If admin re-authentication we remove the old session entry because a new one has been created...
         if ($admin) {
             // the login array is used because the user ids do not differ for re-authentication
             $sql = 'DELETE FROM ' . SESSIONS_TABLE . "\n\t\t\t\t\tWHERE session_id = '" . $this->db->sql_escape($old_session_id) . "'\n\t\t\t\t\tAND session_user_id = " . (int) $user_id;
             $this->db->sql_query($sql);
             redirect(append_sid("{$this->root_path}adm/index.{$this->php_ext}", false, true, $this->user->data['session_id']));
         }
         redirect(append_sid($redirect, false, true, $this->user->data['session_id']));
     }
     throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
 }
开发者ID:paul999,项目名称:phpbb_2fa,代码行数:64,代码来源:main_controller.php

示例5: viewtopic_lfg

 public function viewtopic_lfg($event)
 {
     //$topic_data = $event['topic_data'];
     //$topic_id = $topic_data['topic_id'];
     $post_row = $event['post_row'];
     $current_row_number = $event['current_row_number'];
     $message = $post_row['MESSAGE'];
     $att = $post_row['S_HAS_ATTACHMENTS'];
     $user_id = $this->user->data['user_id'];
     $max = $this->max_topics;
     $read = $cookie = $this->request->variable($this->config['cookie_name'] . '_cookie_lfg', '', true, \phpbb\request\request_interface::COOKIE);
     if ($user_id == 1 and $current_row_number == 0) {
         if ($read >= $max) {
             $message = $this->user->lang['MAX_GUEST'];
             $att = false;
         } else {
             $this->user->set_cookie('cookie_lfg', $read + 1, strtotime('+1 year'));
         }
     }
     $post_row['S_HAS_ATTACHMENTS'] = $att;
     $post_row['MESSAGE'] = $message;
     $event['post_row'] = $post_row;
 }
开发者ID:bruninoit,项目名称:lfg,代码行数:23,代码来源:lfg.php

示例6: parse_template

    /**
     * Parse template variables for module
     *
     * @param int $module_id	Module ID
     * @param string $type	Module type (center or side)
     *
     * @return string HTML filename
     */
    protected function parse_template($module_id, $type = '')
    {
        $this->user->add_lang('viewtopic');
        // check if we need to include the bbcode class
        if (!class_exists('bbcode')) {
            include $this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext;
        }
        $view = $this->request->variable('view', '');
        $update = $this->request->variable('update', false);
        $poll_view = $this->request->variable('polls', '');
        $poll_view_ar = strpos($poll_view, ',') !== false ? explode(',', $poll_view) : ($poll_view != '' ? array($poll_view) : array());
        if ($update && $this->config['board3_poll_allow_vote_' . $module_id]) {
            $up_topic_id = $this->request->variable('t', 0);
            $up_forum_id = $this->request->variable('f', 0);
            $voted_id = $this->request->variable('vote_id', array('' => 0));
            $cur_voted_id = array();
            if ($this->user->data['is_registered']) {
                $sql = 'SELECT poll_option_id
					FROM ' . POLL_VOTES_TABLE . '
					WHERE topic_id = ' . (int) $up_topic_id . '
						AND vote_user_id = ' . (int) $this->user->data['user_id'];
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $cur_voted_id[] = $row['poll_option_id'];
                }
                $this->db->sql_freeresult($result);
            } else {
                // Cookie based guest tracking ... I don't like this but hum ho
                // it's oft requested. This relies on "nice" users who don't feel
                // the need to delete cookies to mess with results.
                if ($this->request->is_set($this->config['cookie_name'] . '_poll_' . $up_topic_id, \phpbb\request\request_interface::COOKIE)) {
                    $cur_voted_id = explode(',', $this->request->variable($this->config['cookie_name'] . '_poll_' . $up_topic_id, '', true, \phpbb\request\request_interface::COOKIE));
                    $cur_voted_id = array_map('intval', $cur_voted_id);
                }
            }
            $sql = 'SELECT t.poll_length, t.poll_start, t.poll_vote_change, t.topic_status, f.forum_status, t.poll_max_options
				FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f\n\t\t\t\tWHERE t.forum_id = f.forum_id\n\t\t\t\t\tAND t.topic_id = " . (int) $up_topic_id . "\n\t\t\t\t\tAND t.forum_id = " . (int) $up_forum_id;
            $result = $this->db->sql_query_limit($sql, 1);
            $topic_data = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            $s_can_up_vote = (!sizeof($cur_voted_id) && $this->auth->acl_get('f_vote', $up_forum_id) || $this->auth->acl_get('f_votechg', $up_forum_id) && $topic_data['poll_vote_change']) && ($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time() || $topic_data['poll_length'] == 0) && $topic_data['topic_status'] != ITEM_LOCKED && $topic_data['forum_status'] != ITEM_LOCKED ? true : false;
            if ($s_can_up_vote) {
                $redirect_url = $this->modules_helper->route('board3_portal_controller');
                if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id)) {
                    meta_refresh(5, $redirect_url);
                    if (!sizeof($voted_id)) {
                        $message = 'NO_VOTE_OPTION';
                    } else {
                        if (sizeof($voted_id) > $topic_data['poll_max_options']) {
                            $message = 'TOO_MANY_VOTE_OPTIONS';
                        } else {
                            $message = 'VOTE_CONVERTED';
                        }
                    }
                    $message = $this->user->lang[$message] . '<br /><br />' . sprintf($this->user->lang['RETURN_PORTAL'], '<a href="' . $redirect_url . '">', '</a>');
                    trigger_error($message);
                }
                foreach ($voted_id as $option) {
                    if (in_array($option, $cur_voted_id)) {
                        continue;
                    }
                    $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
						SET poll_option_total = poll_option_total + 1
						WHERE poll_option_id = ' . (int) $option . '
							AND topic_id = ' . (int) $up_topic_id;
                    $this->db->sql_query($sql);
                    if ($this->user->data['is_registered']) {
                        $sql_ary = array('topic_id' => (int) $up_topic_id, 'poll_option_id' => (int) $option, 'vote_user_id' => (int) $this->user->data['user_id'], 'vote_user_ip' => (string) $this->user->ip);
                        $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                        $this->db->sql_query($sql);
                    }
                }
                foreach ($cur_voted_id as $option) {
                    if (!in_array($option, $voted_id)) {
                        $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
							SET poll_option_total = poll_option_total - 1
							WHERE poll_option_id = ' . (int) $option . '
								AND topic_id = ' . (int) $up_topic_id;
                        $this->db->sql_query($sql);
                        if ($this->user->data['is_registered']) {
                            $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
								WHERE topic_id = ' . (int) $up_topic_id . '
									AND poll_option_id = ' . (int) $option . '
									AND vote_user_id = ' . (int) $this->user->data['user_id'];
                            $this->db->sql_query($sql);
                        }
                    }
                }
                if ($this->user->data['user_id'] == ANONYMOUS && !$this->user->data['is_bot']) {
                    $this->user->set_cookie('poll_' . $up_topic_id, implode(',', $voted_id), time() + 31536000);
                }
                $sql = 'UPDATE ' . TOPICS_TABLE . '
//.........这里部分代码省略.........
开发者ID:alhitary,项目名称:Board3-Portal,代码行数:101,代码来源:poll.php

示例7: track_cookie

 /**
  * Set tracking data in a cookie.
  *
  * @param int $type			Object type
  * @param int $id			Object id
  * @param bool|int $time	Optional tracking time to use,
  * 		if none is given, the value from time() is used
  */
 protected function track_cookie($type, $id, $time = false)
 {
     $this->store[$type][$id] = $time === false ? time() : (int) $time;
     $this->user->set_cookie('titania_track', serialize($this->store), time() + 31536000);
 }
开发者ID:Sajaki,项目名称:customisation-db,代码行数:13,代码来源:tracking.php

示例8: do_poll_voting_modifications


//.........这里部分代码省略.........
                $message = $this->user->lang[$message] . '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
                trigger_error($message);
            }
            if ($this->user->data['is_registered'] && in_array(0, $cur_voted_id)) {
                $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
					WHERE topic_id = ' . (int) $topic_data['topic_id'] . '
						AND poll_option_id = ' . 0 . '
						AND vote_user_id = ' . (int) $this->user->data['user_id'];
                $this->db->sql_query($sql);
                $cur_voted_id = array_keys($cur_voted_val);
            }
        }
        if ($update && $s_can_vote && $s_is_scoring) {
            $voted_total_val = 0;
            $vote_changed = false;
            foreach ($voted_id as $option) {
                $voted_total_val += $voted_val[$option];
                if (isset($cur_voted_val[$option]) && $cur_voted_val[$option] > $voted_val[$option]) {
                    $vote_changed = true;
                }
            }
            if ($voted_total_val > $topic_data['wolfsblvt_poll_total_value'] || !$s_can_change_vote && $vote_changed) {
                meta_refresh(5, $viewtopic_url);
                $message = '';
                if (!$s_can_change_vote && $vote_changed) {
                    $message = 'AP_VOTE_CHANGED';
                } else {
                    if ($voted_total_val > $topic_data['wolfsblvt_poll_total_value']) {
                        $message = 'AP_TOO_MANY_VOTES';
                    }
                }
                $message = $this->user->lang[$message] . '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
                trigger_error($message);
            }
            foreach ($cur_voted_id as $option) {
                if (!in_array($option, $voted_id) || $cur_voted_val[$option] != $voted_val[$option]) {
                    $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
						SET poll_option_total = poll_option_total - ' . (int) $cur_voted_val[$option] . '
						WHERE poll_option_id = ' . (int) $option . '
							AND topic_id = ' . (int) $topic_data['topic_id'];
                    $this->db->sql_query($sql);
                    $vote_counts[$option] -= (int) $cur_voted_val[$option];
                    if ($this->user->data['is_registered']) {
                        $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
							WHERE topic_id = ' . (int) $topic_data['topic_id'] . '
								AND poll_option_id = ' . (int) $option . '
								AND vote_user_id = ' . (int) $this->user->data['user_id'];
                        $this->db->sql_query($sql);
                    }
                }
            }
            foreach ($voted_id as $option) {
                if (in_array($option, $cur_voted_id) && $cur_voted_val[$option] == $voted_val[$option]) {
                    continue;
                }
                $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
					SET poll_option_total = poll_option_total + ' . (int) $voted_val[$option] . '
					WHERE poll_option_id = ' . (int) $option . '
						AND topic_id = ' . (int) $topic_data['topic_id'];
                $this->db->sql_query($sql);
                $vote_counts[$option] += (int) $voted_val[$option];
                if ($this->user->data['is_registered']) {
                    $sql_ary = array('topic_id' => (int) $topic_data['topic_id'], 'poll_option_id' => (int) $option, 'wolfsblvt_poll_option_value' => (int) $voted_val[$option], 'vote_user_id' => (int) $this->user->data['user_id'], 'vote_user_ip' => (string) $this->user->ip);
                    $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                    $this->db->sql_query($sql);
                }
            }
            if ($this->user->data['user_id'] == ANONYMOUS && !$this->user->data['is_bot']) {
                $this->user->set_cookie('poll_' . $topic_data['topic_id'], implode(',', array_keys($voted_val)), time() + 31536000);
                $this->user->set_cookie('poll_votes_' . $topic_data['topic_id'], implode(',', array_values($voted_val)), time() + 31536000);
            }
            $sql = 'UPDATE ' . TOPICS_TABLE . '
				SET poll_last_vote = ' . time() . '
				WHERE topic_id = ' . $topic_data['topic_id'];
            $this->db->sql_query($sql);
            $message = $this->user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
            if ($this->request->is_ajax()) {
                // Filter out invalid options
                $valid_user_votes = array_intersect(array_keys($vote_counts), $voted_id);
                $s_vote_incomplete = $s_incremental ? $s_is_scoring ? $voted_total_val < $topic_data['wolfsblvt_poll_total_value'] : sizeof($valid_user_votes) < $topic_data['poll_max_options'] : !sizeof($valid_user_votes);
                $data = array('NO_VOTES' => $this->user->lang['NO_VOTES'], 'success' => true, 'scoring' => true, 'user_votes' => array_flip($valid_user_votes), 'user_vote_counts' => $voted_val, 'vote_counts' => $vote_counts, 'total_votes' => array_sum($vote_counts), 'can_vote' => $s_vote_incomplete || $s_can_change_vote);
                $json_response = new \phpbb\json_response();
                $json_response->send($data);
            }
            meta_refresh(5, $viewtopic_url);
            trigger_error($message);
        }
        // If we have ajax call here with no_vote, we exit save it here and return json_response
        if (in_array('wolfsblvt_no_vote', $options) && $this->request->is_ajax() && $this->request->is_set('no_vote')) {
            if ($this->user->data['is_registered']) {
                $sql_ary = array('topic_id' => (int) $topic_data['topic_id'], 'poll_option_id' => (int) 0, 'wolfsblvt_poll_option_value' => (int) 0, 'vote_user_id' => (int) $this->user->data['user_id'], 'vote_user_ip' => (string) $this->user->ip);
                $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                $this->db->sql_query($sql);
                $json_response = new \phpbb\json_response();
                $json_response->send(array('success' => true));
            }
        }
        $this->cur_voted_val = $cur_voted_val;
        return;
    }
开发者ID:Galixte,项目名称:advancedpolls,代码行数:101,代码来源:advancedpolls.php

示例9: user_setup

 public function user_setup($event)
 {
     $this->quick_language_enable = false;
     //get all installed languages
     $sql = "SELECT * FROM " . LANG_TABLE;
     $result = $this->db->sql_query($sql);
     $counter = 0;
     $this->lang_info = array();
     while ($row = $this->db->sql_fetchrow($result)) {
         $this->lang_info[] = $row;
         if (!($row['lang_iso'] == 'en' && !$this->is_english_show)) {
             $counter++;
         }
     }
     $this->db->sql_freeresult($result);
     if ($counter < 2 || $event['user_data']['is_bot'] || $event['user_data']['user_id'] == ANONYMOUS && !$this->allow_guests) {
         //do nothing
         $this->quick_language_enable = false;
         $this->current_lang = $event['user_data']['is_registered'] ? $event['user_lang_name'] : $this->config['default_lang'];
         return;
     }
     $this->quick_language_enable = true;
     $this->current_lang = $event['user_data']['is_registered'] ? $event['user_lang_name'] : $this->request_cookie('quicklang', $this->config['default_lang']);
     $submit = isset($_POST['h_lang']) ? true : false;
     if (!$submit) {
         if ($event['user_data']['is_registered']) {
             return;
         } else {
             if ($this->current_lang != $this->config['default_lang']) {
                 $event['user_lang_name'] = $this->current_lang;
             }
             return;
         }
     }
     $new_lang = basename($this->request->variable('h_lang', $this->current_lang));
     //validate user data
     $res = $this->get_iso($new_lang);
     $this->new_lang = $new_lang;
     if ($res == '') {
         $this->error = listener::QUICK_LANG_NO;
         return;
     }
     if ($res == 'en' && !$this->is_english_show) {
         $this->error = listener::QUICK_LANG_EN_DISABLE;
         return;
     }
     //registered user
     if ($event['user_data']['is_registered']) {
         if ($new_lang != $event['user_data']['user_lang']) {
             //change user lang preference
             $sql = "UPDATE " . USERS_TABLE . " SET user_lang = '" . $new_lang . "' WHERE user_id=" . (int) $event['user_data']['user_id'];
             $this->db->sql_query($sql);
             $event['user_lang_name'] = $new_lang;
             $this->current_lang = $new_lang;
             return;
         }
     }
     // guest (not bot)
     if ($event['user_data']['user_id'] == ANONYMOUS) {
         if ($new_lang != $this->current_lang) {
             //change guest lang preference
             $this->user->set_cookie('quicklang', $new_lang, 0);
             $event['user_lang_name'] = $new_lang;
             $this->current_lang = $new_lang;
         }
     }
 }
开发者ID:ezpz-cz,项目名称:web-plugins,代码行数:67,代码来源:listener.php


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