示例#1
0
文件: wekit.php 项目: fanqimeng/4tweb
 /**
  * phpwind初始化
  *
  * @return void
  */
 public static function init()
 {
     function_exists('set_magic_quotes_runtime') && @set_magic_quotes_runtime(0);
     $_conf = (include WEKIT_PATH . '../conf/directory.php');
     foreach ($_conf as $namespace => $path) {
         $realpath = realpath(WEKIT_PATH . $path);
         Wind::register($realpath, $namespace);
         define($namespace . '_PATH', $realpath . DIRECTORY_SEPARATOR);
     }
     Wind::register(WEKIT_PATH, 'WEKIT');
     self::_loadBase();
 }
示例#2
0
文件: wekit.php 项目: ccq18/EduSoho
 /**
  * phpwind初始化
  *
  * @return void
  */
 public static function init($name)
 {
     function_exists('set_magic_quotes_runtime') && @set_magic_quotes_runtime(0);
     self::_loadSystemConfig($name);
     $_conf = (include WEKIT_PATH . self::S('directory'));
     foreach ($_conf as $namespace => $path) {
         $realpath = realpath(WEKIT_PATH . $path);
         Wind::register($realpath, $namespace);
         define($namespace . '_PATH', $realpath . DIRECTORY_SEPARATOR);
     }
     Wind::register(WEKIT_PATH, 'WEKIT');
     self::_loadBase();
     self::$_var = self::S('global-vars');
 }
 public function initConfig($config, $factory)
 {
     is_array($config) || ($config = $factory->getInstance('configParser')->parse($config));
     foreach ($config['web-apps'] as $key => $value) {
         if (isset($this->_config['web-apps'][$key])) {
             continue;
         }
         $rootPath = empty($value['root-path']) ? dirname($_SERVER['SCRIPT_FILENAME']) : Wind::getRealPath($value['root-path'], true);
         Wind::register($rootPath, $key, true);
         if ('default' !== $key && !empty($config['default'])) {
             $value = WindUtility::mergeArray($config['default'], $value);
         }
         $this->setConfig($key, $value);
     }
     $this->_config['router'] = isset($config['router']) ? $config['router'] : array();
 }
示例#4
0
 * 
 * 支持参数<code>
 * -r	是否递归的方式打包文件夹
 * -p	将所列文件夹打包,合并成一个文件(去除空格,注释等)
 * example:
 * pack -pci /var/www/wind/utility /var/www/wind/base
 * 这个例子中包含两个文件夹utility、base(支持文件,文件夹;支持一个或者多个)。打包工具将这两个文件夹下面的文件打包到同一个文件下。
 * 并将 /var/www/wind/ 以WIND别名注册为系统目录别名
 * </code>
 * @author Qiong Wu <*****@*****.**> 2010-11-2
 * @link http://www.phpwind.com
 * @copyright Copyright &copy; 2003-2010 phpwind.com
 * @license http://www.phpwind.com/license.php
 */
include '../../wind/Wind.php';
Wind::register(dirname(dirname(__FILE__)), '_COMPILE');
Wind::import('_COMPILE:lib.*');
$args = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
if (count($args) < 2) {
    CompileCmdHelp::showError('Not enough arguments provided');
}
unset($args[0]);
$files = array();
$params = '';
foreach ($args as $value) {
    if (!$value) {
        continue;
    }
    if ($value[0] === '-') {
        $params .= trim($value, '-');
    } else {
示例#5
0
<?php

!class_exists('PHPUnit_Framework_TestCase') && (include 'PHPUnit/Framework/TestCase.php');
define('T_P', dirname(__FILE__));
define('WIND_DEBUG', true);
include 'Wind.php';
Wind::register(T_P, 'TEST');
abstract class BaseTestCase extends PHPUnit_Framework_TestCase
{
    protected function setUp()
    {
        parent::setUp();
        Wind::init();
    }
    protected function tearDown()
    {
        parent::tearDown();
        spl_autoload_unregister('Wind::autoLoad');
    }
    protected function assertArrayEquals($array1, $array2)
    {
        !is_array($array1) && $this->fail("Error type for arg1");
        $this->assertTrue(is_array($array2) && count($array1) == count($array2));
        foreach ($array1 as $key => $value) {
            $this->assertTrue(isset($array2[$key]));
            if (is_array($value)) {
                $this->assertArrayEquals($value, $array2[$key]);
            } elseif (is_object($value)) {
                $this->assertEquals(get_class($value), get_class($array2[$key]));
            } else {
                $this->assertEquals($value, $array2[$key]);
 /**
  * 初始化前端控制器
  * <ul>
  * <li>初始化应用配置<li>
  * <li>加载类加载器,拥有系统初始化加速</li>
  * <li>初始化组建工厂,组建工厂的组建分为,系统配置和自定义配置</li>
  * <li>初始化应用根目录</li>
  * </ul>
  * 
  * @param array|string $config
  *        应用配置
  */
 protected function init($config)
 {
     $factory = WindFactory::_getInstance();
     $factory->setClassDefinitions($this->_components());
     $this->_loadBaseLib();
     $this->_initConfig($config, $factory);
     if (!empty($this->_config['components'])) {
         if (!empty($this->_config['components']['resource'])) {
             $this->_config['components'] += $factory->getInstance('configParser')->parse(Wind::getRealPath($this->_config['components']['resource'], true, true));
         }
         $factory->loadClassDefinitions($this->_config['components']);
     }
     $rootPath = empty($this->_config['web-apps'][$this->_appName]['root-path']) ? dirname($_SERVER['SCRIPT_FILENAME']) : Wind::getRealPath($this->_config['web-apps'][$this->_appName]['root-path'], false);
     Wind::register($rootPath, $this->_appName, true);
     if ($this->_appName === 'default') {
     } elseif (isset($this->_config['web-apps'][$this->_appName])) {
         $this->_config['web-apps'][$this->_appName] = WindUtility::mergeArray($this->_config['web-apps']['default'], $this->_config['web-apps'][$this->_appName]);
     } else {
         throw new WindException('Your requested application \'' . $this->_appName . '\' was not found on this server, please check your application configuration.', WindException::ERROR_SYSTEM_ERROR);
     }
 }
示例#7
0
<?php

!defined("ACLOUD_PATH") && define("ACLOUD_PATH", dirname(__FILE__) . DIRECTORY_SEPARATOR);
Wind::register(ACLOUD_PATH, 'ACLOUD');
require_once Wind::getRealPath('ACLOUD:system.core.ACloudSysCoreCommon');
define('ACLOUD_VERSION_PATH', ACLOUD_PATH . '/version/' . ACloudSysCoreDefine::ACLOUD_VERSION);
Wind::register(ACLOUD_VERSION_PATH, 'ACLOUD_VER');
require_once Wind::getRealPath(sprintf('ACLOUD:version.%s.ACloud%sBootstrap', ACloudSysCoreDefine::ACLOUD_VERSION, ucfirst(ACloudSysCoreDefine::ACLOUD_VERSION)));
class ACloudRouter
{
    public function run()
    {
        list($a) = ACloudSysCoreS::gp(array('a'));
        $action = $a ? $a . "Action" : "";
        if ($action && method_exists($this, $action)) {
            ACloudInit::execute();
            $this->{$action}();
        }
    }
    public function sysAction()
    {
        Wind::import('ACLOUD:system.ACloudSysRouter');
        $sysRouter = new ACloudSysRouter();
        return $sysRouter->run();
    }
    public function apiAction()
    {
        Wind::import('ACLOUD:api.ACloudApiRouter');
        $apiRouter = new ACloudApiRouter();
        return $apiRouter->run();
    }
示例#8
0
if (!defined('WEKIT_VERSION')) {
    error_reporting(E_ERROR | E_PARSE);
    require_once WINDID_BOOT . '../wekit.php';
    Wekit::init('windidclient');
    Wind::application('windidclient', Wekit::S());
    $database = (include WINDID_BOOT . 'conf/database.php');
    $windidConfig = (include Wind::getRealPath('WINDID:conf.config.php', true));
    Wind::register(WINDID_PATH . 'service', 'SRV');
} else {
    $windidConfig = Wekit::C('windid');
    if ($windidConfig['windid'] == 'local') {
        $database = Wind::getComponent('db')->getConfig();
        $database['tableprefix'] .= 'windid_';
        $windidConfig['connect'] = 'db';
    } else {
        $database = array('dsn' => 'mysql:host=' . $windidConfig['db.host'] . ';dbname=' . $windidConfig['db.name'] . ';port=' . $windidConfig['db.port'], 'user' => $windidConfig['db.user'], 'pwd' => $windidConfig['db.pwd'], 'charset' => $windidConfig['db.charset'], 'tableprefix' => $windidConfig['db.prefix']);
    }
    $windidConfig['charset'] = Wekit::V('charset');
}
Wind::register(WINDID_PATH . 'service', 'WSRV');
Wind::import('WSRV:base.WindidBaseDao');
Wind::import('WSRV:base.WindidUtility');
Wind::import('WSRV:base.WindidError');
Wind::registeComponent(array('path' => 'WIND:db.WindConnection', 'config' => $database), 'windiddb', 'singleton');
define('WINDID_CONNECT', $windidConfig['connect']);
define('WINDID_SERVER_URL', $windidConfig['serverUrl']);
define('WINDID_CLIENT_ID', $windidConfig['clientId']);
define('WINDID_CLIENT_KEY', $windidConfig['clientKey']);
define('WINDID_CLIENT_CHARSET', $windidConfig['charset']);
Wekit::createapp('windidclient', 'windid');
示例#9
0
<?php

/**
 * @author Shi Long <*****@*****.**>
 * @link http://www.phpwind.com
 * @copyright Copyright &copy; 2003-2010 phpwind.com
 * @license
 */
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
require_once dirname(dirname(__DIR__)) . '/wind/Wind.php';
Wind::register(dirname(dirname(__DIR__)), 'PROJ');
Wind::application('web', __DIR__ . '/conf/config.php')->run();
示例#10
0
<?php

!defined('WINDID') && define('WINDID', dirname(__FILE__));
!defined('WINDID_PATH') && define('WINDID_PATH', WINDID);
!defined('WINDID_VERSION') && define('WINDID_VERSION', '0.0.2');
if (!defined('WEKIT_VERSION')) {
    require_once WINDID . '/../../wind/Wind.php';
    $database = (include WINDID . '/conf/database.php');
    Wind::register(WINDID, 'WINDID');
    Wind::application();
    Wind::import('WINDID:library.Windid');
    $component = array('path' => 'WIND:db.WindConnection', 'config' => $database);
    Wind::registeComponent($component, 'windiddb', 'singleton');
}
class WindidApi
{
    public static function api($api)
    {
        static $cls = array();
        $array = array('user', 'config', 'message', 'avatar', 'area', 'school');
        if (!in_array($api, $array)) {
            return WindidError::FAIL;
        }
        $class = 'Windid' . ucfirst($api) . 'Api';
        if (!isset($cls[$class])) {
            if (Windid::client()->clientDb == 'mysql') {
                $class = Wind::import('WINDID:api.local.' . $class);
                $cls[$class] = new $class();
            } elseif (Windid::client()->clientDb == 'http') {
                $class = Wind::import('WINDID:api.web.' . $class);
                $cls[$class] = new $class();
 /**
  * 初始化配置信息
  *
  * @param array $config
  */
 protected function initConfig()
 {
     if (!$this->_config) {
         return;
     }
     if (is_string($this->_config)) {
         $this->_config = $this->getFactory()->getInstance('configParser')->parse($this->_config);
     }
     if (isset($this->_config['isclosed']) && $this->_config['isclosed']) {
         if ($this->_config['isclosed-tpl']) {
             $this->_errPage = $this->_config['isclosed-tpl'];
         } else {
             $this->_errPage = 'close';
         }
         throw new Exception('Sorry, Site has been closed!');
     }
     if (!empty($this->_config['components'])) {
         if (!empty($this->_config['components']['resource'])) {
             $this->_config['components'] += $this->getFactory()->getInstance('configParser')->parse(Wind::getRealPath($this->_config['components']['resource'], true, true));
         }
         $this->getFactory()->loadClassDefinitions($this->_config['components']);
         unset($this->_config['components']);
     }
     if (empty($this->_config['web-apps'])) {
         return;
     }
     foreach ($this->_config['web-apps'] as $key => $value) {
         $rootPath = empty($value['root-path']) ? dirname($_SERVER['SCRIPT_FILENAME']) : Wind::getRealPath($value['root-path'], false);
         Wind::register($rootPath, $key, true);
     }
 }