HEX
Server: Apache/2.4.6 (CentOS) PHP/5.6.39
System: Linux izj6c6ukj0hyugxsgmuxz3z 3.10.0-514.6.2.el7.x86_64 #1 SMP Thu Feb 23 03:04:39 UTC 2017 x86_64
User: root (0)
PHP: 5.6.39
Disabled: NONE
Upload Files
File: //web/data/www.tbbprovision.com/lib/Model.class.php
<?php

class Model extends Sql
{
    protected $_model;
    public function __construct()
    {
        // 连接数据库
        $this->connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
        
        // 获取模型类名
        $this->_model = get_class($this);

        // 删除类名最后的 Model 字符
        $this->_model = substr($this->_model, 0, -5);
        
        // 数据库表名与类名一致
        $this->_table= TABLE_PREFIX.'_'.strtolower($this->_model);
    }

    /**
     * 添加日志
     * @param $data
     */
    public function add_log($title,$ary=''){
        if(f::get_session('manage_user.user_name')=='admin'){
            return true;
        }
        $data['title'] = $title;
        $data['data'] = $this->array_to_text($ary);
        $data = str::str_code($data);
        $data['id']  =  f::get_session('manage_user.id');
        $data['acc_time'] = WEB_TIME;
        $data['url'] = $_SERVER['HTTP_REFERER'];
        $data['ip'] = f::get_ip();
        $this->table('manage_logs');
        $this->add($data);
    }

    private function array_to_text($row)
    {
        $html = '';
        ob_start();
        $this->array_to_text_ext($row);
        $html = ob_get_contents();
        ob_clean();
        return $html;
    }

    private function array_to_text_ext($row,$i=0){

        foreach ((array)$row as $k=>$item) {
            if(is_array($item)){
                $this->array_to_text_ext($item,$i+1);
            }else {
                echo "┣".str_repeat('━',$i)." {$k} : {$item}\r\n";
            }
        }
    }
}