$tor_type = TOR_TYPE_SILVER; } elseif ($type == 'set_gold') { $tor_type = TOR_TYPE_GOLD; } else { $tor_type = 0; } change_tor_type($attach_id, $tor_type); $title = $lang['CHANGE_TOR_TYPE']; $url = make_url(TOPIC_URL . $torrent['topic_id']); break; case 'reg': tracker_register($attach_id); $url = TOPIC_URL . $torrent['topic_id']; break; case 'unreg': tracker_unregister($attach_id); $url = TOPIC_URL . $torrent['topic_id']; break; case 'del_torrent': if (empty($this->request['confirmed'])) { $this->prompt_for_confirm($lang['DEL_TORRENT']); } delete_torrent($attach_id); $url = make_url(TOPIC_URL . $torrent['topic_id']); break; case 'del_torrent_move_topic': if (empty($this->request['confirmed'])) { $this->prompt_for_confirm($lang['DEL_MOVE_TORRENT']); } delete_torrent($attach_id); $url = make_url("modcp.php?t={$torrent['topic_id']}&mode=move&sid={$userdata['session_id']}");
function handle_attachments($mode) { global $is_auth, $attach_config, $refresh, $HTTP_POST_VARS, $post_id, $submit, $preview, $error, $error_msg, $lang, $template, $userdata; // // ok, what shall we do ;) // // // Some adjustments for PM's // if ($userdata['user_level'] == ADMIN) { $max_attachments = ADMIN_MAX_ATTACHMENTS; } else { $max_attachments = intval($attach_config['max_attachments_pm']); } // // nothing, if the user is not authorized or attachment mod disabled // if (intval($attach_config['disable_mod']) || !$is_auth['auth_attachments']) { return false; } // // Init Vars // $attachments = array(); if (!$refresh) { $add = isset($HTTP_POST_VARS['add_attachment']) ? TRUE : FALSE; $delete = isset($HTTP_POST_VARS['del_attachment']) ? TRUE : FALSE; $edit = isset($HTTP_POST_VARS['edit_comment']) ? TRUE : FALSE; $update_attachment = isset($HTTP_POST_VARS['update_attachment']) ? TRUE : FALSE; $del_thumbnail = isset($HTTP_POST_VARS['del_thumbnail']) ? TRUE : FALSE; $add_attachment_box = !empty($HTTP_POST_VARS['add_attachment_box']) ? TRUE : FALSE; $posted_attachments_box = !empty($HTTP_POST_VARS['posted_attachments_box']) ? TRUE : FALSE; $refresh = $add || $delete || $edit || $del_thumbnail || $update_attachment || $add_attachment_box || $posted_attachments_box; } // // Get Attachments // $attachments = get_attachments_from_post($post_id); $auth = $is_auth['auth_edit'] || $is_auth['auth_mod'] ? TRUE : FALSE; if (!$submit && $mode == 'editpost' && $auth) { if (!$refresh && !$preview && !$error && !isset($HTTP_POST_VARS['del_poll_option'])) { for ($i = 0; $i < count($attachments); $i++) { $this->attachment_list[] = $attachments[$i]['physical_filename']; $this->attachment_comment_list[] = $attachments[$i]['comment']; $this->attachment_filename_list[] = $attachments[$i]['real_filename']; $this->attachment_extension_list[] = $attachments[$i]['extension']; $this->attachment_mimetype_list[] = $attachments[$i]['mimetype']; $this->attachment_filesize_list[] = $attachments[$i]['filesize']; $this->attachment_filetime_list[] = $attachments[$i]['filetime']; $this->attachment_id_list[] = $attachments[$i]['attach_id']; $this->attachment_thumbnail_list[] = $attachments[$i]['thumbnail']; } } } $this->num_attachments = count($this->attachment_list); if ($submit && $mode != 'vote') { if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost') { if ($this->filename != '') { if ($this->num_attachments < intval($max_attachments)) { $this->upload_attachment($this->page); if (!$error && $this->post_attach) { array_unshift($this->attachment_list, $this->attach_filename); array_unshift($this->attachment_comment_list, $this->file_comment); array_unshift($this->attachment_filename_list, $this->filename); array_unshift($this->attachment_extension_list, $this->extension); array_unshift($this->attachment_mimetype_list, $this->type); array_unshift($this->attachment_filesize_list, $this->filesize); array_unshift($this->attachment_filetime_list, $this->filetime); array_unshift($this->attachment_id_list, '0'); array_unshift($this->attachment_thumbnail_list, $this->thumbnail); $this->file_comment = ''; // This Variable is set to FALSE here, because the Attachment Mod enter Attachments into the // Database in two modes, one if the id_list is 0 and the second one if post_attach is true // Since post_attach is automatically switched to true if an Attachment got added to the filesystem, // but we are assigning an id of 0 here, we have to reset the post_attach variable to FALSE. // // This is very relevant, because it could happen that the post got not submitted, but we do not // know this circumstance here. We could be at the posting page or we could be redirected to the entered // post. :) $this->post_attach = FALSE; } } else { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Too_many_attachments'], intval($max_attachments)); } } } } if ($preview || $refresh || $error) { $delete_attachment = isset($HTTP_POST_VARS['del_attachment']) ? TRUE : FALSE; $delete_thumbnail = isset($HTTP_POST_VARS['del_thumbnail']) ? TRUE : FALSE; $add_attachment = isset($HTTP_POST_VARS['add_attachment']) ? TRUE : FALSE; $edit_attachment = isset($HTTP_POST_VARS['edit_comment']) ? TRUE : FALSE; $update_attachment = isset($HTTP_POST_VARS['update_attachment']) ? TRUE : FALSE; // // Perform actions on temporary attachments // if ($delete_attachment || $delete_thumbnail) { // store old values $actual_list = isset($HTTP_POST_VARS['attachment_list']) ? $HTTP_POST_VARS['attachment_list'] : array(); $actual_comment_list = isset($HTTP_POST_VARS['comment_list']) ? $HTTP_POST_VARS['comment_list'] : array(); $actual_filename_list = isset($HTTP_POST_VARS['filename_list']) ? $HTTP_POST_VARS['filename_list'] : array(); $actual_extension_list = isset($HTTP_POST_VARS['extension_list']) ? $HTTP_POST_VARS['extension_list'] : array(); $actual_mimetype_list = isset($HTTP_POST_VARS['mimetype_list']) ? $HTTP_POST_VARS['mimetype_list'] : array(); $actual_filesize_list = isset($HTTP_POST_VARS['filesize_list']) ? $HTTP_POST_VARS['filesize_list'] : array(); $actual_filetime_list = isset($HTTP_POST_VARS['filetime_list']) ? $HTTP_POST_VARS['filetime_list'] : array(); $actual_id_list = isset($HTTP_POST_VARS['attach_id_list']) ? $HTTP_POST_VARS['attach_id_list'] : array(); $actual_thumbnail_list = isset($HTTP_POST_VARS['attach_thumbnail_list']) ? $HTTP_POST_VARS['attach_thumbnail_list'] : array(); // clean values $this->attachment_list = array(); $this->attachment_comment_list = array(); $this->attachment_filename_list = array(); $this->attachment_extension_list = array(); $this->attachment_mimetype_list = array(); $this->attachment_filesize_list = array(); $this->attachment_filetime_list = array(); $this->attachment_id_list = array(); $this->attachment_thumbnail_list = array(); // restore values :) if (isset($HTTP_POST_VARS['attachment_list'])) { for ($i = 0; $i < count($actual_list); $i++) { $restore = FALSE; $del_thumb = FALSE; if ($delete_thumbnail) { if (!isset($HTTP_POST_VARS['del_thumbnail'][$actual_list[$i]])) { $restore = TRUE; } else { $del_thumb = TRUE; } } if ($delete_attachment) { if (!isset($HTTP_POST_VARS['del_attachment'][$actual_list[$i]])) { $restore = TRUE; } } if ($restore) { $this->attachment_list[] = $actual_list[$i]; $this->attachment_comment_list[] = $actual_comment_list[$i]; $this->attachment_filename_list[] = $actual_filename_list[$i]; $this->attachment_extension_list[] = $actual_extension_list[$i]; $this->attachment_mimetype_list[] = $actual_mimetype_list[$i]; $this->attachment_filesize_list[] = $actual_filesize_list[$i]; $this->attachment_filetime_list[] = $actual_filetime_list[$i]; $this->attachment_id_list[] = $actual_id_list[$i]; $this->attachment_thumbnail_list[] = $actual_thumbnail_list[$i]; } else { if (!$del_thumb) { // // delete selected attachment // if ($actual_id_list[$i] == '0') { unlink_attach($actual_list[$i]); if ($actual_thumbnail_list[$i] == 1) { unlink_attach($actual_list[$i], MODE_THUMBNAIL); } } else { delete_attachment($post_id, $actual_id_list[$i], $this->page); } } else { if ($del_thumb) { // // delete selected thumbnail // $this->attachment_list[] = $actual_list[$i]; $this->attachment_comment_list[] = $actual_comment_list[$i]; $this->attachment_filename_list[] = $actual_filename_list[$i]; $this->attachment_extension_list[] = $actual_extension_list[$i]; $this->attachment_mimetype_list[] = $actual_mimetype_list[$i]; $this->attachment_filesize_list[] = $actual_filesize_list[$i]; $this->attachment_filetime_list[] = $actual_filetime_list[$i]; $this->attachment_id_list[] = $actual_id_list[$i]; $this->attachment_thumbnail_list[] = 0; if ($actual_id_list[$i] == '0') { unlink_attach($actual_list[$i], MODE_THUMBNAIL); } else { $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . "\n\t\t\t\t\t\t\t\tSET thumbnail = 0\n\t\t\t\t\t\t\t\tWHERE attach_id = " . $actual_id_list[$i]; if (!DB()->sql_query($sql)) { message_die(GENERAL_ERROR, 'Unable to update ' . ATTACHMENTS_DESC_TABLE . ' Table.', '', __LINE__, __FILE__, $sql); } } } } } } } } else { if ($edit_attachment || $update_attachment || $add_attachment || $preview) { if ($edit_attachment) { $actual_comment_list = isset($HTTP_POST_VARS['comment_list']) ? $HTTP_POST_VARS['comment_list'] : ''; $this->attachment_comment_list = array(); for ($i = 0; $i < count($this->attachment_list); $i++) { $this->attachment_comment_list[$i] = $actual_comment_list[$i]; } } if ($update_attachment) { if ($this->filename == '') { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= $lang['Error_empty_add_attachbox']; } $this->upload_attachment($this->page); if (!$error) { $actual_list = isset($HTTP_POST_VARS['attachment_list']) ? $HTTP_POST_VARS['attachment_list'] : array(); $actual_id_list = isset($HTTP_POST_VARS['attach_id_list']) ? $HTTP_POST_VARS['attach_id_list'] : array(); $attachment_id = 0; $actual_element = 0; for ($i = 0; $i < count($actual_id_list); $i++) { if (isset($HTTP_POST_VARS['update_attachment'][$actual_id_list[$i]])) { $attachment_id = intval($actual_id_list[$i]); $actual_element = $i; } } // Get current informations to delete the Old Attachment $sql = "SELECT physical_filename, comment, thumbnail FROM " . ATTACHMENTS_DESC_TABLE . "\n\t\t\t\t\t\tWHERE attach_id = " . $attachment_id; if (!($result = DB()->sql_query($sql))) { message_die(GENERAL_ERROR, 'Unable to select old Attachment Entry.', '', __LINE__, __FILE__, $sql); } if (DB()->num_rows($result) != 1) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= $lang['Error_missing_old_entry']; } $row = DB()->sql_fetchrow($result); $comment = trim($this->file_comment) == '' ? trim($row['comment']) : trim($this->file_comment); $comment = addslashes($comment); // Update Entry $sql = "UPDATE " . ATTACHMENTS_DESC_TABLE . "\n\t\t\t\t\t\tSET physical_filename = '" . str_replace("'", "''", basename($this->attach_filename)) . "', real_filename = '" . str_replace("'", "''", basename($this->filename)) . "', comment = '" . str_replace("'", "''", $comment) . "', extension = '" . str_replace("'", "''", $this->extension) . "', mimetype = '" . str_replace("'", "''", $this->type) . "', filesize = " . $this->filesize . ", filetime = " . $this->filetime . ", thumbnail = " . $this->thumbnail . "\n\t\t\t\t\t\tWHERE attach_id = " . (int) $attachment_id; if (!DB()->sql_query($sql)) { message_die(GENERAL_ERROR, 'Unable to update the Attachment.', '', __LINE__, __FILE__, $sql); } // Delete the Old Attachment unlink_attach($row['physical_filename']); if (intval($row['thumbnail']) == 1) { unlink_attach($row['physical_filename'], MODE_THUMBNAIL); } //bt if ($this->attachment_extension_list[$actual_element] === TORRENT_EXT && $attachments[$actual_element]['tracker_status']) { include_once FT_ROOT . 'includes/functions_torrent.php'; tracker_unregister($attachment_id); } //bt end // // Make sure it is displayed // $this->attachment_list[$actual_element] = $this->attach_filename; $this->attachment_comment_list[$actual_element] = $comment; $this->attachment_filename_list[$actual_element] = $this->filename; $this->attachment_extension_list[$actual_element] = $this->extension; $this->attachment_mimetype_list[$actual_element] = $this->type; $this->attachment_filesize_list[$actual_element] = $this->filesize; $this->attachment_filetime_list[$actual_element] = $this->filetime; $this->attachment_id_list[$actual_element] = $actual_id_list[$actual_element]; $this->attachment_thumbnail_list[$actual_element] = $this->thumbnail; $this->file_comment = ''; } } if (($add_attachment || $preview) && $this->filename != '') { if ($this->num_attachments < intval($max_attachments)) { $this->upload_attachment($this->page); if (!$error) { array_unshift($this->attachment_list, $this->attach_filename); array_unshift($this->attachment_comment_list, $this->file_comment); array_unshift($this->attachment_filename_list, $this->filename); array_unshift($this->attachment_extension_list, $this->extension); array_unshift($this->attachment_mimetype_list, $this->type); array_unshift($this->attachment_filesize_list, $this->filesize); array_unshift($this->attachment_filetime_list, $this->filetime); array_unshift($this->attachment_id_list, '0'); array_unshift($this->attachment_thumbnail_list, $this->thumbnail); $this->file_comment = ''; } } else { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['Too_many_attachments'], intval($max_attachments)); } } } } } return TRUE; }
// Show users torrent-profile if ($mode == 'userprofile') { redirect(append_sid("profile.php?mode=viewprofile&u={$req_uid}"), TRUE); } // check SID if ($sid == '' || $sid !== $userdata['session_id']) { message_die(GENERAL_ERROR, 'Invalid_session'); } // Register torrent on tracker if ($mode == 'reg') { tracker_register($attach_id, 'request'); exit; } // Unregister torrent from tracker if ($mode == 'unreg') { tracker_unregister($attach_id, 'request'); exit; } // Delete torrent if ($mode == 'del' && $confirm) { delete_torrent($attach_id, 'request'); $redirect_url = append_sid("viewtopic.php?" . POST_TOPIC_URL . "={$topic_id}"); redirect($redirect_url); } // Delete torrent and move topic if ($mode == 'del_move' && $confirm) { delete_torrent($attach_id, 'request'); $redirect_url = "modcp.php?" . POST_TOPIC_URL . "={$topic_id}&mode=move&sid=" . $userdata['session_id']; redirect($redirect_url); } // Generate passkey
/** * Handle all modes... (intern) * @private */ function handle_attachments($mode) { global $is_auth, $attach_config, $refresh, $post_id, $submit, $preview, $error, $error_msg, $lang; // // ok, what shall we do ;) // if (IS_ADMIN) { $max_attachments = ADMIN_MAX_ATTACHMENTS; } else { $max_attachments = intval($attach_config['max_attachments']); } $sql_id = 'post_id'; // nothing, if the user is not authorized or attachment mod disabled if (intval($attach_config['disable_mod']) || !$is_auth['auth_attachments']) { return false; } // Init Vars $attachments = array(); if (!$refresh) { $add = isset($_POST['add_attachment']) ? TRUE : FALSE; $delete = isset($_POST['del_attachment']) ? TRUE : FALSE; $edit = isset($_POST['edit_comment']) ? TRUE : FALSE; $update_attachment = isset($_POST['update_attachment']) ? TRUE : FALSE; $del_thumbnail = isset($_POST['del_thumbnail']) ? TRUE : FALSE; $add_attachment_box = !empty($_POST['add_attachment_box']) ? TRUE : FALSE; $posted_attachments_box = !empty($_POST['posted_attachments_box']) ? TRUE : FALSE; $refresh = $add || $delete || $edit || $del_thumbnail || $update_attachment || $add_attachment_box || $posted_attachments_box; } // Get Attachments $attachments = get_attachments_from_post($post_id); $auth = $is_auth['auth_edit'] || $is_auth['auth_mod'] ? TRUE : FALSE; if (!$submit && $mode == 'editpost' && $auth) { if (!$refresh && !$preview && !$error) { for ($i = 0; $i < sizeof($attachments); $i++) { $this->attachment_list[] = $attachments[$i]['physical_filename']; $this->attachment_comment_list[] = $attachments[$i]['comment']; $this->attachment_filename_list[] = $attachments[$i]['real_filename']; $this->attachment_extension_list[] = $attachments[$i]['extension']; $this->attachment_mimetype_list[] = $attachments[$i]['mimetype']; $this->attachment_filesize_list[] = $attachments[$i]['filesize']; $this->attachment_filetime_list[] = $attachments[$i]['filetime']; $this->attachment_id_list[] = $attachments[$i]['attach_id']; $this->attachment_thumbnail_list[] = $attachments[$i]['thumbnail']; } } } $this->num_attachments = sizeof($this->attachment_list); if ($submit) { if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost') { if ($this->filename != '') { if ($this->num_attachments < intval($max_attachments)) { $this->upload_attachment($this->page); if (!$error && $this->post_attach) { array_unshift($this->attachment_list, $this->attach_filename); array_unshift($this->attachment_comment_list, $this->file_comment); array_unshift($this->attachment_filename_list, $this->filename); array_unshift($this->attachment_extension_list, $this->extension); array_unshift($this->attachment_mimetype_list, $this->type); array_unshift($this->attachment_filesize_list, $this->filesize); array_unshift($this->attachment_filetime_list, $this->filetime); array_unshift($this->attachment_id_list, '0'); array_unshift($this->attachment_thumbnail_list, $this->thumbnail); $this->file_comment = ''; $this->post_attach = FALSE; } } else { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['TOO_MANY_ATTACHMENTS'], intval($max_attachments)); } } } } if ($preview || $refresh || $error) { $delete_attachment = isset($_POST['del_attachment']) ? TRUE : FALSE; $delete_thumbnail = isset($_POST['del_thumbnail']) ? TRUE : FALSE; $add_attachment = isset($_POST['add_attachment']) ? TRUE : FALSE; $edit_attachment = isset($_POST['edit_comment']) ? TRUE : FALSE; $update_attachment = isset($_POST['update_attachment']) ? TRUE : FALSE; // Perform actions on temporary attachments if ($delete_attachment || $delete_thumbnail) { // store old values $actual_id_list = get_var('attach_id_list', array(0)); $actual_comment_list = get_var('comment_list', array('')); $actual_filename_list = get_var('filename_list', array('')); $actual_extension_list = get_var('extension_list', array('')); $actual_mimetype_list = get_var('mimetype_list', array('')); $actual_filesize_list = get_var('filesize_list', array(0)); $actual_filetime_list = get_var('filetime_list', array(0)); $actual_list = get_var('attachment_list', array('')); $actual_thumbnail_list = get_var('attach_thumbnail_list', array(0)); // clean values $this->attachment_list = array(); $this->attachment_comment_list = array(); $this->attachment_filename_list = array(); $this->attachment_extension_list = array(); $this->attachment_mimetype_list = array(); $this->attachment_filesize_list = array(); $this->attachment_filetime_list = array(); $this->attachment_id_list = array(); $this->attachment_thumbnail_list = array(); // restore values :) if (isset($_POST['attachment_list'])) { for ($i = 0; $i < sizeof($actual_list); $i++) { $restore = FALSE; $del_thumb = FALSE; if ($delete_thumbnail) { if (!isset($_POST['del_thumbnail'][$actual_list[$i]])) { $restore = TRUE; } else { $del_thumb = TRUE; } } if ($delete_attachment) { if (!isset($_POST['del_attachment'][$actual_list[$i]])) { $restore = TRUE; } } if ($restore) { $this->attachment_list[] = $actual_list[$i]; $this->attachment_comment_list[] = $actual_comment_list[$i]; $this->attachment_filename_list[] = $actual_filename_list[$i]; $this->attachment_extension_list[] = $actual_extension_list[$i]; $this->attachment_mimetype_list[] = $actual_mimetype_list[$i]; $this->attachment_filesize_list[] = $actual_filesize_list[$i]; $this->attachment_filetime_list[] = $actual_filetime_list[$i]; $this->attachment_id_list[] = $actual_id_list[$i]; $this->attachment_thumbnail_list[] = $actual_thumbnail_list[$i]; } else { if (!$del_thumb) { // delete selected attachment if ($actual_id_list[$i] == '0') { unlink_attach($actual_list[$i]); if ($actual_thumbnail_list[$i] == 1) { unlink_attach($actual_list[$i], MODE_THUMBNAIL); } } else { delete_attachment($post_id, $actual_id_list[$i], $this->page); } } else { if ($del_thumb) { // delete selected thumbnail $this->attachment_list[] = $actual_list[$i]; $this->attachment_comment_list[] = $actual_comment_list[$i]; $this->attachment_filename_list[] = $actual_filename_list[$i]; $this->attachment_extension_list[] = $actual_extension_list[$i]; $this->attachment_mimetype_list[] = $actual_mimetype_list[$i]; $this->attachment_filesize_list[] = $actual_filesize_list[$i]; $this->attachment_filetime_list[] = $actual_filetime_list[$i]; $this->attachment_id_list[] = $actual_id_list[$i]; $this->attachment_thumbnail_list[] = 0; if ($actual_id_list[$i] == 0) { unlink_attach($actual_list[$i], MODE_THUMBNAIL); } else { $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET thumbnail = 0 WHERE attach_id = ' . (int) $actual_id_list[$i]; if (!DB()->sql_query($sql)) { bb_die('Unable to update ' . BB_ATTACHMENTS_DESC); } } } } } } } } else { if ($edit_attachment || $update_attachment || $add_attachment || $preview) { if ($edit_attachment) { $actual_comment_list = get_var('comment_list', array('')); $this->attachment_comment_list = array(); for ($i = 0; $i < sizeof($this->attachment_list); $i++) { $this->attachment_comment_list[$i] = $actual_comment_list[$i]; } } if ($update_attachment) { if ($this->filename == '') { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= $lang['ERROR_EMPTY_ADD_ATTACHBOX']; } $this->upload_attachment($this->page); if (!$error) { $actual_list = get_var('attachment_list', array('')); $actual_id_list = get_var('attach_id_list', array(0)); $attachment_id = 0; $actual_element = 0; for ($i = 0; $i < sizeof($actual_id_list); $i++) { if (isset($_POST['update_attachment'][$actual_id_list[$i]])) { $attachment_id = intval($actual_id_list[$i]); $actual_element = $i; } } // Get current informations to delete the Old Attachment $sql = 'SELECT physical_filename, comment, thumbnail FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int) $attachment_id; if (!($result = DB()->sql_query($sql))) { bb_die('Unable to select old attachment entry'); } if (DB()->num_rows($result) != 1) { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= $lang['ERROR_MISSING_OLD_ENTRY']; } $row = DB()->sql_fetchrow($result); DB()->sql_freeresult($result); $comment = trim($this->file_comment) == '' ? trim($row['comment']) : trim($this->file_comment); // Update Entry $sql_ary = array('physical_filename' => (string) basename($this->attach_filename), 'real_filename' => (string) basename($this->filename), 'comment' => (string) $comment, 'extension' => (string) strtolower($this->extension), 'mimetype' => (string) strtolower($this->type), 'filesize' => (int) $this->filesize, 'filetime' => (int) $this->filetime, 'thumbnail' => (int) $this->thumbnail); $sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . ' WHERE attach_id = ' . (int) $attachment_id; if (!DB()->sql_query($sql)) { bb_die('Unable to update the attachment'); } // Delete the Old Attachment unlink_attach($row['physical_filename']); if (intval($row['thumbnail']) == 1) { unlink_attach($row['physical_filename'], MODE_THUMBNAIL); } //bt if ($this->attachment_extension_list[$actual_element] === TORRENT_EXT && $attachments[$actual_element]['tracker_status']) { include INC_DIR . 'functions_torrent.php'; tracker_unregister($attachment_id); } //bt end // Make sure it is displayed $this->attachment_list[$actual_element] = $this->attach_filename; $this->attachment_comment_list[$actual_element] = $comment; $this->attachment_filename_list[$actual_element] = $this->filename; $this->attachment_extension_list[$actual_element] = $this->extension; $this->attachment_mimetype_list[$actual_element] = $this->type; $this->attachment_filesize_list[$actual_element] = $this->filesize; $this->attachment_filetime_list[$actual_element] = $this->filetime; $this->attachment_id_list[$actual_element] = $actual_id_list[$actual_element]; $this->attachment_thumbnail_list[$actual_element] = $this->thumbnail; $this->file_comment = ''; } } if (($add_attachment || $preview) && $this->filename != '') { if ($this->num_attachments < intval($max_attachments)) { $this->upload_attachment($this->page); if (!$error) { array_unshift($this->attachment_list, $this->attach_filename); array_unshift($this->attachment_comment_list, $this->file_comment); array_unshift($this->attachment_filename_list, $this->filename); array_unshift($this->attachment_extension_list, $this->extension); array_unshift($this->attachment_mimetype_list, $this->type); array_unshift($this->attachment_filesize_list, $this->filesize); array_unshift($this->attachment_filetime_list, $this->filetime); array_unshift($this->attachment_id_list, '0'); array_unshift($this->attachment_thumbnail_list, $this->thumbnail); $this->file_comment = ''; } } else { $error = TRUE; if (!empty($error_msg)) { $error_msg .= '<br />'; } $error_msg .= sprintf($lang['TOO_MANY_ATTACHMENTS'], intval($max_attachments)); } } } } } return TRUE; }
function delete_torrent($attach_id, $mode = '') { global $lang, $userdata; global $reg_mode, $topic_id; $attach_id = intval($attach_id); $reg_mode = $mode; if (!($torrent = get_torrent_info($attach_id))) { message_die(GENERAL_ERROR, 'Torrent not found'); } $post_id = $torrent['post_id']; $topic_id = $torrent['topic_id']; $forum_id = $torrent['forum_id']; $poster_id = $torrent['poster_id']; if ($torrent['extension'] !== TORRENT_EXT) { message_die(GENERAL_ERROR, $lang['Not_torrent']); } torrent_auth_check($forum_id, $torrent['poster_id']); tracker_unregister($attach_id); delete_attachment(0, $attach_id); return; }
function delete_torrent($attach_id, $mode = '') { global $lang, $reg_mode, $topic_id; $attach_id = intval($attach_id); $reg_mode = $mode; if (!($torrent = get_torrent_info($attach_id))) { bb_die($lang['TOR_NOT_FOUND']); } $topic_id = $torrent['topic_id']; $forum_id = $torrent['forum_id']; $poster_id = $torrent['poster_id']; if ($torrent['extension'] !== TORRENT_EXT) { bb_die($lang['NOT_TORRENT']); } torrent_auth_check($forum_id, $poster_id); tracker_unregister($attach_id); delete_attachment(0, $attach_id); return; }