function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false) { global $_G, $space; if ($albumid < 0) { $albumid = 0; } $setarr = array(); require_once libfile('class/upload'); $upload = new discuz_upload(); $filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext; $newfilename = $_G['setting']['attachdir'] . './album/' . $filepath; if ($handle = fopen($newfilename, 'wb')) { if (fwrite($handle, $strdata) !== FALSE) { fclose($handle); $size = filesize($newfilename); if (empty($space)) { $_G['member'] = $space = getspace($_G['uid']); $_G['username'] = addslashes($space['username']); } $_G['member'] = $space; $maxspacesize = checkperm('maxspacesize'); $maxspacesize = $maxspacesize * 1024 * 1024; if ($maxspacesize) { space_merge($space, 'common_member_count'); space_merge($space, 'common_member_field_home'); if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize']) { @unlink($newfilename); return -1; } } if (!$upload->get_image_info($newfilename)) { @unlink($newfilename); return -2; } require_once libfile('class/image'); $image = new image(); $result = $image->Thumb($newfilename, NULL, 140, 140, 1); $thumb = empty($result) ? 0 : 1; $image->Watermark($newfilename); $pic_remote = 0; $album_picflag = 1; if (getglobal('setting/ftp/on')) { $ftpresult_thumb = 0; $ftpresult = ftpupload('album/' . $filepath); if ($ftpresult) { if ($thumb) { ftpupload('album/' . $filepath . '.thumb.jpg'); } $pic_remote = 1; $album_picflag = 2; } else { if (getglobal('setting/ftp/mirror')) { @unlink($newfilename); @unlink($newfilename . '.thumb.jpg'); return -3; } } } $filename = addslashes($name ? $name : substr(strrchr($filepath, '/'), 1)); $title = getstr($title, 200, 1, 1, 1); if ($albumid) { $albumid = album_creat_by_id($albumid); } else { $albumid = 0; } $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote); $setarr['picid'] = DB::insert('home_pic', $setarr, 1); DB::query("UPDATE " . DB::table('common_member_count') . " SET attachsize=attachsize+{$size} WHERE uid='{$_G['uid']}'"); include_once libfile('function/stat'); updatestat('pic'); return $setarr; } else { fclose($handle); } } return -3; }
$image = new image(); $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['sourcewidth'], $_G['setting']['sourceheight'], 1, 1) ? 1 : 0; $width = $image->imginfo['width']; $upload->attach['size'] = $image->imginfo['size']; } if ($_G['setting']['thumbstatus']) { $image = new image(); $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], 0) ? 1 : 0; $width = $image->imginfo['width']; } if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) { list($width) = @getimagesize($upload->attach['target']); } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image = new image(); $image->Watermark($attach['target'], '', 'forum'); $upload->attach['size'] = $image->imginfo['size']; } } $aids[] = $aid = getattachnewaid(); $setarr = array('aid' => $aid, 'dateline' => $_G['timestamp'], 'filename' => $upload->attach['name'], 'filesize' => $upload->attach['size'], 'attachment' => $upload->attach['attachment'], 'isimage' => $upload->attach['isimage'], 'uid' => $_G['uid'], 'thumb' => $thumb, 'remote' => '0', 'width' => $width); C::t("forum_attachment_unused")->insert($setarr); $attachaids[$hash] = $imagereplace['newimageurl'][] = '[attachimg]' . $aid . '[/attachimg]'; } else { $imagereplace['newimageurl'][] = $attachaids[$hash]; } } } if (!empty($aids)) { require_once libfile('function/post'); }
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0) { global $_G; $uid = $uid ? $uid : $_G['uid']; $uidadd = $_G['forum']['ismoderator'] ? '' : " AND uid='{$uid}'"; if ($attachnew) { $newaids = array_keys($attachnew); $newattach = $newattachfile = $albumattach = array(); $query = DB::query("SELECT * FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN (" . dimplode($newaids) . "){$uidadd}"); while ($attach = DB::fetch($query)) { $newattach[$attach['aid']] = daddslashes($attach); if ($attach['isimage']) { $newattachfile[$attach['aid']] = $attach['attachment']; } } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { require_once libfile('class/image'); $image = new image(); } if (!empty($_G['gp_albumaid'])) { array_unshift($_G['gp_albumaid'], ''); $_G['gp_albumaid'] = array_unique($_G['gp_albumaid']); unset($_G['gp_albumaid'][0]); foreach ($_G['gp_albumaid'] as $aid) { if (isset($newattach[$aid])) { $albumattach[$aid] = $newattach[$aid]; } } } foreach ($attachnew as $aid => $attach) { $update = array(); $update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0; $update['price'] = $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0; $update['tid'] = $tid; $update['pid'] = $pid; $update['uid'] = $uid; $update['description'] = cutstr(dhtmlspecialchars($attach['description']), 100); DB::update(getattachtablebytid($tid), $update, "aid='{$aid}'"); if (!$newattach[$aid]) { continue; } $update = array_merge($update, $newattach[$aid]); if (!empty($newattachfile[$aid])) { if ($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) { $update['thumb'] = 0; @unlink($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($newattachfile[$aid])); if (!empty($albumattach[$aid])) { $albumattach[$aid]['thumb'] = 0; } } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum'); $update['filesize'] = $image->imginfo['size']; } } if (!empty($_G['gp_albumaid']) && isset($albumattach[$aid])) { $newalbum = 0; if (!$_G['gp_uploadalbum']) { require_once libfile('function/spacecp'); $_G['gp_uploadalbum'] = album_creat(array('albumname' => $_G['gp_newalbum'])); $newalbum = 1; } $picdata = array('albumid' => $_G['gp_uploadalbum'], 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => $albumattach[$aid]['filename'], 'title' => cutstr(dhtmlspecialchars($attach['description']), 100), 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2); $update['picid'] = DB::insert('home_pic', $picdata, 1); if ($newalbum) { require_once libfile('function/home'); require_once libfile('function/spacecp'); album_update_pic($_G['gp_uploadalbum']); } } DB::insert(getattachtablebytid($tid), $update, false, true); DB::update('forum_attachment', array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid)), "aid='{$aid}'"); DB::delete('forum_attachment_unused', "aid='{$aid}'"); } if (!empty($_G['gp_albumaid'])) { $albumdata = array('picnum' => DB::result_first("SELECT count(*) FROM " . DB::table('home_pic') . " WHERE albumid='{$_G['gp_uploadalbum']}'"), 'updatetime' => $_G['timestamp']); DB::update('home_album', $albumdata, "albumid='{$_G['gp_uploadalbum']}'"); } if ($newattach) { ftpupload($newaids, $uid); } } if (!$modnewthreads && $newattach && $uid == $_G['uid']) { updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']); } if ($attachupdate) { $query = DB::query("SELECT pid, aid, attachment, thumb, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE aid IN (" . dimplode(array_keys($attachupdate)) . ")"); while ($attach = DB::fetch($query)) { if (array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) { dunlink($attach); } } $uaids = dimplode($attachupdate); $query = DB::query("SELECT aid, width, filename, filesize, attachment, isimage, thumb, remote FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN ({$uaids}){$uidadd}"); DB::query("DELETE FROM " . DB::table('forum_attachment_unused') . " WHERE aid IN ({$uaids}){$uidadd}"); $attachupdate = array_flip($attachupdate); while ($attach = DB::fetch($query)) { $update = $attach; $update['dateline'] = TIMESTAMP; $update['remote'] = 0; unset($update['aid']); if ($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum'); $update['filesize'] = $image->imginfo['size']; } DB::update(getattachtablebytid($tid), $update, "aid='" . $attachupdate[$attach['aid']] . "'"); ftpupload(array($attachupdate[$attach['aid']]), $uid); } } $attachcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : '')); $attachment = $attachcount ? DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : '') . " AND isimage != 0") ? 2 : 1 : 0; DB::query("UPDATE " . DB::table('forum_thread') . " SET attachment='{$attachment}' WHERE tid='{$tid}'", 'UNBUFFERED'); if (!$attachment) { DB::delete('forum_threadimage', "tid='{$tid}'"); } $posttable = getposttablebytid($tid); DB::query("UPDATE " . DB::table($posttable) . " SET attachment='{$attachment}' WHERE pid='{$pid}'", 'UNBUFFERED'); $_G['forum_attachexist'] = $attachment; }
$upload->init($_FILES['Filedata'], 'portal'); $attach = $upload->attach; if (!$upload->error()) { $upload->save(); } if ($upload->error()) { $errorcode = 4; } if (!$errorcode) { if ($attach['isimage'] && empty($_G['setting']['portalarticleimgthumbclosed'])) { require_once libfile('class/image'); $image = new image(); $thumbimgwidth = $_G['setting']['portalarticleimgthumbwidth'] ? $_G['setting']['portalarticleimgthumbwidth'] : 300; $thumbimgheight = $_G['setting']['portalarticleimgthumbheight'] ? $_G['setting']['portalarticleimgthumbheight'] : 300; $attach['thumb'] = $image->Thumb($attach['target'], '', $thumbimgwidth, $thumbimgheight, 2); $image->Watermark($attach['target'], '', 'portal'); } if (getglobal('setting/ftp/on') && (!$_G['setting']['ftp']['allowedexts'] && !$_G['setting']['ftp']['disallowedexts'] || $_G['setting']['ftp']['allowedexts'] && in_array($attach['ext'], $_G['setting']['ftp']['allowedexts']) || $_G['setting']['ftp']['disallowedexts'] && !in_array($attach['ext'], $_G['setting']['ftp']['disallowedexts'])) && (!$_G['setting']['ftp']['minsize'] || $attach['size'] >= $_G['setting']['ftp']['minsize'] * 1024)) { if (ftpcmd('upload', 'portal/' . $attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'portal/' . getimgthumbname($attach['attachment'])))) { @unlink($_G['setting']['attachdir'] . '/portal/' . $attach['attachment']); @unlink($_G['setting']['attachdir'] . '/portal/' . getimgthumbname($attach['attachment'])); $attach['remote'] = 1; } else { if (getglobal('setting/ftp/mirror')) { @unlink($attach['target']); @unlink(getimgthumbname($attach['target'])); $errorcode = 5; } } } $setarr = array('uid' => $_G['uid'], 'filename' => $attach['name'], 'attachment' => $attach['attachment'], 'filesize' => $attach['size'], 'isimage' => $attach['isimage'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote'], 'filetype' => $attach['extension'], 'dateline' => $_G['timestamp'], 'aid' => $aid);
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0) { global $_G; $thread = C::t('forum_thread')->fetch($tid); $uid = $uid ? $uid : $_G['uid']; if ($attachnew) { $newaids = array_keys($attachnew); $newattach = $newattachfile = $albumattach = array(); foreach (C::t('forum_attachment_unused')->fetch_all($newaids) as $attach) { if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) { continue; } $attach['uid'] = $uid; $newattach[$attach['aid']] = daddslashes($attach); if ($attach['isimage']) { $newattachfile[$attach['aid']] = $attach['attachment']; } } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) || !$_G['setting']['thumbdisabledmobile']) { require_once libfile('class/image'); $image = new image(); } if (!empty($_GET['albumaid'])) { array_unshift($_GET['albumaid'], ''); $_GET['albumaid'] = array_unique($_GET['albumaid']); unset($_GET['albumaid'][0]); foreach ($_GET['albumaid'] as $aid) { if (isset($newattach[$aid])) { $albumattach[$aid] = $newattach[$aid]; } } } foreach ($attachnew as $aid => $attach) { $update = array(); $update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0; $update['price'] = $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0; $update['tid'] = $tid; $update['pid'] = $pid; $update['uid'] = $uid; $update['description'] = censor(cutstr(dhtmlspecialchars($attach['description']), 100)); C::t('forum_attachment_n')->update('tid:' . $tid, $aid, $update); if (!$newattach[$aid]) { continue; } $update = array_merge($update, $newattach[$aid]); if (!empty($newattachfile[$aid])) { if ($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) { $update['thumb'] = 0; @unlink($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($newattachfile[$aid])); if (!empty($albumattach[$aid])) { $albumattach[$aid]['thumb'] = 0; } } elseif (!$_G['setting']['thumbdisabledmobile']) { $_daid = sprintf("%09d", $aid); $dir1 = substr($_daid, 0, 3); $dir2 = substr($_daid, 3, 2); $dir3 = substr($_daid, 5, 2); $dw = 320; $dh = 320; $thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg'; $image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr'); $dw = 720; $dh = 720; $thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg'; $image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr'); } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum'); $update['filesize'] = $image->imginfo['size']; } } if (!empty($_GET['albumaid']) && isset($albumattach[$aid])) { $newalbum = 0; if (!$_GET['uploadalbum']) { require_once libfile('function/spacecp'); $_GET['uploadalbum'] = album_creat(array('albumname' => $_GET['newalbum'])); $newalbum = 1; } $picdata = array('albumid' => $_GET['uploadalbum'], 'uid' => $uid, 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => censor($albumattach[$aid]['filename']), 'title' => censor(cutstr(dhtmlspecialchars($attach['description']), 100)), 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2); $update['picid'] = C::t('home_pic')->insert($picdata, 1); if ($newalbum) { require_once libfile('function/home'); require_once libfile('function/spacecp'); album_update_pic($_GET['uploadalbum']); } } C::t('forum_attachment_n')->insert('tid:' . $tid, $update, false, true); C::t('forum_attachment')->update($aid, array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid))); C::t('forum_attachment_unused')->delete($aid); } if (!empty($_GET['albumaid'])) { $albumdata = array('picnum' => C::t('home_pic')->check_albumpic($_GET['uploadalbum']), 'updatetime' => $_G['timestamp']); C::t('home_album')->update($_GET['uploadalbum'], $albumdata); require_once libfile('function/home'); require_once libfile('function/spacecp'); album_update_pic($_GET['uploadalbum']); } if ($newattach) { ftpupload($newaids, $uid); } } if (!$modnewthreads && $newattach && $uid == $_G['uid']) { updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']); } if ($attachupdate) { $attachs = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'aid', array_keys($attachupdate)); foreach ($attachs as $attach) { if (array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) { dunlink($attach); } } $unusedattachs = C::t('forum_attachment_unused')->fetch_all($attachupdate); $attachupdate = array_flip($attachupdate); $unusedaids = array(); foreach ($unusedattachs as $attach) { if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) { continue; } $unusedaids[] = $attach['aid']; $update = $attach; $update['dateline'] = TIMESTAMP; $update['remote'] = 0; unset($update['aid']); if ($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum'); $update['filesize'] = $image->imginfo['size']; } C::t('forum_attachment_n')->update('tid:' . $tid, $attachupdate[$attach['aid']], $update); @unlink($_G['setting']['attachdir'] . 'image/' . $attach['aid'] . '_100_100.jpg'); C::t('forum_attachment_exif')->delete($attachupdate[$attach['aid']]); C::t('forum_attachment_exif')->update($attach['aid'], array('aid' => $attachupdate[$attach['aid']])); ftpupload(array($attachupdate[$attach['aid']]), $uid); } if ($unusedaids) { C::t('forum_attachment_unused')->delete($unusedaids); } } $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid); $attachment = 0; if ($attachcount) { if (C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid)) { $attachment = 2; } else { $attachment = 1; } } else { $attachment = 0; } C::t('forum_thread')->update($tid, array('attachment' => $attachment)); C::t('forum_post')->update('tid:' . $tid, $pid, array('attachment' => $attachment), true); if (!$attachment) { C::t('forum_threadimage')->delete_by_tid($tid); } $_G['forum_attachexist'] = $attachment; }
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0, $from = false) { global $_G, $space; if ($albumid < 0) { $albumid = 0; } $allowPicType = array('jpg', 'jpeg', 'gif', 'png'); if (!in_array($fileext, $allowPicType)) { return -3; } $setarr = array(); $upload = new discuz_upload(); $filepath = $upload->get_target_dir('album') . $upload->get_target_filename('album') . '.' . $fileext; $newfilename = $_G['setting']['attachdir'] . './album/' . $filepath; if ($handle = fopen($newfilename, 'wb')) { if (fwrite($handle, $strdata) !== FALSE) { fclose($handle); $size = filesize($newfilename); if (empty($space)) { $_G['member'] = $space = getuserbyuid($_G['uid']); $_G['username'] = $space['username']; } $_G['member'] = $space; loadcache('usergroup_' . $space['groupid']); $_G['group'] = $_G['cache']['usergroup_' . $space['groupid']]; $maxspacesize = checkperm('maxspacesize'); if ($maxspacesize) { space_merge($space, 'count'); space_merge($space, 'field_home'); if ($space['attachsize'] + $size - $delsize > $maxspacesize + $space['addsize'] * 1024 * 1024) { @unlink($newfilename); return -1; } } if (!$upload->get_image_info($newfilename)) { @unlink($newfilename); return -2; } require_once libfile('class/image'); $image = new image(); $result = $image->Thumb($newfilename, NULL, 140, 140, 1); $thumb = empty($result) ? 0 : 1; $image->Watermark($newfilename); $pic_remote = 0; $album_picflag = 1; if (getglobal('setting/ftp/on')) { $ftpresult_thumb = 0; $ftpresult = ftpcmd('upload', 'album/' . $filepath); if ($ftpresult) { @unlink($_G['setting']['attachdir'] . 'album/' . $filepath); if ($thumb) { $thumbpath = getimgthumbname($filepath); ftpcmd('upload', 'album/' . $thumbpath); @unlink($_G['setting']['attachdir'] . 'album/' . $thumbpath); } $pic_remote = 1; $album_picflag = 2; } else { if (getglobal('setting/ftp/mirror')) { @unlink($newfilename); @unlink(getimgthumbname($newfilename)); return -3; } } } $filename = $name ? $name : substr(strrchr($filepath, '/'), 1); $title = getstr($title, 200); $title = censor($title); if (censormod($title) || $_G['group']['allowuploadmod']) { $pic_status = 1; } else { $pic_status = 0; } if ($albumid) { $albumid = album_creat_by_id($albumid); } else { $albumid = 0; } $setarr = array('albumid' => $albumid, 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $_G['timestamp'], 'filename' => $filename, 'postip' => $_G['clientip'], 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb, 'remote' => $pic_remote, 'status' => $pic_status); $setarr['picid'] = C::t('home_pic')->insert($setarr, 1); C::t('common_member_count')->increase($_G['uid'], array('attachsize' => $size)); include_once libfile('function/stat'); updatestat('pic'); return $setarr; } else { fclose($handle); } } return -3; }
showsubmenu('imagepreview_thumb'); $sizesource = filesize(DISCUZ_ROOT . './static/image/admincp/watermarkpreview.jpg'); echo '<img src="data/attachment/temp/watermark_temp1.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes ' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget1) . ' Bytes (' . sprintf("%2.1f", $sizetarget1 / $sizesource * 100) . '%)<br /><br />'; echo '<img src="data/attachment/temp/watermark_temp2.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes ' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget2) . ' Bytes (' . sprintf("%2.1f", $sizetarget2 / $sizesource * 100) . '%)'; } else { cpmsg('imagepreview_errorcode_' . $r, '', 'error'); } } else { $type = $_GET['type']; if (!$_G['setting']['watermarkstatus'][$type]) { cpmsg('watermarkpreview_error', '', 'error'); } require_once libfile('class/image'); @unlink(DISCUZ_ROOT . './data/attachment/temp/watermark_temp3.jpg'); $image = new image(); if (!($r = $image->Watermark(DISCUZ_ROOT . './static/image/admincp/watermarkpreview.jpg', 'temp/watermark_temp3.jpg', $type))) { $r = $image->error(); } if ($r > 0) { showsubmenu('imagepreview_watermark'); $sizesource = filesize('static/image/admincp/watermarkpreview.jpg'); $sizetarget = $image->imginfo['size']; echo '<img src="data/attachment/temp/watermark_temp3.jpg?' . random(5) . '"><br /><br />' . $lang['imagepreview_imagesize_source'] . ' ' . number_format($sizesource) . ' Bytes ' . $lang['imagepreview_imagesize_target'] . ' ' . number_format($sizetarget) . ' Bytes (' . sprintf("%2.1f", $sizetarget / $sizesource * 100) . '%)'; } else { cpmsg('imagepreview_errorcode_' . $r, '', 'error'); } } } elseif ($operation == 'rewrite') { $rule = array(); $rewritedata = rewritedata(); $rule['{apache1}'] = $rule['{apache2}'] = $rule['{iis}'] = $rule['{iis7}'] = $rule['{zeus}'] = $rule['{nginx}'] = '';
function threadsort_insertfile($tid, &$files, $sortid, $edit = 0, $modidentifier, $channel) { global $_G; $allowtype = 'jpg, jpeg, gif, bmp, png'; $newfiles = $aid = array(); if (empty($tid)) { return; } if ($files['categoryimg']) { foreach ($files['categoryimg']['name'] as $key => $val) { $newfiles[$key]['name'] = $val; $newfiles[$key]['type'] = $files['categoryimg']['type'][$key]; $newfiles[$key]['tmp_name'] = $files['categoryimg']['tmp_name'][$key]; $newfiles[$key]['error'] = $files['categoryimg']['error'][$key]; $newfiles[$key]['size'] = $files['categoryimg']['size'][$key]; } } else { return; } require_once libfile('class/upload'); $upload = new discuz_upload(); $uploadtype = 'category'; if ($channel['imageinfo']['watermarkstatus']) { require_once libfile('class/house_image'); $image = new image($channel); } foreach ($newfiles as $key => $file) { if (!$upload->init($file, $uploadtype)) { continue; } if (!$upload->save()) { if (count($newfiles) == 1) { showmessage($upload->errormessage()); } } $newattach[$key] = $upload->attach['attachment']; if ($channel['imageinfo']['watermarkstatus']) { $image->Watermark($upload->attach['target']); } DB::query("INSERT INTO " . DB::table('category_' . $modidentifier . '_pic') . " (tid, url, dateline) VALUES ('{$tid}', '" . $upload->attach['attachment'] . "', '" . TIMESTAMP . "')"); $aid[$key] = DB::insert_id(); } $attachnum = $edit ? intval(DB::result_first("SELECT COUNT(*) FROM " . DB::table('category_' . $modidentifier . '_pic') . " WHERE tid='{$tid}'")) : intval(count($aid)); if (substr($_G['gp_coverpic'], 0, 4) == 'old_') { $newaid = substr($_G['gp_coverpic'], 4); } else { $_G['gp_coverpic'] = intval($_G['gp_coverpic']); if ($aid[$_G['gp_coverpic']]) { $newaid = $aid[$_G['gp_coverpic']]; } else { $aid = array_slice($aid, 0, 1); $newaid = $aid[0]; } } if (!empty($newaid)) { DB::query("UPDATE " . DB::table('category_sortvalue') . "{$sortid} SET attachid='{$newaid}', attachnum='{$attachnum}' WHERE tid='{$tid}'"); } }
function forum_upload() { global $_G; $this->uid = intval($_G['gp_uid']); $swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid); if (!$_FILES['Filedata']['error'] && $_G['gp_hash'] == $swfhash) { $this->aid = 0; $this->simple = !empty($_G['gp_simple']) ? $_G['gp_simple'] : 0; $_G['groupid'] = intval(DB::result_first("SELECT groupid FROM " . DB::table('common_member') . " WHERE uid='" . $this->uid . "'")); loadcache('usergroup_' . $_G['groupid']); $_G['group'] = $_G['cache']['usergroup_' . $_G['groupid']]; require_once libfile('class/upload'); $upload = new discuz_upload(); $upload->init($_FILES['Filedata'], 'forum'); $this->attach =& $upload->attach; if ($upload->error()) { $this->uploadmsg(2); } $allowupload = !$_G['group']['maxattachnum'] || $_G['group']['maxattachnum'] && $_G['group']['maxattachnum'] > DB::result_first("SELECT count(*) FROM " . DB::table('forum_attachment') . " WHERE uid='{$_G['uid']}' AND dateline>'{$_G['timestamp']}'-86400"); if (!$allowupload) { $this->uploadmsg(9); } if ($_G['group']['attachextensions'] && (!preg_match("/(^|\\s|,)" . preg_quote($upload->attach['ext'], '/') . "(\$|\\s|,)/i", $_G['group']['attachextensions']) || !$upload->attach['ext'])) { $this->uploadmsg(1); } if (empty($upload->attach['size'])) { $this->uploadmsg(2); } if ($_G['group']['maxattachsize'] && $upload->attach['size'] > $_G['group']['maxattachsize']) { $this->uploadmsg(3); } if ($type = DB::fetch_first("SELECT maxsize FROM " . DB::table('forum_attachtype') . " WHERE extension='" . addslashes($upload->attach['ext']) . "'")) { if ($type['maxsize'] == 0) { $this->uploadmsg(4); } elseif ($upload->attach['size'] > $type['maxsize']) { $this->uploadmsg(5); } } if ($upload->attach['size'] && $_G['group']['maxsizeperday']) { $todaysize = intval(DB::result_first("SELECT SUM(filesize) FROM " . DB::table('forum_attachment') . " WHERE uid='{$_G['uid']}' AND dateline>'{$_G['timestamp']}'-86400")); $todaysize += $upload->attach['size']; if ($todaysize >= $_G['group']['maxsizeperday']) { $this->uploadmsg(6); } } $upload->save(); if ($upload->error() == -103) { $this->uploadmsg(8); } elseif ($upload->error()) { $this->uploadmsg(9); } $thumb = $remote = $width = 0; if ($upload->attach['isimage']) { require_once libfile('class/image'); $image = new image(); $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0; $image->Watermark($upload->attach['target']); $width = $image->imginfo['width']; } if (!$this->simple) { $upload->attach['name'] = diconv($upload->attach['name'], 'utf-8'); } if ($_G['gp_type'] != 'image' && $upload->attach['isimage']) { $upload->attach['isimage'] = -1; } DB::query("INSERT INTO " . DB::table('forum_attachment') . " (tid, pid, dateline, readperm, price, filename, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote, width)\n\t\t\t\tVALUES ('0', '0', '{$_G['timestamp']}', '0', '0', '" . $upload->attach['name'] . "', '" . $upload->attach['type'] . "', '" . $upload->attach['size'] . "', '" . $upload->attach['attachment'] . "', '0', '" . $upload->attach['isimage'] . "', '" . $this->uid . "', '{$thumb}', '{$remote}', '{$width}')"); $this->aid = DB::insert_id(); $this->uploadmsg(0); } }
function updateattach($postattachcredits, $tid, $pid, $attachnew, $attachdel, $attachupdate = array(), $uid = 0) { global $_G; $uid = $uid ? $uid : $_G['uid']; $uidadd = $_G['forum']['ismoderator'] ? '' : " AND uid='{$uid}'"; $attachnum = $_G['group']['allowpostattach']; if ($attachnew) { $newaids = array_keys($attachnew); $newattach = $newattachfile = $albumattach = array(); $query = DB::query("SELECT aid, tid, attachment FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($newaids) . "){$uidadd}"); while ($attach = DB::fetch($query)) { if ($_G['group']['maxattachnum']) { if ($attachnum <= 0) { unset($attachnew[$attach['aid']]); continue; } else { $attachnum--; } } if (!$attach['tid']) { $newattach[$attach['aid']] = $attach['aid']; $newattachfile[$attach['aid']] = $attach['attachment']; } } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { require_once libfile('class/image'); $image = new image(); } if (!empty($_G['gp_albumaid'])) { array_unshift($_G['gp_albumaid'], ''); $_G['gp_albumaid'] = array_unique($_G['gp_albumaid']); unset($_G['gp_albumaid'][0]); $query = DB::query("SELECT * FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($_G['gp_albumaid']) . ")"); while ($attach = DB::fetch($query)) { $albumattach[$attach['aid']] = $attach; } } foreach ($attachnew as $aid => $attach) { $update = array('readperm' => $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0, 'price' => $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0, 'tid' => $tid, 'pid' => $pid, 'uid' => $uid); if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) && !empty($newattachfile[$aid])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum'); } if (!empty($_G['gp_albumaid']) && isset($albumattach[$aid])) { $newalbum = 0; if (!$_G['gp_uploadalbum']) { require_once libfile('function/spacecp'); $_G['gp_uploadalbum'] = album_creat(array('albumname' => $_G['gp_newalbum'])); $newalbum = 1; } $picdata = array('albumid' => $_G['gp_uploadalbum'], 'uid' => $_G['uid'], 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => $albumattach[$aid]['filename'], 'title' => $albumattach[$aid]['description'], 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2); $update['picid'] = DB::insert('home_pic', $picdata, 1); if ($newalbum) { require_once libfile('function/home'); require_once libfile('function/spacecp'); album_update_pic($_G['gp_uploadalbum']); } } DB::query("REPLACE INTO " . DB::table('forum_attachmentfield') . " (aid, tid, pid, uid, description) VALUES ('{$aid}', '{$tid}', '{$pid}', '{$uid}', '" . cutstr(dhtmlspecialchars($attach['description']), 100) . "')"); DB::update('forum_attachment', $update, "aid='{$aid}'{$uidadd}"); } if (!empty($_G['gp_albumaid'])) { $albumdata = array('picnum' => DB::result_first("SELECT count(*) FROM " . DB::table('home_pic') . " WHERE albumid='{$_G['gp_uploadalbum']}'"), 'updatetime' => $_G['timestamp']); DB::update('home_album', $albumdata, "albumid='{$_G['gp_uploadalbum']}'"); } if ($newattach) { ftpupload($newaids, $uid); } } $query = DB::query("SELECT aid, attachment, thumb, remote FROM " . DB::table('forum_attachment') . " WHERE uid='{$uid}'"); $delaids = array(); while ($attach = DB::fetch($query)) { $aids[] = $attach['aid']; if ($attachdel && in_array($attach['aid'], $attachdel)) { $delaids[] = $attach['aid']; unset($newattach[$attach['aid']]); dunlink($attach); } if ($attachupdate && array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) { dunlink($attach); } } if ($newattach && $uid == $_G['uid']) { updatecreditbyaction('postattach', $uid, array(), '', count($newattach)); } if ($attachupdate) { $uaids = dimplode($attachupdate); $query = DB::query("SELECT aid, width, filename, filetype, filesize, attachment, isimage, thumb, remote FROM " . DB::table('forum_attachment') . " WHERE aid IN ({$uaids}){$uidadd}"); DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE aid IN ({$uaids}){$uidadd}"); $attachupdate = array_flip($attachupdate); while ($attach = DB::fetch($query)) { $update = $attach; $update['dateline'] = TIMESTAMP; $update['remote'] = 0; unset($update['aid']); DB::update('forum_attachment', $update, "aid='" . $attachupdate[$attach['aid']] . "'{$uidadd}"); if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum'); } ftpupload(array($attachupdate[$attach['aid']]), $uid); } } if ($delaids) { DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($delaids) . ")", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE aid IN (" . dimplode($delaids) . ")", 'UNBUFFERED'); } $attachcount = DB::result_first("SELECT count(*) FROM " . DB::table('forum_attachment') . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : '')); $attachment = $attachcount ? DB::result_first("SELECT count(*) FROM " . DB::table('forum_attachment') . " WHERE tid='{$tid}'" . ($pid > 0 ? " AND pid='{$pid}'" : '') . " AND isimage != 0") ? 2 : 1 : 0; DB::query("UPDATE " . DB::table('forum_thread') . " SET attachment='{$attachment}' WHERE tid='{$tid}'", 'UNBUFFERED'); $posttable = getposttablebytid($tid); DB::query("UPDATE " . DB::table($posttable) . " SET attachment='{$attachment}' WHERE pid='{$pid}'", 'UNBUFFERED'); $_G['forum_attachexist'] = $attachment; }
$attach = $upload->attach; if (!$upload->error()) { $upload->save(); } if ($upload->error()) { portal_upload_error($upload->error()); } $attachs[] = $attach; } if ($attachs) { foreach ($attachs as $attach) { if ($attach['isimage']) { require_once libfile('class/image'); $image = new image(); $attach['thumb'] = $image->Thumb($attach['target'], '', '300', '300', 2); $image->Watermark($attach['target']); } if (getglobal('setting/ftp/on')) { if (ftpcmd('upload', 'portal/' . $attach['attachment'])) { if ($attach['thumb']) { ftpcmd('upload', 'portal/' . $attach['attachment'] . '.thumb.jpg'); } $attach['remote'] = 1; } else { if (getglobal('setting/ftp/mirror')) { @unlink($attach['target']); @unlink($attach['target'] . '.thumb.jpg'); portal_upload_error(lang('portalcp', 'upload_remote_failed')); } } }
function forum_downremotefile($arr, $old_arr) { global $_G; $evo_img_no = $_G['cache']['evn_milu_pick']['evo_img_no']; $config = get_pick_set(); $get_file_ext_arr = $config['get_file_ext'] ? explode('|', $config['get_file_ext']) : array(); $arr['is_download_file'] = $arr['is_download_file'] ? $arr['is_download_file'] : $arr['p_arr']['is_download_file']; $arr['message'] = dstripslashes($arr['content']); //print_r($arr); //$arr['message'] = str_replace(array("\r", "\n"), array($_GET['wysiwyg'] ? '<br />' : '', "\\n"), $arr['message']); preg_match_all("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $arr['message'], $image1, PREG_SET_ORDER); //preg_match_all("/\<img.+src=('|\"|)?(.*)(\\1)([\s].*)?\>/ismUe", $arr['message'], $image2, PREG_SET_ORDER); preg_match_all("/\\<img.+src=('|\"|)?(.*)(\\1)(.*)?\\>/isU", $arr['message'], $image2, PREG_SET_ORDER); $temp = $aids = $existentimg = $attach_arr = array(); if (is_array($image1) && !empty($image1)) { foreach ($image1 as $value) { $v = trim(!empty($value[1]) ? $value[1] : $value[2]); $no_remote = 0; if (!filter_something($v, $evo_img_no)) { //存在 $no_remote = 1; } if ($no_remote == 0) { $temp[] = array('0' => $value[0], '1' => $v); } } } if (is_array($image2) && !empty($image2)) { foreach ($image2 as $v) { $no_remote = 0; $v[2] = trim(strip_tags($v[2])); if (!filter_something($v[2], $evo_img_no)) { //存在 $no_remote = 1; } if ($no_remote == 0) { $temp[] = array('0' => $v[0], '1' => $v[2]); } } } if ($arr['is_download_file'] == 1) { $attach_arr = get_attach_data($arr['page_url'], $arr['message']); } $attach_arr = $attach_arr ? $attach_arr : array(); $temp = $temp ? $temp : array(); $temp = array_merge($temp, $attach_arr); //if(VIP) $arr['message'] = post($arr['message'], array('cookie' => $arr['cookie'], 'page_url' => $arr['page_url'], 'cid' => $arr['cid'])); $del_a = 0; if ($arr['content_filter_html'][0] == 0 && $arr['content_filter_html']) { $del_a = 1; } //print_r($arr['message']);exit(); require_once libfile('class/image'); if (is_array($temp) && !empty($temp)) { if (file_exists(libfile('class/upload'))) { require_once libfile('class/upload'); } else { require_once libfile('discuz/upload', 'class'); } $upload = new discuz_upload(); $attachaids = array(); $threadimage_flag = 0; $content_md5_arr = array(); foreach ($temp as $key => $value) { $snoopy_args['cookie'] = $arr['cookie']; $snoop_obj = get_snoopy_obj($snoopy_args); $imageurl = $value[1]; $hash = md5($imageurl); if (strlen($imageurl)) { $imagereplace['oldimageurl'][] = $value[0]; if (!isset($existentimg[$hash])) { $existentimg[$hash] = $imageurl; $attach['ext'] = $upload->fileext($imageurl); if ($upload->is_image_ext($attach['ext']) == 1 && $arr['is_download_img'] != 1) { $imagereplace['newimageurl'][] = $value[0]; continue; } if (!$upload->is_image_ext($attach['ext'])) { $ext = 'no_get'; } if (preg_match('/^(http:\\/\\/|\\.)/i', $imageurl)) { if ($imageurl && snoop_obj) { $content_re = get_img_content($imageurl, $snoop_obj, $ext); } if (is_array($content_re)) { $content = $content_re['content']; $file_name = $attach['name'] = $content_re['file_name'] ? $content_re['file_name'] : ($value[2] ? _striptext($value[2]) : time() . '.' . $content_re['file_ext']); $attach['ext'] = $content_re['file_ext'] ? $content_re['file_ext'] : trim($upload->fileext($file_name)); $file_name = $attach['name'] = $file_name; } else { $content = $content_re; } if (in_array(md5($content), $content_md5_arr)) { $imagereplace['newimageurl'][] = ''; continue; } $content_md5_arr[] = md5($content); } elseif (preg_match('/^(' . preg_quote(getglobal('setting/attachurl'), '/') . ')/i', $imageurl)) { $imagereplace['newimageurl'][] = $value[0]; } if (empty($content)) { if ($value[4] == 1) { if ($del_a == 1) { $imagereplace['newimageurl'][] = $value[2]; } else { unset($imagereplace['oldimageurl'][$key]); } } else { $imagereplace['newimageurl'][] = ''; } continue; } if (!$attach['name']) { $patharr = explode('/', $imageurl); $attach['name'] = trim($patharr[count($patharr) - 1]); } $patharr = explode('/', $imageurl); if (!$attach['name']) { $attach['name'] = trim($patharr[count($patharr) - 1]); } $attach['thumb'] = ''; $attach['ext'] = trim($attach['ext']); //不加这个有些还真不行 $attach['isimage'] = $upload->is_image_ext($attach['ext']); if ($attach['isimage'] == 1 && $arr['is_download_img'] != 1) { $imagereplace['newimageurl'][] = $value[0]; continue; } $attach['extension'] = $upload->get_target_extension($attach['ext']); $attach['attachdir'] = $upload->get_target_dir('forum'); $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum') . '.' . $attach['extension']; $attach['target'] = getglobal('setting/attachdir') . './forum/' . $attach['attachment']; if (!in_array($attach['ext'], $get_file_ext_arr) && $get_file_ext_arr && $attach['isimage'] == 0) { if ($value[4] == 1) { if ($del_a == 1) { $imagereplace['newimageurl'][] = $value[2]; } else { unset($imagereplace['oldimageurl'][$key]); } } else { $imagereplace['newimageurl'][] = ''; } continue; } if (!@($fp = fopen($attach['target'], 'wb'))) { continue; } else { flock($fp, 2); fwrite($fp, $content); fclose($fp); } if (!$upload->get_image_info($attach['target']) && $attach['isimage'] == 1) { @unlink($attach['target']); continue; } $attach['size'] = filesize($attach['target']); $upload->attach = $attach; $thumb = $width = 0; if ($upload->attach['isimage']) { if ($_G['setting']['thumbstatus']) { $image = new image(); $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0; $width = $image->imginfo['width']; } if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) { list($width) = @getimagesize($upload->attach['target']); } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) && $arr['is_water_img'] == 1) { $image = new image(); $image->Watermark($attach['target'], '', 'forum'); } } $desc = $value[3]; $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $arr['dateline']; $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $_G['timestamp']; $remote = 0; $setarr = array('uid' => $arr['uid'], 'tid' => $arr['tid'], 'pid' => $arr['pid'], 'filename' => daddslashes($upload->attach['name']), 'attachment' => $upload->attach['attachment'], 'filesize' => $upload->attach['size'], 'thumb' => $thumb, 'remote' => $remote, 'picid' => $picid, 'isimage' => $attach['isimage'], 'description' => $desc, 'readperm' => 0, 'price' => 0, 'width' => $width, 'dateline' => $arr['public_time']); $setimg_arr = array('tid' => $arr['tid'], 'attachment' => $upload->attach['attachment'], 'remote' => $remote); $set_att = array('downloads' => rand(1, 15), 'tableid' => getattachtableid($arr['tid']), 'uid' => $arr['uid'], 'pid' => $arr['pid'], 'tid' => $arr['tid']); if ($threadimage_flag == 0 && !$arr['is_post'] && $attach['isimage'] == 1) { DB::insert('forum_threadimage', $setimg_arr, true); $threadimage_flag = 1; } $setarr['aid'] = $newaids[] = DB::insert('forum_attachment', $set_att, true); $at[] = $setarr['aid']; $attachnew_arr[$setarr['aid']] = array('description' => $setarr['description']); DB::insert(getattachtablebytid($arr['tid']), $setarr, true); $attachaids[$hash] = $imagereplace['newimageurl'][] = '[attach]' . $setarr['aid'] . '[/attach]'; } else { $imagereplace['newimageurl'][] = $attachaids[$hash]; } } } if ($_G['setting']['ftp']['on'] == 1) { require_once libfile('function/post'); ftpupload($newaids, $arr['uid']); } if (count($at) > 0) { $arr['attachment'] = 2; } $arr['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $arr['message']); if ($del_a == 1) { $arr['message'] = clear_html_script($arr['message'], array(0)); } forum_article_content($arr); } }