skycaiji/SkycaijiApp/admin/model/Provider.php

42 lines
1.1 KiB
PHP
Raw Normal View History

2019-06-23 02:56:18 +00:00
<?php
/*
|--------------------------------------------------------------------------
| SkyCaiji (蓝天采集器)
|--------------------------------------------------------------------------
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|--------------------------------------------------------------------------
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
2019-06-23 02:20:58 +00:00
namespace skycaiji\admin\model;
/*第三方服务商*/
class Provider extends BaseModel{
/*匹配域名*/
2019-09-25 07:45:58 +00:00
public static function match_domain($url){
2019-06-23 02:20:58 +00:00
$domain=null;
if(preg_match('/^\w+\:\/\/[\w\-]+(\.[\w\-]+)*(\:\d+){0,1}/', $url,$domain)){
$domain=rtrim($domain[0],'/');
2019-09-25 07:45:58 +00:00
$domain=strtolower($domain);
2019-06-23 02:20:58 +00:00
}else{
$domain=null;
}
return $domain;
}
/*获取id*/
public function getIdByUrl($url){
2019-09-25 07:45:58 +00:00
$url=self::match_domain($url);
2019-06-23 02:20:58 +00:00
if(is_official_url($url)){
2019-06-23 02:56:18 +00:00
2019-06-23 02:20:58 +00:00
$url=null;
}
$id=0;
if(!empty($url)){
$id=model('Provider')->where('domain',$url)->value('id');
$id=intval($id);
}
return $id;
}
}
?>