Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // RM -rf if exist - for test onlu
- rmdir('zabackupim-workdir');
- unlink('test.tar.gz');
- unlink('zabackupim.php');
- // Zabackupim setup script v0.1
- // Start checks
- // Check disk space
- $dir = getcwd();
- $dt = disk_total_space($dir);
- $df = disk_free_space($dir);
- $pr = ($df/$dt)*100;
- $si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
- $base = 1024;
- if ($pr > 55) {
- echo "Check disk space: <strong><span style=\"color:green;\">Test pass!</span></strong><br />";
- } else {
- echo "Check disk space: <strong><span style=\"color:red;\">Test fail! It is not enough disk space to create a temporary backup!</span></strong>";
- die('<strong><span style=\"color:red;\"><br />Kill all!</span></strong>');
- }
- // Check create new dir
- $structure = './test/';
- if (!mkdir($structure, 0777, true)) {
- echo "Check create new dir: <strong><span style=\"color:red;\">Test fail! Please correct permissions for the site root folder!</span></strong>";
- die('<strong><span style=\"color:red;\"><br />Kill all!</span></strong>');
- } else {
- echo "Check create new dir: <strong><span style=\"color:green;\">Test pass!</span></strong><br />";
- }
- rmdir('test');
- // Check to create new tar.gz archive file
- try
- {
- $a = new PharData('test.tar');
- // ADD FILES TO archive.tar FILE
- $a->addFile('tar.php');
- // COMPRESS archive.tar FILE. COMPRESSED FILE WILL BE archive.tar.gz
- $a->compress(Phar::GZ);
- // NOTE THAT BOTH FILES WILL EXISTS. SO IF YOU WANT YOU CAN UNLINK archive.tar
- unlink('test.tar');
- echo "Check to create new tar.gz archive file: <strong><span style=\"color:green;\">Test pass!</span></strong><br />";
- }
- catch (Exception $e)
- {
- echo "Check to create new tar.gz archive file: <strong><span style=\"color:red;\">Test fail!</span></strong><br />Exception : " . $e;
- die('<strong><span style=\"color:red;\"><br />Kill all!</span></strong>');
- }
- // If all tests is OK, download primary management file and create work-dir
- $file = 'http://cloudtelehouse.com/zabackupim.php';
- $newfile = 'zabackupim.php';
- if (!copy($file, $newfile)) {
- echo "Download primary management file: <strong><span style=\"color:red;\">Fail!</span></strong>";
- die('<strong><span style=\"color:red;\"><br />Kill all!</span></strong>');
- } else {
- echo "Download primary management file: <strong><span style=\"color:green;\">Pass!</span></strong><br />";
- }
- $structure = './zabackupim-workdir/';
- if (!mkdir($structure, 0777, true)) {
- echo "Create work-dir: <strong><span style=\"color:red;\">Fail! Please correct permissions for the site root folder!</span></strong>";
- die('<strong><span style=\"color:red;\"><br />Kill all!</span></strong>');
- } else {
- echo "Create work-dir: <strong><span style=\"color:green;\">Pass!</span></strong><br />";
- }
- // Finish!!!
- echo "<strong><span style=\"color:green;\">All tests run successfully, the working environment was created successfully!</span></strong><br />";
- echo "<strong><span style=\"color:red;\">Please delete the file zb-setup.php manually! If this is not possible problems in the backup service!</span></strong><br />";
- echo "Please go to the <a href=\"http://".$_SERVER['SERVER_NAME']."/zabackupim.php\" target=\"_blank\">Control panel</a> and follow the instructions!<br />";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement