function generateFiles($tpl_vars)
 {
     global $wgOut, $wgUser;
     $this->debug = $wgUser->getOption('w2lDebug');
     $this->is_admin = in_array('sysop', $wgUser->getGroups());
     $msg = '';
     $tempdir = w2lTempDir();
     if ($this->debug == true && $this->is_admin == true) {
         $msg .= "System temp dir: " . $tempdir . "\n";
     }
     if (substr($tempdir, -1) != DIRECTORY_SEPARATOR) {
         $tempdir .= DIRECTORY_SEPARATOR;
     }
     $tempdir .= 'w2ltmp-' . $this->piece;
     if ($this->debug == true && $this->is_admin == true) {
         $msg .= "W2L temp dir: " . $tempdir . "\n";
     }
     $this->path = $tempdir;
     if (true == $this->mkdir) {
         if (!@mkdir($this->path)) {
             wfVarDump($this->path);
             $wgOut->addHTML(wfMsg('w2l_temp_dir_missing'));
             $this->msg = $msg;
             return false;
         }
         $chmod = chmod($this->path, 0777);
         if (!file_exists($this->path) or !is_dir($this->path) or !is_writable($this->path)) {
             $wgOut->addHTML(wfMsg('w2l_temp_dir_missing'));
             $this->msg = $msg;
             return false;
         }
     }
     $cur_dir = getcwd();
     chdir($tempdir);
     foreach ($this->files as $file_name => $file_content) {
         $file_content = str_replace(array_keys($tpl_vars), array_values($tpl_vars), $file_content);
         $failure = file_put_contents($file_name, $file_content);
         if ($failure !== false) {
             $msg .= 'Creating file ' . $file_name . ' with ' . $failure . ' Bytes' . "\n";
         } else {
             $msg .= 'Error creating file ' . $file_name . "\n";
         }
         chmod($file_name, 0666);
     }
     chdir($cur_dir);
     $this->msg = $msg;
     return true;
 }
 *
 * License:
 * 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.
 */
define('W2L_SENDFILE', 1);
// Some Config-Hacks to allow for including some original Mediawiki-files:
define('MEDIAWIKI', 1);
require_once "../../includes/GlobalFunctions.php";
require_once "w2lFunctions.php";
$file = addslashes($_GET['fid']);
$fmt = addslashes($_GET['fmt']);
$title = addslashes($_GET['title']);
$tmp = w2lTempDir();
$title = w2lWebsafeTitle($title);
$file_loc = $tmp . DIRECTORY_SEPARATOR . 'w2ltmp-' . $file . DIRECTORY_SEPARATOR . 'Main.' . $fmt;
switch ($fmt) {
    case 'pdf':
        $mime_type = 'application/pdf';
        break;
    case 'tex':
        $mime_type = 'application/x-tex';
        break;
    default:
        $mime_type = 'text/plain';
        break;
}
if (file_exists($file_loc)) {
    header("Content-Type: " . $mime_type);
Ejemplo n.º 3
0
 function clearTempFolder()
 {
     $dir = w2lTempDir();
     $state = $this->full_rmdir($dir, false);
     return $state;
 }