Example #1
0
 private function setReply()
 {
     $ID_Topic = segment(3);
     if (segment(4) === "edit") {
         $action = "edit";
         $ID_Reply = segment(5);
     } elseif (segment(4) === "new") {
         $action = "save";
     }
     if (segment(6) > 0) {
         $page = segment(6);
     } else {
         $page = 1;
     }
     if (SESSION("ZanUserID") > 0) {
         $this->js("tiny-mce", NULL, "basic");
         $this->js("validations", $this->application);
         if (POST("cancel")) {
             redirect($this->application . _sh . segment(2) . _sh . segment(3) . _sh);
         }
         if (!POST("doAction")) {
             if ($action === "save") {
                 $topic = $this->Forums_Model->getTopicByID($ID_Topic);
             } elseif ($action === "edit") {
                 $topic = $this->Forums_Model->getTopicByID($ID_Reply);
             }
             if ($topic) {
                 $vars["ID_Post"] = $topic[0]["ID_Post"];
                 $vars["ID_Forum"] = $topic[0]["ID_Forum"];
                 if ($action === "save") {
                     $vars["title"] = "Re: " . $topic[0]["Title"];
                     $vars["content"] = "";
                     $vars["href"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . "new");
                     $vars["hrefURL"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh);
                 } elseif ($action === "edit") {
                     $vars["title"] = $topic[0]["Title"];
                     $vars["content"] = $topic[0]["Content"];
                     $vars["ID_Topic"] = $topic[0]["ID_Parent"];
                     $vars["hrefURL"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . "page" . _sh . $page);
                     $vars["href"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . "edit" . _sh . $ID_Reply . _sh . $page);
                 }
                 $vars["action"] = $action;
                 $vars["view"] = $this->view("reply", $this->application, TRUE);
                 $this->template("content", $vars);
             }
         } else {
             if (!POST("title")) {
                 $alert = getAlert("You must to write a title");
             } elseif (isEmptyTiny(POST("content", "decode", FALSE))) {
                 $alert = getAlert("You must to a write a content");
             } elseif (strlen(POST("title")) < 4) {
                 $alert = getAlert("You must to write a valid title");
             } elseif (!POST("content")) {
                 $alert = getAlert("You must to a write a content");
             } elseif (strlen(POST("content")) < 4) {
                 $alert = getAlert("You must to write a valid content");
             } elseif (isInjection(POST("content", "decode", FALSE))) {
                 $alert = getAlert("The content is invalid");
             } elseif (isEmptyTiny(POST("content", "decode", FALSE))) {
                 $alert = getAlert("The content is invalid");
             } elseif (isVulgar(strtolower(POST("title")))) {
                 $alert = getAlert("The title is vulgar");
             } elseif (isVulgar(strtolower(POST("content")))) {
                 $alert = getAlert("The content is vulgar");
             } elseif (isSPAM(POST("content"))) {
                 $alert = getAlert("The content has spam");
             }
             if (isset($alert)) {
                 $vars["alert"] = $alert;
                 $vars["ID_Post"] = POST("ID_Post");
                 $vars["ID_Forum"] = POST("ID_Forum");
                 $vars["title"] = POST("title");
                 $vars["content"] = cleanTiny(POST("content", "decode", FALSE));
                 $vars["action"] = $action;
                 if ($action === "save") {
                     $vars["href"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . "new");
                     $vars["hrefURL"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh);
                 } elseif ($action === "edit") {
                     $vars["ID_Topic"] = POST("ID_Topic");
                     $vars["href"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . "edit" . _sh . $ID_Reply . _sh . $page);
                     $vars["hrefURL"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . "page" . _sh . $page);
                 }
                 $vars["view"] = $this->view("reply", $this->application, TRUE);
                 $this->template("content", $vars);
             } else {
                 if ($action === "save") {
                     $success = $this->Forums_Model->setReply();
                     if ($success > 0) {
                         $page = $this->Forums_Model->getPage($ID_Topic);
                         $reply = $this->Forums_Model->addUserReply();
                     } else {
                         $page = 1;
                     }
                 } elseif ($action === "edit") {
                     $success = $this->Forums_Model->editReply();
                 }
                 $vars["success"] = $success;
                 $vars["action"] = $action;
                 if ($action === "save") {
                     $vars["href"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . _page . _sh . $page . _sh . "#bottom");
                 } elseif ($action === "edit") {
                     $vars["href"] = path($this->application . _sh . segment(2) . _sh . $ID_Topic . _sh . _page . _sh . $page);
                 }
                 $vars["view"] = $this->view("reply", $this->application, TRUE);
                 $this->template("content", $vars);
             }
         }
     } else {
         redirect($this->application . _sh . segment(2) . _sh . segment(3) . _sh);
     }
 }
Example #2
0
 public function editReply()
 {
     $ID_Post = POST("ID_Post");
     $title = POST("title", "decode", "escape");
     $content = cleanTiny(POST("content", "decode", FALSE));
     $nice = nice($title);
     $date1 = now(4);
     $date2 = now(2);
     $hour = date("H:i:s", $date1);
     $this->Db->call("updateReplyTopic('{$ID_Post}', '{$title}', '{$nice}', '{$content}', '{$date1}', '{$date2}', '{$hour}')");
     return TRUE;
 }