/** * 获取文章摘要(内容摘要以及图片) * * @param int $aid 文章id * @param bool $transBr 是否要转换换行 * @param array $options 参数选项, 可选值: array('imageList' => 1, 'imageListLen' => 9, 'imageListThumb' => 1) * @return array array('msg' => '', 'image' => '', 'imageList' => array()) */ public static function getArticleSummary($aid, $transBr = true, $options = array()) { $summary = array('msg' => '', 'image' => '', 'imageList' => array()); $summaryLength = WebUtils::getDzPluginAppbymeAppConfig('portal_summary_length'); $allowImage = WebUtils::getDzPluginAppbymeAppConfig('portal_allow_image'); $allowImage = !($allowImage === '0'); if ($summaryLength === '0' && !$allowImage) { return $summary; } require_once DISCUZ_ROOT . './source/function/function_home.php'; $article = DzPortalArticle::getArticleByAid($aid); if (!empty($article)) { $getImageList = isset($options['imageList']) ? $options['imageList'] : 0; $imageListLen = isset($options['imageListLen']) ? $options['imageListLen'] : 9; $imageListThumb = isset($options['imageListThumb']) ? $options['imageListThumb'] : 1; $msg = $article['summary']; if ($article['pic']) { // $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1); $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 0, 1); if ($allowImage) { $summary['image'] = WebUtils::getHttpFileName($article['pic']); if ($getImageList) { $tempImage = $summary['image']; $imageListThumb && ($tempImage = ImageUtils::getThumbImage($tempImage)); $summary['imageList'][] = $tempImage; } } } $transBr && ($msg = WebUtils::emptyReturnLine($msg, ' ')); $msg = trim($msg); $summaryLength === false && ($summaryLength = 40); $summary['msg'] = (string) WebUtils::subString($msg, 0, $summaryLength); } return $summary; }
/** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: function_portalcp.php 10836 2010-05-17 06:24:38Z zhangguosheng $ */ function get_uploadcontent($attach) { $return = ''; if ($attach['isimage']) { $pic = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote'], 0); $small_pic = $attach['thumb'] ? $pic . '.thumb.jpg' : $pic; $return .= '<table id="attach_list_' . $attach['attachid'] . '" width="100%">'; $return .= '<td width="90"><a href="' . $pic . '" target="_blank"><img src="' . $small_pic . '" width="80" height="80"></a></td>'; $return .= '<td>'; $return .= '<a href="###" onclick="insertImage(\'' . $small_pic . '\', \'' . $pic . '\')">' . lang('portalcp', 'insert_small_image') . '</a><br>'; $return .= '<a href="###" onclick="insertImage(\'' . $pic . '\')">' . lang('portalcp', 'insert_large_image') . '</a><br>'; $return .= '<a href="###" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&op=delete\')">' . lang('portalcp', 'delete') . '</a>'; $return .= '</td>'; $return .= '</table>'; } else { $return .= '<table id="attach_list_' . $attach['attachid'] . '" width="100%">'; $return .= '<td><a href="portal.php?mod=attachment&id=' . $attach['attachid'] . '" target="_blank">' . $attach['filename'] . '</a></td>'; $return .= '<td>'; $return .= '<a href="###" onclick="insertFile(\'' . $attach['filename'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '\')">' . lang('portalcp', 'insert_file') . '</a><br>'; $return .= '<a href="###" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&op=delete\')">' . lang('portalcp', 'delete') . '</a>'; $return .= '</td>'; $return .= '</table>'; } return $return; }
/** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: function_portalcp.php 21207 2011-03-18 08:55:18Z zhangguosheng $ * English by Valery Votintsev at sources.ru */ function get_uploadcontent($attach) { $return = ''; if ($attach['isimage']) { $pic = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote'], 0); $small_pic = $attach['thumb'] ? $pic . '.thumb.jpg' : ''; $check = $attach['pic'] == $attach['attachment'] ? checked : ''; $aid = $check ? $attach['aid'] : ''; $return .= '<table id="attach_list_' . $attach['attachid'] . '" width="100%" class="xi2">'; $return .= '<td width="50" class="bbs"><a href="' . $pic . '" target="_blank"><img src="' . ($small_pic ? $small_pic : $pic) . '" width="40" height="40"></a></td>'; $return .= '<td class="bbs">'; $return .= '<label for="setconver' . $attach['attachid'] . '"><input type="radio" name="setconver" id="setconver' . $attach['attachid'] . '" class="pr" value="1" onclick=setConver(\'' . addslashes(serialize(array('pic' => $attach['attachment'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote']))) . '\') ' . $check . '> ' . lang('portalcp', 'set_to_conver') . '</label><br>'; if ($small_pic) { $return .= '<a href="javascript:void(0);" onclick="insertImage(\'' . $small_pic . '\', \'' . $pic . '\');return false;">' . lang('portalcp', 'insert_small_image') . '</a><br>'; } $return .= '<a href="javascript:void(0);" onclick="insertImage(\'' . $pic . '\');return false;">' . lang('portalcp', 'insert_large_image') . '</a><br>'; $return .= '<a href="javascript:void(0);" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&aid=' . $aid . '&op=delete\');return false;">' . lang('portalcp', 'delete') . '</a>'; $return .= '</td>'; $return .= '</table>'; } else { $return .= '<table id="attach_list_' . $attach['attachid'] . '" width="100%">'; $return .= '<td><a href="portal.php?mod=attachment&id=' . $attach['attachid'] . '" target="_blank">' . $attach['filename'] . '</a></td>'; $return .= '<td>'; $return .= '<a href="javascript:void(0);" onclick="insertFile(\'' . $attach['filename'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '\');return false;">' . lang('portalcp', 'insert_file') . '</a><br>'; $return .= '<a href="javascript:void(0);" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&op=delete\');return false;">' . lang('portalcp', 'delete') . '</a>'; $return .= '</td>'; $return .= '</table>'; } return $return; }
function album_update_pic($albumid, $picid = 0) { global $_G; $setarr = array(); if ($picid) { $wheresql = "AND picid='{$picid}'"; } else { $wheresql = "ORDER BY picid DESC LIMIT 1"; $piccount = getcount('home_pic', array('albumid' => $albumid, 'status' => '0')); if (empty($piccount) && getcount('home_pic', array('albumid' => $albumid)) == 0) { DB::query("DELETE FROM " . DB::table('home_album') . " WHERE albumid='{$albumid}'"); return false; } else { $setarr['picnum'] = $piccount; } } $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE albumid='{$albumid}' {$wheresql}"); if (!($pic = DB::fetch($query))) { return false; } $from = $pic['remote']; $pic['remote'] = $pic['remote'] > 1 ? $pic['remote'] - 2 : $pic['remote']; $basedir = !getglobal('setting/attachdir') ? DISCUZ_ROOT . './data/attachment/' : getglobal('setting/attachdir'); $picdir = 'cover/' . substr(md5($albumid), 0, 2) . '/'; dmkdir($basedir . './album/' . $picdir); if ($pic['remote']) { $picsource = pic_get($pic['filepath'], $from > 1 ? 'forum' : 'album', $pic['thumb'], $pic['remote'], 0); } else { $picsource = $basedir . './' . ($from > 1 ? 'forum' : 'album') . '/' . $pic['filepath']; } require_once libfile('class/image'); $image = new image(); if ($image->Thumb($picsource, 'album/' . $picdir . $albumid . '.jpg', 120, 120, 2)) { $setarr['pic'] = $picdir . $albumid . '.jpg'; $setarr['picflag'] = 1; if (getglobal('setting/ftp/on')) { if (ftpcmd('upload', 'album/' . $picdir . $albumid . '.jpg')) { $setarr['picflag'] = 2; @unlink($_G['setting']['attachdir'] . 'album/' . $picdir . $albumid . '.jpg'); } } } else { if ($pic['status'] == 0) { $setarr['pic'] = $pic['thumb'] ? $pic['filepath'] . '.thumb.jpg' : $pic['filepath']; } if ($from > 1) { $setarr['picflag'] = $pic['remote'] ? 4 : 3; } else { $setarr['picflag'] = $pic['remote'] ? 2 : 1; } } $setarr['updatetime'] = $_G['timestamp']; DB::update('home_album', $setarr, array('albumid' => $albumid)); return true; }
function album_update_pic($albumid, $picid = 0) { global $_G; $setarr = array(); if (!$picid) { $piccount = C::t('home_pic')->check_albumpic($albumid, 0); if (empty($piccount) && C::t('home_pic')->check_albumpic($albumid) == 0) { C::t('home_album')->delete($albumid); return false; } else { $setarr['picnum'] = $piccount; } } $query = C::t('home_pic')->fetch_all_by_albumid($albumid, 0, 1, $picid, 1); if (!($pic = $query[0])) { return false; } $from = $pic['remote']; $pic['remote'] = $pic['remote'] > 1 ? $pic['remote'] - 2 : $pic['remote']; $basedir = !getglobal('setting/attachdir') ? DISCUZ_ROOT . './data/attachment/' : getglobal('setting/attachdir'); $picdir = 'cover/' . substr(md5($albumid), 0, 2) . '/'; dmkdir($basedir . './album/' . $picdir); if ($pic['remote']) { $picsource = pic_get($pic['filepath'], $from > 1 ? 'forum' : 'album', $pic['thumb'], $pic['remote'], 0); } else { $picsource = $basedir . './' . ($from > 1 ? 'forum' : 'album') . '/' . $pic['filepath']; } require_once libfile('class/image'); $image = new image(); if ($image->Thumb($picsource, 'album/' . $picdir . $albumid . '.jpg', 120, 120, 2)) { $setarr['pic'] = $picdir . $albumid . '.jpg'; $setarr['picflag'] = 1; if (getglobal('setting/ftp/on')) { if (ftpcmd('upload', 'album/' . $picdir . $albumid . '.jpg')) { $setarr['picflag'] = 2; @unlink($_G['setting']['attachdir'] . 'album/' . $picdir . $albumid . '.jpg'); } } } else { if ($pic['status'] == 0) { $setarr['pic'] = $pic['thumb'] ? getimgthumbname($pic['filepath']) : $pic['filepath']; } if ($from > 1) { $setarr['picflag'] = $pic['remote'] ? 4 : 3; } else { $setarr['picflag'] = $pic['remote'] ? 2 : 1; } } $setarr['updatetime'] = $_G['timestamp']; C::t('home_album')->update($albumid, $setarr); return true; }
function get_upload_content($attachs, $dotype = '') { $html = ''; $dotype = $dotype ? 'checked' : ''; $i = 0; foreach ($attachs as $key => $attach) { $type = $attach['from'] == 'forum' ? 'forum' : 'portal'; $html .= '<td id="attach_list_' . $attach['attachid'] . '">'; if ($attach['isimage']) { $pic = pic_get($attach['attachment'], $type, $attach['thumb'], $attach['remote'], 0); $small_pic = $attach['thumb'] ? getimgthumbname($pic) : ''; $check = $attach['pic'] == $type . '/' . $attach['attachment'] ? 'checked' : $dotype; $aid = $check ? $attach['aid'] : ''; $html .= '<a href="javascript:;" class="opattach">'; $html .= '<span class="opattach_ctrl">'; $html .= '<span onclick="insertImage(\'' . $pic . '\');" class="cur1">' . lang('portalcp', 'insert_large_image') . '</span><span class="pipe">|</span>'; if ($small_pic) { $html .= '<span onclick="insertImage(\'' . $small_pic . '\', \'' . $pic . '\');" class="cur1">' . lang('portalcp', 'small_image') . '</span>'; } $html .= '</span><img src="' . ($small_pic ? $small_pic : $pic) . '" onclick="insertImage(\'' . $pic . '\');" class="cur1" /></a>'; $html .= '<label for="setconver' . $attach['attachid'] . '" class="cur1 xi2"><input type="radio" name="setconver" id="setconver' . $attach['attachid'] . '" class="pr" value="1" onclick=setConver(\'' . addslashes(serialize(array('pic' => $type . '/' . $attach['attachment'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote']))) . '\') ' . $check . '>' . lang('portalcp', 'set_to_conver') . '</label>'; if ($type == 'portal') { $html .= '<span class="pipe">|</span><span class="cur1 xi2" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&aid=' . $aid . '&op=delete\');">' . lang('portalcp', 'delete') . '</span>'; } } else { $html .= '<img src="static/image/editor/editor_file_thumb.png" class="cur1" onclick="insertFile(\'' . $attach['filename'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '\');" tip="' . $attach['filename'] . '" onmouseover="showTip(this);" /><br/>'; $html .= '<span onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&op=delete\');" class="cur1 xi2">' . lang('portalcp', 'delete') . '</span>'; } $html .= '</td>'; $i++; if ($i % 4 == 0 && isset($attachs[$i])) { $html .= '</tr><tr>'; } } if (!empty($html)) { if (($imgpad = $i % 4) > 0) { $html .= str_repeat('<td width="25%"></td>', 4 - $imgpad); } $html = '<table class="imgl"><tr>' . $html . '</tr></table>'; } return $html; }
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 topic_get($topicid) { global $_SGLOBAL; $topic = array(); if ($topicid) { $typearr = array('blog', 'pic', 'thread', 'poll', 'event', 'share', 'bwzt'); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('topic') . " WHERE topicid='{$topicid}'"); if ($topic = $_SGLOBAL['db']->fetch_array($query)) { $topic['pic'] = $topic['pic'] ? pic_get($topic['pic'], $topic['thumb'], $topic['remote'], 0) : ''; $topic['joingid'] = empty($topic['joingid']) ? array() : explode(',', $topic['joingid']); $topic['jointype'] = empty($topic['jointype']) ? $typearr : explode(',', $topic['jointype']); $topic['lastpost'] = sgmdate('Y-m-d H:i', $topic['lastpost']); $topic['dateline'] = sgmdate('Y-m-d H:i', $topic['dateline']); $topic['allowjoin'] = $topic['endtime'] && $_SGLOBAL['timestamp'] > $topic['endtime'] ? 0 : 1; $topic['endtime'] = $topic['endtime'] ? sgmdate('Y-m-d H:i', $topic['endtime']) : ''; include_once S_ROOT . './source/function_bbcode.php'; $topic['message'] = bbcode($topic['message'], 1); $topic['joinurl'] = ''; foreach ($typearr as $value) { if (in_array($value, $topic['jointype'])) { if ($value == 'pic') { $value = 'upload'; } $topic['joinurl'] = "cp.php?ac={$value}&topicid={$topicid}"; break; } } } } return $topic; }
function getranklist_pictures_index($num = 20, $dateline = 0, $orderby = 'hot DESC') { $picturelist = array(); $query = DB::query("SELECT p.picid, p.uid, p.username, p.title, p.filepath, p.thumb, p.remote, a.albumid, a.albumname, a.friend\n\t\tFROM " . DB::table('home_pic') . " p\n\t\tLEFT JOIN " . DB::table('home_album') . " a ON p.albumid=a.albumid\n\t\tWHERE p.hot>'3'\n\t\tORDER BY p.dateline DESC\n\t\tLIMIT 0, {$num}"); require_once libfile('function/home'); while ($picture = DB::fetch($query)) { $picture['url'] = $picture['friend'] == 0 ? pic_get($picture['filepath'], 'album', $picture['thumb'], $picture['remote']) : STATICURL . 'image/common/nopublish.gif'; $picture['origurl'] = $picture['friend'] == 0 ? pic_get($picture['filepath'], 'album', 0, $picture['remote']) : STATICURL . 'image/common/nopublish.gif'; $picturelist[] = $picture; } return $picturelist; }
$body_data = saddslashes(serialize(sstripslashes(array('message' => $message)))); } //ʼþfeed if ($add_doing) { $ip = getonlineip(); $ip_detail = getIpDetails(); $lon = $ip_detail['latitude']; $lat = $ip_detail['longitude']; $pos = "http://lbs.juhe.cn/api/getaddressbylngb?lngx=" . $lat . "&lngy=" . $lon; $opts = array('http' => array('method' => 'GET', 'time' => 1)); $context = stream_context_create($opts); $res = file_get_contents($pos, false, $context); $res = json_decode($res, 1); $address = $res['row']['result']['formatted_address']; if ($picid && $filepath) { $feedarr = array('appid' => UC_APPID, 'icon' => 'doing', 'uid' => $_SGLOBAL['supe_uid'], 'username' => $_SGLOBAL['supe_username'], 'dateline' => $_SGLOBAL['timestamp'], 'title_template' => $title_template, 'title_data' => $title_data, 'body_template' => $body_template, 'body_data' => $body_data, 'id' => $newdoid, 'idtype' => 'doid', 'fromdevice' => 'web', 'image_1' => pic_get($filepath, 1, 0), 'image_1_link' => "space.php?uid={$_SGLOBAL['supe_uid']}&do=album&picid={$picid}", 'ip' => $ip, 'address' => $address); } else { $feedarr = array('appid' => UC_APPID, 'icon' => 'doing', 'uid' => $_SGLOBAL['supe_uid'], 'username' => $_SGLOBAL['supe_username'], 'dateline' => $_SGLOBAL['timestamp'], 'title_template' => $title_template, 'title_data' => $title_data, 'body_template' => $body_template, 'body_data' => $body_data, 'id' => $newdoid, 'idtype' => 'doid', 'fromdevice' => 'web', 'ip' => $ip, 'address' => $address); } $feedarr['hash_template'] = md5($feedarr['title_template'] . "\t" . $feedarr['body_template']); //ϲºÃhash $feedarr['hash_data'] = md5($feedarr['title_template'] . "\t" . $feedarr['title_data'] . "\t" . $feedarr['body_template'] . "\t" . $feedarr['body_data']); //ºÏ²¢hash $feedid = inserttable('feed', $feedarr, 1); } //ͳ¼Æ updatestat('doing'); //·ÖÏíÖÁÐÂÀË΢²© @(include_once S_ROOT . './source/weibo/config.php'); @(include_once S_ROOT . './source/weibo/saetv2.ex.class.php'); $weibo = $message;
$eventlist = $fevents = array(); if(empty($wherearr)) $wherearr = array('1'); if($needquery) {// 好友的活动已特别处理 $sql = "SELECT COUNT(*) FROM $fromsql WHERE ".implode(" AND ", $wherearr); $count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query($sql),0); } if($count){ if($needquery) { $sql = "SELECT e.* FROM $fromsql $joinsql WHERE ".implode(" AND ", $wherearr) ." ORDER BY $orderby LIMIT $start, $perpage"; } $query = $_SGLOBAL['db']->query($sql); while($event = $_SGLOBAL['db']->fetch_array($query)){ if($event['poster']){ $event['pic'] = pic_get($event['poster'], $event['thumb'], $event['remote']); } else { $event['pic'] = $_SGLOBAL['eventclass'][$event['classid']]['poster']; } realname_set($event['uid'], $event['username']); if($view=="friend"){ realname_set($event['fuid'], $event['fusername']); $fevents[$event['eventid']][] = array("fuid"=>$event['fuid'], "fusername"=>$event['fusername'], "status"=>$event['status']); } $eventlist[$event['eventid']] = $event; } } realname_get(); $multi = multi($count, $perpage, $page, $theurl);
function feed_publish($id, $idtype, $add = 0) { global $_G; $setarr = array(); switch ($idtype) { case 'blogid': $query = DB::query("SELECT b.*, bf.* FROM " . DB::table('home_blog') . " b\r\n\t\t\t\tLEFT JOIN " . DB::table('home_blogfield') . " bf ON bf.blogid=b.blogid\r\n\t\t\t\tWHERE b.blogid='{$id}'"); if ($value = DB::fetch($query)) { if ($value['friend'] != 3) { $setarr['icon'] = 'blog'; $setarr['id'] = $value['blogid']; $setarr['idtype'] = $idtype; $setarr['uid'] = $value['uid']; $setarr['username'] = $value['username']; $setarr['dateline'] = $value['dateline']; $setarr['target_ids'] = $value['target_ids']; $setarr['friend'] = $value['friend']; $setarr['hot'] = $value['hot']; $status = $value['status']; $url = "home.php?mod=space&uid={$value['uid']}&do=blog&id={$value['blogid']}"; if ($value['friend'] == 4) { $setarr['title_template'] = 'feed_blog_password'; $setarr['title_data'] = array('subject' => "<a href=\"{$url}\">{$value['subject']}</a>"); } else { if ($value['pic']) { $setarr['image_1'] = pic_cover_get($value['pic'], $value['picflag']); $setarr['image_1_link'] = $url; } $setarr['title_template'] = 'feed_blog_title'; $setarr['body_template'] = 'feed_blog_body'; $value['message'] = preg_replace("/&[a-z]+\\;/i", '', $value['message']); $setarr['body_data'] = array('subject' => "<a href=\"{$url}\">{$value['subject']}</a>", 'summary' => getstr($value['message'], 150, 1, 1, 0, -1)); } } } break; case 'albumid': $key = 1; if ($id > 0) { $query = DB::query("SELECT a.username, a.albumname, a.picnum, a.friend, a.target_ids, p.* FROM " . DB::table('home_pic') . " p\r\n\t\t\t\t\tLEFT JOIN " . DB::table('home_album') . " a ON a.albumid=p.albumid\r\n\t\t\t\t\tWHERE p.albumid='{$id}' ORDER BY dateline DESC LIMIT 0,4"); while ($value = DB::fetch($query)) { if ($value['friend'] <= 2) { if (empty($setarr['icon'])) { $setarr['icon'] = 'album'; $setarr['id'] = $value['albumid']; $setarr['idtype'] = $idtype; $setarr['uid'] = $value['uid']; $setarr['username'] = $value['username']; $setarr['dateline'] = $value['dateline']; $setarr['target_ids'] = $value['target_ids']; $setarr['friend'] = $value['friend']; $status = $value['status']; $setarr['title_template'] = 'feed_album_title'; $setarr['body_template'] = 'feed_album_body'; $setarr['body_data'] = array('album' => "<a href=\"home.php?mod=space&uid={$value['uid']}&do=album&id={$value['albumid']}\">{$value['albumname']}</a>", 'picnum' => $value['picnum']); } $setarr['image_' . $key] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']); $setarr['image_' . $key . '_link'] = "home.php?mod=space&uid={$value['uid']}&do=album&picid={$value['picid']}"; $key++; } else { break; } } } break; case 'picid': $plussql = $id > 0 ? "p.picid='{$id}'" : "p.uid='{$_G['uid']}' ORDER BY dateline DESC LIMIT 1"; $query = DB::query("SELECT p.*, a.friend, a.target_ids FROM " . DB::table('home_pic') . " p\r\n\t\t\t\tLEFT JOIN " . DB::table('home_album') . " a ON a.albumid=p.albumid WHERE {$plussql}"); if ($value = DB::fetch($query)) { if (empty($value['friend'])) { $setarr['icon'] = 'album'; $setarr['id'] = $value['picid']; $setarr['idtype'] = $idtype; $setarr['uid'] = $value['uid']; $setarr['username'] = $value['username']; $setarr['dateline'] = $value['dateline']; $setarr['target_ids'] = $value['target_ids']; $setarr['friend'] = $value['friend']; $setarr['hot'] = $value['hot']; $status = $value['status']; $url = "home.php?mod=space&uid={$value['uid']}&do=album&picid={$value['picid']}"; $setarr['image_1'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']); $setarr['image_1_link'] = $url; $setarr['title_template'] = 'feed_pic_title'; $setarr['body_template'] = 'feed_pic_body'; $setarr['body_data'] = array('title' => $value['title']); } } break; } if ($setarr['icon']) { $setarr['title_template'] = $setarr['title_template'] ? lang('feed', $setarr['title_template']) : ''; $setarr['body_template'] = $setarr['body_template'] ? lang('feed', $setarr['body_template']) : ''; $setarr['body_general'] = $setarr['body_general'] ? lang('feed', $setarr['body_general']) : ''; $setarr['title_data']['hash_data'] = "{$idtype}{$id}"; $setarr['title_data'] = serialize($setarr['title_data']); $setarr['body_data'] = serialize($setarr['body_data']); $setarr = daddslashes($setarr); $feedid = 0; if (!$add && $setarr['id']) { $query = DB::query("SELECT feedid FROM " . DB::table('home_feed') . " WHERE id='{$id}' AND idtype='{$idtype}'"); $feedid = DB::result($query, 0); } if ($status == 0) { if ($feedid) { DB::update('home_feed', $setarr, array('feedid' => $feedid)); } else { DB::insert('home_feed', $setarr); } } } }
/** * 获取主题封面 * * @param int $tid */ public static function getTopicCover($tid) { $image = ''; $topicImage = DbUtils::getDzDbUtils(true)->queryRow(' SELECT * FROM %t WHERE tid=%d ', array('forum_threadimage', $tid)); if (!empty($topicImage)) { require_once DISCUZ_ROOT . './source/function/function_home.php'; $image = pic_get($topicImage['attachment'], 'forum', 0, $topicImage['remote']); } return WebUtils::getHttpFileName($image); }
case 'blogid': $fs['title_template'] = cplang('feed_click_blog'); $fs['title_data'] = array('touser' => "<a href=\"space.php?uid={$item['uid']}\">{$_SN[$item['uid']]}</a>", 'subject' => "<a href=\"space.php?uid={$item['uid']}&do=blog&id={$item['blogid']}\">{$item['subject']}</a>", 'click' => $click['name']); $note_type = 'clickblog'; $q_note = cplang('note_click_blog', array("space.php?uid={$item['uid']}&do=blog&id={$item['blogid']}", $item['subject'])); break; case 'tid': $fs['title_template'] = cplang('feed_click_thread'); $fs['title_data'] = array('touser' => "<a href=\"space.php?uid={$item['uid']}\">{$_SN[$item['uid']]}</a>", 'subject' => "<a href=\"space.php?uid={$item['uid']}&do=thread&id={$item['tid']}\">{$item['subject']}</a>", 'click' => $click['name']); $note_type = 'clickthread'; $q_note = cplang('note_click_thread', array("space.php?uid={$item['uid']}&do=thread&id={$item['tid']}", $item['subject'])); break; case 'picid': $fs['title_template'] = cplang('feed_click_pic'); $fs['title_data'] = array('touser' => "<a href=\"space.php?uid={$item['uid']}\">{$_SN[$item['uid']]}</a>", 'click' => $click['name']); $fs['images'] = array(pic_get($item['filepath'], $item['thumb'], $item['remote'])); $fs['image_links'] = array("space.php?uid={$item['uid']}&do=album&picid={$item['picid']}"); $fs['body_general'] = $item['title']; $note_type = 'clickpic'; $q_note = cplang('note_click_pic', array("space.php?uid={$item['uid']}&do=album&picid={$item['picid']}")); break; } //Event Publishing if (empty($item['friend']) && ckprivacy('click', 1)) { feed_add('click', $fs['title_template'], $fs['title_data'], '', array(), $fs['body_general'], $fs['images'], $fs['image_links']); } //Reward visitors getreward('click', 1, 0, $idtype . $id); //Statistics updatestat('click'); //Notice
function feed_publish($id, $idtype, $add=0) { global $_G; $id = intval($id); if(empty($id)) { return; } if(!helper_access::check_module('feed')) { return false; } $setarr = array(); switch ($idtype) { case 'blogid': $value = array_merge( C::t('home_blog')->fetch($id), C::t('home_blogfield')->fetch($id) ); if($value) { if($value['friend'] != 3) { $setarr['icon'] = 'blog'; $setarr['id'] = $value['blogid']; $setarr['idtype'] = $idtype; $setarr['uid'] = $value['uid']; $setarr['username'] = $value['username']; $setarr['dateline'] = $value['dateline']; $setarr['target_ids'] = $value['target_ids']; $setarr['friend'] = $value['friend']; $setarr['hot'] = $value['hot']; $status = $value['status']; $url = "home.php?mod=space&uid=$value[uid]&do=blog&id=$value[blogid]"; if($value['friend'] == 4) { $setarr['title_template'] = 'feed_blog_password'; $setarr['title_data'] = array('subject' => "<a href=\"$url\">$value[subject]</a>"); } else { if($value['pic']) { $setarr['image_1'] = pic_cover_get($value['pic'], $value['picflag']); $setarr['image_1_link'] = $url; } $setarr['title_template'] = 'feed_blog_title'; $setarr['body_template'] = 'feed_blog_body'; $value['message'] = preg_replace("/&[a-z]+\;/i", '', $value['message']); $setarr['body_data'] = array( 'subject' => "<a href=\"$url\">$value[subject]</a>", 'summary' => getstr($value['message'], 150, 0, 0, 0, -1) ); } } } break; case 'albumid': $key = 1; if($id > 0) { $query = C::t('home_pic')->fetch_all_by_sql('p.'.DB::field('albumid', $id), 'a.dateline DESC', 0, 4); foreach($query as $value) { if($value['friend'] <= 2) { if(empty($setarr['icon'])) { $setarr['icon'] = 'album'; $setarr['id'] = $value['albumid']; $setarr['idtype'] = $idtype; $setarr['uid'] = $value['uid']; $setarr['username'] = $value['username']; $setarr['dateline'] = $value['dateline']; $setarr['target_ids'] = $value['target_ids']; $setarr['friend'] = $value['friend']; $status = $value['status']; $setarr['title_template'] = 'feed_album_title'; $setarr['body_template'] = 'feed_album_body'; $setarr['body_data'] = array( 'album' => "<a href=\"home.php?mod=space&uid=$value[uid]&do=album&id=$value[albumid]\">$value[albumname]</a>", 'picnum' => $value['picnum'] ); } $setarr['image_'.$key] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']); $setarr['image_'.$key.'_link'] = "home.php?mod=space&uid=$value[uid]&do=album&picid=$value[picid]"; $key++; } else { break; } } } break; case 'picid': $plussql = $id>0 ? 'p.'.DB::field('picid', $id) : 'p.'.DB::field('uid', $_G[uid]).' ORDER BY dateline DESC LIMIT 1'; $query = C::t('home_pic')->fetch_all_by_sql($plussql); if($value = $query[0]) { if(empty($value['friend'])) { $setarr['icon'] = 'album'; $setarr['id'] = $value['picid']; $setarr['idtype'] = $idtype; $setarr['uid'] = $value['uid']; $setarr['username'] = $value['username']; $setarr['dateline'] = $value['dateline']; $setarr['target_ids'] = $value['target_ids']; $setarr['friend'] = $value['friend']; $setarr['hot'] = $value['hot']; $status = $value['status']; $url = "home.php?mod=space&uid=$value[uid]&do=album&picid=$value[picid]"; $setarr['image_1'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']); $setarr['image_1_link'] = $url; $setarr['title_template'] = 'feed_pic_title'; $setarr['body_template'] = 'feed_pic_body'; $setarr['body_data'] = array('title' => $value['title']); } } break; } if($setarr['icon']) { //vot $setarr['title_template'] = $setarr['title_template']?lang('feed', $setarr['title_template']):''; //vot $setarr['body_template'] = $setarr['body_template']?lang('feed', $setarr['body_template']):''; $setarr['body_general'] = $setarr['body_general']?lang('feed', $setarr['body_general']):''; $setarr['title_data']['hash_data'] = "{$idtype}{$id}"; $setarr['title_data'] = serialize($setarr['title_data']); $setarr['body_data'] = serialize($setarr['body_data']); $feedid = 0; if(!$add && $setarr['id']) { $feedid = C::t('home_feed')->fetch($id, $idtype); $feedid = $feedid['feedid']; } if($status == 0) { if($feedid) { C::t('home_feed')->update('', $setarr, '', '', $feedid); } else { C::t('home_feed')->insert($setarr); } } } }
function blog_post($POST, $olds = array()) { global $_SGLOBAL, $_SC, $space; //�����߽�ɫ�л� $isself = 1; if (!empty($olds['uid']) && $olds['uid'] != $_SGLOBAL['supe_uid']) { $isself = 0; $__SGLOBAL = $_SGLOBAL; $_SGLOBAL['supe_uid'] = $olds['uid']; $_SGLOBAL['supe_username'] = addslashes($olds['username']); } //���� $POST['subject'] = getstr(trim($POST['subject']), 80, 1, 1, 1); if (strlen($POST['subject']) < 1) { $POST['subject'] = sgmdate('Y-m-d'); } $POST['friend'] = intval($POST['friend']); //��˽ $POST['target_ids'] = ''; if ($POST['friend'] == 2) { //�ض����� $uids = array(); $names = empty($_POST['target_names']) ? array() : explode(' ', str_replace(cplang('tab_space'), ' ', $_POST['target_names'])); if ($names) { $query = $_SGLOBAL['db']->query("SELECT uid FROM " . tname('space') . " WHERE username IN (" . simplode($names) . ")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $uids[] = $value['uid']; } } 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'] = shtmlspecialchars(trim($POST['tag'])); $POST['tag'] = getstr($POST['tag'], 500, 1, 1, 1); //������� //���� if ($_SGLOBAL['mobile']) { $POST['message'] = getstr($POST['message'], 0, 1, 0, 1, 1); } else { $POST['message'] = checkhtml($POST['message']); $POST['message'] = getstr($POST['message'], 0, 1, 0, 1, 0, 1); $POST['message'] = preg_replace(array("/\\<div\\>\\<\\/div\\>/i", "/\\<a\\s+href\\=\"([^\\>]+?)\"\\>/i"), array('', '<a href="\\1" target="_blank">'), $POST['message']); } $message = $POST['message']; //���˷��� if (empty($olds['classid']) || $POST['classid'] != $olds['classid']) { if (!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') { //������ $classname = shtmlspecialchars(trim(substr($POST['classid'], 4))); $classname = getstr($classname, 0, 1, 1, 1); if (empty($classname)) { $classid = 0; } else { $classid = getcount('class', array('classname' => $classname, 'uid' => $_SGLOBAL['supe_uid']), 'classid'); if (empty($classid)) { $setarr = array('classname' => $classname, 'uid' => $_SGLOBAL['supe_uid'], 'dateline' => $_SGLOBAL['timestamp']); $classid = inserttable('class', $setarr, 1); } } } else { $classid = intval($POST['classid']); } } else { $classid = $olds['classid']; } if ($classid && empty($classname)) { //�Ƿ����Լ��� $classname = getcount('class', array('classid' => $classid, 'uid' => $_SGLOBAL['supe_uid']), '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); //����ͼƬ $titlepic = ''; //��ȡ�ϴ���ͼƬ $uploads = array(); if (!empty($POST['picids'])) { $picids = array_keys($POST['picids']); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('pic') . " WHERE picid IN (" . simplode($picids) . ") AND uid='{$_SGLOBAL['supe_uid']}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if (empty($titlepic) && $value['thumb']) { $titlepic = $value['filepath'] . '.thumb.jpg'; $blogarr['picflag'] = $value['remote'] ? 2 : 1; } $uploads[$POST['picids'][$value['picid']]] = $value; } if (empty($titlepic) && $value) { $titlepic = $value['filepath']; $blogarr['picflag'] = $value['remote'] ? 2 : 1; } } //�������� if ($uploads) { preg_match_all("/\\<img\\s.*?\\_uchome\\_localimg\\_([0-9]+).+?src\\=\"(.+?)\"/i", $message, $mathes); if (!empty($mathes[1])) { $searchs = $idsearchs = array(); $replaces = array(); foreach ($mathes[1] as $key => $value) { if (!empty($mathes[2][$key]) && !empty($uploads[$value])) { $searchs[] = $mathes[2][$key]; $idsearchs[] = "_uchome_localimg_{$value}"; $replaces[] = pic_get($uploads[$value]['filepath'], $uploads[$value]['thumb'], $uploads[$value]['remote'], 0); unset($uploads[$value]); } } if ($searchs) { $message = str_replace($searchs, $replaces, $message); $message = str_replace($idsearchs, 'uchomelocalimg[]', $message); } } //δ�������� foreach ($uploads as $value) { $picurl = pic_get($value['filepath'], $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; } //���slashes $message = addslashes($message); //�������ж�ȡͼƬ if (empty($titlepic)) { $titlepic = getmessagepic($message); $blogarr['picflag'] = 0; } $blogarr['pic'] = $titlepic; //�ȶ� if (checkperm('manageblog')) { $blogarr['hot'] = intval($POST['hot']); } //���� if ($_POST['attachid'] && $_POST['attachpath'] && $_POST['attachname'] && $_POST['attachsize']) { $blogarr['attachid'] = $_POST['attachid']; $blogarr['attachpath'] = $_POST['attachpath']; $blogarr['attachname'] = $_POST['attachname']; $blogarr['attachsize'] = $_POST['attachsize']; } if ($olds['blogid']) { //���� $blogid = $olds['blogid']; updatetable('blog', $blogarr, array('blogid' => $blogid)); $fuids = array(); $blogarr['uid'] = $olds['uid']; $blogarr['username'] = $olds['username']; } else { //�������� $blogarr['topicid'] = topic_check($POST['topicid'], 'blog'); $blogarr['uid'] = $_SGLOBAL['supe_uid']; $blogarr['username'] = $_SGLOBAL['supe_username']; $blogarr['dateline'] = empty($POST['dateline']) ? $_SGLOBAL['timestamp'] : $POST['dateline']; $blogid = inserttable('blog', $blogarr, 1); } $blogarr['blogid'] = $blogid; //���� $fieldarr = array('message' => $message, 'postip' => getonlineip(), 'target_ids' => $POST['target_ids']); //TAG $oldtagstr = addslashes(empty($olds['tag']) ? '' : implode(' ', unserialize($olds['tag']))); $tagarr = array(); if ($POST['tag'] != $oldtagstr) { if (!empty($olds['tag'])) { //�Ȱ���ǰ�ĸ������ $oldtags = array(); $query = $_SGLOBAL['db']->query("SELECT tagid, blogid FROM " . tname('tagblog') . " WHERE blogid='{$blogid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $oldtags[] = $value['tagid']; } if ($oldtags) { $_SGLOBAL['db']->query("UPDATE " . tname('tag') . " SET blognum=blognum-1 WHERE tagid IN (" . simplode($oldtags) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagblog') . " WHERE blogid='{$blogid}'"); } } $tagarr = tag_batch($blogid, $POST['tag']); //���¸����е�tag $fieldarr['tag'] = empty($tagarr) ? '' : addslashes(serialize($tagarr)); } if ($olds) { //���� updatetable('blogfield', $fieldarr, array('blogid' => $blogid)); } else { $fieldarr['blogid'] = $blogid; $fieldarr['uid'] = $blogarr['uid']; inserttable('blogfield', $fieldarr); } //�ռ���� if ($isself) { if ($olds) { //�ռ���� $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET updatetime='{$_SGLOBAL['timestamp']}' WHERE uid='{$_SGLOBAL['supe_uid']}'"); } else { if (empty($space['blognum'])) { $space['blognum'] = getcount('blog', array('uid' => $space['uid'])); $blognumsql = "blognum=" . $space['blognum']; } else { $blognumsql = 'blognum=blognum+1'; } //��� $reward = getreward('publishblog', 0); $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET {$blognumsql}, lastpost='{$_SGLOBAL['timestamp']}', updatetime='{$_SGLOBAL['timestamp']}', credit=credit+{$reward['credit']}, experience=experience+{$reward['experience']} WHERE uid='{$_SGLOBAL['supe_uid']}'"); //ͳ�� updatestat('blog'); } } //����feed if ($POST['makefeed']) { include_once S_ROOT . './source/function_feed.php'; feed_publish($blogid, 'blogid', $olds ? 0 : 1); } //���� if (empty($olds) && $blogarr['topicid']) { topic_join($blogarr['topicid'], $_SGLOBAL['supe_uid'], $_SGLOBAL['supe_username']); } //��ɫ�л� if (!empty($__SGLOBAL)) { $_SGLOBAL = $__SGLOBAL; } return $blogarr; }
case 'article': $feed_hash_data = "articleid{$id}"; $query = DB::query("SELECT * FROM " . DB::table('portal_article_title') . " WHERE aid='{$id}'"); if (!($article = DB::fetch($query))) { showmessage('article_does_not_exist'); } if (in_array($article['status'], array(1, 2))) { showmessage('moderate_article_not_share'); } $arr['itemid'] = $id; $arr['fromuid'] = $article['uid']; $arr['title_template'] = lang('spacecp', 'share_article'); $arr['body_template'] = '<b>{title}</b><br>{username}<br>{summary}'; $arr['body_data'] = array('title' => "<a href=\"portal.php?mod=view&aid={$article['aid']}\">{$article['title']}</a>", 'username' => "<a href=\"home.php?mod=space&uid={$article['uid']}\">" . $article['username'] . "</a>", 'summary' => getstr($article['summary'], 150, 0, 1, 0, -1)); if ($article['pic']) { $arr['image'] = pic_get($article['pic'], 'portal', $article['thumb'], $article['remote'], 1, 1); $arr['image_link'] = "portal.php?mod=view&aid={$article['aid']}"; } $note_uid = $article['uid']; $note_message = 'share_article'; $note_values = array('url' => "portal.php?mod=view&aid={$article['aid']}", 'subject' => $article['title'], 'from_id' => $id, 'from_idtype' => 'aid'); break; default: $actives = array('share' => ' class="active"'); $_G['refer'] = 'home.php?mod=space&uid=' . $_G['uid'] . '&do=share&view=me'; $type = 'link'; $_GET['op'] = 'link'; $linkdefault = 'http://'; $generaldefault = ''; break; }
ckstart($start, $perpage); //Query Processing $theurl = "cp.php?ac=event&op=eventinvite"; $count = getcount("eventinvite", array("touid" => $_SGLOBAL['supe_uid'])); //update statistics if ($count != $space['eventinvitenum']) { updatetable('space', array('eventinvitenum' => $count), array('uid' => $space['uid'])); } $eventinvites = array(); if ($count > 0) { // Unprocessed event invitation $query = $_SGLOBAL['db']->query("SELECT ei.*, e.*, ei.dateline as invitetime FROM " . tname("eventinvite") . " ei LEFT JOIN " . tname("event") . " e ON ei.eventid=e.eventid WHERE ei.touid='{$_SGLOBAL['supe_uid']}' limit {$start}, {$perpage}"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { realname_set($value['uid'], $value['username']); if ($value['poster']) { $value['pic'] = pic_get($value['poster'], $value['thumb'], $value['remote']); } else { $value['pic'] = $_SGLOBAL['eventclass'][$value['classid']]['poster']; } $eventinvites[] = $value; } } //Pagination $multi = multi($count, $perpage, $page, $theurl); } elseif ($op == 'acceptinvite') { //Accept the invitation if (!$eventid) { showmessage("event_does_not_exist"); // Event does not exist or has been deleted } $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname("eventinvite") . " WHERE eventid='{$eventid}' AND touid='{$_SGLOBAL['supe_uid']}' LIMIT 1");
if (isblacklist($pic['uid'])) { showmessage('is_blacklist'); } if (empty($pic['albumid'])) { $pic['albumid'] = 0; } if (empty($pic['albumname'])) { $pic['albumname'] = cplang('default_albumname'); } // real name realname_set($pic['uid'], $pic['username']); realname_get(); $arr['title_template'] = cplang('share_image'); $arr['body_template'] = cplang('album') . ': <b>{albumname}</b><br>{username}<br>{title}'; $arr['body_data'] = array('albumname' => "<a href=\"space.php?uid={$pic['uid']}&do=album&id={$pic['albumid']}\">{$pic['albumname']}</a>", 'username' => "<a href=\"space.php?uid={$pic['uid']}\">" . $_SN[$pic['uid']] . "</a>", 'title' => getstr($pic['title'], 100, 0, 1, 0, 0, -1)); $arr['image'] = pic_get($pic['filepath'], $pic['thumb'], $pic['remote']); $arr['image_link'] = "space.php?uid={$pic['uid']}&do=album&picid={$pic['picid']}"; // notice $note_uid = $pic['uid']; $note_message = cplang('note_share_pic', array("space.php?uid={$pic['uid']}&do=album&picid={$pic['picid']}", $pic['albumname'])); $hotarr = array('picid', $pic['picid'], $pic['hotuser']); break; case 'thread': $query = $_SGLOBAL['db']->query("SELECT t.*, p.message, p.hotuser FROM " . tname('thread') . " t\r\n\t\t\t\tLEFT JOIN " . tname('post') . " p ON p.tid=t.tid AND p.isthread='1'\r\n\t\t\t\tWHERE t.tid='{$id}'"); if (!($thread = $_SGLOBAL['db']->fetch_array($query))) { showmessage('topics_does_not_exist'); } if ($thread['uid'] == $space['uid']) { showmessage('share_not_self'); } //Blacklist
showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1)); } $themes = gettheme('topic'); } elseif ($op == 'diy' || $op == 'image') { $topicid = intval($_GET['topicid']); $topic = C::t('portal_topic')->fetch($topicid); topic_checkperm($topic); $perpage = 6; $page = max(1, intval($_GET['page'])); $start = ($page - 1) * $perpage; $list = array(); if ($topicid) { $count = C::t('portal_topic_pic')->count_by_topicid($topicid); if (!empty($count)) { foreach (C::t('portal_topic_pic')->fetch_all_by_topicid($topicid, $start, $perpage) as $value) { $value['pic'] = pic_get($value['filepath'], 'portal', $value['thumb'], $value['remote']); $list[] = $value; } } $multi = multi($count, $perpage, $page, "portal.php?mod=portalcp&ac=diy&op=image&topicid={$topicid}"); } } elseif ($op == 'delete') { $topicid = intval($_GET['topicid']); $topic = C::t('portal_topic')->fetch($topicid); topic_checkperm($topic); $picid = intval($_GET['picid']); } elseif ($op == 'export') { if (submitcheck('exportsubmit')) { $tpl = $_POST['tpl']; $tpldirectory = $_POST['tpldirectory']; $frame = $_POST['frame'];
private function _getNewsInfo($article, $page) { global $_G; $newsInfo = array(); $aid = $article['aid']; $articleUrl = $this->_fetchArticleUrl($aid); // 门户静态化,暂时去掉这个跳转,因为有些用户不支持wap版的门户页面 /* if(!empty($_G['setting']['makehtml']['flag']) && $article['htmlmade'] && !isset($_G['makehtml']) && empty($_GET['diy']) && empty($article['url'])) { // dheader('location:'. fetch_article_url($article)); $newsInfo['redirectUrl'] = $articleUrl; return $newsInfo; } */ $article_count = C::t('portal_article_count')->fetch($aid); if ($article_count) { $article = array_merge($article_count, $article); } if ($article_count) { C::t('portal_article_count')->increase($aid, array('viewnum' => 1)); unset($article_count); } else { C::t('portal_article_count')->insert(array('aid' => $aid, 'catid' => $article['catid'], 'viewnum' => 1)); } if ($article['url']) { // if(!isset($_G['makehtml'])) { // dheader("location:{$article['url']}"); // } // exit(); $newsInfo['redirectUrl'] = $article['url']; return $newsInfo; } $cat = category_remake($article['catid']); $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1); if ($page < 1) { $page = 1; } $org = array(); if ($article['idtype'] == 'blogid') { $org = C::t('home_blog')->fetch($article['id']); if (empty($org)) { C::t('portal_article_title')->update($aid, array('id' => 0, 'idtype' => '')); // dheader('location: '. fetch_article_url($article)); // exit(); $newsInfo['redirectUrl'] = $articleUrl; return $newsInfo; } } $article['allowcomment'] = !empty($cat['allowcomment']) && !empty($article['allowcomment']) ? 1 : 0; $article['timestamp'] = $article['dateline']; $article['dateline'] = dgmdate($article['dateline']); $newsInfo['redirectUrl'] = ''; $newsInfo['catName'] = WebUtils::t('文章详情'); $newsInfo['title'] = WebUtils::emptyHtml($article['title']); $newsInfo['dateline'] = $article['dateline']; $newsInfo['author'] = $article['username']; $newsInfo['viewNum'] = (int) $article['viewnum']; $newsInfo['commentNum'] = (int) $article['commentnum']; $newsInfo['allowComment'] = $article['allowcomment'] ? 1 : 0; $newsInfo['summary'] = $article['summary']; $newsInfo['pageCount'] = (int) $article['contents']; $newsInfo['from'] = $article['from']; $newsInfo['articleUrl'] = $articleUrl; $newsInfo['content'] = $this->_transContent(PortalUtils::getNewsContent($article, $page)); return $newsInfo; }
$ascdesc = isset($_G['gp_ascdesc']) && $_G['gp_ascdesc'] == 'asc' ? 'asc' : 'desc'; if (!empty($searchid)) { $page = max(1, intval($_G['gp_page'])); $start_limit = ($page - 1) * $_G['tpp']; $index = DB::fetch_first("SELECT searchstring, keywords, num, ids FROM " . DB::table('common_searchindex') . " WHERE searchid='{$searchid}' AND srchmod='{$srchmod}'"); if (!$index) { showmessage('search_id_invalid'); } $keyword = htmlspecialchars($index['keywords']); $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : ''; $index['keywords'] = rawurlencode($index['keywords']); $articlelist = array(); $query = DB::query("SELECT at.*,ac.viewnum, ac.commentnum FROM " . DB::table('portal_article_title') . " at LEFT JOIN " . DB::table('portal_article_count') . " ac ON at.aid=ac.aid WHERE at.aid IN ({$index['ids']}) ORDER BY {$orderby} {$ascdesc} LIMIT {$start_limit}, {$_G['tpp']}"); while ($article = DB::fetch($query)) { $article['dateline'] = dgmdate($article['dateline']); $article['pic'] = pic_get($article['pic'], 'portal', $article['thumb'], $article['remote']); $article['title'] = bat_highlight($article['title'], $keyword); $article['summary'] = bat_highlight($article['summary'], $keyword); $articlelist[] = $article; } $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=portal&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes"); $url_forward = 'search.php?mod=portal&' . $_SERVER['QUERY_STRING']; include template('search/portal'); } else { !($_G['group']['exempt'] & 2) && checklowerlimit('search'); $searchstring = 'portal|title|' . addslashes($srchtxt); $searchindex = array('id' => 0, 'dateline' => '0'); $query = DB::query("SELECT searchid, dateline,\r\n\t\t\t('" . $_G['setting']['search']['portal']['searchctrl'] . "'<>'0' AND " . (empty($_G['uid']) ? "useip='{$_G['clientip']}'" : "uid='{$_G['uid']}'") . " AND {$_G['timestamp']}-dateline<'" . $_G['setting']['search']['portal']['searchctrl'] . "') AS flood,\r\n\t\t\t(searchstring='{$searchstring}' AND expiration>'{$_G['timestamp']}') AS indexvalid\r\n\t\t\tFROM " . DB::table('common_searchindex') . "\r\n\t\t\tWHERE srchmod='{$srchmod}' AND ('" . $_G['setting']['search']['portal']['searchctrl'] . "'<>'0' AND " . (empty($_G['uid']) ? "useip='{$_G['clientip']}'" : "uid='{$_G['uid']}'") . " AND {$_G['timestamp']}-dateline<" . $_G['setting']['search']['portal']['searchctrl'] . ") OR (searchstring='{$searchstring}' AND expiration>'{$_G['timestamp']}')\r\n\t\t\tORDER BY flood"); while ($index = DB::fetch($query)) { if ($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) { $searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
threadsort_optiondata($_G['gp_pid'], $_G['gp_sortid'], $_G['cache']['threadsort_option_' . $_G['gp_sortid']], $_G['cache']['threadsort_template_' . $_G['gp_sortid']]); $template = intval($_G['gp_operate']) ? 'forum/search_sortoption' : 'forum/post_sortoption'; include template($template); exit; } elseif ($_G['gp_action'] == 'albumphoto') { include_once libfile('function/home'); $perpage = 8; $page = max(1, $_G['gp_page']); $start_limit = ($page - 1) * $perpage; $aid = intval($_G['gp_aid']); $photolist = array(); $count = DB::result_first("SELECT picnum FROM " . DB::table('home_album') . " WHERE albumid='{$aid}' AND uid='{$_G['uid']}'"); $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE albumid='{$aid}' AND uid='{$_G['uid']}' ORDER BY dateline DESC LIMIT {$start_limit},{$perpage}"); while ($value = DB::fetch($query)) { $value['bigpic'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote'], 0); $value['pic'] = pic_get($value['filepath'], 'album', $value['thumb'], $value['remote']); $value['count'] = $count; $value['url'] = (substr(strtolower($value['bigpic']), 0, 7) == 'http://' ? '' : $_G['siteurl']) . $value['bigpic']; $value['thumburl'] = (substr(strtolower($value['pic']), 0, 7) == 'http://' ? '' : $_G['siteurl']) . $value['pic']; $photolist[] = $value; } $_G['gp_ajaxtarget'] = 'albumphoto'; $multi = multi($count, $perpage, $page, "forum.php?mod=post&action=albumphoto&aid={$aid}"); include template('forum/ajax_albumlist'); exit; } elseif ($_G['forum']['simple'] & 1 || $_G['forum']['redirect']) { showmessage('forum_disablepost'); } require_once libfile('function/discuzcode'); $space = array(); space_merge($space, 'field_home');
function newMediaObject($uid, $username, $password, $mediaobject = array()) { global $_SGLOBAL, $space; $fileext = fileext($mediaobject['name']); if (!in_array($fileext, array('jpg', 'gif', 'png'))) { $this->sendFault(500, 'You should choose image file to upload.'); } $this->authUser($username, $password); include_once S_ROOT . './source/function_cp.php'; $struct = array(); if ($stream_save = stream_save(sstripslashes($mediaobject['bits']), '0', $fileext)) { $struct['url'] = pic_get($stream_save['filepath'], $stream_save['thumb'], $stream_save['remote'], 0); } else { $this->sendFault(500, 'Sorry, your image could not be uploaded. Something wrong happened.'); } if (!preg_match("/^(http\\:\\/\\/|\\/)/i", $struct['url'])) { $struct['url'] = $this->siteUrl . $struct['url']; } return $struct; }
function onPhotoUpdate($uId, $pId, $aId, $fileName = null, $fileType = null, $fileSize = null, $caption = null, $data = null) { global $_G; $res = $this->getUserSpace($uId); if ($fileName !== null) { $fields['filename'] = $fileName; } if (is_string($caption) && strlen($caption) > 0) { $fields['title'] = $caption; } if (is_string($data) && strlen($data) > 0) { $query = DB::query('SELECT size, title, filename FROM ' . DB::table('home_pic') . ' WHERE picid=' . $pId . ' AND albumid=' . $aId . ' AND uid=' . $uId); $picInfo = DB::fetch($query); if ($picInfo && is_array($picInfo)) { require_once libfile('function/spacecp'); $attachDir = $_SC['attachdir']; $_SC['attachdir'] = DISCUZ_ROOT . './' . $_G['setting']['attachdir']; $title = $fields['title'] ? $caption : $picInfo['title']; $name = $fields['filename'] ? $fileName : $picInfo['filename']; $stream = base64_decode($data); $pic = stream_save($stream, $aId, $fileType, $name, $title, $picInfo['size']); $_SC['attachdir'] = $attachDir; $newPic = array(); if ($pic && is_array($pic)) { require_once libfile('function/delete'); deletepics(array($pId)); DB::update('home_pic', array('picid' => $pId), array('picid' => $pic['picid'])); $newPic['pId'] = $pId; $newPic['src'] = $pic['filepat']; return new APIResponse($newPic); } else { if ($res == -1) { $errCode = 122; $errMessage = 'No Enough Space'; } else { if ($res == -2) { $errCode = 123; $errMessage = 'Uploaded File Is Not A Valid Image'; } else { $errCode = 1; $errMessage = 'Unknown Error'; } } } } else { $errCode = 121; $errMessage = 'Invalid Picture Id'; } return new ErrorResponse($errCode, $errMessage); } else { $where = array('uid' => $uId, 'albumid' => $aId, 'picid' => $pId); DB::update('home_pic', $fields, $where); $query = DB::query('SELECT * FROM ' . DB::table('home_pic') . ' WHERE picid=' . $pId . ' AND uid=' . $uId . ' AND albumid=' . $aId); $picInfo = DB::fetch($query); if ($picInfo && is_array($picInfo)) { $newPic['pId'] = $pId; $newPic['src'] = pic_get($picInfo['filepath'], $picInfo['thumb'], $picInfo['remote'], 0); if (!preg_match("/^(http\\:\\/\\/|\\/)/i", $newPic['src'])) { $newPic['src'] = $this->_getUchomeUrl() . $newPic['src']; } return $newPic; } else { $errCode = 121; $errMessage = 'Invalid Picture Id'; return new ErrorResponse($errCode, $errMessage); } } }
if ($operation == 'delete') { if (!$_G['group']['allowmanagearticle'] && $_G['uid'] != $attach['uid']) { showmessage('portal_attachment_nopermission_delete'); } if ($aid) { C::t('portal_article_title')->update($aid, array('pic' => '')); } C::t('portal_attachment')->delete($id); pic_delete($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']); showmessage('portal_image_noexist'); } elseif ($operation == 'getattach') { require_once libfile('function/attachment'); if ($attach['isimage']) { require_once libfile('function/home'); $smallimg = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']); $bigimg = pic_get($attach['attachment'], 'portal', 0, $attach['remote']); $coverstr = addslashes(serialize(array('pic' => 'portal/' . $attach['attachment'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote']))); } $attach['filetype'] = attachtype($attach['filetype'] . "\t" . $attach['filetype']); $attach['filesize'] = sizecount($attach['filesize']); include template('portal/portal_attachment'); exit; } else { $filename = $_G['setting']['attachdir'] . '/portal/' . $attach['attachment']; if (!$attach['remote'] && !is_readable($filename)) { showmessage('attachment_nonexistence'); } $readmod = 2; //read local file's function: 1=fread 2=readfile 3=fpassthru 4=fpassthru+multiple $range = 0; if ($readmod == 4 && !empty($_SERVER['HTTP_RANGE'])) {
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; } include_once template('home/spacecp_index');
/** * 上传相册图片 * * @param mixed $allowValue 允许上传图片编号(file=name[]). * @param int $albumId 相册ID * * @return array */ private function _uploadAlbum($allowValue, $albumId) { global $_G; $_FILES["Filedata"] = array('name' => $_FILES['uploadFile']['name'][$allowValue], 'type' => $_FILES['uploadFile']['type'][$allowValue], 'tmp_name' => $_FILES['uploadFile']['tmp_name'][$allowValue], 'error' => $_FILES['uploadFile']['error'][$allowValue], 'size' => $_FILES['uploadFile']['size'][$allowValue]); // /source/module/misc/misc_swfupload.php $res = array(); if (helper_access::check_module('album')) { require_once libfile('function/spacecp'); if ($_FILES["Filedata"]['error']) { $file = lang('spacecp', 'file_is_too_big'); } else { require_once libfile('function/home'); $_FILES["Filedata"]['name'] = addslashes(diconv(urldecode($_FILES["Filedata"]['name']), 'UTF-8')); // 为了水印的问题来修改discuz的方法 Yii::import('application.components.discuz.source.function.function_spacecp', true); $file = mobcent_pic_save($_FILES["Filedata"], $albumId, '', true, 0); if (!empty($file) && is_array($file)) { $url = pic_get($file['filepath'], 'album', $file['thumb'], $file['remote']); $bigimg = pic_get($file['filepath'], 'album', 0, $file['remote']); // echo "{\"picid\":\"$file[picid]\", \"url\":\"$url\", \"bigimg\":\"$bigimg\"}"; // die; $res['id'] = $file['picid']; $res['urlName'] = $_G['setting']['ftp']['on'] == 1 ? $this->_processPath($bigimg) : $this->getController()->dzRootUrl . '/' . $bigimg; // ??图片的描述:暂时albumPicDesc[]的方式传进来 // C::t('home_pic')->update_for_uid($_G['uid'], $file['picid'], array('title'=>'123321', 'albumid' => $albumId)); // if($albumId) { // album_update_pic($albumId); // } } // echo WebUtils::u($file); } } return $res; }
$article = array_merge($article_count, $article); } if ($article_count) { C::t('portal_article_count')->increase($aid, array('viewnum' => 1)); unset($article_count); } else { C::t('portal_article_count')->insert(array('aid' => $aid, 'catid' => $article['catid'], 'viewnum' => 1)); } if ($article['url']) { if (!isset($_G['makehtml'])) { dheader("location:{$article['url']}"); } exit; } $cat = category_remake($article['catid']); $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1); $page = intval($_GET['page']); if ($page < 1) { $page = 1; } $content = $contents = array(); $multi = ''; $content = C::t('portal_article_content')->fetch_by_aid_page($aid, $page); if ($article['contents'] && $article['showinnernav']) { foreach (C::t('portal_article_content')->fetch_all($aid) as $value) { $contents[] = $value; } if (empty($contents)) { C::t('portal_article_content')->update($aid, array('showinnernav' => '0')); } }
function blog_post($POST, $olds=array()) { global $_SGLOBAL, $_SC, $space; //操作者角色切换 $isself = 1; if(!empty($olds['uid']) && $olds['uid'] != $_SGLOBAL['supe_uid']) { $isself = 0; $__SGLOBAL = $_SGLOBAL; $_SGLOBAL['supe_uid'] = $olds['uid']; $_SGLOBAL['supe_username'] = addslashes($olds['username']); } //标题 $POST['subject'] = getstr(trim($POST['subject']), 80, 1, 1, 1); if(strlen($POST['subject'])<1) $POST['subject'] = sgmdate('Y-m-d'); $POST['friend'] = intval($POST['friend']); //隐私 $POST['target_ids'] = ''; if($POST['friend'] == 2) { //特定好友 $uids = array(); $names = empty($_POST['target_names'])?array():explode(' ', str_replace(cplang('tab_space'), ' ', $_POST['target_names'])); if($names) { $query = $_SGLOBAL['db']->query("SELECT uid FROM ".tname('space')." WHERE username IN (".simplode($names).")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $uids[] = $value['uid']; } } 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'] = shtmlspecialchars(trim($POST['tag'])); $POST['tag'] = getstr($POST['tag'], 500, 1, 1, 1); //语词屏蔽 //内容 if($_SGLOBAL['mobile']) { $POST['message'] = getstr($POST['message'], 0, 1, 0, 1, 1); } else { $POST['message'] = checkhtml($POST['message']); $POST['message'] = getstr($POST['message'], 0, 1, 0, 1, 0, 1); $POST['message'] = preg_replace(array( "/\<div\>\<\/div\>/i", "/\<a\s+href\=\"([^\>]+?)\"\>/i" ), array( '', '<a href="\\1" target="_blank">' ), $POST['message']); } $message = $POST['message']; //个人分类 if(empty($olds['classid']) || $POST['classid'] != $olds['classid']) { if(!empty($POST['classid']) && substr($POST['classid'], 0, 4) == 'new:') { //分类名 $classname = shtmlspecialchars(trim(substr($POST['classid'], 4))); $classname = getstr($classname, 0, 1, 1, 1); if(empty($classname)) { $classid = 0; } else { $classid = getcount('class', array('classname'=>$classname, 'uid'=>$_SGLOBAL['supe_uid']), 'classid'); if(empty($classid)) { $setarr = array( 'classname' => $classname, 'uid' => $_SGLOBAL['supe_uid'], 'dateline' => $_SGLOBAL['timestamp'] ); $classid = inserttable('class', $setarr, 1); } } } else { $classid = intval($POST['classid']); } } else { $classid = $olds['classid']; } if($classid && empty($classname)) { //是否是自己的 $classname = getcount('class', array('classid'=>$classid, 'uid'=>$_SGLOBAL['supe_uid']), '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 ); //标题图片 $titlepic = ''; //获取上传的图片 $uploads = array(); if(!empty($POST['picids'])) { $picids = array_keys($POST['picids']); $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('pic')." WHERE picid IN (".simplode($picids).") AND uid='$_SGLOBAL[supe_uid]'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if(empty($titlepic) && $value['thumb']) { $titlepic = $value['filepath'].'.thumb.jpg'; $blogarr['picflag'] = $value['remote']?2:1; } $uploads[$POST['picids'][$value['picid']]] = $value; } if(empty($titlepic) && $value) { $titlepic = $value['filepath']; $blogarr['picflag'] = $value['remote']?2:1; } } //插入文章 if($uploads) { preg_match_all("/\<img\s.*?\_uchome\_localimg\_([0-9]+).+?src\=\"(.+?)\"/i", $message, $mathes); if(!empty($mathes[1])) { $searchs = $idsearchs = array(); $replaces = array(); foreach ($mathes[1] as $key => $value) { if(!empty($mathes[2][$key]) && !empty($uploads[$value])) { $searchs[] = $mathes[2][$key]; $idsearchs[] = "_uchome_localimg_$value"; $replaces[] = pic_get($uploads[$value]['filepath'], $uploads[$value]['thumb'], $uploads[$value]['remote'], 0); unset($uploads[$value]); } } if($searchs) { $message = str_replace($searchs, $replaces, $message); $message = str_replace($idsearchs, 'uchomelocalimg[]', $message); } } //未插入文章 foreach ($uploads as $value) { $picurl = pic_get($value['filepath'], $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; } //添加slashes $message = addslashes($message); //从内容中读取图片 if(empty($titlepic)) { $titlepic = getmessagepic($message); $blogarr['picflag'] = 0; } $blogarr['pic'] = $titlepic; //热度 if(checkperm('manageblog')) { $blogarr['hot'] = intval($POST['hot']); } if($olds['blogid']) { //更新 $blogid = $olds['blogid']; updatetable('blog', $blogarr, array('blogid'=>$blogid)); $fuids = array(); $blogarr['uid'] = $olds['uid']; $blogarr['username'] = $olds['username']; } else { //参与热闹 $blogarr['topicid'] = topic_check($POST['topicid'], 'blog'); $blogarr['uid'] = $_SGLOBAL['supe_uid']; $blogarr['username'] = $_SGLOBAL['supe_username']; $blogarr['dateline'] = empty($POST['dateline'])?$_SGLOBAL['timestamp']:$POST['dateline']; $blogid = inserttable('blog', $blogarr, 1); } $blogarr['blogid'] = $blogid; //附表 $fieldarr = array( 'message' => $message, 'postip' => getonlineip(), 'target_ids' => $POST['target_ids'] ); //TAG $oldtagstr = addslashes(empty($olds['tag'])?'':implode(' ', unserialize($olds['tag']))); $tagarr = array(); if($POST['tag'] != $oldtagstr) { if(!empty($olds['tag'])) { //先把以前的给清理掉 $oldtags = array(); $query = $_SGLOBAL['db']->query("SELECT tagid, blogid FROM ".tname('tagblog')." WHERE blogid='$blogid'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $oldtags[] = $value['tagid']; } if($oldtags) { $_SGLOBAL['db']->query("UPDATE ".tname('tag')." SET blognum=blognum-1 WHERE tagid IN (".simplode($oldtags).")"); $_SGLOBAL['db']->query("DELETE FROM ".tname('tagblog')." WHERE blogid='$blogid'"); } } $tagarr = tag_batch($blogid, $POST['tag']); //更新附表中的tag $fieldarr['tag'] = empty($tagarr)?'':addslashes(serialize($tagarr)); } if($olds) { //更新 updatetable('blogfield', $fieldarr, array('blogid'=>$blogid)); } else { $fieldarr['blogid'] = $blogid; $fieldarr['uid'] = $blogarr['uid']; inserttable('blogfield', $fieldarr); } //空间更新 if($isself) { if($olds) { //空间更新 $_SGLOBAL['db']->query("UPDATE ".tname('space')." SET updatetime='$_SGLOBAL[timestamp]' WHERE uid='$_SGLOBAL[supe_uid]'"); } else { if(empty($space['blognum'])) { $space['blognum'] = getcount('blog', array('uid'=>$space['uid'])); $blognumsql = "blognum=".$space['blognum']; } else { $blognumsql = 'blognum=blognum+1'; } //积分 $reward = getreward('publishblog', 0); $_SGLOBAL['db']->query("UPDATE ".tname('space')." SET {$blognumsql}, lastpost='$_SGLOBAL[timestamp]', updatetime='$_SGLOBAL[timestamp]', credit=credit+$reward[credit], experience=experience+$reward[experience] WHERE uid='$_SGLOBAL[supe_uid]'"); //统计 updatestat('blog'); } } //产生feed if($POST['makefeed']) { include_once(S_ROOT.'./source/function_feed.php'); feed_publish($blogid, 'blogid', $olds?0:1); } //热闹 if(empty($olds) && $blogarr['topicid']) { topic_join($blogarr['topicid'], $_SGLOBAL['supe_uid'], $_SGLOBAL['supe_username']); } //角色切换 if(!empty($__SGLOBAL)) $_SGLOBAL = $__SGLOBAL; return $blogarr; }