织梦获取顶级域名
{dede:geturl runphp='yes'} function getdomain($url) { $host = strtolower ( $url ); if (strpos ( $host, '/' ) !== false) { $parse = @parse_url ( $host ); $host = $parse ['host']; } $topleveldomaindb = array ('com', 'edu', 'gov', 'int', 'mil', 'net', 'org', 'biz', 'info', 'pro', 'name', 'museum', 'coop', 'aero', 'xxx', 'idv', 'mobi', 'cc', 'me' ); $str = ''; foreach ( $topleveldomaindb as $v ) { $str .= ($str ? '|' : '') . $v; } $matchstr = "[^\.]+\.(?:(" . $str . ")|\w{2}|((" . $str . ")\.\w{2}))$"; if (preg_match ( "/" . $matchstr . "/ies", $host, $matchs )) { $domain = $matchs ['0']; } else { $domain = $host; } return $domain; } $str = $_SERVER['HTTP_HOST']; $su = getdomain ( $str ); if( $su == 'lol9.cn' ){ @me = "六久阁织梦模板网"; } else{ @me = "lol9"; } {/dede:geturl}
PHP获取顶级域名
<?php header("Content-type:text/html;charset=gb2312"); function getdomain($url) { $host = strtolower ( $url ); if (strpos ( $host, '/' ) !== false) { $parse = @parse_url ( $host ); $host = $parse ['host']; } $topleveldomaindb = array ('com', 'edu', 'gov', 'int', 'mil', 'net', 'org', 'biz', 'info', 'pro', 'name', 'museum', 'coop', 'aero', 'xxx', 'idv', 'mobi', 'cc', 'me' ); $str = ''; foreach ( $topleveldomaindb as $v ) { $str .= ($str ? '|' : '') . $v; } $matchstr = "[^\.]+\.(?:(" . $str . ")|\w{2}|((" . $str . ")\.\w{2}))$"; if (preg_match ( "/" . $matchstr . "/ies", $host, $matchs )) { $domain = $matchs ['0']; } else { $domain = $host; } return $domain; } $str = $_SERVER['HTTP_HOST']; $su = getdomain ( $str ); if($su == 'lol9.cn'){ echo "六久阁织梦模板网"; }else{ echo "lol9"; } ?>
织梦二次开发QQ群
本站客服QQ号:862782808(点击左边QQ号交流),群号(383578617) 如果您有任何织梦问题,请把问题发到群里,阁主将为您写解决教程!
转载请注明: 织梦模板 » 织梦和php方式获取顶级域名,根据判断输出指定文字
标签:
织梦判断