public function clear() { require_once libfile('function/forum'); $deltids = array(); $query = DB::query("SELECT tid, attachment, thumb FROM %t WHERE tid=0 AND dateline<=%d", array($this->_table, TIMESTAMP - 86400)); while ($attach = DB::fetch($query)) { dunlink($attach); $deltids[] = $attach['tid']; } if ($deltids) { $this->delete_by_tid($deltids); } }
public function clear() { require_once libfile('function/forum'); $delaids = array(); $query = XDB::query("SELECT aid, attachment, thumb FROM %t WHERE %i", array($this->_table, XDB::field('dateline', TIMESTAMP - 86400))); while ($attach = XDB::fetch($query)) { dunlink($attach); $delaids[] = $attach['aid']; } if ($delaids) { XDB::query("DELETE FROM %t WHERE %i", array('forum_attachment', XDB::field('aid', $delaids)), false, true); XDB::query("DELETE FROM %t WHERE %i", array($this->_table, XDB::field('dateline', TIMESTAMP - 86400)), false, true); } }
$membernum = C::t('forum_post')->count_author_by_tid($tid); showmessage('thread_reshreply_membernum', '', array('membernum' => intval($membernum - 1)), array('alert' => 'info')); } dexit(); } elseif ($_GET['action'] == 'deleteattach') { $count = 0; if ($_GET['aids']) { foreach ($_GET['aids'] as $aid) { $attach = C::t('forum_attachment_n')->fetch('aid:' . $aid, $aid); if ($attach && ($attach['pid'] && $attach['pid'] == $_GET['pid'] && $_G['uid'] == $attach['uid'])) { updatecreditbyaction('postattach', $attach['uid'], array(), '', -1, 1, $_G['fid']); } if ($attach && ($attach['pid'] && $attach['pid'] == $_GET['pid'] && $_G['uid'] == $attach['uid'] || $_G['forum']['ismoderator'] || !$attach['pid'] && $_G['uid'] == $attach['uid'])) { C::t('forum_attachment_n')->delete('aid:' . $aid, $aid); C::t('forum_attachment')->delete($aid); dunlink($attach); $count++; } } } include template('common/header_ajax'); echo $count; include template('common/footer_ajax'); dexit(); } elseif ($_GET['action'] == 'secondgroup') { require_once libfile('function/group'); $groupselect = get_groupselect($_GET['fupid'], $_GET['groupid']); include template('common/header_ajax'); include template('forum/ajax_secondgroup'); include template('common/footer_ajax'); dexit();
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; }
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; }
public function before_editpost($parameters) { global $_G; $sortid = $parameters['sortid']; $isfirstpost = $this->post['first'] ? 1 : 0; if ($isfirstpost) { $parameters['typeid'] = isset($this->forum['threadtypes']['types'][$parameters['typeid']]) ? $parameters['typeid'] : 0; if (!$this->forum['ismoderator'] && !empty($this->forum['threadtypes']['moderators'][$this->thread['typeid']])) { $parameters['typeid'] = $this->thread['typeid']; } $parameters['sortid'] = isset($this->forum['threadsorts']['types'][$parameters['sortid']]) ? $parameters['sortid'] : 0; $typeexpiration = intval($_GET['typeexpiration']); if (!$parameters['typeid'] && $this->forum['threadtypes']['required'] && !$this->thread['special']) { showmessage('post_type_isnull'); } if ($this->forum['threadsorts']['types'][$sortid] && $_G['forum_checkoption']) { $_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $this->post['pid']); } $this->param['threadimageaid'] = 0; $this->param['threadimage'] = array(); if ($this->forum['threadsorts']['types'][$parameters['sortid']] && $_G['forum_optiondata'] && is_array($_G['forum_optiondata'])) { $sql = $separator = $filedname = $valuelist = ''; foreach ($_G['forum_optiondata'] as $optionid => $value) { $value = censor(daddslashes($value)); if ($_G['forum_optionlist'][$optionid]['type'] == 'image') { $identifier = $_G['forum_optionlist'][$optionid]['identifier']; $newsortaid = intval($_GET['typeoption'][$identifier]['aid']); if ($newsortaid && $_GET['oldsortaid'][$identifier] && $newsortaid != $_GET['oldsortaid'][$identifier]) { $attach = C::t('forum_attachment_n')->fetch('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]); C::t('forum_attachment')->delete($_GET['oldsortaid'][$identifier]); C::t('forum_attachment_n')->delete('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]); dunlink($attach); $this->param['threadimageaid'] = $newsortaid; convertunusedattach($newsortaid, $this->thread['tid'], $this->post['pid']); } } else { if ($_G['forum_optionlist'][$optionid]['type'] == 'face') { $identifier = $_G['forum_optionlist'][$optionid]['identifier']; $newsortaid = intval($_GET['typeoption'][$identifier]['aid']); if ($newsortaid && $_GET['oldsortaid'][$identifier] && $newsortaid != $_GET['oldsortaid'][$identifier]) { $attach = C::t('forum_attachment_n')->fetch('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]); C::t('forum_attachment')->delete($_GET['oldsortaid'][$identifier]); C::t('forum_attachment_n')->delete('tid:' . $this->thread['tid'], $_GET['oldsortaid'][$identifier]); dunlink($attach); $this->param['threadimageaid'] = $newsortaid; convertunusedattach($newsortaid, $this->thread['tid'], $this->post['pid']); } } } if ($_G['forum_optionlist'][$optionid]['unchangeable']) { continue; } if (($_G['forum_optionlist'][$optionid]['search'] || in_array($_G['forum_optionlist'][$optionid]['type'], array('radio', 'select', 'number'))) && $value) { $filedname .= $separator . $_G['forum_optionlist'][$optionid]['identifier']; $valuelist .= $separator . "'{$value}'"; $sql .= $separator . $_G['forum_optionlist'][$optionid]['identifier'] . "='{$value}'"; $separator = ' ,'; } C::t('forum_typeoptionvar')->update_by_tid($this->thread['tid'], array('value' => $value, 'sortid' => $parameters['sortid']), false, false, $optionid); } if ($typeexpiration) { C::t('forum_typeoptionvar')->update_by_tid($this->thread['tid'], array('expiration' => TIMESTAMP + $typeexpiration), false, false, null, $parameters['sortid']); } if ($sql || $filedname && $valuelist) { if (C::t('forum_optionvalue')->fetch_all_tid($parameters['sortid'], "WHERE tid='" . $this->thread['tid'] . "'")) { if ($sql) { C::t('forum_optionvalue')->update($parameters['sortid'], $this->thread['tid'], $this->forum['fid'], $sql); } } elseif ($filedname && $valuelist) { C::t('forum_optionvalue')->insert($parameters['sortid'], "({$filedname}, tid, fid) VALUES ({$valuelist}, '" . $this->thread['tid'] . "', '" . $this->forum['fid'] . "')"); } } } } }
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}'"; if ($attachnew) { $newaids = array_keys($attachnew); $newattach = array(); $query = DB::query("SELECT aid, tid FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($newaids) . "){$uidadd}"); while ($attach = DB::fetch($query)) { !$attach['tid'] && ($newattach[] = $attach['aid']); } 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); DB::update('forum_attachment', $update, "aid='{$aid}'{$uidadd}"); DB::query("REPLACE INTO " . DB::table('forum_attachmentfield') . " (aid, tid, pid, uid, description) VALUES ('{$aid}', '{$tid}', '{$pid}', '{$uid}', '" . cutstr(dhtmlspecialchars($attach['description']), 100) . "')"); } if ($newattach) { if ($uid == $_G['uid']) { updatecreditbyaction('postattach', $uid, array(), '', count($newattach)); } ftpupload($newaids, $uid); } } $query = DB::query("SELECT aid, attachment, thumb FROM " . DB::table('forum_attachment') . " WHERE 1{$uidadd}"); $delaids = array(); while ($attach = DB::fetch($query)) { $aids[] = $attach['aid']; if ($attachdel && in_array($attach['aid'], $attachdel)) { $delaids[] = $attach['aid']; dunlink($attach); } if ($attachupdate && array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) { dunlink($attach); } } 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; unset($update['aid']); DB::update('forum_attachment', $update, "aid='" . $attachupdate[$attach['aid']] . "'{$uidadd}"); } } 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; }
function deleteattach($ids, $idtype = 'aid') { global $_G; if (!$ids || !in_array($idtype, array('authorid', 'uid', 'tid', 'pid'))) { return; } $idtype = $idtype == 'authorid' ? 'uid' : $idtype; $pics = $attachtables = array(); foreach (C::t('forum_attachment')->fetch_all_by_id($idtype, $ids) as $attach) { $attachtables[$attach['tableid']][] = $attach['aid']; } foreach ($attachtables as $attachtable => $aids) { if ($attachtable == 127) { continue; } $attachs = C::t('forum_attachment_n')->fetch_all($attachtable, $aids); foreach ($attachs as $attach) { if ($attach['picid']) { $pics[] = $attach['picid']; } dunlink($attach); } C::t('forum_attachment_exif')->delete($aids); C::t('forum_attachment_n')->delete($attachtable, $aids); } C::t('forum_attachment')->delete_by_id($idtype, $ids); if ($pics) { $albumids = array(); C::t('home_pic')->delete($pics); $query = C::t('home_pic')->fetch_all($pics); foreach ($query as $album) { if (!in_array($album['albumid'], $albumids)) { C::t('home_album')->update($album['albumid'], array('picnum' => C::t('home_pic')->check_albumpic($album['albumid']))); $albumids[] = $album['albumid']; } } } }
function deletethreads($tids = array()) { global $_G; static $cleartable = array('forum_threadmod', 'forum_relatedthread', 'forum_post', 'forum_poll', 'forum_polloption', 'forum_trade', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_attachment', 'forum_typeoptionvar', 'forum_forumrecommend', 'forum_postposition'); foreach ($tids as $tid) { my_thread_log('delete', array('tid' => $tid)); } $threadsdel = 0; if ($tids = dimplode($tids)) { $auidarray = array(); $query = DB::query("SELECT uid, attachment, dateline, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE tid IN ({$tids})"); while ($attach = DB::fetch($query)) { dunlink($attach); if ($attach['dateline'] > $_G['setting']['losslessdel']) { $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1; } } if ($auidarray) { updateattachcredits('-', $auidarray, $_G['setting']['creditspolicy']['postattach']); } require_once libfile('function/delete'); foreach ($cleartable as $tb) { if ($tb == 'forum_post') { deletepost("tid IN ({$tids})"); continue; } DB::query("DELETE FROM " . DB::table($tb) . " WHERE tid IN ({$tids})", 'UNBUFFERED'); } DB::query("DELETE FROM " . DB::table('forum_thread') . " WHERE tid IN ({$tids})"); $threadsdel = DB::affected_rows(); } return $threadsdel; }
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; }
function deleteattach($ids, $idtype = 'aid') { global $_G; if (!$ids || !in_array($idtype, array('authorid', 'uid', 'tid', 'pid'))) { return; } $idtype = $idtype == 'authorid' ? 'uid' : $idtype; $ids = dimplode($ids); $pics = $attachtables = array(); $query = DB::query("SELECT aid, tableid FROM " . DB::table('forum_attachment') . " WHERE {$idtype} IN ({$ids}) AND pid>0"); while ($attach = DB::fetch($query)) { $attachtables[$attach['tableid']][] = $attach['aid']; } foreach ($attachtables as $attachtable => $aids) { if ($attachtable == 127) { continue; } $attachtable = 'forum_attachment_' . $attachtable; $aids = dimplode($aids); $query = DB::query("SELECT attachment, thumb, remote, aid, picid FROM " . DB::table($attachtable) . " WHERE aid IN ({$aids}) AND pid>0"); while ($attach = DB::fetch($query)) { if ($attach['picid']) { $pics[] = $attach['picid']; } dunlink($attach); } DB::delete($attachtable, "aid IN ({$aids}) AND pid>0"); } DB::delete('forum_attachment', "{$idtype} IN ({$ids}) AND pid>0"); if ($pics) { $albumids = array(); $query = DB::query("SELECT albumid FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($pics) . ") GROUP BY albumid"); DB::delete('home_pic', 'picid IN (' . dimplode($pics) . ')', 0); while ($album = DB::fetch($query)) { DB::update('home_album', array('picnum' => getcount('home_pic', array('albumid' => $album['albumid']))), array('albumid' => $album['albumid'])); } } }
public function before_editpost($parameters) { $isfirstpost = $this->post['first'] ? 1 : 0; if ($isfirstpost) { if ($this->thread['special'] == 4 && $this->group['allowpostactivity']) { $activitytime = intval($_GET['activitytime']); if (empty($_GET['starttimefrom'][$activitytime])) { showmessage('activity_fromtime_please'); } elseif (strtotime($_GET['starttimefrom'][$activitytime]) === -1 || @strtotime($_GET['starttimefrom'][$activitytime]) === FALSE) { showmessage('activity_fromtime_error'); } elseif ($activitytime && (@strtotime($_GET['starttimefrom']) > @strtotime($_GET['starttimeto']) || !$_GET['starttimeto'])) { showmessage('activity_fromtime_error'); } elseif (!trim($_GET['activityclass'])) { showmessage('activity_sort_please'); } elseif (!trim($_GET['activityplace'])) { showmessage('activity_address_please'); } elseif (trim($_GET['activityexpiration']) && (@strtotime($_GET['activityexpiration']) === -1 || @strtotime($_GET['activityexpiration']) === FALSE)) { showmessage('activity_totime_error'); } $activity = array(); $activity['class'] = censor(dhtmlspecialchars(trim($_GET['activityclass']))); $activity['starttimefrom'] = @strtotime($_GET['starttimefrom'][$activitytime]); $activity['starttimeto'] = $activitytime ? @strtotime($_GET['starttimeto']) : 0; $activity['place'] = censor(dhtmlspecialchars(trim($_GET['activityplace']))); $activity['cost'] = intval($_GET['cost']); $activity['gender'] = intval($_GET['gender']); $activity['number'] = intval($_GET['activitynumber']); if ($_GET['activityexpiration']) { $activity['expiration'] = @strtotime($_GET['activityexpiration']); } else { $activity['expiration'] = 0; } $extfield = $_GET['extfield']; $extfield = explode("\n", $_GET['extfield']); foreach ($extfield as $key => $value) { $extfield[$key] = censor(trim($value)); if ($extfield[$key] === '' || is_numeric($extfield[$key])) { unset($extfield[$key]); } } $extfield = array_unique($extfield); if (count($extfield) > $this->setting['activityextnum']) { showmessage('post_activity_extfield_toomany', '', array('maxextfield' => $this->setting['activityextnum'])); } $activity['ufield'] = array('userfield' => $_GET['userfield'], 'extfield' => $extfield); $activity['ufield'] = serialize($activity['ufield']); if (intval($_GET['activitycredit']) > 0) { $activity['credit'] = intval($_GET['activitycredit']); } $data = array('cost' => $activity['cost'], 'starttimefrom' => $activity['starttimefrom'], 'starttimeto' => $activity['starttimeto'], 'place' => $activity['place'], 'class' => $activity['class'], 'gender' => $activity['gender'], 'number' => $activity['number'], 'expiration' => $activity['expiration'], 'ufield' => $activity['ufield'], 'credit' => $activity['credit']); C::t('forum_activity')->update($this->thread['tid'], $data); } } if ($parameters['special'] == 4 && $isfirstpost && $this->group['allowpostactivity']) { $activity = C::t('forum_activity')->fetch($this->thread['tid']); $activityaid = $activity['aid']; if ($activityaid && $activityaid != $_GET['activityaid']) { $attach = C::t('forum_attachment_n')->fetch('tid:' . $this->thread['tid'], $activityaid); C::t('forum_attachment')->delete($activityaid); C::t('forum_attachment_n')->delete('tid:' . $this->thread['tid'], $activityaid); dunlink($attach); } if ($_GET['activityaid']) { $threadimageaid = $_GET['activityaid']; convertunusedattach($_GET['activityaid'], $this->thread['tid'], $this->post['pid']); C::t('forum_activity')->update($this->thread['tid'], array('aid' => $_GET['activityaid'])); } } }
public function before_editpost($parameters) { global $closed; if ($parameters['special'] == 2 && $this->group['allowposttrade']) { if ($trade = C::t('forum_trade')->fetch_goods($this->thread['tid'], $this->post['pid'])) { $seller = empty($_GET['paymethod']) && $_GET['seller'] ? censor(dhtmlspecialchars(trim($_GET['seller']))) : ''; $item_name = censor(dhtmlspecialchars(trim($_GET['item_name']))); $item_price = floatval($_GET['item_price']); $item_credit = intval($_GET['item_credit']); $item_locus = censor(dhtmlspecialchars(trim($_GET['item_locus']))); $item_number = intval($_GET['item_number']); $item_quality = intval($_GET['item_quality']); $item_transport = intval($_GET['item_transport']); $postage_mail = intval($_GET['postage_mail']); $postage_express = intval(trim($_GET['postage_express'])); $postage_ems = intval($_GET['postage_ems']); $item_type = intval($_GET['item_type']); $item_costprice = floatval($_GET['item_costprice']); if (!trim($item_name)) { showmessage('trade_please_name'); } elseif ($this->group['maxtradeprice'] && $item_price > 0 && ($this->group['mintradeprice'] > $item_price || $this->group['maxtradeprice'] < $item_price)) { showmessage('trade_price_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice'])); } elseif ($this->group['maxtradeprice'] && $item_credit > 0 && ($this->group['mintradeprice'] > $item_credit || $this->group['maxtradeprice'] < $item_credit)) { showmessage('trade_credit_between', '', array('mintradeprice' => $this->group['mintradeprice'], 'maxtradeprice' => $this->group['maxtradeprice'])); } elseif (!$this->group['maxtradeprice'] && $item_price > 0 && $this->group['mintradeprice'] > $item_price) { showmessage('trade_price_more_than', '', array('mintradeprice' => $this->group['mintradeprice'])); } elseif (!$this->group['maxtradeprice'] && $item_credit > 0 && $this->group['mintradeprice'] > $item_credit) { showmessage('trade_credit_more_than', '', array('mintradeprice' => $this->group['mintradeprice'])); } elseif ($item_price <= 0 && $item_credit <= 0) { showmessage('trade_pricecredit_need'); } elseif ($item_number < 1) { showmessage('tread_please_number'); } if ($trade['aid'] && $_GET['tradeaid'] && $trade['aid'] != $_GET['tradeaid']) { $attach = C::t('forum_attachment_n')->fetch('tid:' . $this->thread['tid'], $trade['aid']); C::t('forum_attachment')->delete($trade['aid']); C::t('forum_attachment_n')->delete('tid:' . $this->thread['tid'], $trade['aid']); dunlink($attach); $this->param['threadimageaid'] = $_GET['tradeaid']; convertunusedattach($_GET['tradeaid'], $this->thread['tid'], $this->post['pid']); } $expiration = $_GET['item_expiration'] ? @strtotime($_GET['item_expiration']) : 0; $closed = $expiration > 0 && @strtotime($_GET['item_expiration']) < TIMESTAMP ? 1 : $closed; switch ($_GET['transport']) { case 'seller': $item_transport = 1; break; case 'buyer': $item_transport = 2; break; case 'virtual': $item_transport = 3; break; case 'logistics': $item_transport = 4; break; } if (!$item_price || $item_price <= 0) { $item_price = $postage_mail = $postage_express = $postage_ems = ''; } $data = array('aid' => $_GET['tradeaid'], 'account' => $seller, 'tenpayaccount' => $_GET['tenpay_account'], 'subject' => $item_name, 'price' => $item_price, 'amount' => $item_number, 'quality' => $item_quality, 'locus' => $item_locus, 'transport' => $item_transport, 'ordinaryfee' => $postage_mail, 'expressfee' => $postage_express, 'emsfee' => $postage_ems, 'itemtype' => $item_type, 'expiration' => $expiration, 'closed' => $closed, 'costprice' => $item_costprice, 'credit' => $item_credit, 'costcredit' => $_GET['item_costcredit']); C::t('forum_trade')->update($this->thread['tid'], $this->post['pid'], $data); if (!empty($_GET['infloat'])) { $viewpid = C::t('forum_post')->fetch_threadpost_by_tid_invisible($this->thread['tid']); $viewpid = $viewpid['pid']; $this->param['redirecturl'] = "forum.php?mod=viewthread&tid=" . $this->thread['tid'] . "&viewpid={$viewpid}#pid{$viewpid}"; } else { $this->param['redirecturl'] = "forum.php?mod=viewthread&do=tradeinfo&tid=" . $this->thread['tid'] . "&pid=" . $this->post['pid']; } } } }
function updateswfattach() { global $db, $tablepre, $attachsave, $attachdir, $discuz_uid, $postattachcredits, $tid, $pid, $swfattachnew, $swfattachdel, $allowsetattachperm, $maxprice, $updateswfattach, $watermarkstatus; $imageexists = 0; $swfattachnew = (array) $swfattachnew; $query = $db->query("SELECT * FROM {$tablepre}attachments WHERE tid='0' AND pid='0' AND uid='{$discuz_uid}'"); if ($db->num_rows($query) && $updateswfattach) { $swfattachcount = 0; $delaids = array(); while ($swfattach = $db->fetch_array($query)) { if (in_array($swfattach['aid'], $swfattachdel)) { dunlink($swfattach['attachment'], $swfattach['thumb']); $delaids[] = $swfattach['aid']; continue; } $extension = strtolower(fileext($swfattach['filename'])); $attach_basename = basename($swfattach['attachment']); $attach_src = $attachdir . '/' . $swfattach['attachment']; if ($attachsave) { switch ($attachsave) { case 1: $attach_subdir = 'forumid_' . $GLOBALS['fid']; break; case 2: $attach_subdir = 'ext_' . $extension; break; case 3: $attach_subdir = 'month_' . date('ym'); break; case 4: $attach_subdir = 'day_' . date('ymd'); break; } $attach_descdir = $attachdir . '/' . $attach_subdir; $swfattachnew[$swfattach['aid']]['attachment'] = $attach_subdir . '/' . $attach_basename; } else { $attach_descdir = $attachdir; $swfattachnew[$swfattach['aid']]['attachment'] = $attach_basename; } $swfattachnew[$swfattach['aid']]['thumb'] = $swfattach['thumb']; $attach_desc = $attach_descdir . '/' . $attach_basename; if ($swfattach['isimage'] && $watermarkstatus) { require_once DISCUZ_ROOT . './include/image.class.php'; $image = new Image($attach_src, $swfattach); if ($image->imagecreatefromfunc && $image->imagefunc) { $image->Watermark(); $swfattach = $image->attach; } } if (!is_dir($attach_descdir)) { @mkdir($attach_descdir, 0777); @fclose(fopen($attach_descdir . '/index.htm', 'w')); } if ($swfattach['thumb'] == 1) { if (!@rename($attach_src . '.thumb.jpg', $attach_desc . '.thumb.jpg') && @copy($attach_src . '.thumb.jpg', $attach_desc . '.thumb.jpg')) { @unlink($attach_src . '.thumb.jpg'); } } if (!@rename($attach_src, $attach_desc) && @copy($attach_src, $attach_desc)) { @unlink($attach_src); } if ($swfattach['isimage']) { $imageexists = 1; } $attachnew = $swfattachnew[$swfattach['aid']]; $attachnew['remote'] = ftpupload($attach_desc, $attachnew); $attachnew['perm'] = $allowsetattachperm ? $attachnew['perm'] : 0; $attachnew['description'] = cutstr(dhtmlspecialchars($attachnew['description']), 100); $attachnew['price'] = $maxprice ? intval($attachnew['price']) <= $maxprice ? intval($attachnew['price']) : $maxprice : 0; $db->query("UPDATE {$tablepre}attachments SET tid='{$tid}', pid='{$pid}', attachment='{$attachnew['attachment']}', description='{$attachnew['description']}', readperm='{$attachnew['readperm']}', price='{$attachnew['price']}', remote='{$attachnew['remote']}' WHERE aid='{$swfattach['aid']}'"); $swfattachcount++; } if ($delaids) { $db->query("DELETE FROM {$tablepre}attachments WHERE aid IN (" . implodeids($delaids) . ")", 'UNBUFFERED'); } $attachment = $imageexists ? 2 : 1; if ($swfattachcount) { $db->query("UPDATE {$tablepre}threads SET attachment='{$attachment}' WHERE tid='{$tid}'", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}posts SET attachment='{$attachment}' WHERE pid='{$pid}'", 'UNBUFFERED'); updatecredits($discuz_uid, $postattachcredits, $swfattachcount); } } }
public function before_deletepost($parameters) { $thread_attachment = $post_attachment = 0; foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $this->thread['tid'], 'tid', $this->thread['tid']) as $attach) { if ($attach['pid'] == $this->post['pid']) { if ($this->thread['displayorder'] >= 0) { $post_attachment++; } dunlink($attach); } else { $thread_attachment = 1; } } $this->param['updatefieldarr']['attachment'] = array($thread_attachment); if ($post_attachment) { C::t('forum_attachment')->delete_by_id('pid', $this->post['pid']); DB::query("DELETE FROM " . DB::table(getattachtablebytid($this->thread['tid'])) . " WHERE pid='" . $this->post['pid'] . "'", 'UNBUFFEREED'); updatecreditbyaction('postattach', $this->post['authorid'], array(), '', -$post_attachment); } }
function deletethreads($tids = array()) { global $db, $tablepre, $losslessdel, $creditspolicy; static $cleartable = array('threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'videos', 'debateposts', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions', 'typeoptionvars', 'forumrecommend'); $threadsdel = 0; if ($tids = implodeids($tids)) { $auidarray = array(); $query = $db->query("SELECT uid, attachment, dateline, thumb, remote FROM {$tablepre}attachments WHERE tid IN ({$tids})"); while ($attach = $db->fetch_array($query)) { dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); if ($attach['dateline'] > $losslessdel) { $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1; } } if ($auidarray) { updateattachcredits('-', $auidarray, $creditspolicy['postattach']); } $videoopen && videodelete($moderate, TRUE); foreach ($cleartable as $tb) { $db->query("DELETE FROM {$tablepre}{$tb} WHERE tid IN ({$tids})", 'UNBUFFERED'); } $db->query("DELETE FROM {$tablepre}threads WHERE tid IN ({$tids})"); $threadsdel = $db->affected_rows(); } return $threadsdel; }
function deleteattach($condition, $unbuffered = true) { $pics = array(); $query = DB::query("SELECT attachment, thumb, remote, aid, picid FROM " . DB::table('forum_attachment') . " WHERE {$condition} AND pid>0"); while ($attach = DB::fetch($query)) { if ($attach['picid']) { $pics[] = $attach['picid']; } dunlink($attach); } if ($pics) { $albumids = array(); $query = DB::query("SELECT albumid FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($pics) . ") GROUP BY albumid"); DB::delete('home_pic', 'picid IN (' . dimplode($pics) . ')', 0); while ($album = DB::fetch($query)) { DB::update('home_album', array('picnum' => getcount('home_pic', array('albumid' => $album['albumid']))), array('albumid' => $album['albumid'])); } } DB::delete('forum_attachment', $condition . ' AND pid>0', 0, $unbuffered); DB::delete('forum_attachmentfield', $condition . ' AND pid>0', 0, $unbuffered); }
showformheader('attach&frame=no', 'target="attachmentframe"'); showtableheader(); showsubtitle(array('', 'filename', 'attach_path', 'author', 'attach_thread', 'size', 'attach_downloadnums', '')); echo $attachments; showsubmit('deletesubmit', 'submit', 'del', '<a href="###" onclick="$(\'admin\').style.display=\'none\';$(\'search\').style.display=\'\';" class="act lightlink normal">' . lang('research') . '</a>', $multipage); showtablefooter(); showformfooter(); echo '<iframe name="attachmentframe" style="display:none"></iframe>'; showtagfooter('div'); } } else { if ($ids = implodeids($delete)) { $tids = $pids = 0; $query = $db->query("SELECT tid, pid, attachment, thumb, remote FROM {$tablepre}attachments WHERE aid IN ({$ids})"); while ($attach = $db->fetch_array($query)) { dunlink($attach['attachment'], $attach['thumb'], $attach['remote']); $tids .= ',' . $attach['tid']; $pids .= ',' . $attach['pid']; } $db->query("DELETE FROM {$tablepre}attachments WHERE aid IN ({$ids})"); $db->query("DELETE FROM {$tablepre}attachmentfields WHERE aid IN ({$ids})"); $attachtids = 0; $query = $db->query("SELECT tid FROM {$tablepre}attachments WHERE tid IN ({$tids}) GROUP BY tid ORDER BY pid DESC"); while ($attach = $db->fetch_array($query)) { $attachtids .= ',' . $attach['tid']; } $db->query("UPDATE {$tablepre}threads SET attachment='0' WHERE tid IN ({$tids})" . ($attachtids ? " AND tid NOT IN ({$attachtids})" : NULL)); $attachpids = 0; $query = $db->query("SELECT pid FROM {$tablepre}attachments WHERE pid IN ({$pids}) GROUP BY pid ORDER BY pid DESC"); while ($attach = $db->fetch_array($query)) { $attachpids .= ',' . $attach['pid'];
function deletethread($condition, $unbuffered = true) { $deletedthreads = 0; $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE {$condition}"); while ($attach = DB::fetch($query)) { dunlink($attach); } foreach (array('forum_thread', 'forum_attachment', 'forum_attachmentfield', 'forum_polloption', 'forum_poll', 'forum_trade', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_typeoptionvar', 'forum_postposition', 'forum_pollvoter') as $table) { DB::delete($table, $condition, 0, $unbuffered); if ($table == 'forum_thread') { $deletedthreads = DB::affected_rows(); } } DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE " . str_replace('tid', 'id', $condition) . " AND idtype='tid'"); return $deletedthreads; }
function updateattach() { global $db, $tablepre, $attachsave, $attachdir, $discuz_uid, $postattachcredits, $tid, $pid, $attachextensions, $attachnew, $attachdel, $allowsetattachperm, $maxprice, $watermarkstatus; $imageexists = 0; $attachnew = (array) $attachnew; $sqladd = $pid > 0 ? "OR pid='{$pid}'" : ''; $query = $db->query("SELECT * FROM {$tablepre}attachments WHERE (uid='{$discuz_uid}' AND tid='0') {$sqladd}"); $attachnum = $db->num_rows($query); if ($attachnum) { if ($attachnum -= count($attachdel)) { checklowerlimit($postattachcredits, $attachnum); } $attachcount = 0; $delaids = array(); while ($attach = $db->fetch_array($query)) { if (is_array($attachdel) && in_array($attach['aid'], $attachdel)) { dunlink($attach['attachment'], $attach['thumb']); $delaids[] = $attach['aid']; continue; } $extension = strtolower(fileext($attach['filename'])); if ($attachextensions && (!preg_match("/(^|\\s|,)" . preg_quote($extension, '/') . "(\$|\\s|,)/i", $attachextensions) || !$extension)) { continue; } $anew = $attachnew[$attach['aid']]; $anew['aid'] = $attach['aid']; $anew['ext'] = $extension; $anew['size'] = $attach['filesize']; if ($attach['pid'] == 0) { $attach_basename = basename($attach['attachment']); $attach_src = $attachdir . '/' . $attach['attachment']; if ($attachsave) { switch ($attachsave) { case 1: $attach_subdir = 'forumid_' . $GLOBALS['fid']; break; case 2: $attach_subdir = 'ext_' . $extension; break; case 3: $attach_subdir = 'month_' . date('ym'); break; case 4: $attach_subdir = 'day_' . date('ymd'); break; } $attach_descdir = $attachdir . '/' . $attach_subdir; $anew['attachment'] = $attach_subdir . '/' . $attach_basename; } else { $attach_descdir = $attachdir; $anew['attachment'] = $attach_basename; } $anew['thumb'] = $attach['thumb']; $attach_desc = $attach_descdir . '/' . $attach_basename; if ($attach['isimage'] && $watermarkstatus) { require_once DISCUZ_ROOT . './include/image.class.php'; $image = new Image($attach_src, $attach); if ($image->imagecreatefromfunc && $image->imagefunc) { $image->Watermark(); $attach = $image->attach; $attach['filesize'] = $attach['size']; } } if (!is_dir($attach_descdir)) { @mkdir($attach_descdir, 0777); @fclose(fopen($attach_descdir . '/index.htm', 'w')); } if ($attach['thumb'] == 1) { if (!@rename($attach_src . '.thumb.jpg', $attach_desc . '.thumb.jpg') && @copy($attach_src . '.thumb.jpg', $attach_desc . '.thumb.jpg')) { @unlink($attach_src . '.thumb.jpg'); } } if (!@rename($attach_src, $attach_desc) && @copy($attach_src, $attach_desc)) { @unlink($attach_src); } $anew['remote'] = ftpupload($attach_desc, $anew); $attachcount++; } if ($attach['isimage']) { $imageexists = 1; } $anew['filesize'] = $attach['filesize']; $anew['perm'] = $allowsetattachperm ? $anew['perm'] : 0; $anew['description'] = cutstr(dhtmlspecialchars($anew['description']), 100); $anew['price'] = $maxprice ? intval($anew['price']) <= $maxprice ? intval($anew['price']) : $maxprice : 0; $sqladd = $attach['pid'] == 0 ? ", tid='{$tid}', pid='{$pid}', attachment='{$anew['attachment']}', remote='{$anew['remote']}'" : ''; $db->query("UPDATE {$tablepre}attachments SET readperm='{$anew['readperm']}', price='{$anew['price']}', filesize='{$anew['filesize']}' {$sqladd} WHERE aid='{$attach['aid']}'"); if ($anew['description']) { $db->query("REPLACE INTO {$tablepre}attachmentfields (aid, tid, pid, uid, description) VALUES ('{$attach['aid']}', '{$tid}', '{$pid}', '{$attach['uid']}', '{$anew['description']}')"); } } if ($delaids) { $db->query("DELETE FROM {$tablepre}attachments WHERE aid IN (" . implodeids($delaids) . ")", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}attachmentfields WHERE aid IN (" . implodeids($delaids) . ")", 'UNBUFFERED'); } $attachment = $imageexists ? 2 : 1; if ($attachcount) { $db->query("UPDATE {$tablepre}threads SET attachment='{$attachment}' WHERE tid='{$tid}'", 'UNBUFFERED'); $db->query("UPDATE {$tablepre}posts SET attachment='{$attachment}' WHERE pid='{$pid}'", 'UNBUFFERED'); updatecredits($discuz_uid, $postattachcredits, $attachcount); } } }
function article_move_forums($arr, $old_arr) { global $_G; $arr['content'] = preg_replace(array('/<center>([\\s\\S]*?)<\\/center>/', '/\\s(?=\\s)/'), array("[align=center]\\1[/align]", ''), $arr['content']); $subject = addslashes(trim($arr['title'])); if ($arr['check']) { if (!strlen($subject)) { return FALSE; } $num = DB::result_first('SELECT COUNT(*) FROM ' . DB::table('forum_thread') . " WHERE subject='{$subject}' AND displayorder > '-1'"); if ($num) { return FALSE; } } if ($arr['contents'] > 1 && $arr['is_content_reply'] != 1) { $arr['reply'] = array(); } $time_arr = create_public_time($arr, count($arr['reply']) + 1, 1); if ($arr['contents'] == 1) { $uid_arr = get_rand_uid($arr, 'reply'); } else { if ($arr['is_content_reply'] != 1) { if ($arr['content_arr']) { $arr['content'] = content_merge($arr['content_arr']); } $uid_arr = get_rand_uid($arr); } } $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : array_shift($time_arr); require_once libfile('function/editor'); require_once libfile('function/forum'); $subject = htmlspecialchars_decode(format_html($subject)); $subject = htmlspecialchars_decode(format_html($subject)); $arr['content'] = dstripslashes($arr['content']); $arr['content'] = img_htmlbbcode($arr['content'], $arr['page_url']); $arr['content'] = media_htmlbbcode($arr['content'], $arr['page_url']); $arr['content'] = audio_htmlbbcode($arr['content'], $arr['page_url']); $message = htmlspecialchars_decode(html2bbcode($arr['content'])); $message = dstripslashes(format_html($message)); $arr['fid'] = $_G['fid'] = $_GET['forums'] ? $_GET['forums'] : $arr['forum_fid']; $_G['uid'] = $arr['uid'] ? $arr['uid'] : $_G['uid']; $view_num = $arr['view_num']; require_once libfile('function/post'); $special = 0; if (trim($subject) == '' || trim($message) == '') { return -1; } if (!$sortid && !$special && trim($message) == '') { return -1; } $_GET['save'] = $arr['uid'] ? $arr['uid'] : $_G['uid']; $uid = $_GET['save']; $typeid = intval($_GET['threadtypeid']) ? intval($_GET['threadtypeid']) : $arr['forum_typeid']; $displayorder = 0; $digest = $_G['forum']['ismoderator'] && $_G['group']['allowdigestthread'] && !empty($_GET['addtodigest']) ? 1 : 0; $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0; $isanonymous = $_G['group']['allowanonymous'] && $_GET['isanonymous'] ? 1 : 0; $price = intval($price); $price = $_G['group']['maxprice'] && !$special ? $price <= $_G['group']['maxprice'] ? $price : $_G['group']['maxprice'] : 0; if (!$typeid && $_G['forum']['threadtypes']['required'] && !$special) { return -2; } if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) { return -3; } if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) { return -4; } $_G['forum'] = DB::fetch_first("SELECT * FROM " . DB::table('forum_forum') . " WHERE fid = '{$arr['fid']}'"); //查询版块信息 if (!$_G['forum']) { return -5; } $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid; $typeexpiration = intval($_GET['typeexpiration']); if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) { return -5; } $_G['forum_optiondata'] = array(); if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) { $_G['forum_optiondata'] = threadsort_validator($_GET['typeoption'], $pid); } $author = !$arr['username'] ? $_G['username'] : $arr['username']; $moderated = $digest || $displayorder > 0 ? 1 : 0; $thread['status'] = 0; $_GET['ordertype'] && ($thread['status'] = setstatus(4, 1, $thread['status'])); $_GET['hiddenreplies'] && ($thread['status'] = setstatus(2, 1, $thread['status'])); $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status'])); $isgroup = $_G['forum']['status'] == 3 ? 1 : 0; //检查各项设置 $bbcodeoff = checkbbcodes($message, FALSE); $smileyoff = checksmilies($message, FALSE); $parseurloff = FALSE; $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0; if ($_G['group']['allowreplycredit']) { $_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']); $_GET['replycredit_times'] = intval($_GET['replycredit_times']); $_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']); $_GET['replycredit_random'] = intval($_GET['replycredit_random']); $_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random']; $replycredit = $replycredit_real = 0; } if ($old_arr['forum_id']) { $info = DB::fetch_first("SELECT p.pid,p.tid,t.tid,p.first FROM " . DB::table('forum_post') . " p Inner Join " . DB::table('forum_thread') . " t ON p.tid = t.tid WHERE p.first = '1' AND t.tid='" . $old_arr['forum_id'] . "' AND t.displayorder > '-1'"); } $reply_count = count($arr['reply']); $view_num = $view_num < $reply_count - 1 ? rand($reply_count * 2, $reply_count * 10) : $view_num; if ($info['tid']) { //更新 DB::query("UPDATE " . DB::table('forum_thread') . " SET typeid='{$typeid}', author='{$author}', authorid='{$uid}', subject='{$subject}', dateline='{$arr['public_time']}', lastpost='{$arr['public_time']}', fid='{$arr['fid']}', lastposter='{$author}', views='{$view_num}', attachment='0' WHERE tid='{$info['tid']}'", 'UNBUFFERED'); $tid = $info['tid']; } else { //添加 DB::query("INSERT INTO " . DB::table('forum_thread') . " (fid, posttableid, readperm, price, typeid, sortid, author, authorid, subject, dateline, lastpost, lastposter, views, displayorder, digest, special, attachment, moderated, status, isgroup, replycredit, closed)\r\n\t\t\tVALUES ('{$_G['fid']}', '0', '{$readperm}', '{$price}', '{$typeid}', '{$sortid}', '{$author}', '{$_G['uid']}', '{$subject}', '{$arr['public_time']}', '{$arr['public_time']}', '{$author}', '{$view_num}', '{$displayorder}', '{$digest}', '{$special}', '0', '{$moderated}', '32', '{$isgroup}', '{$replycredit}', '" . ($closed ? "1" : '0') . "')"); $tid = DB::insert_id(); useractionlog($uid, 'tid'); } DB::update('common_member_field_home', array('recentnote' => $subject), array('uid' => $uid)); if ($moderated) { updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG'); updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1); } if (DISCUZ_VERSION == 'X2') { //2.0版本 $tagstr = addthreadtag($arr['article_tag'], $tid); } else { $class_tag = new tag(); $tagstr = $class_tag->add_tag($arr['article_tag'], $tid, 'tid'); } if ($_G['group']['allowreplycredit']) { if ($replycredit > 0 && $replycredit_real > 0) { updatemembercount($_G['uid'], array('extcredits' . $_G['setting']['creditstransextra'][10] => -$replycredit_real), 1, 'RCT', $tid); DB::query("INSERT INTO " . DB::table('forum_replycredit') . " (tid, extcredits, extcreditstype, times, membertimes, random)VALUES('{$tid}', '{$_G['gp_replycredit_extcredits']}', '{$_G[setting][creditstransextra][10]}', '{$_G['gp_replycredit_times']}', '{$_G['gp_replycredit_membertimes']}', '{$_G['gp_replycredit_random']}')"); } } if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) { DB::query("INSERT INTO " . DB::table('forum_threadrush') . " (tid, stopfloor, starttimefrom, starttimeto, rewardfloor) VALUES ('{$tid}', '{$_G['gp_stopfloor']}', '{$_G['gp_rushreplyfrom']}', '{$_G['gp_rushreplyto']}', '{$_G['gp_rewardfloor']}')"); } $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message); $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '1', 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $isanonymous, 'usesig' => 1, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0); if (DISCUZ_VERSION != 'X2') { //2.5版本 2.5版本多了一个position字段 $post_setarr['position'] = 1; $post_setarr = dstripslashes($post_setarr); } else { $post_setarr = daddslashes($post_setarr); } $post_setarr['tags'] = $tagstr; $replys = 0; if ($info['tid']) { //更新 //发布时间要做更改 $new_post_arr = DB::fetch_first("SELECT dateline FROM " . DB::table('forum_post') . " WHERE tid='{$tid}' ORDER BY dateline ASC limit 1"); $post_setarr['dateline'] = $new_post_arr['dateline'] - 3600; DB::update('forum_post', $post_setarr, array('pid' => $info['pid'])); $pid = $info['pid']; } else { $pid = insertpost($post_setarr); $post_setarr = array(); //发布回复 if ($arr['is_public_reply'] == 1 && $arr['reply'] || $arr['is_content_reply'] == 1) { //是否开启发布回复 if ($arr['is_content_reply'] == 1) { $uid_arr = $time_arr = array(); } $reply_arr = $arr['reply']; $replys = count($reply_arr); if ($arr['public_reply_seq'] == 1) { shuffle($reply_arr); } foreach ((array) $reply_arr as $k => $v) { $message = dstripslashes($v['content']); $message = media_htmlbbcode($message, $arr['page_url']); $message = img_htmlbbcode($message, $arr['page_url']); $message = htmlspecialchars_decode(html2bbcode($message)); //print_r($v['content']);exit(); if (!$message || strlen($message) < 2) { continue; } $post_setarr = array('fid' => $arr['fid'], 'tid' => $tid, 'first' => '0', 'author' => $uid_arr[$k]['username'] ? $uid_arr[$k]['username'] : $arr['username'], 'authorid' => $uid_arr[$k]['uid'] ? $uid_arr[$k]['uid'] : $arr['uid'], 'subject' => '', 'dateline' => $time_arr[$k] ? $time_arr[$k] : $arr['public_time'], 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => 0, 'anonymous' => $_G['group']['allowanonymous'] && !empty($_GET['isanonymous']) ? 1 : 0, 'usesig' => 1, 'htmlon' => $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0, 'bbcodeoff' => checkbbcodes($message, !empty($_GET['bbcodeoff'])), 'smileyoff' => checksmilies($message, !empty($_GET['smileyoff'])), 'parseurloff' => !empty($_GET['parseurloff']), 'attachment' => '0', 'tags' => 0, 'replycredit' => 0, 'status' => defined('IN_MOBILE') ? 8 : 0); $lastpost = $post_setarr['dateline']; $lastposter = $post_setarr['author']; if (DISCUZ_VERSION != 'X2') { //2.5版本 2.5版本多了一个position字段 $post_setarr['position'] = $k + 2; $post_setarr = dstripslashes($post_setarr); } else { $post_setarr = daddslashes($post_setarr); } $reply_pid = insertpost($post_setarr); $v['tid'] = $tid; $v['pid'] = $reply_pid; $v['is_post'] = 1; //标识是回复 $v['cookie'] = $arr['cookie']; $v['is_water_img'] = $arr['is_water_img']; $v['is_download_img'] = $arr['is_download_img']; $v['is_download_file'] = $arr['is_download_file']; $forum_arr['tid'] = $tid; $forum_arr['pid'] = $reply_pid; $forum_arr['is_post'] = 1; //标识是回复 $forum_arr['cookie'] = $arr['cookie']; $forum_arr['is_water_img'] = $arr['is_water_img']; $forum_arr['is_download_img'] = $arr['is_download_img']; $forum_arr['content'] = $v['content']; //$re_arr = forum_downremotefile($forum_arr); if ($arr['is_download_img'] == 1) { $re_arr = forum_downremotefile($v); } DB::query("UPDATE " . DB::table('common_member_count') . " SET posts=posts+1 WHERE uid='{$post_setarr['authorid']}'"); //更新数 $new[$k] = $post_setarr; } unset($post_setarr); DB::update('forum_thread', array('replies' => count($reply_arr), 'lastpost' => $lastpost, 'lastposter' => $lastposter), array('tid' => $tid)); } } //exit(); $re = $arr; $re['fid'] = $fid; $re['tid'] = $tid; $re['fid'] = $fid; $re['uid'] = $arr['uid']; $re['username'] = $author; $re['pid'] = $pid; $re['message'] = $message; if ($pid && getstatus($thread['status'], 1)) { savepostposition($tid, $pid); } $threadimageaid = 0; $threadimage = array(); //print_r($message);exit(); if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata']) && $sortaids) { foreach ($sortaids as $sortaid) { convertunusedattach($sortaid, $tid, $pid); } } if (($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $sortid || !empty($_GET['activityaid']))) { updateattach($displayorder == -4 || $modnewthreads, $tid, $pid, $_GET['attachnew']); if (!$threadimageaid) { $threadimage = DB::fetch_first("SELECT aid, attachment, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1"); $threadimageaid = $threadimage['aid']; } if ($_G['forum']['picstyle']) { setthreadcover($pid, 0, $threadimageaid); } } /*删除附件*/ if ($old_arr['forum_id']) { $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'"); while ($v = DB::fetch($query)) { $attach[] = $v; } dunlink($attach); DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE tid='{$old_arr['forum_id']}'"); DB::query("DELETE FROM " . DB::table(getattachtablebytid($old_arr['forum_id'])) . " WHERE tid='{$old_arr['forum_id']}'"); DB::delete('forum_threadimage', "tid='{$old_arr['forum_id']}'"); //图片表 } $param = array('fid' => $arr['fid'], 'tid' => $tid, 'pid' => $pid); $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread'); include_once libfile('function/stat'); updatestat($isgroup ? 'groupthread' : $statarr[$special]); dsetcookie('clearUserdata', 'forum'); if ($specialextra) { $classname = 'threadplugin_' . $specialextra; if (class_exists($classname) && method_exists($threadpluginclass = new $classname(), 'newthread_submit_end')) { $threadpluginclass->newthread_submit_end($_G['fid'], $tid); } } $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array()); if (!empty($_GET['addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) { $message = !$price ? $message : ''; if ($special == 0) { $feed['icon'] = 'thread'; $feed['title_template'] = 'feed_thread_title'; $feed['body_template'] = 'feed_thread_message'; $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => messagecutstr($message, 150)); if (!empty($_G['forum_attachexist'])) { $firstaid = DB::result_first("SELECT aid FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND dateline>'0' AND isimage='1' ORDER BY dateline LIMIT 1"); if ($firstaid) { $feed['images'] = array(getforumimg($firstaid)); $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}"); } } } } $feed['title_data']['hash_data'] = "tid{$tid}"; $feed['id'] = $tid; $feed['idtype'] = 'tid'; if ($feed['icon']) { postfeed($feed); } if ($displayorder != -4) { if ($digest) { updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']); } updatepostcredits('+', $_G['uid'], 'post', $_G['fid']); if ($isgroup) { DB::query("UPDATE " . DB::table('forum_groupuser') . " SET threads=threads+1, lastupdate='" . $arr['public_time'] . "' WHERE uid='{$_G['uid']}' AND fid='{$_G['fid']}'"); } $subject = str_replace("\t", ' ', $subject); $f_lastpost = "{$tid}\t{$subject}\t" . $arr['public_time'] . "\t{$author}"; if ($_G['forum']['type'] == 'sub') { DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}' WHERE fid='" . $_G['forum'][fup] . "'", 'UNBUFFERED'); } } $subject = str_replace("\t", ' ', $subject); $replys = $replys ? $replys : 1; //今日发帖 $todayposts = date("Yjn", $arr['public_time']) == date("Yjn", $v) ? 1 : 0; foreach ((array) $time_arr as $k => $v) { if (date("Yjn", $_G['timestamp']) == date("Yjn", $v)) { $todayposts++; } } DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$f_lastpost}', threads=threads+1, posts=posts+{$replys}, todayposts=todayposts+{$todayposts} WHERE fid='{$arr['fid']}'", 'UNBUFFERED'); //更新今日发帖这些数据 if ($_G['forum']['status'] == 3) { require_once libfile('function/group'); updateactivity($_G['fid'], 0); require_once libfile('function/grouplog'); updategroupcreditlog($_G['fid'], $_G['uid']); } return $re; }