Exemple #1
0
 public function modify_posting($event)
 {
     if ($event['mode'] == 'post' && !$event['forum_id']) {
         $forum_ary = array();
         $forum_read_ary = $this->auth->acl_getf('f_read');
         foreach ($forum_read_ary as $forum_id => $allowed) {
             if ($allowed['f_read'] && $this->auth->acl_get('f_post', $forum_id)) {
                 if (!$this->exclude_forum($forum_id, $this->config['newtopic_forum'])) {
                     continue;
                 }
                 $forum_ary[] = (int) $forum_id;
             }
         }
         if (sizeof($forum_ary)) {
             // Fetching topics of public forums
             $sql = 'SELECT forum_id, forum_name, forum_type FROM ' . FORUMS_TABLE . "\n\t\t\t\t\tWHERE " . $this->db->sql_in_set('forum_id', $forum_ary) . "\n\t\t\t\t\t\tAND forum_type != " . FORUM_LINK;
             $result = $this->db->sql_query($sql);
             $forumrow = $this->db->sql_fetchrowset($result);
             $this->db->sql_freeresult($result);
             $s_forum_options = '<select id="f" name="f" onchange="this.form.submit();">';
             foreach ($forumrow as $row) {
                 $s_forum_options .= '<option value="' . $row['forum_id'] . '"' . ($row['forum_id'] == $forum_id ? ' selected="selected"' : '') . '' . ($row['forum_type'] == FORUM_CAT ? ' disabled="disabled" class="disabled-option"' : '') . '>' . ($row['forum_type'] != FORUM_CAT ? '&nbsp;&nbsp;' : '') . $row['forum_name'] . '</option>';
                 $forum_id = $row['forum_type'] == FORUM_POST ? $row['forum_id'] : '';
             }
             $s_forum_options .= '</select>';
             $this->template->assign_vars(array('S_FORUM_OPTIONS' => $s_forum_options, 'S_FORUM_OPT_TRUE' => $forum_id ? true : false));
             $event['forum_id'] = $forum_id;
         }
     }
 }
Exemple #2
0
 /**
  * Creates a report entity in the database
  *
  * @param	array	$report_data
  * @return	int	the ID of the created entity
  */
 protected function create_report(array $report_data)
 {
     $sql_ary = array('reason_id' => (int) $report_data['reason_id'], 'post_id' => $report_data['post_id'], 'pm_id' => $report_data['pm_id'], 'user_id' => (int) $this->user->data['user_id'], 'user_notify' => (int) $report_data['user_notify'], 'report_closed' => 0, 'report_time' => (int) time(), 'report_text' => (string) $report_data['report_text'], 'reported_post_text' => $report_data['reported_post_text'], 'reported_post_uid' => $report_data['reported_post_uid'], 'reported_post_bitfield' => $report_data['reported_post_bitfield'], 'reported_post_enable_bbcode' => $report_data['reported_post_enable_bbcode'], 'reported_post_enable_smilies' => $report_data['reported_post_enable_smilies'], 'reported_post_enable_magic_url' => $report_data['reported_post_enable_magic_url']);
     $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
     $this->db->sql_query($sql);
     return $this->db->sql_nextid();
 }
Exemple #3
0
    public function create_welcome_topic($user_id)
    {
        if (!$this->config['welcomerobot_enable']) {
            return false;
        }
        if (!function_exists('get_username_string')) {
            include $this->root_path . 'includes/functions_content.' . $this->phpEx;
        }
        if (!function_exists('submit_post')) {
            include $this->root_path . 'includes/functions_posting.' . $this->phpEx;
        }
        $sql = 'SELECT *
			FROM ' . USERS_TABLE . "\n\t\t\tWHERE user_id = " . intval($user_id) . "";
        $dbresult = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($dbresult);
        $this->db->sql_freeresult($dbresult);
        if (empty($row)) {
            return false;
        }
        $username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
        $clean_username = utf8_clean_string($row['username']);
        $topic_title = str_replace(array('%user', '%robot', '%board'), array($clean_username, $this->config['welcomerobot_username'], $this->config['sitename']), $this->config['welcomerobot_title']);
        $topic_content = str_replace(array('%user', '%robot', '%board'), array($clean_username, $this->config['welcomerobot_username'], $this->config['sitename']), $this->config['welcomerobot_detail']);
        $poll = $uid = $bitfield = $options = '';
        // will be modified by generate_text_for_storage
        $allow_bbcode = $allow_urls = $allow_smilies = true;
        generate_text_for_storage($topic_content, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
        $data = array('forum_id' => $this->config['welcomerobot_forum'], 'topic_id' => 0, 'icon_id' => false, 'robot_name' => $this->config['welcomerobot_username'], 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $topic_content, 'message_md5' => md5($topic_content), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'post_edit_locked' => 0, 'topic_title' => $topic_title, 'notify_set' => false, 'notify' => false, 'post_time' => 0, 'forum_name' => '', 'enable_indexing' => true, 'force_approved_state' => true);
        submit_post('post', $topic_title, 'robot_name', POST_NORMAL, $poll, $data);
        return true;
    }
    public function index_modify_page_title($event)
    {
        // Count the videos ...
        $sql = 'SELECT COUNT(video_id) AS total_videos
			FROM ' . $this->video_table;
        $result = $this->db->sql_query($sql);
        $total_videos = (int) $this->db->sql_fetchfield('total_videos');
        $this->db->sql_freeresult($result);
        // Count the videos categories ...
        $sql = 'SELECT COUNT(video_cat_id) AS total_categories
			FROM ' . $this->video_cat_table . '';
        $result = $this->db->sql_query($sql);
        $total_categories = (int) $this->db->sql_fetchfield('total_categories');
        $this->db->sql_freeresult($result);
        // Count the videos views ...
        $sql = 'SELECT SUM(video_views) AS total_views
			FROM ' . $this->video_table;
        $result = $this->db->sql_query($sql);
        $total_views = (int) $this->db->sql_fetchfield('total_views');
        $this->db->sql_freeresult($result);
        $total_videos;
        // Count the videos comments ...
        $sql = 'SELECT COUNT(cmnt_id) AS total_comments
			FROM ' . $this->video_cmnts_table;
        $result = $this->db->sql_query($sql);
        $total_comments = (int) $this->db->sql_fetchfield('total_comments');
        $this->db->sql_freeresult($result);
        $l_total_video_s = $total_videos == 0 ? 'TOTAL_VIDEO_ZERO' : 'TOTAL_VIDEOS_OTHER';
        $l_total_category_s = $total_categories == 0 ? 'TOTAL_CATEGORY_ZERO' : 'TOTAL_CATEGORIES_OTHER';
        $l_total_view_s = $total_views == 0 ? 'TOTAL_VIEW_ZERO' : 'TOTAL_VIEWS_OTHER';
        $l_total_comment_s = $total_comments == 0 ? 'TOTAL_COMMENT_ZERO' : 'TOTAL_COMMENTS_OTHER';
        $this->template->assign_vars(array('TOTAL_VIDEOS_INDEX' => sprintf($this->user->lang[$l_total_video_s], $total_videos), 'TOTAL_CATEGORIES' => sprintf($this->user->lang[$l_total_category_s], $total_categories), 'TOTAL_VIEWS' => sprintf($this->user->lang[$l_total_view_s], $total_views), 'TOTAL_COMMENTS' => sprintf($this->user->lang[$l_total_comment_s], $total_comments), 'S_ENABLE_VIDEO_STATICS_ON_INDEX' => $this->config['enable_video_statics_on_index']));
    }
    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        $style_count = 0;
        $style_select = '';
        $sql = 'SELECT style_id, style_name
			FROM ' . STYLES_TABLE . '
			WHERE style_active = 1
			ORDER BY LOWER(style_name) ASC';
        $result = $this->db->sql_query($sql, 3600);
        while ($row = $this->db->sql_fetchrow($result)) {
            $style = $this->request->variable('style', 0);
            if (!empty($style)) {
                $url = str_replace('style=' . $style, 'style=' . $row['style_id'], $this->modules_helper->route('board3_portal_controller'));
            } else {
                $url = $this->modules_helper->route('board3_portal_controller') . '?style=' . $row['style_id'];
            }
            ++$style_count;
            $style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $this->user->style['style_id'] ? ' selected="selected"' : '') . '>' . utf8_htmlspecialchars($row['style_name']) . '</option>';
        }
        $this->db->sql_freeresult($result);
        if (strlen($style_select)) {
            $this->template->assign_var('STYLE_SELECT', $style_select);
        }
        // Assign specific vars
        $this->template->assign_vars(array('S_STYLE_OPTIONS' => $this->config['override_user_style'] || $style_count < 2 ? '' : $style_select));
        return 'stylechanger_side.html';
    }
Exemple #6
0
    public function page_header_after($event)
    {
        $context = $this->phpbb_container->get('template_context');
        $rootref =& $context->get_root_ref();
        if (isset($this->config['menu_enabled']) && $this->config['menu_enabled']) {
            $sql = 'SELECT *
				FROM ' . $this->menu_colors;
            $result = $this->db->sql_query($sql);
            $row = $this->db->sql_fetchrow($result);
            if ($this->db->sql_affectedrows()) {
                $this->template->assign_vars(array('S_MENU_COLOR' => $row['color_name'], 'S_MENU_FONT_COLOR' => $row['color_text'], 'S_MENU_FONT_COLOR_HOVER' => $row['color_text_hover'], 'S_MENU_DECORATION' => $row['color_text_hover_decor'], 'S_MENU_WEIGHT' => $row['color_text_weight'], 'S_MENU_SEARCH' => $row['color_display_search'], 'S_MENU_TEXT_TRANSFORM' => $row['color_text_transform'], 'S_MENU_ALIGN' => $row['color_align']));
                $sql = 'SELECT *
					FROM ' . $this->menu_buttons . '
					WHERE button_display = 1
						AND parent_id = 0
					ORDER BY left_id';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    if ($row['button_only_registered'] && $this->user->data['user_id'] == ANONYMOUS || $row['button_only_guest'] && $this->user->data['user_id'] != ANONYMOUS) {
                        continue;
                    }
                    if (preg_match("/\\{(.*)\\}/", $row['button_url'])) {
                        $brackets = array("{", "}");
                        $var_name = strtoupper(str_replace($brackets, '', $row['button_url']));
                        $row['button_url'] = $rootref[$var_name];
                    }
                    if (preg_match("/\\{(.*)\\}/", $row['button_name'])) {
                        $brackets = array("{L_", "}");
                        $var_name = strtoupper(str_replace($brackets, '', $row['button_name']));
                        $row['button_name'] = $this->user->lang[$var_name];
                    }
                    $this->template->assign_block_vars('buttons', array('ID' => $row['button_id'], 'URL' => $row['button_url'], 'NAME' => $row['button_name'], 'EXTERNAL' => $row['button_external']));
                    $sub_sql = 'SELECT *
						FROM ' . $this->menu_buttons . '
						WHERE button_display = 1
							AND parent_id = ' . $row['button_id'] . '
						ORDER BY left_id';
                    $sub_result = $this->db->sql_query($sub_sql);
                    while ($sub_row = $this->db->sql_fetchrow($sub_result)) {
                        if ($sub_row['button_only_registered'] && $this->user->data['user_id'] == ANONYMOUS || $sub_row['button_only_guest'] && $this->user->data['user_id'] != ANONYMOUS) {
                            continue;
                        }
                        if (preg_match("/\\{(.*)\\}/", $sub_row['button_url'])) {
                            $brackets = array("{", "}");
                            $var_name = strtoupper(str_replace($brackets, '', $sub_row['button_url']));
                            $sub_row['button_url'] = $rootref[$var_name];
                        }
                        if (preg_match("/\\{(.*)\\}/", $sub_row['button_name'])) {
                            $brackets = array("{L_", "}");
                            $var_name = strtoupper(str_replace($brackets, '', $sub_row['button_name']));
                            $sub_row['button_name'] = $this->user->lang[$var_name];
                        }
                        $this->template->assign_block_vars('buttons.sub', array('ID' => $sub_row['button_id'], 'URL' => $sub_row['button_url'], 'NAME' => $sub_row['button_name'], 'EXTERNAL' => $sub_row['button_external']));
                    }
                    $this->db->sql_freeresult($sub_result);
                }
                $this->db->sql_freeresult($result);
            }
        }
    }
Exemple #7
0
    /**
     * Modified version of the jumpbox, just lists authed forums (in the correct order)
     */
    function get_forum_list($ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false)
    {
        // This query is identical to the jumpbox one
        $sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id
			FROM ' . FORUMS_TABLE . '
			ORDER BY left_id ASC';
        $result = $this->db->sql_query($sql, 600);
        // We include the forum root/index to make tree traversal easier
        $forum_list[0] = array('forum_id' => '0', 'forum_name' => $this->user->lang['FORUMS'], 'forum_type' => '0', 'link' => append_sid("{$this->root_path}index.{$this->phpEx}"), 'parent_id' => false, 'current' => false, 'current_child' => false, 'disabled' => false);
        // Sometimes it could happen that forums will be displayed here not be displayed within the index page
        // This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
        // If this happens, the padding could be "broken"
        while ($row = $this->db->sql_fetchrow($result)) {
            $disabled = false;
            if (!$ignore_acl && $this->auth->acl_gets(array('f_list', 'f_read'), $row['forum_id'])) {
                if ($only_acl_post && !$this->auth->acl_get('f_post', $row['forum_id']) || !$this->auth->acl_get('m_approve', $row['forum_id']) && !$this->auth->acl_get('f_noapprove', $row['forum_id'])) {
                    $disabled = true;
                }
            } else {
                if (!$ignore_acl) {
                    continue;
                }
            }
            if (is_array($ignore_id) && in_array($row['forum_id'], $ignore_id) || $row['forum_id'] == $ignore_id || $row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id'] && $ignore_emptycat || $row['forum_type'] != FORUM_POST && $ignore_nonpost) {
                $disabled = true;
            }
            $u_viewforum = append_sid("{$this->root_path}viewforum.{$this->phpEx}", 'f=' . $row['forum_id']);
            $forum_list[$row['forum_id']] = array('forum_id' => $row['forum_id'], 'forum_name' => $row['forum_name'], 'forum_type' => $row['forum_type'], 'link' => $u_viewforum, 'parent_id' => $row['parent_id'], 'current' => false, 'current_child' => false, 'disabled' => $disabled);
        }
        $this->db->sql_freeresult($result);
        return $forum_list;
    }
    /**
     * Display the options a user can configure for this extension
     *
     * @return null
     * @access public
     */
    public function display_options()
    {
        add_form_key('acp_donation');
        // Is the form being submitted to us?
        if ($this->request->is_set_post('submit')) {
            if (!check_form_key('acp_donation')) {
                $error[] = 'FORM_INVALID';
            }
            $donation_row = array('donation_body' => $this->request->variable('donation_body', '', true), 'donation_cancel' => $this->request->variable('donation_cancel', '', true), 'donation_success' => $this->request->variable('donation_success', '', true));
            foreach ($donation_row as $this->config_name => $this->config_value) {
                $sql = 'UPDATE ' . $this->donation_table . "\n\t\t\t\t\tSET config_value = '" . $this->db->sql_escape($this->config_value) . "'\n\t\t\t\t\tWHERE config_name = '" . $this->db->sql_escape($this->config_name) . "'";
                $this->db->sql_query($sql);
            }
            // Set the options the user configured
            $this->set_options();
            // Add option settings change action to the admin log
            $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'DONATION_SAVED');
            trigger_error($this->user->lang['DONATION_SAVED'] . adm_back_link($this->u_action));
        }
        // let's get it on
        $sql = 'SELECT *
		FROM ' . $this->donation_table;
        $result = $this->db->sql_query($sql);
        $donation = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            $donation[$row['config_name']] = $row['config_value'];
        }
        $this->db->sql_freeresult($result);
        $donation_body = isset($donation['donation_body']) ? $donation['donation_body'] : '';
        $donation_cancel = isset($donation['donation_cancel']) ? $donation['donation_cancel'] : '';
        $donation_success = isset($donation['donation_success']) ? $donation['donation_success'] : '';
        $donation_version = isset($this->config['donation_version']) ? $this->config['donation_version'] : '';
        $this->template->assign_vars(array('DONATION_VERSION' => $donation_version, 'DONATION_ENABLE' => $this->config['donation_enable'], 'DONATION_INDEX_ENABLE' => $this->config['donation_index_enable'], 'DONATION_INDEX_TOP' => $this->config['donation_index_top'], 'DONATION_INDEX_BOTTOM' => $this->config['donation_index_bottom'], 'DONATION_EMAIL' => $this->config['donation_email'], 'DONATION_ACHIEVEMENT_ENABLE' => $this->config['donation_achievement_enable'], 'DONATION_ACHIEVEMENT' => $this->config['donation_achievement'], 'DONATION_GOAL_ENABLE' => $this->config['donation_goal_enable'], 'DONATION_GOAL' => $this->config['donation_goal'], 'DONATION_GOAL_CURRENCY_ENABLE' => $this->config['donation_goal_currency_enable'], 'DONATION_GOAL_CURRENCY' => $this->config['donation_goal_currency'], 'DONATION_BODY' => $donation_body, 'DONATION_CANCEL' => $donation_cancel, 'DONATION_SUCCESS' => $donation_success, 'U_ACTION' => $this->u_action));
    }
    public function get_bookmarks($ext_mode = '', $forums = array())
    {
        define('POSTS_BOOKMARKS_TABLE', $this->table_prefix . 'posts_bookmarks');
        $start = $this->request->variable('start', 0);
        $sql = 'SELECT COUNT(post_id) as posts_count
			FROM ' . POSTS_BOOKMARKS_TABLE . '
			WHERE user_id = ' . $this->user->data['user_id'];
        $result = $this->db->sql_query($sql);
        $posts_count = (int) $this->db->sql_fetchfield('posts_count');
        $this->db->sql_freeresult($result);
        $sql_where = $sql_fields = '';
        if ($ext_mode != 'find') {
            $sql_where = 'LEFT JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)';
            $sql_fields = ', p.post_time, u.user_id, u.username, u.user_colour';
        }
        $pagination_url = append_sid("{$this->phpbb_root_path}postbookmark", "mode=find");
        $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $posts_count, $this->config['topics_per_page'], $start);
        $sql = 'SELECT b.post_id AS b_post_id, b.user_id, b.bookmark_time, b.bookmark_desc, p.post_id, p.forum_id, p.topic_id, p.poster_id, p.post_subject, t.topic_title ' . $sql_fields . '
			FROM ' . POSTS_BOOKMARKS_TABLE . ' b
			LEFT JOIN ' . POSTS_TABLE . ' p ON( b.post_id = p.post_id)
			LEFT JOIN ' . TOPICS_TABLE . ' t ON( t.topic_id = p.topic_id)
			' . $sql_where . '
			WHERE b.user_id = ' . $this->user->data['user_id'] . '
			ORDER BY b.bookmark_time ASC';
        $result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start);
        while ($row = $this->db->sql_fetchrow($result)) {
            $topic_author = $sql_where ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '';
            $post_time = $sql_where ? $this->user->format_date($row['post_time']) : '';
            // Send vars to template
            $this->template->assign_block_vars('postrow', array('POST_ID' => $row['b_post_id'], 'POST_TIME' => $post_time, 'BOOKMARK_TIME' => $this->user->format_date($row['bookmark_time']), 'BOOKMARK_DESC' => $row['bookmark_desc'], 'TOPIC_AUTHOR' => $topic_author, 'POST_TITLE' => $row['post_subject'] ? $row['post_subject'] : $row['topic_title'], 'U_VIEW_POST' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "p=" . $row['post_id'] . "#p" . $row['post_id'] . ""), 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'S_DELETED_POST' => !$row['post_id'] ? true : false, 'U_POST_BOOKMARK' => '[url=' . generate_board_url() . '/viewtopic.' . $this->php_ext . '?p=' . $row['post_id'] . '#p' . $row['post_id'] . ']' . ($row['post_subject'] ? $row['post_subject'] : $row['topic_title']) . '[/url]'));
        }
        $this->db->sql_freeresult($result);
        $this->template->assign_vars(array('TOTAL_BOOKMARKS' => $this->user->lang('TOTAL_BOOKMARKS', (int) $posts_count), 'PAGE_NUMBER' => $this->pagination->on_page($posts_count, $this->config['topics_per_page'], $start)));
    }
    function main()
    {
        $sql = 'SELECT *
				FROM ' . $this->points_values_table;
        $result = $this->db->sql_query($sql);
        $points_values = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // Add part to bar
        $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'info')), 'FORUM_NAME' => sprintf($this->user->lang['POINTS_INFO'], $this->config['points_name'])));
        // Read out all the need values
        $info_attach = $points_values['points_per_attach'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_attach']) . '&nbsp;' . $this->config['points_name']);
        $info_addtional_attach = $points_values['points_per_attach_file'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_attach_file']) . '&nbsp;' . $this->config['points_name']);
        $info_poll = $points_values['points_per_poll'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_poll']) . '&nbsp;' . $this->config['points_name']);
        $info_poll_option = $points_values['points_per_poll_option'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_poll_option']) . '&nbsp;' . $this->config['points_name']);
        $info_topic_word = $points_values['points_per_topic_word'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_topic_word']) . '&nbsp;' . $this->config['points_name']);
        $info_topic_character = $points_values['points_per_topic_character'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_topic_character']) . '&nbsp;' . $this->config['points_name']);
        $info_post_word = $points_values['points_per_post_word'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_post_word']) . '&nbsp;' . $this->config['points_name']);
        $info_post_character = $points_values['points_per_post_character'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_post_character']) . '&nbsp;' . $this->config['points_name']);
        $info_cost_warning = $points_values['points_per_warn'] == 0 ? sprintf($this->user->lang['INFO_NO_COST'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['points_per_warn']) . '&nbsp;' . $this->config['points_name']);
        $info_reg_bonus = $points_values['reg_points_bonus'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->functions_points->number_format_points($points_values['reg_points_bonus']) . '&nbsp;' . $this->config['points_name']);
        $info_points_bonus = $points_values['points_bonus_chance'] == 0 ? sprintf($this->user->lang['INFO_NO_POINTS'], $this->config['points_name']) : sprintf($this->user->lang['INFO_BONUS_CHANCE_EXPLAIN'], $this->functions_points->number_format_points($points_values['points_bonus_chance']), $this->functions_points->number_format_points($points_values['points_bonus_min']), $this->functions_points->number_format_points($points_values['points_bonus_max']), $this->config['points_name']);
        $this->template->assign_vars(array('USER_POINTS' => sprintf($this->functions_points->number_format_points($this->user->data['user_points'])), 'POINTS_NAME' => $this->config['points_name'], 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'POINTS_INFO_DESCRIPTION' => sprintf($this->user->lang['POINTS_INFO_DESCRIPTION'], $this->config['points_name']), 'INFO_ATTACH' => $info_attach, 'INFO_ADD_ATTACH' => $info_addtional_attach, 'INFO_POLL' => $info_poll, 'INFO_POLL_OPTION' => $info_poll_option, 'INFO_TOPIC_WORD' => $info_topic_word, 'INFO_TOPIC_CHARACTER' => $info_topic_character, 'INFO_POST_WORD' => $info_post_word, 'INFO_POST_CHARACTER' => $info_post_character, 'INFO_COST_WARNING' => $info_cost_warning, 'INFO_REG_BONUS' => $info_reg_bonus, 'INFO_POINTS_BONUS' => $info_points_bonus, 'U_TRANSFER_USER' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'transfer_user')), 'U_LOGS' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'logs')), 'U_LOTTERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'lottery')), 'U_BANK' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')), 'U_ROBBERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')), 'U_INFO' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'info')), 'U_USE_TRANSFER' => $this->auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $this->auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $this->auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $this->auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $this->auth->acl_get('u_use_robbery')));
        // Generate the page
        page_header($this->user->lang['POINTS_INFO']);
        // Generate the page template
        $this->template->set_filenames(array('body' => 'points/points_info.html'));
        page_footer();
    }
Exemple #11
0
    /**
     * Fix tree.
     *
     * @param int $i
     * @param string $pkey
     * @param string $table
     * @param int $parent_id
     * @param array $where
     * @return bool
     */
    protected function fix_tree(&$i, $pkey, $table, $parent_id = 0, $where = array())
    {
        $changes_made = false;
        $sql = 'SELECT *
			FROM ' . $table . '
			WHERE parent_id = ' . (int) $parent_id . (!empty($where) ? ' AND ' . implode(' AND ', $where) : '') . '
			ORDER BY left_id ASC';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            // First we update the left_id for this module
            if ($row['left_id'] != $i) {
                $this->db->sql_query('
					UPDATE ' . $table . '
					SET ' . $this->db->sql_build_array('UPDATE', array('left_id' => $i)) . "\n\t\t\t\t\tWHERE {$pkey} = {$row[$pkey]}");
                $changes_made = true;
            }
            $i++;
            // Then we go through any children and update their left/right id's
            $changes_made = $this->fix_tree($i, $pkey, $table, $row[$pkey], $where) || $changes_made;
            // Then we come back and update the right_id for this module
            if ($row['right_id'] != $i) {
                $this->db->sql_query('
					UPDATE ' . $table . '
					SET ' . $this->db->sql_build_array('UPDATE', array('right_id' => $i)) . "\n\t\t\t\t\tWHERE {$pkey} = {$row[$pkey]}");
                $changes_made = true;
            }
            $i++;
        }
        $this->db->sql_freeresult($result);
        return $changes_made;
    }
Exemple #12
0
    public function base()
    {
        $note = utf8_normalize_nfc($this->request->variable('note', '', true));
        $submit = isset($_POST['submit']) ? true : false;
        $error = array();
        // check if user s logged in, since this page can be used only after registration...
        if (!$this->user->data['is_registered']) {
            login_box($this->helper->route('vinny_usersnotes_controller'));
        }
        // ... and also this is not for bots (especially for bad ones :)
        if ($this->user->data['is_bot']) {
            redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}"));
        }
        $s_action = $this->helper->route('vinny_usersnotes_controller');
        $s_hidden_fields = '';
        add_form_key('postform');
        // create a template variables
        $this->template->assign_vars(array('S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : ''));
        if ($submit) {
            /*if(!check_form_key('postform'))
            		{
            			trigger_error('FORM_INVALID');
            		}*/
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET user_note = "' . $note . '"
				WHERE user_id = ' . $this->user->data['user_id'];
            $this->db->sql_query($sql);
            meta_refresh(3, $this->helper->route('vinny_usersnotes_controller'));
            trigger_error(sprintf($this->user->lang['NOTES_SAVED'], $this->helper->route('vinny_usersnotes_controller')));
        }
        // create a template variables
        $this->template->assign_vars(array('NOTE' => $this->user->data['user_note']));
        $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['NOTES']));
        return $this->helper->render('notes.html', $this->user->lang['NOTES']);
    }
 /**
  * Run the cronjob.
  */
 public function run()
 {
     $time = strtotime('- ' . $this->config['ajaxshoutbox_prune_days'] . ' days');
     $sql = 'SELECT * FROM ' . $this->table . ' WHERE post_time <= ' . $time;
     $result = $this->db->sql_query($sql);
     $canpush = $this->push->canPush();
     $delete = array();
     while ($row = $this->db->sql_fetchrow($result)) {
         if ($canpush) {
             if ($this->push->delete($row['shout_id']) !== false) {
                 $delete[] = $row['shout_id'];
             }
         } else {
             $delete[] = $row['shout_id'];
         }
     }
     $this->db->sql_freeresult();
     if (sizeof($delete)) {
         $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $this->db->sql_in_set('shout_id', $delete);
         $this->db->sql_query($sql);
         $uuid = $this->user->data['user_id'];
         if (!$uuid) {
             $uuid = ANONYMOUS;
         }
         $this->log->add('admin', $uuid, $this->user->ip, 'LOG_AJAX_SHOUTBOX_PRUNED', time(), array(sizeof($delete)));
     }
     $this->config->set('shoutbox_prune_gc', time(), false);
 }
    public function add_page_header_links($event)
    {
        if (!empty($this->config['allow_visits_counter'])) {
            $this->language->add_lang('common', 'dmzx/counter');
            $sql = 'SELECT COUNT(*) AS visits_counter
				FROM ' . $this->visits_counter_table . '
				WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
            $result = $this->db->sql_query($sql);
            $visits_counter = (int) $this->db->sql_fetchfield('visits_counter');
            $this->db->sql_freeresult($result);
            $visits = $this->config['visits_counter'];
            if ($visits_counter == 0) {
                $sql_ary = array('uvc_ip' => $this->user->ip, 'uvc_timestamp' => time());
                $sql = 'INSERT INTO ' . $this->visits_counter_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                $this->db->sql_query($sql);
                $this->config->increment('visits_counter', 1, true);
            } else {
                $sql_ary = array('uvc_timestamp' => time());
                $sql = 'UPDATE ' . $this->visits_counter_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
                $this->db->sql_query($sql);
            }
            $timestamp = time() - 3600 * 24;
            $sql_ary = array($timestamp);
            $sql = 'DELETE FROM ' . $this->visits_counter_table . '
				WHERE uvc_timestamp < ' . $timestamp;
            $this->db->sql_query($sql);
            $sql = 'SELECT COUNT(*) AS num_del
				FROM ' . $this->visits_counter_table . ' ';
            $result = $this->db->sql_query($sql);
            $visitsok = (int) $this->db->sql_fetchfield('num_del');
            $this->template->assign_vars(array('UNIQUE_VISITS_COUNTER' => $this->language->lang('UNIQUE_VISITS_COUNTER', $visitsok)));
        }
    }
Exemple #15
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->db->sql_return_on_error(true);
     $languages = $this->language_helper->get_available_languages();
     $installed_languages = array();
     foreach ($languages as $lang_info) {
         $lang_pack = array('lang_iso' => $lang_info['iso'], 'lang_dir' => $lang_info['iso'], 'lang_english_name' => htmlspecialchars($lang_info['name']), 'lang_local_name' => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'), 'lang_author' => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'));
         $this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack));
         $installed_languages[] = (int) $this->db->sql_nextid();
         if ($this->db->get_sql_error_triggered()) {
             $error = $this->db->sql_error($this->db->get_sql_error_sql());
             $this->iohandler->add_error_message($error['message']);
         }
     }
     $sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE;
     $result = $this->db->sql_query($sql);
     $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
     while ($row = $this->db->sql_fetchrow($result)) {
         foreach ($installed_languages as $lang_id) {
             $insert_buffer->insert(array('field_id' => $row['field_id'], 'lang_id' => $lang_id, 'lang_name' => strtoupper(substr($row['field_name'], 6)), 'lang_explain' => '', 'lang_default_value' => ''));
         }
     }
     $this->db->sql_freeresult($result);
     $insert_buffer->flush();
 }
 public function main()
 {
     $topic_id = $this->request->variable('t', 0);
     $post_id = $this->request->variable('p', 0);
     $forum_id = $this->request->variable('f', 0);
     $mode = $this->request->variable('mode', '');
     $book_submit = $this->request->variable('book', false);
     $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic." . $this->php_ext . "", "f={$forum_id}&amp;t={$topic_id}");
     $return_link = '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
     $body = 'add_bookmark';
     if ($mode == 'delete') {
         $sql = 'DELETE FROM ' . $this->postbookmark_table . "\n\t\t\t\tWHERE user_id = {$this->user->data['user_id']}\n\t\t\t\t\tAND post_id = {$post_id}";
         $this->db->sql_query($sql);
         $message = $this->user->lang['POST_BOOKMARK_REMOVED'];
         $this->helper->output_response($message, $return_link, $viewtopic_url);
     } else {
         if ($mode == 'find') {
             $body = 'find_bookmark';
             $this->helper->get_bookmarks($mode);
         } else {
             $bookmark_desc = $this->request->variable('bookmark_desc', '', true);
             if ($book_submit) {
                 $sql = 'INSERT INTO ' . $this->postbookmark_table . ' ' . $this->db->sql_build_array('INSERT', array('user_id' => $this->user->data['user_id'], 'post_id' => $post_id, 'topic_id' => $topic_id, 'bookmark_time' => time(), 'bookmark_desc' => $bookmark_desc));
                 $this->db->sql_query($sql);
                 $message = $this->user->lang['POST_BOOKMARK_ADDED'];
                 $this->helper->output_response($message, $return_link, $viewtopic_url);
             }
         }
     }
     $this->template->assign_vars(array('U_POST_ACTION' => append_sid("{$this->phpbb_root_path}postbookmark", "f={$forum_id}&amp;t={$topic_id}&amp;p={$post_id}&amp;mode={$mode}")));
     page_header($this->user->lang['POST_BOOKMARK_ADD']);
     $this->template->set_filenames(array('body' => $body . '.html'));
     page_footer();
     return new Response('', 200);
 }
Exemple #17
0
 /**
  * Delete a shoutbox post
  *
  * @param int $id
  *
  * @throws \paul999\ajaxshoutbox\exceptions\shoutbox_exception
  */
 public function delete_post($id)
 {
     if (!$id) {
         $id = $this->request->variable('id', 0);
     }
     $sql = 'SELECT user_id FROM ' . $this->table . ' WHERE shout_id = ' . (int) $id;
     $result = $this->db->sql_query($sql);
     $row = $this->db->sql_fetchrow();
     $this->db->sql_freeresult($result);
     if (!$row) {
         throw new shoutbox_exception('AJAX_SHOUTBOX_NO_SUCH_POST');
     }
     if (!$this->auth->acl_get('m_shoutbox_delete')) {
         // User has no m_ permission.
         if ($row['user_id'] != $this->user->data['user_id']) {
             throw new shoutbox_exception('AJAX_SHOUTBOX_NO_SUCH_POST');
         }
         if (!$this->auth->acl_get('u_shoutbox_delete')) {
             throw new shoutbox_exception('AJAX_SHOUTBOX_NO_PERMISSION');
         }
     }
     if ($this->push->canPush()) {
         if ($this->push->delete($id) === false) {
             throw new shoutbox_exception('AJAX_SHOUTBOX_PUSH_NOT_AVAIL');
         }
     }
     $sql = 'DELETE FROM ' . $this->table . ' WHERE shout_id =  ' . (int) $id;
     $this->db->sql_query($sql);
 }
Exemple #18
0
    public function handle_downloadlog()
    {
        if (!$this->auth->acl_get('a_')) {
            trigger_error('Access Denied');
        } else {
            $this->user->add_lang_ext('dmzx/downloadlog', 'common');
            $fileid = $this->request->variable('file', 0);
            $start = $this->request->variable('start', 0);
            // Pagination number from ACP
            $dll = $this->config['downloadlog_value'];
            // Generate pagination
            $sql = 'SELECT COUNT(downloadslog_id) AS total_downloadlogs
				FROM ' . $this->userdownloadslog_table . '
				WHERE user_id = user_id
				AND file_id = ' . $fileid;
            $result = $this->db->sql_query($sql);
            $total_downloadlogs = (int) $this->db->sql_fetchfield('total_downloadlogs');
            $sql = 'SELECT d.user_id, d.down_date, u.user_id, u.username, u.user_colour
				FROM ' . $this->userdownloadslog_table . ' d, ' . USERS_TABLE . ' u
				WHERE u.user_id = d.user_id
				AND file_id = ' . $fileid . '
				ORDER BY d.down_date DESC';
            $top_result = $this->db->sql_query_limit($sql, $dll, $start);
            while ($row = $this->db->sql_fetchrow($top_result)) {
                $this->template->assign_block_vars('downloaders', array('D_USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'D_TIME' => $this->user->format_date($row['down_date'])));
            }
        }
        $pagination_url = $this->helper->route('dmzx_downloadlog_controller', array('file' => $fileid));
        //Start pagination
        $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_downloadlogs, $dll, $start);
        $this->template->assign_vars(array('DOWNLOADERS_USERS' => $total_downloadlogs == 1 ? $this->user->lang['DOWNLOADERS_COUNT'] : sprintf($this->user->lang['DOWNLOADERS_COUNTS'], $total_downloadlogs), 'DOWNLOADERS_VERSION' => $this->config['downloadlog_version']));
        page_header('Downloaders Log', false);
        $this->template->set_filenames(array('body' => 'DownloadLog.html'));
        page_footer();
    }
Exemple #19
0
 /**
  * {@inheritdoc}
  */
 public function get_group_rules($type = '')
 {
     $sql_array = array('SELECT' => 'agr.*, agt.autogroups_type_name', 'FROM' => array($this->autogroups_rules_table => 'agr', $this->autogroups_types_table => 'agt'), 'WHERE' => 'agr.autogroups_type_id = agt.autogroups_type_id' . ($type ? " AND agt.autogroups_type_name = '" . $this->db->sql_escape($type) . "'" : ''));
     $sql = $this->db->sql_build_query('SELECT', $sql_array);
     $result = $this->db->sql_query($sql, 7200);
     $rows = $this->db->sql_fetchrowset($result);
     $this->db->sql_freeresult($result);
     return $rows;
 }
Exemple #20
0
 /**
  * Show all anniversaries
  *
  * @return void
  * @access public
  */
 public function overview()
 {
     // Catch all anniversaries from the database
     $sql = 'SELECT anniversary_id, day, month, year, event, link FROM phpbb_consim_anniversary';
     $result = $this->db->sql_query($sql);
     while ($row = $this->db->sql_fetchrow($result)) {
         $this->template->assign_block_vars('Anniversaries', array('EVENT' => $row['event'], 'ODATE' => $row['year'] != 0 ? date("Y") - (int) $row['year'] . ". " : "", 'DAY' => $row['day'], 'MONTH' => $row['month'], 'YEAR' => $row['year'], 'LINK' => $row['link'], 'ID' => $row['anniversary_id'], 'DELETE' => build_url() . "&action=delete_anniversary&anniversary_id=" . $row['anniversary_id']));
     }
 }
Exemple #21
0
 /**
  * @dataProvider data_attachment_delete
  */
 public function test_attachment_delete($mode, $ids, $resync, $expected)
 {
     // We need to reset the attachment ID sequence to properly test this
     if ($this->db->get_sql_layer() === 'postgres') {
         $sql = 'ALTER SEQUENCE phpbb_attachments_seq RESTART WITH 1';
         $this->db->sql_query($sql);
     }
     $this->assertSame($expected, $this->attachment_delete->delete($mode, $ids, $resync));
 }
    public function page_header($event)
    {
        $this->user->add_lang_ext('dmzx/totalavtiveext', 'common');
        $sql = 'SELECT SUM(ext_active) AS count
			FROM ' . EXT_TABLE;
        $result = $this->db->sql_query($sql);
        $ext_count = (int) $this->db->sql_fetchfield('count');
        $this->template->assign_vars(array('TOTAL_EXT' => $this->user->lang['TOTAL_EXT'] . ' <strong>' . number_format($ext_count) . '</strong>'));
    }
Exemple #23
0
    /**
     * Check if the provided user has a specific key in the table provided
     *
     * @param string $table   Table to check in
     * @param int    $user_id The specific user
     * @param string $where	  Extra where clause. Be sure to include AND
     *
     * @return bool
     */
    protected function check_table_for_user($table, $user_id, $where = '')
    {
        $sql = 'SELECT COUNT(registration_id) as reg_id 
			FROM ' . $this->db->sql_escape($table) . '
			WHERE user_id = ' . (int) $user_id . ' ' . $where;
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        return $row && $row['reg_id'] > 0;
    }
Exemple #24
0
    public function attachments_data($event)
    {
        $topic_id = $event['topic_id'];
        $sql = 'SELECT COUNT(attach_id) as num_attachments
			FROM ' . ATTACHMENTS_TABLE . " a\n\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tAND a.is_orphan = 0";
        $result = $this->db->sql_query($sql);
        $num_attachments = $this->db->sql_fetchfield('num_attachments');
        $this->db->sql_freeresult($result);
        $this->template->assign_vars(array('U_ATTACHMENTS_TOPIC' => $this->helper->route("bb3mobi_attach_cat", array('t' => $topic_id)), 'TOTAL_ATTACH_TOPIC' => (int) $num_attachments));
    }
Exemple #25
0
    /**
     * Runs this cron task.
     *
     * @return null
     */
    public function run()
    {
        $sql = 'UPDATE ' . RATING_TABLE . ' SET 
			`top_hits_before` = `top_hits`,
			`top_hosts_before` = `top_hosts`,
			`top_in_before` = `top_in`,
			`top_out_before` = `top_out`,
			`top_hits` = 0,
			`top_hosts` = 0,
			`top_in` = 0,
			`top_out` = 0
		WHERE `top_id` BETWEEN 1 AND 100000
			AND top_hosts > 1';
        $this->db->sql_query($sql);
        $this->db->sql_query('TRUNCATE TABLE ' . RATING_CLICK_TABLE);
        $this->db->sql_query('TRUNCATE TABLE ' . RATING_HITS_TABLE);
        $this->db->sql_query('TRUNCATE TABLE ' . RATING_ONLINE_TABLE);
        $this->db->sql_query('OPTIMIZE TABLE ' . RATING_TABLE);
        $this->db->sql_query('OPTIMIZE TABLE ' . RATING_CLICK_TABLE);
        $this->db->sql_query('OPTIMIZE TABLE ' . RATING_HITS_TABLE);
        $this->db->sql_query('OPTIMIZE TABLE ' . RATING_ONLINE_TABLE);
        //$this->config->set('rating_platforms_active', 0);
        $timestamp = time();
        $timezone = new \DateTimeZone($this->config['board_timezone']);
        $time = $this->user->get_timestamp_from_format('Y-m-d H:i:s', date('Y', $timestamp) . '-' . date('m', $timestamp) . '-' . date('d', $timestamp) . ' 00:00:00', $timezone);
        $this->config->set('top_rating_last_gc', $time);
    }
    /**
     * Fetches language entries for options from DB
     *
     * @param	int		$lang_id
     */
    public function load_option_lang($lang_id)
    {
        $sql = 'SELECT field_id, option_id, lang_value
				FROM ' . $this->language_table . '
				WHERE lang_id = ' . (int) $lang_id . "\n\t\t\t\tORDER BY option_id";
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $this->options_lang[$row['field_id']][$lang_id][$row['option_id'] + 1] = $row['lang_value'];
        }
        $this->db->sql_freeresult($result);
    }
 public function load_language_on_setup($event)
 {
     // Initial reset of the module_display row in the module table
     if (!$this->config['lmdi_purge_ucp']) {
         $sql = "UPDATE " . MODULES_TABLE . "\n\t\t\t\tSET module_display = 0 \n\t\t\t\tWHERE module_langname = 'UCP_PSB'";
         // var_dump ($sql);
         $this->db->sql_query($sql);
     }
     $lang_set_ext = $event['lang_set_ext'];
     $lang_set_ext[] = array('ext_name' => 'lmdi/purgesub', 'lang_set' => 'common');
     $event['lang_set_ext'] = $lang_set_ext;
 }
Exemple #28
0
 public function marquer_photos_lues($event)
 {
     $user_id = $this->user->data["user_id"];
     $lesPhotos = fonctionGetLastCommentaireForUser($user_id, 10, false);
     $lesPhotos = commentaireForUser($lesPhotos, $user_id);
     foreach ($lesPhotos['lignesMessage'] as $photo) {
         $query = "\n\t\t\t\tDELETE FROM `photo_track` \n\t\t\t\tWHERE user_id = '" . $user_id . "' \n\t\t\t\tAND photo_id = '" . $photo['photo_id'] . "' \n\t\t\t";
         $this->db->sql_query($query);
         $query = "\n\t\t\t\tINSERT INTO `photo_track` \n\t\t\t\t(`user_id`, `photo_id`, `mark_time`) \n\t\t\t\tVALUES \n\t\t\t\t('" . $user_id . "', '" . $photo['photo_id'] . "', " . time() . ")\n\t\t\t";
         $this->db->sql_query($query);
     }
 }
    public function edit_user_ranks()
    {
        $this->template->assign_vars(array('U_ACTION' => $this->u_action, 'S_FIND_USER' => true, 'U_FIND_USERNAME' => append_sid("{$this->root_path}memberlist.{$this->php_ext}", 'mode=searchuser&amp;form=select_user&amp;field=username&amp;select_single=true')));
        $submit = isset($_POST['submit-user']) ? true : false;
        if ($submit) {
            $username = utf8_normalize_nfc(request_var('username', '', true));
            $user_sql = 'SELECT *
				FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'";
            $user_result = $this->db->sql_query($user_sql);
            $user_row = $this->db->sql_fetchrow($user_result);
            $user_id = (int) $user_row['user_id'];
            $this->db->sql_freeresult($user_result);
            if (!$user_id) {
                trigger_error($this->user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
            }
            $rank_sql = 'SELECT *
					FROM ' . RANKS_TABLE . '
					WHERE rank_special = 1
					ORDER BY rank_title';
            $rank_result = $this->db->sql_query($rank_sql);
            $s_rank_one_options = '<option value="0"' . (!$user_row['user_rank'] ? ' selected="selected"' : '') . '>' . $this->user->lang['ACP_NO_SPEC_RANK'] . '</option>';
            $s_rank_two_options = '<option value="0"' . (!$user_row['user_rank_two'] ? ' selected="selected"' : '') . '>' . $this->user->lang['ACP_NO_SPEC_RANK'] . '</option>';
            $s_rank_three_options = '<option value="0"' . (!$user_row['user_rank_three'] ? ' selected="selected"' : '') . '>' . $this->user->lang['ACP_NO_SPEC_RANK'] . '</option>';
            while ($row = $this->db->sql_fetchrow($rank_result)) {
                $selected1 = $user_row['user_rank'] && $row['rank_id'] == $user_row['user_rank'] ? ' selected="selected"' : '';
                $s_rank_one_options .= '<option value="' . $row['rank_id'] . '"' . $selected1 . '>' . $row['rank_title'] . '</option>';
                $selected2 = $user_row['user_rank_two'] && $row['rank_id'] == $user_row['user_rank_two'] ? ' selected="selected"' : '';
                $s_rank_two_options .= '<option value="' . $row['rank_id'] . '"' . $selected2 . '>' . $row['rank_title'] . '</option>';
                $selected3 = $user_row['user_rank_three'] && $row['rank_id'] == $user_row['user_rank_three'] ? ' selected="selected"' : '';
                $s_rank_three_options .= '<option value="' . $row['rank_id'] . '"' . $selected3 . '>' . $row['rank_title'] . '</option>';
            }
            $this->db->sql_freeresult($result);
            $this->template->assign_vars(array('ACP_MR_USER' => sprintf($this->user->lang['ACP_EDIT_USER_RANK'], $user_row['username']), 'S_EDIT_RANKS' => true, 'S_FIND_USER' => false, 'S_RANK_ONE_OPTIONS' => $s_rank_one_options, 'S_RANK_TWO_OPTIONS' => $s_rank_two_options, 'S_RANK_THREE_OPTIONS' => $s_rank_three_options, 'HIDDEN_RANK_USER_ID' => $user_id));
        }
        add_form_key('submit-rank-key');
        $upd_rank = isset($_POST['submit-rank']) ? true : false;
        if ($upd_rank) {
            if (check_form_key('submit-rank-key')) {
                $rank_one = request_var('user_rank_one', 0);
                $rank_two = request_var('user_rank_two', 0);
                $rank_thr = request_var('user_rank_three', 0);
                $upd_user_id = request_var('hidden_user_id', 0);
                $upd_sql = 'UPDATE ' . USERS_TABLE . '
							SET user_rank = ' . $rank_one . ',
								user_rank_two = ' . $rank_two . ',
								user_rank_three = ' . $rank_thr . '
							WHERE user_id = ' . $upd_user_id;
                $this->db->sql_query($upd_sql);
                trigger_error($this->user->lang('ACP_MR_SAVED') . adm_back_link($this->u_action));
            }
        }
    }
Exemple #30
0
 /**
  * Get users that should not have their default status changed
  *
  * @return array An array of user ids
  * @access public
  */
 public function get_default_exempt_users()
 {
     $user_id_ary = array();
     // Get users whose default group is autogroup_default_exempt
     $sql_array = array('SELECT' => 'u.user_id', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(GROUPS_TABLE => 'g'), 'ON' => 'g.group_id = u.group_id')), 'WHERE' => 'g.autogroup_default_exempt = 1');
     $sql = $this->db->sql_build_query('SELECT', $sql_array);
     $result = $this->db->sql_query($sql);
     while ($row = $this->db->sql_fetchrow($result)) {
         $user_id_ary[] = $row['user_id'];
     }
     $this->db->sql_freeresult($result);
     return $user_id_ary;
 }