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