/** * 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; }
/** * {@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 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))); } }
/** * 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'])); } }
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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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']) . ' ' . $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(); }
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'])); }
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 ? ' ' : '') . $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; } } }
/** * 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'))); } }
/** * 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 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; }
/** * 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); }
/** * 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))); }
/** * 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); }
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))); }
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(""", '"', $word), 'S_DIDYOUKNOW' => !empty($this->user->data['user_didyouknow']) ? true : false, 'U_DYK_HIDE' => $this->helper->route('dmzx_didyouknow_controller', array('mode' => 'hide')))); } }
/** * 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); }
/** * {@inheritdoc} */ protected function get_records_by_range($min_id, $max_id) { $sql = $this->get_records_by_range_query($min_id, $max_id); $result = $this->db->sql_query($sql); $records = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $records; }
/** * {@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; }
/** * 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; }
/** * Get number of groups, displayed on the legend * * @return int value of the last item displayed */ public function get_group_count() { $sql = 'SELECT group_legend FROM ' . GROUPS_TABLE . ' ORDER BY group_legend DESC'; $result = $this->db->sql_query_limit($sql, 1); $group_count = (int) $this->db->sql_fetchfield('group_legend'); $this->db->sql_freeresult($result); return $group_count; }
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)); }
/** * 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; }
/** * Get batch. * * @return array */ protected function get_batch() { $sql = 'SELECT DISTINCT topic_id, post_user_id FROM ' . $this->posts_table . ' WHERE post_approved = 1 AND post_deleted = 0'; $result = $this->db->sql_query_limit($sql, $this->limit, $this->start); $rows = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $rows; }
/** * 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); }
/** * {@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'] . '&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'; }
/** * {@inheritdoc} */ protected function get_records_by_range($min_id, $max_id) { $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE o.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id . ' AND t.topic_id = o.topic_id AND p.post_id = t.topic_first_post_id'; $result = $this->db->sql_query($sql); $records = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); return $records; }
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&form=select_user&field=username&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)); } } }
/** * Executes the command thumbnail:generate. * * Generate a thumbnail for all attachments which need one and don't have it yet. * * @param InputInterface $input The input stream used to get the argument and verboe option. * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. * * @return int 0. */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->section($this->user->lang('CLI_THUMBNAIL_GENERATING')); $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 0'; $result = $this->db->sql_query($sql); $nb_missing_thumbnails = (int) $this->db->sql_fetchfield('nb_missing_thumbnails'); $this->db->sql_freeresult($result); if ($nb_missing_thumbnails === 0) { $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE')); return 0; } $extensions = $this->cache->obtain_attach_extensions(true); $sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 0'; $result = $this->db->sql_query($sql); if (!function_exists('create_thumbnail')) { require $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext; } $progress = $this->create_progress_bar($nb_missing_thumbnails, $io, $output); $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATING')); $progress->start(); $thumbnail_created = array(); while ($row = $this->db->sql_fetchrow($result)) { if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE) { $source = $this->phpbb_root_path . 'files/' . $row['physical_filename']; $destination = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename']; if (create_thumbnail($source, $destination, $row['mimetype'])) { $thumbnail_created[] = (int) $row['attach_id']; if (count($thumbnail_created) === 250) { $this->commit_changes($thumbnail_created); $thumbnail_created = array(); } $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename'])); } else { $progress->setMessage('<info>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</info>'); } } $progress->advance(); } $this->db->sql_freeresult($result); if (!empty($thumbnail_created)) { $this->commit_changes($thumbnail_created); } $progress->finish(); $io->newLine(2); $io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE')); return 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; }