本文整理汇总了PHP中dunlink函数的典型用法代码示例。如果您正苦于以下问题:PHP dunlink函数的具体用法?PHP dunlink怎么用?PHP dunlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dunlink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
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);
}
}
示例2: clear
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);
}
}
示例3: showmessage
$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();
示例4: updateattach
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;
//.........这里部分代码省略.........
示例5: updateattach
//.........这里部分代码省略.........
$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;
}
示例6: before_editpost
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'] . "')");
}
}
}
}
}
示例7: updateattach
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;
}
示例8: deleteattach
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'];
}
}
}
}
示例9: deletethreads
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;
}
示例10: updateattach
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);
}
//.........这里部分代码省略.........
示例11: deleteattach
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']));
}
}
}
示例12: before_editpost
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']));
}
}
}
示例13: before_editpost
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'];
}
}
}
}
示例14: updateswfattach
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);
}
}
}
示例15: before_deletepost
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);
}
}