static function index()
 {
     Sys::D('StoreVisitStatic');
     //        StoreVisitStaticModel::newAccessNum(1);
     //        $accessNum=StoreVisitStaticModel::getVisitedNum(1);
     //        Sys::D('StoreOrderStatic');
     //        $num= StoreOrderStaticModel::getDateOrderNum(1,'20150819');
     //
     //        var_dump($num);
     //        Sys::D('SysMessage');
     //        $msgData=SysMessageModel::getMsgList();
     //        Sys::D('UserAddress');
     //
     //        UserAddressModel::newAddress(1,'bee','18224087281','成都市高新区天府软件园D区6栋一楼232');
     //        UserAddressModel::disabledAddress(1);
     //
     //        $data= UserAddressModel::getList(1);
     //
     //        var_dump($data);
     //        Sys::D('AreaLnglat');
     //        $data= AreaLnglatModel::getLngLatByCode('340403');
     //        $data=AreaLnglatModel::getInfoByCode('510100');
     //        $address=AreaLnglatModel::decorateAddress('510100','510100','详细地址');
     //        var_dump($address);
     Sys::S('core.PhpExcel.PHPExcel.php');
     PHPExcel::init();
     $PHPExcel = PHPExcel::load();
 }
 public static function login($username, $psd)
 {
     $rs = Sys::M(self::$trueTableName)->select('*', '`username`=\'' . $username . '\'', 1);
     if ($rs) {
         if ($rs['password'] != md5($psd)) {
             if ($rs['login_err_times'] + 1 > self::MAX_LOGIN_ERROR_TIME) {
                 self::lockAccount($rs['id']);
             } else {
                 self::loginFail($rs['id']);
             }
             return self::MAX_LOGIN_ERROR_TIME - $rs['login_err_times'];
         }
         if (!$rs['status']) {
             return self::ACCOUNT_DISABLED;
         }
         /*判断是否已经被锁定*/
         if ($rs['last_login_time'] > NOW) {
             return self::ACCOUNT_LOCKED;
         } else {
             self::loginSuccess($rs['id']);
             Sys::D('GroupMember');
             $rs['group_id'] = GroupMemberModel::getGroupId($rs['id']);
             $_SESSION['userinfo'] = $rs;
             return self::LOGIN_SUCCESS;
         }
     } else {
         Sys::D('LoginFailLog');
         LoginFailLogModel::log($username, $psd);
         return self::LOGIN_FAIL;
     }
 }
 public function test()
 {
     Sys::D('Order');
     $goodsData = array(array(1, 3), array(2, 1));
     $receiveData = array('username' => 'bee', 'tel' => '18224087281', 'email' => '*****@*****.**', 'address' => '四川省成都市青羊区');
     OrderModel::add(1, 1, $goodsData, $receiveData, 'this is a remark');
 }
 static function verify()
 {
     $data = array('uname' => array(null, 'string', '', '用户名为空'), 'password' => array(null, 'length', array(4, 16), '密码错误'), 'checkcode' => array(null, 'string', '', '验证码为空'));
     Sys::S('core.Verify.Input');
     $data = Input::dataFilter($data, 'post');
     if (!isset($_SESSION['verify_code']) || strtoupper($data['checkcode']) != $_SESSION['verify_code']) {
         Error::halt(self::WRONG_CHECK_CODE, '验证码错误!');
     }
     $oUcenterMember = Sys::D('UcenterMember');
     $loginStatus = UcenterMemberModel::login($data['uname'], $data['password']);
     if ($loginStatus >= 10) {
         if ($loginStatus == 10) {
             Error::halt(UcenterMemberModel::LOGIN_SUCCESS, array('msg' => '登录成功', 'redirect' => DOMAIN . 'Index_index.jsp'));
         } else {
             if ($loginStatus == UcenterMemberModel::ACCOUNT_LOCKED) {
                 Error::halt($loginStatus, '账号已被锁定!');
             } else {
                 if ($loginStatus == UcenterMemberModel::ACCOUNT_DISABLED) {
                     Error::halt($loginStatus, '账号无效');
                 } else {
                     Error::halt($loginStatus, '用户名或密码错误');
                 }
             }
         }
     } else {
         $msg = $loginStatus <= 0 ? '您的账号已被锁定' : '登录失败,您还有' . $loginStatus . '次机会登录!';
         Error::halt($loginStatus, $msg);
     }
 }
 private static function getAuthInfo()
 {
     if (!isset($_SESSION['authority'])) {
         Sys::D('Group');
         $_SESSION['authority'] = GroupModel::getInheritRule($_SESSION['userinfo']['group_id']);
     }
     return true;
 }
 /**
  *  实例化驱动
  */
 private function setDriver($driver, $driver_config)
 {
     $this->uploader = Sys::D($driver);
     if ($this->uploader) {
         return $this->uploader->init($driver_config);
     } else {
         $this->error(10);
     }
 }
 static function getOrderGoodsInfo($goods_id)
 {
     $data = Sys::M(self::$trueTableName)->select('`logo`,`name`,`price`,`discount_price`', '`id`=' . $goods_id, 1);
     if (empty($data)) {
         $data = array('logo' => 0, 'name' => '', 'price' => 0, 'discount_price' => 0);
     }
     Sys::D('Image');
     $imgData = ImageModel::getImageInfo($data['logo']);
     return array_merge($data, $imgData);
 }
 /**
  * 获取菜单信息
  */
 public static function getMenu($listIds)
 {
     $menuData = array();
     $list = explode(',', $listIds);
     foreach ($list as $v) {
         $menuData[] = self::getInfo($v);
     }
     $treeData = Sys::D('Tree.tree')->getTreeData($menuData, 'id', 'pid');
     return self::getMenuDecorate($treeData);
 }
 /**
  * 获取table入口
  */
 public function getTable(&$data)
 {
     $tableArr = array();
     $this->id = $data['id'];
     $tableArr[] = '<table class="table dataTable no-footer" id="' . $this->id . '" role="grid" aria-describedby=' . $this->id . '"_info">';
     $tableArr[] = $this->getHeader($data['header']);
     $pageData = Sys::D('Page')->getPager($data['pageData']);
     $tableArr[] = $this->getBody($pageData['data'], $data['callback']);
     $tableArr[] = $this->getPager($pageData['paging']);
     return implode('', $tableArr);
 }
 public static function index()
 {
     Sys::D('AdminLoginLog');
     AdminLoginLogModel::log($_SESSION['userinfo']['id'], AdminLoginLogModel::LOGIN_OUT);
     if (isset($_SESSION['userinfo'])) {
         unset($_SESSION['userinfo']);
     }
     if (isset($_SESSION['authority'])) {
         unset($_SESSION['authority']);
     }
     Error::halt(SUCCESS, '登出成功!', './Login_index.jsp');
 }
 /**
  * 获取table入口
  */
 static function getTable(&$data)
 {
     self::init();
     $tableArr = array();
     self::$tableId = $data['id'];
     $pageData = Sys::D('Page')->getPager($data['pageData']);
     $tableArr[] = '<div class="paging_full_numbers">';
     $tableArr[] = '<table class="table dataTable no-footer" id="' . self::$tableId . '">';
     $tableArr[] = self::getHeader($pageData['paging'], $data['header']);
     $tableArr[] = self::getBody($pageData['data'], $data['callback']);
     $tableArr[] = '</table>';
     $tableArr[] = self::getPager($pageData['paging']);
     $tableArr[] = '</div>';
     return implode('', $tableArr);
 }
 public function modifyPassword()
 {
     Sys::S('core.Verify.Input');
     $data = array('src_password' => array(null, 'string', '', '原密码不能为空'), 'new_password' => array(null, 'string', '', '新密码不能为空'));
     $data = Input::dataFilter($data, 'post');
     if (md5($data['src_password']) != $_SESSION['userinfo']['password']) {
         Error::halt(FAIL, '原密码不正确');
     } else {
         if ($data['src_password'] == $data['new_password']) {
             Error::halt(FAIL, '新密码不能与原密码一致');
         } else {
             Sys::D('UcenterMember');
             UcenterMemberModel::savePassword($_SESSION['userinfo']['id'], $data['new_password']);
             Error::halt(SUCCESS, '操作成功');
         }
     }
 }
 public static function getInheritRule($group_id)
 {
     $rule_arr = array('rules' => array(), 'g_rules' => array());
     $group_info = array();
     $tmpRule = array();
     $group_info = self::getGroupInfo($group_id);
     $oAuthGroup = Sys::D('AuthGroup');
     do {
         $tmpRule = $oAuthGroup::getRuleByGroupId($group_id);
         $rule_arr['rules'][] = $tmpRule['rules'];
         $rule_arr['g_rules'][] = $tmpRule['g_rules'];
         $group_info = self::getGroupInfo($group_info['pid']);
     } while ($group_info && ($group_id = $group_info['id'] && $group_info['pid'] != 0 && $group_info['inherit']));
     //去除重复项
     $rule_arr['rules'] = array_unique(explode(',', implode(',', $rule_arr['rules'])));
     $rule_arr['g_rules'] = array_unique(explode(',', implode(',', $rule_arr['g_rules'])));
     return $rule_arr;
 }
 private static function saveGoodsInfo(&$goodsData, $orderNum)
 {
     Sys::D('StoreGoods');
     $data = array();
     $totalPrice = 0;
     $goodsTotalPrice = 0;
     $goodsInfo = array();
     foreach ($goodsData as $v) {
         $goodsInfo = StoreGoodsModel::getOrderGoodsInfo($v[0]);
         /*
          * goods_id goods_img  price discount_price count total_price name order_num
          * */
         $totalPrice = ($goodsInfo['discount_price'] > 0 ? $goodsInfo['discount_price'] : $goodsInfo['price']) * $v[1];
         $goodsTotalPrice += $totalPrice;
         $data[] = sprintf('(%s,\'%s\',%s,%s,%s,%s,\'%s\',\'%s\')', $v[0], $goodsInfo['url'], $goodsInfo['price'], $goodsInfo['discount_price'], $v[1], $totalPrice, $goodsInfo['name'], $orderNum);
     }
     Sys::D('OrderGoods');
     OrderGoodsModel::save($data);
     return $goodsTotalPrice;
 }
 static function index()
 {
     Sys::D('PathTrace');
     echo PathTraceModel::getTraceByUrl('user', 'test');
 }
    /**
     * [select description]
     * @param  [type] id名
     * @param  [type] 
     * $data=array(
     * 		array('值','标题'),
     * 		array('label描述','data-subject描述',
     * 			array(
     * 				array('值','标题'),
     * 				...
     * 			)
     * 		),
     * );
     * @param  boolean
     * @return [type]
     */
    public function getSelect($id, $data, $selIndex = 0, $disabled = false)
    {
        $relyData = array('js' => array('core.Bootstrap.Select.Bootstrap-select'), 'css' => array('core.Bootstrap.Select.Bootstrap-select-min'));
        $htmlArr = array();
        $this->selIndex = $selIndex;
        $htmlArr[] = '<select' . $this->ifDisabled($disabled) . ' id="' . $id . '" class="selectpicker bla bla bli" multiple data-live-search="true">';
        foreach ($data as $v) {
            if (isset($v[2]) && is_array($v[2])) {
                $htmlArr[] = $this->groupStrategy($v[0], $v[1], $v[2]);
            } else {
                $htmlArr[] = '<option' . $this->ifSelected($v[0]) . ' value="' . $v[0] . '">' . $v[1] . '</option>';
            }
        }
        $htmlArr[] = '</select>';
        $liveScripts = '$(window).on(\'load\', function () {
			
            $(\'.selectpicker\').selectpicker({
                //\'selectedText\': \'cat\'
            });

        });';
        Sys::D('LoadRely')->loadFile($relyData['css'], $relyData['js']);
        View::assign('liveScripts', array($liveScripts));
        return implode('', $htmlArr);
    }
 static function wordProcessing($val, $rule, $rule_detail, $memo = '')
 {
     $rule = strtolower($rule);
     $ret_val = '';
     switch ($rule) {
         case 'int':
             $ret_val = (int) $val;
             break;
         case 'string':
             $ret_val = addslashes($val);
             break;
         case 'double':
             $ret_val = (double) $val;
             break;
         case 'float':
             $ret_val = (double) $val;
             break;
         case 'regexp':
             $ret_val = self::regularExpression($val, $rule_detail);
             break;
         case 'regexp_defined':
             if (isset(self::$preg[$rule_detail])) {
                 $ret_val = self::regularExpression($val, self::$preg[$rule_detail]);
                 break;
             } else {
                 self::errorHandle('regexp not found : ' . $rule_detail);
             }
         case 'function':
             $ret_val = call_user_func($rule_detail, $val);
             break;
         case 'xss':
             $ret_val = Sys::D('Xss.Xss')->RemoveXSS($val);
             break;
         case 'unique':
             $flag = self::ifUnique($val, $rule_detail[0], $rule_detail[1]);
             $ret_val = $flag ? false : $val;
             break;
         case 'not_unique':
             $flag = self::ifUnique($val, $rule_detail[0], $rule_detail[1]);
             $ret_val = $flag ? $val : false;
             break;
         case 'length':
             $ret_val = self::lengthCheck($val, $rule_detail);
             break;
         case 'multi':
             $ret_val = self::multi($val, $rule_detail, $memo);
             break;
         case 'ignore':
             $ret_val = $val;
             break;
         default:
             $ret_val = addslashes($val);
             break;
     }
     if ($ret_val === false) {
         self::errorHandle($memo ? $memo : 'illegal data');
     }
     return $ret_val;
 }
 public function errorHandle($data)
 {
     if (defined('AJAX_REQUEST') && AJAX_REQUEST == 1) {
         Exception::redirect('error', $data, 5);
     } else {
         Sys::D('Return')->returnJson(FAIL, $data);
     }
 }