index.php
changeset 228 b0a4d179be85
parent 195 eec079676fe7
parent 220 d44492e34ab3
child 248 ed13b72b13cc
equal deleted inserted replaced
197:90b7a52bea45 228:b0a4d179be85
    13  *
    13  *
    14  */
    14  */
    15 
    15 
    16   // Set up gzip encoding before any output is sent
    16   // Set up gzip encoding before any output is sent
    17   
    17   
    18   $aggressive_optimize_html = true;
    18   $aggressive_optimize_html = false;
    19   
    19   
    20   global $do_gzip;
    20   global $do_gzip;
    21   $do_gzip = true;
    21   $do_gzip = true;
    22   
    22   
    23   if(isset($_SERVER['PATH_INFO'])) $v = $_SERVER['PATH_INFO'];
    23   if(isset($_SERVER['PATH_INFO'])) $v = $_SERVER['PATH_INFO'];
    87           if(!isset($_GET['id']) || ( isset($_GET['id']) && !preg_match('#^([0-9]+)$#', $_GET['id']) )) { echo '<p>Invalid comment ID</p>'; break; }
    87           if(!isset($_GET['id']) || ( isset($_GET['id']) && !preg_match('#^([0-9]+)$#', $_GET['id']) )) { echo '<p>Invalid comment ID</p>'; break; }
    88           $q = $db->sql_query('SELECT subject,comment_data,comment_id FROM '.table_prefix.'comments WHERE comment_id='.$_GET['id']);
    88           $q = $db->sql_query('SELECT subject,comment_data,comment_id FROM '.table_prefix.'comments WHERE comment_id='.$_GET['id']);
    89           if(!$q) $db->_die('The comment data could not be selected.');
    89           if(!$q) $db->_die('The comment data could not be selected.');
    90           $row = $db->fetchrow();
    90           $row = $db->fetchrow();
    91           $db->free_result();
    91           $db->free_result();
       
    92           $row['subject'] = str_replace('\'', '&#039;', $row['subject']);
    92           echo '<form action="'.makeUrl($paths->page, 'do=comments&amp;sub=savecomment').'" method="post">';
    93           echo '<form action="'.makeUrl($paths->page, 'do=comments&amp;sub=savecomment').'" method="post">';
    93           echo "<br /><div class='tblholder'><table border='0' width='100%' cellspacing='1' cellpadding='4'>
    94           echo "<br /><div class='tblholder'><table border='0' width='100%' cellspacing='1' cellpadding='4'>
    94                   <tr><td class='row1'>Subject:</td><td class='row1'><input type='text' name='subj' value='{$row['subject']}' /></td></tr>
    95                   <tr><td class='row1'>" . $lang->get('comment_postform_field_subject') . "</td><td class='row1'><input type='text' name='subj' value='{$row['subject']}' /></td></tr>
    95                   <tr><td class='row2'>Comment:</td><td class='row2'><textarea rows='10' cols='40' style='width: 98%;' name='text'>{$row['comment_data']}</textarea></td></tr>
    96                   <tr><td class='row2'>" . $lang->get('comment_postform_field_comment') . "</td><td class='row2'><textarea rows='10' cols='40' style='width: 98%;' name='text'>{$row['comment_data']}</textarea></td></tr>
    96                   <tr><td class='row1' colspan='2' class='row1' style='text-align: center;'><input type='hidden' name='id' value='{$row['comment_id']}' /><input type='submit' value='Save Changes' /></td></tr>
    97                   <tr><td class='row1' colspan='2' class='row1' style='text-align: center;'><input type='hidden' name='id' value='{$row['comment_id']}' /><input type='submit' value='" . $lang->get('etc_save_changes') . "' /></td></tr>
    97                 </table></div>";
    98                 </table></div>";
    98           echo '</form>';
    99           echo '</form>';
    99           break;
   100           break;
   100         case 'savecomment':
   101         case 'savecomment':
   101           if(empty($_POST['subj']) || empty($_POST['text'])) { echo '<p>Invalid request</p>'; break; }
   102           if(empty($_POST['subj']) || empty($_POST['text'])) { echo '<p>Invalid request</p>'; break; }
   122       $template->header();
   123       $template->header();
   123       if(isset($_POST['_preview']))
   124       if(isset($_POST['_preview']))
   124       {
   125       {
   125         $text = $_POST['page_text'];
   126         $text = $_POST['page_text'];
   126         echo PageUtils::genPreview($_POST['page_text']);
   127         echo PageUtils::genPreview($_POST['page_text']);
   127       }
   128         $text = htmlspecialchars($text);
   128       else $text = RenderMan::getPage($paths->cpage['urlname_nons'], $paths->namespace, 0, false, false, false, false);
   129       }
       
   130       else
       
   131       {
       
   132         $text = RenderMan::getPage($paths->cpage['urlname_nons'], $paths->namespace, 0, false, false, false, false);
       
   133       }
   129       echo '
   134       echo '
   130         <form action="'.makeUrl($paths->page, 'do=edit').'" method="post" enctype="multipart/form-data">
   135         <form action="'.makeUrl($paths->page, 'do=edit').'" method="post" enctype="multipart/form-data">
   131         <br />
   136         <br />
   132         <textarea name="page_text" rows="20" cols="60" style="width: 97%;">'.$text.'</textarea><br />
   137         <textarea name="page_text" rows="20" cols="60" style="width: 97%;">'.$text.'</textarea><br />
   133         <br />
   138         <br />
   134         ';
   139         ';
   135       if($paths->wiki_mode)
   140       if($paths->wiki_mode)
   136         echo 'Edit summary: <input name="edit_summary" type="text" size="40" /><br /><label><input type="checkbox" name="minor" /> This is a minor edit</label><br />';  
   141         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 />';  
   137       echo '<br />
   142       echo '<br />
   138           <input type="submit" name="_save" value="Save changes" style="font-weight: bold;" />
   143           <input type="submit" name="_save"    value="' . $lang->get('editor_btn_save') . '" style="font-weight: bold;" />
   139           <input type="submit" name="_preview" value="Preview changes" />
   144           <input type="submit" name="_preview" value="' . $lang->get('editor_btn_preview') . '" />
   140           <input type="submit" name="_revert" value="Revert changes" />
   145           <input type="submit" name="_revert"  value="' . $lang->get('editor_btn_revert') . '" />
   141           <input type="submit" name="_cancel" value="Cancel" />
   146           <input type="submit" name="_cancel"  value="' . $lang->get('editor_btn_cancel') . '" />
   142         </form>
   147         </form>
   143       ';
   148       ';
   144       if ( getConfig('wiki_edit_notice') == '1' )
   149       if ( getConfig('wiki_edit_notice') == '1' )
   145       {
   150       {
   146         $notice = getConfig('wiki_edit_notice_text');
   151         $notice = getConfig('wiki_edit_notice_text');
   154       echo '
   159       echo '
   155         <form action="'.makeUrl($paths->page, 'do=edit').'" method="post">
   160         <form action="'.makeUrl($paths->page, 'do=edit').'" method="post">
   156         <br />
   161         <br />
   157         <textarea readonly="readonly" name="page_text" rows="20" cols="60" style="width: 97%;">'.$text.'</textarea>';
   162         <textarea readonly="readonly" name="page_text" rows="20" cols="60" style="width: 97%;">'.$text.'</textarea>';
   158       echo '<br />
   163       echo '<br />
   159           <input type="submit" name="_cancel" value="Close viewer" />
   164           <input type="submit" name="_cancel" value="' . $lang->get('editor_btn_closeviewer') . '" />
   160         </form>
   165         </form>
   161       ';
   166       ';
   162       $template->footer();
   167       $template->footer();
   163       break;
   168       break;
   164     case 'history':
   169     case 'history':
   196       echo $c[1];
   201       echo $c[1];
   197       $template->footer();
   202       $template->footer();
   198       break;
   203       break;
   199     case 'moreoptions':
   204     case 'moreoptions':
   200       $template->header();
   205       $template->header();
   201       echo '<div class="menu_nojs" style="width: 150px; padding: 0;"><ul style="display: block;"><li><div class="label">More options for this page</div><div style="clear: both;"></div></li>'.$template->tpl_strings['TOOLBAR_EXTRAS'].'</ul></div>';
   206       echo '<div class="menu_nojs" style="width: 150px; padding: 0;"><ul style="display: block;"><li><div class="label">' . $lang->get('ajax_lbl_moreoptions_nojs') . '</div><div style="clear: both;"></div></li>'.$template->toolbar_menu.'</ul></div>';
   202       $template->footer();
   207       $template->footer();
   203       break;
   208       break;
   204     case 'protect':
   209     case 'protect':
   205       if (!isset($_REQUEST['level'])) die_friendly('Invalid request', '<p>No protection level specified</p>');
   210       if (!isset($_REQUEST['level'])) die_friendly('Invalid request', '<p>No protection level specified</p>');
   206       if(!empty($_POST['reason']))
   211       if(!empty($_POST['reason']))
   207       {
   212       {
   208         if(!preg_match('#^([0-2]*){1}$#', $_POST['level'])) die_friendly('Error protecting page', '<p>Request validation failed</p>');
   213         if(!preg_match('#^([0-2]*){1}$#', $_POST['level'])) die_friendly('Error protecting page', '<p>Request validation failed</p>');
   209         PageUtils::protect($paths->cpage['urlname_nons'], $paths->namespace, intval($_POST['level']), $_POST['reason']);
   214         PageUtils::protect($paths->cpage['urlname_nons'], $paths->namespace, intval($_POST['level']), $_POST['reason']);
   210         die_friendly('Page protected', '<p>The protection setting has been applied. <a href="'.makeUrl($paths->page).'">Return to the page</a>.</p>');
   215         
       
   216         die_friendly($lang->get('page_protect_lbl_success_title'), '<p>' . $lang->get('page_protect_lbl_success_body', array( 'page_link' => makeUrl($paths->page) )) . '</p>');
   211       }
   217       }
   212       $template->header();
   218       $template->header();
   213       ?>
   219       ?>
   214       <form action="<?php echo makeUrl($paths->page, 'do=protect'); ?>" method="post">
   220       <form action="<?php echo makeUrl($paths->page, 'do=protect'); ?>" method="post">
   215         <input type="hidden" name="level" value="<?php echo $_REQUEST['level']; ?>" />
   221         <input type="hidden" name="level" value="<?php echo $_REQUEST['level']; ?>" />
   216         <?php if(isset($_POST['reason'])) echo '<p style="color: red;">Error: you must enter a reason for protecting this page.</p>'; ?>
   222         <?php if(isset($_POST['reason'])) echo '<p style="color: red;">' . $lang->get('page_protect_err_need_reason') . '</p>'; ?>
   217         <p>Reason for protecting the page:</p>
   223         <p><?php echo $lang->get('page_protect_lbl_reason'); ?></p>
   218         <p><input type="text" name="reason" size="40" /><br />
   224         <p><input type="text" name="reason" size="40" /><br />
   219            Protecion level to be applied: <b><?php
   225            <?php echo $lang->get('page_protect_lbl_level'); ?> <b><?php
   220              switch($_REQUEST['level'])
   226              switch($_REQUEST['level'])
   221              {
   227              {
   222                case '0':
   228                case '0':
   223                  echo 'No protection';
   229                  echo $lang->get('page_protect_lbl_level_none');
   224                  break;
   230                  break;
   225                case '1':
   231                case '1':
   226                  echo 'Full protection';
   232                  echo $lang->get('page_protect_lbl_level_full');
   227                  break;
   233                  break;
   228                case '2':
   234                case '2':
   229                  echo 'Semi-protection';
   235                  echo $lang->get('page_protect_lbl_level_semi');
   230                  break;
   236                  break;
   231                default:
   237                default:
   232                  echo 'None;</b> Warning: request validation will fail after clicking submit<b>';
   238                  echo 'None;</b> Warning: request validation will fail after clicking submit<b>';
   233              }
   239              }
   234            ?></b></p>
   240            ?></b></p>
   235         <p><input type="submit" value="Protect page" style="font-weight: bold;" /></p> 
   241         <p><input type="submit" value="<?php echo htmlspecialchars($lang->get('page_protect_btn_submit')) ?>" style="font-weight: bold;" /></p> 
   236       </form>
   242       </form>
   237       <?php
   243       <?php
   238       $template->footer();
   244       $template->footer();
   239       break;
   245       break;
   240     case 'rename':
   246     case 'rename':
   241       if(!empty($_POST['newname']))
   247       if(!empty($_POST['newname']))
   242       {
   248       {
   243         $r = PageUtils::rename($paths->cpage['urlname_nons'], $paths->namespace, $_POST['newname']);
   249         $r = PageUtils::rename($paths->cpage['urlname_nons'], $paths->namespace, $_POST['newname']);
   244         die_friendly('Page renamed', '<p>'.nl2br($r).' <a href="'.makeUrl($paths->page).'">Return to the page</a>.</p>');
   250         die_friendly('Page renamed', '<p>'.nl2br($r).' <a href="'.makeUrl($paths->page).'">' . $lang->get('etc_return_to_page') . '</a>.</p>');
   245       }
   251       }
   246       $template->header();
   252       $template->header();
   247       ?>
   253       ?>
   248       <form action="<?php echo makeUrl($paths->page, 'do=rename'); ?>" method="post">
   254       <form action="<?php echo makeUrl($paths->page, 'do=rename'); ?>" method="post">
   249         <?php if(isset($_POST['newname'])) echo '<p style="color: red;">Error: you must enter a new name for this page.</p>'; ?>
   255         <?php if(isset($_POST['newname'])) echo '<p style="color: red;">' . $lang->get('page_rename_err_need_name') . '</p>'; ?>
   250         <p>Please enter a new name for this page:</p>
   256         <p><?php echo $lang->get('page_rename_lbl'); ?></p>
   251         <p><input type="text" name="newname" size="40" /></p>
   257         <p><input type="text" name="newname" size="40" /></p>
   252         <p><input type="submit" value="Rename page" style="font-weight: bold;" /></p> 
   258         <p><input type="submit" value="<?php echo htmlspecialchars($lang->get('page_rename_btn_submit')); ?>" style="font-weight: bold;" /></p> 
   253       </form>
   259       </form>
   254       <?php
   260       <?php
   255       $template->footer();    
   261       $template->footer();    
   256       break;
   262       break;
   257     case 'flushlogs':
   263     case 'flushlogs':
   258       if(!$session->get_permissions('clear_logs')) die_friendly('Access denied', '<p>Flushing the logs for a page <u>requires</u> administrative rights.</p>');
   264       if(!$session->get_permissions('clear_logs'))
       
   265       {
       
   266         die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('etc_access_denied') . '</p>');
       
   267       }
   259       if(isset($_POST['_downthejohn']))
   268       if(isset($_POST['_downthejohn']))
   260       {
   269       {
   261         $template->header();
   270         $template->header();
   262           $result = PageUtils::flushlogs($paths->cpage['urlname_nons'], $paths->namespace);
   271           $result = PageUtils::flushlogs($paths->cpage['urlname_nons'], $paths->namespace);
   263           echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">Return to the page</a>.</p>';
   272           echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">' . $lang->get('etc_return_to_page') . '</a>.</p>';
   264         $template->footer();
   273         $template->footer();
   265         break;
   274         break;
   266       }
   275       }
   267       $template->header();
   276       $template->header();
   268         ?>
   277         ?>
   269         <form action="<?php echo makeUrl($paths->page, 'do=flushlogs'); ?>" method="post">
   278         <form action="<?php echo makeUrl($paths->page, 'do=flushlogs'); ?>" method="post">
   270           <h3>You are about to <span style="color: red;">destroy</span> all logged edits and actions on this page.</h3>
   279            <?php echo $lang->get('page_flushlogs_warning_stern'); ?>
   271            <p>Unlike deleting or editing this page, this action is <u>not reversible</u>! You should only do this if you are desparate for
   280            <p><input type="submit" name="_downthejohn" value="<?php echo htmlspecialchars($lang->get('page_flushlogs_btn_submit')); ?>" style="color: red; font-weight: bold;" /></p>
   272               database space.</p>
       
   273            <p>Do you really want to continue?</p>
       
   274            <p><input type="submit" name="_downthejohn" value="Flush logs" style="color: red; font-weight: bold;" /></p>
       
   275         </form>
   281         </form>
   276         <?php
   282         <?php
   277       $template->footer();
   283       $template->footer();
   278       break;
   284       break;
   279     case 'delvote':
   285     case 'delvote':
   280       if(isset($_POST['_ballotbox']))
   286       if(isset($_POST['_ballotbox']))
   281       {
   287       {
   282         $template->header();
   288         $template->header();
   283         $result = PageUtils::delvote($paths->cpage['urlname_nons'], $paths->namespace);
   289         $result = PageUtils::delvote($paths->cpage['urlname_nons'], $paths->namespace);
   284         echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">Return to the page</a>.</p>';
   290         echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">' . $lang->get('etc_return_to_page') . '</a>.</p>';
   285         $template->footer();
   291         $template->footer();
   286         break;
   292         break;
   287       }
   293       }
   288       $template->header();
   294       $template->header();
   289         ?>
   295         ?>
   290         <form action="<?php echo makeUrl($paths->page, 'do=delvote'); ?>" method="post">
   296         <form action="<?php echo makeUrl($paths->page, 'do=delvote'); ?>" method="post">
   291           <h3>Your vote counts.</h3>
   297            <?php
   292            <p>If you think that this page is not relavent to the content on this site, or if it looks like this page was only created in
   298              echo $lang->get('page_delvote_warning_stern');
   293               an attempt to spam the site, you can request that this page be deleted by an administrator.</p>
   299              echo '<p>';
   294            <p>After you vote, you should leave a comment explaining the reason for your vote, especially if you are the first person to
   300              switch($paths->cpage['delvotes'])
   295               vote against this page.</p>
   301              {
   296            <p>So far, <?php echo ( $paths->cpage['delvotes'] == 1 ) ? $paths->cpage['delvotes'] . ' person has' : $paths->cpage['delvotes'] . ' people have'; ?> voted to delete this page.</p>
   302                case 0:  echo $lang->get('page_delvote_count_zero'); break;
   297            <p><input type="submit" name="_ballotbox" value="Vote to delete this page" /></p>
   303                case 1:  echo $lang->get('page_delvote_count_one'); break;
       
   304                default: echo $lang->get('page_delvote_count_plural', array('delvotes' => $paths->cpage['delvotes'])); break;
       
   305              }
       
   306              echo '</p>';
       
   307            ?>
       
   308            <p><input type="submit" name="_ballotbox" value="<?php echo htmlspecialchars($lang->get('page_delvote_btn_submit')); ?>" /></p>
   298         </form>
   309         </form>
   299         <?php
   310         <?php
   300       $template->footer();
   311       $template->footer();
   301       break;
   312       break;
   302     case 'resetvotes':
   313     case 'resetvotes':
   303       if(!$session->get_permissions('vote_reset')) die_friendly('Access denied', '<p>Resetting the deletion votes against this page <u>requires</u> admin rights.</p>');
   314       if(!$session->get_permissions('vote_reset'))
       
   315       {
       
   316         die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('etc_access_denied') . '</p>');
       
   317       }
   304       if(isset($_POST['_youmaylivealittlelonger']))
   318       if(isset($_POST['_youmaylivealittlelonger']))
   305       {
   319       {
   306         $template->header();
   320         $template->header();
   307           $result = PageUtils::resetdelvotes($paths->cpage['urlname_nons'], $paths->namespace);
   321           $result = PageUtils::resetdelvotes($paths->cpage['urlname_nons'], $paths->namespace);
   308           echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">Return to the page</a>.</p>';
   322           echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">' . $lang->get('etc_return_to_page') . '</a>.</p>';
   309         $template->footer();
   323         $template->footer();
   310         break;
   324         break;
   311       }
   325       }
   312       $template->header();
   326       $template->header();
   313         ?>
   327         ?>
   314         <form action="<?php echo makeUrl($paths->page, 'do=resetvotes'); ?>" method="post">
   328         <form action="<?php echo makeUrl($paths->page, 'do=resetvotes'); ?>" method="post">
   315           <p>This action will reset the number of votes against this page to zero. Are you sure you want to do this?</p>
   329           <p><?php echo $lang->get('ajax_delvote_reset_confirm'); ?></p>
   316           <p><input type="submit" name="_youmaylivealittlelonger" value="Reset votes" /></p>
   330           <p><input type="submit" name="_youmaylivealittlelonger" value="<?php echo htmlspecialchars($lang->get('page_delvote_reset_btn_submit')); ?>" /></p>
   317         </form>
   331         </form>
   318         <?php
   332         <?php
   319       $template->footer();
   333       $template->footer();
   320       break;
   334       break;
   321     case 'deletepage':
   335     case 'deletepage':
   322       if(!$session->get_permissions('delete_page')) die_friendly('Access denied', '<p>Deleting pages <u>requires</u> admin rights.</p>');
   336       if(!$session->get_permissions('delete_page'))
       
   337       {
       
   338         die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('etc_access_denied') . '</p>');
       
   339       }
   323       if(isset($_POST['_adiossucker']))
   340       if(isset($_POST['_adiossucker']))
   324       {
   341       {
   325         $reason = ( isset($_POST['reason']) ) ? $_POST['reason'] : false;
   342         $reason = ( isset($_POST['reason']) ) ? $_POST['reason'] : false;
   326         if ( empty($reason) )
   343         if ( empty($reason) )
   327           $error = 'Please enter a reason for deleting this page.';
   344           $error = $lang->get('ajax_delete_prompt_reason');
   328         else
   345         else
   329         {
   346         {
   330           $template->header();
   347           $template->header();
   331             $result = PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace, $reason);
   348             $result = PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace, $reason);
   332             echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">Return to the page</a>.</p>';
   349             echo '<p>'.$result.' <a href="'.makeUrl($paths->page).'">' . $lang->get('etc_return_to_page') . '</a>.</p>';
   333           $template->footer();
   350           $template->footer();
   334           break;
   351           break;
   335         }
   352         }
   336       }
   353       }
   337       $template->header();
   354       $template->header();
   338         ?>
   355         ?>
   339         <form action="<?php echo makeUrl($paths->page, 'do=deletepage'); ?>" method="post">
   356         <form action="<?php echo makeUrl($paths->page, 'do=deletepage'); ?>" method="post">
   340           <h3>You are about to <span style="color: red;">destroy</span> this page.</h3>
   357            <?php echo $lang->get('page_delete_warning_stern'); ?>
   341            <p>While the deletion of the page itself is completely reversible, it is impossible to recover any comments or category information on this page. If this is a file page, the file along with all older revisions of it will be permanently deleted. Also, any custom information that this page is tagged with, such as a custom name, protection status, or additional settings such as whether to allow comments, will be permanently lost.</p>
       
   342            <p>Are you <u>absolutely sure</u> that you want to continue?<br />
       
   343               You will not be asked again.</p>
       
   344            <?php if ( isset($error) ) echo "<p>$error</p>"; ?>
   358            <?php if ( isset($error) ) echo "<p>$error</p>"; ?>
   345            <p>Reason for deleting: <input type="text" name="reason" size="50" /></p>
   359            <p><?php echo $lang->get('page_delete_lbl_reason'); ?> <input type="text" name="reason" size="50" /></p>
   346            <p><input type="submit" name="_adiossucker" value="Delete this page" style="color: red; font-weight: bold;" /></p>
   360            <p><input type="submit" name="_adiossucker" value="<?php echo htmlspecialchars($lang->get('page_delete_btn_submit')); ?>" style="color: red; font-weight: bold;" /></p>
   347         </form>
   361         </form>
   348         <?php
   362         <?php
   349       $template->footer();
   363       $template->footer();
   350       break;
   364       break;
   351     case 'setwikimode':
   365     case 'setwikimode':
   352       if(!$session->get_permissions('set_wiki_mode')) die_friendly('Access denied', '<p>Changing the wiki mode setting <u>requires</u> admin rights.</p>');
   366       if(!$session->get_permissions('set_wiki_mode'))
       
   367       {
       
   368         die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('etc_access_denied') . '</p>');
       
   369       }
   353       if ( isset($_POST['finish']) )
   370       if ( isset($_POST['finish']) )
   354       {
   371       {
   355         $level = intval($_POST['level']);
   372         $level = intval($_POST['level']);
   356         if ( !in_array($level, array(0, 1, 2) ) )
   373         if ( !in_array($level, array(0, 1, 2) ) )
   357         {
   374         {
   358           die_friendly('Invalid request', '<p>Level not specified</p>');
   375           die_friendly('Invalid request', '<p>Level not specified</p>');
   359         }
   376         }
   360         $q = $db->sql_query('UPDATE '.table_prefix.'pages SET wiki_mode=' . $level . ' WHERE urlname=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND namespace=\'' . $paths->namespace . '\';');
   377         $q = $db->sql_query('UPDATE '.table_prefix.'pages SET wiki_mode=' . $level . ' WHERE urlname=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND namespace=\'' . $paths->namespace . '\';');
   361         if ( !$q )
   378         if ( !$q )
   362           $db->_die();
   379           $db->_die();
   363         redirect(makeUrl($paths->page), htmlspecialchars($paths->cpage['name']), 'Wiki mode for this page has been set. Redirecting you to the page...', 2);
   380         redirect(makeUrl($paths->page), htmlspecialchars($paths->cpage['name']), $lang->get('page_wikimode_success_redirect'), 2);
   364       }
   381       }
   365       else
   382       else
   366       {
   383       {
   367         $template->header();
   384         $template->header();
   368         if(!isset($_GET['level']) || ( isset($_GET['level']) && !preg_match('#^([0-9])$#', $_GET['level']))) die_friendly('Invalid request', '<p>Level not specified</p>');
   385         if(!isset($_GET['level']) || ( isset($_GET['level']) && !preg_match('#^([0-9])$#', $_GET['level']))) die_friendly('Invalid request', '<p>Level not specified</p>');
   372             die_friendly('Invalid request', '<p>Level not specified</p>');
   389             die_friendly('Invalid request', '<p>Level not specified</p>');
   373           }
   390           }
   374         echo '<form action="' . makeUrl($paths->page, 'do=setwikimode', true) . '" method="post">';
   391         echo '<form action="' . makeUrl($paths->page, 'do=setwikimode', true) . '" method="post">';
   375         echo '<input type="hidden" name="finish" value="foo" />';
   392         echo '<input type="hidden" name="finish" value="foo" />';
   376         echo '<input type="hidden" name="level" value="' . $level . '" />';
   393         echo '<input type="hidden" name="level" value="' . $level . '" />';
   377         $level_txt = ( $level == 0 ) ? 'disabled' : ( ( $level == 1 ) ? 'enabled' : 'use the global setting' );
   394         $level_txt = ( $level == 0 ) ? 'page_wikimode_level_off' : ( ( $level == 1 ) ? 'page_wikimode_level_on' : 'page_wikimode_level_global' );
   378         $blurb = ( $level == 0 || ( $level == 2 && getConfig('wiki_mode') != '1' ) ) ? 'Because this will disable the wiki behavior on this page, several features, most
   395         $blurb = ( $level == 0 || ( $level == 2 && getConfig('wiki_mode') != '1' ) ) ? 'page_wikimode_blurb_disable' : 'page_wikimode_blurb_enable';
   379            notably the ability for users to vote to have this page deleted, will be disabled as they are not relevant to non-wiki pages. In addition, users will not be able
       
   380            to edit this page unless an ACL rule specifically permits them.' : 'Because this will enable the wiki behavior on this page, users will gain the ability to
       
   381            freely edit this page unless an ACL rule specifically denies them. If your site is public and gets good traffic, you should be aware of the possiblity of vandalism, and you need to be ready to revert
       
   382            malicious edits to this page.';
       
   383         ?>
   396         ?>
   384         <h3>You are changing wiki mode for this page.</h3>
   397         <h3><?php echo $lang->get('page_wikimode_heading'); ?></h3>
   385         <p>Wiki features will be set to <?php echo $level_txt; ?>. <?php echo $blurb; ?></p>
   398         <p><?php echo $lang->get($level_txt) . ' ' . $lang->get($blurb); ?></p>
   386         <p>If you want to continue, please click the button below.</p>
   399         <p><?php echo $lang->get('page_wikimode_warning'); ?></p>
   387         <p><input type="submit" value="Set wiki mode" /></p>
   400         <p><input type="submit" value="<?php echo htmlspecialchars($lang->get('page_wikimode_btn_submit')); ?>" /></p>
   388         <?php
   401         <?php
   389         echo '</form>';
   402         echo '</form>';
   390         $template->footer();
   403         $template->footer();
   391       }
   404       }
   392       break;
   405       break;
   401       $template->footer();
   414       $template->footer();
   402       break;
   415       break;
   403     case 'detag':
   416     case 'detag':
   404       if ( $session->user_level < USER_LEVEL_ADMIN )
   417       if ( $session->user_level < USER_LEVEL_ADMIN )
   405       {
   418       {
   406         die_friendly('Access denied', '<p>You need to be an administrator to detag pages.</p>');
   419         die_friendly($lang->get('etc_access_denied_short'), '<p>' . $lang->get('etc_access_denied') . '</p>');
   407       }
   420       }
   408       if ( $paths->page_exists )
   421       if ( $paths->page_exists )
   409       {
   422       {
   410         die_friendly('Invalid request', '<p>The detag action is only valid for pages that have been deleted in the past.</p>');
   423         die_friendly($lang->get('etc_invalid_request_short'), '<p>' . $lang->get('page_detag_err_page_exists') . '</p>');
   411       }
   424       }
   412       $q = $db->sql_query('DELETE FROM '.table_prefix.'tags WHERE page_id=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND namespace=\'' . $paths->namespace . '\';');
   425       $q = $db->sql_query('DELETE FROM '.table_prefix.'tags WHERE page_id=\'' . $db->escape($paths->cpage['urlname_nons']) . '\' AND namespace=\'' . $paths->namespace . '\';');
   413       if ( !$q )
   426       if ( !$q )
   414         $db->_die('Detag query, index.php:'.__LINE__);
   427         $db->_die('Detag query, index.php:'.__LINE__);
   415       die_friendly('Page detagged', '<p>All stale tags have been removed from this page.</p>');
   428       die_friendly($lang->get('page_detag_success_title'), '<p>' . $lang->get('page_detag_success_body') . '</p>');
   416       break;
   429       break;
   417     case 'aclmanager':
   430     case 'aclmanager':
   418       $data = ( isset($_POST['data']) ) ? $_POST['data'] : Array('mode' => 'listgroups');
   431       $data = ( isset($_POST['data']) ) ? $_POST['data'] : Array('mode' => 'listgroups');
   419       PageUtils::aclmanager($data);
   432       PageUtils::aclmanager($data);
   420       break;
   433       break;