pony 大佬有话说 :
Chevereto免费鉴黄接口
本帖最后由 pony 于 2020-5-11 11:50 编辑
没办法发代码…被拦截,可能代码问题
拦截地址:https://www.hostloc.com/forum.php?mod=post&action=edit&extra=&editsubmit=yes
https://01.urlnode.com/2020/05/11/_20200511114829.png
具体方式看这里了
https://ssbb.net/thread-14-1-1.html
对接方式:
安装Chevereto
在ModerateContent申请免费接口获取KEY
使用ModerateContent的免费套餐,通过ModerateContent的API接口
pony 大佬有话说 :
1.修改Chevereto程序文件app/lib/classes/class.upload.php
// Size
if (!$this->options[‘max_size’]) {
$this->options[‘max_size’] = self::getDefaultOptions()[‘max_size’];
}
if ($this->source_image_fileinfo["size"] > $this->options["max_size"]) {
throw new UploadException("File too big – max " . Gformat_bytes($this->options["max_size"]), 313);
}
// BMP?
if ($this->source_image_fileinfo[‘extension’] == ‘bmp’) {
$this->ImageConvert = new ImageConvert($this->downstream, "png", $this->downstream);
$this->downstream = $this->ImageConvert->out;
$this->source_image_fileinfo = Gget_image_fileinfo($this->downstream);
}
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
if (intval(Settings::get(‘moderatecontent’)) != 0 && intval(Settings::get(‘moderatecontent_action_block_upload’)) != 0){
require_once CHV_APP_PATH_LIB_VENDOR . ‘moderatecontent/moderatecontent.php’;
$response = ModerateContent::moderate_image($this->downstream);
if ($response->error_code == 0 && $response->moderation->rating_letter == "a"){
throw new UploadException("This image contains adult content", 1404);
}
if ($response->error_code == 0 && $response->moderation->rating_letter == "t" && intval(Settings::get(‘moderatecontent_include_teen’)) != 0){
throw new UploadException("This image contains adult content", 1404);
}
}
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
}
// Handle flood uploads
protected static function handleFlood()
{
$logged_user = Login::getUser();
2.修改Chevereto程序文件app/lib/classes/class.image.php
public static function insert($image_upload, $values=[])
{
try {
$table_chv_image = self::$table_chv_image;
foreach ($table_chv_image as $k => $v) {
$table_chv_image[$k] = ‘image_’ . $v;
}
// Remove eternal/useless Exif MakerNote
if ($image_upload[‘source’][‘image_exif’][‘MakerNote’]) {
unset($image_upload[‘source’][‘image_exif’][‘MakerNote’]);
}
$original_exifdata = $image_upload[‘source’][‘image_exif’] ? json_encode(Garray_utf8encode($image_upload[‘source’][‘image_exif’])) : null;
// Fix some values
$values[‘nsfw’] = in_array(strval($values[‘nsfw’]), [‘0′,’1’]) ? $values[‘nsfw’] : 0;
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
if (intval(Settings::get(‘moderatecontent’)) != 0 && intval($values[‘nsfw’]) != 1 && intval(Settings::get(‘moderatecontent_action_flag_nsfw’)) != 0){
require_once CHV_APP_PATH_LIB_VENDOR . ‘moderatecontent/moderatecontent.php’;
$response = ModerateContent::moderate_image($image_upload[‘uploaded’][‘file’]);
if ($response->error_code == 0){
if ($response->moderation->rating_letter == "a"){
$values[‘nsfw’] = ‘1’;
}
if ($response->moderation->rating_letter == "t" && intval(Settings::get(‘moderatecontent_include_teen’)) != 0){
$values[‘nsfw’] = 1;
}
}
}
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
pony 大佬有话说 :
public static function update($id, $values)
{
try {
$values = Garray_filter_array($values, self::$table_chv_image, ‘exclusion’);
foreach ([‘title’, ‘description’, ‘category_id’, ‘album_id’] as $v) {
if (!array_key_exists($v, $values)) {
continue;
}
Gnullify_string($values[$v]);
}
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
if (intval(Settings::get(‘moderatecontent’)) != 0 && intval($values[‘nsfw’]) != 1 && intval(Settings::get(‘moderatecontent_action_flag_nsfw’)) != 0){
require_once CHV_APP_PATH_LIB_VENDOR . ‘moderatecontent/moderatecontent.php’;
$image_db = self::getSingle($id, false, false);
$image_path = $image_db[‘file_resource’][‘chain’][‘image’];
$response = ModerateContent::moderate_image($image_path);
if ($response->error_code == 0){
if ($response->moderation->rating_letter == "a"){
$values[‘nsfw’] = 1;
}
if ($response->moderation->rating_letter == "t" && intval(Settings::get(‘moderatecontent_include_teen’)) != 0){
$values[‘nsfw’] = 1;
}
}
}
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
// MODERATECONTENT PLUGIN
zzidc 大佬有话说 :
感谢楼主分享 收藏了
W4ter 大佬有话说 :
值得注意的是,这个接口对国内用户极不友好,可能会出现上传失败的情况,估计应该是我的网络问题。
xiaoyang 大佬有话说 :
谢谢dalaoyc003t
bigtiger8 大佬有话说 :
好的
微笑不用花一分钱,却永远价值连城。
拂霓裳 大佬有话说 :
谢谢
fcxc1 大佬有话说 :
谢谢dalao
ncnc 大佬有话说 :
之前用官方的 剑皇