Ejemplo n.º 1
0
 private function detail()
 {
     $user = new userModel();
     if (isset($_GET['id'])) {
         $this->model->id = $_GET['id'];
         $oneOrder = $this->model->getOneOrder();
         switch ($oneOrder->payed) {
             case 0:
                 $oneOrder->payed = "<span style='color:red;'>[未付]</span>";
                 break;
             case 1:
                 $oneOrder->payed = "<span style='color:green;'>[已付]</span>";
         }
         switch ($oneOrder->sent) {
             case 0:
                 $oneOrder->sent = "<span style='color:red;'>[未发货]</span>";
                 break;
             case 1:
                 $oneOrder->sent = "<span style='color:green;'>[已发货]</span>";
         }
         $user->id = $oneOrder->uid;
         $oneUser = $user->getOneUserByID();
         $oneOrder->username = $oneUser->username;
         $this->smarty->assign("oneOrder", $oneOrder);
     }
     $this->smarty->assign("back", $_SERVER['HTTP_REFERER']);
     $this->smarty->assign("detail", true);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 private function result()
 {
     $this->showNav();
     if (isset($_POST['send'])) {
         $course = new courseModel();
         $course->id = $_POST['cid'];
         $oneCourse = $course->getOneCourse();
         $this->smarty->assign("oneCourse", $oneCourse);
         $user = new userModel();
         $user->id = $_SESSION['oneUserName']->id;
         $oneUser = $user->getOneUserByID();
         $this->smarty->assign("oneUser", $oneUser);
         $user->updateCountdown();
         $num = 0;
         $str .= "";
         $resultNum = 0;
         //echo $_POST['choiceNum'];
         while ($i < $_POST['choiceNum']) {
             $i++;
             $num++;
             //echo $_POST['choice'.($i)]
             $this->model->id = $_POST['choice' . $i];
             //echo $this->model->id."<br>";
             $oneChoice = $this->model->getOneChoice();
             //Tools::dump($_POST['choice'][$i]);
             //echo $_POST['choice'][$_POST['choice'.($i)]]."<br>";
             if ($oneChoice->answer == $_POST['choice'][$_POST['choice' . $i]]) {
                 $str .= "<div class='item'><dt>" . $num . "." . $oneChoice->question;
                 $str .= "<span class='glyphicon glyphicon-ok right'></span>";
                 $str .= "</dt>";
                 $resultNum++;
             } else {
                 $str .= "<div class='item'><dt>" . $num . "." . $oneChoice->question;
                 $str .= "<span class='glyphicon glyphicon-remove wrong'></span>";
                 $str .= "</dt>";
                 if ($_POST['choice'][$_POST['choice' . $i]] != '') {
                     $str .= "<dd class='failed'><b style='color:green;'>正确答案是:" . $oneChoice->answer . "</b>,";
                     $str .= "<span class='wrong'>您选择的是:" . $_POST['choice'][$_POST['choice' . $i]] . "。<span></dd>";
                     $str .= "<dd style='margin-bottom:3px;' class='alert alert-danger'><b style='color:red'>提示:</b>" . $oneChoice->tips . "</dd>";
                 } else {
                     $str .= "<dd class='wrong'>您未答此题</dd>";
                 }
             }
             $str .= "<dd>A." . $oneChoice->a . "</dd>";
             $str .= "<dd>B." . $oneChoice->b . "</dd>";
             $str .= "<dd>C." . $oneChoice->c . "</dd>";
             $str .= "<dd>D." . $oneChoice->d . "</dd></div>";
         }
         ////////judge/////////////////
         $num2 = 0;
         $str2 .= "";
         $resultNum2 = 0;
         //echo $_POST['choiceNum'];
         //echo $_POST['judgeNum'];
         while ($j < $_POST['judgeNum']) {
             $j++;
             $num2++;
             //echo $_POST['choice'.($i)]
             $this->model->id = $_POST['judge' . $j];
             $oneJudge = $this->model->getOneJudge();
             //Tools::dump($_POST['choice'][$i]);
             //echo $_POST['choice'][$_POST['choice'.($i)]]."<br>";
             if ($oneJudge->answer == $_POST['judge'][$_POST['judge' . $j]]) {
                 $str2 .= "<div class='item'><dt>" . $num2 . "." . $oneJudge->question;
                 $str2 .= "<span class='glyphicon glyphicon-ok right'></span>";
                 $str2 .= "</dt></div>";
                 $resultNum2++;
             } else {
                 $str2 .= "<div class='item'><dt>" . $num2 . "." . $oneJudge->question;
                 $str2 .= "<span class='glyphicon glyphicon-remove wrong'></span>";
                 $str2 .= "</dt>";
                 if ($_POST['judge'][$_POST['judge' . $j]] != '') {
                     switch ($oneJudge->answer) {
                         case '1':
                             $answer = "正确";
                             break;
                         case "0":
                             $answer = "错误";
                     }
                     switch ($_POST['judge'][$_POST['judge' . $j]]) {
                         case '1':
                             $answer2 = "正确";
                             break;
                         case "0":
                             $answer2 = "错误";
                     }
                     $str2 .= "<dd><span class='wrong'>正确答案是:" . $answer . "</span>,";
                     $str2 .= "<span class='wrong'>您选择的是:" . $answer2 . "。<span></dd>";
                     $str2 .= "<dd style='margin-bottom:3px;' class='alert alert-danger'><b style='color:red'>提示:</b>" . $oneJudge->tips . "</dd>";
                 } else {
                     $str2 .= "<dd class='wrong'>您未答此题</dd>";
                 }
                 $str2 .= "<dd>A.正确,";
                 $str2 .= "B.错误</dd></div>";
             }
         }
         //
         $user = new userModel();
         $examination = new examinationModel();
         $userLeaderboard = $examination->getUserLeaderboard();
         $allCourse = $course->getFrontCourse();
         $arr = array();
         foreach ($allCourse as $key => $value) {
             $examination->cid = $value->id;
             $hotExam = $examination->getExamByCID();
             foreach ($hotExam as $k => $v) {
                 $user->id = $v->uid;
                 $oneUser = $user->getOneUserByID();
                 $v->uid = $oneUser->username;
             }
             $arr[$value->name] = $hotExam;
         }
         //Tools::dump($arr);
         $this->smarty->assign("arr", $arr);
         $this->model->uid = $_POST['uid'];
         $this->model->cid = $_POST['cid'];
         $this->model->total = $_POST['choiceNum'] + $_POST['judgeNum'];
         $this->model->ticked = count($_POST['judge']) + count($_POST['choice']);
         $this->model->rightNum = $resultNum + $resultNum2;
         //$this->model->score=$resultNum*10+$resultNum2*10;
         $this->model->score = number_format(($resultNum + $resultNum2) / ($_POST['choiceNum'] + $_POST['judgeNum']) * 100, 2);
         $this->model->createExam();
     }
     $this->smarty->assign("total", $_POST['choiceNum'] + $_POST['judgeNum']);
     $this->smarty->assign("ticked", count($_POST['judge']) + count($_POST['choice']));
     $this->smarty->assign("choiceOutput", $str);
     $this->smarty->assign("judgeOutput", $str2);
     $this->smarty->assign("resultNum", $resultNum);
     $this->smarty->assign("resultNum2", $resultNum2);
     $this->smarty->assign("score", number_format(($resultNum + $resultNum2) / ($_POST['choiceNum'] + $_POST['judgeNum']) * 100, 2));
     $this->smarty->assign("result", true);
 }
Ejemplo n.º 4
0
 private function detail()
 {
     if (Tools::isSession("oneUser")) {
         Tools::Redirect("只有注册会员才可以回复", "?", 2, 1);
     }
     if ($_GET['id']) {
         $user = new userModel();
         $this->model->id = $_GET["id"];
         $oneAsk = $this->model->getOneAsk();
         //Tools::dump($oneAsk);
         //Tools::dump($this->model->getAllAnswersTotal());
         parent::page($this->model->getAllAnswersTotal());
         //$AllAnswers=$this->model->getAllAnswers();
         $data = $this->model->getAllAnswers();
         //Tools::dump($data);
         foreach ($data as $key => $value) {
             $user->id = $value->aid;
             $oneUser = $user->getOneUserByID();
             //Tools::dump($oneUser);
             $value->username = $oneUser->username;
             $value->icon = $oneUser->icon;
         }
         /*  $data=array();
             foreach ($AllAnswers as $key=>$value){
                 $this->model->id=$value->id;                
                 $SubAllAnswers=$this->model->getAllAnswers();
                 //Tools::dump($this->model->getAllAnswers());
                 $data[$value->content]=$SubAllAnswers;                               
             } */
         //Tools::dump($oneAsk);
         $askLeaderboard = $this->model->askLeaderboard();
         $this->smarty->assign("askLeaderboard", $askLeaderboard);
         $this->smarty->assign("data", $data);
         //Tools::dump($data);
         $this->smarty->assign("oneAsk", $oneAsk);
     }
     $this->smarty->display("home/ask.html");
 }
Ejemplo n.º 5
0
 private function add()
 {
     //echo "ok";
     //Tools::dump($_SESSION);
     $user = new userModel();
     if (isset($_GET['aid'])) {
         //Tools::dump($_GET);
         $this->model->aid = $_GET['aid'];
         $this->model->uid = $_GET['uid'];
         $this->model->content = $_GET['content'];
         //Tools::dump($this->model);
         if ($this->model->addComment()) {
             $page = new Ajax_Page($this->model->getAllCommentTotal(), 10);
             $this->model->limit = $page->limit;
             $allComment = $this->model->getAllComment();
             foreach ($allComment as $key => $value) {
                 $user->id = $value->uid;
                 $oneUser = $user->getOneUserByID();
                 //Tools::dump($oneUser);
                 $value->username = $oneUser->username;
                 //echo $value->id;
             }
             $temp = array();
             $temp[0] = $allComment;
             $temp[1] = $page->display(array(0, 1, 2));
             echo json_encode($temp);
             //echo "ok";
         } else {
             echo "failed";
         }
     }
     //Tools::dump($_GET);
     exit;
 }
Ejemplo n.º 6
0
 private function showExam()
 {
     //Tools::dump($this->model->getAllExams());
     $course = new courseModel();
     $AllCourse = $course->getAllCourse();
     $courseStr = null;
     foreach ($AllCourse as $value) {
         $courseStr .= $value->id . ",";
     }
     $courseStr = rtrim($courseStr, ",");
     //echo $levelStr;
     if (empty($_GET['kind'])) {
         $this->model->kind = $courseStr;
     } else {
         $this->model->kind = $_GET['kind'];
     }
     $this->course($_GET['kind']);
     parent::page($this->model->getAllExamsTotal());
     $user = new userModel();
     $allExams = $this->model->getAllExams();
     foreach ($allExams as $key => $value) {
         $user->id = $value->uid;
         $oneUser = $user->getOneUserByID();
         $value->uid = $oneUser->username;
         $course->id = $value->cid;
         $oneCourse = $course->getOneCourse();
         $value->cid = $oneCourse->name;
     }
     $this->smarty->assign('allExams', $allExams);
     $this->smarty->assign("showExam", true);
 }
Ejemplo n.º 7
0
 public function main()
 {
     if ($_SESSION['oneUserName']) {
         $this->smarty->assign("logged", true);
         $user = new userModel();
         $user->id = $_SESSION['oneUserName']->id;
         $oneUser = $user->getOneUserByID();
         $this->smarty->assign("oneUser", $oneUser);
     } else {
         $this->smarty->assign("logged", false);
     }
     switch ($_GET['action']) {
         case "vote":
             $this->castVote();
             break;
         case "logout":
             $this->logout();
             break;
     }
     $this->getUser();
     $this->showAD();
     $this->showVote();
     $this->showNav();
     $this->showArticle();
     $product = new productModel();
     $allProducts = $product->getHotProducts();
     $course = new courseModel();
     //$ask=new askModel();
     //$askLeaderboard=$ask->askLeaderboard();
     //$this->smarty->assign("askLeaderboard",$askLeaderboard);
     //Tools::dump($askLeaderboard);
     //$AllAsk=$ask->getAllAsks();
     $user = new userModel();
     $examination = new examinationModel();
     $userLeaderboard = $examination->getUserLeaderboard();
     //Tools::dump($userLeaderboard);
     $allCourse = $course->getFrontCourse();
     //$arr=[];
     // 		$arr=array();
     // 		foreach ($allCourse as $key=>$value){
     // 		    $examination->cid=$value->id;
     // 		    $hotExam=$examination->getExamByCID();
     // 		    foreach ($hotExam as $k=>$v){
     // 		        $user->id=$v->uid;
     // 		        $oneUser=$user->getOneUserByID();
     // 		        $v->uid=$oneUser->username;
     // 		    }
     // 		    $arr[$value->name]=$hotExam;
     // 		}
     foreach ($userLeaderboard as $key => $value) {
         $user->id = $value->uid;
         $course->id = $value->cid;
         $value->cid = $course->getOneCourse()->name;
         $oneUser = $user->getOneUserByID();
         $value->uid = $oneUser->username;
     }
     //Tools::dump($userLeaderboard);
     $this->smarty->assign("newExam", $userLeaderboard);
     $this->smarty->assign("userLeaderboard", $userLeaderboard);
     //Tools::dump($AllAsk);
     /* foreach ($AllAsk as $key=>$value){
     		    $user->id=$value->aid;
     		    $oneUser=$user->getOneUserByID();
     		    $course->id=$value->cid;
     		    $oneCourse=$course->getOneCourse();
     		    $value->courseName=$oneCourse->name;
     		    $ask->id=$value->id;
     		    $value->answerNum=$ask->getAllAnswersTotal();
     		    $value->username=$oneUser->username;
     		} */
     $download = new downloadModel();
     //Tools::dump($download->getDownloadNum());
     //Tools::dump($download->getDownloadNum());
     //$this->smarty->assign("downloadLeaderboard",$download->getDownloadNum());
     $this->smarty->assign("downloadLeaderboard", $download->getLatestDownload());
     //Tools::dump($AllAsk);
     /* $this->smarty->assign("AllAsk",$AllAsk); */
     $this->smarty->assign("AllAsk", false);
     $this->smarty->assign("allProducts", $allProducts);
     $product = new productModel();
     $this->smarty->assign("productRecommend", $product->getAttrArticle("recommend"));
     $this->smarty->display("home/home.html");
 }