Example #1
0
 public function dotext($keyword, $fromUsername)
 {
     $go = new Trans();
     $keyword = $go->t2c($keyword);
     //database
     $ctype = 'general';
     $contentStr = '';
     $moretext = '';
     if (strlen($keyword) > 0) {
         $flag = secret_getflag($fromUsername);
         if ($flag == SECRET_TEXT) {
             secret_inserttext($fromUsername, $keyword);
             $user = secret_gettouser($fromUsername);
             $contentStr = "发送成功!\n如果TA也关注我,\n输入 @" . $user . " 就可以看到你的匿名纸条啦。快让身边的人也来吐露心声吧~~\n";
             $contentStr .= secret_ending();
             secret_updateflag($fromUsername, 0);
         } else {
             //查看最新
             if (preg_match("/^kk([\\s\\S]*)\$/", trim(strtolower($keyword)), $match)) {
                 $contentStr = secret_latestwords($fromUsername);
                 $ctype = 'kk';
             } else {
                 if ($keyword == '有缘人') {
                     $contentStr = secret_wordsbyuser(trim($match[1]));
                 } else {
                     if (preg_match("/^mm([\\s\\S]*)\$/", trim(strtolower($keyword)), $match)) {
                         secret_updateflag($fromUsername, MM_TEXT);
                         secret_inserttouser($fromUsername, '有缘人');
                         $contentStr = "现在以@开头输入你想说的话, 可以说个笑话或者分享一段糗事啊或者分享你的心情,\n而且记得加上联系方式哦~ \nQQ、邮箱、微信号都行啦 这样有缘人才能联系上你~~" . "\n\n输入  @有缘人  查看最新发布";
                         $ctype = 'mm';
                     } else {
                         if (preg_match("/^kta([\\s\\S]*)\$/", trim(strtolower($keyword)), $match)) {
                             secret_updateflag($fromUsername, SECRET_KTA);
                             $contentStr = "以@开头,输入想要查看的的名字,如输入:\n@李小四";
                             $ctype = 'kta';
                         } else {
                             if (preg_match("/^ta([\\s\\S]*)\$/", trim(strtolower($keyword)), $match)) {
                                 secret_updateflag($fromUsername, SECRET_TA);
                                 $contentStr = "以@开头,先输入TA的名字,如输入:\n@李小四";
                                 $ctype = 'ta';
                             } else {
                                 if (preg_match("/^@([\\s\\S]+)\$/", trim($keyword), $match)) {
                                     if (strlen(trim($match[1])) == 0) {
                                         $contentStr = "请在@后面加上名字哦~\n";
                                         $contentStr .= secret_ending();
                                     } else {
                                         if (trim($match[1]) == '有缘人') {
                                             $contentStr = secret_wordsbyuser(trim($match[1]));
                                         } else {
                                             if ($flag == MM_TEXT) {
                                                 secret_inserttext($fromUsername, trim($match[1]));
                                                 $contentStr = "发送成功!\n你的有缘人看到了 一定会联系你的!!\n";
                                                 $contentStr .= secret_ending();
                                                 secret_updateflag($fromUsername, 0);
                                             } else {
                                                 if (strstr(trim($match[1]), ' ') && strpos(trim($match[1]), ' ') < 6) {
                                                     $index = strpos(trim($match[1]), ' ');
                                                     $touser = substr(trim($match[1]), 0, $index);
                                                     secret_inserttouser($fromUsername, $touser);
                                                     secret_inserttext($fromUsername, trim($match[1]));
                                                     if ($touser == '有缘人') {
                                                         $contentStr = "发送成功!\n你的有缘人看到了 一定会联系你的!!\n";
                                                     } else {
                                                         $contentStr = "发送成功!\n如果TA也关注我,\n输入 @" . $touser . " 就可以看到你的匿名纸条啦。快让身边的人也来吐露心声吧~~\n";
                                                     }
                                                     $contentStr .= secret_ending();
                                                     secret_updateflag($fromUsername, 0);
                                                 } else {
                                                     if (mb_strlen(trim($match[1]), 'utf-8') > 8) {
                                                         $touser = '******';
                                                         $index = strpos(trim($match[1]), ' ');
                                                         if ($index != null && index < 6) {
                                                             $touser = substr(trim($match[1]), 0, $index);
                                                         } else {
                                                             $index = strpos(trim($match[1]), ',');
                                                             if ($index != null && index < 6) {
                                                                 $touser = substr(trim($match[1]), 0, $index);
                                                             }
                                                         }
                                                         secret_inserttouser($fromUsername, $touser);
                                                         secret_inserttext($fromUsername, trim($match[1]));
                                                         if ($touser == '有缘人') {
                                                             $contentStr = "发送成功!\n你的有缘人看到了 一定会联系你的!!\n";
                                                         } else {
                                                             $contentStr = "发送成功!\n如果TA也关注我,\n输入 @" . $touser . " 就可以看到你的匿名纸条啦。快让身边的人也来吐露心声吧~~\n";
                                                         }
                                                         $contentStr .= secret_ending();
                                                         secret_updateflag($fromUsername, 0);
                                                     } else {
                                                         if ($flag == SECRET_KTA) {
                                                             $contentStr = secret_wordsbyuser(trim($match[1]));
                                                         } else {
                                                             if ($flag == SECRET_TA) {
                                                                 secret_updateflag($fromUsername, SECRET_TEXT);
                                                                 secret_inserttouser($fromUsername, trim($match[1]));
                                                                 $contentStr = '现在输入你想说的话,可以留下署名哦 这样可能会有人回复你呢';
                                                             } else {
                                                                 $contentStr = secret_wordsbyuser(trim($match[1]));
                                                                 //	$contentStr = secret_welcome();
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     $ctype = '@';
                                 } else {
                                     if (strtolower($keyword) == 'jx' || strstr($keyword, "匿名小纸条")) {
                                         $contentStr = secret_welcome();
                                         $ctype = 'jx';
                                     } else {
                                         $webchat_textmsgObj = new webchat_textmsg();
                                         list($contentStr, $ctype) = $webchat_textmsgObj->dotext($keyword, $fromUsername);
                                         if ($flag == MM_TEXT && mb_strlen($keyword, 'utf-8') > 10) {
                                             $touser = '******';
                                             secret_inserttouser($fromUsername, $touser);
                                             secret_inserttext($fromUsername, $keyword);
                                             $contentStr .= "\n-----------\n发送成功!\n你的有缘人看到了 一定会联系你的!!\n";
                                             secret_updateflag($fromUsername, 0);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $namesArray = array('傻逼', '生殖器官', '交配', '约炮');
     $contentStr = trim(str_replace($namesArray, '**', $contentStr));
     return array($contentStr, $ctype);
 }
Example #2
0
function secret_wordsbyuser($touser)
{
    //database connection
    $contetstr = '';
    $secretIndex = 0;
    $sql = "select pcount, secretwords.id as sid, city, sex, touser, words,UNIX_TIMESTAMP(secretwords.ptime) as pptime from secretwords, users where touser like '%{$touser}%' and users.user= secretwords.user order by secretwords.id desc";
    //	$sql = "select city, touser, words, UNIX_TIMESTAMP(ptime) as ptime from secretwords where touser like '%$touser%' order by id desc limit 50";
    $nn = 0;
    date_default_timezone_set('PRC');
    $mysqlHelperObj = new mysqlHelper();
    $rows = $mysqlHelperObj->queryValueArray($sql);
    if ($rows != "") {
        $len = count($rows);
        for ($i = 0; $i < $len; $i++) {
            $row = $rows[$i];
            $city = $row['city'];
            $sex = $row['sex'];
            $touser = $row['touser'];
            $words = $row['words'];
            $ptime = $row['pptime'];
            $pcount = intval($row['pcount']) + 1;
            array_push($idStack, $row['sid']);
            if ($sex == '0') {
                $sex = '某女生';
            } else {
                if ($sex == '1') {
                    $sex = '某男生';
                } else {
                    $sex = '某人';
                }
            }
            if (strlen($words) > 0) {
                $nn = $nn + 1;
                $contetstr .= "【第 {$nn} 条】\n";
                $contetstr .= date('Y-m-d H:i', $ptime) . "\n";
                $contetstr .= "{$city} {$sex} \n对 {$touser} 说:\n";
                $contetstr .= "{$words} \n";
                $contetstr .= "-------浏览次数({$pcount})\n";
            }
        }
        $c = count($idStack);
        for ($ii = 0; $ii < $c; $ii++) {
            $sql = "update secretwords set pcount = pcount + 1 where id = '" . $idStack[$ii] . "'";
            $mysqlHelperObj->execute($sql);
        }
    }
    if (strlen($contetstr) == 0) {
        $contetstr = "还没有发给 {$touser} 的告白哦~\n快叫{$touser} 的同学朋友也来关注我吧,兴许他们会对TA说出心里的告白哦~\n ";
    }
    return $contetstr . secret_ending();
}