当前位置: 首页>>代码示例>>PHP>>正文


PHP delete_attachments函数代码示例

本文整理汇总了PHP中delete_attachments函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_attachments函数的具体用法?PHP delete_attachments怎么用?PHP delete_attachments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delete_attachments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: uninstall

 /**
  * Standard modular uninstall function.
  */
 function uninstall()
 {
     $GLOBALS['SITE_DB']->drop_if_exists('comcode_pages');
     $GLOBALS['SITE_DB']->drop_if_exists('cached_comcode_pages');
     delete_config_option('store_revisions');
     delete_config_option('number_revisions_show');
     delete_config_option('points_COMCODE_PAGE_ADD');
     /*$zones=find_all_zones(true);
     		$langs=find_all_langs(true);
     		foreach ($zones as $zone)
     		{
     			foreach (array_keys($langs) as $lang)
     			{
     				deldir_contents(zone_black_magic_filterer(get_custom_file_base().(($zone=='')?'':'/').$zone.'/pages/comcode_custom/'.$lang,true),true);
     			}
     		}*/
     delete_attachments('comcode_page');
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:21,代码来源:cms_comcode_pages.php

示例2: uninstall

 /**
  * Standard modular uninstall function.
  */
 function uninstall()
 {
     $GLOBALS['SITE_DB']->drop_if_exists('news');
     $GLOBALS['SITE_DB']->drop_if_exists('news_categories');
     $GLOBALS['SITE_DB']->drop_if_exists('news_rss_cloud');
     $GLOBALS['SITE_DB']->drop_if_exists('news_category_entries');
     $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'news'));
     $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'news'));
     $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'news'));
     delete_attachments('news');
     delete_config_option('points_ADD_NEWS');
     delete_config_option('news_update_time');
     delete_config_option('blog_update_time');
     delete_config_option('ping_url');
     delete_config_option('news_show_stats_count_total_posts');
     delete_config_option('news_show_stats_count_blogs');
     delete_menu_item_simple('_SEARCH:cms_news:type=ad');
 }
开发者ID:erico-deh,项目名称:ocPortal,代码行数:21,代码来源:news.php

示例3: delete_forum_content

    /**
     * Delete forum content
     */
    function delete_forum_content($forum_id)
    {
        global $db, $config, $phpbb_root_path, $phpEx;
        include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
        $db->sql_transaction('begin');
        // Select then delete all attachments
        $sql = 'SELECT a.topic_id
			FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a\n\t\t\tWHERE p.forum_id = {$forum_id}\n\t\t\t\tAND a.in_message = 0\n\t\t\t\tAND a.topic_id = p.topic_id";
        $result = $db->sql_query($sql);
        $topic_ids = array();
        while ($row = $db->sql_fetchrow($result)) {
            $topic_ids[] = $row['topic_id'];
        }
        $db->sql_freeresult($result);
        delete_attachments('topic', $topic_ids, false);
        // Delete shadow topics pointing to topics in this forum
        delete_topic_shadows($forum_id);
        // Before we remove anything we make sure we are able to adjust the post counts later. ;)
        $sql = 'SELECT poster_id
			FROM ' . POSTS_TABLE . '
			WHERE forum_id = ' . $forum_id . '
				AND post_postcount = 1
				AND post_approved = 1';
        $result = $db->sql_query($sql);
        $post_counts = array();
        while ($row = $db->sql_fetchrow($result)) {
            $post_counts[$row['poster_id']] = !empty($post_counts[$row['poster_id']]) ? $post_counts[$row['poster_id']] + 1 : 1;
        }
        $db->sql_freeresult($result);
        switch ($db->sql_layer) {
            case 'mysql4':
            case 'mysqli':
                // Delete everything else and thank MySQL for offering multi-table deletion
                $tables_ary = array(SEARCH_WORDMATCH_TABLE => 'post_id', REPORTS_TABLE => 'post_id', WARNINGS_TABLE => 'post_id', BOOKMARKS_TABLE => 'topic_id', TOPICS_WATCH_TABLE => 'topic_id', TOPICS_POSTED_TABLE => 'topic_id', POLL_OPTIONS_TABLE => 'topic_id', POLL_VOTES_TABLE => 'topic_id');
                $sql = 'DELETE ' . POSTS_TABLE;
                $sql_using = "\nFROM " . POSTS_TABLE;
                $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = {$forum_id}\n";
                foreach ($tables_ary as $table => $field) {
                    $sql .= ", {$table} ";
                    $sql_using .= ", {$table} ";
                    $sql_where .= "\nAND {$table}.{$field} = " . POSTS_TABLE . ".{$field}";
                }
                $db->sql_query($sql . $sql_using . $sql_where);
                break;
            default:
                // Delete everything else and curse your DB for not offering multi-table deletion
                $tables_ary = array('post_id' => array(SEARCH_WORDMATCH_TABLE, REPORTS_TABLE, WARNINGS_TABLE), 'topic_id' => array(BOOKMARKS_TABLE, TOPICS_WATCH_TABLE, TOPICS_POSTED_TABLE, POLL_OPTIONS_TABLE, POLL_VOTES_TABLE));
                // Amount of rows we select and delete in one iteration.
                $batch_size = 500;
                foreach ($tables_ary as $field => $tables) {
                    $start = 0;
                    do {
                        $sql = "SELECT {$field}\n\t\t\t\t\t\t\tFROM " . POSTS_TABLE . '
							WHERE forum_id = ' . $forum_id;
                        $result = $db->sql_query_limit($sql, $batch_size, $start);
                        $ids = array();
                        while ($row = $db->sql_fetchrow($result)) {
                            $ids[] = $row[$field];
                        }
                        $db->sql_freeresult($result);
                        if (sizeof($ids)) {
                            $start += sizeof($ids);
                            foreach ($tables as $table) {
                                $db->sql_query("DELETE FROM {$table} WHERE " . $db->sql_in_set($field, $ids));
                            }
                        }
                    } while (sizeof($ids) == $batch_size);
                }
                unset($ids);
                break;
        }
        $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE);
        foreach ($table_ary as $table) {
            $db->sql_query("DELETE FROM {$table} WHERE forum_id = {$forum_id}");
        }
        // Set forum ids to 0
        $table_ary = array(DRAFTS_TABLE);
        foreach ($table_ary as $table) {
            $db->sql_query("UPDATE {$table} SET forum_id = 0 WHERE forum_id = {$forum_id}");
        }
        // Adjust users post counts
        if (sizeof($post_counts)) {
            foreach ($post_counts as $poster_id => $substract) {
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_posts = 0
					WHERE user_id = ' . $poster_id . '
					AND user_posts < ' . $substract;
                $db->sql_query($sql);
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_posts = user_posts - ' . $substract . '
					WHERE user_id = ' . $poster_id . '
					AND user_posts >= ' . $substract;
                $db->sql_query($sql);
            }
        }
        $db->sql_transaction('commit');
        // Make sure the overall post/topic count is correct...
//.........这里部分代码省略.........
开发者ID:PetsFundation,项目名称:Pets,代码行数:101,代码来源:acp_forums.php

示例4: delete_posts


//.........这里部分代码省略.........
    }
    $db->sql_transaction('begin');
    $table_ary = array(POSTS_TABLE, REPORTS_TABLE);
    foreach ($table_ary as $table) {
        $sql = "DELETE FROM {$table}\n\t\t\tWHERE " . $db->sql_in_set('post_id', $post_ids);
        $db->sql_query($sql);
    }
    unset($table_ary);
    // Adjust users post counts
    if (sizeof($post_counts) && $post_count_sync) {
        foreach ($post_counts as $poster_id => $substract) {
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET user_posts = 0
				WHERE user_id = ' . $poster_id . '
				AND user_posts < ' . $substract;
            $db->sql_query($sql);
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET user_posts = user_posts - ' . $substract . '
				WHERE user_id = ' . $poster_id . '
				AND user_posts >= ' . $substract;
            $db->sql_query($sql);
        }
    }
    // Remove topics now having no posts?
    if (sizeof($topic_ids)) {
        $sql = 'SELECT topic_id
			FROM ' . POSTS_TABLE . '
			WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
			GROUP BY topic_id';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $remove_topics[] = $row['topic_id'];
        }
        $db->sql_freeresult($result);
        // Actually, those not within remove_topics should be removed. ;)
        $remove_topics = array_diff($topic_ids, $remove_topics);
    }
    // Remove the message from the search index
    $search_type = $config['search_type'];
    if (!class_exists($search_type)) {
        trigger_error('NO_SUCH_SEARCH_MODULE');
    }
    $error = false;
    $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
    if ($error) {
        trigger_error($error);
    }
    $search->index_remove($post_ids, $poster_ids, $forum_ids);
    delete_attachments('post', $post_ids, false);
    /**
     * Perform additional actions during post(s) deletion
     *
     * @event core.delete_posts_in_transaction
     * @var	array	post_ids					Array with deleted posts' ids
     * @var	array	poster_ids					Array with deleted posts' author ids
     * @var	array	topic_ids					Array with deleted posts' topic ids
     * @var	array	forum_ids					Array with deleted posts' forum ids
     * @var	string	where_type					Variable containing posts deletion mode
     * @var	mixed	where_ids					Array or comma separated list of posts ids to delete
     * @var	array	delete_notifications_types	Array with notifications types to delete
     * @since 3.1.0-a4
     */
    $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type', 'where_ids', 'delete_notifications_types');
    extract($phpbb_dispatcher->trigger_event('core.delete_posts_in_transaction', compact($vars)));
    $db->sql_transaction('commit');
    /**
     * Perform additional actions after post(s) deletion
     *
     * @event core.delete_posts_after
     * @var	array	post_ids					Array with deleted posts' ids
     * @var	array	poster_ids					Array with deleted posts' author ids
     * @var	array	topic_ids					Array with deleted posts' topic ids
     * @var	array	forum_ids					Array with deleted posts' forum ids
     * @var	string	where_type					Variable containing posts deletion mode
     * @var	mixed	where_ids					Array or comma separated list of posts ids to delete
     * @var	array	delete_notifications_types	Array with notifications types to delete
     * @since 3.1.0-a4
     */
    $vars = array('post_ids', 'poster_ids', 'topic_ids', 'forum_ids', 'where_type', 'where_ids', 'delete_notifications_types');
    extract($phpbb_dispatcher->trigger_event('core.delete_posts_after', compact($vars)));
    // Resync topics_posted table
    if ($posted_sync) {
        update_posted_info($topic_ids);
    }
    if ($auto_sync) {
        sync('topic_reported', 'topic_id', $topic_ids);
        sync('topic', 'topic_id', $topic_ids, true);
        sync('forum', 'forum_id', $forum_ids, true, true);
    }
    if ($approved_posts && $post_count_sync) {
        set_config_count('num_posts', $approved_posts * -1, true);
    }
    // We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
    if (sizeof($remove_topics) && $call_delete_topics) {
        delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false);
    }
    $phpbb_notifications = $phpbb_container->get('notification_manager');
    $phpbb_notifications->delete_notifications($delete_notifications_types, $post_ids);
    return sizeof($post_ids);
}
开发者ID:mike-a-b,项目名称:crossfit,代码行数:101,代码来源:functions_admin.php

示例5: delete

 function delete()
 {
     delete_attachments('attach', $this->attach_id);
 }
开发者ID:gn36,项目名称:phpbb-oo-posting-api,代码行数:4,代码来源:functions_post_oo.php

示例6: delete_posts

function delete_posts($where_type, $where_ids, $auto_sync = true)
{
    global $_CLASS;
    if (is_array($where_ids)) {
        $where_ids = array_unique($where_ids);
    }
    if (empty($where_ids)) {
        return false;
    }
    $post_ids = $topic_ids = $forum_ids = $post_counts = array();
    $sql = 'SELECT post_id, poster_id, post_postcount, topic_id, forum_id
		FROM ' . FORUMS_POSTS_TABLE . "\n\t\tWHERE {$where_type} " . (!is_array($where_ids) ? "= {$where_ids}" : 'IN (' . implode(', ', $where_ids) . ')');
    $result = $_CLASS['core_db']->query($sql);
    while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
        $post_ids[] = $row['post_id'];
        $poster_ids[] = $row['poster_id'];
        $topic_ids[] = $row['topic_id'];
        $forum_ids[] = $row['forum_id'];
        if ($row['post_postcount']) {
            $post_counts[$row['poster_id']] = !empty($post_counts[$row['poster_id']]) ? $post_counts[$row['poster_id']] + 1 : 1;
        }
    }
    $_CLASS['core_db']->free_result();
    if (empty($post_ids)) {
        return false;
    }
    $sql_where = implode(', ', $post_ids);
    $_CLASS['core_db']->transaction();
    $table_ary = array(FORUMS_POSTS_TABLE, FORUMS_REPORTS_TABLE);
    foreach ($table_ary as $table) {
        $sql = "DELETE FROM {$table} \n\t\t\tWHERE post_id IN ({$sql_where})";
        $_CLASS['core_db']->query($sql);
    }
    unset($table_ary);
    // Adjust users post counts
    if (!empty($post_counts)) {
        foreach ($post_counts as $poster_id => $substract) {
            $sql = 'UPDATE ' . CORE_USERS_TABLE . '
				SET user_posts = user_posts - ' . $substract . '
				WHERE user_id = ' . $poster_id;
            $_CLASS['core_db']->query($sql);
        }
    }
    // Remove the message from the search index
    $search_type = basename($config['search_type']);
    if (!file_exists(SITE_FILE_ROOT . 'includes/forums/search/', $search_type, '.php')) {
        trigger_error('NO_SUCH_SEARCH_MODULE');
    }
    require_once SITE_FILE_ROOT . 'includes/forums/search/' . $search_type . '.php';
    $error = false;
    $search = new $search_type($error);
    if ($error) {
        trigger_error($error);
    }
    $search->index_remove($post_ids, $poster_ids, $forum_ids);
    delete_attachments('post', $post_ids, false);
    $_CLASS['core_db']->transaction('commit');
    // Resync topics_posted table
    if ($posted_sync) {
        update_posted_info($topic_ids);
    }
    if ($auto_sync) {
        sync('topic_reported', $where_type, $where_ids);
        sync('topic', 'topic_id', $topic_ids, true);
        sync('forum', 'forum_id', $forum_ids, true);
    }
    set_config('num_posts', $config['num_posts'] - sizeof($post_ids), true);
    return count($post_ids);
}
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:69,代码来源:functions_admin.php

示例7: delete_pm

/**
* Delete PM(s)
*/
function delete_pm($user_id, $msg_ids, $folder_id)
{
    global $db, $user, $phpbb_root_path, $phpEx;
    $user_id = (int) $user_id;
    $folder_id = (int) $folder_id;
    if (!$user_id) {
        return false;
    }
    if (!is_array($msg_ids)) {
        if (!$msg_ids) {
            return false;
        }
        $msg_ids = array($msg_ids);
    }
    if (!sizeof($msg_ids)) {
        return false;
    }
    // Get PM Information for later deleting
    $sql = 'SELECT msg_id, pm_unread, pm_new
		FROM ' . PRIVMSGS_TO_TABLE . '
		WHERE ' . $db->sql_in_set('msg_id', array_map('intval', $msg_ids)) . "\n\t\t\tAND folder_id = {$folder_id}\n\t\t\tAND user_id = {$user_id}";
    $result = $db->sql_query($sql);
    $delete_rows = array();
    $num_unread = $num_new = $num_deleted = 0;
    while ($row = $db->sql_fetchrow($result)) {
        $num_unread += (int) $row['pm_unread'];
        $num_new += (int) $row['pm_new'];
        $delete_rows[$row['msg_id']] = 1;
    }
    $db->sql_freeresult($result);
    unset($msg_ids);
    if (!sizeof($delete_rows)) {
        return false;
    }
    $db->sql_transaction('begin');
    // if no one has read the message yet (meaning it is in users outbox)
    // then mark the message as deleted...
    if ($folder_id == PRIVMSGS_OUTBOX) {
        // Remove PM from Outbox
        $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "\n\t\t\tWHERE user_id = {$user_id} AND folder_id = " . PRIVMSGS_OUTBOX . '
				AND ' . $db->sql_in_set('msg_id', array_keys($delete_rows));
        $db->sql_query($sql);
        // Update PM Information for safety
        $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = ''\n\t\t\tWHERE " . $db->sql_in_set('msg_id', array_keys($delete_rows));
        $db->sql_query($sql);
        // Set delete flag for those intended to receive the PM
        // We do not remove the message actually, to retain some basic information (sent time for example)
        $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
			SET pm_deleted = 1
			WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows));
        $db->sql_query($sql);
        $num_deleted = $db->sql_affectedrows();
    } else {
        // Delete private message data
        $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "\n\t\t\tWHERE user_id = {$user_id}\n\t\t\t\tAND folder_id = {$folder_id}\n\t\t\t\tAND " . $db->sql_in_set('msg_id', array_keys($delete_rows));
        $db->sql_query($sql);
        $num_deleted = $db->sql_affectedrows();
    }
    // if folder id is user defined folder then decrease pm_count
    if (!in_array($folder_id, array(PRIVMSGS_INBOX, PRIVMSGS_OUTBOX, PRIVMSGS_SENTBOX, PRIVMSGS_NO_BOX))) {
        $sql = 'UPDATE ' . PRIVMSGS_FOLDER_TABLE . "\n\t\t\tSET pm_count = pm_count - {$num_deleted}\n\t\t\tWHERE folder_id = {$folder_id}";
        $db->sql_query($sql);
    }
    // Update unread and new status field
    if ($num_unread || $num_new) {
        $set_sql = $num_unread ? 'user_unread_privmsg = user_unread_privmsg - ' . $num_unread : '';
        if ($num_new) {
            $set_sql .= $set_sql != '' ? ', ' : '';
            $set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new;
        }
        $db->sql_query('UPDATE ' . USERS_TABLE . " SET {$set_sql} WHERE user_id = {$user_id}");
        $user->data['user_new_privmsg'] -= $num_new;
        $user->data['user_unread_privmsg'] -= $num_unread;
    }
    // Now we have to check which messages we can delete completely
    $sql = 'SELECT msg_id
		FROM ' . PRIVMSGS_TO_TABLE . '
		WHERE ' . $db->sql_in_set('msg_id', array_keys($delete_rows));
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        unset($delete_rows[$row['msg_id']]);
    }
    $db->sql_freeresult($result);
    $delete_ids = array_keys($delete_rows);
    if (sizeof($delete_ids)) {
        // Check if there are any attachments we need to remove
        if (!function_exists('delete_attachments')) {
            include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
        }
        delete_attachments('message', $delete_ids, false);
        $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
			WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
        $db->sql_query($sql);
    }
    $db->sql_transaction('commit');
    return true;
}
开发者ID:jvinhit,项目名称:php,代码行数:100,代码来源:functions_privmsgs.php

示例8: main


//.........这里部分代码省略.........
                                $topic_id_ary = array();
                                while ($row = $db->sql_fetchrow($result)) {
                                    $topic_id_ary[$row['topic_id']] = $row['total_posts'];
                                }
                                $db->sql_freeresult($result);
                                if (sizeof($topic_id_ary)) {
                                    $sql = 'SELECT topic_id, topic_replies, topic_replies_real
										FROM ' . TOPICS_TABLE . '
										WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')';
                                    $result = $db->sql_query($sql);
                                    $del_topic_ary = array();
                                    while ($row = $db->sql_fetchrow($result)) {
                                        if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) {
                                            $del_topic_ary[] = $row['topic_id'];
                                        }
                                    }
                                    $db->sql_freeresult($result);
                                    if (sizeof($del_topic_ary)) {
                                        $sql = 'DELETE FROM ' . TOPICS_TABLE . '
											WHERE topic_id IN (' . implode(', ', $del_topic_ary) . ')';
                                        $db->sql_query($sql);
                                    }
                                }
                                // Delete posts, attachments, etc.
                                delete_posts('poster_id', $user_id);
                                add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']);
                                trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            } else {
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
                            }
                            break;
                        case 'delattach':
                            if (confirm_box(true)) {
                                delete_attachments('user', $user_id);
                                add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']);
                                trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            } else {
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
                            }
                            break;
                        case 'moveposts':
                            $new_forum_id = request_var('new_f', 0);
                            if (!$new_forum_id) {
                                $this->page_title = 'USER_ADMIN_MOVE_POSTS';
                                $template->assign_vars(array('S_SELECT_FORUM' => true, 'U_ACTION' => $this->u_action . "&amp;action={$action}&amp;u={$user_id}", 'U_BACK' => $this->u_action . "&amp;u={$user_id}", 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true)));
                                return;
                            }
                            // Two stage?
                            // Move topics comprising only posts from this user
                            $topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array();
                            $forum_id_ary = array($new_forum_id);
                            $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
								FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP BY topic_id";
                            $result = $db->sql_query($sql);
                            while ($row = $db->sql_fetchrow($result)) {
                                $topic_id_ary[$row['topic_id']] = $row['total_posts'];
                            }
                            $db->sql_freeresult($result);
                            if (sizeof($topic_id_ary)) {
                                $sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_replies_real
									FROM ' . TOPICS_TABLE . '
									WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')';
                                $result = $db->sql_query($sql);
                                while ($row = $db->sql_fetchrow($result)) {
                                    if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) {
                                        $move_topic_ary[] = $row['topic_id'];
开发者ID:yunsite,项目名称:gloryroad,代码行数:67,代码来源:acp_users.php

示例9: main

    function main($id, $mode)
    {
        global $template, $user, $db, $config, $phpEx, $phpbb_root_path;
        $start = request_var('start', 0);
        $sort_key = request_var('sk', 'a');
        $sort_dir = request_var('sd', 'a');
        $delete = isset($_POST['delete']) ? true : false;
        $confirm = isset($_POST['confirm']) ? true : false;
        $delete_ids = array_keys(request_var('attachment', array(0)));
        if ($delete && sizeof($delete_ids)) {
            // Validate $delete_ids...
            $sql = 'SELECT attach_id
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE poster_id = ' . $user->data['user_id'] . '
					AND is_orphan = 0
					AND ' . $db->sql_in_set('attach_id', $delete_ids);
            $result = $db->sql_query($sql);
            $delete_ids = array();
            while ($row = $db->sql_fetchrow($result)) {
                $delete_ids[] = $row['attach_id'];
            }
            $db->sql_freeresult($result);
        }
        if ($delete && sizeof($delete_ids)) {
            $s_hidden_fields = array('delete' => 1);
            foreach ($delete_ids as $attachment_id) {
                $s_hidden_fields['attachment'][$attachment_id] = 1;
            }
            if (confirm_box(true)) {
                if (!function_exists('delete_attachments')) {
                    include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
                }
                delete_attachments('attach', $delete_ids);
                meta_refresh(3, $this->u_action);
                $message = (sizeof($delete_ids) == 1 ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
                trigger_error($message);
            } else {
                confirm_box(false, sizeof($delete_ids) == 1 ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS', build_hidden_fields($s_hidden_fields));
            }
        }
        // Select box eventually
        $sort_key_text = array('a' => $user->lang['SORT_FILENAME'], 'b' => $user->lang['SORT_COMMENT'], 'c' => $user->lang['SORT_EXTENSION'], 'd' => $user->lang['SORT_SIZE'], 'e' => $user->lang['SORT_DOWNLOADS'], 'f' => $user->lang['SORT_POST_TIME'], 'g' => $user->lang['SORT_TOPIC_TITLE']);
        $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.attach_comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
        $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);
        $s_sort_key = '';
        foreach ($sort_key_text as $key => $value) {
            $selected = $sort_key == $key ? ' selected="selected"' : '';
            $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        $s_sort_dir = '';
        foreach ($sort_dir_text as $key => $value) {
            $selected = $sort_dir == $key ? ' selected="selected"' : '';
            $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        if (!isset($sort_key_sql[$sort_key])) {
            $sort_key = 'a';
        }
        $order_by = $sort_key_sql[$sort_key] . ' ' . ($sort_dir == 'a' ? 'ASC' : 'DESC');
        $sql = 'SELECT COUNT(attach_id) as num_attachments
			FROM ' . ATTACHMENTS_TABLE . '
			WHERE poster_id = ' . $user->data['user_id'] . '
				AND is_orphan = 0';
        $result = $db->sql_query($sql);
        $num_attachments = $db->sql_fetchfield('num_attachments');
        $db->sql_freeresult($result);
        $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
			FROM ' . ATTACHMENTS_TABLE . ' a
				LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
				LEFT JOIN ' . PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id AND a.in_message = 1)
			WHERE a.poster_id = ' . $user->data['user_id'] . "\n\t\t\t\tAND a.is_orphan = 0\n\t\t\tORDER BY {$order_by}";
        $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
        $row_count = 0;
        if ($row = $db->sql_fetchrow($result)) {
            $template->assign_var('S_ATTACHMENT_ROWS', true);
            do {
                if ($row['in_message']) {
                    $view_topic = append_sid("{$phpbb_root_path}ucp.{$phpEx}", "i=pm&amp;p={$row['post_msg_id']}");
                } else {
                    $view_topic = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "t={$row['topic_id']}&amp;p={$row['post_msg_id']}") . "#p{$row['post_msg_id']}";
                }
                $template->assign_block_vars('attachrow', array('ROW_NUMBER' => $row_count + ($start + 1), 'FILENAME' => $row['real_filename'], 'COMMENT' => bbcode_nl2br($row['attach_comment']), 'EXTENSION' => $row['extension'], 'SIZE' => get_formatted_filesize($row['filesize']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $user->format_date($row['filetime']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_VIEW_ATTACHMENT' => append_sid("{$phpbb_root_path}download/file.{$phpEx}", 'id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic));
                $row_count++;
            } while ($row = $db->sql_fetchrow($result));
        }
        $db->sql_freeresult($result);
        $template->assign_vars(array('PAGE_NUMBER' => on_page($num_attachments, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&amp;sk={$sort_key}&amp;sd={$sort_dir}", $num_attachments, $config['topics_per_page'], $start), 'TOTAL_ATTACHMENTS' => $num_attachments, 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], 'U_SORT_FILENAME' => $this->u_action . "&amp;sk=a&amp;sd=" . ($sort_key == 'a' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_FILE_COMMENT' => $this->u_action . "&amp;sk=b&amp;sd=" . ($sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_EXTENSION' => $this->u_action . "&amp;sk=c&amp;sd=" . ($sort_key == 'c' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_FILESIZE' => $this->u_action . "&amp;sk=d&amp;sd=" . ($sort_key == 'd' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_DOWNLOADS' => $this->u_action . "&amp;sk=e&amp;sd=" . ($sort_key == 'e' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_POST_TIME' => $this->u_action . "&amp;sk=f&amp;sd=" . ($sort_key == 'f' && $sort_dir == 'a' ? 'd' : 'a'), 'U_SORT_TOPIC_TITLE' => $this->u_action . "&amp;sk=g&amp;sd=" . ($sort_key == 'g' && $sort_dir == 'a' ? 'd' : 'a'), 'S_DISPLAY_MARK_ALL' => $num_attachments ? true : false, 'S_DISPLAY_PAGINATION' => $num_attachments ? true : false, 'S_UCP_ACTION' => $this->u_action, 'S_SORT_OPTIONS' => $s_sort_key, 'S_ORDER_SELECT' => $s_sort_dir));
        $this->tpl_name = 'ucp_attachments';
        $this->page_title = 'UCP_ATTACHMENTS';
    }
开发者ID:ahmatjan,项目名称:Crimson,代码行数:89,代码来源:ucp_attachments.php

示例10: ucp_attachments

    function ucp_attachments($id, $mode)
    {
        global $_CLASS, $config, $site_file_root;
        $start = request_var('start', 0);
        $delete = isset($_POST['delete']) ? true : false;
        $confirm = isset($_POST['confirm']) ? true : false;
        $delete_ids = isset($_REQUEST['attachment']) ? array_keys(array_map('intval', $_REQUEST['attachment'])) : array();
        if ($delete && sizeof($delete_ids)) {
            $s_hidden_fields = '<input type="hidden" name="delete" value="1" />';
            foreach ($delete_ids as $attachment_id) {
                $s_hidden_fields .= '<input type="hidden" name="attachment[' . $attachment_id . ']" value="1" />';
            }
            if (display_confirmation($_CLASS['core_user']->get_lang(count($delete_ids) == 1 ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS'), $s_hidden_fields)) {
                require $site_file_root . 'includes/forums/functions_admin.php';
                delete_attachments('attach', $delete_ids);
                $refresh_url = generate_link('Control_Panel&amp;i=' . $id);
                $_CLASS['core_display']->meta_refresh(3, $refresh_url);
                $message = (sizeof($delete_ids) == 1 ? $_CLASS['core_user']->lang['ATTACHMENT_DELETED'] : $_CLASS['core_user']->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_UCP'], '<a href="' . $refresh_url . '">', '</a>');
                trigger_error($message);
            }
        }
        $sort_key = request_var('sk', 'a');
        $sort_dir = request_var('sd', 'a');
        // Select box eventually
        $sort_key_text = array('a' => $_CLASS['core_user']->lang['SORT_FILENAME'], 'b' => $_CLASS['core_user']->lang['SORT_COMMENT'], 'c' => $_CLASS['core_user']->lang['SORT_EXTENSION'], 'd' => $_CLASS['core_user']->lang['SORT_SIZE'], 'e' => $_CLASS['core_user']->lang['SORT_DOWNLOADS'], 'f' => $_CLASS['core_user']->lang['SORT_POST_TIME'], 'g' => $_CLASS['core_user']->lang['SORT_TOPIC_TITLE']);
        $sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
        $sort_dir_text = array('a' => $_CLASS['core_user']->lang['ASCENDING'], 'd' => $_CLASS['core_user']->lang['DESCENDING']);
        $s_sort_key = '';
        foreach ($sort_key_text as $key => $value) {
            $selected = $sort_key == $key ? ' selected="selected"' : '';
            $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        $s_sort_dir = '';
        foreach ($sort_dir_text as $key => $value) {
            $selected = $sort_dir == $key ? ' selected="selected"' : '';
            $s_sort_dir .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
        }
        $order_by = $sort_key_sql[$sort_key] . '  ' . ($sort_dir == 'a' ? 'ASC' : 'DESC');
        $sql = 'SELECT COUNT(*) as num_attachments
			FROM ' . FORUMS_ATTACHMENTS_TABLE . '
			WHERE poster_id = ' . $_CLASS['core_user']->data['user_id'];
        $result = $_CLASS['core_db']->query_limit($sql, 1);
        list($num_attachments) = $_CLASS['core_db']->fetch_row_num($result);
        $_CLASS['core_db']->free_result($result);
        $sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
			FROM ' . FORUMS_ATTACHMENTS_TABLE . ' a 
				LEFT JOIN ' . FORUMS_TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id
					AND a.in_message = 0)
				LEFT JOIN ' . FORUMS_PRIVMSGS_TABLE . ' p ON (a.post_msg_id = p.msg_id
					AND a.in_message = 1)
			WHERE a.poster_id = ' . $_CLASS['core_user']->data['user_id'] . "\n\t\t\tORDER BY {$order_by}";
        $result = $_CLASS['core_db']->query_limit($sql, $config['posts_per_page'], $start);
        $row_count = 0;
        if ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
            $_CLASS['core_template']->assign('S_ATTACHMENT_ROWS', true);
            do {
                if ($row['in_message']) {
                    $view_topic = generate_link('Control_Panel&amp;i=pm&amp;p=' . $row['post_msg_id']);
                } else {
                    $view_topic = generate_link("Forums&amp;file=viewtopic&amp;t={$row['topic_id']}&amp;p={$row['post_msg_id']}#{$row['post_msg_id']}");
                }
                $_CLASS['core_template']->assign_vars_array('attachrow', array('ROW_NUMBER' => $row_count + ($start + 1), 'FILENAME' => $row['real_filename'], 'COMMENT' => str_replace("\n", '<br />', $row['comment']), 'EXTENSION' => $row['extension'], 'SIZE' => $row['filesize'] >= 1048576 ? ($row['filesize'] >> 20) . ' ' . $_CLASS['core_user']->lang['MB'] : ($row['filesize'] >= 1024 ? ($row['filesize'] >> 10) . ' ' . $_CLASS['core_user']->lang['KB'] : $row['filesize'] . ' ' . $_CLASS['core_user']->lang['BYTES']), 'DOWNLOAD_COUNT' => $row['download_count'], 'POST_TIME' => $_CLASS['core_user']->format_date($row['filetime'], $_CLASS['core_user']->lang['DATE_FORMAT']), 'TOPIC_TITLE' => $row['in_message'] ? $row['message_title'] : $row['topic_title'], 'ATTACH_ID' => $row['attach_id'], 'POST_ID' => $row['post_msg_id'], 'TOPIC_ID' => $row['topic_id'], 'S_IN_MESSAGE' => $row['in_message'], 'U_VIEW_ATTACHMENT' => generate_link('Forums&amp;file=download&amp;id=' . $row['attach_id']), 'U_VIEW_TOPIC' => $view_topic));
                $row_count++;
            } while ($row = $_CLASS['core_db']->fetch_row_assoc($result));
        }
        $_CLASS['core_db']->free_result($result);
        $_CLASS['core_template']->assign(array('PAGE_NUMBER' => on_page($num_attachments, $config['posts_per_page'], $start), 'PAGINATION' => generate_pagination("Control_Panel&amp;i={$id}&amp;sk={$sort_key}&amp;sd={$sort_dir}", $num_attachments, $config['posts_per_page'], $start), 'TOTAL_ATTACHMENTS' => $num_attachments, 'U_SORT_FILENAME' => generate_link("Control_Panel&amp;i={$id}&amp;sk=a&amp;sd=" . ($sort_key == 'a' && $sort_dir == 'a' ? 'd' : 'a')), 'U_SORT_FILE_COMMENT' => generate_link("Control_Panel&amp;i={$id}&amp;sk=b&amp;sd=" . ($sort_key == 'b' && $sort_dir == 'a' ? 'd' : 'a')), 'U_SORT_EXTENSION' => generate_link("Control_Panel&amp;i={$id}&amp;sk=c&amp;sd=" . ($sort_key == 'c' && $sort_dir == 'a' ? 'd' : 'a')), 'U_SORT_FILESIZE' => generate_link("Control_Panel&amp;i={$id}&amp;sk=d&amp;sd=" . ($sort_key == 'd' && $sort_dir == 'a' ? 'd' : 'a')), 'U_SORT_DOWNLOADS' => generate_link("Control_Panel&amp;i={$id}&amp;sk=e&amp;sd=" . ($sort_key == 'e' && $sort_dir == 'a' ? 'd' : 'a')), 'U_SORT_POST_TIME' => generate_link("Control_Panel&amp;i={$id}&amp;sk=f&amp;sd=" . ($sort_key == 'f' && $sort_dir == 'a' ? 'd' : 'a')), 'U_SORT_TOPIC_TITLE' => generate_link("Control_Panel&amp;i={$id}&amp;sk=g&amp;sd=" . ($sort_key == 'f' && $sort_dir == 'a' ? 'd' : 'a')), 'S_DISPLAY_MARK_ALL' => $num_attachments ? true : false, 'S_DISPLAY_PAGINATION' => $num_attachments ? true : false, 'S_UCP_ACTION' => generate_link('Control_Panel&amp;i=' . $id), 'S_SORT_OPTIONS' => $s_sort_key, 'S_ORDER_SELECT' => $s_sort_dir));
        $this->display($_CLASS['core_user']->lang['UCP_ATTACHMENTS'], 'ucp_attachments.html');
    }
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:69,代码来源:ucp_attachments.php

示例11: delete_forum_content

/**
* Delete forum content
*/
function delete_forum_content($forum_id)
{
    global $_CLASS;
    require_once SITE_FILE_ROOT . 'includes/forums/functions_posting.php';
    $_CLASS['core_db']->transaction();
    // Select then delete all attachments
    $sql = 'SELECT a.topic_id
		FROM ' . FORUMS_POSTS_TABLE . ' p, ' . FORUMS_ATTACHMENTS_TABLE . " a\r\n\t\tWHERE p.forum_id = {$forum_id}\r\n\t\t\tAND a.in_message = 0\r\n\t\t\tAND a.topic_id = p.topic_id";
    $result = $_CLASS['core_db']->query($sql);
    $topic_ids = array();
    while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
        $topic_ids[] = $row['topic_id'];
    }
    $_CLASS['core_db']->free_result($result);
    delete_attachments('topic', $topic_ids, false);
    // Before we remove anything we make sure we are able to adjust the post counts later. ;)
    $sql = 'SELECT poster_id
		FROM ' . FORUMS_POSTS_TABLE . '
		WHERE forum_id = ' . $forum_id . '
			AND post_postcount = 1';
    $result = $_CLASS['core_db']->query($sql);
    $post_counts = array();
    while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
        $post_counts[$row['poster_id']] = !empty($post_counts[$row['poster_id']]) ? $post_counts[$row['poster_id']] + 1 : 1;
    }
    $_CLASS['core_db']->free_result($result);
    switch ($_CLASS['core_db']->db_layer) {
        case 'mysql4':
        case 'mysqli':
            // Delete everything else and thank MySQL for offering multi-table deletion
            $tables_ary = array(FORUMS_SEARCH_WORDMATCH_TABLE => 'post_id', FORUMS_REPORTS_TABLE => 'post_id', FORUMS_BOOKMARKS_TABLE => 'topic_id', FORUMS_WATCH_TABLE => 'topic_id', FORUMS_POLL_OPTIONS_TABLE => 'topic_id', FORUMS_POLL_VOTES_TABLE => 'topic_id');
            $sql = 'DELETE ' . FORUMS_POSTS_TABLE;
            $sql_using = "\nFROM " . FORUMS_POSTS_TABLE;
            $sql_where = "\nWHERE " . FORUMS_POSTS_TABLE . ".forum_id = {$forum_id}\n";
            foreach ($tables_ary as $table => $field) {
                $sql .= ", {$table} ";
                $sql_using .= ", {$table} ";
                $sql_where .= "\nAND {$table}.{$field} = " . POSTS_TABLE . ".{$field}";
            }
            $_CLASS['core_db']->query($sql . $sql_using . $sql_where);
            break;
        default:
            // Delete everything else and curse your DB for not offering multi-table deletion
            $tables_ary = array('post_id' => array(FORUMS_SEARCH_WORDMATCH_TABLE, FORUMS_REPORTS_TABLE), 'topic_id' => array(FORUMS_BOOKMARKS_TABLE, FORUMS_WATCH_TABLE, FORUMS_POLL_OPTIONS_TABLE, FORUMS_POLL_VOTES_TABLE));
            foreach ($tables_ary as $field => $tables) {
                $start = 0;
                do {
                    $sql = "SELECT {$field}\r\n\t\t\t\t\t\tFROM " . FORUMS_POSTS_TABLE . '
						WHERE forum_id = ' . $forum_id;
                    $result = $_CLASS['core_db']->query_limit($sql, 500, $start);
                    $ids = array();
                    while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
                        $ids[] = $row[$field];
                    }
                    $_CLASS['core_db']->free_result($result);
                    if (sizeof($ids)) {
                        $start += sizeof($ids);
                        foreach ($tables as $table) {
                            $_CLASS['core_db']->query("DELETE FROM {$table} WHERE {$field} IN (" . implode(', ', $ids) . ')');
                        }
                    }
                } while ($row);
            }
            unset($ids);
            break;
    }
    $table_ary = array(FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, FORUMS_LOG_TABLE, FORUMS_MODERATOR_CACHE_TABLE, FORUMS_POSTS_TABLE, FORUMS_TOPICS_TABLE);
    //, TOPICS_TRACK_TABLE
    foreach ($table_ary as $table) {
        $_CLASS['core_db']->query("DELETE FROM {$table} WHERE forum_id = {$forum_id}");
    }
    // Adjust users post counts
    if (sizeof($post_counts)) {
        foreach ($post_counts as $poster_id => $substract) {
            $sql = 'UPDATE ' . CORE_USERS_TABLE . '
				SET user_posts = user_posts - ' . $substract . '
				WHERE user_id = ' . $poster_id;
            $_CLASS['core_db']->query($sql);
        }
    }
    // Set forum ids to 0
    $table_ary = array(FORUMS_DRAFTS_TABLE);
    foreach ($table_ary as $table) {
        $_CLASS['core_db']->query("UPDATE {$table} SET forum_id = 0 WHERE forum_id = {$forum_id}");
    }
    $_CLASS['core_db']->transaction('commit');
    // Make sure the overall post/topic count is correct...
    $sql = 'SELECT COUNT(post_id) AS stat 
		FROM ' . FORUMS_POSTS_TABLE . '
		WHERE post_approved = 1';
    $result = $_CLASS['core_db']->query($sql);
    $row = $_CLASS['core_db']->fetch_row_assoc($result);
    $_CLASS['core_db']->free_result($result);
    set_config('num_posts', (int) $row['stat'], true);
    $sql = 'SELECT COUNT(topic_id) AS stat
		FROM ' . FORUMS_TOPICS_TABLE . '
		WHERE topic_approved = 1';
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:101,代码来源:admin_forums.php

示例12: delete_forum_content

    /**
     * Delete forum content
     */
    function delete_forum_content($forum_id)
    {
        global $db, $config, $phpbb_root_path, $phpEx;
        include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
        $db->sql_transaction('begin');
        // Select then delete all attachments
        $sql = 'SELECT a.topic_id
			FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a\n\t\t\tWHERE p.forum_id = {$forum_id}\n\t\t\t\tAND a.in_message = 0\n\t\t\t\tAND a.topic_id = p.topic_id";
        $result = $db->sql_query($sql);
        $topic_ids = array();
        while ($row = $db->sql_fetchrow($result)) {
            $topic_ids[] = $row['topic_id'];
        }
        $db->sql_freeresult($result);
        delete_attachments('topic', $topic_ids, false);
        switch (SQL_LAYER) {
            case 'mysql4':
            case 'mysqli':
                // Delete everything else and thank MySQL for offering multi-table deletion
                $tables_ary = array(SEARCH_WORDMATCH_TABLE => 'post_id', REPORTS_TABLE => 'post_id', WARNINGS_TABLE => 'post_id', BOOKMARKS_TABLE => 'topic_id', TOPICS_WATCH_TABLE => 'topic_id', TOPICS_POSTED_TABLE => 'topic_id', POLL_OPTIONS_TABLE => 'topic_id', POLL_VOTES_TABLE => 'topic_id');
                $sql = 'DELETE ' . POSTS_TABLE;
                $sql_using = "\nFROM " . POSTS_TABLE;
                $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = {$forum_id}\n";
                foreach ($tables_ary as $table => $field) {
                    $sql .= ", {$table} ";
                    $sql_using .= ", {$table} ";
                    $sql_where .= "\nAND {$table}.{$field} = " . POSTS_TABLE . ".{$field}";
                }
                $db->sql_query($sql . $sql_using . $sql_where);
                break;
            default:
                // Delete everything else and curse your DB for not offering multi-table deletion
                $tables_ary = array('post_id' => array(SEARCH_WORDMATCH_TABLE, REPORTS_TABLE, WARNINGS_TABLE), 'topic_id' => array(BOOKMARKS_TABLE, TOPICS_WATCH_TABLE, TOPICS_POSTED_TABLE, POLL_OPTIONS_TABLE, POLL_VOTES_TABLE));
                foreach ($tables_ary as $field => $tables) {
                    $start = 0;
                    do {
                        $sql = "SELECT {$field}\n\t\t\t\t\t\t\tFROM " . POSTS_TABLE . '
							WHERE forum_id = ' . $forum_id;
                        $result = $db->sql_query_limit($sql, 500, $start);
                        $ids = array();
                        while ($row = $db->sql_fetchrow($result)) {
                            $ids[] = $row[$field];
                        }
                        $db->sql_freeresult($result);
                        if (sizeof($ids)) {
                            $start += sizeof($ids);
                            $id_list = implode(', ', $ids);
                            foreach ($tables as $table) {
                                $db->sql_query("DELETE FROM {$table} WHERE {$field} IN ({$id_list})");
                            }
                        }
                    } while ($row);
                }
                unset($ids, $id_list);
                break;
        }
        $table_ary = array(ACL_GROUPS_TABLE, ACL_USERS_TABLE, FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE);
        foreach ($table_ary as $table) {
            $db->sql_query("DELETE FROM {$table} WHERE forum_id = {$forum_id}");
        }
        // Set forum ids to 0
        $table_ary = array(DRAFTS_TABLE);
        foreach ($table_ary as $table) {
            $db->sql_query("UPDATE {$table} SET forum_id = 0 WHERE forum_id = {$forum_id}");
        }
        $db->sql_transaction('commit');
        return array();
    }
开发者ID:yunsite,项目名称:gloryroad,代码行数:71,代码来源:acp_forums.php

示例13: get_variable

// * Use this for ACP integration - changeable user id
//
global $_CLASS, $config, $site_file_root;
$start = get_variable('start', 'REQUEST', 0, 'int');
$delete = isset($_POST['delete']);
$confirm = isset($_POST['confirm']);
// change this
$delete_ids = array_unique(get_variable('attachment', 'POST', array(), 'array:int'));
if (!empty($delete_ids)) {
    $hidden_fields['delete'] = 1;
    $hidden_fields['attachment'] = $delete_ids;
    if (display_confirmation($_CLASS['core_user']->get_lang(count($delete_ids) == 1 ? 'DELETE_ATTACHMENT' : 'DELETE_ATTACHMENTS'), generate_hidden_fields($hidden_fields))) {
        require_once $site_file_root . 'includes/forums/functions_admin.php';
        require_once $site_file_root . 'includes/forums/functions.php';
        $_CLASS['core_db']->transaction();
        delete_attachments('attach', $delete_ids);
        $_CLASS['core_db']->transaction('commit');
        $return_link = generate_link($this->link_parent);
        $_CLASS['core_display']->meta_refresh(3, $return_link);
        $message = (count($delete_ids) === 1 ? $_CLASS['core_user']->lang['ATTACHMENT_DELETED'] : $_CLASS['core_user']->lang['ATTACHMENTS_DELETED']) . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_UCP'], '<a href="' . $return_link . '">', '</a>');
        trigger_error($message);
    }
}
$sort_key = get_variable('sk', 'REQUEST', 'a');
$sort_dir = get_variable('sd', 'REQUEST', 'a');
// Select box eventually
$sort_key_text = array('a' => $_CLASS['core_user']->lang['SORT_FILENAME'], 'b' => $_CLASS['core_user']->lang['SORT_COMMENT'], 'c' => $_CLASS['core_user']->lang['SORT_EXTENSION'], 'd' => $_CLASS['core_user']->lang['SORT_SIZE'], 'e' => $_CLASS['core_user']->lang['SORT_DOWNLOADS'], 'f' => $_CLASS['core_user']->lang['SORT_POST_TIME'], 'g' => $_CLASS['core_user']->lang['SORT_TOPIC_TITLE']);
$sort_key_sql = array('a' => 'a.real_filename', 'b' => 'a.comment', 'c' => 'a.extension', 'd' => 'a.filesize', 'e' => 'a.download_count', 'f' => 'a.filetime', 'g' => 't.topic_title');
$sort_dir_text = array('a' => $_CLASS['core_user']->lang['ASCENDING'], 'd' => $_CLASS['core_user']->lang['DESCENDING']);
$s_sort_key = '';
foreach ($sort_key_text as $key => $value) {
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:31,代码来源:ucp_attachments.php

示例14: delete_posts

/**
* Remove post(s)
*/
function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true)
{
    global $db, $config, $phpbb_root_path, $phpEx;
    if (is_array($where_ids)) {
        $where_ids = array_unique($where_ids);
    }
    if (empty($where_ids)) {
        return false;
    }
    $post_ids = $topic_ids = $forum_ids = array();
    $sql = 'SELECT post_id, poster_id, topic_id, forum_id
		FROM ' . POSTS_TABLE . "\n\t\tWHERE {$where_type} " . (!is_array($where_ids) ? '= ' . (int) $where_ids : 'IN (' . implode(', ', array_map('intval', $where_ids)) . ')');
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $post_ids[] = $row['post_id'];
        $poster_ids[] = $row['poster_id'];
        $topic_ids[] = $row['topic_id'];
        $forum_ids[] = $row['forum_id'];
    }
    $db->sql_freeresult($result);
    if (!sizeof($post_ids)) {
        return false;
    }
    $sql_where = implode(', ', $post_ids);
    $db->sql_transaction('begin');
    $table_ary = array(POSTS_TABLE, REPORTS_TABLE);
    foreach ($table_ary as $table) {
        $sql = "DELETE FROM {$table} \n\t\t\tWHERE post_id IN ({$sql_where})";
        $db->sql_query($sql);
    }
    unset($table_ary);
    // Remove the message from the search index
    $search_type = basename($config['search_type']);
    if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) {
        trigger_error('NO_SUCH_SEARCH_MODULE');
    }
    require "{$phpbb_root_path}includes/search/{$search_type}.{$phpEx}";
    $error = false;
    $search = new $search_type($error);
    if ($error) {
        trigger_error($error);
    }
    $search->index_remove($post_ids, $poster_ids);
    delete_attachments('post', $post_ids, false);
    $db->sql_transaction('commit');
    // Resync topics_posted table
    if ($posted_sync) {
        update_posted_info($topic_ids);
    }
    if ($auto_sync) {
        sync('topic_reported', 'topic_id', $topic_ids);
        sync('topic', 'topic_id', $topic_ids, true);
        sync('forum', 'forum_id', $forum_ids, true);
    }
    return sizeof($post_ids);
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:59,代码来源:functions_admin.php

示例15: main


//.........这里部分代码省略.........
                            $db->sql_query($sql);
                            add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']);
                            add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER');
                            trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            break;
                        case 'delavatar':
                            if (!check_form_key($form_name)) {
                                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
                            }
                            $sql_ary = array('user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0);
                            $sql = 'UPDATE ' . USERS_TABLE . '
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
                            $db->sql_query($sql);
                            // Delete old avatar if present
                            if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) {
                                avatar_delete('user', $user_row);
                            }
                            add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
                            add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER');
                            trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            break;
                        case 'delposts':
                            if (confirm_box(true)) {
                                // Delete posts, attachments, etc.
                                delete_posts('poster_id', $user_id);
                                add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']);
                                trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            } else {
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
                            }
                            break;
                        case 'delattach':
                            if (confirm_box(true)) {
                                delete_attachments('user', $user_id);
                                add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']);
                                trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            } else {
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
                            }
                            break;
                        case 'deloutbox':
                            if (confirm_box(true)) {
                                $msg_ids = array();
                                $lang = 'EMPTY';
                                $sql = 'SELECT msg_id
									FROM ' . PRIVMSGS_TO_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE author_id = {$user_id}\n\t\t\t\t\t\t\t\t\t\tAND folder_id = " . PRIVMSGS_OUTBOX;
                                $result = $db->sql_query($sql);
                                if ($row = $db->sql_fetchrow($result)) {
                                    if (!function_exists('delete_pm')) {
                                        include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
                                    }
                                    do {
                                        $msg_ids[] = (int) $row['msg_id'];
                                    } while ($row = $db->sql_fetchrow($result));
                                    $db->sql_freeresult($result);
                                    delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX);
                                    add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']);
                                    $lang = 'EMPTIED';
                                }
                                $db->sql_freeresult($result);
                                trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            } else {
                                confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
                            }
                            break;
                        case 'moveposts':
开发者ID:ubick,项目名称:lorekeepers.org,代码行数:67,代码来源:acp_users.php


注:本文中的delete_attachments函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。