129 lines
2.9 KiB
PHP
Executable File
129 lines
2.9 KiB
PHP
Executable File
<?php
|
|
/**
|
|
*
|
|
* @author Fm453
|
|
* @site www.hiluker.com
|
|
* @remark 自定义加载器(加载的是文件,文件中允许多函数或类)
|
|
* 全部fmsoft文件的使用前提都是先引用了本文件
|
|
*/
|
|
defined('HI_FM') or define('HI_FM',true);
|
|
defined('FM_CORE') or define('FM_CORE',dirname(__FILE__).'/');
|
|
defined('FM_YII_ROOT') or define('FM_YII_ROOT',str_replace('vendor/fmsoft/','',FM_CORE));
|
|
|
|
global $_FM;
|
|
|
|
function fm_load() {
|
|
static $loader;
|
|
if(empty($loader)) {
|
|
$fm_loader = new fm_loader();
|
|
}
|
|
return $fm_loader;
|
|
}
|
|
|
|
class fm_loader {
|
|
private $cache = [];
|
|
|
|
function fm_func($name) {
|
|
global $_FM;
|
|
if (isset($cache['fmfunc'][$name])) {
|
|
return true;
|
|
}
|
|
$_FM_CORE = FM_CORE;
|
|
$file = $_FM_CORE . 'function/' . $name . '.func.php';
|
|
if (file_exists($file)) {
|
|
include_once $file;
|
|
$cache['fmfunc'][$name] = true;
|
|
return true;
|
|
} else {
|
|
trigger_error('Invalid Function '.$_FM_CORE.'function/' . $name . '.func.php', E_USER_ERROR);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function fm_class($name) {
|
|
global $_FM;
|
|
if (isset($cache['fmclass'][$name])) {
|
|
return true;
|
|
}
|
|
$_FM_CORE = FM_CORE;
|
|
$file = $_FM_CORE . 'class/' . $name . '.class.php';
|
|
if (file_exists($file)) {
|
|
require_once $file;
|
|
$cache['fmclass'][$name] = true;
|
|
return true;
|
|
} else {
|
|
trigger_error('Invalid Class '.$_FM_CORE.'class/' . $name . '.class.php', E_USER_ERROR);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function fm_model($name) {
|
|
global $_FM;
|
|
if (isset($cache['fmmodel'][$name])) {
|
|
return true;
|
|
}
|
|
$_FM_CORE = FM_CORE;
|
|
$file = $_FM_CORE . 'model/' . $name . '.mod.php';
|
|
if (file_exists($file)) {
|
|
include_once $file;
|
|
$cache['fmmodel'][$name] = true;
|
|
return true;
|
|
} else {
|
|
trigger_error('Invalid Model '.$_FM_CORE.'model/' . $name . '.mod.php', E_USER_ERROR);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function fm_web($name) {
|
|
global $_FM;
|
|
if (isset($cache['fmweb'][$name])) {
|
|
return true;
|
|
}
|
|
$_FM_CORE = FM_CORE;
|
|
$file = $_FM_CORE . 'web/' . $name . '.php';
|
|
if (file_exists($file)) {
|
|
include_once $file;
|
|
$cache['fmweb'][$name] = true;
|
|
return true;
|
|
} else {
|
|
trigger_error('Invalid Web Helper '.$_FM_CORE.'web/' . $name . '.php', E_USER_ERROR);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function fm_app($name) {
|
|
global $_FM;
|
|
if (isset($cache['fmapp'][$name])) {
|
|
return true;
|
|
}
|
|
$_FM_CORE = FM_CORE;
|
|
$file = $_FM_CORE . 'app/' . $name . '.php';
|
|
if (file_exists($file)) {
|
|
include_once $file;
|
|
$cache['fmapp'][$name] = true;
|
|
return true;
|
|
} else {
|
|
trigger_error('Invalid App Function '.$_FM_CORE.'app/' . $name . '.php', E_USER_ERROR);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* 动态引用变量$_FM;
|
|
*/
|
|
function fm_vars() {
|
|
global $_FM;
|
|
$_FM_CORE = FM_CORE;
|
|
$file = $_FM_CORE . 'vars.php';
|
|
if (file_exists($file)) {
|
|
include $file; //每次请求均调用
|
|
} else {
|
|
if(defined(FM_DEBUG) && FM_DEBUG == true){
|
|
trigger_error('文件 '.$file.'不在在!', E_USER_ERROR);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|