private function _saveAlbum($ids, $picDesc, $albumId) { global $_G; $ids = rawurldecode($ids); $picDesc = WebUtils::t(rawurldecode($picDesc)); $pidIdArray = explode(',', $ids); foreach ($pidIdArray as $picid) { C::t('home_pic')->update_for_uid($_G['uid'], $picid, array('title' => $picDesc, 'albumid' => $albumId)); } require_once libfile('function/spacecp'); album_update_pic($albumId); return $this->makeErrorInfo($res, 'mobcent_save_album_success', array('noError' => 1, 'alert' => 1)); }
} if (submitcheck('uploadsubmit')) { $albumid = $picid = 0; if (!checkperm('allowupload')) { echo "<script>"; echo "alert(\"" . lang('spacecp', 'not_allow_upload') . "\")"; echo "</script>"; exit; } $uploadfiles = pic_save($_FILES['attach'], $_POST['albumid'], $_POST['pic_title'], false); if ($uploadfiles && is_array($uploadfiles)) { $albumid = $uploadfiles['albumid']; $picid = $uploadfiles['picid']; $uploadStat = 1; require_once libfile('function/spacecp'); album_update_pic($albumid); } else { $uploadStat = $uploadfiles; } $picurl = pic_get($uploadfiles['filepath'], 'album', $uploadfiles['thumb'], $uploadfiles['remote']); echo "<script>"; if ($uploadStat == 1) { echo "parent.spaceDiy.getdiy('diy', 'albumid', '{$albumid}');"; echo "parent.spaceDiy.setBgImage('{$picurl}');"; echo "parent.Util.toggleEle('upload');"; } else { echo "parent.showDialog('{$uploadStat}','notice');"; } echo "</script>"; exit; }
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; }
$bbcode =& bbcode::instance(); $query = C::t('home_pic')->fetch_all_by_albumid($albumid, $start, $perpage, $picid, 0, 1, $albumid > 0 ? 0 : $_G['uid']); foreach ($query as $value) { if ($picid) { $value['checked'] = ' checked'; } $value['title'] = $bbcode->html2bbcode($value['title']); $value['pic'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']); $value['bigpic'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0); $list[] = $value; } } $multi = multi($count, $perpage, $page, "home.php?mod=spacecp&ac=album&op=editpic&albumid={$albumid}"); $albumlist = getalbums($album['uid']); } elseif ($_GET['op'] == 'setpic') { album_update_pic($albumid, $picid); showmessage('do_success', dreferer(), array('picid' => $picid), array('showmsg' => true, 'closetime' => true)); } elseif ($_GET['op'] == 'edittitle') { $picid = empty($_GET['picid']) ? 0 : intval($_GET['picid']); $pic = C::t('home_pic')->fetch($picid); if (!checkperm('managealbum') && $pic['uid'] != $_G['uid']) { $pic = array(); } } elseif ($_GET['op'] == 'edithot') { if (!checkperm('managealbum')) { showmessage('no_privilege_edithot_album'); } if (!($pic = C::t('home_pic')->fetch($picid))) { showmessage('image_does_not_exist'); } if (submitcheck('hotsubmit')) {
function updateattach($modnewthreads, $tid, $pid, $attachnew, $attachupdate = array(), $uid = 0) { global $_G; $thread = C::t('forum_thread')->fetch($tid); $uid = $uid ? $uid : $_G['uid']; if ($attachnew) { $newaids = array_keys($attachnew); $newattach = $newattachfile = $albumattach = array(); foreach (C::t('forum_attachment_unused')->fetch_all($newaids) as $attach) { if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) { continue; } $attach['uid'] = $uid; $newattach[$attach['aid']] = daddslashes($attach); if ($attach['isimage']) { $newattachfile[$attach['aid']] = $attach['attachment']; } } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) || !$_G['setting']['thumbdisabledmobile']) { require_once libfile('class/image'); $image = new image(); } if (!empty($_GET['albumaid'])) { array_unshift($_GET['albumaid'], ''); $_GET['albumaid'] = array_unique($_GET['albumaid']); unset($_GET['albumaid'][0]); foreach ($_GET['albumaid'] as $aid) { if (isset($newattach[$aid])) { $albumattach[$aid] = $newattach[$aid]; } } } foreach ($attachnew as $aid => $attach) { $update = array(); $update['readperm'] = $_G['group']['allowsetattachperm'] ? $attach['readperm'] : 0; $update['price'] = $_G['group']['maxprice'] ? intval($attach['price']) <= $_G['group']['maxprice'] ? intval($attach['price']) : $_G['group']['maxprice'] : 0; $update['tid'] = $tid; $update['pid'] = $pid; $update['uid'] = $uid; $update['description'] = censor(cutstr(dhtmlspecialchars($attach['description']), 100)); C::t('forum_attachment_n')->update('tid:' . $tid, $aid, $update); if (!$newattach[$aid]) { continue; } $update = array_merge($update, $newattach[$aid]); if (!empty($newattachfile[$aid])) { if ($_G['setting']['thumbstatus'] && $_G['forum']['disablethumb']) { $update['thumb'] = 0; @unlink($_G['setting']['attachdir'] . '/forum/' . getimgthumbname($newattachfile[$aid])); if (!empty($albumattach[$aid])) { $albumattach[$aid]['thumb'] = 0; } } elseif (!$_G['setting']['thumbdisabledmobile']) { $_daid = sprintf("%09d", $aid); $dir1 = substr($_daid, 0, 3); $dir2 = substr($_daid, 3, 2); $dir3 = substr($_daid, 5, 2); $dw = 320; $dh = 320; $thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg'; $image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr'); $dw = 720; $dh = 720; $thumbfile = 'image/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($_daid, -2) . '_' . $dw . '_' . $dh . '.jpg'; $image->Thumb($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], $thumbfile, $dw, $dh, 'fixwr'); } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid], '', 'forum'); $update['filesize'] = $image->imginfo['size']; } } if (!empty($_GET['albumaid']) && isset($albumattach[$aid])) { $newalbum = 0; if (!$_GET['uploadalbum']) { require_once libfile('function/spacecp'); $_GET['uploadalbum'] = album_creat(array('albumname' => $_GET['newalbum'])); $newalbum = 1; } $picdata = array('albumid' => $_GET['uploadalbum'], 'uid' => $uid, 'username' => $_G['username'], 'dateline' => $albumattach[$aid]['dateline'], 'postip' => $_G['clientip'], 'filename' => censor($albumattach[$aid]['filename']), 'title' => censor(cutstr(dhtmlspecialchars($attach['description']), 100)), 'type' => fileext($albumattach[$aid]['attachment']), 'size' => $albumattach[$aid]['filesize'], 'filepath' => $albumattach[$aid]['attachment'], 'thumb' => $albumattach[$aid]['thumb'], 'remote' => $albumattach[$aid]['remote'] + 2); $update['picid'] = C::t('home_pic')->insert($picdata, 1); if ($newalbum) { require_once libfile('function/home'); require_once libfile('function/spacecp'); album_update_pic($_GET['uploadalbum']); } } C::t('forum_attachment_n')->insert('tid:' . $tid, $update, false, true); C::t('forum_attachment')->update($aid, array('tid' => $tid, 'pid' => $pid, 'tableid' => getattachtableid($tid))); C::t('forum_attachment_unused')->delete($aid); } if (!empty($_GET['albumaid'])) { $albumdata = array('picnum' => C::t('home_pic')->check_albumpic($_GET['uploadalbum']), 'updatetime' => $_G['timestamp']); C::t('home_album')->update($_GET['uploadalbum'], $albumdata); require_once libfile('function/home'); require_once libfile('function/spacecp'); album_update_pic($_GET['uploadalbum']); } if ($newattach) { ftpupload($newaids, $uid); } } if (!$modnewthreads && $newattach && $uid == $_G['uid']) { updatecreditbyaction('postattach', $uid, array(), '', count($newattach), 1, $_G['fid']); } if ($attachupdate) { $attachs = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'aid', array_keys($attachupdate)); foreach ($attachs as $attach) { if (array_key_exists($attach['aid'], $attachupdate) && $attachupdate[$attach['aid']]) { dunlink($attach); } } $unusedattachs = C::t('forum_attachment_unused')->fetch_all($attachupdate); $attachupdate = array_flip($attachupdate); $unusedaids = array(); foreach ($unusedattachs as $attach) { if ($attach['uid'] != $uid && !$_G['forum']['ismoderator']) { continue; } $unusedaids[] = $attach['aid']; $update = $attach; $update['dateline'] = TIMESTAMP; $update['remote'] = 0; unset($update['aid']); if ($attach['isimage'] && $_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark'])) { $image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'], '', 'forum'); $update['filesize'] = $image->imginfo['size']; } C::t('forum_attachment_n')->update('tid:' . $tid, $attachupdate[$attach['aid']], $update); @unlink($_G['setting']['attachdir'] . 'image/' . $attach['aid'] . '_100_100.jpg'); C::t('forum_attachment_exif')->delete($attachupdate[$attach['aid']]); C::t('forum_attachment_exif')->update($attach['aid'], array('aid' => $attachupdate[$attach['aid']])); ftpupload(array($attachupdate[$attach['aid']]), $uid); } if ($unusedaids) { C::t('forum_attachment_unused')->delete($unusedaids); } } $attachcount = C::t('forum_attachment_n')->count_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid); $attachment = 0; if ($attachcount) { if (C::t('forum_attachment_n')->count_image_by_id('tid:' . $tid, $pid ? 'pid' : 'tid', $pid ? $pid : $tid)) { $attachment = 2; } else { $attachment = 1; } } else { $attachment = 0; } C::t('forum_thread')->update($tid, array('attachment' => $attachment)); C::t('forum_post')->update('tid:' . $tid, $pid, array('attachment' => $attachment), true); if (!$attachment) { C::t('forum_threadimage')->delete_by_tid($tid); } $_G['forum_attachexist'] = $attachment; }
function blog_post($POST, $olds=array()) { global $_G, $space; $isself = 1; if(!empty($olds['uid']) && $olds['uid'] != $_G['uid']) { $isself = 0; $__G = $_G; $_G['uid'] = $olds['uid']; $_G['username'] = addslashes($olds['username']); } $POST['subject'] = getstr(trim($POST['subject']), 80); $POST['subject'] = censor($POST['subject']); if(strlen($POST['subject'])<1) $POST['subject'] = dgmdate($_G['timestamp'], 'Y-m-d'); $POST['friend'] = intval($POST['friend']); $POST['target_ids'] = ''; if($POST['friend'] == 2) { $uids = array(); $names = empty($_POST['target_names'])?array():explode(',', preg_replace("/(\s+)/s", ',', $_POST['target_names'])); if($names) { $uids = C::t('common_member')->fetch_all_uid_by_username($names); } if(empty($uids)) { $POST['friend'] = 3; } else { $POST['target_ids'] = implode(',', $uids); } } elseif($POST['friend'] == 4) { $POST['password'] = trim($POST['password']); if($POST['password'] == '') $POST['friend'] = 0; } if($POST['friend'] !== 2) { $POST['target_ids'] = ''; } if($POST['friend'] !== 4) { $POST['password'] == ''; } $POST['tag'] = dhtmlspecialchars(trim($POST['tag'])); $POST['tag'] = getstr($POST['tag'], 500); $POST['tag'] = censor($POST['tag']); $POST['message'] = checkhtml($POST['message']); if($_G['mobile']) { $POST['message'] = getstr($POST['message'], 0, 0, 0, 1); $POST['message'] = censor($POST['message']); } else { $POST['message'] = getstr($POST['message'], 0, 0, 0, 0, 1); $POST['message'] = censor($POST['message']); $POST['message'] = preg_replace(array( "/\<div\>\<\/div\>/i", "/\<a\s+href\=\"([^\>]+?)\"\>/i" ), array( '', '<a href="\\1" target="_blank">' ), $POST['message']); } $message = $POST['message']; if(censormod($message) || censormod($POST['subject']) || $_G['group']['allowblogmod']) { $blog_status = 1; } else { $blog_status = 0; } if(empty($olds['classid']) || $POST['classid'] != $olds['classid']) { if(!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') { $classname = dhtmlspecialchars(trim(substr($POST['classid'], 4))); $classname = getstr($classname); $classname = censor($classname); if(empty($classname)) { $classid = 0; } else { $classid = C::t('home_class')->fetch_classid_by_uid_classname($_G['uid'], $classname); if(empty($classid)) { $setarr = array( 'classname' => $classname, 'uid' => $_G['uid'], 'dateline' => $_G['timestamp'] ); $classid = C::t('home_class')->insert($setarr, true); } } } else { $classid = intval($POST['classid']); } } else { $classid = $olds['classid']; } if($classid && empty($classname)) { $query = C::t('home_class')->fetch($classid); $classname = ($query['uid'] == $_G['uid']) ? $query['classname'] : ''; if(empty($classname)) $classid = 0; } $blogarr = array( 'subject' => $POST['subject'], 'classid' => $classid, 'friend' => $POST['friend'], 'password' => $POST['password'], 'noreply' => empty($POST['noreply'])?0:1, 'catid' => intval($POST['catid']), 'status' => $blog_status, ); $titlepic = ''; $uploads = array(); if(!empty($POST['picids'])) { $picids = array_keys($POST['picids']); $query = C::t('home_pic')->fetch_all_by_uid($_G['uid'], 0, 0, $picids); foreach($query as $value) { if(empty($titlepic) && $value['thumb']) { $titlepic = getimgthumbname($value['filepath']); $blogarr['picflag'] = $value['remote']?2:1; } $picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0); $uploads[md5($picurl)] = $value; } if(empty($titlepic) && $value) { $titlepic = $value['filepath']; $blogarr['picflag'] = $value['remote']?2:1; } } if($uploads) { $albumid = 0; if($POST['savealbumid'] < 0 && !empty($POST['newalbum'])) { $albumname = addslashes(dhtmlspecialchars(trim($POST['newalbum']))); if(empty($albumname)) $albumname = dgmdate($_G['timestamp'],'Ymd'); $albumarr = array('albumname' => $albumname); $albumid = album_creat($albumarr); } else { $albumid = $POST['savealbumid'] < 0 ? 0 : intval($POST['savealbumid']); } if($albumid) { C::t('home_pic')->update_for_uid($_G['uid'], $picids, array('albumid' => $albumid)); album_update_pic($albumid); } preg_match_all("/\s*\<img src=\"(.+?)\".*?\>\s*/is", $message, $mathes); if(!empty($mathes[1])) { foreach ($mathes[1] as $key => $value) { $urlmd5 = md5($value); if(!empty($uploads[$urlmd5])) { unset($uploads[$urlmd5]); } } } foreach ($uploads as $value) { $picurl = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0); $message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>$value[title]</p></div>"; } } $ckmessage = preg_replace("/(\<div\>|\<\/div\>|\s|\ \;|\<br\>|\<p\>|\<\/p\>)+/is", '', $message); if(empty($ckmessage)) { return false; } if(checkperm('manageblog')) { $blogarr['hot'] = intval($POST['hot']); } if($olds['blogid']) { if($blogarr['catid'] != $olds['catid']) { if($olds['catid']) { C::t('home_blog_category')->update_num_by_catid(-1, $olds['catid'], true, true); } if($blogarr['catid']) { C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']); } } $blogid = $olds['blogid']; C::t('home_blog')->update($blogid, $blogarr); $fuids = array(); $blogarr['uid'] = $olds['uid']; $blogarr['username'] = $olds['username']; } else { if($blogarr['catid']) { C::t('home_blog_category')->update_num_by_catid(1, $blogarr['catid']); } $blogarr['uid'] = $_G['uid']; $blogarr['username'] = $_G['username']; $blogarr['dateline'] = empty($POST['dateline'])?$_G['timestamp']:$POST['dateline']; $blogid = C::t('home_blog')->insert($blogarr, true); C::t('common_member_status')->update($_G['uid'], array('lastpost' => $_G['timestamp'])); C::t('common_member_field_home')->update($_G['uid'], array('recentnote'=>$POST['subject'])); } $blogarr['blogid'] = $blogid; $class_tag = new tag(); $POST['tag'] = $olds ? $class_tag->update_field($POST['tag'], $blogid, 'blogid') : $class_tag->add_tag($POST['tag'], $blogid, 'blogid'); $fieldarr = array( 'message' => $message, 'postip' => $_G['clientip'], 'target_ids' => $POST['target_ids'], 'tag' => $POST['tag'] ); if(!empty($titlepic)) { $fieldarr['pic'] = $titlepic; } if($olds) { C::t('home_blogfield')->update($blogid, $fieldarr); } else { $fieldarr['blogid'] = $blogid; $fieldarr['uid'] = $blogarr['uid']; C::t('home_blogfield')->insert($fieldarr); } if($isself && !$olds && $blog_status == 0) { updatecreditbyaction('publishblog', 0, array('blogs' => 1)); include_once libfile('function/stat'); updatestat('blog'); } if($olds['blogid'] && $blog_status == 1) { updatecreditbyaction('publishblog', 0, array('blogs' => -1), '', -1); include_once libfile('function/stat'); updatestat('blog'); } if($POST['makefeed'] && $blog_status == 0) { include_once libfile('function/feed'); feed_publish($blogid, 'blogid', $olds?0:1); } if(!empty($__G)) $_G = $__G; if($blog_status == 1) { updatemoderate('blogid', $blogid); manage_addnotify('verifyblog'); } return $blogarr; }
function deletepics($picids) { global $_G; $albumids = $sizes = $pics = $newids = array(); $allowmanage = checkperm('managealbum'); $haveforumpic = false; $query = C::t('home_pic')->fetch_all($picids); foreach ($query as $value) { if ($allowmanage || $value['uid'] == $_G['uid']) { $pics[] = $value; $newids[] = $value['picid']; $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; $albumids[$value['albumid']] = $value['albumid']; if (!$haveforumpic && $value['remote'] > 1) { $haveforumpic = true; } } } if (empty($pics)) { return array(); } C::t('home_pic')->delete($newids); if ($haveforumpic) { for ($i = 0; $i < 10; $i++) { C::t('forum_attachment_n')->reset_picid($i, $newids); } } C::t('home_comment')->delete('', $newids, 'picid'); C::t('home_feed')->delete_by_id_idtype($newids, 'picid'); C::t('home_clickuser')->delete_by_id_idtype($newids, 'picid'); C::t('common_moderate')->delete($newids, 'picid'); C::t('common_moderate')->delete($newids, 'picid_cid'); if ($sizes) { foreach ($sizes as $uid => $setarr) { $attachsize = intval($sizes[$uid]); updatemembercount($uid, array('attachsize' => -$attachsize), false); } } require_once libfile('function/spacecp'); foreach ($albumids as $albumid) { if ($albumid) { album_update_pic($albumid); } } deletepicfiles($pics); return $pics; }
function deletepics($picids) { global $_G; $albumids = $sizes = $pics = $newids = array(); $allowmanage = checkperm('managealbum'); $haveforumpic = false; $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($picids) . ")"); while ($value = DB::fetch($query)) { if ($allowmanage || $value['uid'] == $_G['uid']) { $pics[] = $value; $newids[] = $value['picid']; $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; $albumids[$value['albumid']] = $value['albumid']; if (!$haveforumpic && $value['remote'] > 1) { $haveforumpic = true; } } } if (empty($pics)) { return array(); } DB::query("DELETE FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($newids) . ")"); if ($haveforumpic) { for ($i = 0; $i < 10; $i++) { DB::query("UPDATE " . DB::table('forum_attachment_' . $i) . " SET picid='0' WHERE picid IN (" . dimplode($newids) . ")"); } } DB::delete('home_comment', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('home_feed', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('home_clickuser', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('common_moderate', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('common_moderate', "id IN (" . dimplode($newsids) . ") AND idtype='picid_cid'"); if ($sizes) { foreach ($sizes as $uid => $setarr) { $attachsize = intval($sizes[$uid]); updatemembercount($uid, array('attachsize' => -$attachsize), false); } } require_once libfile('function/spacecp'); foreach ($albumids as $albumid) { if ($albumid) { album_update_pic($albumid); } } deletepicfiles($pics); return $pics; }
if(!$album = $_SGLOBAL['db']->fetch_array($query)) { $_POST['newalbumid'] = 0; } } $_SGLOBAL['db']->query("UPDATE ".tname('pic')." SET albumid='$_POST[newalbumid]' WHERE picid IN (".simplode($_POST['ids']).") $plussql"); $updatecount = $_SGLOBAL['db']->affected_rows(); if($updatecount) { if($albumid>0) { $_SGLOBAL['db']->query("UPDATE ".tname('album')." SET picnum=picnum-$updatecount WHERE albumid='$albumid' $plussql"); //更新封面 album_update_pic($albumid); } if($_POST['newalbumid']) { $_SGLOBAL['db']->query("UPDATE ".tname('album')." SET picnum=picnum+$updatecount WHERE albumid='$_POST[newalbumid]' $plussql"); //更新封面 album_update_pic($_POST['newalbumid']); } } } } $url = empty($_POST['refer'])?"cp.php?ac=album&op=editpic&albumid=$albumid&page=$_POST[page]":$_POST['refer']; showmessage('do_success', $url, 0); } $perpage = 10; $page = empty($_GET['page'])?0:intval($_GET['page']); if($page<1) $page = 1; $start = ($page-1)*$perpage; //检查开始数 ckstart($start, $perpage);
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; }
showmessage('do_success', "home.php?mod=space&uid={$_G['uid']}&do=album&picid={$picid}"); } else { showmessage($uploadStat, 'home.php?mod=spacecp&ac=upload'); } } else { echo "<script>"; echo "parent.albumid = {$albumid};"; echo "parent.uploadStat = '{$uploadStat}';"; echo "parent.picid = {$picid};"; echo "parent.upload();"; echo "</script>"; } exit; } elseif (submitcheck('viewAlbumid')) { if ($_POST['opalbumid'] > 0) { album_update_pic($_POST['opalbumid']); } if (ckprivacy('upload', 'feed')) { require_once libfile('function/feed'); feed_publish($_POST['opalbumid'], 'albumid'); } $url = "home.php?mod=space&uid={$_G['uid']}&do=album&quickforward=1&id=" . (empty($_POST['opalbumid']) ? -1 : $_POST['opalbumid']); showmessage('upload_images_completed', $url); } else { if (!checkperm('allowupload')) { showmessage('no_privilege_upload', '', array(), array('return' => true)); } cknewuser(); $config = urlencode($_G['siteroot'] . 'home.php?mod=misc&ac=swfupload&op=config' . ($_GET['op'] == 'cam' ? '&cam=1' : '')); $albums = getalbums($_G['uid']); $actives = $_GET['op'] == 'flash' || $_GET['op'] == 'cam' ? array($_GET['op'] => ' class="a"') : array('js' => ' class="a"');
function deletepics($picids) { global $_G; $sizes = $pics = $newids = $counts = array(); $allowmanage = checkperm('managealbum'); $albumids = array(); $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($picids) . ")"); while ($value = DB::fetch($query)) { if ($allowmanage || $value['uid'] == $_G['uid']) { $pics[] = $value; $newids[] = $value['picid']; if ($value['uid'] != $_G['uid']) { $counts[$value['uid']]['coef'] -= 1; } $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; $albumids[$value['albumid']] = $value['albumid']; } } if (empty($pics)) { return array(); } DB::query("DELETE FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($newids) . ")"); DB::query("DELETE FROM " . DB::table('home_comment') . " WHERE id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::query("DELETE FROM " . DB::table('home_clickuser') . " WHERE id IN (" . dimplode($newids) . ") AND idtype='picid'"); if ($counts) { foreach ($counts as $uid => $setarr) { $attachsize = intval($sizes[$uid]); batchupdatecredit('uploadimage', $uid, array('attachsize' => -$attachsize), $setarr['coef']); unset($sizes[$uid]); } } if ($sizes) { foreach ($sizes as $uid => $setarr) { $attachsize = intval($sizes[$uid]); updatemembercount($uid, array('attachsize' => -$attachsize), false); } } require_once libfile('function/spacecp'); foreach ($albumids as $albumid) { if ($albumid) { album_update_pic($albumid); } } deletepicfiles($pics); return $pics; }