本文整理汇总了PHP中getAtName函数的典型用法代码示例。如果您正苦于以下问题:PHP getAtName函数的具体用法?PHP getAtName怎么用?PHP getAtName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getAtName函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: IHomeServiceCreateComplainReply
function IHomeServiceCreateComplainReply($params = NULL)
{
global $_SGLOBAL;
$cpid = 0;
# complain 表中的 id
$relay_times = 0;
if ($params['uid']) {
if ($params['uid'] <= 0) {
$errorMsg = array("errorNo" => "4002", "content" => "the format of parameter is not correct.the parameter uid must be a positive integer.");
return json_encode($errorMsg);
} else {
$query = $_SGLOBAL['db']->query("select name,username from " . tname('space') . " where uid = " . $params['uid']);
if ($row = $_SGLOBAL['db']->fetch_array($query)) {
if ($row['name']) {
$params['uname'] = $row['name'];
} else {
$params['uname'] = $row['username'];
}
} else {
$errorMsg = array("errorNo" => "500", "content" => "the uid is not exist");
return json_encode($errorMsg);
}
}
} else {
$errorMsg = array("errorNo" => "4001", "content" => "lack the neccessary parameter.the parameter uid is not exist or is not a positive integer.");
return json_encode($errorMsg);
}
$complain = array();
if ($params['complainId']) {
if ($params['complainId'] <= 0) {
$errorMsg = array("errorNo" => "4002", "content" => "the format of parameter is not correct.the parameter complainId must be a positive integer.");
return json_encode($errorMsg);
} else {
$query = $_SGLOBAL['db']->query("select * from " . tname('complain') . " where doid = " . $params['complainId']);
if ($complain = $_SGLOBAL['db']->fetch_array($query)) {
if (isblacklist($complain['uid'])) {
$errorMsg = array("errorNo" => "500", "content" => "the user of complain is in blacklist.");
return json_encode($errorMsg);
}
} else {
$errorMsg = array("errorNo" => "500", "content" => "the complain id is not exist");
return json_encode($errorMsg);
}
}
} else {
$errorMsg = array("errorNo" => "4001", "content" => "lack the neccessary parameter.the parameter complainId is not exist or is not a positive integer.");
return json_encode($errorMsg);
}
if (!$params['message']) {
$errorMsg = array("errorNo" => "4001", "content" => "lack the neccessary parameter message.");
return json_encode($errorMsg);
}
$params['timestamp'] = time();
$doid = $params['complainId'];
$message = getstr($params['message'], 480, 1, 1, 1);
preg_match_all("/[@](.*)[(]([\\d]+)[)]\\s*/U", $params['message'], $matches, PREG_SET_ORDER);
preg_match_all("/回复[@](.*)[(]([\\d]+)[)]\\s*/U", $params['message'], $reply_matches, PREG_SET_ORDER);
if ($reply_matches) {
$exclude_relay = 1;
}
# 如果带有回复字眼,则默认不为relay
$newid = 0;
$addtype = 0;
$query = $_SGLOBAL['db']->query("select * from " . tname('complain') . " where doid=" . $params['complainId'] . ' and atuid=' . $params['uid']);
if ($row = $_SGLOBAL['db']->fetch_array($query)) {
$complain = $row;
$addtype = 2;
$cpid = $complain['id'];
$relay_times = $complain['relay_times'];
}
$isrelay = 0;
if ($addtype && $matches && !$exclude_relay) {
$isrelay = 1;
}
if ($isrelay && $relay_times >= 3) {
$errorMsg = array("errorNo" => "500", "content" => "relay times reach the ceiling'.");
return json_encode($errorMsg);
}
$UserIds = array();
$relay_depid = 0;
foreach ($matches as $value) {
$TmpString = $value[0];
$TmpName = $value[1];
$UserId = $value[2];
$result = $_SGLOBAL['db']->query("select uid,username,name from " . tname('space') . " where uid=" . $UserId);
if ($rs = $_SGLOBAL['db']->fetch_array($result)) {
$realname = $rs['name'];
if (empty($realname)) {
$realname = $rs['username'];
}
$ValidValue = getAtName($TmpString, $TmpName, $realname);
$ValidValue = trim($ValidValue);
$at_friend = "space.php?uid=" . $UserId;
if ($ValidValue != false) {
$message = str_replace($ValidValue, "<a href={$at_friend}>@" . $realname . "</a> ", $message);
if (!in_array($UserId, $UserIds)) {
$UserIds[] = $UserId;
}
}
}
//.........这里部分代码省略.........
示例2: preg_match_all
} else {
//处理评论的@功能 Add by am 2013-12-07 start
//提取AT用户
preg_match_all("/[@](.*)[(]([\\d]+)[)]\\s/U", $Message, $matches, PREG_SET_ORDER);
foreach ($matches as $value) {
$TmpString = $value[0];
$TmpName = $value[1];
$UserId = $value[2];
$result = $_SGLOBAL['db']->query("select uid,username,name from " . tname('space') . " where uid={$UserId}");
if ($rs = $_SGLOBAL['db']->fetch_array($result)) {
$realname = $rs['name'];
if (empty($realname)) {
$realname = $rs['username'];
}
//调用检查函数将@后的内容进行验证,为UID对应的姓名相同则返回@与姓名,不相同则继续判断下一个@,没有找到匹配的最终将返回false
$ValidValue = getAtName($TmpString, $TmpName, $realname);
$ValidValue = trim($ValidValue);
$at_friend = "space.php?uid=" . $UserId;
if ($ValidValue != false) {
$Message = str_replace($ValidValue, "<a href={$at_friend}>@" . $realname . "</a> ", $Message);
$UserIds[] = $UserId;
}
}
}
//Add by Add by am 2013-12-07 end
$arr = array('tid' => intval($Commentid), "tagid" => intval($TagId), "uid" => intval($userid), "username" => getstr($username, 15, 1, 1, 1), "message" => getstr($Message, 5000, 1, 1, 1), "ip" => getonlineip(), 'dateline' => $_SGLOBAL['timestamp'], "isthread" => 0);
$pid = inserttable('post', $arr, 1);
//更新统计数据
$_SGLOBAL['db']->query("UPDATE " . tname('thread') . "\r\n\tSET replynum=replynum+1, lastpost='{$_SGLOBAL['timestamp']}', lastauthor='{$username}', lastauthorid='{$userid}'\r\n\tWHERE tid='{$Commentid}'");
//通知
$note = cplang('note_thread_reply') . " <a href=\"space.php?uid={$userid}&do=thread&id={$Commentid}&pid={$pid}\" target=\"_blank\">{$thread['subject']}</a>";
示例3: getAtName
function getAtName($Str, $TmpName, $Name)
{
//echo "----Str: ".$Str."----TmpName: ".$TmpName."----TMPREALNAME: ".$Name;
if ($TmpName == $Name) {
return $Str;
} else {
$position = strpos($TmpName, "@");
//echo ">>>>POSITION: ".$position;
if ($position != false) {
$TmpStr = substr($Str, 1);
$TmpStr = substr($TmpStr, strpos($TmpStr, "@"));
//echo "=====TMPTMPSTR: ".$TmpStr;
$SubTmpName = substr($TmpName, $position + 1);
//echo "^^^^SubTmpName: ".$SubTmpName;
return getAtName($TmpStr, $SubTmpName, $Name);
} else {
return false;
}
}
}