Пример #1
0
 /**
  * 记录日志内容
  * @param string $message 内容
  * @param int $logType 类型
  */
 static public function set($message, $logType)
 {
     if (DEBUG or !C("LOG_SAVE"))
         return;
     //获得日志类型
     $type = substr(FriendlyErrorType($logType), 2);
     if (in_array($type, array_change_value_case(C("LOG_TYPE"), 1))) {
         $date = date("y-m-d h:i:s");
         self::$log[] = $message . "\n";
     }
 }
Пример #2
0
 /**
  * 构造函数
  * @param string $path 上传路径
  * @param array $ext 允许的文件类型,传入数组如array('jpg','jpeg','png','doc')
  * @param array $size 允许上传大小,如array('jpg'=>200000,'rar'=>'39999') 如果不设置系统会依据配置项C("UPLOAD_EXT_SIZE")值
  */
 public function __construct($path = null, $ext = array(), $size = null)
 {
     $path = $path ? $path : C("UPLOAD_PATH");
     //上传路径
     $path = rtrim(str_replace('\\', '/', $path), '/') . '/';
     $this->path = str_replace(ROOT_PATH, '', $path);
     //上传类型
     $ext = $ext ? $ext : C("UPLOAD_ALLOW_TYPE");
     $this->ext = array_change_value_case($ext);
     //允许大小
     $this->size = $size ? $size : C("UPLOAD_ALLOW_SIZE");
 }
Пример #3
0
 /**
  * 获得角色所有节点
  * @param int $rid 角色ID,角色id如果传值将获得角色的所有权限信息
  * @return array
  */
 public static function getNodeList($rid = null)
 {
     $table = self::getRbacTable();
     //获得所有RBAC表
     $nodeTable = $table['RBAC_NODE_TABLE'];
     //节点表
     $accessTable = $table['access_table'];
     //权限表
     $where = $rid ? " WHERE rid ={$rid}" : "";
     $sql = "SELECT n.nid,n.name ,n.title,n.state,n.pid ,n.level, " . " a.rid AS rid FROM " . $nodeTable . " AS n " . "LEFT JOIN (select * from {$accessTable}  {$where}) AS a " . "ON n.nid = a.nid " . "ORDER BY n.level,n.sort ASC";
     $data = M()->query($sql);
     if (!$data) {
         return array();
     }
     $nodes = array();
     //组合后的节点
     foreach ($data as $n) {
         if ($n['level'] == 1) {
             $nodes[$n['nid']] = $n;
             $nodes[$n['nid']]['node'] = array();
             foreach ($data as $m) {
                 if ($n['nid'] == $m['pid']) {
                     $nodes[$n['nid']]['node'][$m['nid']] = $m;
                     $nodes[$n['nid']]['node'][$m['nid']]['node'] = array();
                     foreach ($data as $c) {
                         if ($m['nid'] == $c['pid']) {
                             $nodes[$n['nid']]['node'][$m['nid']]['node'][$c['nid']] = $c;
                         }
                     }
                 }
             }
         }
     }
     return array_change_key_case_d(array_change_value_case($nodes));
 }
Пример #4
0
 public function __construct($model)
 {
     $this->data_source = $model;
     if (array_key_exists('per_page', $this->data_source)) {
         $this->use_paginator = true;
         $this->fields = array_combine($this->data_source->items[0]->fields, $this->data_source->items[0]->fields);
         $this->headers = array_combine($this->data_source->items[0]->fields, array_change_value_case($this->data_source->items[0]->fields));
         $this->model = $this->data_source->items[0]->get_source();
     } else {
         $this->fields = array_combine($this->data_source[0]->fields, $this->data_source[0]->fields);
         $this->headers = array_combine($this->data_source[0]->fields, array_change_value_case($this->data_source[0]->fields));
         $this->model = $this->data_source[0]->get_source();
     }
 }
Пример #5
0
/**
 * 将数组中的值全部转为大写或小写
 * @param array $arr
 * @param int $type 类型 1值大写 0值小写
 * @return array
 */
function array_change_value_case($arr, $type = 0)
{
    $function = $type ? 'strtoupper' : 'strtolower';
    $newArr = array();
    //格式化后的数组
    foreach ($arr as $k => $v) {
        if (is_array($v)) {
            $newArr[$k] = array_change_value_case($v, $type);
        } else {
            $newArr[$k] = $function($v);
        }
    }
    return $newArr;
}
Пример #6
0
Файл: Boot.php Проект: jyht/v5
 public static function set($message, $logType)
 {
     $type = substr(FriendlyErrorType($logType), 2);
     if (in_array($type, array_change_value_case(C("LOG_TYPE"), 1))) {
         self::$log[] = $message . "\n";
     }
 }
Пример #7
0
/**
 * 验证扩展是否加载
 * @param string $ext
 * @return bool
 */
function extension_exists($ext)
{
    $ext = strtolower($ext);
    $loaded_extensions = get_loaded_extensions();
    return in_array($ext, array_change_value_case($loaded_extensions, 0));
}
Пример #8
0
/**
 * Changes all values of input to lower- or upper-case.
 *
 * @param array $input The array to change values in
 * @param int   $case  The case - can be either CASE_UPPER or CASE_LOWER (constants)
 *
 * @author Benjamin Carl <*****@*****.**>
 *
 * @return array The resulting (processed) array
 */
function array_change_value_case($input, $case = CASE_LOWER)
{
    $result = [];
    if (!is_array($input)) {
        return $result;
    }
    foreach ($input as $key => $value) {
        if (is_array($value)) {
            $result[$key] = array_change_value_case($value, $case);
            continue;
        }
        $result[$key] = $case == CASE_UPPER ? strtoupper($value) : strtolower($value);
    }
    return $result;
}