本文整理汇总了PHP中substrs函数的典型用法代码示例。如果您正苦于以下问题:PHP substrs函数的具体用法?PHP substrs怎么用?PHP substrs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了substrs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateForumCount
function updateForumCount($fid, $topic, $replies, $tpost = 0)
{
global $db, $db_fcachenum;
$fm = $db->get_one("SELECT fup,type,password,allowvisit,f_type FROM pw_forums WHERE fid=" . S::sqlEscape($fid));
if ($fm['type'] == 'category') {
return false;
}
delfcache($fid, $db_fcachenum);
$topic = intval($topic);
$article = $topic + intval($replies);
$tpost = intval($tpost);
$lastpost = '';
$lt = $db->get_one("SELECT tid,author,postdate,lastpost,lastposter,subject FROM pw_threads WHERE fid=" . S::sqlEscape($fid) . " AND specialsort='0' AND ifcheck='1' AND lastpost>0 ORDER BY lastpost DESC LIMIT 1");
if ($lt) {
if ($lt['postdate'] == $lt['lastpost']) {
$subject = substrs($lt['subject'], 26);
} else {
$subject = 'Re:' . substrs($lt['subject'], 26);
}
$lastpost = ",lastpost=" . S::sqlEscape($subject . "\t" . $lt['lastposter'] . "\t" . $lt['lastpost'] . "\t" . "read.php?tid={$lt['tid']}&page=e#a");
}
$db->update("UPDATE pw_forumdata SET article=article+'{$article}',topic=topic+'{$topic}',tpost=tpost+'{$tpost}'{$lastpost} WHERE fid=" . S::sqlEscape($fid));
Perf::gatherInfo('changeForumData', array('fid' => $fid));
if (($fm['type'] == 'sub' || $fm['type'] == 'sub2') && ($fids = getUpFids($fid))) {
if ($fm['password'] != '' || $fm['allowvisit'] != '' || $fm['f_type'] == 'hidden') {
$lastpost = '';
}
$db->update("UPDATE pw_forumdata SET article=article+'{$article}',subtopic=subtopic+'{$topic}',tpost=tpost+'{$tpost}'{$lastpost} WHERE fid IN(" . S::sqlImplode($fids) . ')');
Perf::gatherInfo('changeForumData', array('fid' => $fids));
}
}
示例2: addSchools
/**
*加入多条学校数据
* @param array $data数据
* @return array $schoolIds学校id
*/
function addSchools($data)
{
if (!S::isArray($data)) {
return false;
}
$fieldData = array();
$schoolNames = array();
$schoolDb = $this->_getSchoolDao();
foreach ($data as $value) {
$value['areaid'] = intval($value['areaid']);
$value['schoolname'] = trim($value['schoolname']);
$value['schoolname'] = trim(substrs($value['schoolname'], 32, 'N'), ' ');
$schoolNames[] = trim($value['schoolname']);
$value['type'] = $value['type'] ? intval($value['type']) : 1;
if (!$value['schoolname'] || $value['areaid'] < 0 || $value['type'] < 0) {
continue;
}
$fieldData[] = $value;
}
$schoolIds = $schoolDb->checkSchoolNames((int) $value['areaid'], $value['type'], $schoolNames);
if ($schoolIds > 0) {
return $schoolIds;
}
return $schoolDb->addSchools($fieldData);
}
示例3: topicPost
function topicPost($tid, $postdata)
{
global $timestamp, $winduid, $windid;
if (!$this->info) {
return false;
}
$this->_db->update("INSERT INTO pw_argument SET " . S::sqlSingle(array('tid' => $tid, 'cyid' => $this->info['id'], 'postdate' => $timestamp, 'lastpost' => $timestamp)));
if ($postdata['ifcheck'] > 0) {
require_once R_P . 'u/require/core.php';
//tnum加一
//* $this->_db->update("UPDATE pw_colonys SET tnum=tnum+'1',pnum=pnum+'1',todaypost=todaypost+'1' WHERE id=" . S::sqlEscape($this->cyid));
$this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET tnum=tnum+1,pnum=pnum+1,todaypost=todaypost+1 WHERE id=:id", array('pw_colonys', $this->cyid)));
$this->info['tnum']++;
$this->info['pnum']++;
updateGroupLevel($this->cyid, $this->info);
if ($this->info['ifopen']) {
$weiboService = L::loadClass('weibo', 'sns');
/* @var $weiboService PW_Weibo */
$weiboContent = substrs(stripWindCode($postdata['content']), 125);
$weiboExtra = array('cyid' => $this->cyid, 'title' => stripslashes($postdata['title']), 'cname' => $this->info['cname']);
$weiboService->send($winduid, $weiboContent, 'group_article', $tid, $weiboExtra);
}
}
//更新群成员表里面的最后发言时间
$this->_db->update("UPDATE pw_cmembers SET lastpost=" . S::sqlEscape($timestamp) . " WHERE uid=" . S::sqlEscape($winduid));
}
示例4: getSourceData
function getSourceData($sourceId)
{
$data = $this->_getThreadData($sourceId);
if (!$data || $this->_checkIfDelete($data)) {
return array();
}
$data['content'] = preg_replace("/\\[attachment=[0-9]+\\]/is", '', $data['content']);
$data['descrip'] = substrs(stripWindCode($data['content']), 100);
$data['frominfo'] = 'ÂÛ̳';
return $data;
}
示例5: getSourceData
function getSourceData($sourceId)
{
$data = $this->_getDiaryData($sourceId);
if (!$data) {
return array();
}
$data['descrip'] = substrs(stripWindCode($data['content']), 100);
$data['frominfo'] = 'хуж╬';
$data['author'] = $data['username'];
return $data;
}
示例6: _cookData
function _cookData($data)
{
global $db_bbsurl;
$data['url'] = $db_bbsurl . '/apps.php?q=group&cyid=' . $data['id'];
$data['title'] = $data['cname'];
$data['image'] = $this->_getGroupImage($data['cnimg']);
$data['descrip'] = substrs(strip_tags(stripWindCode($data['descrip'])), 100);
if ($data['credit']) {
$data['credit'] = (int) $data['credit'];
}
return $data;
}
示例7: set_summary
/**
* @param $_summary the $_summary to set
*/
function set_summary($_summary, $convert)
{
if ($_summary) {
$_summary = stripWindCode($_summary);
$_summary = strip_tags($_summary);
$_summary = str_replace(array('"', "\n", "\r", ' ', '&', '<', '', ' '), '', $_summary);
$_summary = substrs($_summary, 255);
if ($convert) {
$wordsfb = L::loadClass('FilterUtil');
$_summary = $wordsfb->convert($_summary);
}
$this->_summary = trim($_summary);
}
}
示例8: writelog
function writelog($log)
{
global $db, $db_moneyname, $db_rvrcname, $db_bbsurl;
$log['username1'] = S::escapeChar($log['username1']);
$log['username2'] = S::escapeChar($log['username2']);
$log['field1'] = S::escapeChar($log['field1']);
$log['field2'] = S::escapeChar($log['field2']);
$log['field3'] = S::escapeChar($log['field3']);
if (!$log['subject']) {
$log['subject'] = substrs($db_bbsurl . '/read.php?tid=' . $log['tid'], 28);
}
$log['descrip'] = S::escapeChar(getLangInfo('log', $log['descrip'], $log));
$db->update("INSERT INTO pw_adminlog" . " SET " . S::sqlSingle(array('type' => $log['type'], 'username1' => $log['username1'], 'username2' => $log['username2'], 'field1' => $log['field1'], 'field2' => $log['field2'], 'field3' => $log['field3'], 'descrip' => $log['descrip'], 'timestamp' => $log['timestamp'], 'ip' => $log['ip']), false));
}
示例9: getToolsByUidAndNum
/**
* 调取指定个数和指定用户的的道具信息
* @param $uid 调取的用户
* @param $num 调取的个数
* @return array
*/
function getToolsByUidAndNum($uid, $num)
{
$tools = array();
$query = $this->_db->query("SELECT u.*,t.name,t.price,t.creditype,t.stock,t.descrip,t.type,t.logo FROM pw_usertool u LEFT JOIN pw_tools t ON t.id=u.toolid WHERE u.uid=" . S::sqlEscape($uid) . " AND u.nums>0 LIMIT " . intval($num));
while ($rt = $this->_db->fetch_array($query)) {
if (empty($rt['logo'])) {
$rt['logo'] = $GLOBALS['imgpath'] . '/nopic.gif';
} else {
$rt['logo'] = "u/images/toolcenter/tool/{$rt['toolid']}.gif";
}
$rt['subdescrip'] = substrs($rt['descrip'], 20);
$tools[] = $rt;
}
return $tools;
}
示例10: getOneInfo
function getOneInfo($uid)
{
global $db;
$uid = (int) $uid;
if (!$uid) {
Showmsg('undefined_action');
}
$oneinfo = $db->get_one("SELECT m.uid,m.username,m.email,m.groupid,m.memberid,m.icon,m.gender,m.regdate,m.honor,m.bday,m.medals,m.userstatus,md.thisvisit,md.onlinetime,md.postnum,md.digests,md.rvrc,md.money,md.credit,md.lastvisit,md.lastpost,md.todaypost,md.f_num FROM pw_members m LEFT JOIN pw_memberdata md ON m.uid=md.uid WHERE m.uid=" . pwEscape($uid));
if ($oneinfo) {
require_once R_P . 'require/showimg.php';
list($oneinfo['face']) = showfacedesign($oneinfo['icon'], 1);
$oneinfo['honor'] = substrs($oneinfo['honor'], 90);
return $oneinfo;
} else {
return false;
}
}
示例11: _cookData
/**
* 格式化输出结果
* @param unknown_type $data
* @return unknown
*/
function _cookData($data)
{
global $db_bbsurl, $db_windpost;
$data['url'] = $data['url'] ? $data['url'] : $db_bbsurl . '/notice.php?fid=' . $data['fid'] . '#' . $data['aid'];
$data['title'] = convert($data['subject'], $db_windpost);
if ($data['author']) {
$userService = L::loadClass('userService', 'user');
$userId = $userService->getUserIdByUserName($data['author']);
$data['authorurl'] = 'u.php?uid=' . $userId;
} else {
$data['authorurl'] = '';
}
$data['content'] = convert($data['content'], $db_windpost);
$data['descrip'] = substrs(strip_tags($data['content']), 100);
$data['postdate'] = $data['startdate'];
return $data;
}
示例12: getOneInfo
function getOneInfo($uid)
{
global $db;
$uid = (int) $uid;
if (!$uid) {
Showmsg('undefined_action');
}
$userService = L::loadClass('UserService', 'user');
/* @var $userService PW_UserService */
$oneinfo = $userService->get($uid, true, true);
if ($oneinfo) {
require_once R_P . 'require/showimg.php';
list($oneinfo['face']) = showfacedesign($oneinfo['icon'], 1);
$oneinfo['honor'] = substrs($oneinfo['honor'], 90);
return $oneinfo;
} else {
return false;
}
}
示例13: getLangInfo
require_once R_P . 'require/functions.php';
$customdes = getLangInfo('other', 'invite_custom_des');
$tmpUrlAdd .= '&a=invite';
if ($type == 'groupactive') {
$invite_url = $db_bbsurl . '/u.php?a=invite&type=groupactive&id=' . $id . '&uid=' . $winduid . '&hash=' . appkey($winduid, $type);
$activeArray = $db->get_one("SELECT * FROM pw_active WHERE id=" . S::sqlEscape($id));
$objectName = $activeArray['title'];
$objectDescrip = substrs($activeArray['content'], 30);
$activeId = $activeArray['id'];
$emailContent = getLangInfo('email', 'email_groupactive_invite_content');
} else {
$id = $cyid;
$type = 'group';
$invite_url = $db_bbsurl . '/u.php?a=invite&type=group&id=' . $cyid . '&uid=' . $winduid . '&hash=' . appkey($winduid, $type);
$objectName = $colony['cname'];
$objectDescrip = substrs($colony['descrip'], 30);
$emailContent = getLangInfo('email', 'email_group_invite_content');
}
if (empty($_POST['step'])) {
S::gp("id", null, 2);
//* @include_once pwCache::getPath(D_P.'data/bbscache/o_config.php');
pwCache::getData(D_P . 'data/bbscache/o_config.php');
$friend = getFriends($winduid) ? getFriends($winduid) : array();
foreach ($friend as $key => $value) {
$frienddb[$value['ftid']][] = $value;
}
$query = $db->query("SELECT * FROM pw_friendtype WHERE uid=" . S::sqlEscape($winduid) . " ORDER BY ftid");
$friendtype = array();
while ($rt = $db->fetch_array($query)) {
$friendtype[$rt['ftid']] = $rt;
}
示例14: getmco
function getmco($c, $i, $n = 0, $r = 0)
{
$m = 200;
return ($r > 0 && strstr($c, "\r") ? '<br/>' : '') . (strlen($c) > $m ? mbookencode(substrs($c, $m - 5)) . '<br/><a href="?m=list&id=' . $i . ($n > 0 ? '#reply-' . $n : '') . '">查看全部 >></a>' : mbookencode($c));
}
示例15: PrintEot
}
!$rt['pid'] && ($rt['pid'] = 'tpc');
$rt['fname'] = $forum[$rt['fid']]['name'];
$showdb[$key] = $rt;
}
require_once PrintEot('show');
footer();
} else {
$pw_attachs = L::loadDB('attachs', 'forum');
$rt = $pw_attachs->get($aid);
if ($rt && $rt['tid'] && $rt['fid']) {
$pw_tmsgs = GetTtable($rt['tid']);
$rtinfo = $db->get_one("SELECT t.fid,t.subject,t.ifcheck,t.ifshield,tm.content,m.username\r\n\t\t\tFROM pw_threads t LEFT JOIN {$pw_tmsgs} tm ON tm.tid=t.tid\r\n\t\t\tLEFT JOIN pw_members m ON m.uid=t.authorid\r\n\t\t\tWHERE t.tid=" . S::sqlEscape($rt['tid'], false));
if (in_array($rtinfo['fid'], $fidoff) || $rtinfo['ifshield'] == '2' || $groupid != '3' && $groupid != '4' && ($rtinfo['needrvrc'] > $userrvrc || !$rtinfo['ifcheck'] || $rtinfo['ifshield'] || strpos($rtinfo['content'], "[post]") !== false && strpos($rtinfo['content'], "[/post]") !== false || strpos($rtinfo['content'], "[hide") !== false && strpos($rtinfo['content'], "[/hide]") !== false || strpos($rtinfo['content'], "[sell") !== false && strpos($rtinfo['content'], "[/sell]") !== false)) {
Showmsg('pic_not_exists');
}
$rt['subject'] = $rtinfo['subject'];
$rt['username'] = $rtinfo['username'];
$a_url = geturl($rt['attachurl'], 'show');
$rt['a_url'] = is_array($a_url) ? $a_url[0] : $a_url;
$uid = $rt['uid'];
$type = 1;
$owner = $rt['username'];
!$rt['pid'] && ($rt['pid'] = 'tpc');
!$rt['descrip'] && ($rt['descrip'] = substrs(stripWindCode($rtinfo['content']), 120));
} else {
Showmsg('pic_not_exists');
}
require_once PrintEot('show');
footer();
}