/** * * @param type $oFile * @param type $sDir * @param type $sRootPath */ function writePhpList($oFile, $sDir, $sRootPath) { $aFile = getFileList($sDir); for ($i = 0; $i < count($aFile); $i++) { $sTemp = str_replace($sRootPath, ".", $aFile[$i]); $sTemp = str_replace("\\", "/", $sTemp); fwrite($oFile, $sTemp . "\n"); } $aSubDir = getSubDir($sDir); if ($aSubDir != false) { for ($i = 0; $i < count($aSubDir); $i++) { writePhpList($oFile, $aSubDir[$i], $sRootPath); } } }
/** * 自动加载类函数 * @param string $className */ function loadClassFile($className) { // 延迟加载 ActiveRecord,使得 if ($className == "ActiveRecord\\Model") { require_once LIBPATH . 'PHPActiveRecord' . DIRECTORY_SEPARATOR . 'ActiveRecord.php'; ActiveRecord\Config::initialize(function ($cfg) { $cfg->set_model_directory($GLOBALS['config']['moddir']); $cfg->set_connections($GLOBALS['config']['dbconfig']); $cfg->set_default_connection(!isset($_SERVER['HTTP_APPNAME']) ? 'local' : 'sae'); }); return; } $file = str_replace('\\', DIRECTORY_SEPARATOR, $className); $dirs = getSubDir(SYSPATH); //加载 sytem 下的所有目录作为候选目录 foreach ($dirs as $dir) { $filename = SYSPATH . $dir . DIRECTORY_SEPARATOR . $file . '.php'; if (file_exists($filename)) { require_once $filename; return; } } }