Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create and remove temp dir. fixes #24, maybe #25

  • Loading branch information...
commit 1c9fae9eda14b27299d8f89b406a1d73eade9c42 1 parent 7a5bffa
@splitbrain authored
Showing with 24 additions and 2 deletions.
  1. +23 −1 DokuPDF.class.php
  2. +1 −1  plugin.info.txt
View
24 DokuPDF.class.php
@@ -8,7 +8,7 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/
-if(!defined('_MPDF_TEMP_PATH')) define('_MPDF_TEMP_PATH', $conf['tmpdir'].'/dwpdf/'.rand(1,1000));
+if(!defined('_MPDF_TEMP_PATH')) define('_MPDF_TEMP_PATH', $conf['tmpdir'].'/dwpdf/'.rand(1,1000).'/');
if(!defined('_MPDF_TTFONTDATAPATH')) define('_MPDF_TTFONTDATAPATH',$conf['cachedir'].'/mpdf_ttf/');
require_once(dirname(__FILE__)."/mpdf/mpdf.php");
@@ -16,12 +16,34 @@ class DokuPDF extends mpdf {
function __construct(){
io_mkdir_p(_MPDF_TTFONTDATAPATH);
+ io_mkdir_p(_MPDF_TEMP_PATH);
// we're always UTF-8
parent::__construct('UTF-8-s');
$this->SetAutoFont(AUTOFONT_ALL);
$this->ignore_invalid_utf8 = true;
+ }
+
+ /**
+ * Cleanup temp dir
+ */
+ function __destruct(){
+ $this->deletedir(_MPDF_TEMP_PATH);
+ }
+ /**
+ * Recursively delete a directory and its contents
+ *
+ * @link http://de3.php.net/manual/en/function.rmdir.php#108113
+ */
+ function deletedir($dir){
+ foreach(glob($dir . '/*') as $file) {
+ if(is_dir($file))
+ $this->deletedir($file);
+ else
+ @unlink($file);
+ }
+ @rmdir($dir);
}
/**
View
2  plugin.info.txt
@@ -1,7 +1,7 @@
base dw2pdf
author Luigi Micco
email l.micco@tiscali.it
-date 2012-05-11
+date 2012-05-19
name Dw2Pdf plugin
desc DokuWiki to PDF converter
url http://www.dokuwiki.org/plugin:dw2pdf
Please sign in to comment.
Something went wrong with that request. Please try again.