예제 #1
0
 /**
  * 工厂模式调用验证码驱动
  *
  * @param  string  $driver
  * @param  mixed   $options
  * @return EGP_Captcha_Abstract
  * @throws Exception
  */
 public static function factory($driver = 'basic', $options = array())
 {
     if ($options instanceof YUN_ArrayObject) {
         $options = $options->toArray();
     }
     if (!is_array($options)) {
         throw new Exception('验证码的配置必须是一个数组(Array)');
     }
     $class = 'YUN_Captcha_' . ucfirst($driver);
     if (!YUN_Core::classExists($class)) {
         throw new Exception("不支持的验证码类型: '{$driver}'");
     }
     $obj = new $class($options);
     if (!$obj instanceof YUN_Captcha_Abstract) {
         throw new Exception("'{$driver}' 必须从 'YUN_Captcha_Abstract ' 继承");
     }
     $storage = self::getInstance()->getStorage();
     $storage->phrase = strtolower($obj->generatePhrase());
     //$storage->lock(); //锁定
     return $obj;
 }
예제 #2
0
 * 設置類的查找路徑
 */
YUN_Core::setIncludePath(strip(LIB_DIR));
//Regulus_Core的單例模式實現
$regulusCore = YUN_Core::getInstance();
/**
 * 设定异常处理控制器 错误处理控制器
 */
set_exception_handler(array($regulusCore, 'exceptionHandler'));
set_error_handler(array($regulusCore, 'errorHandler'));
/**
 * 加载配置文件
 */
$config = YUN_Core::loadConfig('config');
Zend_Registry::set('config', $config);
$route = YUN_Core::loadConfig('route');
/**
 * Zend_Controller_Front 初始化
 */
$controller = Zend_Controller_Front::getInstance();
foreach ($config->hosts as $key => $value) {
    $arr[$key] = $value;
}
$controller->setControllerDirectory($arr);
// 添加模塊
$controller->setDefaultModule('default');
$controller->throwExceptions(true);
// 設置錯誤機制
$controller->setParam('noViewRenderer', true);
// 不使用默認的視圖
$controller->setParam('noErrorHandler', false);
예제 #3
0
 /**
  * 在所有及指定的目录内查找文件,并返回完整路径
  *
  * @param  string  $file  文件及路径
  * @param  mixed   $dirs  查找的目录
  * @return string|false
  */
 public static function findFile($file, $dirs = null)
 {
     $file = preg_replace('/[\\\\\\/]+/', DIR_SEP, $file);
     if (!is_file($file)) {
         !is_array($dirs) && ($dirs = array($dirs));
         null == self::$_dirs && (self::$_dirs = explode(PATH_SEP, get_include_path()));
         $dirs = array_merge($dirs, self::$_dirs);
         $tmp = '';
         foreach ($dirs as $dir) {
             $tmp = preg_replace('/[\\\\\\/]+$/', '', trim($dir)) . DIR_SEP . $file;
             if (@is_file($tmp)) {
                 break;
             }
             unset($tmp);
         }
         $file = empty($tmp) ? $file : $tmp;
     }
     return is_readable($file) ? $file : false;
 }