本文整理汇总了PHP中phpbb\db\driver\driver_interface::sql_freeresult方法的典型用法代码示例。如果您正苦于以下问题:PHP driver_interface::sql_freeresult方法的具体用法?PHP driver_interface::sql_freeresult怎么用?PHP driver_interface::sql_freeresult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\db\driver\driver_interface
的用法示例。
在下文中一共展示了driver_interface::sql_freeresult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify_replies
/**
* 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;
}
示例2: run
/**
* {@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();
}
示例3: add_page_header_links
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)));
}
}
示例4: display_settings
/**
* 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']));
}
}
示例5: main
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();
}
示例6: index_modify_page_title
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']));
}
示例7: modify_posting
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;
}
}
}
示例8: like_post
/**
* 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')));
}
}
示例9: display_options
/**
* 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));
}
示例10: create_welcome_topic
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;
}
示例11: run
/**
* 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);
}
示例12: version
/**
* 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)));
}
示例13: __construct
/**
* 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);
}
示例14: get_bookmarks
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)));
}
示例15: page_header
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'))));
}
}