예제 #1
0
파일: Atmjs.php 프로젝트: tianyunchong/php
 public static function import($path)
 {
     $pathConf = '/atmjs/work/';
     //路径兼容
     if (preg_match('/^([^:]+):([\\d]+\\.[\\d]+\\.[\\d]+)\\/exports\\/(.*)/', $path, $m)) {
         $path = $m[1] . '/' . $m[2] . ':' . $m[3];
     }
     self::$path = $path;
     // todo 原来id规则eg: m/buyer:1.0.0/exports/buyer
     // 修改后规则       : m/buyer/1.0.0:buyer
     // 处理方案:        : 需要在这里判断下,如果是原来的id格式则直接转换成新的规则
     if (preg_match('/^([^:]+):([\\d]+\\.[\\d]+\\.[\\d]+)/', $path, $m)) {
         $route = $m[1] . '/' . $m[2];
     } elseif (preg_match('/(.*[\\d]+\\.[\\d]+\\.[\\d]+):(.*)/', $path, $m)) {
         $route = $m[1];
     } else {
         return;
     }
     $datas = \Qconf::getConf($pathConf . $route, APP_ENV);
     if (!$datas) {
         return;
     }
     $datas = json_decode($datas, true);
     if (!isset($datas['settings']) || !isset($datas) || !isset($datas['maps']) || !isset($datas['maps'][$path])) {
         return;
     }
     self::$settings = $datas['settings'];
     self::$json = $datas['maps'][$path];
     // 获取domain
     self::setDomain();
     self::$status = true;
 }
예제 #2
0
파일: cate.php 프로젝트: tianyunchong/php
function getCateInfo($cateid = array(), $select = array('nav'))
{
    $rsArr = array();
    if (!is_array($cateid) || empty($cateid)) {
        return array();
    }
    //数据过滤
    $default = array('info', 'nav', 'childcate', 'attr', 'child');
    foreach ($select as $key => $value) {
        if (!in_array($value, $default)) {
            unset($select[$value]);
        }
    }
    foreach ($cateid as $key => $value) {
        $cateinfo = Qconf::getConf("/qconf/backcate/cateinfo/{$value}", APP_ENV, 0);
        $cateinfoArr = json_decode($cateinfo, true);
        foreach ($select as $k => $v) {
            $rsArr[$value][$v] = $cateinfoArr[$v];
        }
    }
    return $rsArr;
}
예제 #3
0
 public static function getHost()
 {
     $host = Qconf::getHost("dba/mysql/m3909");
     //        $host = "10.16.15.235:3306";
     return $host;
 }
예제 #4
0
<?php

require_once 'Qconf.php';
// path with qconf prefix
$paths = "__qconf_anchor_node";
var_dump(Qconf::getConf("__qconf_anchor_node"));
var_dump(Qconf::getBatchConf("__qconf_anchor_node"));
var_dump(Qconf::getBatchKeys("__qconf_anchor_node"));
var_dump(Qconf::getHost("__qconf_anchor_node"));
var_dump(Qconf::getAllHost("__qconf_anchor_node"));
// native path without qconf prefix
$native_path = "/qconf/__qconf_anchor_node";
var_dump(Qconf::getHostNative($native_path));
var_dump(Qconf::getAllHostNative($native_path));
예제 #5
0
 * 1. default get
 */
echo "1. defalut get: " . PHP_EOL;
$names = "__qconf_anchor_node";
var_dump(Qconf::getConf("__qconf_anchor_node"));
var_dump(Qconf::getHost("__qconf_anchor_node"));
var_dump(Qconf::getAllHost("__qconf_anchor_node"));
/**
 * 2. wait if there is no value in share memory
 */
$idc = null;
$flags = QconfConfig::QCONF_WAIT;
echo PHP_EOL . "2. wait if there is no value in share memory: " . PHP_EOL;
$names = "__qconf_anchor_node";
var_dump(Qconf::getHost("__qconf_anchor_node", $idc, $flags));
/**
 * 3. return immediately if there is no value in share memory
 */
$idc = null;
$flags = QconfConfig::QCONF_NOWAIT;
echo PHP_EOL . "3. return immediately if there is no value in share memory:" . PHP_EOL;
$names = "__qconf_anchor_node";
var_dump(Qconf::getHost("__qconf_anchor_node", $idc, $flags));
/**
 * 4. get with the path directly
 */
echo PHP_EOL . "4. get with the path directly: " . PHP_EOL;
$names = "/qconf/__qconf_anchor_node";
var_dump(Qconf::getHostNative("/qconf/__qconf_anchor_node"));
var_dump(Qconf::getAllHostNative("/qconf/__qconf_anchor_node"));