function create_backup_sql($file) { $line_count = 0; $db_connection = db_connect(); mysql_select_db(db_name()) or exit; $tables = mysql_list_tables(db_name()); $sql_string = NULL; while ($table = mysql_fetch_array($tables)) { $table_name = $table[0]; $sql_string = "DELETE FROM {$table_name}"; $table_query = mysql_query("SELECT * FROM `{$table_name}`"); $num_fields = mysql_num_fields($table_query); while ($fetch_row = mysql_fetch_array($table_query)) { $sql_string .= "INSERT INTO {$table_name} VALUES("; $first = TRUE; for ($field_count = 1; $field_count <= $num_fields; $field_count++) { if (TRUE == $first) { $sql_string .= "'" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'"; $first = FALSE; } else { $sql_string .= ", '" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'"; } } $sql_string .= ");"; if ($sql_string != "") { $line_count = write_backup_sql($file, $sql_string, $line_count); } $sql_string = NULL; } } return $line_count; }
/** * constructor **/ public function __construct() { $this->host = db_host(); $this->dbname = db_name(); $this->user = db_user(); $this->pass = db_psw(); $this->path = db_path(); switch (db_type()) { case "mysql": $dsn = 'mysql:host=' . $this->host . ";port=" . db_port() . ';dbname=' . $this->dbname; break; case "sqlite": $dsn = 'sqlite:' . $this->path . ';'; break; case "postgresql": $dsn = 'pgsql:host=' . $this->host . ";port=" . db_port() . ';dbname=' . $this->dbname; break; default: $dsn = 'mysql:host=' . $this->host . ";port=" . db_port() . ';dbname=' . $this->dbname; } $connection = new PDOConnection($dsn, $this->user, $this->pass, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY, PDO::ATTR_TIMEOUT => 60 * 60 * 60 * 60, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_PERSISTENT => false]); $connection->connect(); $this->dbh = new Database($connection); }
printf(gettext("Graphics support: <strong>%s</strong>"), $graphics_lib['Library_desc']); ?> </li> <li><?php printf(gettext('PHP memory limit: <strong>%1$s</strong> (Note: Your server might allocate less!)'), INI_GET('memory_limit')); ?> </li> <li> <?php $dbsoftware = db_software(); printf(gettext('%1$s version: <strong>%2$s</strong>'), $dbsoftware['application'], $dbsoftware['version']); ?> </li> <li><?php printf(gettext('Database name: <strong>%1$s</strong>'), db_name()); ?> </li> <li> <?php $prefix = prefix(); if (!empty($prefix)) { echo sprintf(gettext('Table prefix: <strong>%1$s</strong>'), prefix()); } ?> </li> <li><?php printf(gettext('Spam filter: <strong>%s</strong>'), getOption('spam_filter')); ?> </li> <li><?php
} else { echo gettext('Backup and Restore your Database'); } ?> </h1> <?php echo $messages; $compression_level = getOption('backup_compression'); ?> <p> <?php printf(gettext("Database software <strong>%s</strong>"), DATABASE_SOFTWARE); ?> <br /> <?php printf(gettext("Database name <strong>%s</strong>"), db_name()); ?> <br /> <?php printf(gettext("Tables prefix <strong>%s</strong>"), trim(prefix(), '`')); ?> </p> <br /> <br /> <?php if (!$_zp_current_admin_obj->reset) { ?> <form name="backup_gallery" action=""> <?php XSRFToken('backup'); ?>
zp_apply_filter('admin_note', 'database', ''); ?> <h1><span id="top"><?php echo $mybutton['button_text']; ?> </span></h1> <p> <?php echo $mybutton['title']; ?> <?php echo gettext("The internal table relations can be viewed on the PDF database reference that is included in the release package within the /docs_files folder of your installation. For more detailed info about the database use tools like phpMyAdmin."); ?> </p> <?php $database_name = db_name(); $prefix = trim(prefix(), '`'); $resource = db_show('tables'); if ($resource) { $result = array(); while ($row = db_fetch_assoc($resource)) { $result[] = $row; } db_free_result($resource); } else { $result = false; } $tables = array(); if (is_array($result)) { foreach ($result as $row) { $tables[] = array_shift($row);
/** * @internal * Check and get the database configuration settings * @param string $namespace Namespace of the configuration to read from */ function db_prerequisite($namespace = 'default') { if (db_host($namespace) && db_user($namespace) && db_name($namespace)) { return db_config($namespace); } else { $error = new stdClass(); $error->message = 'Required to configure <code class="inline">db</code> in "/inc/parameters/' . _cfg('env') . '.php".'; $error->message = array(function_exists('_t') ? _t($error->message) : $error->message); $error->type = 'sitewide-message error'; include _i('inc/tpl/site.error.php'); exit; } }
_autoloadDir(CLASSES . 'console'); _autoloadDir(LIB . 'commands'); _autoloadDir(APP_ROOT . 'commands'); _autoloadDir(APP_ROOT . 'cmd'); _autoloadDir(APP_ROOT . 'entity'); # DB configuration & DB helper (required) if (isset($lc_databases[$lc_defaultDbSource]) && is_array($lc_databases[$lc_defaultDbSource]) && $lc_databases[$lc_defaultDbSource]['engine']) { if ($file = _i('helpers/db_helper.php', false)) { include $file; } $dbEngine = $lc_databases[$lc_defaultDbSource]['engine']; if ($dbEngine === 'mysql') { $dbEngine = 'mysqli'; } require HELPER . 'db_helper.' . $dbEngine . '.php'; if (db_host($lc_defaultDbSource) && db_user($lc_defaultDbSource) && db_name($lc_defaultDbSource)) { # Start DB connection db_connect($lc_defaultDbSource); } } _loader('session_helper', HELPER); _loader('i18n_helper', HELPER); _loader('validation_helper', HELPER); _loader('auth_helper', HELPER); _loader('pager_helper', HELPER); _loader('form_helper', HELPER); _loader('file_helper', HELPER); if (file_exists(INC . 'autoload.php')) { require INC . 'autoload.php'; } # Session helper (unloadable from /inc/autoload.php)