Example #1
0
 public function __construct()
 {
     parent::__construct();
     Tpl::setLayout('store_joinin_layout');
     $this->checkLogin();
     $model_seller = Model('seller');
     $seller_info = $model_seller->getSellerInfo(array('member_id' => $_SESSION['member_id']));
     if (!empty($seller_info)) {
         @header('location: index.php?act=seller_login');
     }
     if ($_GET['op'] != 'check_seller_name_exist' && $_GET['op'] != 'checkname') {
         $this->check_joinin_state();
     }
     $phone_array = explode(',', C('site_phone'));
     Tpl::output('phone_array', $phone_array);
     $model_help = Model('help');
     $condition = array();
     $condition['type_id'] = '99';
     //默认显示入驻流程;
     $list = $model_help->getShowStoreHelpList($condition);
     Tpl::output('list', $list);
     //左侧帮助类型及帮助
     Tpl::output('show_sign', 'joinin');
     Tpl::output('html_title', C('site_name') . ' - ' . '商家入驻');
     Tpl::output('article_list', '');
     //底部不显示文章分类
 }
 /**
  * 后台菜单首页
  * @return none
  */
 public function index()
 {
     $pid = I('get.pid', 0);
     if ($pid) {
         $data = D('Menu')->where("id={$pid}")->field(true)->find();
         $this->assign('data', $data);
     }
     $title = trim(I('get.title'));
     $type = C('CONFIG_GROUP_LIST');
     $all_menu = D('Menu')->getField('id,title');
     $map['pid'] = $pid;
     if ($title) {
         $map['title'] = array('like', "%{$title}%");
     }
     $list = D("Menu")->where($map)->field(true)->order('sort asc,id asc')->select();
     int_to_string($list, array('hide' => array(1 => L('_YES_'), 0 => L('_NOT_')), 'is_dev' => array(1 => L('_YES_'), 0 => L('_NOT_'))));
     if ($list) {
         foreach ($list as &$key) {
             if ($key['pid']) {
                 $key['up_title'] = $all_menu[$key['pid']];
             }
         }
         $this->assign('list', $list);
     }
     // 记录当前列表页的cookie
     Cookie('__forward__', $_SERVER['REQUEST_URI']);
     $this->meta_title = L('_MENU_LIST_');
     $this->display();
 }
 /**
  * 我的兑换 do_personal_index
  */
 public function do_personal_index()
 {
     /* 初始化变量 */
     $user_id = I('get.user_id');
     $page_num = I('get.page_num');
     $page_num = empty($page_num) || $page_num < 0 ? 1 : $page_num;
     /* 查询条件 */
     $field = 'pay_order.trade_no,pay_order.shop_coupon_info,pay_order.shop_id,pay_order.trade_state,shop.title as shop_title';
     $where['pay_order.user_id'] = array('EQ', $user_id);
     $where['pay_order.display'] = array('EQ', 1);
     $order = 'pay_order.id desc';
     /* 查询数据 */
     $list = $this->alias('pay_order')->field($field)->where($where)->join('LEFT JOIN __SHOP__ shop on pay_order.shop_id = shop.id')->order($order)->limit(C('PAGE_NUM'))->page($page_num)->select();
     foreach ($list as $k => $v) {
         $shop_coupon_info = json_decode($v['shop_coupon_info'], true);
         $list[$k]['coupon_id'] = $shop_coupon_info['id'];
         $list[$k]['coupon_title'] = $shop_coupon_info['title'];
         if ($shop_coupon_info['coupon_type'] == 1) {
             $list[$k]['coupon_tag'] = strval(0);
         } else {
             $list[$k]['coupon_tag'] = $shop_coupon_info['coupon_worth'];
         }
         $list[$k]['coupon_content'] = $shop_coupon_info['content'];
         unset($list[$k]['shop_coupon_info']);
         /* 过滤数据 */
         if (!empty($v['coupon_title'])) {
             $list[$k]['coupon_title'] = htmlspecialchars_decode($v['coupon_title']);
         }
     }
     /* 读取json */
     $list = empty($list) ? array() : $list;
     $jsonInfo['list'] = arr_content_replace($list);
     return $jsonInfo;
 }
 public function test_newslist()
 {
     $urlbase = C("HTTP_HOST") . "/app/movie/newslist";
     //验证用户ID
     $this->assert_is_true(send_get_success($urlbase));
     //id为空
     $this->assert(40002, send_get($urlbase . "?id=d")->errcode);
     //id非整数
     $this->assert_is_true(send_get_success($urlbase . "?id=1"));
     //id为整数
     //验证mfields字符串
     $this->assert(40099, send_get($urlbase . "?mfields=id,name22,alias")->errcode);
     $this->assert(40099, send_get($urlbase . "?id=1&mfields=id,name22,alias")->errcode);
     $this->assert_is_true(send_get_success($urlbase . "?id=1&mfields=id,alias"));
     $this->assert_is_true(send_get_success($urlbase . "?id=1&mfields=id,mname,alias"));
     //验证nfields字符串
     $this->assert(40099, send_get($urlbase . "?id=1&nfields=id,title22,content")->errcode);
     $this->assert_is_true(send_get_success($urlbase . "?id=1&nfields=id,content"));
     $this->assert_is_true(send_get_success($urlbase . "?id=1&nfields=id,title,content"));
     //验证分页
     $this->assert(40002, send_get($urlbase . '?pager={"limit":2,dd"page":1,"order":"id desc"}')->errcode);
     //pager参数不合法
     //$this->assert(40002,send_get($urlbase.'?pager={"limit":2,dd"page":1,"order":"id desc"}')->errcode);//pager参数排序不合法
     $this->assert_is_true(send_get_success($urlbase . '?pager={"limit":2,"page":1,"order":"id%20desc"}'));
     //合法的pager
 }
Example #5
0
 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         $conn = $this->pconnect ? 'mysql_pconnect' : 'mysql_connect';
         $this->linkID[$linkNum] = $conn($config['hostname'] . ':' . $config['hostport'], $config['username'], $config['password']);
         if (!$this->linkID[$linkNum]) {
             throw_exception(mysql_error());
             return False;
         }
         if (!mysql_select_db($config['database'], $this->linkID[$linkNum])) {
             throw_exception($this->error());
             return False;
         }
         $this->dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($this->dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
Example #6
0
 function __construct()
 {
     $this->APPID = C('APPID');
     $this->SECRET = C('APPSECRET');
     $this->api_url = C('WEIXIN_API_URL');
     $this->access_token = $this->getToken();
 }
 public function co_star_edit()
 {
     if ($_POST['submit'] and $_POST['index'] != "") {
         $Stars = M('Co_stars');
         $index = $_POST['index'];
         $star = $Stars->where('photo_index=' . $index)->find();
         if ($_POST['title'] != "") {
             $data['photo_title'] = $_POST['title'];
         }
         $tmp_name = $_FILES['upfile']['tmp_name'];
         $file = $_FILES["upfile"];
         //上傳文件名稱
         //C('__PUBLIC__')爲 /Quanquan/Public
         move_uploaded_file($tmp_name, 'Public/WebResources/co_star/' . $file['name']);
         //將上傳文件移動到指定目錄待解壓
         if ($file['name']) {
             unlink($star['photo_url']);
             $data['photo_url'] = C('__PUBLIC__') . '/WebResources/co_star/' . $file['name'];
         }
         if ($Stars->where('photo_index=' . $index)->save($data)) {
             echo '修改成功';
         } else {
             echo $star['photo_url'];
         }
     } else {
         echo '未輸入數據';
     }
     $this->display();
 }
 public function index()
 {
     $sysinfo = M('sys')->order('id asc')->find();
     $this->assign('sys', $sysinfo);
     $appid = $sysinfo['web_appid'];
     $appsecret = $sysinfo['web_appsecret'];
     if (!defined('VIRIFY')) {
         virifylocal();
     }
     $_scene = M('scene');
     $where['scenecode_varchar'] = I('get.id', 0);
     $where['delete_int'] = 0;
     $_scene_list = $_scene->where($where)->select();
     // print_r($_scene_list); exit('dddd');
     $sysinfo = M('sys')->order('id asc')->find();
     if ($sysinfo['is_user_anli_shenghe'] && !isset($_GET['preview'])) {
         if ($_scene_list[0]["shenhe"] != 1) {
             $this->error('抱歉,您的场景还没通过管理员审核', '/#/main');
         }
     }
     $argu2 = array();
     $argu2['title'] = $_scene_list[0]["scenename_varchar"];
     $argu2['url'] = C('IS_OPEN_STATIC') ? 'v-' . $_scene_list[0]["scenecode_varchar"] : 'index.php?c=view&id=' . $_scene_list[0]["scenecode_varchar"];
     $argu2['desc'] = $_scene_list[0]["desc_varchar"];
     $argu2['imgsrc'] = $_scene_list[0]["thumbnail_varchar"];
     $this->assign("confinfo2", $argu2);
     $mydd = get_client_ip();
     if ($mydd !== '127.0.0.1') {
         $confinfo = $this->get_js_sdk($appid, $appsecret);
     }
     $this->assign("confinfo", $confinfo);
     $this->display(HTML_VESION);
 }
Example #9
0
 public function get_run_link($id)
 {
     static $des;
     $des = empty($des) ? new \Common\ORG\DES(C('API_DATA_CRYPT_KEY')) : $des;
     $item = $this->find($id);
     $item_data = $this->get_item_data($id, true);
     $service_db = D('Service');
     $service = $service_db->find($item['sid']);
     $item_data_field = array_keys($item_data);
     foreach ($item_data_field as $key => $var) {
         $item_data_field[$key] = '{' . $var . '}';
     }
     $item_data_value = array_values($item_data);
     $service_db = D('Service');
     $service = $service_db->find($item['sid']);
     $environment_db = D('Environment');
     $eid = $environment_db->get_current_environment();
     $link = [];
     $link_tpl = '[protocol]://[type]/[path](des)/[parameter](des)/[attach](des)/';
     $replace['[protocol]'] = C('API_PROTOCOL');
     $replace['[type]'] = $service['protocol'];
     $replace['[path](des)'] = '';
     $replace['[parameter](des)'] = '';
     $replace['[attach](des)'] = '';
     $soft = D('Soft')->get_soft($item['sid'], $eid);
     foreach ($soft as $var) {
         $replace['[parameter](des)'] = $des->encrypt(str_replace($item_data_field, $item_data_value, $var['tpl']));
         $replace['[path](des)'] = $des->encrypt($var['path']);
         $replace['[attach](des)'] = $des->encrypt('pathid-' . $var['pathid'] . ',item-' . $item['id'] . ',user-' . session("admin_username"));
         $link[] = array('name' => $var['name'], 'link' => str_replace(array_keys($replace), array_values($replace), $link_tpl));
     }
     return $link;
 }
Example #10
0
 protected function isLogin()
 {
     if (empty($_SESSION[APP_NAME . '_USERINFO'])) {
         /* session 不存在,检查cookie */
         if (!empty($_COOKIE['ECTOUCHCP']['ADMIN_ID']) && !empty($_COOKIE['ECTOUCHCP']['ADMIN_PWD'])) {
             // 找到了cookie, 验证cookie信息
             $condition['user_id'] = intval($_COOKIE['ECTOUCHCP']['ADMIN_ID']);
             $userInfo = $this->model->table('admin_user')->field('user_id, user_name, password, email, last_login, ec_salt')->where($condition)->find();
             if (empty($userInfo)) {
                 // 没有找到这个记录
                 setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
                 setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
                 return false;
             } else {
                 // 检查密码是否正确
                 if (md5(md5($userInfo['user_id'] . $userInfo['user_name']) . C('hash_code')) == $_COOKIE['ECTOUCHCP']['ADMIN_PWD']) {
                     $this->setLogin($userInfo);
                     $data['last_login'] = gmtime();
                     $data['last_ip'] = get_client_ip();
                     $this->model->table('admin_user')->data($data)->where($condition)->update();
                     $this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
                     return true;
                 } else {
                     setcookie($_COOKIE['ECTOUCHCP']['ADMIN_ID'], '', 1);
                     setcookie($_COOKIE['ECTOUCHCP']['ADMIN_PWD'], '', 1);
                     return false;
                 }
             }
         }
         return false;
     } else {
         $this->userInfo = $_SESSION[APP_NAME . '_USERINFO'];
         return true;
     }
 }
 public function index()
 {
     if (!session('openid_' . $this->token)) {
         $this->info = M('wxuser')->where(array('token' => $this->token))->find();
         vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor');
         vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor');
         $wechat = new Wechat();
         $wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret']));
         $redirect_uri = C('site_url') . '/index.php/Wap/Coupons/index?token=' . $this->token . '&coupon_id=' . $this->coupon_id;
         if (!$_GET['code']) {
             // By sending no options it'll come back here
             $url = $wechat->authorize(array('redirect_uri' => $redirect_uri));
             redirect($url);
         } else {
             try {
                 // Have a go at creating an access token from the code
                 $token = $wechat->access($_GET['code'], array('redirect_uri' => $redirect_uri));
                 // Use this object to try and get some user details (username, full name, etc)
                 $user = $wechat->get_user_info($token);
                 $this->openid = $user->openid;
                 session('openid_' . $this->token, $user->openid);
             } catch (OAuth2_Exception $e) {
                 print_r($e);
                 die;
             }
         }
     } else {
         $this->openid = session('openid_' . $this->token);
     }
     $url = C('site_url') . "/index.php?g=Wap&m=Coupon&a=index&type=1&token=" . $this->token . '&id=' . $this->coupon_id . '&wecha_id=' . $this->openid;
     header('Location:' . $url);
 }
Example #12
0
 public static function factory($options)
 {
     $options = is_array($options) ? $options : array();
     //只实例化一个对象
     if (is_null(self::$cacheFactory)) {
         self::$cacheFactory = new cacheFactory();
     }
     $driver = isset($options['driver']) ? $options['driver'] : C("CACHE_TYPE");
     //静态缓存实例名称
     $driverName = md5_s($options);
     //对象实例存在
     if (isset(self::$cacheFactory->cacheList[$driverName])) {
         return self::$cacheFactory->cacheList[$driverName];
     }
     $class = 'Cache' . ucwords(strtolower($driver));
     //缓存驱动
     $classFile = YY_PATH . 'Cache/' . $class . '.class.php';
     //加载驱动类库文件
     if (!require_array($classFile)) {
         halt("缓存类型指定错误,不存在缓存驱动文件:" . $classFile);
     }
     $cacheObj = new $class($options);
     self::$cacheFactory->cacheList[$driverName] = $cacheObj;
     return self::$cacheFactory->cacheList[$driverName];
 }
Example #13
0
 /**
  * 上传图片
  */
 public function uploadPic()
 {
     $config = array('maxSize' => 0, 'exts' => array('jpg', 'png', 'gif', 'jpeg'), 'rootPath' => './Upload/', 'driver' => 'LOCAL', 'subName' => array('date', 'Y-m'), 'savePath' => I('dir', 'uploads') . "/");
     $upload = new \Think\Upload($config);
     $rs = $upload->upload($_FILES);
     if (!$rs) {
         $this->error($upload->getError());
     } else {
         $images = new \Think\Image();
         $images->open('./Upload/' . $rs['Filedata']['savepath'] . $rs['Filedata']['savename']);
         $newsavename = str_replace('.', '_thumb.', $rs['Filedata']['savename']);
         $vv = $images->thumb(I('width', 300), I('height', 300), I('thumb_type', 1))->save('./Upload/' . $rs['Filedata']['savepath'] . $newsavename);
         if (C('RTC_M_IMG_SUFFIX') != '') {
             $msuffix = C('RTC_M_IMG_SUFFIX');
             $mnewsavename = str_replace('.', $msuffix . '.', $rs[$Filedata]['savename']);
             $mnewsavename_thmb = str_replace('.', "_thumb" . $msuffix . '.', $rs[$Filedata]['savename']);
             $images->open('./Upload/' . $rs[$Filedata]['savepath'] . $rs[$Filedata]['savename']);
             $images->thumb(I('width', 700), I('height', 700))->save('./Upload/' . $rs[$Filedata]['savepath'] . $mnewsavename);
             $images->thumb(I('width', 250), I('height', 250))->save('./Upload/' . $rs[$Filedata]['savepath'] . $mnewsavename_thmb);
         }
         $rs['Filedata']['savepath'] = "Upload/" . $rs['Filedata']['savepath'];
         $rs['Filedata']['savethumbname'] = $newsavename;
         $rs['status'] = 1;
         echo json_encode($rs);
     }
 }
 public function register($username = '', $password = '', $repassword = '', $email = '', $verify = '')
 {
     if (!C('USER_ALLOW_REGISTER')) {
         $this->error('注册已关闭');
     }
     if (IS_POST) {
         //注册用户
         /* 检测验证码 */
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         /* 检测密码 */
         if ($password != $repassword) {
             $this->error('密码和重复密码不一致!');
         }
         /* 调用注册接口注册用户 */
         $User = new UserApi();
         $uid = $User->register($username, $password, $email);
         if (0 < $uid) {
             //注册成功
             //TODO: 发送验证邮件
             $this->success('注册成功!', U('login'));
         } else {
             //注册失败,显示错误信息
             $this->error($this->showRegError($uid));
         }
     } else {
         //显示注册表单
         $this->display();
     }
 }
Example #15
0
 public function insert()
 {
     C('TOKEN_ON', false);
     $db = D('Call');
     $where['uid'] = $_SESSION['uid'];
     $where['token'] = $_SESSION['token'];
     $res = $db->where($where)->find();
     if ($res == false) {
         $where['phone_account'] = $this->_post('phone_account', 'trim');
         if (isset($_POST['phone_password'])) {
             $where['phone_password'] = $this->_post('phone_password', 'trim');
         }
         if ($where['phone_account'] == false) {
             $this->error('标题必须填写');
         }
         $id = $db->data($where)->add();
         if ($id) {
             $this->success('添加成功', U('Call/index'));
         } else {
             $this->error('添加失败', U('Call/index'));
         }
     } else {
         $where['id'] = $res['id'];
         $where['phone_account'] = $this->_post('phone_account', 'trim');
         if (isset($_POST['phone_password'])) {
             $where['phone_password'] = $this->_post('phone_password', 'trim');
         }
         if ($db->save($where)) {
             $this->success('更新成功', U('Call/index'));
         } else {
             $this->error('更新失败', U('Call/index'));
         }
     }
 }
 function _thumb_media_id($cover_id)
 {
     $cover = get_cover($cover_id);
     $driver = C('PICTURE_UPLOAD_DRIVER');
     if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
         // 先把图片下载到本地
         $pathinfo = pathinfo(SITE_PATH . $cover['path']);
         mkdirs($pathinfo['dirname']);
         $content = wp_file_get_contents($cover['url']);
         $res = file_put_contents(SITE_PATH . $cover['path'], $content);
         if ($res) {
             return '';
         }
     }
     $path = $cover['path'];
     if (!$path) {
         return '';
     }
     $param['type'] = 'thumb';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         return '';
     }
     $map['cover_id'] = $cover_id;
     $map['manager_id'] = $this->mid;
     $this->where($map)->setField('thumb_media_id', $res['media_id']);
     return $res['media_id'];
 }
 /**
  * 收藏列表
  */
 public function favorites_listOp()
 {
     $model_favorites = Model('favorites');
     $model_store = Model('store');
     $favorites_list = $model_favorites->getStoreFavoritesList(array('member_id' => $this->member_info['member_id']), '*', $this->page);
     $page_count = $model_favorites->gettotalpage();
     $store_list = array();
     $favorites_list_indexed = array();
     foreach ($favorites_list as $v) {
         $item = array();
         $item['store_id'] = $v['store_id'];
         $item['store_name'] = $v['store_name'];
         $item['fav_time'] = $v['fav_time'];
         $item['fav_time_text'] = date('Y-m-d H:i', $v['fav_time']);
         $store = $model_store->getStoreInfoByID($v['store_id']);
         $item['goods_count'] = $store['goods_count'];
         $item['store_collect'] = $store['store_collect'];
         $item['store_avatar'] = $store['store_avatar'];
         if ($store['store_avatar']) {
             $item['store_avatar_url'] = UPLOAD_SITE_URL . '/' . ATTACH_STORE . '/' . $store['store_avatar'];
         } else {
             $item['store_avatar_url'] = UPLOAD_SITE_URL . '/' . ATTACH_COMMON . DS . C('default_store_avatar');
         }
         $store_list[] = $item;
     }
     output_data(array('favorites_list' => $store_list), mobile_page($page_count));
 }
 public function index()
 {
     C('SHOW_RUN_TIME', false);
     // 运行时间显示
     C('SHOW_PAGE_TRACE', false);
     $this->display();
 }
Example #19
0
 public function indexOp()
 {
     //查询会员及其附属信息
     $result = parent::pointshopMInfo(true);
     $member_info = $result['member_info'];
     unset($result);
     $model_member = Model('member');
     //获得会员升级进度
     $membergrade_arr = $model_member->getMemberGradeArr(true, $member_info['member_exppoints'], $member_info['level']);
     Tpl::output('membergrade_arr', $membergrade_arr);
     //处理经验值计算说明文字
     $exppoints_rule = C("exppoints_rule") ? unserialize(C("exppoints_rule")) : array();
     $ruleexplain_arr = array();
     $exppoints_rule['exp_orderrate'] = floatval($exppoints_rule['exp_orderrate']);
     if ($exppoints_rule['exp_orderrate'] > 0) {
         $ruleexplain_arr['exp_order'] = "经验值以有效购物金额作为计算标准,有效购物金额{$exppoints_rule['exp_orderrate']}元=1经验值;";
         $exp_ordermax = intval($exppoints_rule['exp_ordermax']);
         if ($exp_ordermax > 0) {
             $ruleexplain_arr['exp_order'] .= "单个订单最多获得{$exppoints_rule['exp_ordermax']}经验值;";
         }
     }
     $exppoints_rule['exp_login'] = intval($exppoints_rule['exp_login']);
     if ($exppoints_rule['exp_login'] > 0) {
         $ruleexplain_arr['exp_login'] = "******";
     }
     $exppoints_rule['exp_comments'] = intval($exppoints_rule['exp_comments']);
     if ($exppoints_rule['exp_comments'] > 0) {
         $ruleexplain_arr['exp_comments'] = "进行一次订单商品评价将获得{$exppoints_rule['exp_comments']}经验值;";
     }
     Tpl::output('ruleexplain_arr', $ruleexplain_arr);
     //分类导航
     $nav_link = array(0 => array('title' => L('homepage'), 'link' => SHOP_SITE_URL), 1 => array('title' => L('nc_pointprod'), 'link' => urlShop('pointshop', 'index')), 2 => array('title' => '我的成长进度'));
     Tpl::output('nav_link_list', $nav_link);
     Tpl::showpage('pointgrade');
 }
 public function fix()
 {
     $order_id = 0;
     while ($order_id < 70000) {
         $order_id += 1;
         $order = $this->MOrder->get_one('deal_price', array('id' => $order_id));
         $deal_price = $order['deal_price'];
         if (!empty($deal_price)) {
             continue;
         }
         $complete_flag = TRUE;
         $suborders = $this->MSuborder->get_lists('deal_price, status', array('order_id' => $order_id));
         $complete_arr = array(C('order.status.success.code'), C('order.status.closed.code'), C('order.status.sales_return.code'));
         $deal_price_total = 0;
         foreach ($suborders as $suborder) {
             //    echo $suborder['deal_price'] . "\t";
             $deal_price_total += $suborder['deal_price'];
             if (!in_array($suborder['status'], $complete_arr)) {
                 $complete_flag = FALSE;
             }
         }
         //echo "\n";
         if ($complete_flag) {
             $this->MOrder->update_info(array('deal_price' => $deal_price_total), array('id' => $order_id));
             print_r($this->db->last_query());
             echo "\r\n";
         }
     }
 }
Example #21
0
 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '');
         if ($this->pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect($host, $config['username'], $config['password'], CLIENT_MULTI_RESULTS);
         } else {
             $this->linkID[$linkNum] = mysql_connect($host, $config['username'], $config['password'], true, CLIENT_MULTI_RESULTS);
         }
         if (!$this->linkID[$linkNum] || !empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) {
             throw_exception(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         if ($dbVersion >= "4.1") {
             //使用UTF8存取数据库 需要mysql 4.1.0以上支持
             mysql_query("SET NAMES '" . C('DB_CHARSET') . "'", $this->linkID[$linkNum]);
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             mysql_query("SET sql_mode=''", $this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected = true;
         // 注销数据库连接配置信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
Example #22
0
 /**
 +----------------------------------------------------------
 * 连接数据库方法
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($config = '', $linkNum = 0)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         $this->linkID[$linkNum] = new mysqli($config['hostname'], $config['username'], $config['password'], $config['database'], $config['hostport']);
         if (mysqli_connect_errno()) {
             throw_exception(mysqli_connect_error());
         }
         $dbVersion = $this->linkID[$linkNum]->server_version;
         if ($dbVersion >= "4.1") {
             // 设置数据库编码 需要mysql 4.1.0以上支持
             $this->linkID[$linkNum]->query("SET NAMES '" . C('DB_CHARSET') . "'");
         }
         //设置 sql_model
         if ($dbVersion > '5.0.1') {
             $this->linkID[$linkNum]->query("SET sql_mode=''");
         }
         // 标记连接成功
         $this->connected = true;
         //注销数据库安全信息
         if (1 != C('DB_DEPLOY_TYPE')) {
             unset($this->config);
         }
     }
     return $this->linkID[$linkNum];
 }
 public function index()
 {
     $data = I('post.');
     if (!empty($data['username']) && !empty($data['password']) && !empty($data['verify'])) {
         if ($this->Verify->check($data['verify'])) {
             $user = M('user');
             $userdata = $user->where("username='******' and state=0", $data['username'])->find();
             if ($userdata && $userdata['password'] === md5(C('SECURE_CODE') . md5($data['password']))) {
                 unset($userdata['password']);
                 $userdata['ip'] = get_client_ip();
                 $user->where('id=' . $userdata['id'])->save(array('logintime' => time()));
                 $user_auth = json_encode($userdata);
                 $user_auth_cookie = authcode($user_auth, ENCODE);
                 cookie('auth', $user_auth_cookie, 3600);
                 $this->success('登陆成功', U('index/index'));
                 exit;
             } else {
                 $this->error("用户名或密码错误");
             }
         } else {
             $this->error("验证码填写错误");
         }
     }
     $this->display();
 }
 /**
  * [contentManage 文章内容列表页]
  * @return [type] [description]
  */
 public function index()
 {
     $arr = I();
     $table = M('article');
     $articleCategory = M('article_category');
     $where = array('is_del' => 0);
     if ($arr['search']) {
         $where['title'] = array('like', "%" . $arr['search'] . "%");
     }
     if ($arr['categoryid']) {
         $where['category_id'] = $arr['categoryid'];
     }
     $articleCategorys = $articleCategory->select();
     $count = $table->where($where)->count();
     $pagesize = C('BACKEND_PAGESIZE');
     $page = getpage($count, $pagesize);
     $result = $table->where($where)->order('createtime desc')->limit($page->firstRow . ',' . $page->listRows)->select();
     foreach ($result as $key => $value) {
         $category = $articleCategory->where(array('id' => $value['category_id']))->find();
         $result[$key]['categoryName'] = $category['name'];
     }
     $nowPage = $arr['p'] && $arr['p'] > 1 ? $arr['p'] : 1;
     $totalSize = $count;
     $totalPage = ceil($count / $pagesize);
     $this->assign('page', $page->show());
     $this->assign('search', $arr['search']);
     $this->assign('categoryid', $arr['categoryid']);
     $this->assign('categorys', $articleCategorys);
     $this->assign('nowPage', $nowPage);
     $this->assign('result', $result);
     // 赋值数据集
     $this->assign('totalSize', $totalSize);
     $this->assign('totalPage', $totalPage);
     $this->display();
 }
 /**
  * 文档保存成功后执行行为
  * @param  array  $data     文档数据
  * @param  array  $catecory 分类数据
  */
 public function documentSaveComplete($param)
 {
     if (MODULE_NAME == 'Home') {
         list($data, $category) = $param;
         /* 附件默认配置项 */
         $default = C('ATTACHMENT_DEFAULT');
         /* 合并当前配置 */
         $config = $category['extend']['attachment'];
         $config = empty($config) ? $default : array_merge($default, $config);
         $attach = I('post.attachment');
         /* 该分类不允许上传附件 */
         if (!$config['is_upload'] || !in_array($attach['type'], str2arr($config['allow_type']))) {
             return;
         }
         switch ($attach['type']) {
             case 1:
                 //外链
                 # code...
                 break;
             case 2:
                 //文件
                 $info = json_decode(think_decrypt($attach['info']), true);
                 if (!empty($info)) {
                     $Attachment = D('Addons://Attachment/Attachment');
                     $Attachment->saveFile($info['name'], $info, $data['id']);
                 } else {
                     return;
                     //TODO:非法附件上传,可记录日志
                 }
                 break;
         }
     }
 }
 /**
  * 获取某个节点权限的用户组
  *
  * @param unknown_type $node 节点
  * @return unknown $gid 用户组ID
  */
 public function getGidByNode($node)
 {
     if (($cache = F('Cache_Node')) === false) {
         $prefix = C('DB_PREFIX');
         $sql = "select  a.*,b.user_group_id from {$prefix}node a left join {$prefix}user_group_popedom b on  a.node_id = b.node_id";
         $cache = M('')->query($sql);
         F('Cache_Node', $cache);
     }
     $gid = array();
     foreach ($cache as $v) {
         if (empty($v['user_group_id'])) {
             continue;
         }
         if ($v['app_name'] == $node[0]) {
             if ($v['mod_name'] == '*') {
                 $gid[] = $v['user_group_id'];
                 continue;
             }
             if ($v['mod_name'] == $node[1]) {
                 if ($v['act_name'] == $node[2] || $v['act_name'] == '*') {
                     $gid[] = $v['user_group_id'];
                 }
             }
         }
     }
     return $gid;
 }
Example #27
0
 /**
  * 构造函数
  * @param string $name 模型名称
  * @param string $tablePrefix 表前缀
  * @param mixed $connection 数据库连接信息
  */
 public function __construct($name = '', $tablePrefix = '', $connection = '')
 {
     /* 设置默认的表前缀 */
     $this->tablePrefix = C('DB_PREFIX') . 'document_';
     /* 执行构造方法 */
     parent::__construct($name, $tablePrefix, $connection);
 }
Example #28
0
 /**
  * 连接数据库方法
  * @access public
  * @throws ThinkExecption
  */
 public function connect($config='',$linkNum=0,$force=false) {
     if ( !isset($this->linkID[$linkNum]) ) {
         if(empty($config))  $config =   $this->config;
         // 处理不带端口号的socket连接情况
         $host = $config['hostname'].($config['hostport']?":{$config['hostport']}":'');
         // 是否长连接
         $pconnect   = !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
         if($pconnect) {
             $this->linkID[$linkNum] = mysql_pconnect( $host, $config['username'], $config['password'],131072);
         }else{
             $this->linkID[$linkNum] = mysql_connect( $host, $config['username'], $config['password'],true,131072);
         }
         if ( !$this->linkID[$linkNum] || (!empty($config['database']) && !mysql_select_db($config['database'], $this->linkID[$linkNum])) ) {
             E(mysql_error());
         }
         $dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
         //使用UTF8存取数据库
         mysql_query("SET NAMES '".C('DB_CHARSET')."'", $this->linkID[$linkNum]);
         //设置 sql_model
         if($dbVersion >'5.0.1'){
             mysql_query("SET sql_mode=''",$this->linkID[$linkNum]);
         }
         // 标记连接成功
         $this->connected    =   true;
         // 注销数据库连接配置信息
         if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
     }
     return $this->linkID[$linkNum];
 }
 public function add_classification_handle()
 {
     // 获取id
     $id = $_POST['id'];
     // 获取名称
     $name = $_POST['name'];
     // 输入判断
     if ($name == "") {
         $this->error('请输入分类名称');
     }
     // 获取操作者
     $loginname = $_SESSION['loginname'];
     // 读取所有数据,为了排序
     $where = array('type' => 'SHOE');
     $dataRead = M('classification')->where($where)->select();
     if ($_POST['optionsRadios'] == C('TOP')) {
         // 置顶
         $sort = $this->sortGetTop($dataRead, 'classification');
     } else {
         // 非置顶
         $sort = $this->sortGetBottom($dataRead);
     }
     // 构造数据
     $data = array('id' => $id, 'name' => $name, 'type' => 'SHOE', 'sort' => $sort, 'controller' => $loginname, 'created_time' => Date('Y-m-d H:i:s'));
     // 数据插入
     if (!M('classification')->add($data)) {
         echo 'classification表插入数据出错';
         die;
     } else {
         $this->success('添加成功', U('Shoesort/index'));
     }
 }
 public function add_handle()
 {
     // 读取参数
     $title = $_POST['title'];
     $answer = $_POST['answer'];
     // 输入判断
     if ($title == "") {
         $this->error('请输入问题');
     }
     if ($answer == "") {
         $this->error('请输入问答');
     }
     // 获取操作者
     $loginname = $_SESSION['loginname'];
     // 读取所有数据,为了排序
     $dataRead = M('question')->select();
     if ($_POST['optionsRadios'] == C('TOP')) {
         // 置顶
         $sort = $this->sortGetTop($dataRead, 'question');
     } else {
         // 非置顶
         $sort = $this->sortGetBottom($dataRead);
     }
     // 构造数据
     $data = array('title' => $title, 'answer' => $answer, 'sort' => $sort, 'controller' => $loginname, 'created_time' => Date('Y-m-d H:i:s'));
     // 数据插入
     if (!M('question')->add($data)) {
         echo 'question表插入数据出错';
         die;
     } else {
         $this->success('添加成功', U('Question/index'));
     }
 }