Browse Source

增加说明

north 8 years ago
parent
commit
d114e87ed5
1 changed files with 5 additions and 87 deletions
  1. 5 87
      www/protected/components/CommonFn.php

+ 5 - 87
www/protected/components/CommonFn.php

@@ -1235,10 +1235,15 @@ class CommonFn
 
 
     /**
+     *
      * 视频/图片鉴黄
      * 同步图片检测,调用会实时返回检测结果
      * 异步视频检测,上传视频后轮训获取检测结果
      * http://oscmpgu1a.bkt.clouddn.com/o_1bjrul60t1o4g1n6egb4sse1icl9.jpg 测试url
+     * @param $url 视频/图片地址
+     * @param string $type 类型 默认图片鉴定 传入其他值鉴定视频
+     * @return bool 返回结果  true 图片/视频正常 false 1 url 为空 2 视频/图片 不正常
+     * 返回异常时可能是因为 连接超时
      */
     public static function imageIdent($url,$type ='image') {
         Yii::$enableIncludePath = false;
@@ -1346,91 +1351,4 @@ class CommonFn
         }
     }
 
-
-
-    public static function videoIdent() {
-        date_default_timezone_set("PRC");
-
-        Yii::$enableIncludePath = false;
-        Yii::import('ext.aliyuncs.aliyun-php-sdk-core.Config',1);
-        date_default_timezone_set("PRC");
-        //请替换成你自己的accessKeyId、accessKeySecret
-        $ak['accessKeyId']='LTAIsUUDuVvAmDMP';
-        $ak['accessKeySecret']='d8gz2BkKVWGQg77sjShH7TAhei6qIP';
-//请替换成你自己的accessKeyId、accessKeySecret
-        $iClientProfile = DefaultProfile::getProfile("cn-shanghai", $ak["accessKeyId"], $ak["accessKeySecret"]); // TODO
-        DefaultProfile::addEndpoint("cn-shanghai", "cn-shanghai", "Green", "green.cn-shanghai.aliyuncs.com");
-        $client = new DefaultAcsClient($iClientProfile);
-
-        $request = new Green\VideoAsyncScanRequest();
-        $request->setMethod("POST");
-        $request->setAcceptFormat("JSON");
-        $url = 'http://wozhua-others.qiniudn.com/20160215-wozhua-2.MP4?';
-        $frames = array();
-        for ($i=0; $i <4; $i ++) {
-            $frames[$i]['offset'] = $i*5;
-            $frames[$i]['url'] = $url."vframe/jpg/offset/".$i*5;
-
-        }
-
-        $task1 = array(
-            "dataId" => uniqid(),
-            "interval" => 5,
-            "length" => 3600,
-            "frames" => $frames
-        );
-        $request->setContent(json_encode(array("tasks" => array($task1),
-            "scenes" => array("porn"))));
-
-        try {
-            $response = $client->getAcsResponse($request);
-
-            if ($response->code == 200) {
-                $flag = true;
-                while ($flag) {
-                    sleep(2);
-                    $request = new Green\VideoAsyncScanResultsRequest();
-                    $request->setMethod("POST");
-                    $request->setAcceptFormat("JSON");
-
-                    $request->setContent(json_encode(array($response->data[0]->taskId)));
-
-                    try {
-                        $response = $client->getAcsResponse($request);
-                        if(200 == $response->code){
-                            $taskResults = $response->data;
-                            foreach ($taskResults as $key => $taskResult) {
-                                if(200 == $taskResult->code){
-                                    $sceneResults = $taskResult->results;
-                                    foreach ($sceneResults as $sceneResult) {
-                                        if ($sceneResult->suggestion == 'pass') {
-                                            return true;
-                                        } else if($sceneResult->suggestion == 'review') {
-                                            //$data[$key]['suggestion'] = '需要人工审核';
-                                            if (intval($sceneResult->rate) >= 60) {//分数越大 越趋于该分类
-
-                                                return false;
-                                            } else {
-
-                                                return true;
-                                            }
-                                        } else if ($sceneResult->suggestion == 'block') {
-
-                                            return false;
-                                        }
-                                    }
-                                }
-                            }
-
-                        }
-                    } catch (Exception $e) {
-                        print_r($e);exit;
-                    }
-
-                }
-            }
-        } catch (Exception $e) {
-            print_r($e);
-        }
-    }
 }