コード例 #1
0
// Access this file from Cron Jobs in CPanel
include 'php/config.php';
if (isset($argv) && isset($argv[1])) {
    $_GET['cron'] = $argv[1];
}
if (isset($_GET['cron']) && $_GET['cron'] == $admin_name) {
    include 'php/pbm.class.php';
    //if set to backup mysql database
    if (BK_CRON_SQL == 1) {
        define('CRON_BK', 1);
        //used in saveBkZip() to set zip-name
        ignore_user_abort(true);
        @set_time_limit(2000);
        include 'php/pbmysql.class.php';
        $bk = new pbmysql();
        $bk->setMysql($bk_cron_mysql);
        //set connection data
        $tables = count($bk_cron_mysql['tables']) == 0 ? $bk->getTables() : $bk_cron_mysql['tables'];
        //tables to backup
        $bk->saveBkZip($tables);
        //make and save the backup
    }
    //if set to backup folders
    if (BK_CRON_DIR == 1) {
        include 'php/pbmdirs.class.php';
        $bk = new pbmdirs();
        $bk->backup($_SERVER['DOCUMENT_ROOT'] . '/' . trim(ROOT_DIR, '/'), $bk_cron_dirs, []);
    }
} else {
    echo 'Invalid request';
}
コード例 #2
0
        unset($_SESSION['pbm_mysql']);
    }
    if (isset($_SESSION['pbm_re'])) {
        unset($_SESSION['pbm_re']);
    }
    $tpl_index['re_cnt'] = $bk->template(file_get_contents(TPL . 'conn_mysql.htm'), $tplv);
} else {
    //if request to connect to mysql
    if (isset($_POST['host']) && isset($_POST['user']) && isset($_POST['pass']) && isset($_POST['dbname'])) {
        $_SESSION['pbm_mysql'] = ['host' => $_POST['host'], 'user' => $_POST['user'], 'pass' => $_POST['pass'], 'dbname' => $_POST['dbname']];
    }
}
//if session with data for connecting to MySQL database (MySQL server, user, password, database name)
if (isset($_SESSION['pbm_mysql'])) {
    @set_time_limit(2000);
    $bk->setMysql($_SESSION['pbm_mysql']);
    //set connection data
    //if form with tables to backup, create ZIP archive with backup. Else: restore backup
    if (isset($_POST['tables'])) {
        $tables = $_POST['tables'];
        //store tables in object
        $bk->redirSes($bk->saveBkZip($tables), $tplv['php_self']);
        //response, redirect-location
    } else {
        if (isset($_POST['file']) && isset($_POST['pbm_zip']) && $_POST['pbm_zip'] == 'res_file') {
            $bk->redirSes($bk->restore($_POST['file']), $tplv['uri']);
        }
    }
    //on click button to restore sql.zip. Response, redirect-location
    $tables = $bk->getListTables();
    //array with [f, er] (form, error)