2 class repo_indexmenu_plugin
{
6 * @author Samuele Tognini <samuele@netsons.org>
9 function send_theme ($file) {
10 require_once(DOKU_PLUGIN
.'indexmenu/syntax/indexmenu.php');
11 $idxm=new syntax_plugin_indexmenu_indexmenu();
15 if(!$idxm->getConf('be_repo') ||
empty($file)) return false;
16 $repodir=INDEXMENU_IMG_ABSDIR
."/repository";
17 $zipfile=$repodir."/$file.zip";
18 $localtheme=INDEXMENU_IMG_ABSDIR
."/$file/";
19 //theme does not exists
20 if (!file_exists($localtheme)) return false;
21 if (!io_mkdir_p($repodir)) return false;
22 $lm=@filemtime
($zipfile);
23 //no cached zip or older than 1 day
24 if ($lm < time()-(60*60*24)) {
26 require_once(DOKU_PLUGIN
."indexmenu/inc/pclzip.lib.php");
28 $zip=new PclZip($zipfile);
29 $status=$zip->add($localtheme,PCLZIP_OPT_REMOVE_ALL_PATH
);
31 if ($status == 0) return false;
33 $len = (int) filesize($zipfile);
34 //don't send large zips
35 if ($len > 2*1024*1024) return false;
37 header('Cache-Control: must-revalidate, no-transform, post-check=0, pre-check=0');
38 header('Pragma: public');
39 header('Content-Type: application/zip');
40 header('Content-Disposition: attachment; filename="'.basename($zipfile).'";');
41 header("Content-Transfer-Encoding: binary");
43 $fp=@fopen
($zipfile, 'rb');
45 $ct=@fread
($fp, $len);