Esempio n. 1
0
 function help_save()
 {
     $rules = array('title:required:标题不能为空!', 'content:required:内容不能为空!');
     $info = Validator::check($rules);
     if ($info == true) {
         Filter::form(array('sql' => 'title', 'text' => 'content'));
         if (Req::args('id') == null) {
             Req::args('publish_time', date('Y-m-d H:i:s'));
         }
         $id = Req::args('id');
         $model = new Model("help");
         if ($id) {
             $model->where("id={$id}")->update();
             Log::op($this->manager['id'], "修改帮助", "管理员[" . $this->manager['name'] . "]:修改了帮助 " . Req::args('title'));
         } else {
             $model->insert();
             Log::op($this->manager['id'], "添加帮助", "管理员[" . $this->manager['name'] . "]:添加了帮助 " . Req::args('title'));
         }
     } else {
         if (is_array($info)) {
             $data = Req::args() + array('validator' => $info);
             $this->redirect('help_edit', false, $data);
             exit;
         }
     }
     $this->redirect("help_list");
 }
Esempio n. 2
0
 function ask_validator()
 {
     $manager = $this->safebox->get('manager');
     $rules = array('content:required:内容不能为空!');
     $info = Validator::check($rules);
     if ($info == true) {
         Filter::form(array('text' => 'content'));
         if (Req::args('id') != null) {
             Req::args('reply_time', date('Y-m-d H:i:s'));
             Req::args('status', 1);
             Req::args('admin_id', $manager['id']);
         }
     }
     return $info;
 }
Esempio n. 3
0
 public function address_save($redirect = null)
 {
     $rules = array('zip:zip:邮政编码格式不正确!', 'addr:required:内容不能为空!', 'accept_name:required:收货人姓名不能为空!,mobile:mobi:手机格式不正确!,phone:phone:电话格式不正确', 'province:[1-9]\\d*:选择地区必需完成', 'city:[1-9]\\d*:选择地区必需完成', 'county:[1-9]\\d*:选择地区必需完成');
     $info = Validator::check($rules);
     if (!is_array($info) && $info == true) {
         Filter::form(array('sql' => 'accept_name|mobile|phone', 'txt' => 'addr', 'int' => 'province|city|county|zip|is_default|id'));
         $is_default = Filter::int(Req::args("is_default"));
         if ($is_default == 1) {
             $this->model->table("address")->where("user_id=" . $this->user['id'])->data(array('is_default' => 0))->update();
         } else {
             Req::args("is_default", "0");
         }
         Req::args("user_id", $this->user['id']);
         $id = Filter::int(Req::args('id'));
         if ($id) {
             $this->model->table("address")->where("id={$id} and user_id=" . $this->user['id'])->update();
         } else {
             $obj = $this->model->table("address")->where('user_id=' . $this->user['id'])->fields("count(*) as total")->find();
             if ($obj && $obj['total'] >= 20) {
                 $this->assign("msg", array("error", '地址最大允许添加20个'));
                 $this->redirect("address_other", false, Req::args());
                 exit;
             } else {
                 $address_id = $this->model->table("address")->insert();
                 $order_status = Session::get("order_status");
                 $order_status['address_id'] = $address_id;
                 Session::set("order_status", $order_status);
             }
         }
         $this->assign("msg", array("success", "地址编辑成功!"));
         Req::args("id", null);
         //$this->redirect("address_other",false);
         if ($redirect == null) {
             echo "<script>parent.location.reload();</script>";
         } else {
             $this->redirect($redirect);
         }
         exit;
     } else {
         $this->assign("msg", array("error", $info['msg']));
         $this->redirect("address_other", false, Req::args());
     }
 }
Esempio n. 4
0
 public function voucher_activated()
 {
     if (!Tiny::app()->checkToken()) {
         $this->redirect("voucher");
     }
     $rules = array('account:required:账号不能为空!', 'password:required:密码不能为空!');
     $info = Validator::check($rules);
     if (!is_array($info) && $info == true) {
         Filter::form(array('sql' => 'account'));
         $account = Filter::sql(Req::args("account"));
         $voucher = $this->model->table("voucher")->where("account='{$account}'")->find();
         if ($voucher && $voucher['password'] == Req::args("password")) {
             if (strtotime($voucher['end_time']) > time()) {
                 if ($voucher['status'] == 0) {
                     $this->model->table("voucher")->data(array('user_id' => $this->user['id'], 'is_send' => 1, 'status' => 0))->where("account='{$account}'")->update();
                     $this->redirect("voucher", false, array('msg' => array("success", "优惠券成功激活!")));
                 } else {
                     $this->redirect("voucher", false, array('msg' => array("warning", "此优惠券已使用过!")));
                 }
             } else {
                 //过期
                 $this->redirect("voucher", false, array('msg' => array("warning", "优惠券已过期!")));
             }
         } else {
             //不存在此优惠券
             $this->redirect("voucher", false, array('msg' => array("error", "优惠券账号或密码错误!")));
         }
     } else {
         //输入信息有误
         $this->redirect("voucher", false, array('msg' => array("info", "输入的信息不格式不正确")));
     }
 }