本文整理汇总了PHP中backup_tables函数的典型用法代码示例。如果您正苦于以下问题:PHP backup_tables函数的具体用法?PHP backup_tables怎么用?PHP backup_tables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了backup_tables函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
if (!is_writable(WPSQT_DIR . 'db-backups')) {
echo '<div class="error">The backup folder <strong>wp-content/plugins/wp-survey-and-quiz-tool/db-backups</strong> is not writable or doesn\'t exist, please create this folder or change it\'s permissions to <strong>777</strong>.</div>';
$this->_pageVars['dirwriteable'] = false;
}
if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['host']) && !empty($_POST['user']) && !empty($_POST['pass']) && !empty($_POST['database'])) {
$tables = array(WPSQT_TABLE_QUIZ_SURVEYS, WPSQT_TABLE_SECTIONS, WPSQT_TABLE_QUESTIONS, WPSQT_TABLE_FORMS, WPSQT_TABLE_RESULTS, WPSQT_TABLE_SURVEY_CACHE);
require_once 'backupfunction.php';
$sql = backup_tables($_POST['host'], $_POST['user'], $_POST['pass'], $_POST['database'], $tables);
file_put_contents(WPSQT_DIR . 'db-backups/db-' . date('His-dmy') . '.sql', $sql);
$this->_pageView = "admin/maintenance/backupdone.php";
} else {
$this->_pageView = "admin/maintenance/backup.php";
}
}
示例2: session_start
<?php
session_start();
if (!isset($_SESSION['admin'])) {
exit(header("location:index.php"));
} else {
include "conn.php";
$pos = "Administrator";
}
backup_tables('localhost', 'root', '', 'user');
/* backup the db OR just a table */
$host = 'localhost';
$user = 'root';
$pass = '';
$name = 'thesis';
function backup_tables($host, $user, $pass, $name, $tables = '*')
{
$link = mysql_connect("localhost", "root", "");
mysql_select_db('thesis', $link);
//get all of the tables
if ($tables == '*') {
$tables = array();
$result = mysql_query('SHOW TABLES');
while ($row = mysql_fetch_row($result)) {
$tables[] = $row[0];
}
} else {
$tables = is_array($tables) ? $tables : explode(',', $tables);
}
foreach ($tables as $table) {
$result = mysql_query("SELECT * FROM {$table}");
示例3: _
<?php
/* $Id: PcTypeTabs.php 3924 2010-09-30 15:10:30Z tim_schofield $ */
$PageSecurity = 15;
include 'includes/session.inc';
$title = _('Insert Marks');
include 'includes/header.inc';
backup_tables('localhost', 'elly', 'masinde', '*', $db);
/* backup the db OR just a table */
function backup_tables($host, $user, $pass, $tables = '*', $db)
{
//get all of the tables
if ($tables == '*') {
$tables = array();
$result = DB_query('SHOW TABLES', $db);
while ($row = DB_fetch_row($result)) {
$tables[] = $row[0];
}
} else {
$tables = is_array($tables) ? $tables : explode(',', $tables);
}
//cycle through
foreach ($tables as $table) {
$result = DB_query('SELECT * FROM ' . $table, $db);
$num_fields = DB_num_fields($result);
$num_rows = DB_num_rows($result);
$return .= 'DROP TABLE IF EXISTS ' . $table . ';';
$row2 = DB_fetch_row(DB_query('SHOW CREATE TABLE ' . $table, $db));
$return .= "\n\n" . $row2[1] . ";\n\n";
$return .= 'INSERT INTO ' . $table . ' VALUES';
for ($i = 0; $i < $num_fields; $i++) {
示例4: header
$api->update_data('register', $v);
$api->logs($TEXT['Users system has been updated']);
header('Location: admin_main.php?mode=settings&submode=about&success=system');
break;
case 'dropusers':
$api->drop_table("users");
$api->logs($TEXT['Users table has been truncated']);
header('Location: admin_main.php?mode=settings&submode=about&success=dropusers');
break;
case 'droptickets':
$api->drop_table("tickets");
$api->logs($TEXT['Tickets table has been truncated']);
header('Location: admin_main.php?mode=settings&submode=about&success=droptable');
break;
case 'backup':
backup_tables();
break;
case 'newdep':
$api->add_department($_POST[title]);
$api->logs($TEXT['New department created']);
header('Location: admin_main.php?mode=settings&submode=departments&success=newdep');
break;
case 'deletedep':
$api->delete_department($_POST['delete']);
$api->logs($TEXT['Department deleted'] . ": " . $api->sql_escape($_POST[delete]));
header('Location: admin_main.php?mode=settings&submode=departments&success=deletedep');
break;
case 'langs':
$query = $api->get_langs();
while ($l = mysqli_fetch_array($query)) {
if ($_POST[$l[short]]) {
示例5: backup_tables
$c = backup_tables("{$_GET['table']}", '../../../../.backup/.table', "{$file}", true);
if ($c) {
$size = format_size(filesize("../../../../.backup/.table/{$file}.sql"));
$time = date("Y/m/d H:i:s", filemtime("../../../../.backup/.table/{$file}.sql"));
$r = "{$size} - {$time}";
echo "{ \"file\":\"{$file}.sql\" , \"info\":\"{$r}\" }";
}
}
if ($_GET['type'] == 'installer') {
@unlink("../../../../.backup/{$_GET['file']}");
$file = '../../../../system/installer.zip';
extractZip($file, '../../../../system');
if (!file_exists('../../../../.backup')) {
mkdir('../../../../.backup');
}
backup_tables('*', '../../../../system/installer', 'data', true);
archiveZip('../../../../system/installer', '../../../../system/installer.zip');
$date = md5(date("Ymd:His"));
$file = "installer-backup-{$date}.zip";
$c = archiveZip('../../../../', "../../../../.backup/{$file}");
if ($c) {
$size = format_size(filesize("../../../../.backup/{$file}"));
$time = date("Y/m/d H:i:s", filemtime("../../../../.backup/{$file}"));
$r = "{$size} - {$time}";
echo "{ \"file\":\"{$file}\" , \"info\":\"{$r}\" }";
}
}
if ($_GET['type'] == 'delete') {
if ($_GET['act'] == 'installer' || $_GET['act'] == 'db') {
@unlink("../../../../.backup/{$_GET['file']}");
}
示例6: GETPOST
// for compression format, we add extension
$compression = GETPOST('compression') ? GETPOST('compression', 'alpha') : 'none';
if ($compression == 'gz') {
$outputfile .= '.gz';
}
if ($compression == 'bz') {
$outputfile .= '.bz2';
}
$outputerror = $outputfile . '.err';
dol_mkdir($conf->admin->dir_output . '/backup');
if ($compression == 'gz' or $compression == 'bz') {
backup_tables($outputfiletemp);
dol_compress_file($outputfiletemp, $outputfile, $compression);
unlink($outputfiletemp);
} else {
backup_tables($outputfile);
}
$_SESSION["commandbackuplastdone"] = "";
$_SESSION["commandbackuptorun"] = "";
}
// POSTGRESQL
if ($what == 'postgresql') {
$cmddump = GETPOST("postgresqldump");
// Do not sanitize here with 'alpha', will be sanitize later by escapeshellarg
if ($cmddump) {
dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity);
}
$outputdir = $conf->admin->dir_output . '/backup';
$outputfile = $outputdir . '/' . $file;
// for compression format, we add extension
$compression = GETPOST('compression') ? GETPOST('compression', 'alpha') : 'none';
示例7: backup_tables
<?
include "../../../classes/Database.php";
include "../../../classes/Connection.php";
include "../../../classes/AdminAction.php";
include_once "../../../includes/bootstrap.php";
?>
<?
backup_tables('dnradmin.db.3506263.hostedresource.com','dnradmin','DSAre96FGdd','dnradmin');
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host,$user,$pass);
mysql_select_db($name,$link);
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
示例8: backup_tables
<?php
backup_tables('localhost', 'root', '', 'avijatry');
/* backup the db OR just a table */
function backup_tables($host, $user, $pass, $name, $tables = '*')
{
$return = "";
$link = mysql_connect($host, $user, $pass);
mysql_select_db($name, $link);
//get all of the tables
if ($tables == '*') {
$tables = array();
$result = mysql_query('SHOW TABLES');
while ($row = mysql_fetch_row($result)) {
$tables[] = $row[0];
}
} else {
$tables = is_array($tables) ? $tables : explode(',', $tables);
}
//cycle through
foreach ($tables as $table) {
$result = mysql_query('SELECT * FROM ' . $table);
$num_fields = mysql_num_fields($result);
$return .= 'DROP TABLE ' . $table . ';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table));
$return .= "\n\n" . $row2[1] . ";\n\n";
for ($i = 0; $i < $num_fields; $i++) {
while ($row = mysql_fetch_row($result)) {
$return .= 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
示例9: fread
}
if ($_GET['do'] == 'download') {
if ($_GET['file'] && file_exists(_BACKUP . $_GET['file'])) {
if ($fp = fopen(_BACKUP . $_GET['file'], 'rb')) {
$buffer = fread($fp, filesize(_BACKUP . $_GET['file']));
fclose($fp);
header('Content-type: application/x-octet-stream');
header('Content-disposition: attachment; filename=' . $_GET['file']);
echo $buffer;
exit;
}
}
$hook->redirect('./?mod=' . $system->module . '&act=' . $system->action);
}
if ($_POST) {
$backup_file = backup_tables(_BACKUP, $cfg['server'], $cfg['port'], $cfg['usr'], $cfg['psw'], $cfg['name']);
if ($_POST['download_only']) {
header('Content-type: application/x-octet-stream');
header('Content-disposition: attachment; filename=' . $backup_file);
readfile(_BACKUP . $backup_file);
unlink(_BACKUP . $backup_file);
exit;
}
$hook->redirect('./?mod=' . $system->module . '&act=' . $system->action);
}
if ($_GET['do'] == 'new') {
$tpl->setfile(array('body' => 'tools.' . $system->action . '.new.tpl'));
} else {
$tpl->setfile(array('body' => 'tools.' . $system->action . '.tpl'));
$dir = dir(_BACKUP);
$contents = array();
示例10: backup_tables
echo "<script>alert('No se pudo descargar')</script>";
}
}
/* verifcamos si se hace una peticion de descarga de una base de datos mysql */
if (isset($_GET['descargar_bd'])) {
/* verificamos que el nombre de la base de datos a descargar sea distinto de vacio */
if ($_GET['descargar_bd'] != "") {
/* si se cumple la condicion, guardamos los datos en variables */
$valor = $_GET['descargar_bd'];
$host = $_GET['host'];
$usuario = $_GET['usuario'];
$clave = $_GET['clave'];
$tipo = $_GET['bd'];
$base = $_GET['base'];
$sql = $_GET['sql'];
backup_tables($host, $usuario, $clave, $valor);
}
}
/* verifcamos si se hace una peticion de descarga de una base de datos mysqli */
if (isset($_GET['descargar_bdi'])) {
/* verificamos que el nombre de la base de datos a descargar sea distinto de vacio */
if ($_GET['descargar_bdi'] != "") {
/* si se cumple la condicion, guardamos los datos en variables */
$valor = $_GET['descargar_bdi'];
$host = $_GET['host'];
$usuario = $_GET['usuario'];
$clave = $_GET['clave'];
$tipo = $_GET['bd'];
$base = $_GET['base'];
$sql = $_GET['sql'];
backup_tables_mysqli($host, $usuario, $clave, $valor);
示例11: backup_tables
<?php
//http://www.cristalab.com/tutoriales/respaldar-base-de-datos-mysql-usando-php-c98522l/
backup_tables('servidor', 'usuario', 'contrasena', 'bd');
/* backup the db OR just a table */
//En la variable $talbes puedes agregar las tablas especificas separadas por comas:
//profesor,estudiante,clase
//O d�jalo con el asterisco '*' para que se respalde toda la base de datos
function backup_tables($host, $user, $pass, $name, $tables = '*')
{
$link = mysql_connect($host, $user, $pass);
mysql_select_db($name, $link);
//get all of the tables
if ($tables == '*') {
$tables = array();
$result = mysql_query('SHOW TABLES');
while ($row = mysql_fetch_row($result)) {
$tables[] = $row[0];
}
} else {
$tables = is_array($tables) ? $tables : explode(',', $tables);
}
//cycle through
foreach ($tables as $table) {
$result = mysql_query('SELECT * FROM ' . $table);
$num_fields = mysql_num_fields($result);
$return .= 'DROP TABLE IF EXISTS ' . $table . ';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table));
$return .= "\n\n" . $row2[1] . ";\n\n";
//Comprobar que no es una vista
if (strpos($row2[1], 'ALGORITHM') == false) {
示例12: convert_users_tables
//.........这里部分代码省略.........
$query = "SELECT * FROM `" . $key . '_' . session_id() . "`";
$result = mysql_query($query);
$i = 1;
while ($data = mysql_fetch_assoc($result)) {
if ($key == "joomla_db") {
$wp_users_joomla[$i] = $data;
} elseif ($key == "wp_db_user") {
$wp_users_wp[$i] = $data;
} elseif ($key == "wp_db_usermeta") {
$wp_db_usermeta[$i] = $data;
}
$i++;
}
$query = "DROP TABLE `" . $key . '_' . session_id() . "`";
mysql_query($query);
}
foreach ($wp_users_joomla as $num => $value) {
@($users[$num]['wp_users']['ID'] = $num);
@($users[$num]['wp_users']["user_login"] = $value['username']);
@($users[$num]['wp_users']["user_pass"] = $value['password']);
@($users[$num]['wp_users']["user_nicename"] = $value['name']);
@($users[$num]['wp_users']["user_email"] = $value['email']);
@($users[$num]['wp_users']["user_url"] = '');
@($users[$num]['wp_users']["user_registered"] = $value['registerDate']);
@($users[$num]['wp_users']["user_activation_key"] = '');
@($users[$num]['wp_users']["user_status"] = "0");
@($users[$num]['wp_users']["display_name"] = $value['name']);
@($users[$num]['wp_usermeta']["nickname"] = $value['username']);
@($users[$num]['wp_usermeta']["first_name"] = substr($value['name'], 0, strpos($value['name'], " ")));
@($users[$num]['wp_usermeta']["last_name"] = substr($value['name'], strpos($value['name'], " ")));
@($users[$num]['wp_usermeta']["description"] = '');
@($users[$num]['wp_usermeta']["rich_editing"] = 'true');
@($users[$num]['wp_usermeta']["comment_shortcuts"] = 'false');
@($users[$num]['wp_usermeta']["admin_color"] = 'fresh');
@($users[$num]['wp_usermeta']["use_ssl"] = '-');
@($users[$num]['wp_usermeta']["show_admin_bar_front"] = 'false');
@($users[$num]['wp_usermeta']["wp_capabilities"] = 'a:1:{s:8:"customer";b:1:}');
@($users[$num]['wp_usermeta']["wp_user_level"] = '0');
@($users[$num]['wp_usermeta']["dismissed_wp_pointers"] = '');
@($users[$num]['wp_usermeta']["author_facebook"] = '');
@($users[$num]['wp_usermeta']["author_custom"] = '');
@($users[$num]['wp_usermeta']["author_gplus"] = '');
@($users[$num]['wp_usermeta']["author_dribble"] = '');
@($users[$num]['wp_usermeta']["author_linkedin"] = '');
@($users[$num]['wp_usermeta']["author_twitter"] = '');
}
foreach ($wp_users_wp as $numb => $value) {
@($wp[$numb]['wp_users']['ID'] = $numb);
@($wp[$numb]['wp_users']["user_login"] = $value['user_login']);
@($wp[$numb]['wp_users']["user_pass"] = $value['user_pass']);
@($wp[$numb]['wp_users']["user_nicename"] = $value['user_nicename']);
@($wp[$numb]['wp_users']["user_email"] = $value['user_email']);
@($wp[$numb]['wp_users']["user_url"] = $value["user_url"]);
@($wp[$numb]['wp_users']["user_registered"] = $value['user_registered']);
@($wp[$numb]['wp_users']["user_activation_key"] = $value["user_activation_key"]);
@($wp[$numb]['wp_users']["user_status"] = $value["user_status"]);
@($wp[$numb]['wp_users']["display_name"] = $value['display_name']);
}
foreach ($wp_db_usermeta as $idmeta => $value) {
@($wp[$value['user_id']]['wp_usermeta'][$value['meta_key']] = $value['meta_value']);
}
$allusers = array_merge($users, $wp);
echo "<pre>";
// var_dump($allusers);
echo "</pre>";
$i = 1;
foreach ($allusers as $key => $value) {
$tables[$i] = $value;
$i++;
}
foreach ($tables as $key => $value) {
foreach ($value as $wp => $val) {
if ($wp == "wp_users") {
$query = "INSERT INTO `wp_users_" . session_id() . "` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES\n\t\t\t\t\t\t\t ('" . $val["ID"] . "', '" . $val["user_login"] . "', '" . $val["user_pass"] . "', '" . $val["user_nicename"] . "', '" . $val["user_email"] . "', '" . $val["user_url"] . "', '" . $val["user_registered"] . "', '" . $val["user_activation_key"] . "', '" . $val["user_status"] . "', '" . $val["display_name"] . "')";
$result = mysql_query($query);
} elseif ($wp == "wp_usermeta") {
foreach ($val as $meta_key => $data) {
$query = "INSERT INTO `wp_usermeta_" . session_id() . "` (`user_id`, `meta_key`, `meta_value`) VALUES('" . $key . "', '" . $meta_key . "', '" . $data . "')";
$result = mysql_query($query);
}
}
}
}
$backup_file = $upload_dir . '/wp_users_' . session_id() . '.sql';
$mybackup = backup_tables(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, "wp_users_" . session_id());
$handle = fopen($backup_file, 'w+');
fwrite($handle, $mybackup);
fclose($handle);
$query = "DROP TABLE `wp_users_" . session_id() . "`";
mysql_query($query);
$backup_file = $upload_dir . '/wp_usermeta_' . session_id() . '.sql';
$mybackup = backup_tables(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME, "wp_usermeta_" . session_id());
$handle = fopen($backup_file, 'w+');
fwrite($handle, $mybackup);
fclose($handle);
$query = "DROP TABLE `wp_usermeta_" . session_id() . "`";
mysql_query($query);
}
}
}
示例13: backup_tables
<?php
//backup_tables('localhost','username','password','blog');
backup_tables('localhost', 'root', '', 'salesfinder');
/* backup the db OR just a table */
function backup_tables($host, $user, $pass, $name, $tables = '*')
{
$link = mysql_connect($host, $user, $pass);
mysql_select_db($name, $link);
//get all of the tables
if ($tables == '*') {
$tables = array();
$result = mysql_query('SHOW TABLES');
while ($row = mysql_fetch_row($result)) {
$tables[] = $row[0];
}
} else {
$tables = is_array($tables) ? $tables : explode(',', $tables);
}
//cycle through
foreach ($tables as $table) {
$result = mysql_query('SELECT * FROM ' . $table);
$num_fields = mysql_num_fields($result);
$return .= 'DROP TABLE ' . $table . ';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table));
$return .= "\n\n" . $row2[1] . ";\n\n";
for ($i = 0; $i < $num_fields; $i++) {
while ($row = mysql_fetch_row($result)) {
$return .= 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
示例14: while
echo "</div><br />";
while ($r3o = mysql_fetch_assoc($sql)) {
$email = $r3o['email'];
$date = $r3o['date'];
$message = $r3o['message'];
echo "<div class='tmp'><table cellpadding='0' align='center' width='70%' >";
echo "<tr><td>email : {$email} </td><td>date : {$date} </td></tr>\r\n<tr > <td>message</td> <td colspan='2'>{$message}</td><br /><br /></tr>";
echo "</table></div>";
echo "<br /><a href='{$pg}?sws=ms&show=tb'>[ Back ]</a>";
exit;
}
} else {
if ($op == 'bkup') {
if (isset($_POST['viw'])) {
$path = $_POST['path'];
$domp = @backup_tables($path, $host_c, $user_c, $pass_c, $db_c);
echo "<center><br /><div style=\"color: #003300; font-weight: bold\">Create backup successfully <br /><br /> {$path}</div> </center>";
echo "<br /><a href='{$pg}?sws=ms&show=tb'>[ Back ]</a>";
exit;
} else {
echo '<form method="post">
<br /><br />
path backup <br /><br /><input type="text" name="path" /><br /><br />
<input type="submit" name="viw" value="Create" />
</form>';
exit;
}
} else {
if ($op == 'sh3') {
if (isset($_POST['viw'])) {
示例15: str_replace
</h3>
<table cellpadding="0" cellspacing="0">
<td><?php
// Include settings
include "config.php";
// Set the suffix of the backup filename
if ($table == '*') {
$extname = 'all';
} else {
$extname = str_replace(",", "_", $table);
$extname = str_replace(" ", "_", $extname);
}
$here = dirname(__FILE__) . DS;
// Generate the filename for the backup file
$index1 = $here . 'backup' . DS . 'index.php';
$filess = $here . 'backup' . DS . 'dbbackup_' . date("d.m.Y_H_i_s") . uniqid() . '_' . $extname;
touch($filess);
touch($index1);
// Call the backup function for all tables in a DB
backup_tables($DBhost, $DBuser, $DBpass, $DBName, $table, $extname, $filess);
// Backup the table and save it to a sql file
// Print the message
print _e("The backup has been created successfully", true) . '. <br />' . _e("You can get MySQL dump file", true) . ' <a href="' . $filess . '.sql" class="view">' . _e("", true) . '</a>.<br>' . "\n";
print _e("You can get Backed-up files archive", true) . ' <a href="' . $filess . '.zip" class="view">' . _e("here", true) . '</a>.<br>' . "\n";
?>
</td>
</table>
<br />
</form>