コード例 #1
0
 public function vote()
 {
     global $rep, $view;
     $post_id = isset($_REQUEST['id_adv']) ? $_REQUEST['id_adv'] : NULL;
     $username = isset($_SESSION['username']) ? $_SESSION['username'] : NULL;
     if (postModel::getPost($post_id) == NULL) {
         $data = array();
         $data[0] = "We're sorry, something somewhere went wrong...";
         $data[1] = "The post you're trying to vote for doesn't exist!";
         require_once $view['error'];
     } elseif ($username == NULL) {
         $data = array();
         $data[0] = "We're sorry, something somewhere went wrong...";
         $data[1] = "Please login first";
         require_once $view['error'];
     } else {
         $vote = vote_postModel::existVote_post($post_id, $username);
         if ($vote) {
             vote_postModel::unsetVote_post($post_id, $username);
         } else {
             vote_postModel::setVote_post($post_id, $username);
         }
         $this->showadventure();
     }
 }
コード例 #2
0
 protected function showadventure()
 {
     global $rep, $view;
     $id_adv = $_REQUEST['arg1'];
     $post = postModel::getPost($id_adv);
     if ($post == NULL) {
         header($_SERVER["SERVER_PROTOCOL"] . " 404 Page not found");
         $data[0] = "We're sorry, something somewhere went wrong...";
         $data[1] = "The adventure you're looking for doesn't exist (anymore?)";
         require_once $view['error'];
     } else {
         require_once $view['adventure'];
     }
 }