• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP getAtName函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:shiyake,项目名称:php-ihome,代码行数:101,代码来源:do_complain.php


示例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>";
开发者ID:shiyake,项目名称:php-ihome,代码行数:31,代码来源:do_addtopicreply.php


示例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;
        }
    }
}
开发者ID:shiyake,项目名称:php-ihome,代码行数:20,代码来源:function_cp.php



注:本文中的getAtName函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getAttachmentFilename函数代码示例发布时间:2022-05-15
下一篇:
PHP getAssociatedProducts函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap