Example #1
0
// ensure user is coming from the admin side and has access to this function
if (!($my->usertype == 'Super Administrator') && $adminside > 0) {
    mosRedirect('index2.php', T_('You are not authorized to view this resource.'));
}
require_once $mainframe->getPath('admin_html');
require_once "{$mosConfig_absolute_path}/administrator/includes/pcl/pclzip.lib.php";
$task = mosGetParam($_REQUEST, "task", "");
$file = mosGetParam($_POST, "file", null);
$upfile = mosGetParam($_FILES, "upfile", null);
$tables = mosGetParam($_POST, "tables", null);
$OutType = mosGetParam($_POST, "OutType", null);
$OutDest = mosGetParam($_POST, "OutDest", null);
$toBackUp = mosGetParam($_POST, "toBackUp", null);
switch ($task) {
    case "dbBackup":
        dbBackup($option);
        break;
    case "doBackup":
        doBackup($tables, $OutType, $OutDest, $toBackUp, $_SERVER['HTTP_USER_AGENT'], $local_backup_path);
        break;
    case "dbRestore":
        dbRestore($local_backup_path);
        break;
    case "doRestore":
        doRestore($file, $upfile, $local_backup_path);
        break;
    case "xquery":
        xquery($option);
        break;
}
function dbBackup($p_option)
Example #2
0
<?php

//-----------------------------------------------define
require_once 'config.php';
// ■指定した日より前のDBバックアップファイルは削除
$dirPath = DB_BACKUP_PATH;
$expire = strtotime("-2 weeks");
deleteFiles($dirPath, $expire);
echo 'DBパックアップ削除完了<br />';
// ■DBバックアップ
$dirPath = DB_BACKUP_PATH;
$fileName = date('Ymd') . '_' . date('His') . DB_NAME . '.sql';
dbBackup(DB_HOST, DB_USER, DB_PASS, DB_NAME, $dirPath, $fileName);
echo 'DBバックアップ完了<br />';
//-----------------------------------------------function
/**
 * ■ファイル削除関数
 * $dirPath : ディレクトリパス
 * $expire : 削除期限
 */
function deleteFiles($dirPath, $expire)
{
    $list = scandir($dirPath);
    // フォルダ内のファイル一覧取得
    foreach ($list as $value) {
        $file = $dirPath . $value;
        // ファイル名にパスを付ける
        if (!is_file($file)) {
            continue;
        }
        // ファイルの存在確認をしなかったらcontinue(. .. ← をcontinue)
Example #3
0
} elseif ($do == 'backup') {
    $compression = isset($_REQUEST['compression']) ? 1 : 0;
    // Path
    $path = $ecLocal['scriptPath'] . '/backups/database/';
    if (!extension_loaded("zlib")) {
        $compression = 0;
    }
    $filetype = $compression == 1 ? 'sql.gz' : 'sql';
    $curDate = date("Y-m-d", $ecLocal['timestamp']);
    for ($i = 1; file_exists($path . $ecDb['name'] . '_' . $curDate . '_' . $i . '_structur' . ".sql") || file_exists($path . $ecDb['name'] . '_' . $curDate . '_' . $i . '_structur' . ".sql.gz"); $i++) {
    }
    $path1 = $path . $ecDb['name'] . '_' . $curDate . '_' . $i . '_structur' . "." . $filetype;
    for ($i = 1; file_exists($path . $ecDb['name'] . '_' . $curDate . '_' . $i . '_data' . ".sql") || file_exists($path . $ecDb['name'] . '_' . $curDate . '_' . $i . '_data' . ".sql.gz"); $i++) {
    }
    $path2 = $path . $ecDb['name'] . '_' . $curDate . '_' . $i . '_data' . "." . $filetype;
    dbBackup($ecDb['name'], $path1, $path2, $compression);
    $next = ecReferer('index.php?view=system&site=database');
    echo ecTemplate('system', 'database', 'dbDumped');
} elseif ($do == 'import') {
    $file = 'backups/database/' . $_REQUEST['backup'];
    dbImport($file, 'abcd');
    $next = ecReferer('index.php?view=system&site=database');
    echo ecTemplate('system', 'database', 'backupImported');
} elseif ($do == 'delete') {
    $file = 'backups/database/' . $_REQUEST['backup'];
    ecFileDelete($file);
    $next = ecReferer('index.php?view=system&site=database');
    echo ecTemplate('system', 'database', 'backupDeleted');
} else {
    echo ecTemplate('system', 'database', 'siteHead');
    echo ecTemplate('system', 'database', 'dbOptimize');