mirror of https://github.com/helloxz/onenav.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.9 KiB
81 lines
1.9 KiB
<?php |
|
/** |
|
* 首页模板入口 |
|
*/ |
|
|
|
//如果已经登录,获取所有分类和链接 |
|
if( is_login() ){ |
|
//查询分类目录 |
|
$categorys = $db->select('on_categorys','*',[ |
|
"ORDER" => ["weight" => "DESC"] |
|
]); |
|
//根据category id查询链接 |
|
function get_links($fid) { |
|
global $db; |
|
$fid = intval($fid); |
|
$links = $db->select('on_links','*',[ |
|
'fid' => $fid, |
|
'ORDER' => ["weight" => "DESC"] |
|
]); |
|
return $links; |
|
} |
|
} |
|
//如果没有登录,只获取公有链接 |
|
else{ |
|
//查询分类目录 |
|
$categorys = $db->select('on_categorys','*',[ |
|
"property" => 0, |
|
"ORDER" => ["weight" => "DESC"] |
|
]); |
|
//根据category id查询链接 |
|
function get_links($fid) { |
|
global $db; |
|
$fid = intval($fid); |
|
$links = $db->select('on_links','*',[ |
|
'fid' => $fid, |
|
'property' => 0, |
|
'ORDER' => ["weight" => "DESC"] |
|
]); |
|
return $links; |
|
} |
|
} |
|
|
|
|
|
//获取访客IP |
|
function getIP() { |
|
if (getenv('HTTP_CLIENT_IP')) { |
|
$ip = getenv('HTTP_CLIENT_IP'); |
|
} |
|
elseif (getenv('HTTP_X_FORWARDED_FOR')) { |
|
$ip = getenv('HTTP_X_FORWARDED_FOR'); |
|
} |
|
elseif (getenv('HTTP_X_FORWARDED')) { |
|
$ip = getenv('HTTP_X_FORWARDED'); |
|
} |
|
elseif (getenv('HTTP_FORWARDED_FOR')) { |
|
$ip = getenv('HTTP_FORWARDED_FOR'); |
|
} |
|
elseif (getenv('HTTP_FORWARDED')) { |
|
$ip = getenv('HTTP_FORWARDED'); |
|
} |
|
else { |
|
$ip = $_SERVER['REMOTE_ADDR']; |
|
} |
|
return $ip; |
|
} |
|
//判断用户是否已经登录 |
|
function is_login(){ |
|
$key = md5(USER.PASSWORD.getIP().'onenav'); |
|
//获取session |
|
$session = $_COOKIE['key']; |
|
//如果已经成功登录 |
|
if($session == $key) { |
|
return true; |
|
} |
|
else{ |
|
return false; |
|
} |
|
} |
|
// 载入前台首页模板 |
|
require('templates/'.TEMPLATE.'/index.php'); |
|
?>
|