<?php
/**
* $Horde$
*
* Copyright 2007 The Horde Project (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*
* @author Jan Schneider <jan@horde.org>
*/
@define('IMP_BASE', dirname(__FILE__));
define('AUTH_HANDLER', true);
$session_control = 'none';
$authentication = 'none';
require_once IMP_BASE . '/lib/base.php';
require_once 'Horde/Compress.php';
require_once 'VFS.php';
$xpi = Horde_Compress::factory('zip');
$vfs = VFS::factory('file', array('vfsroot' => IMP_TEMPLATES));
// http://neo.wg.de/headhorde/imp/compose.php?popup=1&to=^T&cc=^C&bcc=^B&message=^M&subject=^S
$list = $vfs->listFolder('/extension', 'CVS', false, false, true);
$list = array($list);
$dirs = $files = array();
while (count($list) && count($list[0])) {
$file = array_shift($list[0]);
if ($file['type'] == '**dir') {
array_unshift($list, $file['subdirs']);
$dirs[] = $file['name'];
} else {
$dir = implode('/', $dirs);
$files[] = array(
'data' => file_get_contents(IMP_TEMPLATES . '/extension/' . $dir . '/' . $file['name']),
'name' => ($dir ? $dir . '/' : '') . $file['name'],
'time' => $file['date']);
}
while (count($list) && !count($list[0])) {
array_shift($list);
array_pop($dirs);
}
}
header('Content-Type: application/x-xpinstall');
echo $xpi->compress($files);