Esempio n. 1
0
     Typeframe::Redirect('Comments on this page are closed.', TYPEF_WEB_DIR . '/', -1);
     return;
 }
 $form = new Form_Handler_Comment();
 if ($form->validate()) {
     $badCaptcha = false;
     if (defined('COMMENTS_REQUIRE_CAPTCHA') && COMMENTS_REQUIRE_CAPTCHA && !Typeframe::User()->loggedIn()) {
         if (!isset($_SESSION['captcha']) || empty($_SESSION['captcha']) || !isset($_POST['captcha']) || $_POST['captcha'] != $_SESSION['captcha']) {
             $badCaptcha = true;
         }
     }
     if ($badCaptcha) {
         $pm->addLoop('errors', array('message' => 'Captcha code was incorrect.'));
         $pm->setVariable('comment', $_POST);
     } else {
         $comment = Model_Comment::Create();
         $comment->setArray($form->input());
         $comment['urlmetaid'] = $_POST['urlmetaid'];
         $comment['userid'] = Typeframe::User()->get('userid');
         $comment->save();
         // TODO: Redirect to the originating page.
         $urlmeta = Model_UrlMeta::Get($section['urlmetaid']);
         Typeframe::Redirect('Comment submitted.', $urlmeta['fullpath']);
     }
 } else {
     //$pm->setVariable('referer', $referer);
     // add user input (as comment) to template
     $pm->setVariable('comment', $_POST);
     // add section to template
     //$pm->setVariable('sectionid', $sectionid);
     // add require captcha flag to template