index.php
changeset 337 491518997ae5
parent 334 c72b545f1304
child 372 5bd429428101
equal deleted inserted replaced
336:bfa2e9c23f03 337:491518997ae5
   128         redirect(makeUrl($paths->page), '', '', 0);
   128         redirect(makeUrl($paths->page), '', '', 0);
   129         break;
   129         break;
   130       }
   130       }
   131       if(isset($_POST['_save']))
   131       if(isset($_POST['_save']))
   132       {
   132       {
   133         $e = PageUtils::savepage($paths->page_id, $paths->namespace, $_POST['page_text'], $_POST['edit_summary'], isset($_POST['minor']));
   133         $captcha_valid = true;
   134         if ( $e == 'good' )
   134         if ( !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' )
   135         {
   135         {
   136           redirect(makeUrl($paths->page), $lang->get('editor_msg_save_success_title'), $lang->get('editor_msg_save_success_body'), 3);
   136           $captcha_valid = false;
       
   137           if ( isset($_POST['captcha_id']) && isset($_POST['captcha_code']) )
       
   138           {
       
   139             $hash_correct = strtolower($session->get_captcha($_POST['captcha_id']));
       
   140             $hash_input   = strtolower($_POST['captcha_code']);
       
   141             if ( $hash_input === $hash_correct )
       
   142               $captcha_valid = true;
       
   143           }
   137         }
   144         }
   138       }
   145         if ( $captcha_valid )
   139       $template->header();
   146         {
       
   147           $e = PageUtils::savepage($paths->page_id, $paths->namespace, $_POST['page_text'], $_POST['edit_summary'], isset($_POST['minor']));
       
   148           if ( $e == 'good' )
       
   149           {
       
   150             redirect(makeUrl($paths->page), $lang->get('editor_msg_save_success_title'), $lang->get('editor_msg_save_success_body'), 3);
       
   151           }
       
   152         }
       
   153       }
       
   154       $template->header();
       
   155       if ( isset($captcha_valid) )
       
   156       {
       
   157         echo '<div class="usermessage">' . $lang->get('editor_err_captcha_wrong') . '</div>';
       
   158       }
   140       if(isset($_POST['_preview']))
   159       if(isset($_POST['_preview']))
   141       {
   160       {
   142         $text = $_POST['page_text'];
   161         $text = $_POST['page_text'];
   143         echo PageUtils::genPreview($_POST['page_text']);
   162         echo PageUtils::genPreview($_POST['page_text']);
   144         $text = htmlspecialchars($text);
   163         $text = htmlspecialchars($text);
   151         <form action="'.makeUrl($paths->page, 'do=edit').'" method="post" enctype="multipart/form-data">
   170         <form action="'.makeUrl($paths->page, 'do=edit').'" method="post" enctype="multipart/form-data">
   152         <br />
   171         <br />
   153         <textarea name="page_text" rows="20" cols="60" style="width: 97%;">'.$text.'</textarea><br />
   172         <textarea name="page_text" rows="20" cols="60" style="width: 97%;">'.$text.'</textarea><br />
   154         <br />
   173         <br />
   155         ';
   174         ';
   156       if($paths->wiki_mode)
   175       echo $lang->get('editor_lbl_edit_summary') . ' <input name="edit_summary" type="text" size="40" /><br /><label><input type="checkbox" name="minor" /> ' . $lang->get('editor_lbl_minor_edit_field') . '</label><br />';
   157         echo $lang->get('editor_lbl_edit_summary') . ' <input name="edit_summary" type="text" size="40" /><br /><label><input type="checkbox" name="minor" /> This is a minor edit</label><br />';  
   176       if ( !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' )
       
   177       {
       
   178         echo '<br /><table border="0"><tr><td>';
       
   179         echo '<b>' . $lang->get('editor_lbl_field_captcha') . '</b><br />'
       
   180              . '<br />'
       
   181              . $lang->get('editor_msg_captcha_pleaseenter') . '<br /><br />'
       
   182              . $lang->get('editor_msg_captcha_blind');
       
   183         echo '</td><td>';
       
   184         $hash = $session->make_captcha();
       
   185         echo '<img src="' . makeUrlNS('Special', "Captcha/$hash") . '" onclick="this.src+=\'/a\'" style="cursor: pointer;" /><br />';
       
   186         echo '<input type="hidden" name="captcha_id" value="' . $hash . '" />';
       
   187         echo $lang->get('editor_lbl_field_captcha_code') . ' <input type="text" name="captcha_code" value="" size="9" />';
       
   188         echo '</td></tr></table>';
       
   189       }
   158       echo '<br />
   190       echo '<br />
   159           <input type="submit" name="_save"    value="' . $lang->get('editor_btn_save') . '" style="font-weight: bold;" />
   191           <input type="submit" name="_save"    value="' . $lang->get('editor_btn_save') . '" style="font-weight: bold;" />
   160           <input type="submit" name="_preview" value="' . $lang->get('editor_btn_preview') . '" />
   192           <input type="submit" name="_preview" value="' . $lang->get('editor_btn_preview') . '" />
   161           <input type="submit" name="_revert"  value="' . $lang->get('editor_btn_revert') . '" />
   193           <input type="submit" name="_revert"  value="' . $lang->get('editor_btn_revert') . '" />
   162           <input type="submit" name="_cancel"  value="' . $lang->get('editor_btn_cancel') . '" />
   194           <input type="submit" name="_cancel"  value="' . $lang->get('editor_btn_cancel') . '" />