/** * 修改信息 * @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, '修改失败'); } }
/** * 打印店登录 * @method loginAction * @return [type] [description] * @author NewFuture */ public function POST_indexAction() { $response['status'] = 0; if (!Input::post('account', $account, Config::get('regex.account'))) { $response['info'] = '账号格式错误'; } elseif (!Input::post('password', $password, 'isMd5')) { $response['info'] = '密码未加密处理'; } elseif (!Safe::checkTry('printer_auth_' . $account)) { $response['info'] = '尝试次数过多账号临时封禁,稍后重试或者联系我们'; } elseif (!($Printer = PrinterModel::where('account', $account)->field('id,sch_id,password,status,name')->find())) { $response['info'] = '账号错误'; } elseif (Encrypt::encryptPwd($password, $account) != $Printer['password']) { $response['info'] = '密码错误'; } else { Safe::del('printer_auth_' . $account); unset($Printer['password']); $sid = Session::start(); Session::set('printer', ['id' => $Printer['id'], 'sch_id' => $Printer['sch_id']]); $response['status'] = 1; $response['info'] = ['sid' => $sid, 'printer' => $Printer]; } $this->response = $response; }
/** * 重置密码 * @method POST_indexAction * @author NewFuture */ public function POST_indexAction() { $response['status'] = 0; if (!Input::post('password', $password, 'isMd5')) { $response['info'] = '密码无效'; } elseif (!($printer = Session::get('find_printer'))) { $response['info'] = '未验证或者验证信息过期'; } else { $printer['password'] = Encrypt::encryptPwd($password, $printer['account']); if (PrinterModel::where('id', $printer['id'])->update($printer) >= 0) { $response['status'] = 1; $response['info'] = '重置成功'; } else { $response['info'] = '新密码保存失败'; } } $this->response = $response; }