function admin_database_make() { if (@$_SESSION['rights']['admin']['database']['backup'] or @$_SESSION['rights']['superadmin']) { ob_end_clean(); $backup_obj = new MySQL_Backup(); $backup_obj->server = MYSQL_HOST; $backup_obj->username = MYSQL_USER; $backup_obj->password = MYSQL_PASS; $backup_obj->database = MYSQL_DATABASE; $backup_obj->tables = array(); $backup_obj->drop_tables = true; $backup_obj->struct_only = false; $backup_obj->comments = true; $backup_obj->fname_format = 'd_m_y__H_i_s'; if (!$backup_obj->Execute(MSB_DOWNLOAD, '', false)) { die($backup_obj->error); } die; } else { table(ERROR, NO_ADMIN_RIGHTS); } }
if ($do == "backup") { $backup_obj = new MySQL_Backup(); $backup_obj->server = $pixieconfig['host']; $backup_obj->username = $pixieconfig['user']; $backup_obj->password = $pixieconfig['pass']; $backup_obj->database = $pixieconfig['db']; $backup_obj->tables = array(); $backup_obj->drop_tables = true; $backup_obj->struct_only = false; $backup_obj->comments = true; $backup_obj->backup_dir = '../files/sqlbackups/'; $backup_obj->fname_format = 'd_m_Y-H-i-s'; $filename = date("d_m_Y-H-i-s") . ".sql.gz"; $task = MSB_SAVE; $use_gzip = true; if (!$backup_obj->Execute($task, '', $use_gzip)) { $message = $backup_obj->error; } else { $messageok = $lang['backup_ok']; logme($lang['backup_ok'], "no", "save"); safe_update("pixie_settings", "last_backup = '{$filename}'", "settings_id = '1'"); $prefs = get_prefs(); extract($prefs); } } if (isset($del)) { if (file_exists("../files/sqlbackups/" . $del)) { $current = safe_field('last_backup', 'pixie_settings', "settings_id='1'"); if ($current != $del) { $delk = file_delete("../files/sqlbackups/" . $del); } else {
public function accion_copiaseg($datos = array(), $estruc = false, $version = 'CED') { require_once dirname(__FILE__) . '/../class/mysql_backup.class.php'; $backup_obj = new MySQL_Backup(); //----------------------- EDIT - REQUIRED SETUP VARIABLES ----------------------- $backup_obj->server = FS_DB_HOST; $backup_obj->port = FS_DB_PORT; $backup_obj->username = FS_DB_USER; $backup_obj->password = FS_DB_PASS; $backup_obj->database = FS_DB_NAME; //Tables you wish to backup. All tables in the database will be backed up if this array is null. $backup_obj->tables = $datos; //------------------------ END - REQUIRED SETUP VARIABLES ----------------------- //-------------------- OPTIONAL PREFERENCE VARIABLES --------------------- //Add DROP TABLE IF EXISTS queries before CREATE TABLE in backup file. $backup_obj->drop_tables = true; //Only structure of the tables will be backed up if true. $backup_obj->struct_only = $estruc; //Include comments in backup file if true. $backup_obj->comments = true; //Directory on the server where the backup file will be placed. Used only if task parameter equals MSB_SAVE. $backup_obj->backup_dir = $this->crear_dir(); //Default file name format. $backup_obj->fname_format = "d-m-Y_H-i-s"; //--------------------- END - OPTIONAL PREFERENCE VARIABLES --------------------- //---------------------- EDIT - REQUIRED EXECUTE VARIABLES ---------------------- /* * Task: * MSB_STRING - Return SQL commands as a single output string. * MSB_SAVE - Create the backup file on the server. * MSB_DOWNLOAD - Download backup file to the user's computer. */ $task = MSB_SAVE; //Optional name of backup file if using 'MSB_SAVE' or 'MSB_DOWNLOAD'. If nothing is passed, the default file name format will be used. $filename = "_" . $version . "_FacturaSctipts_V" . $this->version(); //Use GZip compression if using 'MSB_SAVE' or 'MSB_DOWNLOAD'? $use_gzip = true; //--------------------- END - REQUIRED EXECUTE VARIABLES ---------------------- //-------------------- NO NEED TO ANYTHING BELOW THIS LINE -------------------- return $backup_obj->Execute($task, $filename, $use_gzip); }
function nulluhr() { global $db; update_all_ranks(); $db->query('DELETE FROM ' . DB_PRE . 'ecp_messages WHERE fromdel = 1 AND del = 1'); $result = $db->query('SELECT ID FROM ' . DB_PRE . 'ecp_user WHERE (ondelete < ' . time() . ' AND ondelete != 0) OR (status = 0 AND registerdate < ' . (time() - DELETE_UNAKTIV * 86400) . ')'); while ($row = mysql_fetch_assoc($result)) { delete_user($row['ID']); } $result = $db->query('SELECT ID, money FROM ' . DB_PRE . 'ecp_user LEFT JOIN ' . DB_PRE . 'ecp_ranks ON (rID = rankID)'); while ($row = mysql_fetch_assoc($result)) { if ($row['money'] != '') { $db->query('UPDATE ' . DB_PRE . 'ecp_user_stats SET money = money + ' . $row['money'] . ' WHERE userID = ' . $row['ID']); } } if (BACKUP_AKTIV) { $last = $db->result(DB_PRE . 'ecp_stats', 'lastdbbackup', '1'); if (BACKUP_CYCLE == 'day' or $last + (BACKUP_CYCLE == 'month' ? 2592000 : 604800) < time()) { $backup_obj = new MySQL_Backup(); $backup_obj->server = MYSQL_HOST; $backup_obj->username = MYSQL_USER; $backup_obj->password = MYSQL_PASS; $backup_obj->database = MYSQL_DATABASE; $backup_obj->tables = array(); $backup_obj->drop_tables = true; $backup_obj->struct_only = false; $backup_obj->comments = true; $backup_obj->fname_format = 'd_m_y__H_i_s'; $string = get_random_string(8, 2); if ($backup_obj->Execute(MSB_SAVE, 'uploads/forum/' . $string . '.sql.gz', true)) { $m = new XMail(); // set from address and name $m->From(SITE_EMAIL); // add to address and name $m->AddTo(BACKUP_EMAIL); // set subject $m->Subject(BACKUP_AUTO); // set text/plain version of message $m->Text(DATE . ': ' . date('d.m.Y H:i:s')); // add attachment ('text/plain' file) $m->Attach(date('Y_m_d') . '.sql.gz', 'application/x-gzip'); $f = 'uploads/forum/' . $string . '.sql.gz'; $id = MIME::unique(); // add inline attachment '$f' file with ID '$id' $m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'attachment', $id); if (SMTP_AKTIV) { $c = $m->Connect(SMTP_HOST, (int) SMTP_PORT, SMTP_USER, SMTP_PASS, 'tls', 10, 'localhost', null, 'plain'); //or die(print_r($m->Result)); } if ($m->Send(SMTP_AKTIV ? $c : null)) { $db->query('UPDATE ' . DB_PRE . 'ecp_stats SET lastdbbackup = ' . strtotime('today 00:00:00')); } unlink('uploads/forum/' . $string . '.sql.gz'); } } } $result = $db->query('SELECT attachID, strname FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000)); while ($row = $db->fetch_assoc()) { @unlink('upload/forum/' . $row['attachID'] . '_' . $row['strname']); } $db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000)); // Buchungen durchf�hren $buchresult = $db->query('SELECT `ID`, `verwendung`, `intervall`, `betrag`, `nextbuch`, `tagmonat` FROM ' . DB_PRE . 'ecp_clankasse_auto WHERE nextbuch <= \'' . time() . '\''); while ($row = mysql_fetch_assoc($buchresult)) { $db->query('INSERT INTO ' . DB_PRE . 'ecp_clankasse_transaktion (`geld`, `verwendung`, `datum`, `userID`) VALUES (-' . $row['betrag'] . ', \'' . mysql_real_escape_string($row['verwendung']) . '\', ' . time() . ', 0)'); $db->query('UPDATE ' . DB_PRE . 'ecp_clankasse SET kontostand = kontostand - ' . $row['betrag']); switch ($row['tagmonat']) { case 1: $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month'); break; case 15: $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month'); break; case 28: $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month'); } $db->query('UPDATE ' . DB_PRE . 'ecp_clankasse_auto SET `nextbuch` = \'' . $nextdate . '\''); } $db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_search WHERE datum < ' . (time() - 86400)); $result = $db->query('SELECT COUNT(sID) as anzahl, sID FROM ' . DB_PRE . 'ecp_server_stats GROUP BY sID'); while ($row = mysql_fetch_assoc($result)) { if ($row['anzahl'] > SERVER_MAX_LOG) { $db->query('DELETE FROM ' . DB_PRE . 'ecp_server_stats WHERE sID = ' . $row['sID'] . ' ORDER BY datum ASC LIMIT ' . ($row['anzahl'] - SERVER_MAX_LOG)); } } }
// now you have access to all CMS API // only root user can backup the database if (!is_root()) { die_msg($_loginMsg["NOT_ALLOWED"]); } require SYS_DIR . 'class.db.backup.php'; // load maintenance configuration require 'config.php'; $backup = new MySQL_Backup(); $backup->server = DB_HOST; $backup->username = DB_USER; $backup->password = DB_PASSWORD; $backup->database = DB_NAME; // backup all tables on 'backup' dir $backup->tables = array(); $backup->backup_dir = BACKUPDIR; $backup->fname_format = 'Ymd-His'; $task = (int) $_GET['task']; $run = $backup->Execute($task); if (!$run) { $output = $backup->error; } else { $output = 'Operation completed successfully at <strong>' . date('H:i:s') . '</strong><em> (Local Server Time)</em>.'; if ($task == MSB_SAVE) { notify_request("backup", (bool) $run, $output); } else { if ($task == MSB_STRING) { echo $output . '<br /><pre>' . $run . '</pre>'; } } }
if (is_dir($file)) { $createZip->addDirectory($basename . "/" . $zipPath); } else { $fileContents = file_get_contents($file); $createZip->addFile($fileContents, $basename . "/" . $zipPath); } } } } } if (isset($configBackupDB) && is_array($configBackupDB) && count($configBackupDB) > 0) { foreach ($configBackupDB as $db) { $backup = new MySQL_Backup(); $backup->server = $db['server']; $backup->username = $db['username']; $backup->password = $db['password']; $backup->database = $db['database']; #$backup->tables = $db['tables']; $backup->backup_dir = $configBackupDir; $sqldump = $backup->Execute(MSB_STRING, "", false); $createZip->addFile($sqldump, $db['database'] . '-' . date('d-m-y') . '-' . date('H-i-s') . '.sql'); } } $fileName = $configBackupDir . $backupName; $fd = fopen($fileName, "wb"); $out = fwrite($fd, $createZip->getZippedfile()); fclose($fd); // Dump done now lets email the user if (isset($configEmail) && !empty($configEmail)) { mailAttachment($fileName, $configEmail, '*****@*****.**', 'Backup Script', '*****@*****.**', 'Backup - ' . $backupName, "Backup file is attached"); }