index.php
changeset 304 e2cb5f1432c8
parent 266 917dcc6c4ceb
parent 286 b2f985e4cef3
child 310 199b9708f4a2
equal deleted inserted replaced
280:dc08c70ca550 304:e2cb5f1432c8
    52   
    52   
    53   if(!isset($_GET['do'])) $_GET['do'] = 'view';
    53   if(!isset($_GET['do'])) $_GET['do'] = 'view';
    54   switch($_GET['do'])
    54   switch($_GET['do'])
    55   {
    55   {
    56     default:
    56     default:
    57       die_friendly('Invalid action', '<p>The action "'.$_GET['do'].'" is not defined. Return to <a href="'.makeUrl($paths->page).'">viewing this page\'s text</a>.</p>');
    57       die_friendly('Invalid action', '<p>The action "'.htmlspecialchars($_GET['do']).'" is not defined. Return to <a href="'.makeUrl($paths->page).'">viewing this page\'s text</a>.</p>');
    58       break;
    58       break;
    59     case 'view':
    59     case 'view':
    60       // echo PageUtils::getpage($paths->page, true, ( (isset($_GET['oldid'])) ? $_GET['oldid'] : false ));
    60       // echo PageUtils::getpage($paths->page, true, ( (isset($_GET['oldid'])) ? $_GET['oldid'] : false ));
    61       $rev_id = ( (isset($_GET['oldid'])) ? intval($_GET['oldid']) : 0 );
    61       $rev_id = ( (isset($_GET['oldid'])) ? intval($_GET['oldid']) : 0 );
    62       $page = new PageProcessor( $paths->cpage['urlname_nons'], $paths->namespace, $rev_id );
    62       $page = new PageProcessor( $paths->cpage['urlname_nons'], $paths->namespace, $rev_id );
   116           break;
   116           break;
   117       }
   117       }
   118       $template->footer();
   118       $template->footer();
   119       break;
   119       break;
   120     case 'edit':
   120     case 'edit':
   121       if(isset($_POST['_cancel'])) { header('Location: '.makeUrl($paths->page)); echo '<html><head><title>Redirecting...</title></head><body>If you haven\'t been redirected yet, <a href="'.makeUrl($paths->page).'">click here</a>.'; break; }
   121       if(isset($_POST['_cancel']))
   122       if(isset($_POST['_save'])) {
   122       {
       
   123         redirect(makeUrl($paths->page), '', '', 0);
       
   124         break;
       
   125       }
       
   126       if(isset($_POST['_save']))
       
   127       {
   123         $e = PageUtils::savepage($paths->cpage['urlname_nons'], $paths->namespace, $_POST['page_text'], $_POST['edit_summary'], isset($_POST['minor']));
   128         $e = PageUtils::savepage($paths->cpage['urlname_nons'], $paths->namespace, $_POST['page_text'], $_POST['edit_summary'], isset($_POST['minor']));
   124         header('Location: '.makeUrl($paths->page)); echo '<html><head><title>Redirecting...</title></head><body>If you haven\'t been redirected yet, <a href="'.makeUrl($paths->page).'">click here</a>.'; break;
   129         if ( $e == 'good' )
       
   130         {
       
   131           redirect(makeUrl($paths->page), $lang->get('editor_msg_save_success_title'), $lang->get('editor_msg_save_success_body'), 3);
       
   132         }
   125       }
   133       }
   126       $template->header();
   134       $template->header();
   127       if(isset($_POST['_preview']))
   135       if(isset($_POST['_preview']))
   128       {
   136       {
   129         $text = $_POST['page_text'];
   137         $text = $_POST['page_text'];
   248       break;
   256       break;
   249     case 'rename':
   257     case 'rename':
   250       if(!empty($_POST['newname']))
   258       if(!empty($_POST['newname']))
   251       {
   259       {
   252         $r = PageUtils::rename($paths->cpage['urlname_nons'], $paths->namespace, $_POST['newname']);
   260         $r = PageUtils::rename($paths->cpage['urlname_nons'], $paths->namespace, $_POST['newname']);
   253         die_friendly('Page renamed', '<p>'.nl2br($r).' <a href="'.makeUrl($paths->page).'">' . $lang->get('etc_return_to_page') . '</a>.</p>');
   261         die_friendly($lang->get('page_rename_success_title'), '<p>'.nl2br($r).' <a href="'.makeUrl($paths->page).'">' . $lang->get('etc_return_to_page') . '</a>.</p>');
   254       }
   262       }
   255       $template->header();
   263       $template->header();
   256       ?>
   264       ?>
   257       <form action="<?php echo makeUrl($paths->page, 'do=rename'); ?>" method="post">
   265       <form action="<?php echo makeUrl($paths->page, 'do=rename'); ?>" method="post">
   258         <?php if(isset($_POST['newname'])) echo '<p style="color: red;">' . $lang->get('page_rename_err_need_name') . '</p>'; ?>
   266         <?php if(isset($_POST['newname'])) echo '<p style="color: red;">' . $lang->get('page_rename_err_need_name') . '</p>'; ?>
   432       break;
   440       break;
   433     case 'aclmanager':
   441     case 'aclmanager':
   434       $data = ( isset($_POST['data']) ) ? $_POST['data'] : Array('mode' => 'listgroups');
   442       $data = ( isset($_POST['data']) ) ? $_POST['data'] : Array('mode' => 'listgroups');
   435       PageUtils::aclmanager($data);
   443       PageUtils::aclmanager($data);
   436       break;
   444       break;
       
   445     case 'sql_report':
       
   446       $rev_id = ( (isset($_GET['oldid'])) ? intval($_GET['oldid']) : 0 );
       
   447       $page = new PageProcessor( $paths->cpage['urlname_nons'], $paths->namespace, $rev_id );
       
   448       $page->send_headers = true;
       
   449       $pagepass = ( isset($_REQUEST['pagepass']) ) ? sha1($_REQUEST['pagepass']) : '';
       
   450       $page->password = $pagepass;
       
   451       $page->send(true);
       
   452       ob_end_clean();
       
   453       ob_start();
       
   454       $db->sql_report();
       
   455       break;
   437   }
   456   }
   438   
   457   
   439   //
   458   //
   440   // Optimize HTML by replacing newlines with spaces (excludes <pre>, <script>, and <style> blocks)
   459   // Optimize HTML by replacing newlines with spaces (excludes <pre>, <script>, and <style> blocks)
   441   //
   460   //
   442   if ($aggressive_optimize_html)
   461   if ($aggressive_optimize_html)
   443   {
   462   {
   444     // Load up the HTML
   463     // Load up the HTML
   445     $html = ob_get_contents();
   464     $html = ob_get_contents();
   446     ob_end_clean();
   465     @ob_end_clean();
   447     
   466     
   448     $html = aggressive_optimize_html($html);
   467     $html = aggressive_optimize_html($html);
   449     
   468     
   450     // Re-enable output buffering to allow the Gzip function (below) to work
   469     // Re-enable output buffering to allow the Gzip function (below) to work
   451     ob_start();
   470     ob_start();