-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3ffce5
commit e7b3fb8
Showing
106 changed files
with
12,365 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
require "../load.php"; | ||
|
||
/** | ||
* Backup Lobby DIR as .zip folder | ||
* http://stackoverflow.com/a/19451938/1372424 | ||
*/ | ||
$the_folder = L_DIR; | ||
$zip_file_name = L_DIR . "/contents/extra/lobby-" .date("Y-m-d@H-i-s") . '.zip'; | ||
|
||
$download_file = true; | ||
|
||
class FlxZipArchive extends ZipArchive { | ||
/** Add a Dir with Files and Subdirs to the archive;;;;; @param string $location Real Location;;;; @param string $name Name in Archive;;; @author Nicolas Heimann;;;; @access private **/ | ||
|
||
public function addDir($location, $name) { | ||
$this->addEmptyDir($name); | ||
|
||
$this->addDirDo($location, $name); | ||
} // EO addDir; | ||
|
||
/** Add Files & Dirs to archive;;;; @param string $location Real Location; @param string $name Name in Archive;;;;;; @author Nicolas Heimann | ||
* @access private **/ | ||
private function addDirDo($location, $name) { | ||
$name .= '/'; | ||
$location .= '/'; | ||
|
||
// Read all Files in Dir | ||
$dir = opendir ($location); | ||
while ($file = readdir($dir)) | ||
{ | ||
if ($file == '.' || $file == '..') continue; | ||
// Rekursiv, If dir: FlxZipArchive::addDir(), else ::File(); | ||
$do = (filetype( $location . $file) == 'dir') ? 'addDir' : 'addFile'; | ||
$this->$do($location . $file, $name . $file); | ||
} | ||
} // EO addDirDo(); | ||
} | ||
|
||
$za = new FlxZipArchive; | ||
$res = $za->open($zip_file_name, ZipArchive::CREATE); | ||
if($res === TRUE) | ||
{ | ||
$za->addDir($the_folder, basename($the_folder)); | ||
$za->close(); | ||
} | ||
else { echo 'Could not create a zip archive';} | ||
|
||
if ($download_file){ | ||
ob_get_clean(); | ||
header("Pragma: public"); | ||
header("Expires: 0"); | ||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | ||
header("Cache-Control: private", false); | ||
header("Content-Type: application/zip"); | ||
header("Content-Disposition: attachment; filename=" . basename($zip_file_name) . ";" ); | ||
header("Content-Transfer-Encoding: binary"); | ||
header("Content-Length: " . filesize($zip_file_name)); | ||
readfile($zip_file_name); | ||
} | ||
|
||
/** | ||
* Delete .zip File | ||
*/ | ||
\Lobby\FS::remove($zip_file_name); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.