Esempio n. 1
0
// Simple PHP Backup Manager - file from Cron Jobs
// 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';
Esempio n. 2
0
<?php

//code used in index.php for backup mysql tables
include 'php/pbmysql.class.php';
$bk = new pbmysql();
//if not post, set data for connecting form
if ((!isset($_POST) || count($_POST) == 0) && $tpl_index['pbm_re'] == '') {
    $bk->setTplv(['msg_connect', 'msg_database', 'msg_server', 'msg_user']);
    //add texts from #lang in $tplv
    //if not form send, set form with fields for connection data
    if (isset($_SESSION['pbm_mysql'])) {
        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'];