Add files via upload

This commit is contained in:
任宝硕 2020-03-09 23:55:32 +08:00 committed by GitHub
parent f1c91dbe38
commit 36d7decd07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 1 deletions

53
inc/functions.php Normal file
View File

@ -0,0 +1,53 @@
<?php
// 获取网站标题
function get_title() {
global $config;
return $config['title'];
}
// 获取网站简介
function get_description() {
global $config;
return $config['description'];
}
// 获取用户 IP
function get_ip() {
$ip = '0.0.0.0';
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip = $_SERVER['HTTP_CLIENT_IP'];
} else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if(!empty($_SERVER['HTTP_X_FORWARDED'])) {
$ip = $_SERVER['HTTP_X_FORWARDED'];
} else if(!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
} else if(!empty($_SERVER['HTTP_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_FORWARDED_FOR'];
} else if(!empty($_SERVER['HTTP_FORWARDED'])) {
$ip = $_SERVER['HTTP_FORWARDED'];
} else if(!empty($_SERVER['REMOTE_ADDR'])) {
$ip= $_SERVER['REMOTE_ADDR'];
} else if(!empty($_SERVER['HTTP_VIA'])) {
$ip = $_SERVER['HTTP_VIA '];
}
return $ip;
}
// 获取用户 UserAgent
function get_ua() {
$ua = 'N/A';
if(!empty($_SERVER['HTTP_USER_AGENT'])) $ua = $_SERVER['HTTP_USER_AGENT'];
return $ua;
}
// 获取程序所在路径
function get_uri() {
global $config;
// 获取传输协议
$url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
// 获取域名
$url .= $_SERVER['HTTP_HOST'];
// 获取程序所在路径
$url .= $config['path'];
if(substr($url, strlen($url) - 1) != '/') $url .= '/';
// 返回值
return $url;
}
?>

View File

@ -1 +1 @@
<?php exit; ?>
<?php exit; ?>

11
inc/require.php Normal file
View File

@ -0,0 +1,11 @@
<?php
// 引入配置文件
require_once(dirname(__FILE__) . '/../config.php');
// 引入域名缩址库
require_once('functions.php');
require_once('class/db.class.php');
require_once('class/url.class.php');
// 初始化数据库
global $db_c;
$db_c = new db();
?>