private function show()
 {
     $user = new userModel();
     $upload = new UploadFile("pic", "public/uploads/member");
     if (isset($_POST['send'])) {
         $user->id = $_POST['id'];
         $user->email = $_POST['email'];
         if ($_POST['pwd'] == $_POST['newpwd']) {
             $user->pwd = $_POST['newpwd'];
         } else {
             $user->pwd = md5($_POST['newpwd']);
         }
         if (is_uploaded_file($_FILES['pic']['tmp_name'])) {
             if ($upload->upload("pic")) {
                 $user->icon = $upload->getNewName();
             }
         } else {
             $user->icon = $_POST['newpic'];
             //echo "没有上传".$_POST['newpic'];
         }
         //Tools::dump($_POST);
         if ($user->updateUser()) {
             //echo "ok";
             Tools::Redirect("会员资料修改成功", $_SERVER['HTTP_REFERER']);
         } else {
             if ($user->updateUser() == 0) {
                 Tools::Redirect("会员资料没有修改", $_SERVER['HTTP_REFERER']);
                 //echo "not changed";
             } else {
                 Tools::Redirect("会员资料修改失败", $_SERVER['HTTP_REFERER'], 2);
             }
         }
     }
     $comment = new commentModel();
     $article = new articleModel();
     $product = new productModel();
     $ask = new askModel();
     $quiz = new quizModel();
     if ($_GET['id']) {
         $user->id = $_GET['id'];
         $oneUser = $user->getOneUserByID();
         $this->smarty->assign("oneUser", $oneUser);
         /////////////////////////////////
         $comment->uid = $_GET['id'];
         $allComments = $comment->getAllCommentsByUID();
         foreach ($allComments as $key => $value) {
             $article->id = $value->aid;
             $oneArticle = $article->getOneArticle();
             $value->title = $oneArticle->title;
         }
         $product->uid = $_GET['id'];
         $allOrders = $product->getAllOrdersByUID();
         foreach ($allOrders as $value) {
             $pids = explode(",", $value->pid);
             $str = null;
             foreach ($pids as $v) {
                 $product->id = $v;
                 //Tools::dump($v);
                 $oneProduct = $product->getOneProduct();
                 //Tools::dump($oneProduct);
                 $str .= $oneProduct->name . ",";
             }
             $str = rtrim($str, ",");
             //Tools::dump($str);
             $value->pid = $str;
             switch ($value->payed) {
                 case 0:
                     $value->payed = "<span style='color:red;'>[未付]</span>";
                     break;
                 case 1:
                     $value->payed = "<span style='color:green;'>[已付]</span>";
             }
             switch ($value->sent) {
                 case 0:
                     $value->sent = "<span style='color:red;'>[未发货]</span>";
                     break;
                 case 1:
                     $value->sent = "<span style='color:green;'>[已发货]</span>";
             }
         }
         $ask->aid = $_GET['id'];
         $allAsks = $ask->getAllAskByAID();
         $this->smarty->assign("allAsks", $allAsks);
         $this->smarty->assign("allOrders", $allOrders);
         $this->smarty->assign("allComments", $allComments);
         $quiz->uid = $_GET["id"];
         $allScores = $quiz->getAllScoresByUID();
         $course = new courseModel();
         foreach ($allScores as $key => $value) {
             $course->id = $value->cid;
             $oneCourse = $course->getOneCourse();
             $value->cid = $oneCourse->name;
         }
         $this->smarty->assign("allScores", $allScores);
     }
     $this->smarty->assign("show", true);
 }
示例#2
0
 public function add()
 {
     if (isset($_POST['send'])) {
         if (is_uploaded_file($_FILES['pix']['tmp_name'])) {
             $upload = new UploadFile("pix", "public/uploads/product/");
             if ($upload->upload("pix")) {
                 $pix = $upload->getNewName();
             } else {
                 Tools::getBack($upload->getErrorMsg());
             }
         } else {
             $pix = "product.gif";
         }
         $this->model->name = $_POST['name'];
         $this->model->price = $_POST['price'];
         $this->model->inventory = $_POST['inventory'];
         $this->model->pix = $pix;
         $this->model->description = $_POST['description'];
         if ($this->model->addProduct()) {
             Tools::Redirect("添加商品成功", "?a=product&m=adminShow");
         } else {
             Tools::getBack("添加商品失败");
         }
     }
     $this->smarty->assign("add", true);
     $this->smarty->display("admin/product.html");
 }
示例#3
0
 private function add()
 {
     if (isset($_POST['send'])) {
         //Tools::dump($_POST);
         //Tools::dump($_FILES);
         if (is_uploaded_file($_FILES['thumbnail']['tmp_name'])) {
             $this->model->title = $_POST['title'];
             $this->model->link = $_POST['link'];
             $this->model->description = $_POST['description'];
             $this->model->type = $_POST['type'];
             $upload = new UploadFile("thumbnail", "public/uploads/ad/");
             if ($upload->upload("thumbnail")) {
                 $this->model->thumbnail = $upload->getNewName();
                 if ($this->model->addAd()) {
                     Tools::Redirect("添加广告成功", "index.php?a=ad&action=show", 1, 1);
                 } else {
                     Tools::Redirect("添加广告失败", "index.php?a=ad&action=add", 2, 1);
                 }
             }
         } else {
             Tools::Redirect("必须要选择上传的图片", $_SERVER['HTTP_REFERER'], 2);
         }
         $upload = new UploadFile("thumbnail");
         $upload->upload("thumbnail");
     }
     $this->smarty->assign("add", true);
 }
示例#4
0
 private function update()
 {
     if (isset($_POST['send'])) {
         //Tools::dump($_POST);
         //Tools::dump($_FILES);
         $this->model->id = $_POST['id'];
         $this->model->email = $_POST['email'];
         if ($_POST['pwd'] != $_POST['pwd2']) {
             $this->model->pwd = md5($_POST['pwd']);
         } else {
             $this->model->pwd = $_POST['pwd'];
         }
         $file = null;
         if (is_uploaded_file($_FILES['icon']['tmp_name'])) {
             $upload = new UploadFile("icon", 'public/uploads/member/');
             if ($upload->upload("icon")) {
                 $file = $upload->getNewName();
             }
         } else {
             $file = $_POST['icon2'];
         }
         $this->model->icon = $file;
         if ($this->model->updateUser()) {
             Tools::Redirect("修改成功", "?a=user&action=member&id=" . $_POST['id']);
         } elseif ($this->model->updateUser() == 0) {
             Tools::Redirect("没有修改", "?a=user&action=member&id=" . $_POST['id']);
         } else {
             Tools::Redirect("修改失败", $_SERVER['HTTP_REFERER']);
         }
     }
     if (isset($_GET['id'])) {
         $this->model->id = $_GET['id'];
         $oneUser = $this->model->getOneUserByID();
         //Tools::dump($oneUser);
         $this->smarty->assign("oneUser", $oneUser);
     }
     $this->smarty->assign("update", true);
     $this->smarty->display('home/member.html');
     exit;
 }
 private function add()
 {
     if (isset($_POST['send'])) {
         if (is_uploaded_file($_FILES['pic']['tmp_name'])) {
             $upload = new UploadFile("pic", "public/uploads/download");
             $upload->setAllowType(array('zip'));
             if ($upload->upload("pic")) {
                 $this->model->name = $upload->getNewName();
             }
         } else {
             $this->model->url = $_POST["url"];
         }
         $this->model->description = $_POST["description"];
         $this->model->tid = $_POST["tid"];
         $this->model->title = $_POST["title"];
         if ($this->model->addDownload()) {
             Tools::Redirect("添加上传内容成功", "?a=download&action=show");
         } else {
             Tools::Redirect("添加上传内容失败", $_SERVER['HTTP_REFERER'], 2);
         }
     }
     $this->topic();
     $this->smarty->assign("add", true);
 }
 private function add()
 {
     //Tools::dump($_POST);
     //exit();
     //Tools::dump($_FILES);
     $thumbnail = null;
     $this->nav();
     $this->mall();
     if (isset($_POST['send'])) {
         if (empty($_POST['nid'])) {
             Tools::getBack("必须选择一个栏目");
         }
         if (is_uploaded_file($_FILES['thumbnail']['tmp_name'])) {
             $upload = new UploadFile("thumbnail", "public/uploads/article/");
             if ($upload->upload("thumbnail")) {
                 $thumbnail = $upload->getNewName();
             } else {
                 Tools::getBack($upload->getErrorMsg());
             }
         } else {
             $thumbnail = "default.jpg";
         }
         //echo $thumbnail;
         $this->model->title = $_POST['title'];
         $this->model->lead = $_POST['lead'];
         $this->model->content = $_POST['content'];
         $this->model->author = $_POST['author'];
         $this->model->tag = $_POST['tag'];
         $this->model->thumbnail = $thumbnail;
         $this->model->nid = $_POST['nid'];
         $this->model->cid = $_POST['cid'];
         $this->model->source = $_POST['source'];
         $this->model->pageview = 1;
         //echo implode(",", $_POST['attr']);
         $this->model->attr = implode(",", $_POST['attr']);
         if ($this->model->addArticle()) {
             Tools::Redirect("添加文章成功", "?a=article&action=show");
         } else {
             Tools::getBack("添加文章失败");
         }
     }
     $this->smarty->assign("add", true);
 }