pages)/2;$i++)
- {
- if(!isset($final_pid))
- {
- if ($paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id)) $final_pid = str_replace(' ', '_', $page_id);
- elseif($paths->pages[$i]['name'] == $page_id) $final_pid = $paths->pages[$i]['urlname_nons'];
- elseif(strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons'];
- elseif(strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons'];
- if(isset($final_pid)) { $_POST['name'] = $paths->pages[$i]['name']; $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; }
- }
- }
- if(!isset($final_pid)) { echo 'The page you searched for cannot be found. Back'; return false; }
- $_POST['namespace'] = $ns;
- $_POST['page_id'] = $final_pid;
- if(!isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']])) { echo 'The page you searched for cannot be found. Back'; return false; }
- }
-
- if(isset($_POST['page_id']) && !isset($_POST['cancel']))
- {
- echo '';
}
-function page_Admin_DBBackup()
-{
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
- if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
- {
- $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true);
- echo '' . $lang->get('adm_err_not_auth_title') . '
';
- echo '' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '
';
- return;
- }
-
- if ( ENANO_DBLAYER != 'MYSQL' )
- die('Not supported
- This function is only supported under the MySQL database driver.
');
-
- if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes' && defined('ENANO_DEMO_MODE') )
- {
- redirect(makeUrlComplete('Special', 'Administration'), 'Access denied', 'You\'ve got to be kidding me. Forget it, kid.', 4 );
- }
-
- global $system_table_list;
- if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes')
- {
-
- if(defined('SQL_BACKUP_CRYPT'))
- // Try to increase our time limit
- @set_time_limit(0);
- // Do the actual export
- $aesext = ( defined('SQL_BACKUP_CRYPT') ) ? '.tea' : '';
- $filename = 'enano_backup_' . date('ymd') . '.sql' . $aesext;
- ob_start();
- // Spew some headers
- $headdate = date('F d, Y \a\t h:i a');
- echo <<username}
-
-HEADER;
- // build the table list
- $base = ( isset($_POST['do_system_tables']) ) ? $system_table_list : Array();
- $add = ( isset($_POST['additional_tables'])) ? $_POST['additional_tables'] : Array();
- $tables = array_merge($base, $add);
-
- // Log it!
- $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().', \''.date('d M Y h:i a').'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(implode(', ', $tables)) . '\')');
- if ( !$e )
- $db->_die();
-
- foreach($tables as $i => $t)
- {
- if(!preg_match('#^([a-z0-9_]+)$#i', $t))
- die('Hacking attempt');
- // if($t == table_prefix.'files' && isset($_POST['do_data']))
- // unset($tables[$i]);
- }
- foreach($tables as $t)
- {
- // THE FOLLOWING COMMENT DOES NOT APPLY AS OF 1.0.
- // Sorry folks - this script CAN'T backup enano_files and enano_search_index due to the sheer size of the tables.
- // If encryption is enabled the log data will be excluded too.
- $result = export_table(
- $t,
- isset($_POST['do_struct']),
- ( isset($_POST['do_data']) ),
- false
- ) . "\n";
- if ( !$result )
- {
- $db->_die();
- }
- echo $result;
- }
- $data = ob_get_contents();
- ob_end_clean();
- if(defined('SQL_BACKUP_CRYPT'))
- {
- // Free some memory, we don't need this stuff any more
- $db->close();
- unset($paths, $db, $template, $plugins);
- $tea = new TEACrypt();
- $data = $tea->encrypt($data, $session->private_key);
- }
- header('Content-disposition: attachment, filename="'.$filename.'";');
- header('Content-type: application/transact-sql');
- header('Content-length: '.strlen($data));
- echo $data;
- exit;
- }
- else
- {
- // Show the UI
- echo '';
- ?>
- This page allows you to back up your Enano database should something go miserably wrong.
-
-
Additional tables to export:
-
-
-
-
-
-
- ';
- }
-}
-
function page_Admin_AdminLogout()
{
global $db, $session, $paths, $template, $plugins; // Common objects