Exemplo n.º 1
0
 function getConf($name)
 {
     $name = $this->_normalizeConfName($name);
     if (isset($this->confs[$name])) {
         return $this->confs[$name];
     }
     $ext = substr($name, strpos($name, '.'));
     if ($ext == '.ini') {
         $file = $this->_locateConfFiles($name);
         if (lmb_env_has('LIMB_VAR_DIR')) {
             $this->confs[$name] = new lmbCachedIni($file, lmb_env_get('LIMB_VAR_DIR') . '/ini/');
         } else {
             $this->confs[$name] = new lmbIni($file);
         }
     } elseif ($ext == '.yml') {
         $file = $this->_locateConfFiles($name);
         $this->confs[$name] = $this->parseYamlFile(lmbFs::normalizePath($file));
     } elseif ($ext == '.conf.php') {
         $file = $this->_locateConfFiles($name);
         if (!count($file)) {
             throw new lmbFileNotFoundException($name);
         }
         $this->confs[$name] = new lmbConf(lmbFs::normalizePath($file));
     } else {
         throw new lmbException("'{$ext}' type configuration is not supported!");
     }
     return $this->confs[$name];
 }
Exemplo n.º 2
0
 function createLocaleObject($locale)
 {
     $file = $this->toolkit->findFileByAlias($locale . '.ini', lmb_env_get('LIMB_LOCALE_INCLUDE_PATH'), 'i18n_locale');
     if (lmb_env_has('LIMB_VAR_DIR')) {
         return new lmbLocale($locale, new lmbCachedIni($file, lmb_env_get('LIMB_VAR_DIR') . '/locale/'));
     } else {
         return new lmbLocale($locale, new lmbIni($file));
     }
 }
 function testRemove()
 {
     lmb_env_set('foo_remove', 'bar');
     $this->assertTrue(lmb_env_has('foo_remove'));
     $this->assertEqual(lmb_env_get('foo_remove'), 'bar');
     lmb_env_remove('foo_remove');
     $this->assertFalse(lmb_env_has('foo_remove'));
     $this->assertEqual(lmb_env_get('foo_remove', $random = mt_rand()), $random);
 }
Exemplo n.º 4
0
 static function getTmpDir()
 {
     if (lmb_env_has('LIMB_VAR_DIR')) {
         return lmb_env_get('LIMB_VAR_DIR');
     }
     if ($path = session_save_path()) {
         if (($pos = strpos($path, ';')) !== false) {
             $path = substr($path, $pos + 1);
         }
         return $path;
     }
     if ($tmp = getenv('TMP') || ($tmp = getenv('TEMP') || ($tmp = getenv('TMPDIR')))) {
         return $tmp;
     }
     //gracefull falback?
     return '/tmp';
 }
Exemplo n.º 5
0
 function getFileLocator($paths, $locator_name = null)
 {
     if (!$locator_name) {
         $locator_name = md5($paths);
     }
     if (isset($this->file_locators[$locator_name])) {
         return $this->file_locators[$locator_name];
     }
     if (is_array($paths)) {
         $file_locations = new lmbIncludePathFileLocations($paths);
     } else {
         $file_locations = new lmbIncludePathFileLocations(explode(';', $paths));
     }
     if (lmb_env_has('LIMB_VAR_DIR') && 'devel' != lmb_env_get('LIMB_APP_MODE')) {
         $locator = new lmbCachingFileLocator(new lmbFileLocator($file_locations), lmb_env_get('LIMB_VAR_DIR') . '/locators/', $locator_name);
     } else {
         $locator = new lmbFileLocator($file_locations);
     }
     $this->file_locators[$locator_name] = $locator;
     return $locator;
 }
Exemplo n.º 6
0
function lmb_env_trace_has($name)
{
    return lmb_env_has('profile' . $name . LIMB_UNDEFINED);
}
Exemplo n.º 7
0
    lmb_env_setor('LIMB_HTTP_REQUEST_PATH', $request->getUri()->toString());
    if (!lmb_env_has('LIMB_HTTP_OFFSET_PATH')) {
        $offset = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
        if ($offset && $offset != '.') {
            lmb_env_setor('LIMB_HTTP_OFFSET_PATH', $offset . '/');
        } else {
            lmb_env_setor('LIMB_HTTP_OFFSET_PATH', '');
        }
    }
    if (substr(lmb_env_get('LIMB_HTTP_OFFSET_PATH'), 0, 1) == '/') {
        throw new lmbException('LIMB_HTTP_OFFSET_PATH constant must not have starting slash(' . lmb_env_get('LIMB_HTTP_OFFSET_PATH') . ')!!!');
    }
    //HTTP_BASE_PATH is defined automatically according to current host and offset settings
    lmb_env_setor('LIMB_HTTP_BASE_PATH', $request->getUri()->toString(array('protocol', 'user', 'password', 'host', 'port')) . '/' . lmb_env_get('LIMB_HTTP_OFFSET_PATH'));
    if (!lmb_env_has('LIMB_HTTP_GATEWAY_PATH')) {
        if (lmb_env_has('LIMB_ENABLE_MOD_REWRITE')) {
            lmb_env_setor('LIMB_HTTP_GATEWAY_PATH', lmb_env_get('LIMB_HTTP_BASE_PATH'));
        } else {
            lmb_env_setor('LIMB_HTTP_GATEWAY_PATH', lmb_env_get('LIMB_HTTP_BASE_PATH') . 'index.php/');
        }
    }
    lmb_env_setor('LIMB_HTTP_SHARED_PATH', lmb_env_get('LIMB_HTTP_BASE_PATH') . 'shared/');
    if (substr(lmb_env_get('LIMB_HTTP_BASE_PATH'), -1, 1) != '/') {
        echo 'LIMB_HTTP_BASE_PATH constant must have trailing slash(' . lmb_env_get('LIMB_HTTP_BASE_PATH') . ')!!!';
        exit(1);
    }
    if (substr(lmb_env_get('LIMB_HTTP_SHARED_PATH'), -1, 1) != '/') {
        echo 'LIMB_HTTP_SHARED_PATH constant must have trailing slash(' . lmb_env_get('LIMB_HTTP_SHARED_PATH') . ')!!!';
        exit(1);
    }
}
Exemplo n.º 8
0
 protected function _isDbInfoCacheEnabled()
 {
     if (is_null($this->is_db_info_cache_enabled)) {
         $this->is_db_info_cache_enabled = true;
         if (lmb_env_has('LIMB_CACHE_DB_META_IN_FILE')) {
             $this->is_db_info_cache_enabled = lmb_env_get('LIMB_CACHE_DB_META_IN_FILE');
         } else {
             if ($this->toolkit->getConf('db')->has('cache_db_info')) {
                 $this->is_db_info_cache_enabled = $this->toolkit->getConf('db')->get('cache_db_info');
             }
         }
     }
     return $this->is_db_info_cache_enabled;
 }
    protected function _makeCallFromDifferentThread($method, $arguments)
    {
        $filename = lmb_var_dir() . '/diff_thread.php';
        $cur_file_dir = dirname(__FILE__);
        $include_path = get_include_path();
        $cur_process_dir = getcwd();
        $arguments_str = implode("', '", $arguments);
        $setup_file = realpath($cur_file_dir . '/../../../common.inc.php');
        if (lmb_env_has('LIMB_DB_DSN')) {
            $limb_db_dsn = "lmb_env_setor('LIMB_DB_DSN', '" . lmb_env_get('LIMB_DB_DSN') . "');";
        } else {
            $limb_db_dsn = '';
        }
        if (lmb_env_has('LIMB_VAR_DIR')) {
            $limb_var_dir = "lmb_env_setor('LIMB_VAR_DIR', '" . lmb_env_get('LIMB_VAR_DIR') . "');";
        } else {
            $limb_var_dir = '';
        }
        if ($this->storage_init_file) {
            $storage_init_file = "lmb_require('{$this->storage_init_file}');";
        } else {
            $storage_init_file = '';
        }
        $request_code = <<<EOD
<?php
    ob_start();
    chdir('{$cur_process_dir}');
    set_include_path('{$include_path}');
    require_once('{$setup_file}');

    {$limb_db_dsn}
    {$limb_var_dir}
    {$storage_init_file}

    lmb_require('limb/cache2/src/lmbCacheFactory.class.php');
    \$cache = lmbCacheFactory::createConnection('{$this->dsn}');
    ob_end_clean();
    echo serialize(\$cache->{$method}('{$arguments_str}'));
EOD;
        file_put_contents($filename, $request_code);
        $response = shell_exec("php {$filename}");
        $result = unserialize($response);
        if (false === $result) {
            throw new lmbException("Can't parse response", array('response' => $response));
        } else {
            return $result;
        }
    }
Exemplo n.º 10
0
 * @copyright  Copyright &copy; 2004-2012 BIT(http://bit-creative.com)
 * @license    LGPL http://www.gnu.org/copyleft/lesser.html
 */
/**
 * @package web_app
 */
if (PHP_SAPI == 'cli') {
    lmb_env_setor('LIMB_HTTP_GATEWAY_PATH', '/');
    lmb_env_setor('LIMB_HTTP_SHARED_PATH', '/shared/');
    lmb_env_setor('LIMB_HTTP_OFFSET_PATH', '');
} else {
    $request = lmbToolkit::instance()->getRequest();
    if (!lmb_env_has('LIMB_HTTP_OFFSET_PATH')) {
        $offset = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
        if ($offset && $offset != '.') {
            lmb_env_setor('LIMB_HTTP_OFFSET_PATH', $offset . '/');
        } else {
            lmb_env_setor('LIMB_HTTP_OFFSET_PATH', '');
        }
    }
    if (substr(lmb_env_get('LIMB_HTTP_OFFSET_PATH'), 0, 1) == '/') {
        throw new lmbException('LIMB_HTTP_OFFSET_PATH constant must not have starting slash(' . lmb_env_get('LIMB_HTTP_OFFSET_PATH') . ')');
    }
    if (!lmb_env_has('LIMB_HTTP_GATEWAY_PATH')) {
        lmb_env_setor('LIMB_HTTP_GATEWAY_PATH', lmb_env_get('LIMB_HTTP_OFFSET_PATH') . '/');
    }
    lmb_env_setor('LIMB_HTTP_SHARED_PATH', lmb_env_get('LIMB_HTTP_OFFSET_PATH') . '/shared/');
    if (substr(lmb_env_get('LIMB_HTTP_SHARED_PATH'), -1, 1) != '/') {
        throw new lmbException('LIMB_HTTP_SHARED_PATH constant must have trailing slash(' . lmb_env_get('LIMB_HTTP_SHARED_PATH') . ')');
    }
}