Пример #1
0
 /**
  * 订单 详情
  */
 public function detail()
 {
     \Core\View::css('/manage/datetimepicker/css/bootstrap-datetimepicker.min.css');
     \Core\View::script('/manage/datetimepicker/js/bootstrap-datetimepicker.js');
     \Core\View::script('/manage/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js');
     $this->view->content = view('order/detail.php');
     $order_id = \Core\URI::kv('order_id');
     $v = new \Core\Validation();
     $v->required($order_id)->message('参数错误');
     if ($v->has_error()) {
         \Core\Cookie::set('message', $v->get_error('message'));
         redirect(\Core\URI::a2p(array('order' => 'index')));
     }
     $this->view->content->row = new \Db\Trade\Order($order_id);
 }
Пример #2
0
 /**
  * 删除友情连接
  */
 public function delete()
 {
     $ids = \Core\URI::kv('ids');
     $v = new \Core\Validation();
     $v->required($ids)->message('参数错误');
     if (!$v->has_error()) {
         $id_arr = explode('-', $ids);
         foreach ($id_arr as $id) {
             $slide = new \DB\Mall\Slide($id);
             $slide->delete();
         }
     }
     echo json_encode($v->get_error());
     exit;
 }
Пример #3
0
 /**
  * 微信创建账号登录
  * @see Core.Controller::initialize()
  */
 public function initialize()
 {
     $user = self::login_user();
     if (empty($user)) {
         $code = \Core\URI::kv('code');
         $v = new \Core\Validation();
         $v->required($code)->message('用户未来授权访问', 1000);
         $oauth = \WX\Platform\Oauth::init_config_params();
         if ($v->has_error()) {
             //                $oauth->to_weixin(W_DOMAIN.\Core\URI::a2p_before(), 'host_base');
             $oauth->to_weixin(W_DOMAIN . \Core\URI::a2p_before(), 'user_info');
         } else {
             $user_accesstoken = $oauth->user_accesstoken($code);
             $openid = $user_accesstoken['openid'];
             $access_token = $user_accesstoken['access_token'];
             $userinfo = $oauth->user_info();
             $row = \DB\Account\Identify::row(array('identify_name' => $openid, 'identify_type' => 4));
             if (empty($row)) {
                 $user = new \DB\Account\User();
                 $user->user_avatar = $userinfo['headimgurl'];
                 $user->user_nickname = $userinfo['nickname'];
                 $user->user_status = 1;
                 $user->user_gender = $userinfo['sex'] == 1 ? 'male' : 'female';
                 $user->create_time = W_START_TIME;
                 $user->login_time = W_START_TIME;
                 $user_id = $user->save();
                 $identify = new \DB\Account\Identify();
                 $identify->identify_name = $openid;
                 $identify->identify_level = 1;
                 $identify->create_time = W_START_TIME;
                 $identify->identify_password = $access_token;
                 $identify->user_id = $user_id;
                 $identify->identify_type = 4;
                 $identify->save();
             } else {
                 $user_id = $row->user_id;
                 $row->user->user_avatar = $userinfo['headimgurl'];
                 $row->user->user_nickname = $userinfo['nickname'];
                 $row->user->user_gender = $userinfo['sex'] == 1 ? 'male' : 'female';
                 $row->user->login_time = W_START_TIME;
                 $row->user->save();
             }
             \Core\Session::set('user_id', $user_id);
         }
     }
 }
Пример #4
0
 /**
  * 上传图片
  */
 public function upload()
 {
     $file = \Ext\Uploader::get('ajax_upload');
     $v = new \Core\Validation();
     $v->required($file)->message('参数错误');
     if (!$v->has_error()) {
         if ($file->is_successed()) {
             $to_path_file = '/' . time() . '.' . $file->file_ext();
             $file->move(\Core\Application::config()->upload_dir . $to_path_file);
             echo json_encode(array('imgurl' => \Core\Application::config()->upload_url . $to_path_file));
             exit;
         } else {
             $v->required(false)->message($file->error_code());
         }
     }
     echo json_encode($v->get_error());
     exit;
 }
Пример #5
0
 /**
  * 登录
  */
 public function login()
 {
     $account = \Core\URI::kv('user_account');
     $password = \Core\URI::kv('user_password');
     $v = new \Core\Validation();
     $v->filter_var(filter_var($account, FILTER_VALIDATE_EMAIL))->message('邮箱帐号错误');
     if ($v->has_error()) {
         \Core\Cookie::set('error', $v->get_error('message'));
     } else {
         $gen_password = \DB\Authorize\Admin::gen_password($password);
         $row = \DB\Authorize\Admin::row(array('admin_account' => $account, 'admin_password' => $gen_password));
         //var_dump(!empty($row->admin_account));exit();
         if (!empty($row->admin_account)) {
             \Db\Log::message('登录', '', $row->admin_name);
             \Core\Session::set('admin_id', $row->admin_id);
             redirect(\Core\URI::a2p(array('order' => 'index')));
         }
     }
     redirect(\Core\URI::a2p(array('main' => 'index')));
 }
Пример #6
0
 public function changepw()
 {
     $password = \Core\URI::kv('password');
     $new_password = \Core\URI::kv('new_password');
     $repeat_password = \Core\URI::kv('repeat_password');
     $v = new \Core\Validation();
     $v->required($password)->message('密码');
     $v->required($new_password)->message('新密码不能为空');
     $v->filter_var($new_password == $repeat_password)->message('重复新密码不正确');
     if (!$v->has_error()) {
         $authorize_id = \Core\Session::get('authorize_id');
         $row = \DB\Authorize::row(array('authorize_id' => $authorize_id));
         $gen_password = \DB\Authorize::gen_password($password);
         if ($gen_password == $row->authorize_password) {
             $row->authorize_password = \DB\Authorize::gen_password($new_password);
             $row->save();
             $v->required(false)->message('密码修改成功,退出当前登录生效');
         } else {
             $v->required(false)->message('原始密码不正确');
         }
     }
     echo json_encode($v->get_error());
     exit;
 }
Пример #7
0
 /**
  * 更改用户状态
  */
 public function status()
 {
     $ids = \Core\URI::kv('ids');
     $status = \Core\URI::kv('status', 0);
     $v = new \Core\Validation();
     $v->required($ids)->message('参数不合法');
     if (!$v->has_error()) {
         $id_arr = explode('-', $ids);
         foreach ($id_arr as $id) {
             $item = \DB\Account\User::row(array('user_id' => $id));
             if (!empty($item)) {
                 $item->user_status = $status;
                 $item->update();
             }
         }
     }
     echo json_encode($v->get_error());
     exit;
 }
Пример #8
0
 /**
  * 获取某列数据
  */
 public function get()
 {
     \Core\View::script('/manage/js/ajaxfileupload.js');
     $id = \Core\URI::kv('id');
     $v = new \Core\Validation();
     $v->required($id)->message('参数错误');
     if (!$v->has_error()) {
         $this->view->content = view('admin/get.php');
         $this->view->content->row = new \DB\Authorize\Admin($id);
     }
 }