/** * @param $url 图片url * @param $md5 图片md5 */ public static function doAddCheckImage($url, $md5) { $images = array(); array_push($images, $url); $md5_map = array(); $md5_map[$url] = $md5; $res = Service_TupuTech::doCheckImages($images, 1); if ($res["code"] == 0) { self::addImagesRecord($res, $md5_map); } }
/** * 图片检测接口 * img 图片url */ public function checkImgAction() { //sleep(50); $log = new FLogger("images_log"); $url = FRequest::getString('imgs'); $item = FRequest::getInt("type"); if (!$url) { FResponse::output(array('status' => 'fail', 'msg' => 'parm img is empty')); return; } if (!$item || $item <= 0) { FResponse::output(array('status' => 'fail', 'msg' => 'parm type is empty')); return; } $images = explode(",", $url); if (!$images || count($images) <= 0) { FResponse::output(array('status' => 'fail', 'msg' => 'the length of images is less than 0')); return; } // 检测图片域名 foreach ($images as &$url) { $S = parse_url($url); $S = strtolower($S['host']); //取域名部分 if ($item == Service_TupuTech::$SEXY_AND_AD && !(strpos($S, "yuanfenba.net") || strpos($S, "mumu123.cn"))) { FResponse::output(array('status' => 'fail', 'msg' => 'the host of image is error')); return; } if (strpos($S, "yuanfenba.net") || strpos($S, "mumu123.cn")) { $url = CommonUtil::getImgBySize($url, 256); } } $log->append("checkImgAction - begin :" . time() . json_encode($images)); $res = Service_TupuTech::doCheckImages($images, $item); $log->append("checkImgAction - 1 :" . time()); if ($res["code"] == 0) { $data = Service_Images::addImagesRecord($res, $item); FResponse::output($data); } else { $log->append("[ERROR] checkImgAction is error" . json_encode($res)); FResponse::output(array('status' => 'fail', 'msg' => 'check img is error')); } $log->append("checkImgAction - end :" . time()); }