diff options
author | Sem <sembrestels@riseup.net> | 2013-11-09 16:13:46 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2013-11-09 16:13:46 +0100 |
commit | e2a2fbdccaf0f48878903f448428cab5852d0870 (patch) | |
tree | 9cbe6b74c8e2e191ec65fba78d7435af35506f82 /mod/dokuwiki/vendors/dokuwiki/lib/plugins/indexmenu/inc/repo.class.php | |
parent | 59448d8a9864573c05477a63a6dda404c455fdb6 (diff) | |
parent | b603da53e13005c67d05efac67b70023dfffc450 (diff) | |
download | elgg-e2a2fbdccaf0f48878903f448428cab5852d0870.tar.gz elgg-e2a2fbdccaf0f48878903f448428cab5852d0870.tar.bz2 |
Add 'mod/dokuwiki/' from commit 'b603da53e13005c67d05efac67b70023dfffc450'
git-subtree-dir: mod/dokuwiki
git-subtree-mainline: 59448d8a9864573c05477a63a6dda404c455fdb6
git-subtree-split: b603da53e13005c67d05efac67b70023dfffc450
Diffstat (limited to 'mod/dokuwiki/vendors/dokuwiki/lib/plugins/indexmenu/inc/repo.class.php')
-rw-r--r-- | mod/dokuwiki/vendors/dokuwiki/lib/plugins/indexmenu/inc/repo.class.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mod/dokuwiki/vendors/dokuwiki/lib/plugins/indexmenu/inc/repo.class.php b/mod/dokuwiki/vendors/dokuwiki/lib/plugins/indexmenu/inc/repo.class.php new file mode 100644 index 000000000..04dc75675 --- /dev/null +++ b/mod/dokuwiki/vendors/dokuwiki/lib/plugins/indexmenu/inc/repo.class.php @@ -0,0 +1,51 @@ +<?php +class repo_indexmenu_plugin { + /** + * Send a zipped theme + * + * @author Samuele Tognini <samuele@netsons.org> + */ + + function send_theme ($file) { + require_once(DOKU_PLUGIN.'indexmenu/syntax/indexmenu.php'); + $idxm=new syntax_plugin_indexmenu_indexmenu(); + //clean the file name + $file=cleanID($file); + //check config + if(!$idxm->getConf('be_repo') || empty($file)) return false; + $repodir=INDEXMENU_IMG_ABSDIR."/repository"; + $zipfile=$repodir."/$file.zip"; + $localtheme=INDEXMENU_IMG_ABSDIR."/$file/"; + //theme does not exists + if (!file_exists($localtheme)) return false; + if (!io_mkdir_p($repodir)) return false; + $lm=@filemtime($zipfile); + //no cached zip or older than 1 day + if ($lm < time()-(60*60*24)) { + //create the zip + require_once(DOKU_PLUGIN."indexmenu/inc/pclzip.lib.php"); + @unlink($zipfile); + $zip=new PclZip($zipfile); + $status=$zip->add($localtheme,PCLZIP_OPT_REMOVE_ALL_PATH); + //error + if ($status == 0) return false; + } + $len = (int) filesize($zipfile); + //don't send large zips + if ($len > 2*1024*1024) return false; + //headers + header('Cache-Control: must-revalidate, no-transform, post-check=0, pre-check=0'); + header('Pragma: public'); + header('Content-Type: application/zip'); + header('Content-Disposition: attachment; filename="'.basename($zipfile).'";'); + header("Content-Transfer-Encoding: binary"); + //send zip + $fp=@fopen($zipfile, 'rb'); + if ($fp) { + $ct=@fread($fp, $len); + print $ct; + } + @fclose($fp); + return true; + } +} |