exit; } $size = filesize($workdir . "/" . $filename); $dlfilename = $file->getDownloadname(); if (empty($dlfilename)) { $dlfilename = $fileid . "." . $file->getExt(); } if (strstr($HTTP_SERVER_VARS["HTTP_USER_AGENT"], "MSIE")) { // For IE if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/convert.php")) { $langdir = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language']; } else { $langdir = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/english"; } include_once $langdir . "/convert.php"; $dlfilename = WfsConvert::filenameForWin($dlfilename); header("Content-Type: " . $file->getMinetype()); header("Content-Length: {$size}"); header("Cache-control: private"); header("Content-Disposition: attachment; filename={$dlfilename}"); } else { // For Other browsers header("Content-Type: " . $file->getMinetype()); header("Content-Length: {$size}"); if (preg_match("/[^a-zA-Z0-9_\\-\\.]/", $dlfilename)) { $dlfilename = $fileid . "." . $file->getExt(); } header("Content-Disposition: attachment; filename=\"{$dlfilename}\""); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate");
function setFiletextByFile() { global $WfsHelperDir, $xoopsModule, $xoopsConfig, $wfsConfig; $workdir = XOOPS_ROOT_PATH . "/" . $wfsConfig['filesbasepath']; // set fullpath of $this->filerealname if (preg_match("/^\\/|~[ABCDEFGHIJKLMNOPQRSTQVWXYZ]:\\//", $this->filerealname)) { $filename = $this->filerealname; } else { $filename = $this->filerealname; } // helper app & character set convertor if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/convert.php")) { $langdir = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language']; } else { $langdir = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/english"; } include_once $langdir . "/convert.php"; // switch ($this->minetype) { case "text/plain": $this->filetext = join(' ', file($filename)); $this->filetext = WfsConvert::TextPlane($this->filetext); break; case "text/html": $this->filetext = join(' ', file($filename)); //echo "text/html<br />"; $this->filetext = WfsConvert::TextHtml($this->filetext); break; case "application/vnd.ms-excel": if (!empty($WfsHelperDir['application/vnd.ms-excel'])) { exec(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/helper/" . $WfsHelperDir['application/vnd.ms-excel'] . "/xlhtml -te " . $filename, $ret); $this->filetext = join(' ', $ret); $this->filetext = WfsConvert::TextHtml($this->filetext); //echo "filetext = ".$this->filetext."<br />"; } break; case "application/pdf": if (!empty($WfsHelperDir['application/pdf'])) { $distfile = tempnam($workdir . "/temp/", "pdf"); exec(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/helper/" . $WfsHelperDir['application/pdf'] . "/pdftotext " . "-cfg " . $langdir . "/xpdfrc " . $filename . " " . $distfile); $this->filetext = join(' ', file($distfile)); $this->filetext = WfsConvert::stripSpaces($this->filetext); unlink($distfile); } break; case "default": default: $this->filetext = ""; } }