예제 #1
0
 /**
  * 部分功能初始化
  */
 public static function init()
 {
     //引入公共方法
     require __BT__ . '/common/common.php';
     if (defined("__APP__")) {
         $file = __APP__ . '/common/common.php';
         if (is_file($file)) {
             require $file;
         }
         $config = __APP__ . '/library/Config.php';
         if (is_file($config)) {
             $conf = (include $config);
             //初始化conf
             Conf::init($conf);
         }
     }
     //定义常量.
     define('PHP_CLI', php_sapi_name());
     define('NOW_TIME', $_SERVER['REQUEST_TIME']);
     if (PHP_CLI != 'cli') {
         define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
         define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
         define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
         define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
         define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
         define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ? true : false);
     }
 }
예제 #2
0
 public function run($config)
 {
     Conf::init($config);
     //设置app路由
     if ($_SERVER['REQUEST_URI'] != "/") {
         $server_request_uri = parse_url($_SERVER['REQUEST_URI']);
         $domainInfo = Router::init()->parseDomain($server_request_uri['path'], Conf::init()->getConf("ROUTER"), Conf::init()->getConf("ROUTER")['default']);
         Conf::init()->setAppInfo($domainInfo);
         //注册应用地址
     }
     Autoloader::register(Conf::init()->getAppPath());
     //获取路由表
     $routers = Conf::init()->getRouter();
     //解析url路径
     $actArr = array();
     if ($_SERVER['REQUEST_URI'] === "/") {
         $actArr = Router::init()->getDefaultAct();
     } else {
         $server_request_uri = parse_url($_SERVER['REQUEST_URI']);
         $actArr = Router::init()->parse($server_request_uri['path'], $routers);
     }
     Router::init()->load(Conf::init()->getAppPath(), $actArr);
 }
예제 #3
0
define('ROOT_DIR', dirname(dirname(__FILE__)));
/**
 * 全局配置类
 */
class Conf
{
    static $rootDir;
    static $scriptDir;
    static function init()
    {
        self::$rootDir = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
        $scriptDir = str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']);
        self::$scriptDir = substr($scriptDir, 0, strrpos($scriptDir, '/'));
    }
}
Conf::init();
require_once ROOT_DIR . '/common/Util.php';
require_once ROOT_DIR . '/common/Service.php';
/*
Service 组件在每个页面里面的调用方法
$service = new Service(array(
    'tplPath' => 'zhuanti/index',
    // json文件数组配置,会依次读取json文件中的变量,然后塞到smarty的templateVars
    'json' => array(
        '../common/data/header.json',
        './data'
    ),
    // 或者采用hash数组配置,会把json对象赋值给`key`,然后塞到smarty的templateVars
    'json' => array(
        'header' => '../common/data/header.json',
        'data' => './data'
예제 #4
0
<?php

//+---------------------------------------------------------------------------------------------------------------------------------+
//																    /
// Copyright (c) 2012 Yahoo! Inc. All rights reserved. 										    /
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this 				            /
// file except in compliance with the License. You may obtain a copy of the License at 						    /
//																    /
//		http://www.apache.org/licenses/LICENSE-2.0 									    /
//																    /
// Unless required by applicable law or agreed to in writing, software distributed under 					    /
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF    					    /
// ANY KIND, either express or implied. See the License for the specific language governing 					    /
// permissions and limitations under the License. See accompanying LICENSE file.						    /
// 																    /
// $Author:shawcs@yahoo-inc.com  $Date: 30-Jan-2012										    /
//																    /
//+---------------------------------------------------------------------------------------------------------------------------------+
define('OPS_APP_PRIVATE_DIR', dirname(__FILE__));
require_once 'assist/common/init.php';
require_once 'assist/include.inc';
// initialize config files
Conf::init('conf/calendar_database.ini', 'db');