当前位置:首页 > 编程技术 > 正文

文章是否原创PHP检测源码

文章是否原创PHP检测源码

<?phpfunction curl($url,$post=0 { $ch = curl_init( ;&n...

<?php


function curl($url,$post=0){

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL,$url);

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

        $httpheader[] = "Accept:*/*";

        $httpheader[] = "Accept-Encoding:gzip,deflate,sdch";

        $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";

        $httpheader[] = "Connection:close";

        $httpheader[] = "Host:check1.myleguan.com";

        $httpheader[] = "Origin: http://www.myleguan.com";

        curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);

        curl_setopt($ch, CURLOPT_POST, 1);

        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

        curl_setopt($ch, CURLOPT_REFERER, 'http://www.myleguan.com/lgEditor/lgEditor.html');

        curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0');

        curl_setopt($ch, CURLOPT_ENCODING, "gzip");

        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '60');

        $ret = curl_exec($ch);

        curl_close($ch);

        return $ret;

}


$content=$_POST['content'];

$title=mb_strimwidth($content, 0, 10, '', 'utf8');


$content_mediaobj=curl('http://check1.myleguan.com/Keyword/checkoriginal','content='.$content.'&title='.$title);

$json=json_decode($content_mediaobj,1);

$ycd=$json['ycpercent'];//原创度数字

$xsd=$json['mediaobj']['0']['score'];

    if($ycd <=40){

        $str = "您的相似度($xsd)很低,属于原创文章,可以发布";

    }else if($ycd <=55 && $ycd > 40){

        $str = "您的相似度($xsd)较低,基本属于原创文章,可以发布";

    }else if($ycd <=70 && $ycd > 55){

        $str = "您的相似度($xsd)比较高,建议修改后再发布";

    }else if($ycd > 70){

        $str = "您的相似度($xsd)非常高,不建议发布";

    }

echo $str;


发表评论

最新文章