print_submit_row($vbphrase['save']); } // ###################### Edit an attachment #################### if ($_POST['do'] == 'doedit') { $vbulletin->input->clean_array_gpc('p', array('attachmentid' => TYPE_UINT, 'a_filename' => TYPE_STR, 'a_counter' => TYPE_UINT, 'a_visible' => TYPE_BOOL, 'newvisible' => TYPE_BOOL, 'url' => TYPE_STR)); if (!($attachment = $db->query_first("\n\t\tSELECT attachmentid, post.postid, attachment.userid\n\t\tFROM " . TABLE_PREFIX . "attachment AS attachment\n\t\tLEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid)\n\t\tWHERE attachment.attachmentid = " . $vbulletin->GPC['attachmentid'] . "\n\t"))) { print_stop_message('no_matches_found'); } $vbulletin->input->clean_gpc('f', 'upload', TYPE_FILE); $attachdata =& datamanager_init('Attachment', $vbulletin, ERRTYPE_CP); $attachdata->set_existing($attachment); # Replace attachment if (!empty($vbulletin->GPC['upload']['tmp_name']) or !empty($vbulletin->GPC['url'])) { require_once DIR . '/includes/class_upload.php'; require_once DIR . '/includes/class_image.php'; $upload = new vB_Upload_Attachment($vbulletin); $image =& vB_Image::fetch_library($vbulletin); $upload->data =& $attachdata; $attachdata->set('visible', intval($vbulletin->GPC['newvisible'])); $attachdata->set('counter', 0); $upload->image =& $image; $upload->postinfo = array('postid' => $attachment['postid']); $upload->userinfo = array('userid' => $attachment['userid'], 'attachmentpermissions' => $vbulletin->userinfo['attachmentpermissions'], 'forumpermissions' => $vbulletin->userinfo['forumpermissions']); $upload->emptyfile = false; if (!empty($vbulletin->GPC['url'])) { $attachment_input = $vbulletin->GPC['url']; } else { $attachment_input = array('name' => &$vbulletin->GPC['upload']['name'], 'tmp_name' => &$vbulletin->GPC['upload']['tmp_name'], 'error' => &$vbulletin->GPC['upload']['error'], 'size' => &$vbulletin->GPC['upload']['size']); } $vbulletin->options['allowduplicates'] = true; if (!$upload->process_upload($attachment_input)) {
if ($vbulletin->options['attachurlcount']) { $urlcount = 1; foreach ($vbulletin->GPC['attachmenturl'] as $url) { if (!empty($url) and $urlcount <= $vbulletin->options['attachurlcount']) { $index = count($vbulletin->GPC['attachment']['name']); $vbulletin->GPC['attachment']['name']["{$index}"] = $url; $vbulletin->GPC['attachment']['url']["{$index}"] = true; $urlcount++; } } } $uploadsum = count($vbulletin->GPC['attachment']['name']); for ($x = 0; $x < $uploadsum; $x++) { // These are created each go around to insure memory has been freed $attachdata =& datamanager_init('Attachment', $vbulletin, ERRTYPE_ARRAY); $upload = new vB_Upload_Attachment($vbulletin); $image =& vB_Image::fetch_library($vbulletin); $upload->data =& $attachdata; $upload->image =& $image; if ($uploadsum > 1) { $upload->emptyfile = false; } $upload->foruminfo =& $foruminfo; if ($postid) { $upload->userinfo =& $userinfo; } $upload->postinfo =& $postinfo; if ($vbulletin->GPC['attachment']['url']["{$x}"]) { $attachment =& $vbulletin->GPC['attachment']['name']["{$x}"]; } else { $attachment = array('name' => &$vbulletin->GPC['attachment']['name']["{$x}"], 'tmp_name' => &$vbulletin->GPC['attachment']['tmp_name']["{$x}"], 'error' => &$vbulletin->GPC['attachment']['error']["{$x}"], 'size' => &$vbulletin->GPC['attachment']['size']["{$x}"]);