/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright ©2006 by sTEFANs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Provides user interface for creating, downloading and deleting archives.
* @copyright Copyright ©2006 by sTEFANs
* @license http://opensource.org/licenses/lgpl-license.php GNU General Public License
/** Common definitions */
require_once('var.inc.php');
/** ZIP archive creation library */
require_once('zip.inc.php');
/** HTML generation library */
require_once('page.inc.php');
/** Useful routines library */
require_once('utils.inc.php');
/** Common filename for spaceball hint file. */
define('SPACEBALL_HINT_FILE', '.spaceball.hints');
/** Section name for revision map section in hint file. */
define('SECTION_REV_MAP', 'Revision map');
* Prints the complete content of the archive page
* including archive creation form and archive list.
* Prints a cell containing the form to create an archive.
* @param SwcConfig $config Configuration for the concrete project.
$text =
$config->GetProjectName();
'text_low', $overwrite_file, NULL, NULL, true);
* Prints a cell containing the list of existing archives including
* @param SwcConfig $config Configuration for the concrete project.
$path =
$config->GetSpaceballDir();
$url =
$config->GetSpaceballUrl();
} else if (empty($files)){
foreach($files as $file){
$abs_path =
$path.
'/'.
$file;
if ($filesize >
(10 *
1024 -
1)){
if ($filesize >
(10 *
1024 -
1)){
$rev =
(isset
($revision_map[$file]) ?
$revision_map[$file] :
'?');
PrintTableCell(' '.
$filesize.
' '.
$size_unit_prefix.
'B', 'text_low');
* Creates a file archive of the current webspace called "Spaceball".
* @param SwcConfig $config Configuration for the concrete project.
* @param string $file_name Name of the Spaceball file. It is stored within
* archive path as set in SwcConfig.
* @param boolean $overwrite Whether or not an existing Spaceball should
* @return string Textual result of the operation.
$sb_dir =
$config->GetSpaceballDir();
$spaceball_file =
$sb_dir.
'/'.
$file_name;
// Check if file exists and can be overwritten
if (!unlink($spaceball_file)){
$webspace =
$config->GetWebspaceRootDir();
if (count($file_list) ==
0){
foreach($file_list as $file){
// check if it is not an spaceball
$zip->addFile($content, $file, $filetime);
// Save the spaceball and create path if necessary.
$path =
$sb_dir.
'/'.
$path;
if (!$zip->store($spaceball_file)){
$spaceball_hints =
array();
$hint_content =
"; Simple file that contains hints about generated Spaceballs.\n".
"; This file is automatically generated.\n".
"; PLEASE DO NOT EDIT IT MANUALLY!\n\n";
foreach($spaceball_hints as $group =>
$data){
$hint_content .=
'['.
$group.
"]\n";
foreach($data as $key =>
$val){
$hint_content .=
$key.
' = '.
$val.
"\n";
* Returns the files recursively including subdirectory starting with the
* given path. Hidden files and directories can be ignored,
* <i>.svn</i> directories are always ignored. If an error occurs,
* it is returned as only array entry.
* @param string $path Absolute path of the dirctory to start with.
* @param array $files Array in which the file structure or
* translated error message in index <i>IDX_EXEC_RES</i> is returned.
* @param string $rel_path Relative path for files, empty per default.
function GetFiles($path, &$files, $ignore_hidden =
false, $rel_path =
''){
while ($filename !==
false){
if ($filename !=
'.' &&
$filename !=
'..' &&
$filename !=
'.svn' &&
(!$ignore_hidden ||
strpos($filename, '.') !==
0)){
if (is_dir($path.
'/'.
$filename)){
GetFiles($path.
'/'.
$filename, $files, $ignore_hidden, $rel_path.
($rel_path !=
'' ?
'/' :
'').
$filename);
$files[] =
$rel_path.
($rel_path !=
'' ?
'/' :
'').
$filename;