示例#1
1
function makeArticleEasy($article)
{
    log_info($article);
    $conn = getDB();
    $words = explode(" ", $article);
    $outp = "";
    $array = array();
    foreach ($words as $word) {
        $word = str_replace('"', "", $word);
        $word = str_replace("'", "", $word);
        $word = str_replace(" ", "", $word);
        $word = str_replace(".", "", $word);
        $word = str_replace(",", "", $word);
        $word = str_replace(":", "", $word);
        $word = str_replace("\\", "", $word);
        if (empty($word) || strlen($word) < 3) {
            continue;
        }
        $meaning = '';
        $gender = '';
        $partOfSpeech = '';
        //check if the meaning exist in DB
        $result = mysqli_query($conn, "SELECT * FROM words WHERE word = '" . $word . "'");
        if (mysqli_num_rows($result) == 0) {
            // row not found, get from online dicts
            $link = "http://de-en.dict.cc/?s=" . utf8_encode($word);
            $meaning = getMeaningFromOnlinDict($link);
            if (!empty($meaning)) {
                insertWord($conn, $word, $meaning, null, null, 0);
            } else {
                continue;
            }
        } else {
            //take db value
            $row = mysqli_fetch_row($result);
            //var_dump($row);
            $meaning = $row[2];
            $partOfSpeech = $row[3];
            $gender = $row[4];
        }
        if (empty($meaning)) {
            continue;
        }
        //now return as json object
        //     if ($outp != "") {$outp .= ",";}
        $a = new Article();
        $a->word = $word;
        $a->meaning = $meaning;
        array_push($array, $a);
        // $outp .= '{"word":"'  . $word . '",';
        //$outp .= '"meaning":"'  . $meaning . '",';
        //    $outp .= '"meaning":"'  . $meaning. '"}';
        //   $outp .= '"partOfSpeech":"'  . $partOfSpeech . '",';
        //    $outp .= '"gender":"'  . $gender  . '"}';
    }
    //forloop
    //$outp ='{"words":['.$outp.']}';
    echo json_encode($array);
    $conn->close();
}
示例#2
0
         $message["status"] = "Fail";
     }
 } else {
     if (isset($_GET["token"]) && isset($_GET["action"])) {
         $userID = getUserFromToken($conn, $_GET["token"]);
         if ($userID != null) {
             $message["status"] = "OK";
             switch ($_GET["action"]) {
                 case "insert":
                     $word = isset($_POST["word"]) ? $_POST["word"] : "";
                     $wordBase = isset($_POST["wordbase"]) ? $_POST["wordbase"] : "";
                     $translation = isset($_POST["translation"]) ? $_POST["translation"] : "";
                     $description = isset($_POST["description"]) ? $_POST["description"] : "";
                     $list = $_POST["list"];
                     $forceInsert = isset($_POST["force"]) ? filter_var($_POST["force"], FILTER_VALIDATE_BOOLEAN) : false;
                     $message = insertWord($conn, $userID, $word, $translation, $description, $wordBase, $list, $forceInsert);
                     break;
                 case "get":
                     $message["action"] = "check";
                     break;
                 case "userinfo":
                     $message["user"] = getUserInfo($conn, $userID);
                     break;
                 case "userdetail":
                     $message["user"] = getUserDetail($conn, $userID);
                     break;
                 case "updateuserdetail":
                     $message["status"] = updateUserDetail($conn, $userID, $_POST["firstname"], $_POST["lastname"], $_POST["nickname"]);
                     break;
                 case "updatepassword":
                     $message["update"] = updatePassword($conn, $userID, $_POST["password"], $_POST["newpassword"], $passwordSalt);
示例#3
0
文件: setbwd.php 项目: jechiy/PHPWind
     ajaxmsg('filtermsg_cannot', "{$basename}&action=setting");
 }
 //查询是否有重复记录
 $sql = "SELECT * FROM pw_wordfb WHERE word IN ({$strword})";
 $query = $db->query($sql);
 $wordfb = $db->affected_rows($query);
 //插入新分类
 if ($newclass) {
     $class = newClass($newclass);
 }
 if (!$wordfb) {
     if (!$repword) {
         $repword = '*****';
     }
     //插入敏感词
     insertWord($word, $type, $class, $repword);
     //更新缓存
     updatecache_w();
     //设置字典文件
     setAllDictionary();
     require_once R_P . 'require/posthost.php';
     $appclient = L::loadClass('AppClient');
     $sitehash = $appclient->getApicode();
     $word = serialize(pwConvert($word, 'UTF8', $db_charset));
     //提交到中心词库
     $data = PostHost($updateHost, "m=wordsfb&a=custom&sitehash={$sitehash}&type=plus&word={$word}", "POST");
     if ($class) {
         //重定向
         adminmsg('operate_success', "{$basename}&action=setting&show={$class}");
     } else {
         //重定向
示例#4
0
     $type = intval($type);
     if (!$word) {
         ajaxmsg('filtermsg_cannot', "{$basename}&action=setting");
     }
     //查询是否有重复记录
     $sql = "SELECT * FROM pw_wordfb WHERE word IN ({$strword})";
     $query = $db->query($sql);
     $wordfb = $db->affected_rows($query);
     //插入新分类
     if ($newclass) {
         $class = newClass($newclass);
     }
     if (!$wordfb) {
         $repword || ($repword = '*****');
         //插入敏感词
         insertWord($word, $type, $class, $repword = '*****');
         //更新缓存
         updatecache_w();
         //设置字典文件
         setDictionary();
         require_once R_P . 'require/posthost.php';
         $appclient = L::loadClass('AppClient');
         $sitehash = $appclient->getApicode();
         $word = serialize(pwConvert($word, 'UTF8', $db_charset));
         //提交到中心词库
         $data = PostHost($updateHost, "m=wordsfb&a=custom&sitehash={$sitehash}&type=plus&word={$word}", "POST");
         //重定向
         adminmsg('operate_success', "{$basename}&action=setting");
     }
 } else {
     define('AJAX', 1);