<?php
header("Content-type:text/html;charset=utf-8"); define('DYHB_PATH',str_replace('\\','/',dirname(__FILE__))); $GLOBALS['_beginTime_']=microtime(TRUE); define('IS_WIN',DIRECTORY_SEPARATOR=='\\'?1:0); function E($sMessage){ require_once(DYHB_PATH.'/Resource_/Template/Error.template.php'); exit(); } if(!defined('APP_PATH')){ define('APP_PATH',dirname($_SERVER['SCRIPT_FILENAME'])); } if(!defined('APP_RUNTIME_PATH')){ define('APP_RUNTIME_PATH',APP_PATH.'/App/~Runtime'); } set_exception_handler(array('Dyhb','exceptionHandler')); if(!defined('DOYOUHAOBABY_DEBUG')){ define('DOYOUHAOBABY_DEBUG',FALSE); } if(DOYOUHAOBABY_DEBUG===TRUE){ set_error_handler(array('Dyhb','errorHandel')); register_shutdown_function(array('Dyhb','shutdownHandel')); } if(function_exists('spl_autoload_register')) { spl_autoload_register(array('Dyhb','autoload')); }else{ function __autoload($sClassName){ Dyhb::autoLoad($sClassName); } } if(!defined('APP_RUNTIME_LOCK')){ define('APP_RUNTIME_LOCK',APP_RUNTIME_PATH.'/~Runtime.inc.lock'); } if(!is_file(APP_RUNTIME_LOCK)){ require(DYHB_PATH.'/Common_/InitRuntime.inc.php'); } define('DYHB_VERSION','2.5.2'); define('MEMORY_LIMIT_ON',function_exists('memory_get_usage')); if(MEMORY_LIMIT_ON){ $GLOBALS['_startUseMems_']=memory_get_usage(); } define('CURRENT_TIMESTAMP',time()); if(version_compare(PHP_VERSION,'6.0.0','<')){ if(version_compare(PHP_VERSION,'5.3.0','<')){ @set_magic_quotes_runtime(0); } define('MAGIC_QUOTES_GPC',get_magic_quotes_gpc()?TRUE:FALSE); } class Dyhb{ static private $INSTANCES=array(); static private $OBJECTS=array(); static private $_arrClassRegex=array('/^(.+)\.class\.php$/i','/^(.+)\.interface\.php$/i'); static private $_arrClassFilePat=array('%DirPath%/%ClassName%.class.php'); static private $_arrInterPat=array('%DirPath%/%ClassName%.interface.php'); static private $CLASS_PATH='Class.inc'; static private $_arrImportedPackDir=array(); static private $_bAutoLoad=true; static private $_sPackagePath=''; static private $_arrConfig=array(); static public function import($sPackage,$bForce=false){ if(!is_dir($sPackage)){ Dyhb::E("Package:'{$sPackage}' does not exists."); } self::$_sPackagePath=$sPackagePath=realpath($sPackage).'/'; $sClassPathFile=$sPackagePath.self::$CLASS_PATH; if($bForce || !is_file($sClassPathFile)){ $arrFileStores=array(); $arrClassPath=self::viewClass($sPackagePath); foreach($arrClassPath as $arrMap){ $arrFileStores[$arrMap['class']]=$arrMap['file']; $arrKeys[]=$arrMap['class']; } if(!empty($arrKeys) && count($arrKeys)!=count(array_unique($arrKeys))){ $arrDiffKeys=array(); $arrDiffUnique=array_unique($arrKeys); foreach($arrDiffUnique as $nKey=>$sValue){ if(in_array($sValue,$arrKeys)){ unset($arrKeys[$nKey]); } } E(sprintf('Same class %s exists',implode(',',$arrKeys))); } foreach($arrFileStores as $nKeyFileStore=>$sFileStoreValue){ if(in_array(DYHB_PATH.'/'.$sFileStoreValue,(array)(include DYHB_PATH.'/Config_/Paths.inc.php'))){ unset($arrFileStores[$nKeyFileStore]); } } $sFileContents=serialize($arrFileStores); if(!is_file($sClassPathFile)){ if(($hFile=fopen($sClassPathFile,'a'))!==false){ fclose($hFile); chmod($sClassPathFile,0666); }else{ return false; } } if(!file_put_contents($sClassPathFile,$sFileContents)){ E(sprintf('Can not create Class Path File: %s',$sClassPathFile)); } } self::$OBJECTS=array_merge(self::$OBJECTS,array_map(array('Dyhb','reallyPath'),self::readCache($sClassPathFile))); } static public function reallyPath($sValue){ return self::$_sPackagePath.$sValue; } static public function readCache($sCacheFile){ $sData=file_get_contents($sCacheFile); return unserialize($sData); } static public function regClass($sClass,$sPath){ if(isset(self::$OBJECTS[$sClass])){ E(sprintf('Class %s already exist in %s and unable to repeat the register',$sClass,$sPath)); } self::$OBJECTS[$sClass]=$sPath; } static public function setAutoload($bAutoload){ if(!is_bool($bAutoload)){ $bAutoload=$bAutoload?true:false; }else{ $bAutoload=&$bAutoload; } $bOldValue=self::$_bAutoLoad; self::$_bAutoLoad=$bAutoload; return $bOldValue; } static public function autoLoad($sClassName){ if(isset(self::$OBJECTS[$sClassName]) && !self::classExists($sClassName) && !self::classExists($sClassName,true)){ require(self::$OBJECTS[$sClassName]); } } static public function classExists($sClassName,$bInter=false,$bAutoload=false){ $bAutoloadOld=self::setAutoload($bAutoload); $sFuncName=$bInter?'interface_exists':'class_exists'; $bResult=$sFuncName($sClassName); self::setAutoload($bAutoloadOld); return $bResult; } static private function viewClass($sDirectory,$sPreFilename=''){ $arrReturnClass=array(); $sDirectoryPath=realpath($sDirectory).'/'; $hDir=opendir($sDirectoryPath); while(($sFilename=readdir($hDir))!==false){ $sPath=$sDirectoryPath.$sFilename; if(is_file($sPath)){ foreach(self::$_arrClassRegex as $sRegexp){ $arrRes=array(); if(preg_match($sRegexp,$sFilename,$arrRes)){ $sClassName=isset($arrRes[1])?$arrRes[1]:null; if($sClassName){ $arrReturnClass[]=array('class'=>$sClassName,'file'=>$sPreFilename.$sFilename); } } } }else if(is_dir($sPath)){ $sSpecialDir=array('.','..','.svn','#note'); if(in_array($sFilename,$sSpecialDir)){ unset($sSpecialDir); continue; }else{ $arrReturnClass=array_merge($arrReturnClass,self::viewClass($sPath,$sPreFilename.$sFilename.'/')); } }else{ Dyhb::E(sprintf("\$sPath:%s is not a valid path",$sPath)); } } return $arrReturnClass; } static public function instance($sClass,$Args=null,$sMethod=null,$MethodArgs=null){ $sIdentify=$sClass.serialize($Args).$sMethod.serialize($MethodArgs); if(!isset(self::$INSTANCES[$sIdentify])){ if(class_exists($sClass)){ $oClass=$Args===null?new $sClass():new $sClass($Args); if(!empty($sMethod) && method_exists($oClass,$sMethod)){ self::$INSTANCES[$sIdentify]=$MethodArgs===null?call_user_func(array(&$oClass,$sMethod)):call_user_func_array(array(&$oClass,$sMethod),array($MethodArgs)); }else{ self::$INSTANCES[$sIdentify]=$oClass; } }else{ Dyhb::E(sprintf('class %s is not exists',$sClass)); } } return self::$INSTANCES[$sIdentify]; } static public function cache($sId,$Data='',array $arrOption=null,$sBackendClass=null){ static $oObj=null; if(is_null($sBackendClass)){ $sBackendClass=$GLOBALS['_commonConfig_']['RUNTIME_CACHE_BACKEND']; } if(is_null($oObj)){ $oObj=self::instance($sBackendClass); } if($Data===''){ return $oObj->getCache($sId,$arrOption); } if($Data===null){ return $oObj->deleleCache($sId,$arrOption); } return $oObj->setCache($sId,$Data,$arrOption); } public static function normalize($Input,$sDelimiter=',',$bAllowedEmpty=false){ if(is_array($Input) || is_string($Input)){ if(!is_array($Input)){ $Input=explode($sDelimiter,$Input); } $Input=array_filter($Input); if($bAllowedEmpty===true){ return $Input; }else{ $Input=array_map('trim',$Input); return array_filter($Input,'strlen'); } }else{ return $Input; } } static public function exceptionHandler(Exception $oE){ $sErrstr=$oE->getMessage(); $sErrfile=$oE->getFile(); $nErrline=$oE->getLine(); $nErrno=$oE->getCode(); $sErrorStr="[$nErrno] $sErrstr ".basename($sErrfile).self::L(" 第 %d 行。",'__DYHB__@Dyhb',null,$nErrline); if($GLOBALS['_commonConfig_']['LOG_RECORD'] && self::C('LOG_MUST_RECORD_EXCEPTION')){ Log::W($sErrstr,Log::EXCEPTION); } if(method_exists($oE,'formatException')){ self::halt($oE->formatException()); }else{ self::halt($oE->getMessage()); } } static public function errorHandel($nErrorNo,$sErrStr,$sErrFile,$nErrLine){ if($nErrorNo){ E("<b>[{$nErrorNo}]:</b> {$sErrStr}<br><b>File:</b> {$sErrFile}<br><b>Line:</b> {$nErrLine}"); } } static public function shutdownHandel(){ if(($arrError=error_get_last()) && $arrError['type']){ E("<b>[{$arrError['type']}]:</b> {$arrError['message']}<br><b>File:</b> {$arrError['file']}<br><b>Line:</b> {$arrError['line']}"); } } static public function C($sName='',$Value=NULL,$Default=null){ if(is_string($sName) && !empty($sName) && $Value===null){ if(!strpos($sName,'.')){ return array_key_exists($sName,self::$_arrConfig)?self::$_arrConfig[$sName]:$Default; } $arrParts=explode('
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
PHP实例开发源码-DoYouHaoBaby PHP开发框架.zip (990个子文件)
myPage.css 29KB
all_in_one.css 26KB
style.css 7KB
style.css 4KB
common.css 3KB
common.css 3KB
common.css 3KB
common.css 3KB
loader.gif 11KB
loader.gif 11KB
loader.gif 11KB
loader.gif 11KB
Logo.gif 3KB
loader.gif 2KB
IconLogo.gif 2KB
info_big.gif 2KB
error_big.gif 2KB
image2.gif 673B
image1.gif 671B
m.gif 103B
w.gif 102B
m.gif 101B
q.gif 101B
h.gif 100B
q.gif 99B
g.gif 98B
r.gif 98B
r.gif 96B
w.gif 96B
b.gif 96B
h.gif 96B
k.gif 95B
8.gif 95B
k.gif 95B
8.gif 94B
x.gif 94B
c.gif 94B
b.gif 94B
v.gif 93B
v.gif 93B
6.gif 92B
p.gif 92B
x.gif 92B
p.gif 91B
g.gif 91B
9.gif 91B
2.gif 90B
3.gif 90B
4.gif 90B
6.gif 89B
j.gif 89B
4.gif 88B
e.gif 88B
y.gif 88B
t.gif 87B
y.gif 87B
9.gif 87B
2.gif 86B
3.gif 86B
e.gif 86B
f.gif 85B
j.gif 84B
7.gif 84B
t.gif 84B
c.gif 84B
7.gif 84B
f.gif 84B
.htaccess 176B
.htaccess 176B
.htaccess 176B
index_config.html 20KB
create_models.html 5KB
index_hello.html 3KB
index_index.html 3KB
create_controllers.html 3KB
public_header.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
index.html 3KB
共 990 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
毕业_设计
- 粉丝: 1979
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功