public function submit_post_end($event)
    {
        if ($event['mode'] == 'edit') {
            // we need to ensure that what we are resetting is appropriate
            // do we care about when someone edits the first post of a topic?
            // $event['data']['topic_first_post_id'] == $event['data']['post_id'] $post_mode = 'edit_first_post'
            $ext_post_mode = '';
            if ($event['data']['topic_posts_approved'] + $event['data']['topic_posts_unapproved'] + $event['data']['topic_posts_softdeleted'] == 1) {
                $ext_post_mode = 'edit_topic';
            } else {
                if ($event['data']['topic_last_post_id'] == $event['data']['post_id']) {
                    $ext_post_mode = 'edit_last_post';
                }
            }
            if ($ext_post_mode == 'edit_last_post' || $ext_post_mode == 'edit_topic') {
                $sql = 'UPDATE ' . POSTS_TABLE . '
					SET post_time = ' . time() . '
					WHERE post_id = ' . $event['data']['post_id'] . '
						AND topic_id = ' . $event['data']['topic_id'];
                $this->db->sql_query($sql);
                $sql = 'UPDATE ' . TOPICS_TABLE . '
					SET topic_last_post_time = ' . time() . '
					WHERE topic_id = ' . $event['data']['topic_id'];
                $this->db->sql_query($sql);
                if (!function_exists('update_post_information')) {
                    include $this->root_path . 'includes/functions_posting.' . $this->php_ext;
                }
                update_post_information('forum', $event['data']['forum_id']);
                markread('post', $event['data']['forum_id'], $event['data']['topic_id'], $event['data']['post_time']);
            }
        }
    }
    /**
     * Display zodiac on viewing user profile
     *
     * @param object $event The event object
     * @return null
     * @access public
     */
    public function memberlist_view_profile($event)
    {
        $user_id = $event['member']['user_id'];
        $reg_date = $event['member']['user_regdate'];
        $this->user->add_lang_ext('rmcgirr83/searchusertopics', 'common');
        // get all topics started by the user and make sure they are visible
        $sql = 'SELECT t.*, p.post_visibility
			FROM ' . TOPICS_TABLE . ' t
			LEFT JOIN ' . POSTS_TABLE . ' p ON t.topic_first_post_id = p.post_id
			WHERE t.topic_poster = ' . $user_id . '
			ORDER BY t.topic_time ASC';
        $result = $this->db->sql_query($sql);
        $topics_num = 0;
        while ($row = $this->db->sql_fetchrow($result)) {
            if (!$this->auth->acl_get('f_read', $row['forum_id'])) {
                continue;
            }
            if ($row['post_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $row['forum_id'])) {
                continue;
            }
            ++$topics_num;
        }
        $this->db->sql_freeresult($result);
        if ($topics_num) {
            // Do the relevant calculations
            $users_days = max(1, round((time() - $reg_date) / 86400));
            $topics_per_day = $topics_num / $users_days;
            $topics_percent = $this->config['num_topics'] ? min(100, $topics_num / $this->config['num_topics'] * 100) : 0;
            $this->template->assign_vars(array('TOPICS' => $topics_num, 'L_TOTAL_TOPICS' => $this->user->lang('TOTAL_TOPICS', $topics_num), 'TOPICS_PER_DAY' => $this->user->lang('TOPICS_PER_DAY', $topics_per_day), 'TOPICS_PERCENT' => $this->user->lang('TOPICS_PERCENT', $topics_percent), 'U_SEARCH_TOPICS' => $this->auth->acl_get('u_search') ? append_sid("{$this->root_path}search.{$this->php_ext}", "author_id={$user_id}&sr=topics&sf=firstpost") : ''));
        }
    }
Ejemplo n.º 3
0
    /**
     * Display zodiac on viewing user profile
     *
     * @param object $event The event object
     * @return null
     * @access public
     */
    public function memberlist_view_profile($event)
    {
        $user_id = $event['member']['user_id'];
        $this->user->add_lang_ext('rmcgirr83/topicsbyuser', 'common');
        // get all topics started by the user and make sure they are visible
        $sql = 'SELECT t.*, p.post_visibility
			FROM ' . TOPICS_TABLE . ' t
			LEFT JOIN ' . POSTS_TABLE . ' p ON t.topic_first_post_id = p.post_id
			WHERE t.topic_poster = ' . $user_id . '
			ORDER BY t.topic_time ASC';
        $result = $this->db->sql_query($sql);
        $count = 0;
        $topic_options = '<option value="">' . $this->user->lang['CHOOSE_A_TOPIC'] . '</option>';
        while ($row = $this->db->sql_fetchrow($result)) {
            if (!$this->auth->acl_get('f_read', $row['forum_id'])) {
                continue;
            }
            if ($row['post_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $row['forum_id'])) {
                continue;
            }
            ++$count;
            $topic_color = $row['post_visibility'] != ITEM_APPROVED ? 'class="error"' : '';
            $topic_options .= '<option value="' . append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']) . '" ' . $topic_color . '>&nbsp;&nbsp;' . truncate_string($row['topic_title'], 30, 255, false, $this->user->lang['ELLIPSIS']) . '</option>';
        }
        $this->db->sql_freeresult($result);
        if (!empty($count)) {
            $this->template->assign_vars(array('HAS_TOPICS' => true, 'S_TOPIC_OPTIONS' => $topic_options));
        }
    }
    /**
     * Get nru group id
     *
     * @return int group id
     */
    public function getnruid()
    {
        $sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = 'NEWLY_REGISTERED'\n\t\t\t\t\tAND group_type = " . GROUP_SPECIAL;
        $result = $this->db->sql_query($sql);
        $group_id = $this->db->sql_fetchfield('group_id');
        $this->db->sql_freeresult($result);
        if (!$group_id) {
            return false;
        }
        return (int) $group_id;
    }
Ejemplo n.º 5
0
    /**
     * Set own position on map
     *
     * @return type
     */
    public function position()
    {
        if ($this->user->data['user_id'] == ANONYMOUS || !$this->auth->acl_get('u_usermap_add')) {
            trigger_error('NOT_AUTHORISED');
        }
        $data = array('user_usermap_lon' => substr($this->request->variable('lon', ''), 0, 10), 'user_usermap_lat' => substr($this->request->variable('lat', ''), 0, 10));
        if (confirm_box(true)) {
            if (!function_exists('validate_data')) {
                include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
            }
            $error = validate_data($data, array('user_usermap_lon' => array('match', false, self::REGEX_LON), 'user_usermap_lat' => array('match', false, self::REGEX_LAT)));
            if (sizeof($error)) {
                $error = array_map(array($this->user, 'lang'), $error);
                trigger_error(implode('<br>', $error));
            }
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', $data) . '
				WHERE user_id = ' . (int) $this->user->data['user_id'];
            $this->db->sql_query($sql);
            trigger_error('POSITION_SET');
        } else {
            confirm_box(false, $this->user->lang('CONFIRM_COORDINATES_SET', $data['user_usermap_lon'], $data['user_usermap_lat']), build_hidden_fields(array('lon' => $data['user_usermap_lon'], 'lat' => $data['user_usermap_lat'])));
        }
        return $this->index();
    }
    private function obtain_guest_count_24()
    {
        $total_guests_online_24 = 0;
        if ($this->config['load_online_guests']) {
            // Get number of online guests for the past 24 hours
            // caching and main sql if none yet
            if (($total_guests_online_24 = $this->cache->get('_total_guests_online_24')) === false) {
                if ($this->db->get_sql_layer() === 'sqlite' || $this->db->get_sql_layer() === 'sqlite3') {
                    $sql = 'SELECT COUNT(session_ip) as num_guests_24
						FROM (
							SELECT DISTINCT session_ip
							FROM ' . SESSIONS_TABLE . '
							WHERE session_user_id = ' . ANONYMOUS . '
								AND session_time >= ' . ($this->interval - (int) ($this->interval % 60)) . ')';
                } else {
                    $sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests_24
						FROM ' . SESSIONS_TABLE . '
						WHERE session_user_id = ' . ANONYMOUS . '
							AND session_time >= ' . ($this->interval - (int) ($this->interval % 60));
                }
                $result = $this->db->sql_query($sql);
                $total_guests_online_24 = (int) $this->db->sql_fetchfield('num_guests_24');
                $this->db->sql_freeresult($result);
                // cache this data for 5 minutes, this improves performance
                $this->cache->put('_total_guests_online_24', $total_guests_online_24, 300);
            }
        }
        return $total_guests_online_24;
    }
Ejemplo n.º 7
0
    public function display_tpotm($event)
    {
        $now = time();
        $date_today = gmdate("Y-m-d", $now);
        list($year_cur, $month_cur, $day1) = split('-', $date_today);
        // Start time for current month
        $month_start_cur = gmmktime(0, 0, 0, $month_cur, 1, $year_cur);
        $month_start = $month_start_cur;
        $month_end = $now;
        // group_id 5 = administrators
        // group_id 4 = global moderators
        // this groups belong to a Vanilla 3.1.x board
        $sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_type, u.group_id, COUNT(p.post_id) AS total_posts
			FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p
				WHERE u.user_id > ' . ANONYMOUS . '
					AND u.user_id = p.poster_id
						AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . '
							AND (u.user_type <> ' . USER_FOUNDER . ')
								AND (u.group_id <> 5)
									AND (u.group_id <> 4)
			GROUP BY u.user_id
			ORDER BY total_posts DESC';
        $result = $this->db->sql_query_limit($sql, 1);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // let's go then..
        // posts made into the selected elapsed time
        $topm_tp = $row['total_posts'];
        $topm_un = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
        // there is not a Top Poster, usually happens with fresh installations, where only the FOUNDER made the first post/topic. Or no normal users already did it.
        //Here TOPM_UN reflects this state.
        $this->template->assign_vars(array('TOPM_UN' => $topm_tp < 1 ? $topm_un = $this->user->lang['TOP_USERNAME_NONE'] : $topm_un, 'L_TPOTM' => $this->user->lang['TOP_CAT'], 'L_TOPM_UNA_L' => $this->user->lang['TOP_USERNAME'], 'L_TOPM_UPO_L' => sprintf($this->user->lang['TOP_USER_MONTH_POSTS'], $topm_tp), 'L_TOPM_POSTS_L' => $topm_tp > 1 || $topm_tp == 0 ? $this->user->lang['TOP_POSTS'] : $this->user->lang['TOP_POST']));
    }
Ejemplo n.º 8
0
    public function position()
    {
        if ($this->user->data['user_id'] == ANONYMOUS || !$this->auth->acl_get('u_usermap_add')) {
            trigger_error('NOT_AUTHORISED');
        }
        $lon = substr($this->request->variable('lon', ''), 0, 10);
        $lat = substr($this->request->variable('lat', ''), 0, 10);
        if (confirm_box(true)) {
            $data = array('user_usermap_lon' => $lon, 'user_usermap_lat' => $lat);
            if (!function_exists('validate_data')) {
                include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
            }
            $error = validate_data($data, array('user_usermap_lon' => array(array('string', true, 5, 10)), 'user_usermap_lat' => array(array('string', true, 5, 10))));
            $error = array_map(array($this->user, 'lang'), $error);
            if (sizeof($error)) {
                trigger_error(implode('<br>', $error) . '<br><br><a href="' . $this->helper->route('tas2580_usermap_index', array()) . '">' . $this->user->lang('BACK_TO_USERMAP') . '</a>');
            }
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', $data) . '
				WHERE user_id = ' . (int) $this->user->data['user_id'];
            $this->db->sql_query($sql);
            trigger_error('POSITION_SET');
        } else {
            confirm_box(false, $this->user->lang('CONFIRM_COORDINATES_SET', $lon, $lat), build_hidden_fields(array('lon' => $lon, 'lat' => $lat)));
        }
        return $this->index();
    }
Ejemplo n.º 9
0
 /**
  * Validates the request's trader type with the forum's trader_type and returns the corresponding (int) $type or null if invalid
  * @param $forum_id
  * @param $type
  * @return int
  */
 public function validateForumType($forum_id, $type, $isStringRep)
 {
     $result = $this->db->sql_query('SELECT enabled_trader_types FROM ' . FORUMS_TABLE . ' WHERE forum_id=' . $forum_id);
     $forum_row = $this->db->sql_fetchrow($result);
     $forum_type = $forum_row['enabled_trader_types'];
     if ($isStringRep) {
         switch ($type) {
             case 'buy':
                 $type = self::TOPIC_TYPE_BUY;
                 break;
             case 'sell':
                 $type = self::TOPIC_TYPE_SELL;
                 break;
             case 'trade':
                 $type = self::TOPIC_TYPE_TRADE;
                 break;
             default:
                 $type = null;
         }
     }
     if (!is_null($type) && $type <= $forum_type) {
         return $type;
     } else {
         return null;
     }
 }
 /**
  * Activate user
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 private function user_justification_activate()
 {
     $user = $this->data;
     if (!function_exists('user_active_flip')) {
         include $this->root_path . 'includes/functions_user.' . $this->php_ext;
     }
     if (!class_exists('messenger')) {
         include $this->root_path . 'includes/functions_messenger.' . $this->php_ext;
     }
     user_active_flip('activate', $user['user_id']);
     $messenger = new \messenger(false);
     $messenger->template('admin_welcome_activated', $user['user_lang']);
     $messenger->to($user['user_email'], $user['username']);
     $messenger->anti_abuse_headers($this->config, $this->user);
     $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user['username'])));
     $messenger->send(NOTIFY_EMAIL);
     $messenger->save_queue();
     // Remove the notification
     $this->notification_manager->delete_notifications('notification.type.admin_activate_user', $user['user_id']);
     $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\tSET user_actkey = ''\n\t\t\tWHERE user_id = {$user['user_id']}";
     $this->db->sql_query($sql);
     // Create the correct logs
     $this->log->add('user', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_ACTIVE_USER', false, array('reportee_id' => $user['user_id']));
     $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_ACTIVE', false, array($user['username']));
 }
    /**
     * Clear user reputation
     *
     * @param int $uid	User ID
     * @return null
     * @access public
     */
    public function clear_user($uid)
    {
        $this->user->add_lang_ext('pico/reputation', 'reputation_system');
        $is_ajax = $this->request->is_ajax();
        $submit = false;
        $sql_array = array('SELECT' => 'r.*, ut.username AS username_to', 'FROM' => array($this->reputations_table => 'r'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'ut'), 'ON' => 'r.user_id_to = ut.user_id ')), 'WHERE' => 'r.user_id_to = ' . $uid);
        $sql = $this->db->sql_build_query('SELECT', $sql_array);
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        //We couldn't find this reputation. May be it was deleted meanwhile?
        if (empty($row)) {
            $message = $this->user->lang('RS_NO_REPUTATION');
            $json_data = array('error_msg' => $message);
            $redirect = append_sid("{$this->root_path}index.{$this->php_ext}");
            $redirect_text = 'RETURN_INDEX';
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        $redirect = $this->helper->route('reputation_details_controller', array('uid' => $uid));
        if ($this->request->is_set_post('cancel')) {
            redirect($redirect);
        }
        $post_ids = array();
        $post_type_id = (int) $this->reputation_manager->get_reputation_type_id('post');
        $sql = 'SELECT reputation_item_id
			FROM ' . $this->reputations_table . "\n\t\t\tWHERE user_id_to = {$uid}\n\t\t\t\tAND reputation_type_id = {$post_type_id}\n\t\t\tGROUP BY reputation_item_id";
        $result = $this->db->sql_query($sql);
        while ($post_row = $this->db->sql_fetchrow($result)) {
            $post_ids[] = $post_row['reputation_item_id'];
        }
        $this->db->sql_freeresult($result);
        $redirect_text = 'RETURN_PAGE';
        if ($this->auth->acl_gets('m_rs_moderate')) {
            if ($is_ajax) {
                $submit = true;
            } else {
                $s_hidden_fields = build_hidden_fields(array('u' => $uid));
                if (confirm_box(true)) {
                    $submit = true;
                } else {
                    confirm_box(false, $this->user->lang('RS_CLEAR_POST_CONFIRM'), $s_hidden_fields);
                }
            }
        } else {
            $message = $this->user->lang('RS_USER_CANNOT_DELETE');
            $json_data = array('error_msg' => $message);
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        if ($submit) {
            try {
                $this->reputation_manager->clear_user_reputation($uid, $row, $post_ids);
            } catch (\pico\reputation\exception\base $e) {
                // Catch exception
                trigger_error($e->get_message($this->user));
            }
            $message = $this->user->lang('RS_CLEARED_USER');
            $json_data = array('clear_user' => true, 'post_ids' => $post_ids, 'poster_id' => $uid, 'user_reputation' => 0, 'post_reputation' => 0, 'reputation_class' => 'neutral');
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
    }
    /**
     * Display reputation toplist
     *
     * @return null
     * @access public
     */
    public function reputation_toplist()
    {
        if ($this->config['rs_enable'] && $this->config['rs_enable_toplist'] && $this->config['rs_toplist_num']) {
            $this->user->add_lang_ext('pico/reputation', 'reputation_toplist');
            $sql = 'SELECT user_id, username, user_colour, user_reputation
				FROM ' . USERS_TABLE . '
				WHERE user_reputation > 0
				ORDER BY user_reputation DESC';
            $result = $this->db->sql_query_limit($sql, $this->config['rs_toplist_num']);
            while ($row = $this->db->sql_fetchrow($result)) {
                $this->template->assign_block_vars('toplist', array('USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER_REPUTATION' => $row['user_reputation'], 'U_VIEW_USER_REPUTATION' => $this->helper->route('reputation_details_controller', array('uid' => $row['user_id'])), 'S_DIRECTION' => $this->config['rs_toplist_direction'] ? true : false));
            }
            $this->db->sql_freeresult($result);
            $this->template->assign_vars(array('S_RS_TOPLIST' => true, 'S_VIEW_REPUTATION' => $this->auth->acl_get('u_rs_view') ? true : false));
        }
    }
Ejemplo n.º 13
0
    private function obtain_guest_count_24()
    {
        $total_guests_online_24 = 0;
        // Get number of online guests for the past 24 hours
        // caching and main sql if none yet
        if (($total_guests_online_24 = $this->cache->get('_total_guests_online_24')) === false) {
            // teh time
            $interval = time() - 86400;
            if ($this->db->get_sql_layer() === 'sqlite' || $this->db->get_sql_layer() === 'sqlite3') {
                $sql = 'SELECT COUNT(session_ip) as num_guests_24
					FROM (
						SELECT DISTINCT session_ip
						FROM ' . SESSIONS_TABLE . '
						WHERE session_user_id = ' . ANONYMOUS . '
							AND session_time >= ' . ($interval - (int) ($interval % 60)) . ')';
            } else {
                $sql = 'SELECT COUNT(DISTINCT session_ip) as num_guests_24
					FROM ' . SESSIONS_TABLE . '
					WHERE session_user_id = ' . ANONYMOUS . '
						AND session_time >= ' . ($interval - (int) ($interval % 60));
            }
            $result = $this->db->sql_query($sql);
            $total_guests_online_24 = (int) $this->db->sql_fetchfield('num_guests_24');
            $this->db->sql_freeresult($result);
            // cache this stuff for, ohhhh, how about 5 minutes
            // change 300 to whatever number to reduce or increase the cache time
            $this->cache->put('_total_guests_online_24', $total_guests_online_24, 300);
        }
        return $total_guests_online_24;
    }
Ejemplo n.º 14
0
 /**
  * {@inheritDoc}
  */
 function get_row_count($table_name)
 {
     $table_status = $this->get_table_status($table_name);
     if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM') {
         return $table_status['Rows'];
     }
     return parent::get_row_count($table_name);
 }
Ejemplo n.º 15
0
    /**
     *
     * https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php
     *
     * @return boolean
     */
    public function ipn()
    {
        $raw_post_data = file_get_contents('php://input');
        $raw_post_array = explode('&', $raw_post_data);
        $myPost = array();
        foreach ($raw_post_array as $keyval) {
            $keyval = explode('=', $keyval);
            if (count($keyval) == 2) {
                $myPost[$keyval[0]] = urldecode($keyval[1]);
            }
        }
        // read the post from PayPal system and add 'cmd'
        $req = 'cmd=_notify-validate';
        if (function_exists('get_magic_quotes_gpc')) {
            $get_magic_quotes_exists = true;
        }
        foreach ($myPost as $key => $value) {
            if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
                $value = urlencode(stripslashes($value));
            } else {
                $value = urlencode($value);
            }
            $req .= "&{$key}={$value}";
        }
        $sql = 'SELECT paypal_sandbox
			FROM ' . $this->table_config;
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $paypal_url = $row['paypal_sandbox'] == 1 ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
        $ch = curl_init($paypal_url);
        if ($ch == false) {
            return false;
        }
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
        $res = curl_exec($ch);
        curl_close($ch);
        // Inspect IPN validation result and act accordingly
        // Split response headers and payload, a better way for strcmp
        $tokens = explode("\r\n\r\n", trim($res));
        $res = trim(end($tokens));
        if (strcmp($res, 'VERIFIED') == 0) {
            $sql_data = array('user_id' => (int) $this->request->variable('custom', '0'), 'item_id' => (int) $this->request->variable('item_number', '0'), 'item_name' => $this->request->variable('item_number', '', true), 'donation_time' => time(), 'donation_amount' => $this->request->variable('mc_gross', '0'));
            $sql = 'INSERT INTO ' . $this->table_donations . '
				' . $this->db->sql_build_array('INSERT', $sql_data);
            $this->db->sql_query($sql);
        }
        $headers = array('Content-Type' => 'application/xml; charset=UTF-8');
        return new Response('', '200', $headers);
    }
    /**
     * Display the form
     *
     * @access public
     */
    public function displayform()
    {
        $this->user->add_lang_ext('rmcgirr83/applicationform', 'application');
        // user can't be a guest and can't be a bot
        if ($this->user->data['is_bot'] || $this->user->data['user_id'] == ANONYMOUS) {
            throw new http_exception(401, 'LOGIN_APPLICATION_FORM');
        }
        add_form_key('appform');
        if ($this->request->is_set_post('submit')) {
            // Test if form key is valid
            if (!check_form_key('appform')) {
                trigger_error($this->user->lang['FORM_INVALID'], E_USER_WARNING);
            }
            if (utf8_clean_string($this->request->variable('name', '')) === '' || utf8_clean_string($this->request->variable('why', '')) === '') {
                trigger_error($this->user->lang['APP_NOT_COMPLETELY_FILLED'], E_USER_WARNING);
            }
            $sql = 'SELECT forum_name
				FROM ' . FORUMS_TABLE . '
				WHERE forum_id = ' . (int) $this->config['appform_forum_id'];
            $result = $this->db->sql_query($sql);
            $forum_name = $this->db->sql_fetchfield('forum_name');
            $this->db->sql_freeresult($result);
            // Setting the variables we need to submit the post to the forum where all the applications come in
            $subject = sprintf($this->user->lang['APPLICATION_SUBJECT'], $this->user->data['username']);
            $apply_post = sprintf($this->user->lang['APPLICATION_MESSAGE'], get_username_string('full', $this->user->data['user_id'], $this->user->data['username'], $this->user->data['user_colour']), utf8_normalize_nfc($this->request->variable('name', '', true)), $this->user->data['user_email'], $this->request->variable('postion', '', true), utf8_normalize_nfc($this->request->variable('why', '', true)));
            // variables to hold the parameters for submit_post
            $uid = $bitfield = $options = '';
            generate_text_for_storage($apply_post, $uid, $bitfield, $options, true, true, true);
            $data = array('forum_id' => $this->config['appform_forum_id'], 'icon_id' => false, 'poster_id' => $this->user->data['user_id'], 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $apply_post, 'message_md5' => md5($apply_post), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'poster_ip' => $this->user->ip, 'post_edit_locked' => 0, 'topic_title' => $subject, 'notify_set' => false, 'notify' => false, 'post_time' => time(), 'forum_name' => $forum_name, 'enable_indexing' => true, 'force_approved_state' => true, 'force_visibility' => true);
            $poll = array();
            // Submit the post!
            submit_post('post', $subject, $this->user->data['username'], POST_NORMAL, $poll, $data);
            $message = $this->user->lang['APPLICATION_SEND'];
            $message = $message . '<br /><br />' . sprintf($this->user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$this->root_path}index.{$this->php_ext}") . '">', '</a>');
            trigger_error($message);
        }
        $this->template->assign_vars(array('APPLICATION_POSITIONS' => $this->display_positions(explode("\n", $this->config['appform_positions']))));
        // Send all data to the template file
        return $this->helper->render('appform_body.html', $this->user->lang('APPLICATION_PAGETITLE'));
    }
    /**
     * User details controller
     *
     * @param int $uid			User ID taken from the URL
     * @param string $sort_key	Sort key: id|username|time|point|action (default: id)
     * @param string $sort_dir	Sort direction: dsc|asc (descending|ascending) (default: dsc)
     * @return Symfony\Component\HttpFoundation\Response A Symfony Response object
     * @access public
     */
    public function userdetails($uid, $sort_key, $sort_dir)
    {
        $this->user->add_lang_ext('pico/reputation', array('reputation_system', 'reputation_rating'));
        $is_ajax = $this->request->is_ajax();
        $referer = $this->symfony_request->get('_referer');
        if (empty($this->config['rs_enable'])) {
            if ($is_ajax) {
                $json_response = new \phpbb\json_response();
                $json_data = array('error_msg' => $this->user->lang('RS_DISABLED'));
                $json_response->send($json_data);
            }
            redirect(append_sid("{$this->root_path}index.{$this->php_ext}"));
        }
        $sql = 'SELECT user_id, username, user_colour
			FROM ' . USERS_TABLE . '
			WHERE user_type <> 2
				AND user_id =' . (int) $uid;
        $result = $this->db->sql_query($sql);
        $user_row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if (empty($user_row)) {
            $message = $this->user->lang('RS_NO_USER_ID');
            $json_data = array('error_msg' => $message);
            $redirect = append_sid("{$this->root_path}index.{$this->php_ext}");
            $redirect_text = 'RETURN_INDEX';
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        if (!$this->auth->acl_get('u_rs_view')) {
            $message = $this->user->lang('RS_VIEW_DISALLOWED');
            $json_data = array('error_msg' => $message);
            $redirect = append_sid("memberlist.{$this->php_ext}", 'mode=viewprofile&amp;u=' . $uid);
            $redirect_text = 'RETURN_PAGE';
            $this->reputation_manager->response($message, $json_data, $redirect, $redirect_text, $is_ajax);
        }
        $sort_key_sql = array('username' => 'u.username_clean', 'time' => 'r.reputation_time', 'point' => 'r.reputation_points', 'action' => 'rt.reputation_type_name', 'id' => 'r.reputation_id');
        // Sql order depends on sort key
        $order_by = $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'dsc' ? 'DESC' : 'ASC');
        $reputation_type_id = (int) $this->reputation_manager->get_reputation_type_id('post');
        $sql_array = array('SELECT' => 'r.*, rt.reputation_type_name, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, p.post_id, p.forum_id, p.post_subject', 'FROM' => array($this->reputations_table => 'r', $this->reputation_types_table => 'rt'), 'LEFT_JOIN' => array(array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = r.user_id_from'), array('FROM' => array(POSTS_TABLE => 'p'), 'ON' => 'p.post_id = r.reputation_item_id
						AND r.reputation_type_id = ' . $reputation_type_id)), 'WHERE' => 'r.user_id_to = ' . $uid . '
				AND r.reputation_type_id = rt.reputation_type_id', 'ORDER_BY' => $order_by);
        $sql = $this->db->sql_build_query('SELECT', $sql_array);
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $this->template->assign_block_vars('reputation', array('ID' => $row['reputation_id'], 'USERNAME' => get_username_string('full', $row['user_id_from'], $row['username'], $row['user_colour']), 'ACTION' => $this->user->lang('RS_' . strtoupper($row['reputation_type_name']) . '_RATING'), 'AVATAR' => phpbb_get_user_avatar($row), 'TIME' => $this->user->format_date($row['reputation_time']), 'COMMENT' => $row['reputation_comment'], 'POINTS' => $row['reputation_points'], 'POINTS_CLASS' => $this->reputation_helper->reputation_class($row['reputation_points']), 'POINTS_TITLE' => $this->user->lang('RS_POINTS_TITLE', $row['reputation_points']), 'U_DELETE' => $this->helper->route('reputation_delete_controller', array('rid' => $row['reputation_id'])), 'S_COMMENT' => !empty($row['reputation_comment']), 'S_DELETE' => $this->auth->acl_get('m_rs_moderate') || $row['user_id_from'] == $this->user->data['user_id'] && $this->auth->acl_get('u_rs_delete') ? true : false));
            // Generate post url
            $this->reputation_manager->generate_post_link($row);
        }
        $this->db->sql_freeresult($result);
        $this->template->assign_vars(array('USER_ID' => $uid, 'U_USER_DETAILS' => $this->helper->route('reputation_details_controller', array('uid' => $uid)), 'U_SORT_USERNAME' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'username', 'sort_dir' => $sort_key == 'username' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_TIME' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'time', 'sort_dir' => $sort_key == 'time' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_POINT' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'point', 'sort_dir' => $sort_key == 'point' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_SORT_ACTION' => $this->helper->route('reputation_user_details_controller', array('uid' => $uid, 'sort_key' => 'action', 'sort_dir' => $sort_key == 'action' && $sort_dir == 'asc' ? 'dsc' : 'asc')), 'U_CLEAR' => $this->helper->route('reputation_clear_user_controller', array('uid' => $uid)), 'U_REPUTATION_REFERER' => $referer, 'L_RS_USER_REPUTATION' => $this->user->lang('RS_USER_REPUTATION', get_username_string('username', $user_row['user_id'], $user_row['username'], $user_row['user_colour'])), 'S_RS_AVATAR' => $this->config['rs_display_avatar'] ? true : false, 'S_RS_COMMENT' => $this->config['rs_enable_comment'] ? true : false, 'S_RS_POINTS_IMG' => $this->config['rs_point_type'] ? true : false, 'S_CLEAR' => $this->auth->acl_gets('m_rs_moderate') ? true : false, 'S_IS_AJAX' => $is_ajax ? true : false));
        return $this->helper->render('userdetails.html');
    }
Ejemplo n.º 18
0
    /**
     * Get the data for all reportee from the database
     *
     * @param	array	$reportee_ids	Array with the user ids of the reportees
     *
     * @return	array		Returns an array with the reportee data
     */
    protected function get_reportee_data(array $reportee_ids)
    {
        $reportee_ids = array_unique($reportee_ids);
        $reportee_data_list = array();
        $sql = 'SELECT user_id, username, user_colour
			FROM ' . USERS_TABLE . '
			WHERE ' . $this->db->sql_in_set('user_id', $reportee_ids);
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $reportee_data_list[$row['user_id']] = $row;
        }
        $this->db->sql_freeresult($result);
        return $reportee_data_list;
    }
Ejemplo n.º 19
0
    /**
     * Get an array of forums
     * return all forums where the extension is active
     *
     * @return forum id array
     * @access private
     */
    private function get_sfpo_forums()
    {
        $forum_ids = array();
        $sql = 'SELECT forum_id
			FROM ' . FORUMS_TABLE . '
			WHERE sfpo_guest_enable = ' . true;
        $result = $this->db->sql_query($sql);
        $forums = $this->db->sql_fetchrowset($result);
        $this->db->sql_freeresult($result);
        foreach ($forums as $forum) {
            foreach ($forum as $id) {
                $forum_ids[] = $id;
            }
        }
        return $forum_ids;
    }
Ejemplo n.º 20
0
 /**
  * Update topics table
  * @param object $user_colour The colour of the user chosen in the UCP
  * @return null
  * @access private
  */
 private function update_tables($user_colour)
 {
     $sql_ary = array('topic_last_poster_colour' => $user_colour);
     $sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE topic_last_poster_id = ' . $this->user->data['user_id'];
     $this->db->sql_query($sql);
     $sql_ary = array('topic_first_poster_colour' => $user_colour);
     $sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE topic_poster = ' . $this->user->data['user_id'];
     $this->db->sql_query($sql);
     $sql_ary = array('forum_last_poster_colour' => $user_colour);
     $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE forum_last_poster_id = ' . $this->user->data['user_id'];
     $this->db->sql_query($sql);
     if ($this->config['newest_user_id'] == $this->user->data['user_id']) {
         $this->config->set('newest_user_colour', $user_colour, true);
     }
     return;
 }
Ejemplo n.º 21
0
    public function display_tpotm($event)
    {
        $now = time();
        $date_today = gmdate("Y-m-d", $now);
        list($year_cur, $month_cur, $day1) = split('-', $date_today);
        /* Start time for current month */
        $month_start_cur = gmmktime(0, 0, 0, $month_cur, 1, $year_cur);
        $month_start = $month_start_cur;
        $month_end = $now;
        /*
         * group_id 5 = administrators
         * group_id 4 = global moderators
         * per default into a Vanilla 3.1.x board
         */
        $group_ids = array(5, 4);
        /*
         * config time for cache, still to be fully implemented thus hardcoded
         * 900 = 15 minutes
         */
        $config_time_cache = 900;
        /* Check cached data */
        if (($row = $this->cache->get('_tpotm')) === false) {
            $sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_type, u.group_id, p.poster_id, p.post_time, COUNT(p.post_id) AS total_posts
				FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p
				WHERE u.user_id > ' . ANONYMOUS . '
					AND u.user_id = p.poster_id
						AND (u.user_type <> ' . USER_FOUNDER . ')
							AND ' . $this->db->sql_in_set('u.group_id', $group_ids, true) . '
								AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . '
				GROUP BY u.user_id
				ORDER BY total_posts DESC';
            $result = $this->db->sql_query_limit($sql, 1);
            $row = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            /* caching this data improves performance */
            $this->cache->put('_tpotm', $row, (int) $config_time_cache);
        }
        /* Let's show the Top Poster then */
        $tpotm_tot_posts = (int) $row['total_posts'];
        $tpotm_un_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
        /* Fresh installs or new Month starts give zero posts */
        $tpotm_un_nobody = $this->user->lang['TPOTM_NOBODY'];
        $tpotm_post = $this->user->lang('TPOTM_POST', (int) $tpotm_tot_posts);
        $tpotm_name = $tpotm_tot_posts < 1 ? $tpotm_un_nobody : $tpotm_un_string;
        /* you know.. template stuffs */
        $this->template->assign_vars(array('TPOTM_NAME' => $tpotm_name, 'L_TPOTM_CAT' => $this->user->lang['TPOTM_CAT'], 'L_TPOTM_NOW' => $this->user->lang['TPOTM_NOW'], 'L_TPOTM_POST' => $tpotm_post));
    }
Ejemplo n.º 22
0
    /**
     * Add map to users profile
     *
     * @param	object	$event	The event object
     * @return	null
     * @access	public
     */
    public function memberlist_view_profile($event)
    {
        if ($this->config['tas2580_usermap_map_in_viewprofile'] == 0) {
            return false;
        }
        $data = $event['member'];
        $this->user->add_lang_ext('tas2580/usermap', 'controller');
        $distance = $this->get_distance($this->user->data['user_usermap_lon'], $this->user->data['user_usermap_lat'], $data['user_usermap_lon'], $data['user_usermap_lat']);
        // Center the map to user
        $this->template->assign_vars(array('S_IN_USERMAP' => true, 'USERMAP_CONTROLS' => 'false', 'USERNAME' => get_username_string('full', $data['user_id'], $data['username'], $data['user_colour']), 'USERMAP_LON' => $data['user_usermap_lon'], 'USERMAP_LAT' => $data['user_usermap_lat'], 'USERMAP_ZOOM' => (int) 10, 'DISTANCE' => $distance, 'MARKER_PATH' => $this->path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('tas2580/usermap', true) . 'marker'), 'MAP_TYPE' => $this->config['tas2580_usermap_map_type'], 'GOOGLE_API_KEY' => $this->config['tas2580_usermap_google_api_key']));
        $sql = 'SELECT group_id, group_usermap_marker
			FROM ' . GROUPS_TABLE . '
			WHERE group_id = ' . (int) $data['group_id'];
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->template->assign_vars(array('USERMAP_MARKER' => $row['group_usermap_marker']));
    }
Ejemplo n.º 23
0
 /**
  * Forum check
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function viewtopic_get_post_data($event)
 {
     $topic_data = $event['topic_data'];
     $sql_ary = $event['sql_ary'];
     $post_list = $event['post_list'];
     $s_sfpo = !empty($topic_data['sfpo_guest_enable']) && $this->user->data['user_id'] == ANONYMOUS;
     if ($s_sfpo) {
         $this->user->add_lang_ext('rmcgirr83/sfpo', 'common');
         $post_list = array((int) $topic_data['topic_first_post_id']);
         $sql_ary['WHERE'] = $this->db->sql_in_set('p.post_id', $post_list) . ' AND u.user_id = p.poster_id';
         $topic_replies = $this->content_visibility->get_count('topic_posts', $topic_data, $event['forum_id']) - 1;
         $redirect = '&amp;redirect=' . urlencode(str_replace('&amp;', '&', build_url(array('_f_'))));
         $this->template->assign_vars(array('S_SFPO' => true, 'SFPO_MESSAGE' => $topic_replies ? $this->user->lang('SFPO_MSG_REPLY', $topic_replies) : '', 'U_SFPO_LOGIN' => append_sid("{$this->root_path}ucp.{$this->php_ext}", 'mode=login' . $redirect)));
     }
     $event['post_list'] = $post_list;
     $event['sql_ary'] = $sql_ary;
 }
 /**
  * Get top_flags
  * displayed on the index page
  */
 public function top_flags()
 {
     // grab all the flags
     $sql_array = array('SELECT' => 'user_flag, COUNT(user_flag) AS fnum', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => $this->db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' AND user_flag > 0', 'GROUP_BY' => 'user_flag', 'ORDER_BY' => 'fnum DESC');
     // we limit the number of flags to display to the number set in the ACP settings
     $result = $this->db->sql_query_limit($this->db->sql_build_query('SELECT', $sql_array), $this->config['flags_num_display']);
     $count = 0;
     $flags = $this->cache->get('_user_flags');
     while ($row = $this->db->sql_fetchrow($result)) {
         ++$count;
         $this->template->assign_block_vars('flag', array('FLAG' => $this->get_user_flag($row['user_flag']), 'FLAG_USERS' => $this->user->lang('FLAG_USERS', (int) $row['fnum']), 'U_FLAG' => $this->helper->route('rmcgirr83_nationalflags_getflags', array('flag_id' => $flags[$row['user_flag']]['flag_id']))));
     }
     $this->db->sql_freeresult($result);
     if ($count) {
         $this->template->assign_vars(array('U_FLAGS' => $this->helper->route('rmcgirr83_nationalflags_display'), 'S_FLAGS' => true));
     }
 }
    /**
     * Clear user reputation
     *
     * @param int $user_id User id
     * @param array $data Reputation data
     * @param arrat $post_ids Post IDs
     * @access public
     * @return null
     */
    public function clear_user_reputation($user_id, $data, $post_ids)
    {
        // Required fields
        $fields = array('user_id_to', 'reputation_item_id');
        foreach ($fields as $field) {
            if (!isset($data[$field])) {
                throw new \pico\reputation\exception\invalid_argument(array($field, 'FIELD_MISSING'));
            }
        }
        $sql = 'UPDATE ' . USERS_TABLE . "\n\t\t\tSET user_reputation = 0\n\t\t\tWHERE user_id = {$user_id}";
        $this->db->sql_query($sql);
        $sql = 'UPDATE ' . POSTS_TABLE . '
			SET post_reputation = 0
			WHERE ' . $this->db->sql_in_set('post_id', $post_ids, false, true);
        $this->db->sql_query($sql);
        $sql = 'DELETE FROM ' . $this->reputations_table . "\n\t\t\tWHERE user_id_to = {$user_id}";
        $this->db->sql_query($sql);
        $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_REPUTATION_CLEARED', false, array('user_id_to' => isset($data['username_to']) ? $data['username_to'] : $data['user_id_to']));
    }
    /**
     * Function returns a reputation power used by an user
     *
     * @param $user_id User ID
     * @return int Power used
     * @access public
     */
    public function used($user_id)
    {
        $time = time();
        $power_used = 0;
        if ($this->config['rs_power_renewal']) {
            // Until what time stamp should we count user votes
            $renewal_timeout = $time - $this->config['rs_power_renewal'] * 3600;
            // Let's get all voting data on this user.
            $sql = 'SELECT reputation_points
				FROM ' . $this->reputation_table . "\n\t\t\t\tWHERE user_id_from = {$user_id}\n\t\t\t\t\tAND reputation_time > {$renewal_timeout}";
            $result = $this->db->sql_query($sql);
            // Let's run through the rows and make statistics
            while ($renewal = $this->db->sql_fetchrow($result)) {
                // How much power a user spent in a specified period of time
                $power_used += (int) $renewal['reputation_points'];
            }
            $this->db->sql_freeresult($result);
        }
        return (int) $power_used;
    }
    /**
     * Display flag
     *
     * @param $flag_id		int		the id of the flag
     * @param $start		int		page number we start at
     * @param $limit		int		limit to display for pagination
     * @return null
     * @access public
     */
    protected function display_flag($flag_id, $start, $limit)
    {
        //let's get the flag requested
        $sql = 'SELECT flag_id, flag_name, flag_image
			FROM ' . $this->flags_table . '
			WHERE flag_id = ' . (int) $flag_id;
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // now users that have the flag
        $sql = 'SELECT *
			FROM ' . USERS_TABLE . '
			WHERE user_flag = ' . (int) $row['flag_id'] . '
				AND ' . $this->db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
			ORDER BY username_clean';
        $result = $this->db->sql_query_limit($sql, $limit, $start);
        $rows = $this->db->sql_fetchrowset($result);
        $this->db->sql_freeresult($result);
        // for counting of total flag users
        $result = $this->db->sql_query($sql);
        $row2 = $this->db->sql_fetchrowset($result);
        $total_users = (int) count($row2);
        $this->db->sql_freeresult($result);
        unset($row2);
        foreach ($rows as $userrow) {
            $user_id = $userrow['user_id'];
            $username = $this->auth->acl_get('u_viewprofile') ? get_username_string('full', $user_id, $userrow['username'], $userrow['user_colour']) : get_username_string('no_profile', $user_id, $userrow['username'], $userrow['user_colour']);
            $this->template->assign_block_vars('user_row', array('JOINED' => $this->user->format_date($userrow['user_regdate']), 'VISITED' => empty($userrow['user_lastvisit']) ? ' - ' : $this->user->format_date($userrow['user_lastvisit']), 'POSTS' => $userrow['user_posts'] ? $userrow['user_posts'] : 0, 'USERNAME_FULL' => $username, 'U_SEARCH_USER' => $this->auth->acl_get('u_search') ? append_sid("{$this->root_path}search.{$this->php_ext}", "author_id={$user_id}&amp;sr=posts") : ''));
        }
        $this->pagination->generate_template_pagination(array('routes' => array('rmcgirr83_nationalflags_getflags', 'rmcgirr83_nationalflags_getflags_page'), 'params' => array('flag_id' => $flag_id)), 'pagination', 'page', $total_users, $limit, $start);
        $flag_image = $this->functions->get_user_flag($row['flag_id']);
        $users_count = $total_users;
        $total_users = $this->user->lang('FLAG_USERS', (int) $total_users);
        $this->template->assign_vars(array('FLAG' => html_entity_decode($row['flag_name']), 'FLAG_IMAGE' => $flag_image, 'TOTAL_USERS' => $total_users, 'S_VIEWONLINE' => $this->auth->acl_get('u_viewonline'), 'S_FLAGS' => true, 'S_FLAG_USERS' => !empty($users_count) ? true : false, 'MESSAGE_TEXT' => empty($users_count) ? $this->user->lang['NO_USER_HAS_FLAG'] : ''));
        // Assign breadcrumb template vars for the flags page
        $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('rmcgirr83_nationalflags_display'), 'FORUM_NAME' => $this->user->lang('NATIONAL_FLAGS')));
        // Assign breadcrumb template vars for the flags page
        $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('rmcgirr83_nationalflags_getflags', array('flag_id' => $flag_id)), 'FORUM_NAME' => $row['flag_name']));
    }
Ejemplo n.º 28
0
    /**
     * Display message to the user if there where failed login trys
     *
     * @param object $event The event object
     * @return null
     * @access public
     */
    public function page_footer($event)
    {
        // clear failed_logins_count_last on user action
        if ($this->request->is_set('failedlogins_remove')) {
            if (check_form_key('failedlogins_remove')) {
                $sql = 'UPDATE ' . USERS_TABLE . ' SET failed_logins_count_last = 0
					WHERE user_id = ' . (int) $this->user->data['user_id'];
                $this->db->sql_query($sql);
                if ($this->request->is_ajax()) {
                    trigger_error('REMOVED_FAILED_LOGINS');
                }
            } else {
                if ($this->request->is_ajax()) {
                    trigger_error('FORM_INVALID', E_USER_WARNING);
                }
            }
        }
        // Display failed logins
        if ($this->user->data['failed_logins_count_last'] > 0) {
            add_form_key('failedlogins_remove');
            $this->template->assign_vars(array('U_REMOVE_MESSAGE' => generate_board_url() . '/' . $this->user->page['page'], 'FAILED_LOGINS' => $this->user->data['failed_logins_count_last'] == 1 ? $this->user->lang['ONE_FAILED_LOGIN'] : sprintf($this->user->lang['FAILED_LOGINS_COUNT'], $this->user->data['failed_logins_count_last'])));
        }
    }
    /**
     * Rate user
     *
     * @return null
     * @access public
     */
    public function rate_user()
    {
        add_form_key('rate');
        //$this->user->add_lang_ext('pico/reputation', 'reputation_common');
        $submit = $this->request->is_set_post('submit');
        $username = $this->request->variable('username', '', true);
        $points = $this->request->variable('points', '');
        $comment = $this->request->variable('comment', '', true);
        $errors = array();
        if ($submit) {
            if (!check_form_key('rate')) {
                $errors[] = $this->user->lang('FORM_INVALID');
            }
            $sql = 'SELECT user_id
				FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'";
            $result = $this->db->sql_query($sql);
            $user_id_to = (int) $this->db->sql_fetchfield('user_id');
            $this->db->sql_freeresult($result);
            if (!$user_id_to) {
                $errors[] = $this->user->lang('NO_USER');
            }
            if (!is_numeric($points)) {
                $errors[] = $this->user->lang('POINTS_INVALID');
            }
        }
        if ($submit && empty($errors)) {
            $data = array('user_id_from' => $this->user->data['user_id'], 'user_id_to' => $user_id_to, 'reputation_type' => 'user', 'reputation_item_id' => $user_id_to, 'reputation_points' => $points, 'reputation_comment' => $comment);
            try {
                $this->reputation_manager->store_reputation($data);
                trigger_error($this->user->lang('RS_VOTE_SAVED') . adm_back_link($this->u_action));
            } catch (\pico\reputation\exception\base $e) {
                // Catch exceptions and add them to errors array
                $errors[] = $e->get_message($this->user);
            }
        }
        $this->template->assign_vars(array('S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => implode('<br />', $errors), 'U_ACTION' => $this->u_action, 'U_FIND_USERNAME' => append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=searchuser&amp;form=rate&amp;field=username&amp;select_single=true'), 'RS_USERNAME' => $username, 'RS_POINTS' => $points, 'RS_COMMENT' => $comment));
    }
Ejemplo n.º 30
0
 /**
  * Disapprove a comment
  *
  * @param int $id
  * @return bool
  */
 public function disapprove($id)
 {
     $sql = 'UPDATE ' . $this->blog_comments_table . ' SET status = 0 WHERE id = ' . (int) $id;
     $this->db->sql_query($sql);
     return true;
 }