Example #1
0
File: post.php Project: ncube/edu
 public function _index($url)
 {
     $id = $url[0];
     if (!empty($url[0])) {
         $data = DB::fetch('post', array('unique_id' => $id));
         if (empty($data)) {
             echo 'Not Found';
             die;
         } else {
             if (!empty($url[1])) {
                 switch ($url[1]) {
                     case 'comment':
                         $post = Input::post();
                         if (!empty($post)) {
                             if (Token::check($post['token'])) {
                                 User::comment($url[0], $post['comment']);
                                 echo 'Commented';
                             } else {
                                 echo 'Security token missing';
                             }
                         } else {
                             Redirect::to('/post/' . $url[0]);
                         }
                         break;
                     default:
                         break;
                 }
             } else {
                 self::init('PostModel', 'post', $url);
             }
         }
     } else {
         Redirect::to('/');
     }
 }
Example #2
0
 public function _index()
 {
     new Protect('ajax');
     $data['success'] = FALSE;
     $data['errors'] = NULL;
     $post = Input::post();
     $post_id = $post['post_id'];
     $content = $post['content'];
     if (empty($post_id)) {
         $data['errors'] = 'Post Id Required';
     } else {
         User::comment($post_id, $content);
         $data['success'] = TRUE;
     }
     return $data;
 }