コード例 #1
0
function restoreDBFromBackup()
{
    makeRed("Restore Database? WARNING: This will drop all tables and restore data to last backup!");
    echo "(Y/N): ";
    $data = FOPEN("php://stdin", "rb");
    $input = '';
    while (1 == 1) {
        $chunk = FREAD($data, 1);
        if ($chunk == "\n" || $chunk == "\r") {
            break;
        }
        $input .= $chunk;
    }
    FCLOSE($data);
    if (strtolower(@$input) == 'y') {
        echo "Getting Credentials from application.ini...\n";
        $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
        $bootstrap = $application->getBootstrap();
        $options = $bootstrap->getOptions();
        $db = $options['resources']['db']['params'];
        echo "Database Restoring. Please be patient, this could take a while...";
        sleep(1);
        echo ".";
        sleep(1);
        echo ".";
        sleep(1);
        echo ".";
        echo "\n";
        exec("mysql -u " . $db['username'] . " -p" . $db['password'] . " " . $db['dbname'] . " < " . APPLICATION_PATH . "/../data/dbbackup.sql", $output);
        makeGreen("DONE!");
        echo "\n\n";
    } else {
        echo "Operation Cancelled.\n";
    }
}
コード例 #2
0
function packageApplication($path = false)
{
    if (!$path) {
        $path = APPLICATION_PATH . "/../data/application.zip";
    }
    echo "Preparing to Archive Application. Please Be Patient...\n";
    if (file_exists("{$path}")) {
        makeRed("Removing old archive...\n");
        unlink("{$path}");
    }
    exec("zip -9 -r {$path} ../*", $output);
    foreach ($output as $o) {
        echo "{$o}\n";
    }
    makeGreen("DONE! Archive saved to " . str_replace("application/../", '', $path));
    echo "\n\n";
}