Changeset 779

Show
Ignore:
Timestamp:
04/30/08 12:50:07 (7 months ago)
Author:
michiel
Message:

move captcha stuff to a plugin

Location:
trunk
Files:
3 added
1 removed
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/common/mvblog.php

    r776 r779  
    584584                                                        <textarea name="comment_content" rows="20" cols="50"><?php if (array_key_exists("comment_content", $_POST)) echo $_POST["comment_content"]; ?></textarea><br /> 
    585585                                                        <?php 
    586                                                                 if ($anoncomments && !array_key_exists("blog_user", $_SESSION) && !array_key_exists("author_email", $_SESSION)) 
    587                                                                         $this->show_captcha(); 
     586                                                                if ($anoncomments && !array_key_exists("blog_user", $_SESSION) && !array_key_exists("author_email", $_SESSION)) { 
     587                                                                        $captcha = $this->plugman->run_hooks("captcha_output", ""); 
     588                                                                        echo $captcha; 
     589                                                                        echo "<input type=\"hidden\" name=\"checkcap\" value=\"1\" />\n"; 
     590                                                                } 
    588591                                                        ?> 
    589592                                                        <script type="text/javascript" language="Javascript1.2" src="common/js/xmlhttp.js"></script> 
     
    916919                $sanitize_options_email        = array("email" => 1); 
    917920                if (array_key_exists("checkcap", $postdata) && $postdata["checkcap"]) { 
    918                         if ($postdata["caphid"] != md5($postdata["captcha"])) 
     921                        $captcha_check = $this->plugman->run_hooks("captcha_check", $postdata); 
     922                        if ($captcha_check) { 
     923                                $captcha_error = 0; 
     924                        } else { 
    919925                                $captcha_error = 1; 
    920                         else 
    921                                 $captcha_error = 0; 
     926                        } 
    922927 
    923928                        /* check if name and email address are already in the database */ 
     
    954959                        if ($row["count"] == 0) { die(gettext("no valid article given")); } 
    955960                        /* check for anon comments on non-anon comments enabled post/blog */ 
    956                         if ($_SESSION["blog_user"]["user_id"] || $_SESSION["author_id"]) { 
     961                        if ((array_key_exists("blog_user", $_SESSION) && $_SESSION["blog_user"]["user_id"]) || (array_key_exists("author_id", $_SESSION) && $_SESSION["author_id"])) { 
    957962                                $anon_user = false; 
    958963                        } else { 
  • trunk/common/mvblog_common.php

    r776 r779  
    11081108        } 
    11091109        /* }}} */ 
    1110         /* show_captcha {{{ */ 
    1111         /** 
    1112          * Show a captcha and hidden input and user input field 
    1113          */ 
    1114         public function show_captcha() { 
    1115                 // generate random text string 
    1116                 $txt = ""; 
    1117                 for ($i=0; $i<6; $i++) { 
    1118                         $set = array(rand(65,90), rand(97,122)); 
    1119                         $txt .= chr($set[rand(0,1)]); 
    1120                 } 
    1121                 $_SESSION["txt"] = $txt; 
    1122                 echo "<img src=\"common/captcha.php\">"; 
    1123                 //create tmp image file 
    1124                 echo "<input type=\"hidden\" name=\"checkcap\" value=\"1\" />\n"; 
    1125                 echo "<input type=\"hidden\" name=\"caphid\" value=\"".md5($txt)."\" />\n"; 
    1126                 echo "<input type=\"text\" name=\"captcha\" style=\"width: 60px;\" />&nbsp;".gettext("Type the text as shown on the left.")."<br /><br />\n"; 
    1127         } 
    1128         /* }}} */ 
    11291110}