Example #1
0
 public function Adodb($clone = false)
 {
     static $mysql;
     if (is_object($mysql)) {
         return $clone ? clone $mysql : $mysql;
     }
     $cfg = parse_url(__CFG::MYSQL);
     if ($mdlClass = Import::M("mysql/{$cfg['scheme']}")) {
         list($cfg["dbname"], $cfg["tablepre"], $cfg["charset"]) = explode("/", trim($cfg["path"], "/"));
         $mysql = new $mdlClass($cfg["host"], $cfg["user"], $cfg["pass"], $cfg["dbname"], $cfg["port"]);
         $mysql->_tablepre = $this->_tablepre = $cfg["tablepre"];
         $this->db = $mysql;
         return $mysql;
     }
     return false;
 }
Example #2
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author @shzhrui<*****@*****.**>
 * $Id: view.mdl.php 3909 2014-03-17 03:08:57Z langzhong $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('member/base');
class Mdl_member_View extends Mdl_member_Base
{
    public function member($u, $l = 'uid')
    {
        $l = strtolower($l);
        switch ($l) {
            case 'uid':
                $field = 'uid';
                break;
            case 'name':
            case 'uname':
                $field = 'uname';
                break;
            case 'mail':
            case 'email':
                $field = 'mail';
                break;
            case 'mobile':
                $field = 'mobile';
Example #3
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author @shzhrui<*****@*****.**>
 * $Id: image.mdl.php 2034 2013-12-07 03:08:33Z langzhong $
 */
Import::M('image/gd');
class Mdl_Image_Image extends Model
{
    protected static $_oimg = null;
    public function __construct(&$system)
    {
        parent::__construct($system);
        self::$_oimg = new Mdl_Image_Image();
        self::$_oimg->params = $system->config->get('attach');
    }
    public function thumb()
    {
    }
}
Example #4
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author @shzhrui<*****@*****.**>
 * $Id: config.mdl.php 2034 2013-12-07 03:08:33Z langzhong $
 */
Import::M('developer/base');
class Mdl_Developer_Config extends Mdl_Developer_Base
{
    public function create_cfg($cfg)
    {
        if (empty($cfg['k'])) {
            $this->err->add('没有填写配置标识', 201);
        } else {
            if (K::$system->config->add($cfg['k'], $cfg['title'])) {
                if ($cfg['module_id']) {
                    //ctl,act,title,visible,parent_id,orderby
                    $ctl = array('ctl' => 'system/config', 'act' => $cfg['k'], 'visible' => 1);
                    $ctl['parent_id'] = $cfg['module_id'];
                    $ctl['title'] = $cfg['title'];
                    K::M('module/handler')->create($ctl);
                }
                return true;
            }
        }
        return false;
    }
    public function create_tmpl($cfg, $schema)
    {
Example #5
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author @shzhrui<*****@*****.**>
 * $Id: view.mdl.php 2444 2013-12-23 07:23:01Z langzhong $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('article/base');
class Mdl_article_View extends Mdl_article_Base
{
    public function detail($article_id, $closed = false)
    {
        if (!($article_id = intval($article_id))) {
            return false;
        }
        $where = "a.article_id='{$article_id}'";
        if ($closed) {
            $where .= " AND a.closed=0";
        }
        $sql = "SELECT c.*,a.* FROM " . $this->table($this->_table) . " a LEFT JOIN " . $this->table('article_content') . " c ON a.article_id=c.article_id WHERE {$where} LIMIT 1";
        if ($detail = $this->db->GetRow($sql)) {
            $cate = K::M('article/cate')->cate($detail['cat_id']);
            $detail['cat_title'] = $cate['title'];
        }
        return $detail;
    }
    public function up_item($article_id)
Example #6
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author shzhrui<*****@*****.**>
 * $Id: menu.mdl.php 2034 2013-12-07 03:08:33Z langzhong $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('module/base');
class Mdl_Module_Menu extends Mdl_Module_Base
{
    public function create($data, $checked = false)
    {
        if (!$checked && !($data = $this->_check($data))) {
            return false;
        }
        $data['orderby'] = $data['orderby'] ? $data['orderby'] : 50;
        $data['dateline'] = __CFG::TIME;
        if ($ID = $this->db->insert($this->_table, $data, true)) {
            $this->flush();
        }
        return $ID;
    }
    public function update($ID, $data, $checked = false)
    {
        if (!$checked && !($data = $this->_check($data, $ID))) {
            return false;
        }
Example #7
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author @shzhrui<*****@*****.**>
 * $Id: mdl.handler.php 2034 2013-12-07 03:08:33Z langzhong $
 */
Import::M('#base#/base');
class Mdl_
{
}
Example #8
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author @shzhrui<*****@*****.**>
 * $Id: handler.mdl.php 2034 2013-12-07 03:08:33Z langzhong $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('order/base');
class Mdl_order_Handler extends Mdl_order_Base
{
    public function create($data, $checked = false)
    {
        if (!$checked && !($data = $this->_check_schema($data))) {
            return false;
        }
        $data['clientip'] = $data['clientip'] ? $data['clientip'] : __IP;
        $data['dateline'] = $data['dateline'] ? $data['dateline'] : __CFG::TIME;
        return $this->db->insert($this->_table, $data, true);
    }
    public function update($pk, $data, $checked = false)
    {
        $this->_checkpk();
        if (!$checked && !($data = $this->_check_schema($data, $pk))) {
            return false;
        }
        return $this->db->update($this->_table, $data, $this->field($this->_pk, $pk));
    }
Example #9
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author shzhrui<*****@*****.**>
 * $Id: msgbox.mdl.php 2034 2013-12-07 03:08:33Z langzhong $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('helper/error');
class Mdl_Magic_Msgbox extends Mdl_Helper_Error
{
    public function response()
    {
        $request = K::$system->request;
        $objctl =& K::$system->objctl;
        if (!($tmpl = $objctl->tmpl)) {
            $tmpl = $objctl->pagedata['_OO_'];
        }
        if ($request['MINI'] == 'load') {
            if ($tmpl) {
                $objctl->output();
            } else {
                $this->show($request['referer'], 'HTML');
            }
        } else {
            if ($request['XREQ']) {
                if ($tmpl) {
                    $this->_data['html'] = $objctl->output(false);
Example #10
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author shzhrui<*****@*****.**>
 * $Id: mysql.mdl.php 3237 2014-02-11 03:36:35Z langzhong $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('mysql/safecheck');
class Mdl_Mysql_Mysql
{
    public $_QSQL = array();
    public $_ERR = array();
    public $cfg = array();
    public $_tablepre = '';
    public $link = null;
    public function __construct($host, $user, $passwd, $dbname = null, $port = 3306, $socket = null)
    {
        $this->cfg['host'] = $host;
        $this->cfg['user'] = $user;
        $this->cfg['passwd'] = $passwd;
        $this->cfg['dbname'] = $dbname;
        $this->cfg['port'] = $port;
        $this->cfg['socket'] = $socket;
    }
    public function connect()
    {
        if ($this->link === null) {
Example #11
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * Author shzhrui<*****@*****.**>
 * $Id: view.mdl.php 2034 2013-12-07 03:08:33Z langzhong $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('admin/base');
class Mdl_Admin_View extends Mdl_Admin_Base
{
    public function admin($id = 0, $name = '')
    {
        if ($id = intval($id)) {
            $where = "admin_id='{$id}'";
        } else {
            if ($name = trim($name)) {
                $where = "admin_name='{$name}'";
            } else {
                return false;
            }
        }
        return $this->db->GetRow("SELECT * FROM " . $this->table($this->_table) . " WHERE {$where}");
    }
    protected function _format_row($row)
    {
        if ($row['last_login']) {
            $row['format_last_login'] = date("Y-m-d H:i:s", $row['last_login']);
Example #12
0
<?php

/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * $Id: view.mdl.php 4407 2014-04-07 09:05:17Z youyi $
 */
if (!defined('__CORE_DIR')) {
    exit("Access Denied");
}
Import::M('home/main');
class Mdl_Home_View extends Mdl_Home_Main
{
    public function items($filter = array(), $orderby = null, $p = 1, $l = 20, &$count = 0)
    {
        if ($attrs = $filter['attrs']) {
            $attr_ids = join(',', $attrs);
            $attr_count = array_sum($attrs);
            $attr_sql = "SELECT home_id FROM " . $this->table('home_attr') . " WHERE attr_value_id IN({$attr_ids}) GROUP BY home_id HAVING SUM(attr_value_id)={$attr_count}";
        }
        unset($filter['attrs']);
        $where = $this->where($filter);
        if ($attr_sql) {
            $where .= " AND id IN({$attr_sql})";
        }
        $orderby = $this->order($orderby, null);
        $limit = $this->limit($p, $l);
        $items = array();
        $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM " . $this->table($this->_table) . "  WHERE {$where} {$orderby} {$limit}";
        if ($rs = $this->db->query($sql)) {
            while ($row = $rs->fetch()) {