2 Star 0 Fork 0

Wang Ningkai / oneindex

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
init.php 3.39 KB
一键复制 编辑 原始数据 按行查看 历史
Secret 提交于 2018-12-20 13:33 . 新增防盗链
<?php
error_reporting(E_ALL & ~E_NOTICE);
date_default_timezone_set('PRC');
define('TIME', time());
!defined('ROOT') && define('ROOT', str_replace("\\", "/", dirname(__FILE__)) . '/');
//__autoload方法
function i_autoload($className) {
if (is_int(strripos($className, '..'))) {
return;
}
$file = ROOT . 'lib/' . $className . '.php';
if (file_exists($file)) {
include $file;
}
}
spl_autoload_register('i_autoload');
!defined('FILE_FLAGS') && define('FILE_FLAGS', LOCK_EX);
/**
* config('name');
* config('name@file');
* config('@file');
*/
if (!function_exists('config')) {
!defined('CONFIG_PATH') && define('CONFIG_PATH', ROOT . 'config/');
function config($key) {
static $configs = array();
list($key, $file) = explode('@', $key, 2);
$file = empty($file) ? 'base' : $file;
$file_name = CONFIG_PATH . $file . '.php';
//读取配置
if (empty($configs[$file]) AND file_exists($file_name)) {
$configs[$file] = @include $file_name;
}
if (func_num_args() === 2) {
$value = func_get_arg(1);
//写入配置
if (!empty($key)) {
$configs[$file] = (array) $configs[$file];
if (is_null($value)) {
unset($configs[$file][$key]);
} else {
$configs[$file][$key] = $value;
}
} else {
if (is_null($value)) {
return unlink($file_name);
} else {
$configs[$file] = $value;
}
}
file_put_contents($file_name, "<?php return " . var_export($configs[$file], true) . ";", FILE_FLAGS);
} else {
//返回结果
if (!empty($key)) {
return $configs[$file][$key];
}
return $configs[$file];
}
}
}
// cache
define('CACHE_PATH', ROOT.'cache/');
cache::$type = empty( config('cache_type') )?'secache':config('cache_type');
if (!function_exists('db')) {
function db($table) {
return db::table($table);
}
}
if (!function_exists('view')) {
function view($file, $set = null) {
return view::load($file, $set = null);
}
}
if (!function_exists('_')) {
function _($str) {
return htmlspecialchars($str);
}
}
if (!function_exists('e')) {
function e($str) {
echo $str;
}
}
if (!function_exists('str_is')) {
function str_is($pattern, $value)
{
if (is_null($pattern)) {
$patterns = [];
}
$patterns = ! is_array($pattern) ? [$pattern] : $pattern;
if (empty($patterns)) {
return false;
}
foreach ($patterns as $pattern) {
if ($pattern == $value) {
return true;
}
$pattern = preg_quote($pattern, '#');
$pattern = str_replace('\*', '.*', $pattern);
if (preg_match('#^'.$pattern.'\z#u', $value) === 1) {
return true;
}
}
return false;
}
}
if (!function_exists('get_domain')) {
function get_domain($url=null)
{
if (is_null($url)) {
return $_SERVER['HTTP_HOST'];
}
return strstr(ltrim(strstr($url, '://'), '://'), '/', true);
}
}
function get_absolute_path($path) {
$path = str_replace(array('/', '\\', '//'), '/', $path);
$parts = array_filter(explode('/', $path), 'strlen');
$absolutes = array();
foreach ($parts as $part) {
if ('.' == $part) continue;
if ('..' == $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
return str_replace('//','/','/'.implode('/', $absolutes).'/');
}
!defined('CONTROLLER_PATH') && define('CONTROLLER_PATH', ROOT.'controller/');
onedrive::$client_id = config('client_id');
onedrive::$client_secret = config('client_secret');
onedrive::$redirect_uri = config('redirect_uri');
1
https://gitee.com/wangningkai/oneindex.git
git@gitee.com:wangningkai/oneindex.git
wangningkai
oneindex
oneindex
master

搜索帮助