本文整理汇总了PHP中cn_substr函数的典型用法代码示例。如果您正苦于以下问题:PHP cn_substr函数的具体用法?PHP cn_substr怎么用?PHP cn_substr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cn_substr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CoOnePage
/**
* 获取一个页面
*
* @access public
* @param string $gurl 操作地址
* @return string
*/
function CoOnePage($gurl)
{
global $dsql, $cfg_auot_description, $cfg_soft_lang;
$redatas = array('title' => '', 'body' => '', 'source' => '', 'writer' => '', 'description' => '', 'keywords' => '');
$redatas['source'] = preg_replace("/http:\\/\\//i", "", $gurl);
$redatas['source'] = preg_replace("/\\/(.*)\$/i", "", $redatas['source']);
$row = $dsql->GetOne("SELECT * FROM `#@__co_onepage` WHERE url LIKE '" . $redatas['source'] . "' ");
$s = $e = '';
if (is_array($row)) {
list($s, $e) = explode('{@body}', $row['rule']);
$s = trim($s);
$e = trim($e);
if ($row['issource'] == 1) {
$redatas['source'] = $row['title'];
}
}
$htd = new DedeHttpDown();
$htd->OpenUrl($gurl);
$body = $htd->GetHtml();
if ($body != '') {
//编码自动转换
if ($cfg_soft_lang == 'utf-8') {
if ($row['lang'] == 'gb2312') {
$body = gb2utf8($body);
}
} else {
if ($cfg_soft_lang == 'gb2312') {
if ($row['lang'] == 'utf-8') {
$body = utf82gb($body);
}
}
}
//获取标题
$inarr = array();
preg_match("/<title>(.*)<\\/title>/isU", $body, $inarr);
if (isset($inarr[1])) {
$redatas['title'] = $inarr[1];
}
//获取关键词
$inarr = array();
preg_match("/<meta[\\s]+name=['\"]keywords['\"] content=['\"](.*)['\"]/isU", $body, $inarr);
if (isset($inarr[1])) {
$redatas['keywords'] = cn_substr(html2text($inarr[1]), 30);
}
//获取摘要
$inarr = array();
preg_match("/<meta[\\s]+name=['\"]description['\"] content=['\"](.*)['\"]/isU", $body, $inarr);
if (isset($inarr[1])) {
$redatas['description'] = cn_substr(html2text($inarr[1]), $cfg_auot_description);
}
//获取内容
if ($s != '' && $e != '') {
$redatas['body'] = GetHtmlAreaA($s, $e, $body);
if ($redatas['body'] != '' && $redatas['description'] == '') {
$redatas['description'] = cn_substr(html2text($redatas['body']), $GLOBALS['cfg_auot_description']);
}
}
}
return $redatas;
}
示例2: lib_feedback
/**
* 调用最新评论
*
* @param int row 12
* int infolen 10
* @param int titlelen 100
* @return unknown
*/
function lib_feedback(&$ctag, &$refObj)
{
global $dsql;
$attlist = "row|12,titlelen|24,infolen|100";
FillAttsDefault($ctag->CAttribute->Items, $attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$innertext = trim($ctag->GetInnerText());
$totalrow = $row;
$revalue = '';
if (empty($innertext)) {
$innertext = GetSysTemplets('tag_feedback.htm');
}
$wsql = " where ischeck=1 ";
$equery = "SELECT * FROM `#@__feedback` {$wsql} ORDER BY id DESC LIMIT 0 , {$totalrow}";
$ctp = new DedeTagParse();
$ctp->SetNameSpace('field', '[', ']');
$ctp->LoadSource($innertext);
$dsql->Execute('fb', $equery);
while ($arr = $dsql->GetArray('fb')) {
$arr['title'] = cn_substr($arr['arctitle'], $titlelen);
$arr['msg'] = jstrim($arr['msg'], $infolen);
foreach ($ctp->CTags as $tagid => $ctag) {
if (!empty($arr[$ctag->GetName()])) {
$ctp->Assign($tagid, $arr[$ctag->GetName()]);
}
}
$revalue .= $ctp->GetResult();
}
return $revalue;
}
示例3: GetArchives
/**
* 获取文档
*
* @param object $dsql
* @param string $ordertype 排序类型
* @return string
*/
function GetArchives($dsql, $ordertype)
{
$starttime = time() - 24 * 3600 * 30;
if ($ordertype == 'monthFeedback' || $ordertype == 'monthHot') {
$swhere = " where senddate>{$starttime} ";
} else {
$swhere = "";
}
if (preg_match("#feedback#", $ordertype)) {
$ordersql = " ORDER BY scores DESC ";
} else {
$ordersql = " ORDER BY click DESC ";
}
$query = "SELECT id,title,click,scores FROM #@__archives {$swhere} {$ordersql} LIMIT 0,20 ";
$dsql->SetQuery($query);
$dsql->Execute('ga');
while ($row = $dsql->GetObject('ga')) {
if (preg_match("#feedback#i", $ordertype)) {
$moreinfo = "[<a target='_blank' href='" . $GLOBALS['cfg_phpurl'] . "/feedback.php?aid={$row->id}'><u>评论:{$row->scores}</u></a>]";
} else {
$moreinfo = "[点击:{$row->click}]";
}
echo "·<a href='archives_do.php?aid={$row->id}&dopost=viewArchives' target='_blank'>";
echo cn_substr($row->title, 30) . "</a>{$moreinfo}<br/>\r\n";
}
}
示例4: JstrimJajxLog
function JstrimJajxLog($str, $len)
{
$str = cn_substr($str, $len);
$str = str_replace(''', '"', $str);
$str = str_replace('<', '<', $str);
$str = str_replace('>', '>', $str);
return $str;
}
示例5: jsTrim
function jsTrim($str, $len)
{
$str = preg_replace("/{quote}(.*){\\/quote}/is", '', $str);
$str = str_replace('<br/>', ' ', $str);
$str = cn_substr($str, $len);
$str = preg_replace("#['\"\r\n]#", "", $str);
return $str;
}
示例6: show_description_text
function show_description_text($s, $len)
{
$s = strip_tags($s);
$s = preg_replace('/ /', ' ', $s);
$s = preg_replace('/\\s{2,}/', '', $s);
$s = cn_substr($s, 0, $len);
return $s;
}
示例7: indexAction
public function indexAction()
{
$keyword = daddslashes($this->reqVar('keyword', ''));
$startTime = daddslashes($this->reqVar('start_time', ''));
$endTime = daddslashes($this->reqVar('end_time', ''));
$page = (int) $this->reqVar('page', 1);
$pageUrl = "/admin/operate/";
if (!empty($keyword)) {
$opertaeSet['operat'] = $keyword;
$pageUrl .= "?keyword={$keyword}";
}
if (!empty($startTime)) {
$opertaeSet['start_time'] = $startTime;
$pageUrl .= !empty($keyword) ? "&" : "?";
$pageUrl .= "&start_time={$startTime}";
}
if (!empty($endTime)) {
$opertaeSet['end_time'] = $endTime;
if (!empty($keyword) || !empty($startTime)) {
$pageUrl .= "&end_time={$endTime}";
} else {
$pageUrl .= "?end_time={$endTime}";
}
}
$operateList = $this->operateModel->getOpLogList($opertaeSet, $page, 20);
if ($operateList) {
foreach ($operateList as $key => $val) {
$contentStr = '';
$content = json_decode($val['content'], true);
// die();
if (is_array($content)) {
foreach ($content as $ckey => $cval) {
$contentStr .= $ckey . "/" . $cval . ",";
}
$contentStr = trim($contentStr, ",");
$contentSub = cn_substr($contentStr, 20);
$operateList[$key]['content'] = $contentStr;
$operateList[$key]['content_sub'] = $contentSub;
} else {
$operateList[$key]['content'] = $operateList[$key]['content_sub'] = $content;
}
// $operateList[$key]['content_sub'] = $val['content'];
}
}
$operateCount = $this->operateModel->getOpLogCount($opertaeSet);
$operatePages = pages($operateCount, $page, 20, $pageUrl, array());
$this->assign('keyword', $keyword);
$this->assign('startTime', $startTime);
$this->assign('endTime', $endTime);
$this->assign('operateList', $operateList);
$this->assign('operatePages', $operatePages);
$this->assign("page", $page);
$this->getViewer()->needLayout(false);
$this->render('operate_list');
}
示例8: lib_flink
function lib_flink(&$ctag, &$refObj)
{
global $dsql;
$attlist = "type|textall,row|24,titlelen|24,linktype|1,typeid|0";
FillAttsDefault($ctag->CAttribute->Items, $attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$totalrow = $row;
$revalue = '';
$wsql = " where ischeck >= '{$linktype}' ";
if ($typeid == 0) {
$wsql .= '';
} else {
$wsql .= "And typeid = '{$typeid}'";
}
if ($type == 'image') {
$wsql .= " And logo<>'' ";
} else {
if ($type == 'text') {
$wsql .= " And logo='' ";
}
}
$equery = "Select * from #@__flink {$wsql} order by sortrank asc limit 0,{$totalrow}";
if (trim($ctag->GetInnerText()) == '') {
$innertext = "<li>[field:link /]</li>";
} else {
$innertext = $ctag->GetInnerText();
}
$dsql->SetQuery($equery);
$dsql->Execute();
while ($dbrow = $dsql->GetObject()) {
if ($type == 'text' || $type == 'textall') {
$link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
} else {
if ($type == 'image') {
$link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='88' height='31' border='0'></a> ";
} else {
if ($dbrow->logo == '') {
$link = "<a href='" . $dbrow->url . "' target='_blank'>" . cn_substr($dbrow->webname, $titlelen) . "</a> ";
} else {
$link = "<a href='" . $dbrow->url . "' target='_blank'><img src='" . $dbrow->logo . "' width='88' height='31' border='0'></a> ";
}
}
}
$rbtext = preg_replace("/\\[field:url([\\/\\s]{0,})\\]/isU", $row['url'], $innertext);
$rbtext = preg_replace("/\\[field:webname([\\/\\s]{0,})\\]/isU", $row['webname'], $rbtext);
$rbtext = preg_replace("/\\[field:logo([\\/\\s]{0,})\\]/isU", $row['logo'], $rbtext);
$rbtext = preg_replace("/\\[field:link([\\/\\s]{0,})\\]/isU", $link, $rbtext);
$revalue .= $rbtext;
}
return $revalue;
}
示例9: plus_spacenewart
function plus_spacenewart(&$atts, &$refObj, &$fields)
{
global $dsql, $_vars;
$attlist = "channel=1,titlelen=30,infolen=200,row=8,imgwidth=120,imgheight=90";
FillAtts($atts, $attlist);
FillFields($atts, $fields, $refObj);
extract($atts, EXTR_OVERWRITE);
$query = "Select arc.*,mt.mtypename,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,\r\n\t\ttp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath\r\n\t\tfrom `#@__archives` arc\r\n\t\tleft join `#@__arctype` tp on arc.typeid=tp.id\r\n\t\tleft join `#@__mtypes` mt on mt.mtypeid=arc.mtype\r\n\t\twhere arc.mid='{$_vars['mid']}' and arc.channel={$channel}\r\n\t\torder by id desc limit 0,{$row}";
$dsql->SetQuery($query);
$dsql->Execute("al");
$artlist = '';
$rearr = array();
while ($row = $dsql->GetArray("al")) {
//处理一些特殊字段
$row['infos'] = cn_substr($row['description'], $infolen);
$row['id'] = $row['id'];
$row['arcurl'] = GetFileUrl($row['id'], $row['typeid'], $row['senddate'], $row['title'], $row['ismake'], $row['arcrank'], $row['namerule'], $row['typedir'], $row['money'], $row['filename'], $row['moresite'], $row['siteurl'], $row['sitepath']);
$row['typeurl'] = GetTypeUrl($row['typeid'], $row['typedir'], $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['moresite'], $row['siteurl'], $row['sitepath']);
if ($row['litpic'] == '') {
$row['litpic'] = '/images/defaultpic.gif';
}
if (!eregi("^http://", $row['litpic'])) {
$row['picname'] = $row['litpic'] = $GLOBALS['cfg_cmsurl'] . $row['litpic'];
} else {
$row['picname'] = $row['litpic'] = $row['litpic'];
}
$row['stime'] = GetDateMK($row['pubdate']);
$row['typelink'] = "<a href='" . $row['typeurl'] . "'>" . $row['typename'] . "</a>";
$row['image'] = "<img src='" . $row['picname'] . "' border='0' width='{$imgwidth}' height='{$imgheight}' alt='" . ereg_replace("['><]", "", $row['title']) . "'>";
$row['imglink'] = "<a href='" . $row['filename'] . "'>" . $row['image'] . "</a>";
$row['fulltitle'] = $row['title'];
$row['title'] = cn_substr($row['title'], $titlelen);
if ($row['color'] != '') {
$row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
}
if (ereg('b', $row['flag'])) {
$row['title'] = "<strong>" . $row['title'] . "</strong>";
}
//$row['title'] = "<b>".$row['title']."</b>";
$row['textlink'] = "<a href='" . $row['filename'] . "'>" . $row['title'] . "</a>";
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
$row['memberurl'] = $GLOBALS['cfg_memberurl'];
$row['templeturl'] = $GLOBALS['cfg_templeturl'];
$rearr[] = $row;
}
//loop line
$dsql->FreeResult("al");
return $rearr;
}
示例10: plus_ask
function plus_ask(&$atts, &$refObj, &$fields)
{
global $dsql, $_vars;
$attlist = "titlelen=40,row=8,typeid=0,sort=";
FillAtts($atts, $attlist);
FillFields($atts, $fields, $refObj);
extract($atts, EXTR_OVERWRITE);
$wheresql = ' 1 ';
if ($sort == '') {
$orderby = 'order by id desc';
} else {
if ($sort == 'commend') {
$wheresql .= ' And digest=1';
$orderby = ' order by dateline desc';
} else {
if ($sort == 'ok') {
$wheresql .= ' And status=1 ';
$orderby = ' order by solvetime desc';
} else {
if ($sort == 'expiredtime') {
$wheresql .= ' And status=0 ';
$orderby = ' order by expiredtime asc, dateline desc';
} else {
if ($sort == 'reward') {
$wheresql .= ' And status=0 ';
$orderby = ' order by reward desc';
} else {
$wheresql .= ' And status=0 ';
$orderby = ' order by disorder desc, dateline desc';
}
}
}
}
}
$query = "select id, tid, tidname, tid2, tid2name, title from `#@__ask` where {$wheresql} {$orderby} limit {$row}";
$dsql->SetQuery($query);
$dsql->Execute('an');
$rearr = array();
while ($row = $dsql->GetArray('an')) {
if ($row['tid2'] != 0) {
$row['typelink'] = $row['typedata'] = " <a href='browser.php?tid2={$row['tid2']}'>{$row['tid2name']}</a>\r\n";
} else {
$row['typelink'] = $row['typedata'] = " <a href='browser.php?tid={$row['tid']}'>{$row['tidname']}</a>\r\n";
}
$row['title'] = cn_substr($row['title'], $titlelen);
$rearr[] = $row;
}
return $rearr;
}
示例11: IsCommendArchives
function IsCommendArchives($iscommend)
{
global $arcatts;
$sn = '';
foreach ($arcatts as $k => $v) {
$v = cn_substr($v, 2);
$sn .= preg_match("#" . $k . "#", $iscommend) ? ' ' . $v : '';
}
$sn = trim($sn);
if ($sn == '') {
return '';
} else {
return "[<font color='red'>{$sn}</font>]";
}
}
示例12: lib_groupthread
function lib_groupthread(&$ctag, &$refObj)
{
global $dsql, $envs, $cfg_dbprefix, $cfg_cmsurl;
//属性处理
$attlist = "gid|0,orderby|dateline,orderway|desc,row|12,titlelen|30";
FillAttsDefault($ctag->CAttribute->Items, $attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
if (!$dsql->IsTable("{$cfg_dbprefix}groups")) {
return '没安装圈子模块';
}
if (!preg_match("#\\/\$#", $cfg_cmsurl)) {
$cfg_group_url = $cfg_cmsurl . "/group";
} else {
$cfg_group_url = $cfg_cmsurl . "group";
}
$innertext = $ctag->GetInnerText();
if (trim($innertext) == '') {
$innertext = GetSysTemplets('groupthreads.htm');
}
$WhereSql = " WHERE t.closed=0 ";
$orderby = 't.' . $orderby;
if ($gid > 0) {
$WhereSql .= " AND t.gid='{$gid}' ";
}
$query = "SELECT t.subject,t.gid,t.tid,t.lastpost,g.groupname FROM `#@__group_threads` t \r\n LEFT JOIN `#@__groups` g ON g.groupid=t.gid\r\n {$WhereSql} ORDER BY {$orderby} {$orderway} LIMIT 0,{$row}";
$dsql->SetQuery($query);
$dsql->Execute();
$ctp = new DedeTagParse();
$ctp->SetNameSpace('field', '[', ']');
if (!isset($list)) {
$list = '';
}
while ($rs = $dsql->GetArray()) {
$ctp->LoadSource($innertext);
$rs['subject'] = cn_substr($rs['subject'], $titlelen);
$rs['url'] = $cfg_group_url . "/viewthread.php?id={$rs['gid']}&tid={$rs['tid']}";
$rs['groupurl'] = $cfg_group_url . "/group.php?id={$rs['gid']}";
foreach ($ctp->CTags as $tagid => $ctag) {
if (!empty($rs[strtolower($ctag->GetName())])) {
$ctp->Assign($tagid, $rs[$ctag->GetName()]);
}
}
$list .= $ctp->GetResult();
}
return $list;
}
示例13: GetOneArchive
function GetOneArchive($aid)
{
global $dsql;
include_once DEDEINC . "/channelunit.func.php";
$aid = trim(preg_replace('/[^0-9]/', '', $aid));
$reArr = array();
$chRow = $dsql->GetOne("SELECT arc.*,ch.maintable,ch.addtable,ch.issystem FROM `#@__arctiny` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='{$aid}' ");
if (!is_array($chRow)) {
return $reArr;
} else {
if (empty($chRow['maintable'])) {
$chRow['maintable'] = '#@__archives';
}
}
if ($chRow['issystem'] != -1) {
$nquery = " SELECT arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\n FROM `{$chRow['maintable']}` arc LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid\n WHERE arc.id='{$aid}' ";
} else {
$nquery = " SELECT arc.*,1 AS ismake,0 AS money,'' AS filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath\n FROM `{$chRow['addtable']}` arc LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid\n WHERE arc.aid='{$aid}' ";
}
$arcRow = $dsql->GetOne($nquery);
if (!is_array($arcRow)) {
return $reArr;
}
if (!isset($arcRow['description'])) {
$arcRow['description'] = '';
}
if (empty($arcRow['description']) && isset($arcRow['body'])) {
$arcRow['description'] = cn_substr(html2text($arcRow['body']), 250);
}
if (!isset($arcRow['pubdate'])) {
$arcRow['pubdate'] = $arcRow['senddate'];
}
if (!isset($arcRow['notpost'])) {
$arcRow['notpost'] = 0;
}
$reArr = $arcRow;
$reArr['aid'] = $aid;
$reArr['topid'] = $arcRow['topid'];
$reArr['arctitle'] = $arcRow['title'];
$reArr['arcurl'] = GetFileUrl($aid, $arcRow['typeid'], $arcRow['senddate'], $reArr['title'], $arcRow['ismake'], $arcRow['arcrank'], $arcRow['namerule'], $arcRow['typedir'], $arcRow['money'], $arcRow['filename'], $arcRow['moresite'], $arcRow['siteurl'], $arcRow['sitepath']);
return $reArr;
}
示例14: getList
function getList($list, $keyword)
{
global $cfg_cmsurl;
$key = urlencode($keyword);
$str = "<h3>您可能感兴趣的内容<span><a href=\"{$cfg_cmsurl}/cloudsearch_{$key}_0_1.html\" target=\"_blank\">+更多»</a></span></h3>";
$out = '';
for ($i = 0; isset($list[$i]); $i++) {
$row = $list[$i];
$channelname = getChannelName($row['tablename']);
$title = setColor($keyword, cn_substr($row['title'], 36));
$litpic = getLitpic($row['imgurl'], $row['webid'], $row);
$url = getUrl($row['aid'], $row['webid'], $row['tablename'], $row['tag']);
if (!empty($row['title'])) {
$out .= "<li><span class=\"fl\">[{$channelname}]</span><a href=\"{$url}\" target=\"_blank\" title=\"{$row['title']}\">{$title}</a></li>";
}
}
if (!empty($out)) {
$out = $str . "<ul>" . $out . "</ul>";
}
return $out;
}
示例15: lib_group
function lib_group(&$ctag, &$refObj)
{
global $dsql, $envs, $cfg_dbprefix, $cfg_cmsurl;
//属性处理
$attlist = "row|6,orderby|threads,titlelen|30";
FillAttsDefault($ctag->CAttribute->Items, $attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
if (!$dsql->IsTable("{$cfg_dbprefix}groups")) {
return '没安装圈子模块';
}
if (!preg("#\\/\$#", $cfg_cmsurl)) {
$cfg_group_url = $cfg_cmsurl . '/group';
} else {
$cfg_group_url = $cfg_cmsurl . 'group';
}
$innertext = $ctag->GetInnerText();
if (trim($innertext) == '') {
$innertext = GetSysTemplets("groups.htm");
}
$list = '';
$dsql->SetQuery("SELECT groupimg,groupid,groupname FROM `#@__groups` WHERE ishidden=0 ORDER BY {$orderby} DESC LIMIT 0,{$row}");
$dsql->Execute();
$ctp = new DedeTagParse();
$ctp->SetNameSpace('field', '[', ']');
while ($rs = $dsql->GetArray()) {
$ctp->LoadSource($innertext);
$rs['groupname'] = cn_substr($rs['groupname'], $titlelen);
$rs['url'] = $cfg_group_url . "/group.php?id={$rs['groupid']}";
$rs['icon'] = $rs['groupimg'];
foreach ($ctp->CTags as $tagid => $ctag) {
if (!empty($rs[strtolower($ctag->GetName())])) {
$ctp->Assign($tagid, $rs[$ctag->GetName()]);
}
}
$list .= $ctp->GetResult();
}
return $list;
}