public function update($id)
 {
     if (parent::auth()) {
         if ($_SESSION['id'] == $id) {
             $user = User::find($id);
             if ($_POST) {
                 if ($_FILES['picture']) {
                     parent::uploadImage($_FILES['picture'], 'user');
                 }
                 try {
                     $user->update_attributes($_POST);
                     $_SESSION['username'] = $_POST['username'];
                     parent::redirect('site/index');
                 } catch (Exception $e) {
                     if (strstr($e->getMessage(), 'Duplicate entry') == true) {
                         $error = 'Username or Email Has Been Previously Registered';
                     }
                 }
             }
             parent::setHeader('default');
             parent::render('user/update', array('user' => $user, 'error' => isset($error) ? $error : ''));
             parent::setFooter('default');
         } else {
             parent::redirect('site/index');
         }
     } else {
         parent::redirect('site/index');
     }
 }
 public function update($id)
 {
     if (parent::auth()) {
         $post = Post::find($id);
         if ($post->user_id == $_SESSION['id']) {
             if ($_POST) {
                 if (isset($_FILES['picture'])) {
                     parent::uploadImage($_FILES['picture'], 'post');
                 }
                 $post->update_attributes($_POST);
                 parent::redirect('post/view&id=' . $post->id);
             }
             parent::render('post/update', array('post' => $post));
         } else {
             parent::redirect('site/index');
         }
     } else {
         parent::redirect('site/index');
     }
 }