示例#1
0
文件: Lib.php 项目: sparrww/frame
        }
        list($path, $param) = explode("?", $_SERVER["PHP_SELF"]);
        $param = explode("/", str_replace($string, '', $path));
        $array['module'] = $param[1] ? $param[1] : C("DEFAULT_MODULE");
        $array['controller'] = str_replace('/', '\\', ($param[2] ? $param[1] . '/' . CONTROLLER . '/' . $param[2] : str_replace('Home', ucwords($array['module']), C("DEFAULT_CONTROLLER"))) . CONTROLLER);
        $array['operate'] = $param[3] ? $param[3] : 'index';
        for ($i = 4; $i < count($param); $i++) {
            $array[$param[$i]] = $param[++$i];
        }
        return array_filter($array);
    }
    /**
	 * 程序结束输出 header
	 *
	 * @access private
	 * @static
示例#2
0
文件: DbPdo.php 项目: sparrww/frame
 /**
  * 构造方法
  * @access	public
  * @param	$db	type:array
  * @return	void
  */
 public function __construct(array $db = [])
 {
     if (!is_array($db)) {
         return false;
     }
     // 验证扩展是否开启
     if (!extension_loaded("Pdo_mysql")) {
         throwexce(sprintf("Your PHP installation appears to be missing the %s extension which is required by Worker.", "Pdo"));
     }
     try {
         $this->pdo = new \PDO("mysql:host={$db['DB_HOST']};dbname={$db['DB_NAME']}", $db['DB_USER'], $db['DB_PASS'], $db['DB_PERSISTENT'] ? array(PDO::ATTR_PERSISTENT => true) : []);
         $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         // $this->pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
         $this->pdo->exec("set names utf8");
     } catch (\Exception $e) {
         \Lib\throwexce($e->getMessage());
     }
 }
示例#3
0
/**
 * 调用配置文件
 *
 * @param	string $path   文件夹路径
 * @return	array
 */
function C($string)
{
    $array = getconfig(CONFIG_PATH);
    if (is_array($array)) {
        return $array[$string];
    } else {
        throwexce('config not array!');
    }
}
示例#4
0
 /**
  * 解析文件
  */
 private static function parse($tpl_file)
 {
     if (!defined("TPL_INCLUDE")) {
         throwexce(sprintf('For your security, please call before the procedure to define a template called TPL_INCLUDE constant'), 'Template');
     }
     $d = "<?php defined('TPL_INCLUDE') OR exit('Access Denied'); ?>\r\n";
     $s = $d . file_get_contents($tpl_file);
     $s = @preg_replace("/\\<\\!\\-\\-\\s*\\{(.+?)\\}\\s*\\-\\-\\>/is", "", $s);
     $s = @preg_replace("/\\{include\\s+(.+?)\\}/is", "<?php include Lib\\Template::Tpl(\\1); ?>", $s);
     $s = @preg_replace("/\\{([A-Z][A-Z0-9_]*)\\}/s", "<?php if(defined('\\1')){echo \\1;}?>", $s);
     $s = @preg_replace("/\\{(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$-�]+)\\}/is", "<?php if(\\1){echo \\1;}?>", $s);
     $s = @preg_replace("/\\{\\\$(.+?)\\}/is", "<?php if(\$\\1){ echo \$\\1;}?>", $s);
     $s = @preg_replace("/\\{([@&\\\$a-zA-Z0-9_]+)\\:([ ,\\?\\.=&%-\\:a-zA-Z0-9_\\[\\]\\'\"\\\$-�\\(\\)]*)\\}/is", "<?php echo \\1(\\2);?>", $s);
     $s = @preg_replace("/\\{php\\}/is", "<?php", $s);
     $s = @preg_replace("/\\{\\/php\\}/is", "?>", $s);
     for ($i = 0; $i <= 5; $i++) {
         $s = @preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\}\\s*(.+?)\\s*\\{\\/loop\\}[\n\r\t]*/ies", "Lib\\Template::strip('<?php if((\\1) && is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<?php }} ?>')", $s);
         $s = @preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\}\\s*(.+?)\\s*\\{\\/loop\\}[\n\r\t]*/ies", "Lib\\Template::strip('<?php if((\\1) && is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<?php }} ?>')", $s);
         $s = @preg_replace("/[\n\r\t]*\\{if\\s+(.+?)\\}(\\s*)(.+?)(\\s*)\\{\\/if\\}[\n\r\t]*/ies", "Lib\\Template::strip('<?php if(\\1){?>\\2','\\3\\4<?php }?>')", $s);
     }
     $s = @preg_replace("/[\n\r\t]*\\{elseif\\s+(.+?)\\}[\n\r\t]*/ies", "Lib\\Template::strip('<?php }elseif(\\1) { ?>','')", $s);
     $s = @preg_replace("/[\n\r\t]*\\{else\\}[\n\r\t]*/is", "<?php } else { ?>", $s);
     return $s;
 }