<?php use MRTB\utils\Validate;function mrtb_is_host_url($url){$marks=array('alicdn','pstatp','prntscr','ufileos.com');foreach($marks as $mark){if(strpos($url,$mark)!==false){return true;}}return false;}function imgHostFactory(){switch(mrtb_get_option('image_host_which')){case 'Prnt':return new \MRTB\functions\ImgHost\free\Prnt();break;default:return new \MRTB\functions\ImgHost\free\DanKe();break;}}function mrtb_get_host_url($raw_url,$post_id=0){$raw_url=\MRTB\functions\ImgHost\api\ImgHostAbstract::cdn2Local($raw_url);if(!$post_id&&get_the_ID()){$post_id=get_the_ID();}if(gettype($post_id)=='array'||$post_id===null){$post_id=0;}global $wpdb;$prefix=$wpdb->prefix;$img_host_table=$prefix.'mrtb_img_host';if(mrtb_is_host_url($raw_url)){return $raw_url;}if(img_host_cache_get_url($raw_url)){return img_host_cache_get_url($raw_url);}$result=$wpdb->get_results("
	    SELECT host_url
	    FROM $img_host_table
	    WHERE raw_url = '$raw_url';
    ");if(isset($result[0]->host_url)){$host_url=$result[0]->host_url;img_host_cache_set_url($raw_url,$host_url);return $host_url;}$instance=imgHostFactory();$host_url=$instance->uploadImageHost($raw_url);if(!Validate::isUrl($host_url)){return $raw_url;}$result=$instance->insert($post_id,$instance->type,$raw_url,$host_url);if($result){img_host_cache_set_url($raw_url,$host_url);}unset($instance);return $host_url;}function img_host_cache_get_url($key){if(wp_using_ext_object_cache()&&mrtb_get_option('image_host_is_cache')){return wp_cache_get($key,'mrtb_img_host');}}function img_host_cache_set_url($key,$value){if(wp_using_ext_object_cache()&&mrtb_get_option('image_host_is_cache')){return wp_cache_set($key,$value,'mrtb_img_host');}}function img_host_cache_get_option($key){if(wp_using_ext_object_cache()&&mrtb_get_option('image_host_is_cache')){return wp_cache_get($key,'mrtb_img_host');}}function img_host_cache_set_option($key,$value){if(wp_using_ext_object_cache()&&mrtb_get_option('image_host_is_cache')){return wp_cache_set($key,$value,'mrtb_img_host');}}