plugins/SpecialAdmin.php
changeset 1103 90225c988124
parent 1099 73abd46f5148
child 1118 e26e74d80c15
equal deleted inserted replaced
1102:faef5e62e1e0 1103:90225c988124
    10 }
    10 }
    11 **!*/
    11 **!*/
    12 
    12 
    13 /*
    13 /*
    14  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    14  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    15  * Version 1.1.6 (Caoineag beta 1)
    15  * Copyright (C) 2006-2009 Dan Fuhry
    16  * Copyright (C) 2006-2008 Dan Fuhry
       
    17  *
    16  *
    18  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    17  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    19  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    18  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    20  *
    19  *
    21  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    20  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
  1480     // Do the actual export
  1479     // Do the actual export
  1481     $aesext = ( defined('SQL_BACKUP_CRYPT') ) ? '.tea' : '';
  1480     $aesext = ( defined('SQL_BACKUP_CRYPT') ) ? '.tea' : '';
  1482     $filename = 'enano_backup_' . enano_date('ymd') . '.sql' . $aesext;
  1481     $filename = 'enano_backup_' . enano_date('ymd') . '.sql' . $aesext;
  1483     ob_start();
  1482     ob_start();
  1484     // Spew some headers
  1483     // Spew some headers
  1485     $headdate = enano_date('F d, Y \a\t h:i a');
  1484     $headdate = enano_date(ED_DATE | ED_TIME);
  1486     echo <<<HEADER
  1485     echo <<<HEADER
  1487 -- Enano CMS SQL backup
  1486 -- Enano CMS SQL backup
  1488 -- Generated on {$headdate} by {$session->username}
  1487 -- Generated on {$headdate} by {$session->username}
  1489 
  1488 
  1490 HEADER;
  1489 HEADER;
  1492     $base = ( isset($_POST['do_system_tables']) ) ? $system_table_list : Array();
  1491     $base = ( isset($_POST['do_system_tables']) ) ? $system_table_list : Array();
  1493     $add  = ( isset($_POST['additional_tables'])) ? $_POST['additional_tables'] : Array();
  1492     $add  = ( isset($_POST['additional_tables'])) ? $_POST['additional_tables'] : Array();
  1494     $tables = array_merge($base, $add);
  1493     $tables = array_merge($base, $add);
  1495     
  1494     
  1496     // Log it!
  1495     // Log it!
  1497     $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'db_backup\', '.time().', \''.enano_date('d M Y h:i a').'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(implode(', ', $tables)) . '\')');
  1496     $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'db_backup\', '.time().', \''.enano_date(ED_DATE | ED_TIME).'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(implode(', ', $tables)) . '\')');
  1498     if ( !$e )
  1497     if ( !$e )
  1499       $db->_die();
  1498       $db->_die();
  1500     
  1499     
  1501     foreach($tables as $i => $t)
  1500     foreach($tables as $i => $t)
  1502     {
  1501     {
  2225           </div>
  2224           </div>
  2226         </td>
  2225         </td>
  2227         <td width="100%" valign="top">
  2226         <td width="100%" valign="top">
  2228           <div class="pad" id="ajaxPageContainer">
  2227           <div class="pad" id="ajaxPageContainer">
  2229           <?php
  2228           <?php
  2230           if(isset($_GET['module'])) 
  2229           if ( isset($_GET['module']) ) 
  2231           {
  2230           {
  2232             // Look for a namespace prefix in the urlname, and assign a different namespace, if necessary
  2231             list($module) = explode('/', $_GET['module']);
  2233             $k = array_keys($paths->nslist);
  2232             list($page_id, $namespace) = RenderMan::strToPageID($module);
  2234             for ( $i = 0; $i < sizeof($paths->nslist); $i++ )
  2233             if ( $namespace != 'Admin' )
  2235             {
  2234             {
  2236               $ln = strlen( $paths->nslist[ $k[ $i ] ] );
  2235               echo '<div class="error-box">Module must be in the Admin namespace</div>';
  2237               if ( substr($_GET['module'], 0, $ln) == $paths->nslist[$k[$i]] )
       
  2238               {
       
  2239                 $ns = $k[$i];
       
  2240                 $nm = substr($_GET['module'], $ln, strlen($_GET['module']));
       
  2241               }
       
  2242             }
  2236             }
  2243             $fname = 'page_'.$ns.'_'.$nm;
  2237             else
  2244             $s = strpos($fname, '?noheaders');
       
  2245             if($s) $fname = substr($fname, 0, $s);
       
  2246             $paths->cpage['module'] = $_GET['module'];
       
  2247             if ( function_exists($fname) && $_GET['module'] != $paths->nslist['Special'] . 'Administration' )
       
  2248             {
  2238             {
  2249               call_user_func($fname);
  2239               $paths->fullpage = $_GET['module'];
       
  2240               $paths->cpage['module'] = $_GET['module'];
       
  2241               $page = new PageProcessor($page_id, $namespace);
       
  2242               $page->send_headers = false;
       
  2243               $page->send();
       
  2244               $paths->fullpage = $paths->page;
  2250             }
  2245             }
  2251           } 
  2246           } 
  2252           else 
  2247           else 
  2253           {
  2248           {
  2254             echo '<script type="text/javascript">document.write(\'<div class="wait-box">Please wait while the administration panel loads. You need to be using a recent browser with AJAX support in order to use Runt.</div>\');</script><noscript><div class="error-box">It looks like Javascript isn\'t enabled in your browser. Please enable Javascript or use a different browser to continue.</div></noscript>';
  2249             echo '<script type="text/javascript">document.write(\'<div class="wait-box">Please wait while the administration panel loads. You need to be using a recent browser with AJAX support in order to use Runt.</div>\');</script><noscript><div class="error-box">It looks like Javascript isn\'t enabled in your browser. Please enable Javascript or use a different browser to continue.</div></noscript>';
  2601             $template->footer();
  2596             $template->footer();
  2602             exit;
  2597             exit;
  2603           }
  2598           }
  2604           if(isset($_GET['ajax']))
  2599           if(isset($_GET['ajax']))
  2605           {
  2600           {
  2606             ob_end_clean();
  2601             @ob_end_clean();
  2607             die('GOOD');
  2602             die('GOOD');
  2608           }
  2603           }
  2609           break;
  2604           break;
  2610         case 'rename';
  2605         case 'rename';
  2611           $newname = $db->escape($_POST['newname']);
  2606           $newname = $db->escape($_POST['newname']);