Example #1
0
 public function index()
 {
     //banner
     $banner = oo::m('banner')->getall();
     $this->assign('banner', $banner);
     //获取最热
     $hot = db::getall("SELECT * FROM `product_hot` AS ph, `product` AS p WHERE ph.product_id=p.id AND ph.hot=1");
     $this->assign('hot', $hot);
     //获取分类下的最新
     $cate = oo::m('product_cate')->getall();
     foreach ($cate as $v) {
         $value = array('img' => $v['img'], 'id' => intval($v['id']));
         if ($v['name'] == '针织') {
             $catename = 'zz';
         } else {
             if ($v['name'] == '梭织') {
                 $catename = 'sz';
             }
         }
         $catearr[$catename] = array('img' => $v['img'], 'id' => $v['id']);
     }
     $list['zz']['img'] = $catearr['zz']['img'];
     $catearr['zz']['id'] && ($list['zz']['list'] = oo::m('product')->where(array('cateid' => $catearr['zz']['id']))->limit(8)->orderby('ctime desc')->getall());
     //最新针织
     $list['sz']['img'] = $catearr['sz']['img'];
     $catearr['sz']['id'] && ($list['sz']['list'] = oo::m('product')->where(array('cateid' => $catearr['sz']['id']))->limit(8)->orderby('ctime desc')->getall());
     //最新梭织
     $this->assign('list', $list);
     $this->display();
 }
Example #2
0
 public function _init()
 {
     parent::_init();
     $this->mongo = oo::cache('mongo');
     //自动填充
     $this->auto = array('select' => array('_sort' => array('ctime' => -1)), 'insert' => array('ctime' => time()), 'update' => array('mtime' => time()));
 }
Example #3
0
 function __init()
 {
     $token = $this->req('token');
     $_success = 1;
     if (ENV_PRO && !oo::base('token')->token_verify($token) && 'zhupp1988' != $this->req('debug')) {
         $this->json(self::$err['ILLEGAL']);
     }
 }
Example #4
0
 protected function after_post(&$data)
 {
     $hot = intval($data['hot']) ? 1 : 0;
     $sql = "INSERT INTO #table (`product_id`, `hot`) VALUES ({$this->id}, {$hot}) ON DUPLICATE KEY UPDATE `hot`={$hot}";
     oo::m('product_hot')->execute($sql);
     $sql = "INSERT INTO #table (`product_id`, `chengfen`, `fukuan`, `kezhong`, `yongtu`, `huohao`) VALUES \n\t\t({$this->id}, '{$data['chengfen']}', '{$data['fukuan']}', '{$data['kezhong']}', '{$data['yongtu']}', '{$data['huohao']}') \n\t\tON DUPLICATE KEY UPDATE `chengfen`='{$data['chengfen']}', `fukuan`='{$data['fukuan']}',\n\t\t`kezhong`='{$data['kezhong']}', `yongtu`='{$data['yongtu']}',`huohao`='{$data['huohao']}'";
     oo::m('product_detail')->execute($sql);
 }
Example #5
0
 public function index()
 {
     oo::c('list')->index();
     //控制器调度
     oo::m()->get();
     //模型调度
     $this->display(array('name' => 'zhupp'));
     //模板渲染
 }
Example #6
0
 protected function before_save(&$res)
 {
     //找到一级菜单
     $pids = oo::m('menu')->where(array('pid' => 0))->getall();
     $res['form']['pid']['list'][] = array('value' => 0, 'str' => '无');
     foreach ($pids as $v) {
         $res['form']['pid']['list'][] = array('value' => $v['id'], 'str' => $v['name']);
     }
     //var_dump($res);
 }
Example #7
0
 protected function _init()
 {
     $menuquery = oo::m('menu')->getall();
     foreach ($menuquery as $v) {
         if ($v['pid']) {
             $menu[$v['pid']]['children'][$v['route']] = $v['name'];
         } else {
             $menu[$v['id']]['name'] = $v['name'];
         }
     }
     $this->assign('menu', $menu);
     $this->_login();
 }
Example #8
0
 public function __construct()
 {
     parent::__construct();
     $menuquery = oo::m('menu')->getall();
     foreach ($menuquery as $v) {
         if ($v['pid']) {
             $menu[$v['pid']]['children'][$v['route']] = $v['name'];
         } else {
             $menu[$v['id']]['name'] = $v['name'];
         }
     }
     $this->assign('menu', $menu);
     $this->_login();
 }
Example #9
0
 public static function run()
 {
     self::$controller = $controller = !empty($_REQUEST['c']) ? strtolower($_REQUEST['c']) : DEFAULT_CONTROLLER;
     $ctl = oo::c();
     $resful = '_' . strtolower($_SERVER['REQUEST_METHOD']);
     if (($a = strtolower($_REQUEST['a'])) && method_exists($ctl, $a)) {
         $act = $a;
     } elseif (method_exists($ctl, $resful)) {
         $act = $resful;
     } elseif (method_exists($ctl, DEFAULT_ACTION)) {
         $act = DEFAULT_ACTION;
     } else {
         die('error action');
     }
     self::$action = $act;
     $ctl->{$act}();
     /**
      * 通用方法调度
      * 应付普通的增删改查功能
      * 表名和字段经过加密之后放到表单,这边会解析出来,加密的token在配置文件中设置
      */
     /*
     if(substr($act, 0, 2) == str_repeat(SEPARATOR, 2)){
     	//调度前执行before方法
     	$act_before = $act.SEPARATOR.BEFORE;
     	method_exists($ctl, $act_before) && $ctl->$act_before();
     	
     	list($func, $table) = explode(SEPARATOR, substr($act, 2));
     	if(in_array($func, array('insert', 'update', 'delete', 'select'))){
     		//根据表字段过滤请求参数
     		$m = Model::load($table);
     		//var_dump($m->columns);exit;
     		if(is_array($m->columns) && !empty($m->columns)){
     			foreach ($m->columns as $v){
     				if(isset($_REQUEST[$v['COLUMN_NAME']])){
     					$data[$v['COLUMN_NAME']] = $_REQUEST[$v['COLUMN_NAME']];
     				}
     			}
     		}
     		var_dump($data);
     		!empty($data) && $m->$func($data);
     	}
     	
     	//调度后执行after方法
     	$act_after = $act.SEPARATOR.AFTER;
     	method_exists($controller, $act_after) && $controller->$act_after($res);
     }
     */
 }
Example #10
0
 public function index()
 {
     $cid = $this->req('cid', 0, 'intval');
     $where = array();
     $cid && ($where = array('cateid' => $cid));
     $total = oo::m('product')->where($where)->count();
     $page = $this->req('page');
     pager::init($page, $total);
     $list = oo::m('product')->limit(pager::$start, pager::$num)->orderby('id desc')->where($where)->getall();
     $this->assign('list', $list);
     //推荐商家
     $seller = oo::m('seller')->limit(5)->getall();
     $this->assign('seller', $seller);
     $this->display('list');
 }
Example #11
0
 public function login()
 {
     $where['username'] = $this->req('username', '', 'trim');
     $password = $this->req('password', '', 'trim');
     $query = oo::m('admin')->where($where)->get();
     if (!$query) {
         $this->msg('账号错误');
     } else {
         if (md5($password . $query['salt']) == $query['password']) {
             $_SESSION['username'] = $query['username'];
             $this->redirect('index');
         } else {
             $this->msg('密码错误');
         }
     }
 }
Example #12
0
 public function index()
 {
     $id = $this->req('id', 0, 'intval');
     if (!$id) {
         $this->redirect('index');
     }
     $product = oo::m()->where(array('id' => $id))->get();
     if (empty($product)) {
         $this->redirect('index');
     }
     $product_detail = oo::m('product_detail')->where(array('product_id' => $id))->get();
     if (is_array($product_detail)) {
         $product = array_merge($product, $product_detail);
     }
     $res['product'] = $product;
     $res['seller'] = oo::m('seller')->where(array('id' => $product['sellerid']))->get();
     $this->assign('res', $res);
     $seller_products = oo::m()->where(array('sellerid' => $product['sellerid']))->orderby('id desc')->limit(5)->getall();
     $this->assign('seller_products', $seller_products);
     $this->display('product');
 }
Example #13
0
 /**
  * 动态加载
  * 
  */
 public function __call($c, $args)
 {
     if (in_array($c, array('get', 'update', 'delete', 'insert'))) {
         oo::base('controller_auto')->{$c}($args);
     }
 }
Example #14
0
 public function _init()
 {
     parent::_init();
     $this->mongo = oo::cache('mongo');
 }
Example #15
0
 public static function get($driver)
 {
     return oo::cfg('db.' . $driver);
 }
Example #16
0
 public function delete()
 {
     $msg = '删除失败';
     if ($this->id) {
         if (oo::m()->where(array('id' => $this->id))->delete()) {
             $msg = '删除成功';
         }
     }
     $this->assign('msg', $msg);
     $this->assign('url', NFS::url());
     $this->display('msg');
 }
Example #17
0
 public static function get($driver = '')
 {
     $name = empty($driver) ? 'db' : 'db.' . $driver;
     return oo::cfg($name);
 }
Example #18
0
 public function __call($name, $args)
 {
     $m = oo::m(NFS::$controller)->{$name}($args);
     p($m);
     //p($name, $args);
 }
Example #19
0
 public static function cfg($key, $value = null)
 {
     $apath = explode('.', $key);
     $filename = array_shift($apath);
     $env = ENV;
     if (!empty($env)) {
         if (file_exists(CONFIG_ROOT . $filename . '_' . $env . '.php')) {
             //不同环境不同配置
             $filename .= "_{$env}";
         }
     }
     $file = CONFIG_ROOT . $filename . '.php';
     $cfg = self::include_file($file);
     !is_array($cfg) && ($cfg = array());
     foreach ($apath as $v) {
         $k .= is_numeric($v) ? "[{$v}]" : "['{$v}']";
     }
     $res = null;
     if (is_null($value)) {
         eval("\$res = \$cfg{$k};");
     } else {
         eval("\$cfg{$k} = \$value;");
         $res = oo::base('file')->put($file, '<?php return ' . var_export($cfg, true) . ';');
     }
     return $res;
 }
Example #20
0
<?php

/**
 * 项目入口文件
 * 
 * 加载NFS初始化文件,加载配置、基类等等
 *
 */
header("charset=utf-8");
date_default_timezone_set('Asia/Shanghai');
if (false === strpos($_SERVER['SERVER_NAME'], 'local') && false === strpos($_SERVER['SERVER_NAME'], 'dev')) {
    define('ENV_PRO', 1);
    error_reporting(0);
    ini_set('display_errors', 'Off');
} else {
    define('ENV_PRO', 0);
    error_reporting(E_ALL ^ E_NOTICE);
}
define('APP_DIR', basename(dirname(__DIR__)));
define('APP_ROOT', dirname(dirname(__DIR__)) . '/');
require APP_ROOT . 'nfs/framework/nfs.php';
oo::base('file')->import(CONTROLLER_ROOT . 'base_c.php');
nfs::run();
Example #21
0
 protected function json($array)
 {
     return oo::base('request')->json($array, 'encode', 1);
 }