示例#1
0
文件: submit.php 项目: ssrsfs/blg
        $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
        $pm->setVariable('errors', $form->errors());
    }
} else {
    Typeframe::Redirect('Nothing to do.', TYPEF_WEB_DIR . '/', -1);
}