diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2003-09-07 17:16:12 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2003-09-07 17:16:12 +0000 |
commit | db2a73d2f07cd04e787c0b9ecc5533e4895a400b (patch) | |
tree | 02b4efb589aac7d7f7663c24ed2bd48feef2d156 /phpBB/includes/functions_posting.php | |
parent | 734b62cca6e72d1722a90c63f5779d79186d136f (diff) | |
download | forums-db2a73d2f07cd04e787c0b9ecc5533e4895a400b.tar forums-db2a73d2f07cd04e787c0b9ecc5533e4895a400b.tar.gz forums-db2a73d2f07cd04e787c0b9ecc5533e4895a400b.tar.bz2 forums-db2a73d2f07cd04e787c0b9ecc5533e4895a400b.tar.xz forums-db2a73d2f07cd04e787c0b9ecc5533e4895a400b.zip |
okie, using array_merge. :D
fixed: admin_prune
added: prune topics last viewed at... (only admin_prune ATM)
moved: delete_attachments to functions_admin
git-svn-id: file:///svn/phpbb/trunk@4482 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_posting.php')
-rw-r--r-- | phpBB/includes/functions_posting.php | 209 |
1 files changed, 0 insertions, 209 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 858fd4d3ec..8bfd9b72bb 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -193,215 +193,6 @@ function update_last_post_information($type, $id, &$parent_sql) return $update_sql; } -// Delete Attachment -function delete_attachment($post_id_array = -1, $attach_id_array = -1, $page = 'post', $user_id = -1) -{ - global $db; - - if ($post_id_array == -1 && $attach_id_array == -1 && $page == -1) - { - return; - } - - // Generate Array, if it's not an array - if ($post_id_array == -1 && $attach_id_array != -1) - { - $post_id_array = array(); - - if (!is_array($attach_id_array)) - { - $attach_id_array = (strstr($attach_id_array, ',')) ? explode(',', str_replace(', ', ',', $attach_id_array)) : array((int) $attach_id_array); - } - - // Get the post_ids to fill the array - $sql = 'SELECT ' . (($page == 'privmsgs') ? 'privmsgs_id' : 'post_id') . ' as id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE attach_id IN (' . implode(', ', $attach_id_array) . ') - GROUP BY id'; - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - return; - } - - do - { - $post_id_array[] = $row['id']; - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - } - - if (!is_array($post_id_array)) - { - if (trim($post_id_array) == '') - { - return; - } - - $post_id_array = (strstr($post_id_array, ',')) ? explode(',', str_replace(', ', ',', $attach_id_array)) : array((int) $post_id_array); - } - - if (!count($post_id_array)) - { - return; - } - - // First of all, determine the post id and attach_id - if ($attach_id_array == -1) - { - $attach_id_array = array(); - - // Get the attach_ids to fill the array - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE ' . (($page == 'privmsgs') ? 'privmsgs_id' : 'post_id') . ' IN (' . implode(', ', $post_id_array) . ') - GROUP BY attach_id'; - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - return; - } - - do - { - $attach_id_array[] = $row['attach_id']; - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - } - - if (!is_array($attach_id_array)) - { - $attach_id_array = (strstr($post_id_array, ',')) ? explode(',', str_replace(', ', ',', $attach_id_array)) : array((int) $attach_id_array); - } - - if (!count($attach_id_array)) - { - return; - } - - $sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' - WHERE attach_id IN (' . implode(', ', $attach_id_array) . ') - AND post_id IN (' . implode(', ', $post_id_array) . ')'; - $db->sql_query($sql); - - foreach ($attach_id_array as $attach_id) - { - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . " - WHERE attach_id = $attach_id"; - $select_result = $db->sql_query($sql); - - if (!is_array($db->sql_fetchrow($select_result))) - { - $sql = 'SELECT attach_id, physical_filename, thumbnail - FROM ' . ATTACHMENTS_DESC_TABLE . " - WHERE attach_id = $attach_id"; - $result = $db->sql_query($sql); - - // delete attachments - while ($row = $db->sql_fetchrow($result)) - { - phpbb_unlink($row['physical_filename'], 'file', $config['use_ftp_upload']); - if ($row['thumbnail']) - { - phpbb_unlink($row['physical_filename'], 'thumbnail', $config['use_ftp_upload']); - } - - $sql = 'DELETE FROM ' . ATTACHMENTS_DESC_TABLE . ' - WHERE attach_id = ' . $row['attach_id']; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - } - $db->sql_freeresult($select_result); - } - - // Now Sync the Topic/PM - if ($page == 'privmsgs') - { - foreach ($post_id_array as $privmsgs_id) - { - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . ' - WHERE privmsgs_id = ' . $privmsgs_id; - $select_result = $db->sql_query($sql); - - if (!is_array($db->sql_fetchrow($select_result))) - { - $sql = 'UPDATE ' . PRIVMSGS_TABLE . ' - SET privmsgs_attachment = 0 - WHERE privmsgs_id = ' . $privmsgs_id; - $db->sql_query($sql); - } - $db->sql_freeresult($select_result); - } - } - else - { - $sql = 'SELECT topic_id - FROM ' . POSTS_TABLE . ' - WHERE post_id IN (' . implode(', ', $post_id_array) . ') - GROUP BY topic_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $topic_id = $row['topic_id']; - - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id - GROUP BY post_id"; - $result2 = $db->sql_query($sql); - - $post_ids = array(); - - while ($post_row = $db->sql_fetchrow($result2)) - { - $post_ids[] = $post_row['post_id']; - } - $db->sql_freeresult($result2); - - if (count($post_ids)) - { - $post_id_sql = implode(', ', $post_ids); - - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_id IN ($post_id_sql)"; - $select_result = $db->sql_query_limit($sql, 1); - $set_id = (!is_array($db->sql_fetchrow($select_result))) ? 0 : 1; - $db->sql_freeresult($select_result); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_attachment = $set_id - WHERE topic_id = $topic_id"; - $db->sql_query($sql); - - foreach ($post_ids as $post_id) - { - $sql = 'SELECT attach_id - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_id = $post_id"; - $select_result = $db->sql_query_limit($sql, 1); - $set_id = (!is_array($db->sql_fetchrow($select_result))) ? 0 : 1; - $db->sql_freeresult($select_result); - - $sql = 'UPDATE ' . POSTS_TABLE . " - SET post_attachment = $set_id - WHERE post_id = $post_id"; - $db->sql_query($sql); - } - } - } - $db->sql_freeresult($result); - } -} - // Upload Attachment - filedata is generated here function upload_attachment($filename) { |