La date/heure actuelle est Mer Mai 08, 2024 3:14 pm

Conditions d'utilisation du forum

Utilisation du forum. En vous inscrivant à ce forum, vous vous engagez à en faire un usage conforme, et à vous abstenir de poster tout contenu agressif, insultant, diffamant, incitant à la haine, ou contrevenant aux lois et règlements en vigueur. Vous vous engagez à ne pas poster de messages incitant ou évoquant des pratiques illégales, ou contrevenant aux conditions générales d’utilisation du service.

Les modérateurs et administrateurs de ce forum  s’efforceront de supprimer ou éditer les messages à caractère répréhensible qui pourraient être postés sur le forum. Vous reconnaissez que tous les messages postés sur ce forum expriment l’opinion de leurs auteurs respectifs, et non celle des modérateurs ou administrateurs.

Afin d’assurer la modération de ce forum, tout message contrevenant aux dispositions précédentes pourra être édité ou supprimé sans préavis par les modérateurs et administrateurs du forum. Tout abus peut également être sanctionné par un bannissement ou une suppression du compte. Nous nous réservons la possibilité d’informer votre fournisseur d’accès et/ou les autorités judiciaires de tout comportement malveillant.

Recueil de vos données personnelles. En vous inscrivant sur ce forum, vous acceptez que celui-ci recueille certaines données à caractère personnel vous concernant. Ce recueil des données est effectué soit par le biais des informations que vous nous communiquez, soit par l’utilisation des services elle-même, pour des données techniques nécessaires au bon fonctionnement du forum. Vous pouvez à tout moment accéder, modifier ou supprimer les données vous concernant. L'utilisateur de moins de 16 ans certifie avoir obtenu le consentement de son responsable légal afin de procéder à la présente inscription. Pour plus d'informations, nous vous invitons à lire notre politique de confidentialité.

Ce forum utilise des cookies pour stocker des informations sur votre ordinateur. Ces cookies servent uniquement à améliorer le confort d'utilisation. Vous pouvez prendre connaissance de la finalité d'utilisation des cookies sur cette page d’aide. Vous pouvez choisir dans les paramètres de votre navigateur de ne pas activer les cookies, ce choix étant susceptible de perturber le bon fonctionnement du forum.

Ce forum est susceptible de vous envoyer des messages électroniques (e-mail), tels que des notifications d'activité, ou des newsletters, envoyées par Forumactif ou par un administrateur de ce forum. Vous pouvez choisir dans les préférences de votre profil de recevoir ou de ne pas recevoir chacun de ces messages.


En cliquant sur le bouton ' J'accepte le règlement ' ci-dessous :
- Vous reconnaissez avoir lu dans son intégralité le présent règlement ;
- Vous vous engagez à respecter sans réserve le présent règlement ;
- Vous accordez aux modérateurs de ce forum le droit de supprimer, déplacer ou éditer n'importe quel sujet de discussion à tout moment.

ob_end_clean();
ob_flush();

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
// include($phpbb_root_path . 'common.' . $phpEx);
// include($phpbb_root_path . 'includes/acp/acp_database.' . $phpEx);

global $table_prefix;

@set_time_limit(1200);
@set_time_limit(0);
$time = time();

$store = false;
$download = true;
$format = 'gzip';
$filename = 'backup_' . $time . '_' . unique_id();

$type = 'full';
$table = array(
"{$table_prefix}acl_groups", "{$table_prefix}acl_options", "{$table_prefix}acl_roles", "{$table_prefix}acl_roles_data", "{$table_prefix}acl_users", "{$table_prefix}attachments", "{$table_prefix}banlist",
"{$table_prefix}bbcodes", "{$table_prefix}bookmarks", "{$table_prefix}bots", "{$table_prefix}config", "{$table_prefix}confirm", "{$table_prefix}disallow", "{$table_prefix}drafts", "{$table_prefix}extension_groups",
"{$table_prefix}extensions", "{$table_prefix}forums", "{$table_prefix}forums_access", "{$table_prefix}forums_track", "{$table_prefix}forums_watch", "{$table_prefix}groups", "{$table_prefix}icons",
"{$table_prefix}lang", "{$table_prefix}log", "{$table_prefix}moderator_cache", "{$table_prefix}modules", "{$table_prefix}poll_options", "{$table_prefix}poll_votes", "{$table_prefix}posts",
"{$table_prefix}privmsgs", "{$table_prefix}privmsgs_folder", "{$table_prefix}privmsgs_rules", "{$table_prefix}privmsgs_to", "{$table_prefix}profile_fields", "{$table_prefix}profile_fields_data",
"{$table_prefix}profile_fields_lang", "{$table_prefix}profile_lang", "{$table_prefix}ranks", "{$table_prefix}reports", "{$table_prefix}reports_reasons", "{$table_prefix}search_results",
"{$table_prefix}search_wordlist", "{$table_prefix}search_wordmatch", "{$table_prefix}sessions", "{$table_prefix}sessions_keys", "{$table_prefix}sitelist", "{$table_prefix}smilies", "{$table_prefix}styles",
"{$table_prefix}styles_imageset", "{$table_prefix}styles_imageset_data", "{$table_prefix}styles_template", "{$table_prefix}styles_template_data", "{$table_prefix}styles_theme", "{$table_prefix}topics",
"{$table_prefix}topics_posted", "{$table_prefix}topics_track", "{$table_prefix}topics_watch", "{$table_prefix}user_group", "{$table_prefix}users", "{$table_prefix}warnings", "{$table_prefix}words", "{$table_prefix}zebra");
$where = 'download';
$structure = true;
$schema_data = true;

$extractor = new mysql_extractor($download, $store, $format, $filename, $time);

$extractor->write_start($table_prefix);

foreach ($table as $table_name)
{
// Get the table structure
if ($structure)
{
$extractor->write_table($table_name);
}
else
{
$extractor->flush('TRUNCATE TABLE ' . $table_name . ";\n");
}

// Data
if ($schema_data)
{
$extractor->write_data($table_name);
}
}

$extractor->write_end();

exit;

/**
* @package acp
*/
class acp_database
{
var $u_action;

function main($id, $mode)
{
global $cache, $db, $user, $auth, $template, $table_prefix;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;

$user->add_lang('acp/database');

$this->tpl_name = 'acp_database';
$this->page_title = 'ACP_DATABASE';

$action = request_var('action', '');
$submit = (isset($_POST['submit'])) ? true : false;

$template->assign_vars(array(
'MODE' => $mode
));

switch ($mode)
{
case 'backup':

$this->page_title = 'ACP_BACKUP';

switch ($action)
{
case 'download':
$type = request_var('type', '');
$table = request_var('table', array(''));
$format = request_var('method', '');
$where = request_var('where', '');

if (!sizeof($table))
{
trigger_error($user->lang['TABLE_SELECT_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
}

$store = $download = $structure = $schema_data = false;

if ($where == 'store_and_download' || $where == 'store')
{
$store = true;
}

if ($where == 'store_and_download' || $where == 'download')
{
$download = true;
}

if ($type == 'full' || $type == 'structure')
{
$structure = true;
}

if ($type == 'full' || $type == 'data')
{
$schema_data = true;
}

@set_time_limit(1200);
@set_time_limit(0);

$time = time();

$filename = 'backup_' . $time . '_' . unique_id();
switch ($db->sql_layer)
{
case 'mysqli':
case 'mysql4':
case 'mysql':
$extractor = new mysql_extractor($download, $store, $format, $filename, $time);
break;

case 'sqlite':
$extractor = new sqlite_extractor($download, $store, $format, $filename, $time);
break;

case 'postgres':
$extractor = new postgres_extractor($download, $store, $format, $filename, $time);
break;

case 'oracle':
$extractor = new oracle_extractor($download, $store, $format, $filename, $time);
break;

case 'mssql':
case 'mssql_odbc':
case 'mssqlnative':
$extractor = new mssql_extractor($download, $store, $format, $filename, $time);
break;

case 'firebird':
$extractor = new firebird_extractor($download, $store, $format, $filename, $time);
break;
}

$extractor->write_start($table_prefix);

foreach ($table as $table_name)
{
// Get the table structure
if ($structure)
{
$extractor->write_table($table_name);
}
else
{
// We might wanna empty out all that junk Very Happy
switch ($db->sql_layer)
{
case 'sqlite':
case 'firebird':
$extractor->flush('DELETE FROM ' . $table_name . ";\n");
break;

case 'mssql':
case 'mssql_odbc':
case 'mssqlnative':
$extractor->flush('TRUNCATE TABLE ' . $table_name . "GO\n");
break;

case 'oracle':
$extractor->flush('TRUNCATE TABLE ' . $table_name . "/\n");
break;

default:
$extractor->flush('TRUNCATE TABLE ' . $table_name . ";\n");
break;
}
}

// Data
if ($schema_data)
{
$extractor->write_data($table_name);
}
}

$extractor->write_end();

add_log('admin', 'LOG_DB_BACKUP');

if ($download == true)
{
exit;
}

trigger_error($user->lang['BACKUP_SUCCESS'] . adm_back_link($this->u_action));
break;

default:
include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
$tables = get_tables($db);
asort($tables);
foreach ($tables as $table_name)
{
if (strlen($table_prefix) === 0 || stripos($table_name, $table_prefix) === 0)
{
$template->assign_block_vars('tables', array(
'TABLE' => $table_name
));
}
}
unset($tables);

$template->assign_vars(array(
'U_ACTION' => $this->u_action . '&action=download'
));

$available_methods = array('gzip' => 'zlib', 'bzip2' => 'bz2');

foreach ($available_methods as $type => $module)
{
if (!@extension_loaded($module))
{
continue;
}

$template->assign_block_vars('methods', array(
'TYPE' => $type
));
}

$template->assign_block_vars('methods', array(
'TYPE' => 'text'
));
break;
}
break;

case 'restore':

$this->page_title = 'ACP_RESTORE';

switch ($action)
{
case 'submit':
$delete = request_var('delete', '');
$file = request_var('file', '');

if (!preg_match('#^backup_\d{10,}_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches))
{
trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}

$file_name = $phpbb_root_path . 'store/' . $matches[0];

if (!file_exists($file_name) || !is_readable($file_name))
{
trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}

if ($delete)
{
if (confirm_box(true))
{
unlink($file_name);
add_log('admin', 'LOG_DB_DELETE');
trigger_error($user->lang['BACKUP_DELETE'] . adm_back_link($this->u_action));
}
else
{
confirm_box(false, $user->lang['DELETE_SELECTED_BACKUP'], build_hidden_fields(array('delete' => $delete, 'file' => $file)));
}
}
else
{
$download = request_var('download', '');

if ($download)
{
$name = $matches[0];

switch ($matches[1])
{
case 'sql':
$mimetype = 'text/x-sql';
break;
case 'sql.bz2':
$mimetype = 'application/x-bzip2';
break;
case 'sql.gz':
$mimetype = 'application/x-gzip';
break;
}

header('Pragma: no-cache');
header("Content-Type: $mimetype; name=\"$name\"");
header("Content-disposition: attachment; filename=$name");

@set_time_limit(0);

$fp = @fopen($file_name, 'rb');

if ($fp !== false)
{
while (!feof($fp))
{
echo fread($fp, 8192);
}
fclose($fp);
}

flush();
exit;
}

switch ($matches[1])
{
case 'sql':
$fp = fopen($file_name, 'rb');
$read = 'fread';
$seek = 'fseek';
$eof = 'feof';
$close = 'fclose';
$fgetd = 'fgetd';
break;

case 'sql.bz2':
$fp = bzopen($file_name, 'r');
$read = 'bzread';
$seek = '';
$eof = 'feof';
$close = 'bzclose';
$fgetd = 'fgetd_seekless';
break;

case 'sql.gz':
$fp = gzopen($file_name, 'rb');
$read = 'gzread';
$seek = 'gzseek';
$eof = 'gzeof';
$close = 'gzclose';
$fgetd = 'fgetd';
break;
}

switch ($db->sql_layer)
{
case 'mysql':
case 'mysql4':
case 'mysqli':
case 'sqlite':
while (($sql = $fgetd($fp, ";\n", $read, $seek, $eof)) !== false)
{
$db->sql_query($sql);
}
break;

case 'firebird':
$delim = ";\n";
while (($sql = $fgetd($fp, $delim, $read, $seek, $eof)) !== false)
{
$query = trim($sql);
if (substr($query, 0, Cool === 'SET TERM')
{
$delim = $query[9] . "\n";
continue;
}
$db->sql_query($query);
}
break;

case 'postgres':
$delim = ";\n";
while (($sql = $fgetd($fp, $delim, $read, $seek, $eof)) !== false)
{
$query = trim($sql);

if (substr($query, 0, 13) == 'CREATE DOMAIN')
{
list(, , $domain) = explode(' ', $query);
$sql = "SELECT domain_name
FROM information_schema.domains
WHERE domain_name = '$domain';";
$result = $db->sql_query($sql);
if (!$db->sql_fetchrow($result))
{
$db->sql_query($query);
}
$db->sql_freeresult($result);
}
else
{
$db->sql_query($query);
}

if (substr($query, 0, 4) == 'COPY')
{
while (($sub = $fgetd($fp, "\n", $read, $seek, $eof)) !== '\.')
{
if ($sub === false)
{
trigger_error($user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
pg_put_line($db->db_connect_id, $sub . "\n");
}
pg_put_line($db->db_connect_id, "\\.\n");
pg_end_copy($db->db_connect_id);
}
}
break;

case 'oracle':
while (($sql = $fgetd($fp, "/\n", $read, $seek, $eof)) !== false)
{
$db->sql_query($sql);
}
break;

case 'mssql':
case 'mssql_odbc':
case 'mssqlnative':
while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false)
{
$db->sql_query($sql);
}
break;
}

$close($fp);

// Purge the cache due to updated data
$cache->purge();

add_log('admin', 'LOG_DB_RESTORE');
trigger_error($user->lang['RESTORE_SUCCESS'] . adm_back_link($this->u_action));
break;
}

default:
$methods = array('sql');
$available_methods = array('sql.gz' => 'zlib', 'sql.bz2' => 'bz2');

foreach ($available_methods as $type => $module)
{
if (!@extension_loaded($module))
{
continue;
}
$methods[] = $type;
}

$dir = $phpbb_root_path . 'store/';
$dh = @opendir($dir);

$backup_files = array();

if ($dh)
{
while (($file = readdir($dh)) !== false)
{
if (preg_match('#^backup_(\d{10,})_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches))
{
if (in_array($matches[2], $methods))
{
$backup_files[(int) $matches[1]] = $file;
}
}
}
closedir($dh);
}

if (!empty($backup_files))
{
krsort($backup_files);

foreach ($backup_files as $name => $file)
{
$template->assign_block_vars('files', array(
'FILE' => $file,
'NAME' => $user->format_date($name, 'd-m-Y H:i:s', true),
'SUPPORTED' => true,
));
}
}

$template->assign_vars(array(
'U_ACTION' => $this->u_action . '&action=submit'
));
break;
}
break;
}
}
}

/**
* @package acp
*/
class base_extractor
{
var $fh;
var $fp;
var $write;
var $close;
var $store;
var $download;
var $time;
var $format;
var $run_comp = false;

function base_extractor($download = false, $store = false, $format, $filename, $time)
{
$this->download = $download;
$this->store = $store;
$this->time = $time;
$this->format = $format;

switch ($format)
{
case 'text':
$ext = '.sql';
$open = 'fopen';
$this->write = 'fwrite';
$this->close = 'fclose';
$mimetype = 'text/x-sql';
break;
case 'bzip2':
$ext = '.sql.bz2';
$open = 'bzopen';
$this->write = 'bzwrite';
$this->close = 'bzclose';
$mimetype = 'application/x-bzip2';
break;
case 'gzip':
$ext = '.sql.gz';
$open = 'gzopen';
$this->write = 'gzwrite';
$this->close = 'gzclose';
$mimetype = 'application/x-gzip';
break;
}

if ($download == true)
{
$name = $filename . $ext;
header('Pragma: no-cache');
header("Content-Type: $mimetype; name=\"$name\"");
header("Content-disposition: attachment; filename=$name");

switch ($format)
{
case 'bzip2':
ob_start();
break;

case 'gzip':
if ((isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'msie') === false)
{
ob_start('ob_gzhandler');
}
else
{
$this->run_comp = true;
}
break;
}
}

if ($store == true)
{
global $phpbb_root_path;
$file = $phpbb_root_path . 'store/' . $filename . $ext;

$this->fp = $open($file, 'w');

if (!$this->fp)
{
trigger_error('FILE_WRITE_FAIL', E_USER_ERROR);
}
}
}

function write_end()
{
static $close;

if ($this->store)
{
if ($close === null)
{
$close = $this->close;
}
$close($this->fp);
}

// bzip2 must be written all the way at the end
if ($this->download && $this->format === 'bzip2')
{
$c = ob_get_clean();
echo bzcompress($c);
}
}

function flush($data)
{
static $write;
if ($this->store === true)
{
if ($write === null)
{
$write = $this->write;
}
$write($this->fp, $data);
}

if ($this->download === true)
{
if ($this->format === 'bzip2' || $this->format === 'text' || ($this->format === 'gzip' && !$this->run_comp))
{
echo $data;
}

// we can write the gzip data as soon as we get it
if ($this->format === 'gzip')
{
if ($this->run_comp)
{
echo gzencode($data);
}
else
{
ob_flush();
flush();
}
}
}
}
}

/**
* @package acp
*/
class mysql_extractor extends base_extractor
{
function write_start($table_prefix)
{
$sql_data = "#\n";
$sql_data .= "# phpBB Backup Script\n";
$sql_data .= "# Dump of tables for $table_prefix\n";
$sql_data .= "# DATE : " . gmdate("d-m-Y H:i:s", $this->time) . " GMT\n";
$sql_data .= "#\n";
$this->flush($sql_data);
}

function write_table($table_name)
{
global $db;
static $new_extract;

if ($new_extract === null)
{
if ($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '3.23.20', '>='))
{
$new_extract = true;
}
else
{
$new_extract = false;
}
}

if ($new_extract)
{
$this->new_write_table($table_name);
}
else
{
$this->old_write_table($table_name);
}
}

function write_data($table_name)
{
global $db;
if ($db->sql_layer === 'mysqli')
{
$this->write_data_mysqli($table_name);
}
else
{
$this->write_data_mysql($table_name);
}
}

function write_data_mysqli($table_name)
{
global $db;
$sql = "SELECT *
FROM $table_name";
$result = mysqli_query($db->db_connect_id, $sql, MYSQLI_USE_RESULT);
if ($result != false)
{
$fields_cnt = mysqli_num_fields($result);

// Get field information
$field = mysqli_fetch_fields($result);
$field_set = array();

for ($j = 0; $j < $fields_cnt; $j++)
{