Example #1
0
 public function put_index($id)
 {
     $put = json_decode(Input::put()['model'], true);
     $data = array('title' => $put['title'], 'domain' => $put['domain'], 'user' => $put['user'], 'pass' => $put['pass'], 'updated_at' => time());
     try {
         DB::update(Model_Site::table())->set($data)->where('id', '=', $id)->execute();
         return $this->response(array('ok' => true));
     } catch (Exception $e) {
         return $this->response(array('ok' => false, 'message' => $e->getMessage()), 500);
     }
 }
Example #2
0
 public function put_index($siteId)
 {
     $put = json_decode(Input::put()['model'], true);
     if ($this->isExist($siteId)) {
         try {
             DB::transaction_start();
             DB::commit();
         } catch (Exception $e) {
             DB::rollback();
         }
     } else {
     }
 }
Example #3
0
 /**
  * Updates a seller callback.
  *
  * @param int $seller_id Seller ID.
  * @param int $id        Seller callback ID.
  *
  * @return void
  */
 public function put_index($seller_id = null, $id = null)
 {
     $callback = $this->get_callback($id);
     $validator = \Validation_Seller_Callback::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $callback = \Service_Seller_Callback::update($callback, $data);
     if (!$callback) {
         throw new HttpServerErrorException();
     }
     $this->response($callback);
 }
Example #4
0
 /**
  * Updates a seller contact.
  *
  * @param int $seller_id Seller ID.
  * @param int $id        Contact ID.
  *
  * @return void
  */
 public function put_index($seller_id = null, $id = null)
 {
     $contact = $this->get_contact($id);
     $validator = \Validation_Contact::update('seller');
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $contact = \Service_Contact::update($contact, $data);
     if (!$contact) {
         throw new HttpServerErrorException();
     }
     $this->response($contact);
 }
Example #5
0
 /**
  * Updates a gateway.
  *
  * @param int $seller_id Seller ID.
  * @param int $id        Gateway ID.
  *
  * @return void
  */
 public function put_index($seller_id = null, $id = null)
 {
     $gateway = $this->get_gateway($id);
     $validator = \Validation_Gateway::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $gateway = \Service_Gateway::update($gateway, $data);
     if (!$gateway) {
         throw new HttpServerErrorException();
     }
     $this->response($gateway);
 }
Example #6
0
 /**
  * Updates a customer.
  *
  * @param int $id Customer ID.
  *
  * @return void
  */
 public function put_index($id = null)
 {
     $customer = $this->get_customer($id);
     $validator = \Validation_Customer::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $customer = \Service_Customer::update($customer, $data);
     if (!$customer) {
         throw new HttpServerErrorException();
     }
     $this->response($customer);
 }
Example #7
0
 /**
  * Updates a payment method.
  *
  * @param int $customer_id Customer ID.
  * @param int $id          Payment method ID.
  *
  * @return void
  */
 public function put_index($customer_id = null, $id = null)
 {
     $customer = $this->get_customer($customer_id);
     $payment_method = $this->get_paymentmethod($id, $customer);
     $validator = \Validation_Customer_Paymentmethod::update($payment_method->gateway);
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $payment_method = \Service_Customer_Paymentmethod::update($payment_method, $data);
     if (!$payment_method) {
         throw new HttpServerErrorException();
     }
     $this->response($payment_method);
 }
Example #8
0
 /**
  * Updates a product option.
  *
  * @param int $product_id Product ID.
  * @param int $id         Product option ID.
  *
  * @return void
  */
 public function put_index($product_id = null, $id = null)
 {
     $product = $this->get_product($product_id);
     $option = $this->get_option($id, $product);
     $validator = \Validation_Product_Option::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $option = \Service_Product_Option::update($option, $data);
     if (!$option) {
         throw new HttpServerErrorException();
     }
     $this->response($option);
 }
Example #9
0
 /**
  * 修改信息
  * @param [type] $id [description]
  * @todo 价格
  */
 public function PUT_infoAction($id)
 {
     $this->authPrinter($id);
     $info = [];
     /*店名*/
     Input::put('name', $var, 'title') and $info['name'] = $var;
     /*邮箱*/
     Input::put('email', $var, 'email') and $info['email'] = $var;
     /*手机*/
     Input::put('phone', $var, 'phone') and $info['phone'] = $var;
     /*qq号*/
     Input::put('qq', $var, 'int') and $info['qq'] = $var;
     /*微信号*/
     Input::put('wechat', $var, 'char_num') and $info['wechat'] = $var;
     /*地址*/
     Input::put('address', $var, 'text') and $info['address'] = $var;
     /*简介*/
     Input::put('profile', $var, 'text') and $info['profile'] = $var;
     /*营业时间*/
     Input::put('open', $var, 'text') and $info['open'] = $var;
     /*营业时间*/
     Input::put('other', $var, 'text') and $info['other'] = $var;
     /*价格*/
     $price = [];
     Input::put('price_s', $price['s'], 'float');
     Input::put('price_d', $price['d'], 'float');
     Input::put('price_c_s', $price['c_s'], 'float');
     Input::put('price_c_d', $price['c_d'], 'float');
     if (!empty(array_filter($price))) {
         if ($oldprice = PrinterModel::where('id', $id)->get('price')) {
             if ($oldprice = @json_decode($oldprice, true)) {
                 $price = array_merge($oldprice, array_filter($price));
             }
         }
         $info['price'] = json_encode($price);
     }
     if (empty($info)) {
         $this->response(0, '无有效参数');
     } elseif (PrinterModel::where('id', $id)->update($info) !== false) {
         $this->response(1, $info);
     } else {
         $this->response(0, '修改失败');
     }
 }
Example #10
0
 /**
  * 修改状态
  * @param [type] $id [description]
  */
 public function PUT_infoAction($id)
 {
     $pid = $this->authPrinter();
     $response['status'] = 0;
     if (!Input::put('status', $status, 'int')) {
         $response['info'] = '无效状态';
     } elseif ($status < -1 || $status > 5) {
         $response['info'] = '此状态不允许设置';
     } elseif ($status == -1 && TaskModel::where('id', intval($id))->where('pri_id', $pri_id)->get('payed')) {
         //取消订单
         $response['info'] = '已支付暂不支持线上取消';
     } elseif (TaskModel::where('id', intval($id))->where('pri_id', $pid)->update(['status' => $status])) {
         $response['status'] = 1;
         $response['info'] = '修改成功';
     } else {
         $response['info'] = '状态设置失败';
     }
     $this->response = $response;
 }
Example #11
0
 /**
  * Updates a seller.
  *
  * @param int $id Seller ID.
  *
  * @return void
  */
 public function put_index($id = null)
 {
     if (!$id) {
         throw new HttpNotFoundException();
     }
     $seller = \Service_Seller::find_one($id);
     if (!$seller || $seller != \Seller::active()) {
         throw new HttpNotFoundException();
     }
     $validator = \Validation_Seller::update();
     if (!$validator->run(\Input::put())) {
         throw new HttpBadRequestException($validator->errors());
     }
     $data = $validator->validated();
     $seller = \Service_Seller::update($seller, $data);
     if (!$seller) {
         throw new HttpServerErrorException();
     }
     $this->response($seller);
 }
Example #12
0
 /**
  * This is a test page to test basic curl requests and responses.
  * @return mixed
  */
 public function action_index()
 {
     try {
         //init data response
         $data = array();
         //get url
         $data['url'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
         //get method
         $data['method'] = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
         //get params
         $data['params']['get'] = \Input::get();
         $data['params']['post'] = \Input::post();
         $data['params']['put'] = \Input::put();
         $data['params']['delete'] = \Input::delete();
         //return response
         $this->response(array('data' => $data));
     } catch (\Exception $e) {
         //return caught exceptions to json response
         $this->response(array('exception' => $e->getMessage()));
     }
 }
Example #13
0
 /**
  * 重置密码
  * @method POST_printerAction
  * @author NewFuture
  */
 public function PUT_indexAction($id)
 {
     $this->auth($id);
     $response['status'] = 0;
     if (!Input::put('password', $password, 'isMd5')) {
         $response['info'] = '新的密码格式不对';
     } elseif (!Input::put('old', $old_pwd, 'isMd5')) {
         $response['info'] = '请输入原密码';
     } else {
         /*数据库中读取用户数据*/
         $printer = PrinterModel::field('password,account')->find($id);
         $account = $printer['account'];
         if (!$printer || Encrypt::encryptPwd($old_pwd, $account) != $printer['password']) {
             $response['info'] = '原密码错误';
         } elseif ($printer->update(['password' => Encrypt::encryptPwd($password, $account)]) >= 0) {
             $response['info'] = '修改成功';
             $response['status'] = 1;
         } else {
             $response['info'] = '修改失败';
         }
     }
     $this->response = $response;
 }
Example #14
0
 /**
  * 修改用户邮箱
  * PUT /user/1/phone {code:"C09Eaf"}
  * @method GET_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function PUT_emailAction($id = 0)
 {
     $id = $this->auth($id);
     $response['status'] = 0;
     $Code = new Model('code');
     if (!Input::put('code', $code, 'ctype_alnum')) {
         $response['info'] = '验证码格式不对';
     } elseif (!$Code->where('use_id', $id)->where('type', 1)->field('id,time,code,content')->find()) {
         $response['info'] = '验证信息不存在';
     } elseif (!Safe::checkTry('email_code_' . $id)) {
         $Code->delete();
         Safe::del('email_code_' . $id);
         $response['info'] = '尝试次数过多,请重新验证';
     } elseif (strtoupper($code) != strtoupper(substr($Code['code'], -6))) {
         $response['info'] = '验证码不匹配';
     } elseif (!UserModel::saveEmail($Code['content'], $Code['use_id'])) {
         $response['info'] = '邮箱绑定失败';
     } else {
         $Code->delete();
         Safe::del('email_code_' . $id);
         $response['info'] = $Code['content'];
         $response['status'] = 1;
     }
     $this->response = $response;
 }
Example #15
0
 /**
  * 获取详情
  * PUT /books/123
  * @method GET_infoAction
  * @param  integer        $id [资源id]
  * @author NewFuture
  */
 public function PUT_infoAction($id = 0)
 {
     $pid = $this->authPrinter();
     $book = [];
     if (Input::put('name', $name, 'title')) {
         $book['name'] = $name;
     }
     if (Input::put('detail', $detail, 'text')) {
         $book['detail'] = $detail;
     }
     if (Input::put('price', $price, 'float')) {
         $book['price'] = $price;
     }
     if (empty($book)) {
         $this->response(0, '无修改内容');
     } elseif (BookModel::where('id', $id)->where('pri_id', $pid)->update($book)) {
         $this->response(1, $book);
     } else {
         $this->response(0, '修改失败');
     }
 }
Example #16
0
 /**
  * 信息修改
  * PUT /share/1
  * @method PUT_info
  * @author NewFuture
  * @param name 文件名
  */
 public function PUT_infoAction($id = 0)
 {
     $userid = $this->auth();
     /*检查输入*/
     if (Input::put('name', $name, 'title')) {
         $share['name'] = $name;
     }
     if (Input::put('anonymous', $anonymous)) {
         $share['anonymous'] = boolval($anonymous);
     }
     if (Input::put('detail', $detail, 'text')) {
         $share['detail'] = $detail;
     }
     /*保存*/
     if (empty($share)) {
         $this->response(0, '没有任何有效的修改内容');
     } elseif (ShareModel::where('id', $id)->where('use_id', $use_id)->update($share)) {
         $this->response(1, $share);
     } else {
         $this->response(0, '保存失败');
     }
 }
Example #17
0
 /**
  * 文件信息修改
  * PUT /file/1
  * @method PUT_info
  * @author NewFuture
  * @param name 文件名
  */
 public function PUT_infoAction($id = 0)
 {
     $userid = $this->auth();
     if (Input::put('name', $name, 'title')) {
         if (FileModel::saveName($id, $name)) {
             $this->response(1, '成功修改为:' . $name);
         } else {
             $this->response(0, '修改失败');
         }
     } else {
         $this->response(0, '文件名无效');
     }
 }