function getstr($string, $length, $in_slashes = 0, $out_slashes = 0, $bbcode = 0, $html = 0) { global $_G; $string = trim($string); $sppos = strpos($string, chr(0) . chr(0) . chr(0)); if ($sppos !== false) { $string = substr($string, 0, $sppos); } if ($in_slashes) { $string = dstripslashes($string); } $string = preg_replace("/\\[hide=?\\d*\\](.*?)\\[\\/hide\\]/is", '', $string); if ($html < 0) { $string = preg_replace("/(\\<[^\\<]*\\>|\r|\n|\\s|\\[.+?\\])/is", ' ', $string); } elseif ($html == 0) { $string = dhtmlspecialchars($string); } if ($length) { $string = cutstr($string, $length); } if ($bbcode) { require_once DISCUZ_ROOT . './source/class/class_bbcode.php'; $bb =& bbcode::instance(); $string = $bb->bbcode2html($string, $bbcode); } if ($out_slashes) { $string = daddslashes($string); } return trim($string); }
function getdata($style, $parameter) { global $_G; $parameter = $this->cookparameter($parameter); $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array(); $aids = !empty($parameter['aids']) ? explode(',', $parameter['aids']) : array(); $catid = !empty($parameter['catid']) ? $parameter['catid'] : array(); $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0; $items = isset($parameter['items']) ? intval($parameter['items']) : 10; $titlelength = isset($parameter['titlelength']) ? intval($parameter['titlelength']) : 40; $orderby = isset($parameter['orderby']) && in_array($parameter['orderby'], array('dateline', 'picnum', 'updatetime')) ? $parameter['orderby'] : 'dateline'; $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array(); $list = array(); $wheres = array(); if ($aids) { $wheres[] = 'albumid IN (' . dimplode($aids) . ')'; } if ($bannedids) { $wheres[] = 'albumid NOT IN (' . dimplode($bannedids) . ')'; } if ($uids) { $wheres[] = 'uid IN (' . dimplode($uids) . ')'; } if ($catid) { $wheres[] = 'catid IN (' . dimplode($catid) . ')'; } $wheres[] = "friend = '0'"; $wheresql = $wheres ? implode(' AND ', $wheres) : '1'; $sql = "SELECT * FROM " . DB::table('home_album') . " WHERE {$wheresql} ORDER BY {$orderby} DESC"; $query = DB::query($sql . " LIMIT {$startrow},{$items};"); while ($data = DB::fetch($query)) { $list[] = array('id' => $data['albumid'], 'idtype' => 'albumid', 'title' => cutstr($data['albumname'], $titlelength), 'url' => "home.php?mod=space&uid={$data['uid']}&do=album&id={$data['albumid']}", 'pic' => 'album/' . $data['pic'], 'picflag' => $data['picflag'], 'summary' => '', 'fields' => array('uid' => $data['uid'], 'username' => $data['username'], 'dateline' => $data['dateline'], 'updatetime' => $data['updatetime'], 'picnum' => $data['picnum'])); } return array('html' => '', 'data' => $list); }
public function viewthread_modoption() { global $_G; if (!$_G['adminid']) { return false; } $usergroupsfeedlist = unserialize($_G['setting']['qqgroup_usergroup_feed_list']); if (empty($usergroupsfeedlist) || !in_array($_G['groupid'], $usergroupsfeedlist)) { if (self::$util->isfounder($_G['member']) == false) { return false; } } $tid = $_G['tid']; $title = urlencode(trim($_G['forum_thread']['subject'])); $post = C::t('forum_post')->fetch_all_by_tid_position($_G['fotum_thread']['posttableid'], $_G['tid'], 1); include_once libfile('function/discuzcode'); $content = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", '', trim($post[0]['message'])); $content = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", '', $content); $content = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", '', $content); $content = preg_replace("/\\[hide[=]?(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", '', $content); $content = strip_tags(discuzcode($content, 0, 0, 0)); $content = preg_replace('%\\[attach\\].*\\[/attach\\]%im', '', $content); $content = str_replace(' ', ' ', $content); $content = urlencode(cutstr($content, 50, '')); include template('qqgroup:push'); return trim($return); }
function processCollectionData($collection, $tf = array(), $orderby = '') { if (count($collection) <= 0) { return array(); } require_once libfile('function/discuzcode'); foreach ($collection as $ctid => &$curvalue) { $curvalue['updated'] = $curvalue['lastupdate'] > $tf[$ctid]['lastvisit'] ? 1 : 0; $curvalue['tflastvisit'] = $tf[$ctid]['lastvisit']; $curvalue['lastupdate'] = dgmdate($curvalue['lastupdate']); $curvalue['dateline'] = dgmdate($curvalue['dateline']); $curvalue['lastposttime'] = dgmdate($curvalue['lastposttime']); $curvalue['avgrate'] = number_format($curvalue['rate'], 1); $curvalue['star'] = imgdisplayrate($curvalue['rate']); $curvalue['lastposterhtml'] = rawurlencode($curvalue['lastposter']); $curvalue['shortdesc'] = cutstr(strip_tags(discuzcode($curvalue['desc'])), 50); $curvalue['arraykeyword'] = parse_keyword($curvalue['keyword'], false, false); if ($curvalue['arraykeyword']) { foreach ($curvalue['arraykeyword'] as $kid => $s_keyword) { $curvalue['urlkeyword'][$kid] = rawurlencode($s_keyword); } } if ($orderby == 'commentnum') { $curvalue['displaynum'] = $curvalue['commentnum']; } elseif ($orderby == 'follownum') { $curvalue['displaynum'] = $curvalue['follownum']; } else { $curvalue['displaynum'] = $curvalue['threadnum']; } } return $collection; }
function init($attach, $type = 'temp', $extid = 0, $forcename = '') { if (!is_array($attach) || empty($attach) || !$this->is_upload_file($attach['tmp_name']) || trim($attach['name']) == '' || $attach['size'] == 0) { $this->attach = array(); $this->errorcode = -1; return false; } else { $this->type = $this->check_dir_type($type); $this->extid = intval($extid); $this->forcename = $forcename; $attach['size'] = intval($attach['size']); $attach['name'] = trim($attach['name']); $attach['thumb'] = ''; $attach['ext'] = $this->fileext($attach['name']); $attach['name'] = htmlspecialchars($attach['name'], ENT_QUOTES); if (strlen($attach['name']) > 90) { $attach['name'] = cutstr($attach['name'], 80, '') . '.' . $attach['ext']; } $attach['isimage'] = $this->is_image_ext($attach['ext']); $attach['extension'] = $this->get_target_extension($attach['ext']); $attach['attachdir'] = $this->get_target_dir($this->type, $extid); $attach['attachment'] = $attach['attachdir'] . $this->get_target_filename($this->type, $this->extid, $this->forcename) . '.' . $attach['extension']; $attach['target'] = getglobal('setting/attachdir') . './' . $this->type . '/' . $attach['attachment']; $this->attach =& $attach; $this->errorcode = 0; return true; } }
function getdata($style, $parameter) { global $_G; $parameter = $this->cookparameter($parameter); $uids = isset($parameter['uids']) && !in_array(0, (array) $parameter['uids']) ? $parameter['uids'] : ''; $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0; $items = isset($parameter['items']) ? intval($parameter['items']) : 10; $titlelength = intval($parameter['titlelength']); $orderby = isset($parameter['orderby']) && in_array($parameter['orderby'], array('dateline', 'replynum')) ? $parameter['orderby'] : 'dateline'; $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array(); $datalist = $list = array(); $wheres = array(); if ($uids) { $wheres[] = 'uid IN (' . dimplode($uids) . ')'; } if ($bannedids) { $wheres[] = 'doid NOT IN (' . dimplode($bannedids) . ')'; } $wheres[] = " status = '0'"; $wheresql = $wheres ? implode(' AND ', $wheres) : '1'; $query = DB::query("SELECT * FROM " . DB::table('home_doing') . " WHERE {$wheresql} ORDER BY {$orderby} DESC LIMIT {$startrow},{$items}"); while ($data = DB::fetch($query)) { $datalist = array('id' => $data['doid'], 'idtype' => 'doid', 'title' => cutstr(strip_tags($data['message']), $titlelength, ''), 'url' => 'home.php?mod=space&uid=' . $data['uid'] . '&do=doing&doid=' . $data['doid'], 'pic' => '', 'summary' => '', 'fields' => array('fulltitle' => strip_tags($data['message']), 'uid' => $data['uid'], 'username' => $data['username'], 'avatar' => avatar($data['uid'], 'small', true, false, false, $_G['setting']['ucenterurl']), 'avatar_middle' => avatar($data['uid'], 'middle', true, false, false, $_G['setting']['ucenterurl']), 'avatar_big' => avatar($data['uid'], 'big', true, false, false, $_G['setting']['ucenterurl']), 'dateline' => $data['dateline'], 'replynum' => $data['replynum'])); if ($titlelength) { $datalist['title'] = cutstr(strip_tags($data['message']), $titlelength); } else { $datalist['title'] = strip_tags($data['message'], '<img>'); } $list[] = $datalist; } return array('html' => '', 'data' => $list); }
function getrss($catid) { global $_SGLOBAL, $_SCONFIG; $rssarr = array(); $attacharr = array(); if (empty($_SCONFIG['rssnum'])) { $_SCONFIG['rssnum'] = 10; } $sql = "SELECT si.itemid, si.uid, si.username, si.subject, sn.*, si.dateline, c.name FROM " . tname('spaceitems') . " si INNER JOIN " . tname('categories') . " c ON si.catid = c.catid LEFT JOIN " . tname('spacenews') . " sn ON si.itemid = sn.itemid WHERE si.type='news' "; if (!empty($catid)) { $sql .= " AND si.catid='{$catid}' "; } $sql .= " ORDER BY si.dateline DESC LIMIT 100"; $query = $_SGLOBAL['db']->query($sql); while ($items = $_SGLOBAL['db']->fetch_array($query)) { $othermsgarr = array(); $items['message'] = cutstr($items['message'], 255, 1); if (!empty($othermsgarr)) { $items['message'] = implode('<br>', $othermsgarr) . '<br>' . $items['message']; } if (!empty($items['hash'])) { $attacharr[] = trim($items['hash']); } $rssarr[$items['itemid']] = $items; } return $rssarr; }
function Adddesign() { $id = jget('id', 'int'); $data = array(); $data['name'] = cutstr(trim($this->Post['plugin_name']), 40); $data['identifier'] = cutstr(trim($this->Post['identifier']), 40); $data['version'] = cutstr(trim($this->Post['version']), 10); $data['copyright'] = cutstr(trim($this->Post['copyright']), 80); $data['description'] = cutstr($this->Post['description'], 100); $data['directory'] = $data['identifier'] . '/'; $oldidentifier = jget('old_identifier'); if (empty($data['name'])) { $this->Messager("插件名不能为空"); } if ($oldidentifier == $data['identifier']) { $is_exists = false; } else { $is_exists = jtable('plugin')->info(array('identifier' => $data['identifier'])); } if ($is_exists != false || empty($data['identifier']) || !preg_match("/^[a-z]+[a-z0-9_]*[a-z0-9]+\$/i", $data['identifier'])) { $this->Messager("插件唯一识别符不合法,或不能为空"); } if (empty($data['version'])) { $this->Messager("插件版本号不能为空"); } if (empty($data['copyright'])) { $this->Messager("版权信息不能为空"); } $result = jtable('plugin')->update($data, array('pluginid' => $id)); $this->Messager("插件设计完善成功", 'admin.php?mod=plugindesign&code=design&id=' . $id); }
function init($file, $type, $attachdir) { if (!is_array($file) || empty($file) || !$this->is_upload_file($file['tmp_name']) || trim($file['name']) == '' || $file['size'] == 0) { $this->file = array(); $this->errorcode = 2; //上传失败 return false; } else { $this->type = $this->check_dir_type($type); $this->attachdir = BLOG_ROOT . '/' . $attachdir; $file['size'] = intval($file['size']); $file['name'] = trim($file['name']); $file['thumb'] = ''; $file['ext'] = $this->fileext($file['name']); $file['name'] = htmlspecialchars($file['name'], ENT_QUOTES); if (strlen($file['name']) > 90) { $file['name'] = cutstr($file['name'], 80, '') . '.' . $file['ext']; } $file['isimage'] = $this->is_image_ext($file['ext']); $file['filedir'] = $this->get_target_dir($this->type); $file['filepath'] = $file['filedir'] . $this->get_target_filename() . '.jpg'; $file['target'] = $this->attachdir . '/' . $this->type . '/' . $file['filepath']; $file['imgurl'] = $attachdir . '/' . $this->type . '/' . $file['filepath']; $this->file =& $file; $this->errorcode = 0; return true; } }
function getdata($style, $parameter) { global $_G; $parameter = $this->cookparameter($parameter); $fups = isset($parameter['fups']) && !in_array(0, (array) $parameter['fups']) ? $parameter['fups'] : ''; $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('displayorder', 'threads', 'posts', 'todayposts')) ? $parameter['orderby'] : 'displayorder' : 'displayorder'; $titlelength = isset($parameter['titlelength']) ? intval($parameter['titlelength']) : 40; $summarylength = isset($parameter['summarylength']) ? intval($parameter['summarylength']) : 80; $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0; $items = !empty($parameter['items']) ? intval($parameter['items']) : 10; $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array(); $sqlban = !empty($bannedids) ? ' AND f.fid NOT IN (' . dimplode($bannedids) . ')' : ''; if (empty($fups)) { loadcache('forums'); if (empty($_G['cache']['forums'])) { $fups = array('0'); } else { $fups = array_keys($_G['cache']['forums']); } } $ffadd1 = ", ff.icon, ff.description"; $ffadd2 = "LEFT JOIN `" . DB::table('forum_forumfield') . "` ff ON f.`fid`=ff.`fid`"; $query = DB::query("SELECT f.* {$ffadd1}\r\n\t\t\tFROM `" . DB::table('forum_forum') . "` f {$ffadd2}\r\n\t\t\tWHERE\r\n\t\t\t" . ($fups ? "f.`fup` IN (" . dimplode($fups) . ") " : "1 ") . "\r\n\t\t\tAND f.`status`='1' AND f.`type`!='group'\r\n\t\t\t{$sqlban}\r\n\t\t\tORDER BY " . ($orderby == 'displayorder' ? "f.fup, f.`displayorder` ASC " : "f.`{$orderby}` DESC") . " LIMIT {$startrow}, {$items}"); $datalist = $list = array(); $attachurl = preg_match('/^(http|ftp|ftps|https):\\/\\//', $_G['setting']['attachurl']) ? $_G['setting']['attachurl'] : $_G['siteurl'] . $_G['setting']['attachurl']; while ($data = DB::fetch($query)) { if (!empty($data['icon'])) { $data['icon'] = preg_match('/^(http|ftp|ftps|https):\\/\\//', $data['icon']) ? $data['icon'] : $attachurl . 'common/' . $data['icon']; } else { $data['icon'] = 'static/image/common/forum_new.gif'; } $list[] = array('id' => $data['fid'], 'idtype' => 'fid', 'title' => cutstr($data['name'], $titlelength, ''), 'url' => 'forum.php?mod=forumdisplay&fid=' . $data['fid'], 'pic' => '', 'summary' => cutstr($data['description'], $summarylength, ''), 'fields' => array('fulltitle' => $data['name'], 'icon' => $data['icon'], 'threads' => intval($data['threads']), 'posts' => intval($data['posts']), 'todayposts' => intval($data['todayposts']))); } return array('html' => '', 'data' => $list); }
public function listtitle($db, $cid, $length, $limit, $parentclass) { $sql = 'select * from `article` where'; if ($parentclass) { $sql1 = 'select `cid` from `class` where isfinal=1 and parentclass like \'' . $parentclass . '|' . $cid . ',%\''; $result = $db->_query($sql1); if ($result->num_rows) { for ($i = 0; $i < $result->num_rows; ++$i) { $class = $result->fetch(); $sql .= 'or cid=\'' . $class['cid'] . '\' '; } $sql = substr($sql, 2); } else { return '暂无内容'; } $sql .= 'order by aid desc'; } else { $sql .= ' `cid`=\'' . $cid . '\' order by aid desc'; } $result = $db->_query($sql, $limit); if (!$result->num_rows) { return '暂无内容'; } $listtitle = ''; for ($i = 0; $i < $result->num_rows; ++$i) { $article = $result->fetch(); $article['title'] = cutstr($article['title']); include ABSPATH . TPLPATH . 'listtitle.html'; $listtitle .= $listtitle_html; } return $listtitle; }
function getstr($string, $length, $in_slashes = 0, $out_slashes = 0, $censor = 0, $bbcode = 0, $html = 0) { global $_G; $string = trim($string); if ($in_slashes) { $string = dstripslashes($string); } if ($html < 0) { $string = preg_replace("/(\\<[^\\<]*\\>|\r|\n|\\s|\\[.+?\\])/is", ' ', $string); } elseif ($html == 0) { $string = dhtmlspecialchars($string); } if ($censor) { if (!class_exists('discuz_censor')) { include libfile('class/censor'); } $censor = discuz_censor::instance(); $censor->check($string); if ($censor->modbanned() || $censor->modmoderated()) { showmessage('word_banned'); } } if ($length) { $string = cutstr($string, $length); } if ($bbcode) { require_once DISCUZ_ROOT . './source/class/class_bbcode.php'; $bb =& bbcode::instance(); $string = $bb->bbcode2html($string, $bbcode); } if ($out_slashes) { $string = daddslashes($string); } return trim($string); }
function spacecutstr($str, $length) { $bbcodes = 'b|i|u|color|size|font|align|list|indent|url|email|code|free|table|tr|td|img|swf|payto|float'; $str = shtmlspecialchars(cutstr(strip_tags(preg_replace(array("/\\[hide=?\\d*\\](.+?)\\[\\/hide\\]/is", "/\\[quote](.*)\\[\\/quote]/siU", "/\\[({$bbcodes})=?.*\\]/iU", "/\\[\\/({$bbcodes})\\]/i", "/\\[attach\\](\\d+)\\[\\/attach\\]/i"), array("[b]***[/b]", '', '', '', ''), $str)), $length)); $find = array("/http:\\/\\/[a-z0-9\\/\\-_+=.~!%@?#%&;:\$\\()|]+?\\.(jpg|gif|png|bmp)/is", "/(\n|\r|\r\n){2,}/", "/\\s{2,}/"); $replace = array("<img onload=\"if(this.width>320) {this.resized=true;this.width=320;}\" src=\"\\0\">", "\r\n", ''); $str = preg_replace($find, $replace, $str); return trim(nl2br($str)); }
function showlistrowphoto($value) { global $_G, $BASESCRIPT; $mlist = ''; $value['url'] = 'store.php?id=' . $value['shopid'] . '&action=album&xid=' . $value['albumid'] . '" target="_blank"'; $imgurl = getattachurl($value['subjectimage'], 1); $value['subject'] = cutstr($value['subject'], 15); $mlist = "\n\t<li>\t\t \n\t\t<div class=\"b\">\n\t\t\t\t\t<p><a href=\"{$value['url']}\" rel=\"internal\" title=\"{$value['subject']}\">\n\t\t\t<img class=\"fit129\" src=\"{$imgurl}\" rel=\"\" height=\"128\" width=\"128\" /></a>\n\t\t\t</p>\n\t\t</div>\n\t\n\t\t<div class=\"w\" style=\"margin-top:5px; \">\n\t\t\t<div id=\"flExpand\" style=\"height:75; line-height:20px;\">\n\t\t\t\t<div id=\"div_subject_{$value['itemid']}\" style=\"position:absolute; display:none;\">\n\t\t\t\t\t<input id=\"input_subject_{$value['itemid']}\" style=\"height:20px; border:#ccc 1px solid; padding:1px;\" name=\"subject['{$value['itemid']}']\" onblur=\"edit_photo_subject({$value['itemid']}, this.value);\" value=\"{$value['subject']}\" />\n\t\t\t\t</div>\n\t\t\t\t<a id=\"label_subject_{$value['itemid']}\" href=\"javascript:;\" onclick=\"start_edit_photo_subject('{$value['itemid']}');\" style=\"display:block; height:30px; line-height:30px; text-decoration:none;\" rel=\"internal\" title=\"{$value['subject']}\">{$value['subject']} <img src=\"static/image/ico_edit.png\" /></a>\n\t\t\t\t" . lang('photo_albumid') . ': ' . $value['title'] . "<br />\n\t\t\t\t" . "<div><a href=\"" . $BASESCRIPT . '?action=batchmod&operation=setalbumimg&albumid=' . $value['albumid'] . '&photoid=' . $value['itemid'] . "\">" . lang('setalbumimg') . "</a></div>" . "\n\t\t\t\t<input class=\"checkbox\" style=\"\" type=\"checkbox\" name=\"item[]\" value=\"" . $value['itemid'] . "\" checked />" . lang('select') . "\n\t\t\t\t<span></span>\n\t\t\t</div>\n\t\t</div>\n\t</li>\n\t"; return $mlist; }
private function _userReportType($res, $rtype, $rid, $message) { global $_G; if ($rtype == 'post') { $tid = UserReport::getTidByPid($rid); } $fid = intval($_GET['fid']); $uid = intval($_GET['uid']); $message = WebUtils::t(rawurldecode($message)); $default_url = array('user' => 'home.php?mod=space&uid=', 'post' => 'forum.php?mod=redirect&goto=findpost&ptid=' . $tid . '&pid=', 'thread' => 'forum.php?mod=viewthread&tid=', 'group' => 'forum.php?mod=group&fid=', 'album' => 'home.php?mod=space&do=album&uid=' . $uid . '&id=', 'blog' => 'home.php?mod=space&do=blog&uid=' . $uid . '&id=', 'pic' => 'home.php?mod=space&do=album&uid=' . $uid . '&picid='); $url = ''; if ($rid && !empty($default_url[$rtype])) { $url = $default_url[$rtype] . intval($rid); } else { $url = addslashes(dhtmlspecialchars(base64_decode($_GET['url']))); $url = preg_match("/^http[s]?:\\/\\/[^\\[\"']+\$/i", trim($url)) ? trim($url) : ''; } if (empty($url)) { $res = $this->makeErrorInfo($res, 'report_parameters_invalid'); } else { $urlkey = md5($url); $message = censor(cutstr(dhtmlspecialchars(trim($message)), 200, '')); $message = $_G['username'] . ' : ' . rtrim($message, "\\"); if ($reportid = C::t('common_report')->fetch_by_urlkey($urlkey)) { C::t('common_report')->update_num($reportid, $message); } else { $data = array('url' => $url, 'urlkey' => $urlkey, 'uid' => $_G['uid'], 'username' => $_G['username'], 'message' => $message, 'dateline' => TIMESTAMP); if ($fid) { $data['fid'] = $fid; } C::t('common_report')->insert($data); $report_receive = unserialize($_G['setting']['report_receive']); $moderators = array(); if ($report_receive['adminuser']) { foreach ($report_receive['adminuser'] as $touid) { notification_add($touid, 'report', 'new_report', array('from_id' => 1, 'from_idtype' => 'newreport'), 1); } } if ($fid && $rtype == 'post') { foreach (C::t('forum_moderator')->fetch_all_by_fid($fid, false) as $row) { $moderators[] = $row['uid']; } if ($report_receive['supmoderator']) { $moderators = array_unique(array_merge($moderators, $report_receive['supmoderator'])); } foreach ($moderators as $touid) { $touid != $_G['uid'] && !in_array($touid, $report_receive) && notification_add($touid, 'report', 'new_post_report', array('fid' => $fid, 'from_id' => 1, 'from_idtype' => 'newreport'), 1); } } } $params['noError'] = 1; $res = $this->makeErrorInfo($res, 'report_succeed', $params); } return $res; }
public function upload($upload, $newfilename = '', $allowtype = array('jpg', 'png', 'gif')) { //$upload['tmp_name'] = str_replace('\\\\', '\\', $upload['tmp_name']); $typeallow = (array) $allowtype; try { if (!is_uploaded_file($upload['tmp_name']) || $upload['size'] == 0) { $this->error = 501; throw new Exception($this->errormsg[$this->error]); } else { if ($this->usedate) { $uploadpath = $this->path . date('Ymd') . '/'; } else { $uploadpath = $this->path; } $this->upload['size'] = intval($upload['size']); $this->upload['name'] = htmlspecialchars(trim($upload['name']), ENT_QUOTES); $this->upload['ext'] = $this->fileext($upload['name']); if (!$this->filetypecheck($typeallow)) { $this->error = 503; throw new Exception($this->errormsg[$this->error]); } $this->upload['localname'] = !$newfilename ? date('Ymd') . cutstr(md5($this->upload['name']), 20) . '.' . $this->upload['ext'] : $newfilename . '.' . $this->upload['ext']; if (strlen($this->upload['name']) > 90) { $this->upload['name'] = cutstr($this->upload['name'], 80, '') . '.' . $this->upload['ext']; } $this->upload['pathdir'] = $uploadpath; if (!helper_file::checkdir($this->upload['pathdir'])) { helper_file::makedir($this->upload['pathdir']); } $this->upload['path'] = Uoke_ROOT . $this->upload['pathdir'] . $this->upload['localname']; if (move_uploaded_file($upload['tmp_name'], $this->upload['path'])) { $this->error = 0; } elseif (copy($upload['tmp_name'], $this->upload['path'])) { $this->error = 0; } elseif (is_readable($upload['tmp_name']) && ($fp_s = fopen($upload['tmp_name'], 'rb')) && ($fp_t = fopen($this->upload['path'], 'wb'))) { while (!feof($fp_s)) { $s = fread($fp_s, 1024 * 512); fwrite($fp_t, $s); } fclose($fp_s); fclose($fp_t); $this->error = 0; } else { $this->error = 502; throw new Exception($this->errormsg[$this->error]); } $this->upload['path'] = str_replace(Uoke_ROOT, '', $this->upload['path']); clearstatcache(); return $this; } } catch (Exception $e) { return $this; } }
function spacecutstr($str, $length) { global $_DCACHE; include_once DISCUZ_ROOT . './forumdata/cache/cache_post.php'; $bbcodes = 'b|i|u|color|size|font|align|list|indent|url|email|code|free|table|tr|td|img|swf|payto|float' . ($_DCACHE['bbcodes_display'] ? '|' . implode('|', array_keys($_DCACHE['bbcodes_display'])) : ''); $str = dhtmlspecialchars(cutstr(strip_tags(preg_replace(array("/\\[hide=?\\d*\\](.+?)\\[\\/hide\\]/is", "/\\[quote](.*)\\[\\/quote]/siU", "/\\[({$bbcodes})=?.*\\]/iU", "/\\[\\/({$bbcodes})\\]/i", "/\\[attach\\](\\d+)\\[\\/attach\\]/i", "/\\[media=(\\w{1,4}),(\\d{1,4}),(\\d{1,4}),(\\d)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/i"), array('', '', '', '', '', "\\5"), $str)), $length)); $find = array("/http:\\/\\/[a-z0-9\\/\\-_+=.~!%@?#%&;:\$\\()|]+?\\.(jpg|gif|png|bmp)/is", "/(\n|\r|\r\n){2,}/", "/\\s{2,}/"); $replace = array("<img onload=\"if(this.width>320) {this.resized=true;this.width=320;}\" src=\"\\0\">", "\r\n", ''); $str = preg_replace($find, $replace, $str); return trim(nl2br($str)); }
public function get_resideprovince_by_ip($ip) { require_once libfile('function/misc'); $location = cutstr(str_replace('- ', '', convertip($ip)), 4, ''); if (!empty($location)) { $district = DB::fetch_first('SELECT * FROM %t WHERE level=1 AND (usetype&2>0) AND name LIKE %s', array($this->_table, $location . '%')); if (!empty($district)) { return $district['name']; } } return NULL; }
public function doMobileDetail() { global $_W, $_GPC; $id = intval($_GPC['id']); $item = pdo_fetch("SELECT * FROM " . tablename('business') . " WHERE id = :id", array(':id' => $id)); if (empty($item)) { message('抱歉,该商家不存在或是已经被删除!'); } $content = strip_tags($item['content']); $content = cutstr($content, 50, true); include $this->template('detail'); }
function get_child_list($tree_id = 0) { $three_arr = array(); $child_sql = "SELECT id,content,cid,rank FROM " . DB_TABLEPRE . "quick_content WHERE cid = '{$tree_id}' ORDER BY rank"; $res = $this->db->fetch_all($child_sql, 'id'); foreach ($res as $row) { $three_arr[$row['id']]['id'] = $row['id']; $three_arr[$row['id']]['alt'] = str_replace(" ", " ", htmlspecialchars($row['content'])); $three_arr[$row['id']]['content'] = cutstr($row['content'], 20); } return $three_arr; }
function shy9000_famehall_updateCache() { $query = DB::query("SELECT g.groupname, g.grouppic, m.uid, m.gid, m.value FROM " . DB::table('mingrentang') . " m, " . DB::table('mingrentanggroup') . " g WHERE m.gid=g.id ORDER BY m.uid"); while ($famehall = DB::fetch($query)) { $return[$famehall['uid']][] = $famehall['groupname']; $return2[$famehall['uid']][] = $famehall['gid']; $return3[$famehall['uid']][] = cutstr($famehall['value'], 40); $return4[$famehall['uid']][] = $famehall['grouppic'] ? $famehall['grouppic'] : 'def.gif'; } require_once libfile('function/cache'); writetocache('famehall_cache', getcachevars(array('_FHCACHE' => array('gname' => $return, 'gid' => $return2, 'js' => $return3, 'pic' => $return4)))); return $return; }
function add($qids) { $time = $this->base->time; $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "question WHERE `id` IN ({$qids}) AND status=6"); $addsql = "REPLACE INTO " . DB_TABLEPRE . "recommend (`qid`,`cid`,`title`,`description`,`image`,`url`,`time`) VALUES "; while ($question = $this->db->fetch_array($query)) { $src = getfirstimg($question['description']); $strip_titile = cutstr($question['title'], 45); $strip_desc = cutstr(strip_tags($question['description']), 70); $addsql .= "(" . $question['id'] . "," . $question['cid'] . ",'{$strip_titile}','{$strip_desc}','{$src}','" . $question['url'] . "',{$time}),"; } return $this->db->query(substr($addsql, 0, -1)); }
function _fetch_data($block_id) { global $_G, $postlist, $config, $authorid, $new_window, $tid, $hott; $db = DB::object(); $tablepre = $db->tablepre; $limit = $config['show_limit'] > 0 ? $config['show_limit'] : '6'; $only_lz = $hott[$block_id]['only_lz'] ? ' AND uid=' . $authorid : ''; $date_limit = $config['date_limit'] == 0 ? '' : ' AND dateline>' . ($_G['timestamp'] - $config['date_limit'] * 86400); $query = DB::query("SELECT blogid,subject FROM {$tablepre}home_blog WHERE blogid>0 {$only_lz}{$date_limit} ORDER BY dateline DESC LIMIT 0,{$limit}"); while ($thread = DB::fetch($query)) { $hott_block[] = array('link' => "home.php?mod=space&do=blog&id={$thread[blogid]}", 'link_info' => $new_window, 'subject' => cutstr($thread['subject'], $config['max_text'])); } return (array) $hott_block; }
public function fetch_by_id($id) { $value = self::fetch($id); $cloud = DB::fetch_first("select * from " . DB::table('connect') . " where bz='{$value['bz']}'"); $value['access_id'] = authcode($value['access_id'], 'DECODE', $value['bz']) ? authcode($value['access_id'], 'DECODE', $value['bz']) : $value['access_id']; if (!$value['cloudname']) { $value['cloudname'] = $cloud['name'] . ':' . ($value['bucket'] ? $value['bucket'] : cutstr($value['access_id'], 4, '')); } if ($value['bucket']) { $value['bucket'] .= '/'; } $data = array('id' => $value['id'], 'fid' => md5($cloud['bz'] . ':' . $value['id'] . ':' . $value['bucket']), 'pfid' => 0, 'fname' => $value['cloudname'], 'ficon' => 'dzz/images/default/system/' . $cloud['bz'] . '.png', 'bz' => $cloud['bz'] . ':' . $value['id'] . ':', 'path' => $cloud['bz'] . ':' . $value['id'] . ':' . $value['bucket'], 'type' => 'storage', 'fsperm' => $value['bucket'] ? '0' : perm_FolderSPerm::flagPower($cloud['bz'] . '_root'), 'perm' => perm_binPerm::getGroupPower('all'), 'flag' => $cloud['bz'], 'iconview' => 1, 'disp' => '0'); return $data; }
function build_cache_announcements() { $data = C::t('forum_announcement')->fetch_all_by_date(TIMESTAMP); foreach ($datarow as $data) { if ($datarow['type'] == 2) { $datarow['pmid'] = $datarow['id']; unset($datarow['id']); unset($datarow['message']); $datarow['subject'] = cutstr($datarow['subject'], 60); } $datarow['groups'] = empty($datarow['groups']) ? array() : explode(',', $datarow['groups']); $data[] = $datarow; } savecache('announcements', $data); }
function _fetch_data($block_id) { global $_G, $postlist, $config, $authorid, $new_window, $tid, $hott; $db = DB::object(); $tablepre = $db->tablepre; $limitforum = $config['disallow_fid'] ? ' AND fid NOT IN (' . dimplode(unserialize($config['disallow_fid'])) . ')' : ''; $limit = $config['show_limit'] > 0 ? $config['show_limit'] : '6'; $show_group = $config['show_group'] ? '' : ' AND isgroup=0'; $date_limit = $config['date_limit'] == 0 ? '' : ' AND dateline>' . ($_G['timestamp'] - $config['date_limit'] * 86400); $query = DB::query("SELECT tid,highlight,subject FROM {$tablepre}forum_thread WHERE displayorder>-1 {$limitforum}{$date_limit}{$show_group} ORDER BY lastpost DESC LIMIT 0,{$limit}"); while ($thread = DB::fetch($query)) { $hott_block[] = array('tid' => $thread['tid'], 'link' => "forum.php?mod=redirect&tid={$thread[tid]}&goto=lastpost#lastpost", 'link_info' => $new_window . $this->_sethighlight($thread['highlight']), 'subject' => cutstr($thread['subject'], $config['max_text'])); } return (array) $hott_block; }
function getdata($style, $parameter) { global $_G; $parameter = $this->cookparameter($parameter); $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40; $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : '0'; $items = !empty($parameter['items']) ? intval($parameter['items']) : 10; $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array(); $bansql = $bannedids ? ' AND appid NOT IN (' . dimplode($bannedids) . ')' : ''; $sql = 'SELECT * FROM ' . DB::table('common_myapp') . " WHERE flag>=0 {$bansql} ORDER BY flag DESC, displayorder LIMIT {$startrow}, {$items}"; $query = DB::query($sql); while ($data = DB::fetch($query)) { $list[] = array('id' => $data['appid'], 'idtype' => 'appid', 'title' => cutstr(str_replace('\\\'', ''', $data['appname']), $titlelength, ''), 'url' => 'userapp.php?id=' . $data['appid'], 'pic' => '', 'picflag' => '', 'summary' => '', 'fields' => array('icon' => 'http://appicon.manyou.com/logos/' . $data['appid'], 'icon_small' => 'http://appicon.manyou.com/icons/' . $data['appid'], 'icon_abouts' => 'http://appicon.manyou.com/abouts/' . $data['appid'])); } return array('html' => '', 'data' => $list); }
function getdata($style, $parameter) { global $_G; $type = !empty($parameter['type']) && is_array($parameter['type']) ? array_map('intval', $parameter['type']) : array('0'); $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40; $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80; $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : '0'; $items = !empty($parameter['items']) ? intval($parameter['items']) : 10; $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array(); $time = TIMESTAMP; $list = array(); foreach (C::t('forum_announcement')->fetch_all_by_time($time, $type, $bannedids, $startrow, $items) as $data) { $list[] = array('id' => $data['id'], 'idtype' => 'announcementid', 'title' => cutstr(str_replace('\\\'', ''', strip_tags($data['subject'])), $titlelength, ''), 'url' => $data['type'] == '1' ? $data['message'] : 'forum.php?mod=announcement&id=' . $data['id'], 'pic' => '', 'picflag' => '', 'summary' => cutstr(str_replace('\\\'', ''', $data['message']), $summarylength, ''), 'fields' => array('starttime' => $data['starttime'], 'endtime' => $data['endtime'])); } return array('html' => '', 'data' => $list); }
function build_cache_announcements() { $data = array(); $query = DB::query("SELECT id, subject, type, starttime, endtime, displayorder, groups, message FROM " . DB::table('forum_announcement') . "\r\n\t\tWHERE starttime<='" . TIMESTAMP . "' AND (endtime>='" . TIMESTAMP . "' OR endtime='0') ORDER BY displayorder, starttime DESC, id DESC"); while ($datarow = DB::fetch($query)) { if ($datarow['type'] == 2) { $datarow['pmid'] = $datarow['id']; unset($datarow['id']); unset($datarow['message']); $datarow['subject'] = cutstr($datarow['subject'], 60); } $datarow['groups'] = empty($datarow['groups']) ? array() : explode(',', $datarow['groups']); $data[] = $datarow; } save_syscache('announcements', $data); }
static function addFeed($uid, $username, $url, $where, $action, $event, $desc, $images = array()) { $feed = array(); $feed['icon'] = 'thread'; $feed['title_template'] = '<b>{username} 在{where}{action}了{event}</b>'; $feed['title_data'] = array('username' => $username, 'where' => $where, 'action' => $action, 'event' => $event); $feed['body_template'] = '<br>{message}'; $feed['body_data'] = array('message' => cutstr(strip_tags(preg_replace("/\\[.+?\\]/is", '', $desc)), 150)); $feed['images'] = $images; $addfeed = uc_feed_add($feed['icon'], $uid, $username, $feed['title_template'], $feed['title_data'], $feed['body_template'], $feed['body_data'], '', '', $feed['images']); if ($addfeed > 0) { return $addfeed; } else { self::$lastAction = 'addfeed'; self::$lastErrorCode = $addfeed; return FALSE; } }