Exemple #1
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);
            }
        }
    }
    /**
     * 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)));
    }
Exemple #4
0
    /**
     * Changes the regex replacement for second pass
     *
     * @param object $event
     * @return null
     * @access public
     */
    public function modify_replies($event)
    {
        if (!function_exists('get_username_string')) {
            include $this->root_path . 'includes/functions_content.' . $this->php_ext;
        }
        // 1. output each line with user + post-count
        // 2. output in "inline-popup" like in "mark posts read"
        $topic_row = $event['topic_row'];
        $topic_id = $topic_row['TOPIC_ID'];
        $sql = 'SELECT COUNT(p.post_id) AS posts, p.poster_id, u.username, u.user_colour
		FROM phpbb_posts p, phpbb_users u
		WHERE p.topic_id = ' . (int) $topic_id . '
		AND p.poster_id = u.user_id
		GROUP BY p.poster_id
		ORDER BY posts DESC';
        $result = $this->db->sql_query_limit($sql, 5);
        while ($row = $this->db->sql_fetchrow($result)) {
            var_dump($row);
            $post_count = $row['posts'];
            $display_username = get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']);
            echo $display_username . ' with ' . $post_count . 'posts<br />';
        }
        $this->db->sql_freeresult($result);
        $topic_row['REPLIES'] = '<a href="#t=' . $topic_id . '" class="whoposted">' . $topic_row['REPLIES'] . '</a>';
        $event['topic_row'] = $topic_row;
    }
Exemple #5
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;
    }
 /**
  * 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);
 }
    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 #8
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();
 }
Exemple #9
0
    /**
     * Delete a version of an article
     *
     * @param	int		$id	Id of the version to delete
     * @return	object
     */
    public function version($id)
    {
        if (!$this->auth->acl_get('m_wiki_delete')) {
            trigger_error('NOT_AUTHORISED');
        }
        $sql = 'SELECT article_approved, article_url
			FROM ' . $this->article_table . '
				WHERE article_id = ' . (int) $id;
        $result = $this->db->sql_query_limit($sql, 1);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($row['article_approved'] != 0) {
            trigger_error($this->user->lang['NO_DELETE_ACTIVE_VERSION'] . '<br /><br /><a href="' . $this->helper->route('tas2580_wiki_article', array('article' => $row['article_url'])) . '">' . $this->user->lang['BACK_TO_ARTICLE'] . '</a>');
        }
        if (confirm_box(true)) {
            $sql = 'DELETE FROM ' . $this->article_table . '
				WHERE article_id = ' . (int) $id;
            $this->db->sql_query($sql);
            //return $helper->message('DELETE_VERSION_SUCCESS', array());
            trigger_error($this->user->lang['DELETE_VERSION_SUCCESS'] . '<br /><br /><a href="' . $this->helper->route('tas2580_wiki_article', array('article' => $row['article_url'])) . '">' . $this->user->lang['BACK_TO_ARTICLE'] . '</a>');
        } else {
            $s_hidden_fields = build_hidden_fields(array('id' => $id));
            confirm_box(false, $this->user->lang['CONFIRM_DELETE_VERSION'], $s_hidden_fields);
        }
        redirect($this->helper->route('tas2580_wiki_index', array('id' => $id)));
    }
Exemple #10
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 #11
0
    public function page_header($event)
    {
        if ($this->auth->acl_get('u_did_you_know')) {
            $sql_layer = $this->db->get_sql_layer();
            switch ($sql_layer) {
                case 'postgres':
                    $random = 'RANDOM()';
                    break;
                case 'mssql':
                case 'mssql_odbc':
                    $random = 'NEWID()';
                    break;
                default:
                    $random = 'RAND()';
                    break;
            }
            $sql = 'SELECT word, bbcode_uid, bbcode_bitfield, bbcode_options
				FROM ' . $this->did_you_know . "\n\t\t\t\tWHERE lang_iso = '{$this->user->data['user_lang']}'\n\t\t\t\t\tOR lang_iso = 'default'\n\t\t\t\tORDER BY {$random}";
            $result = $this->db->sql_query_limit($sql, 1);
            $row = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            $word = generate_text_for_display($row['word'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
            $this->template->assign_vars(array('DID_YOU_KNOW' => str_replace("&quot;", '"', $word), 'S_DIDYOUKNOW' => !empty($this->user->data['user_didyouknow']) ? true : false, 'U_DYK_HIDE' => $this->helper->route('dmzx_didyouknow_controller', array('mode' => 'hide'))));
        }
    }
Exemple #12
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 #13
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;
    }
    /**
     * Display the settings page (only one so far)
     *
     * @return null
     * @access public
     */
    public function display_settings()
    {
        $sql = 'SELECT user_change, only_title FROM ' . $this->tables->get_table('settings');
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $active = $row['user_change'];
        $only_title = $row['only_title'];
        $this->db->sql_freeresult($result);
        $user_id = $this->user->data['user_id'];
        $username = $this->user->data['username'];
        // Get lastname and firstname from the phpbb_users or the extern table
        if (\kommodore\secondname\tables::$externTable == true) {
            $sql = 'SELECT ' . \kommodore\secondname\tables::$column['firstname'] . ' AS firstname, ' . \kommodore\secondname\tables::$column['lastname'] . ' AS lastname
						FROM ' . \kommodore\secondname\tables::$tableName . ' WHERE ' . \kommodore\secondname\tables::$externUsername . ' = "' . $this->db->sql_escape($username) . '"';
        } else {
            $sql = 'SELECT ' . \kommodore\secondname\tables::$column['firstname'] . ', ' . \kommodore\secondname\tables::$column['lastname'] . '
						FROM ' . USERS_TABLE . ' WHERE user_id = ' . (int) $user_id;
        }
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // Pass the second set of variables to the template
        $this->template->assign_vars(array('U_FIRSTNAME' => $row['firstname'], 'U_LASTNAME' => $row['lastname'], 'U_USERNAME' => $u_c, 'U_ONLY_TITLE' => $only_title == 1 ? false : true, 'S_ACTIVATED' => $active == 1 ? true : false, 'S_NOT_ACTIVATED' => $active == 0 ? true : false));
        // Get all titles from the database where the user is a member of the assigned group
        $sql = 'SELECT name, id FROM ' . $this->tables->get_table('titles') . ' INNER JOIN ' . USER_GROUP_TABLE . ' ON group_id = groups';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $this->template->assign_block_vars('title_block', array('NAME' => $row['name'], 'ID' => $row['id']));
        }
    }
Exemple #15
0
    /**
     * Creates a configuration container with a default set of values
     *
     * @param \phpbb\db\driver\driver_interface    $db    Database connection
     * @param \phpbb\cache\driver\driver_interface $cache Cache instance
     * @param string                       $table Configuration table name
     */
    public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, $table)
    {
        $this->db = $db;
        $this->cache = $cache;
        $this->table = $table;
        if (($config = $cache->get('config')) !== false) {
            $sql = 'SELECT config_name, config_value
				FROM ' . $this->table . '
				WHERE is_dynamic = 1';
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $config[$row['config_name']] = $row['config_value'];
            }
            $this->db->sql_freeresult($result);
        } else {
            $config = $cached_config = array();
            $sql = 'SELECT config_name, config_value, is_dynamic
				FROM ' . $this->table;
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                if (!$row['is_dynamic']) {
                    $cached_config[$row['config_name']] = $row['config_value'];
                }
                $config[$row['config_name']] = $row['config_value'];
            }
            $this->db->sql_freeresult($result);
            $cache->put('config', $cached_config);
        }
        parent::__construct($config);
    }
    /**
     * {@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 #17
0
 /**
  * Likes controller for route /like_post/{like}
  *
  * @param  int   @post_id  The post to be edited.
  */
 public function like_post($post_id)
 {
     // If unknown user or bot, cannot like.
     if ($this->user->data['user_id'] == ANONYMOUS || $this->user->data['is_bot']) {
         return;
     }
     // Add language variables for response.
     $this->user->add_lang_ext('nuleaf/likes', 'likes');
     // Grab forum id for permission.
     $sql = 'SELECT forum_id
 FROM ' . POSTS_TABLE . '
 WHERE post_id = ' . $post_id;
     $result = $this->db->sql_query_limit($sql, 1);
     $forum_id = $this->db->sql_fetchrow($result)['forum_id'];
     $this->db->sql_freeresult($result);
     // Does the user have permission to like posts in this forum?
     if ($this->auth->acl_get('!f_like', $forum_id)) {
         $json_response = new json_response();
         $json_response->send(array('error' => $this->user->lang('LIKE_NOT_AUTHORIZED')));
         return;
     }
     if ($this->request->is_ajax()) {
         $liked = $this->likes_manager->is_liked($post_id);
         if ($liked) {
             // If post is already liked, unlike it.
             $likes_count = $this->likes_manager->unlike($post_id);
         } else {
             // Else like the post.
             $likes_count = $this->likes_manager->like($post_id);
         }
         // Since the post has now been liked/unliked, $liked is reversed.
         $json_response = new json_response();
         $json_response->send(array('likes_count' => $likes_count, 'liked' => !$liked, 'LIKE_POST' => $this->user->lang('LIKE_POST'), 'UNLIKE_POST' => $this->user->lang('UNLIKE_POST'), 'LIKE_BUTTON' => $this->user->lang('LIKE_BUTTON'), 'UNLIKE_BUTTON' => $this->user->lang('UNLIKE_BUTTON')));
     }
 }
Exemple #18
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']));
     }
 }
    /**
     * Get module data from database
     *
     * @param int $module_id Module ID
     * @return array Module data array
     */
    public function get_module_data($module_id)
    {
        $sql = 'SELECT *
			FROM ' . PORTAL_MODULES_TABLE . '
			WHERE module_id = ' . (int) $module_id;
        $result = $this->db->sql_query_limit($sql, 1);
        $module_data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        return $module_data;
    }
Exemple #20
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;
    }
 /**
  * Find all the entities
  */
 public function find(array $condition = array())
 {
     $sql_where = $this->_get_condition($condition);
     $results = $this->db->sql_query($this->_find_sql($sql_where));
     $this->_collection->clear();
     while ($row = $this->db->sql_fetchrow($results)) {
         $this->_collection[$row[$this->_entity_pkey]] = $this->create_entity($row);
     }
     $this->db->sql_freeresult($results);
     return $this->_collection;
 }
    /**
     * 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);
    }
Exemple #23
0
    /**
     * {@inheritdoc}
     */
    public function get_template_side($module_id)
    {
        $sql = 'SELECT user_id, username, user_posts, user_colour
			FROM ' . USERS_TABLE . '
			WHERE user_type <> ' . USER_IGNORE . "\n\t\t\t\tAND user_posts <> 0\n\t\t\t\tAND username <> ''\n\t\t\tORDER BY user_posts DESC";
        $result = $this->db->sql_query_limit($sql, $this->config['board3_topposters_' . $module_id], 0, 600);
        while ($row = $this->db->sql_fetchrow($result)) {
            $this->template->assign_block_vars('topposters', array('S_SEARCH_ACTION' => append_sid("{$this->phpbb_root_path}search.{$this->php_ext}", 'author_id=' . $row['user_id'] . '&amp;sr=posts'), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'POSTER_POSTS' => $row['user_posts']));
        }
        $this->db->sql_freeresult($result);
        return 'topposters_side.html';
    }
    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 #25
0
    /**
     * Load the data from the database for this object
     *
     * @param int $id user identifier
     * @return NewsChannel $this object for chaining calls; load()->set()->save()
     * @access public
     * @throws \consim\core\exception\out_of_bounds
     */
    public function load($id)
    {
        $sql = 'SELECT channel_id, group_id, channel_name, vRefresh, background_color, color
			FROM ' . $this->consim_channel_table . '
			WHERE channel_id = ' . (int) $id;
        $result = $this->db->sql_query($sql);
        $this->data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($this->data === false) {
            throw new \consim\core\exception\out_of_bounds('id');
        }
        return $this;
    }
Exemple #26
0
    /**
     * Load the data from the database for this object
     *
     * @param int $id user identifier
     * @return Anniversary $this object for chaining calls; load()->set()->save()
     * @access public
     * @throws \consim\core\exception\out_of_bounds
     */
    public function load($id)
    {
        $sql = 'SELECT anniversary_id, day, month, year, event, link
			FROM ' . $this->consim_anniversary_table . '
			WHERE anniversary_id = ' . (int) $id;
        $result = $this->db->sql_query($sql);
        $this->data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($this->data === false) {
            throw new \consim\core\exception\out_of_bounds('id');
        }
        return $this;
    }
Exemple #27
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;
 }
Exemple #28
0
    /**
     * Load the data from the database for this object
     *
     * @param int $id user identifier
     * @return Weather $this object for chaining calls; load()->set()->save()
     * @access public
     * @throws \consim\core\exception\out_of_bounds
     */
    public function load($id)
    {
        $sql = 'SELECT prvnce_id, owm_id, last_updated, weather, weather_image, rain, temperature, wind_speed, wind_direction
			FROM ' . $this->consim_weather_table . '
			WHERE prvnce_id = ' . (int) $id;
        $result = $this->db->sql_query($sql);
        $this->data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($this->data === false) {
            throw new \consim\core\exception\out_of_bounds('id');
        }
        return $this;
    }
 /**
  * get members
  */
 public function get_list($get = array())
 {
     $this->settings = $get + array('query_type' => 'recent', 'date_range' => '', 'max_members' => 5);
     $sql = $this->get_sql_statement();
     $result = $this->db->sql_query_limit($sql, $this->settings['max_members']);
     $has_results = false;
     while ($row = $this->db->sql_fetchrow($result)) {
         $has_results = true;
         $this->ptemplate->assign_block_vars('member', call_user_func_array(array($this, $this->view_mode), array($row)));
     }
     $this->db->sql_freeresult($result);
     return $this->show_results($has_results);
 }
Exemple #30
0
    /**
     * Load the data from the database for this object
     *
     * @param int $id user identifier
     * @return News $this object for chaining calls; load()->set()->save()
     * @access public
     * @throws \consim\core\exception\out_of_bounds
     */
    public function load($id)
    {
        $sql = 'SELECT news_id, channel_id, content
			FROM ' . $this->consim_news_table . '
			WHERE news_id = ' . (int) $id;
        $result = $this->db->sql_query($sql);
        $this->data = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($this->data === false) {
            throw new \consim\core\exception\out_of_bounds('id');
        }
        return $this;
    }