|
- /**
- * 返回库文件的全路径
- *
- * @param string $libname 库文件分类及名称
- * @param string $folder 模块目录'module','include','class'
- * @return string
- *
- * @example require DISCUZ_ROOT.'./source/function/function_cache.php'
- * @example 我们可以利用此函数简写为:require libfile('function/cache');
- *
- */
- function libfile($libname, $folder = '') {
- $libpath = '/source/'.$folder;
- if(strstr($libname, '/')) {
- list($pre, $name) = explode('/', $libname);
- $path = "{$libpath}/{$pre}/{$pre}_{$name}";
- } else {
- $path = "{$libpath}/{$libname}";
- }
- return preg_match('/^[\w\d\/_]+$/i', $path) ? realpath(DISCUZ_ROOT.$path.'.php') : false;
- }
复制代码 |
|