Пример #1
0
 function down_sql_action()
 {
     $file = $this->config[sy_weburl] . "/data/backup/{$_GET['name']}";
     header('Content-type: application/sql');
     header('Content-Disposition: attachment; filename="' . $_GET[name] . '"');
     readfile($file);
 }
Пример #2
0
 public function executeDownload(sfWebRequest $request)
 {
     $this->checkProject($request);
     $this->checkProfile($request, $this->ei_project);
     $this->checkAttachment($request);
     //throw new Exception($this->ei_subject_attachment->getPath());
     $filePath = sfConfig::get('sf_upload_dir') . '/subjectAttachements/' . $this->ei_subject_attachment->getPath();
     //$mimeType = mime_content_type($this->ei_subject_attachment->getPath());
     /** @var $response sfWebResponse */
     $response = $this->getResponse();
     $response->clearHttpHeaders();
     //$response->setContentType($mimeType);
     $response->setHttpHeader('Content-Disposition', 'attachment; filename="' . $this->ei_subject_attachment->getFileName() . '"');
     $response->setHttpHeader('Content-Description', 'File Transfer');
     $response->setHttpHeader('Content-Transfer-Encoding', 'binary');
     $response->setHttpHeader('Content-Length', filesize($filePath));
     $response->setHttpHeader('Cache-Control', 'public, must-revalidate');
     // if https then always give a Pragma header like this  to overwrite the "pragma: no-cache" header which
     // will hint IE8 from caching the file during download and leads to a download error!!!
     $response->setHttpHeader('Pragma', 'public');
     //$response->setContent(file_get_contents($filePath)); # will produce a memory limit exhausted error
     $response->sendHttpHeaders();
     ob_end_flush();
     return $this->renderText(readfile($filePath));
 }
Пример #3
0
 public function display($cachable = false, $urlparams = false)
 {
     JRequest::setVar('view', JRequest::getCmd('view', 'Orphans'));
     if (isset($_POST['_orphanaction']) && $_POST['_orphanaction'] == "zipIt") {
         $file = tempnam("tmp", "zip");
         $zip = new ZipArchive();
         $zip->open($file, ZipArchive::OVERWRITE);
         foreach ($_POST['tozip'] as $_file) {
             $zip->addFile(JPATH_ROOT . "/" . $_file, $_file);
         }
         $zip->close();
         header('Content-Type: application/zip');
         header('Content-Length: ' . filesize($file));
         header('Content-Disposition: attachment; filename="orphans.zip"');
         readfile($file);
         unlink($file);
         die;
     } else {
         if (isset($_POST['_orphanaction']) && $_POST['_orphanaction'] == "delete" && isset($_POST['_confirmAction'])) {
             foreach ($_POST['tozip'] as $_file) {
                 unlink(JPATH_ROOT . "/" . $_file);
             }
         }
     }
     // call parent behavior
     parent::display($cachable);
 }
Пример #4
0
 function image()
 {
     ob_end_clean();
     $hash = basename($_REQUEST["hash"]);
     if ($hash) {
         $filename = $this->cache_dir . "/" . $hash . '.png';
         if (file_exists($filename)) {
             /* See if we can use X-Sendfile */
             $xsendfile = false;
             if (function_exists('apache_get_modules') && array_search('mod_xsendfile', apache_get_modules())) {
                 $xsendfile = true;
             }
             if ($xsendfile) {
                 header("X-Sendfile: {$filename}");
                 header("Content-type: application/octet-stream");
                 header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
             } else {
                 header("Content-type: image/png");
                 $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT";
                 header("Last-Modified: {$stamp}", true);
                 readfile($filename);
             }
         } else {
             header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
             echo "File not found.";
         }
     }
 }
Пример #5
0
 public function display()
 {
     //parse image uri
     $preset = $this->uri->segment(2);
     $fileId = $this->uri->segment(3);
     $file = new File($fileId);
     if (!$file->isFileOfUser($this->c_user->id)) {
         return false;
     }
     $imageFile = $file->image->get();
     $updated = (string) $file->image->updated;
     $manipulator = $this->get('core.image.manipulator');
     if ($this->input->post()) {
         $this->cropParamUpdate($file);
         echo 'images/' . $preset . '/' . $fileId . '/' . $imageFile->updated . '?prev=' . $updated;
     } else {
         $path = FCPATH . $file->path . '/' . $file->fullname;
         $output = $manipulator->getImagePreset($path, $preset, $imageFile, Arr::get($_GET, 'prev', null));
         if ($output) {
             $info = getimagesize($output);
             header("Content-Disposition: filename={$output};");
             header("Content-Type: {$info["mime"]}");
             header('Content-Transfer-Encoding: binary');
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
             readfile($output);
         }
     }
 }
Пример #6
0
    private function pageOpen()
    {
        ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Portfolio</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">

    <?php 
        /* <link rel="stylesheet" href="/style.css"> */
        ?>
    <style><?php 
        readfile(dirname(dirname(__DIR__)) . '/html/style.css');
        ?>
</style>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
    <script src="/tablesort.min.js"></script>
    <script src="/tablesort.number.js"></script>
    <script src="/script.js"></script>
  </head>
  <body>
<?php 
    }
Пример #7
0
 /**
  * Stream a file to the browser, adding all the headings and fun stuff.
  * Headers sent include: Content-type, Content-Length, Last-Modified,
  * and Content-Disposition.
  *
  * @param string $fname Full name and path of the file to stream
  * @param array $headers Any additional headers to send
  * @param bool $sendErrors Send error messages if errors occur (like 404)
  * @throws MWException
  * @return bool Success
  */
 public static function stream($fname, $headers = array(), $sendErrors = true)
 {
     wfProfileIn(__METHOD__);
     if (FileBackend::isStoragePath($fname)) {
         // sanity
         wfProfileOut(__METHOD__);
         throw new MWException(__FUNCTION__ . " given storage path '{$fname}'.");
     }
     wfSuppressWarnings();
     $stat = stat($fname);
     wfRestoreWarnings();
     $res = self::prepareForStream($fname, $stat, $headers, $sendErrors);
     if ($res == self::NOT_MODIFIED) {
         $ok = true;
         // use client cache
     } elseif ($res == self::READY_STREAM) {
         wfProfileIn(__METHOD__ . '-send');
         $ok = readfile($fname);
         wfProfileOut(__METHOD__ . '-send');
     } else {
         $ok = false;
         // failed
     }
     wfProfileOut(__METHOD__);
     return $ok;
 }
Пример #8
0
 public static function GrabImage($url, $filename = "")
 {
     if ($url == "") {
         return false;
     }
     if ($filename == "") {
         $ext = strrchr($url, ".");
         if ($ext != ".gif" && $ext != ".jpg" && $ext != ".png") {
             return false;
         }
         $filename = date("YmdHis") . $ext;
     } else {
         $newPath = dirname($filename);
         DirectoryFile::dirCreate($newPath);
     }
     ob_start();
     readfile($url);
     $img = ob_get_contents();
     ob_end_clean();
     $size = strlen($img);
     $fp2 = @fopen($filename, "a");
     fwrite($fp2, $img);
     fclose($fp2);
     return $filename;
 }
Пример #9
0
 public function action_thumb()
 {
     if (!preg_match('/^image\\/.*$/i', $this->attachment['mime'])) {
         $ext = File::ext_by_mime($this->attachment['mime']);
         if (file_exists(DOCROOT . 'img/icons/' . $ext . '-icon-128x128.png')) {
             $this->redirect('/img/icons/' . $ext . '-icon-128x128.png');
         } else {
             $this->redirect('http://stdicon.com/' . $this->attachment['mime'] . '?size=96&default=http://stdicon.com/text');
         }
     }
     if (!file_exists(DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb')) {
         if (!file_exists(DOCROOT . 'storage/' . $this->attachment['id'])) {
             $this->redirect('http://stdicon.com/' . $this->attachment['mime'] . '?size=96&default=http://stdicon.com/text');
         }
         $data = file_get_contents(DOCROOT . 'storage/' . $this->attachment['id']);
         $image = imagecreatefromstring($data);
         $x = imagesx($image);
         $y = imagesy($image);
         $size = max($x, $y);
         $x = round($x / $size * 96);
         $y = round($y / $size * 96);
         $thumb = imagecreatetruecolor($x, $y);
         imagealphablending($thumb, false);
         imagesavealpha($thumb, true);
         imagecopyresampled($thumb, $image, 0, 0, 0, 0, $x, $y, imagesx($image), imagesy($image));
         imagepng($thumb, DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb', 9);
     }
     header('Content-type: image/png');
     header('Content-disposition: filename="thumbnail.png"');
     header('Content-length: ' . filesize(DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb'));
     readfile(DOCROOT . 'storage/' . $this->attachment['id'] . '.thumb');
     die;
 }
Пример #10
0
 function export($params = null)
 {
     $patients = $this->Patient->getPatients($params);
     unset($this->Patient);
     $zip = new ZipArchive();
     $file = 'GaiaEHR-Patients-Export-' . time() . '.zip';
     if ($zip->open($file, ZipArchive::CREATE) !== true) {
         throw new Exception("cannot open <{$file}>");
     }
     $zip->addFromString('cda2.xsl', file_get_contents(ROOT . '/lib/CCRCDA/schema/cda2.xsl'));
     foreach ($patients as $i => $patient) {
         $patient = (object) $patient;
         $this->CCDDocument->setPid($patient->pid);
         $this->CCDDocument->createCCD();
         $this->CCDDocument->setTemplate('toc');
         $this->CCDDocument->createCCD();
         $ccd = $this->CCDDocument->get();
         $zip->addFromString($patient->pid . '-Patient-CDA' . '.xml', $ccd);
         unset($patients[$i], $ccd);
     }
     $zip->close();
     header('Content-Type: application/zip');
     header('Content-Length: ' . filesize($file));
     header('Content-Disposition: attachment; filename="' . $file . '"');
     readfile($file);
 }
Пример #11
0
 function dumpSPOG()
 {
     header('Content-Type: application/sparql-results+xml');
     if ($this->v('store_use_dump_dir', 0, $this->a)) {
         $path = $this->v('store_dump_dir', 'dumps', $this->a);
         /* default: monthly dumps */
         $path_suffix = $this->v('store_dump_suffix', date('Y_m'), $this->a);
         $path .= '/dump_' . $path_suffix . '.spog';
         if (!file_exists($path)) {
             $this->saveSPOG($path);
         }
         readfile($path);
         exit;
     }
     echo $this->getHeader();
     $offset = 0;
     do {
         $proceed = 0;
         $rs = $this->getRecordset($offset);
         if (!$rs) {
             break;
         }
         while ($row = mysqli_fetch_array($rs)) {
             echo $this->getEntry($row);
             $proceed = 1;
         }
         $offset += $this->limit;
     } while ($proceed);
     echo $this->getFooter();
 }
Пример #12
0
/**
 * This function will feed the $say parameter to a speech
 * synthesizer and send the resulting audio file to the browser
 *
 * @param string $say
 */
function spamhurdles_spoken_captcha($say)
{
    global $PHORUM;
    $conf = $PHORUM["mod_spamhurdles"]["captcha"];
    if ($conf["spoken_captcha"] && file_exists($conf["flite_location"])) {
        // Generate the command for building the wav file.
        $tmpfile = tempnam($PHORUM["cache"], 'spokencaptcha_');
        $cmd = escapeshellcmd($conf["flite_location"]);
        $cmd .= " -t " . escapeshellarg($say);
        $cmd .= " -o " . escapeshellarg($tmpfile);
        // Build the wav file.
        system($cmd);
        // Did we succeed in building the wav? Then stream it to the user.
        if (file_exists($tmpfile) and filesize($tmpfile) > 0) {
            header("Content-Type: audio/x-wav");
            header("Content-Disposition: attachment; filename=captchacode.wav");
            header("Content-Length: " . filesize($tmpfile));
            readfile($tmpfile);
            unlink($tmpfile);
            exit(0);
            // Something in the setup is apparently wrong here.
        } else {
            die("<h1>Internal Spam Hurdles module error</h1>" . "Failed to generate a wave file using flite.\n" . "Please contact the site maintainer to report this problem.");
        }
    } else {
        die("<h1>Internal Spam Hurdles module error</h1>" . "Spoken captcha requested, but no spoken text is available\n" . "or the speech system has not been enabled/configured. " . "Please contact the site maintainer to report this problem.");
    }
}
Пример #13
0
 /**
  * Save the image as the image type the original image was
  *
  * @param  string $savePath     - The path to store the new image
  * @param  string $imageQuality - The qulaity level of image to create
  *
  * @param bool    $download
  *
  * @return null Saves the image
  */
 public function saveImage($savePath, $imageQuality = "100", $download = false)
 {
     if (!$this->newImage) {
         return;
     }
     switch ($this->ext) {
         case 'image/jpg':
         case 'image/jpeg':
             // Check PHP supports this file type
             if (imagetypes() & IMG_JPG) {
                 imagejpeg($this->newImage, $savePath, $imageQuality);
             }
             break;
         case 'image/gif':
             // Check PHP supports this file type
             if (imagetypes() & IMG_GIF) {
                 imagegif($this->newImage, $savePath);
             }
             break;
         case 'image/png':
             $invertScaleQuality = 9 - round($imageQuality / 100 * 9);
             // Check PHP supports this file type
             if (imagetypes() & IMG_PNG) {
                 imagepng($this->newImage, $savePath, $invertScaleQuality);
             }
             break;
     }
     if ($download) {
         header('Content-Description: File Transfer');
         header("Content-type: application/octet-stream");
         header("Content-disposition: attachment; filename= " . $savePath . "");
         readfile($savePath);
     }
     imagedestroy($this->newImage);
 }
Пример #14
0
 /**
  * Display the application.
  */
 public function render()
 {
     $user = JFactory::getUser();
     $conf = JFactory::getConfig();
     if ($user->guest || !JFactory::getUser()->authorise('core.admin', 'com_cache')) {
         //TODO change this to the the proper access acl
         echo JText::_('Unauthorized');
         exit;
     }
     $logfile = $this->input->getPath('logfile', null);
     if (is_null($logfile)) {
         echo JText::_('Log not found.');
         exit;
     }
     $logfile_path = JPATH_ROOT . '/logs/' . $logfile;
     if (!is_file($logfile_path)) {
         echo JText::_('Log not found.');
         exit;
     }
     JResponse::clearHeaders();
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . pathinfo($logfile, PATHINFO_FILENAME) . '.log');
     header('Content-Length: ' . filesize($logfile_path) . ';');
     header('Content-Transfer-Encoding: binary');
     readfile($logfile_path);
     exit;
 }
Пример #15
0
 function redirect($filename)
 {
     Header("Content-Type: text/xml; charset=" . $this->encoding . "; filename=" . basename($filename));
     Header("Content-Disposition: inline; filename=" . basename($filename));
     readfile($filename, "r");
     die;
 }
Пример #16
0
 /**
  * Try download file
  */
 public function download()
 {
     if ($this->fileInfo instanceof \SplFileInfo) {
         if ($this->fileInfo->isFile()) {
             if (is_array($this->validatorExtension)) {
                 if (!in_array($this->fileInfo->getExtension(), $this->validatorExtension)) {
                     throw new \Exception("Extensão invalida!");
                 }
             }
             if (!$this->fileInfo->isReadable()) {
                 throw new \Exception("O Arquivo não pode ser lido!");
             }
             if (is_null($this->newName)) {
                 $this->setNewName($this->fileInfo->getBasename());
             }
             $finfo = new \finfo();
             header("Content-Type: {$finfo->file($this->fileInfo->getRealPath(), FILEINFO_MIME)}");
             header("Content-Length: {$this->fileInfo->getSize()}");
             header("Content-Disposition: attachment; filename={$this->newName}");
             readfile($this->fileInfo->getRealPath());
         } else {
             throw new \Exception("Por favor, adicione um arquivo valido!");
         }
     } else {
         throw new \Exception("Por favor, adicione o arquivo primeiro!");
     }
 }
Пример #17
0
function download($verze)
{
    $verze_ = $GLOBALS['download_dir'] . $verze;
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($verze_));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($verze_));
    ob_clean();
    flush();
    readfile($verze_);
    $relace = mysql_connect('localhost', 'host', 'h0st207p');
    if (!$relace) {
        die('Could not connect: ' . mysql_error());
    }
    if (!mysql_select_db('host', $relace)) {
        die('Could not select database');
    }
    $sql = 'SELECT stazeno FROM sfepy_downloads WHERE verze="' . $verze . '"';
    $data = mysql_query($sql, $relace);
    if (!$data) {
        die('DB Error, could not query the database: ' . mysql_error());
    }
    list($stazeno) = mysql_fetch_row($data);
    $stazeno = $stazeno + 1;
    $sql = 'UPDATE sfepy_downloads SET stazeno="' . $stazeno . '" WHERE verze="' . $verze . '"';
    mysql_query($sql, $relace);
    mysql_free_result($data);
}
 /**
  * Output file to the browser.
  * For performance reasons, we avoid SS_HTTPResponse and just output the contents instead.
  */
 public function sendFile($file)
 {
     $path = $file->getFullPath();
     if (SapphireTest::is_running_test()) {
         return file_get_contents($path);
     }
     header('Content-Description: File Transfer');
     // Quotes needed to retain spaces (http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download)
     header('Content-Disposition: inline; filename="' . basename($path) . '"');
     header('Content-Length: ' . $file->getAbsoluteSize());
     header('Content-Type: ' . HTTP::get_mime_type($file->getRelativePath()));
     header('Content-Transfer-Encoding: binary');
     // Fixes IE6,7,8 file downloads over HTTPS bug (http://support.microsoft.com/kb/812935)
     header('Pragma: ');
     if ($this->config()->min_download_bandwidth) {
         // Allow the download to last long enough to allow full download with min_download_bandwidth connection.
         increase_time_limit_to((int) (filesize($path) / ($this->config()->min_download_bandwidth * 1024)));
     } else {
         // Remove the timelimit.
         increase_time_limit_to(0);
     }
     // Clear PHP buffer, otherwise the script will try to allocate memory for entire file.
     while (ob_get_level() > 0) {
         ob_end_flush();
     }
     // Prevent blocking of the session file by PHP. Without this the user can't visit another page of the same
     // website during download (see http://konrness.com/php5/how-to-prevent-blocking-php-requests/)
     session_write_close();
     readfile($path);
     die;
 }
Пример #19
0
function getguestcache()
{
    global $fid, $tid, $timestamp, $db_guestdir, $db_guestindex, $db_guestthread, $db_guestread;
    $page = (int) $_GET['page'];
    switch (SCR) {
        case 'thread':
            empty($page) && ($page = 1);
            if (file_exists(D_P . "{$db_guestdir}/T_{$fid}/{$fid}_{$page}.html") && $timestamp - pwFilemtime(D_P . "{$db_guestdir}/T_{$fid}/{$fid}_{$page}.html") < $db_guestthread) {
                readfile(D_P . "{$db_guestdir}/T_{$fid}/{$fid}_{$page}.html");
                guestfooter();
            }
            break;
        case 'index':
            $indexpath = getguestIndexpath();
            if (file_exists($indexpath) && $timestamp - pwFilemtime($indexpath) < $db_guestindex) {
                readfile($indexpath);
                guestfooter();
            }
            break;
        case 'read':
            $tmp = 'R_' . intval($tid / 500);
            !$page && ($page = 1);
            if (file_exists(D_P . "{$db_guestdir}/{$tmp}/{$tid}_{$page}.html") && $timestamp - pwFilemtime(D_P . "{$db_guestdir}/{$tmp}/{$tid}_{$page}.html") < $db_guestread) {
                readfile(D_P . "{$db_guestdir}/{$tmp}/{$tid}_{$page}.html");
                echo "<script src=\"hitcache.php?tid={$tid}\"></script>";
                guestfooter();
            }
            break;
    }
}
Пример #20
0
function forceDownload($file)
{
    //Check file exist or not
    if (file_exists($file)) {
        if (ini_get('zlib.output_compression')) {
            // required for IE
            ini_set('zlib.output_compression', 'Off');
        }
        // Get mine type of file.
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        // return mime type ala mimetype extension
        $mimeType = finfo_file($finfo, $file) . "\n";
        finfo_close($finfo);
        header('Expires: 0');
        header('Pragma: public');
        header('Cache-Control: private', false);
        header('Content-Type:' . $mimeType);
        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
        header('Content-Transfer-Encoding: binary');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-Length: ' . filesize($file));
        header('Connection: close');
        readfile($file);
        exit;
    } else {
        return "File does not exist";
    }
}
 public function send_to_browser($destination_file_name, $redirect_to_referer = TRUE)
 {
     if (headers_sent()) {
         error_log("Headers already sent.  Download of {$this->full_path} failed.");
         die('Headers already sent');
     }
     // Required for some browsers
     if (ini_get('zlib.output_compression')) {
         ini_set('zlib.output_compression', 'Off');
     }
     // File Exists?
     if (is_dir($this->full_path) || !file_exists($this->full_path)) {
         return FALSE;
         # To stop hitting the 'exit' command at the bottom of this function.
     }
     if (ob_get_contents()) {
         # Make sure no junk is included in the file
         ob_end_clean();
     }
     header("Content-type: {$this->mime_type}");
     header('Content-Disposition: attachment; filename="' . $destination_file_name . '"');
     header('Cache-Control: no-store, no-cache');
     if (ob_get_contents()) {
         # Make __absolutely__ :) sure no junk is included in the file
         ob_end_flush();
         flush();
     }
     readfile($this->full_path);
     die;
 }
 function get_image()
 {
     $mime = get_mimetype($this->path);
     viscacha_header('Content-Type: ' . $mime['mime']);
     readfile($this->path);
     exit;
 }
Пример #23
0
 public function downloadAction()
 {
     $squadID = $this->params('id', 0);
     $squadRepo = $this->getEntityManager()->getRepository('Frontend\\Squads\\Entity\\Squad');
     /** @var Squad $squadEntity */
     $squadEntity = $squadRepo->findOneBy(array('user' => $this->identity(), 'id' => $squadID));
     if (!$squadEntity) {
         $this->flashMessenger()->addErrorMessage('Squad not found');
         return $this->redirect('frontend/user/squads');
     }
     $fileName = 'squad_file_pack_armasquads_' . $squadID;
     $zipTmpPath = tempnam(ini_get('upload_tmp_dir'), $fileName);
     $zip = new \ZipArchive();
     $zip->open($zipTmpPath, \ZipArchive::CHECKCONS);
     if (!$zip) {
         $this->flashMessenger()->addErrorMessage('Squad Package Download currently not possible');
         return $this->redirect('frontend/user/squads');
     }
     $zip->addFromString('squad.xml', file_get_contents('http://' . $_SERVER['SERVER_NAME'] . $this->url()->fromRoute('frontend/user/squads/xml', array('id' => $squadEntity->getPrivateID()))));
     if ($squadEntity->getSquadLogoPaa()) {
         $zip->addFile(ROOT_PATH . $squadEntity->getSquadLogoPaa(), basename($squadEntity->getSquadLogoPaa()));
     }
     $zip->addFromString('squad.dtd', file_get_contents(realpath(__DIR__ . '/../../../../view/squads/xml/') . '/squad.dtd'));
     //$zip->addFromString('squad.xsl',file_get_contents(realpath(__DIR__ . '/../../../../view/squads/xml/').'/squad.xsl'));
     $zip->close();
     header('Content-Type: application/octet-stream');
     header("Content-Transfer-Encoding: Binary");
     header("Content-disposition: attachment; filename=\"" . basename($fileName) . ".zip\"");
     readfile($zipTmpPath);
     sleep(1);
     @unlink($zipTmpPath);
     die;
 }
Пример #24
0
 public function download()
 {
     $file = DIR_LOGS . $this->config->get('config_error_filename');
     clearstatcache();
     if (file_exists($file) && is_file($file)) {
         if (!headers_sent()) {
             if (filesize($file) > 0) {
                 header('Content-Type: application/octet-stream');
                 header('Content-Description: File Transfer');
                 header('Content-Disposition: attachment; filename=' . str_replace(' ', '_', $this->config->get('config_name')) . '_' . date('Y-m-d_H-i-s', time()) . '_error.log');
                 header('Content-Transfer-Encoding: binary');
                 header('Expires: 0');
                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                 header('Pragma: public');
                 header('Content-Length: ' . filesize($file));
                 readfile($file, 'rb');
                 exit;
             }
         } else {
             exit('Error: Headers already sent out!');
         }
     } else {
         $this->redirect($this->url->link('tool/error_log', 'token=' . $this->session->data['token'], 'SSL'));
     }
 }
 /**
  * send the content or the file to the browser.
  * @return boolean    true it it's ok
  */
 public function output()
 {
     if ($this->doDownload) {
         $this->mimeType = 'application/forcedownload';
         if (!strlen($this->outputFileName)) {
             $f = explode('/', str_replace('\\', '/', $this->fileName));
             $this->outputFileName = $f[count($f) - 1];
         }
     }
     if ($this->hasErrors()) {
         return false;
     }
     $this->addHttpHeader("Content-Type", $this->mimeType, $this->doDownload);
     if ($this->doDownload) {
         $this->_downloadHeader();
     }
     if ($this->content === null) {
         if (is_readable($this->fileName) && is_file($this->fileName)) {
             $this->_httpHeaders['Content-Length'] = filesize($this->fileName);
             $this->sendHttpHeaders();
             readfile($this->fileName);
             flush();
             return true;
         } else {
             throw new jException('jelix~errors.repbin.unknow.file', $this->fileName);
             return false;
         }
     } else {
         $this->_httpHeaders['Content-Length'] = strlen($this->content);
         $this->sendHttpHeaders();
         echo $this->content;
         flush();
         return true;
     }
 }
Пример #26
0
function plugin_information($plugin_slug, $data)
{
    $plugin_path = $data['path'];
    ?>
	
	<textarea readonly="readonly" rows="7" cols="65" wrap="off" style="width: 100%;"><?php 
    //echo "Version History:\n\n";
    readfile($plugin_path . '/history.txt');
    ?>
</textarea>
	<script type="text/javascript">
		jQuery(document).ready(function() {
			jQuery("#pluginbuddy_<?php 
    echo $plugin_slug;
    ?>
_debugtoggle").click(function() {
				jQuery("#pluginbuddy_<?php 
    echo $plugin_slug;
    ?>
_debugtoggle_div").slideToggle();
			});
		});
	</script>
	<?php 
    if (pb_backupbuddy::_POST('reset_defaults') == $plugin_slug) {
        if (call_user_func('pb_' . $plugin_slug . '::reset_options', true) === true) {
            pb_backupbuddy::alert('Plugin settings have been reset to defaults for plugin `' . $data['name'] . '`.');
        } else {
            pb_backupbuddy::alert('Unable to reset plugin settings. Verify you are running the latest version.');
        }
    }
    ?>
	
	<?php 
}
Пример #27
0
 public function viewAction()
 {
     // We view a file, so we should disable layout
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $key = $this->_getParam('key');
     $size = $this->_getParam('size');
     $inline = $this->_getParam('inline');
     if (strpos($key, '.')) {
         $key = substr($key, 0, strpos($key, '.'));
     }
     $files = new Files();
     if (!($file = $files->getFileFromKey($key))) {
         throw new Stuffpress_Exception("No such file for key {$key}");
     }
     if ($size == 'thumbnail') {
         $folder = '/thumbnails/';
     } else {
         if ($size == 'small') {
             $folder = '/small/';
         } else {
             if ($size == 'medium') {
                 $folder = '/medium/';
             } else {
                 if ($size == 'large') {
                     $folder = '/large/';
                 } else {
                     $folder = '/';
                 }
             }
         }
     }
     $root = Zend_Registry::get("root");
     $config = Zend_Registry::get("configuration");
     if (isset($config) && isset($config->path->upload)) {
         $upload = $config->path->upload;
     } else {
         $upload = $root . "/upload/";
     }
     $path = $upload . "/{$folder}{$file->key}";
     if ($folder != '/' && !file_exists($path)) {
         $path = $upload . "/{$file->key}";
     }
     // Dump the file
     if (!$inline) {
         header("Content-Disposition: attachment; filename=\"{$file->name}\"");
     }
     header("Content-type: {$file->type}");
     header('Content-Length: ' . filesize($path));
     /*$this->getResponse()->setHeader('Expires', '', true);
        $this->getResponse()->setHeader('Cache-Control', 'public', true);
      	$this->getResponse()->setHeader('Cache-Control', 'max-age=3800');
        $this->getResponse()->setHeader('Pragma', '', true);*/
     // We turn off output buffering to avoid memory issues
     // when dumping the file
     ob_end_flush();
     readfile($path);
     // Die to make sure that we don't screw up the file
     die;
 }
Пример #28
0
function docs_for_version($base, $version)
{
    echo "<br/><li>Version: {$version}<br/>";
    foreach (glob("build-{$version}.txt") as $filename) {
        readfile($filename);
    }
    echo "<ul>";
    foreach (glob("{$base}/*/Pacemaker/{$version}") as $item) {
        $lang = basename(dirname(dirname($item)));
        $books = array();
        foreach (glob("{$base}/{$lang}/Pacemaker/{$version}/pdf/*") as $filename) {
            $books[] = basename($filename);
        }
        foreach ($books as $b) {
            echo "<li>" . str_replace("_", " ", $b) . " ({$lang})";
            foreach (glob("{$base}/{$lang}/Pacemaker/{$version}/epub/{$b}/*.epub") as $filename) {
                echo " [<a href={$filename}>epub</a>]";
            }
            foreach (glob("{$base}/{$lang}/Pacemaker/{$version}/pdf/{$b}/*.pdf") as $filename) {
                echo " [<a href={$filename}>pdf</a>]";
            }
            foreach (glob("{$base}/{$lang}/Pacemaker/{$version}/html/{$b}/index.html") as $filename) {
                echo " [<a href={$filename}>html</a>]";
            }
            foreach (glob("{$base}/{$lang}/Pacemaker/{$version}/html-single/{$b}/index.html") as $filename) {
                echo " [<a href={$filename}>html-single</a>]";
            }
            foreach (glob("{$base}/{$lang}/Pacemaker/{$version}/txt/{$b}/*.txt") as $filename) {
                echo " [<a href={$filename}>txt</a>]";
            }
        }
        echo "</li><br/>";
    }
    echo "</ul>";
}
Пример #29
0
 public function dwld()
 {
     $this->min();
     if (is_numeric($this->getParam("id"))) {
         $this->download->newDownload();
         if ($this->download->getIsLocal()) {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . basename($url) . '";');
             readfile($url);
         } else {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header("Content-Disposition: attachment; filename=" . basename($url));
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
             header("Content-Length: " . filesize($url));
             flush();
             // this doesn't really matter.
             $fp = fopen($url, "r");
             while (!feof($fp)) {
                 echo fread($fp, 65536);
                 flush();
                 // this is essential for large downloads
             }
             fclose($fp);
         }
     } else {
         throw new \Model\downloads\exception\DownloadCantBeFind("No Download ID given");
     }
 }
Пример #30
0
 /**
  * @param string $fileref
  */
 public function download($fileref)
 {
     $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['sharepoint_connector']);
     $extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($extensionConfiguration);
     $filePath = explode(';#', $fileref);
     $urlInfo = parse_url($extensionConfiguration['sharepointServer']['url']);
     $downloadLink = $urlInfo['scheme'] . '://' . $urlInfo['host'] . '/' . $filePath[1];
     $destinationFile = \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('spdownload_');
     $fp = fopen($destinationFile, 'w+');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $downloadLink);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
     curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
     curl_setopt($ch, CURLOPT_USERPWD, $extensionConfiguration['sharepointServer']['username'] . ':' . $extensionConfiguration['sharepointServer']['password']);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     # increase timeout to download big file
     curl_setopt($ch, CURLOPT_FILE, $fp);
     curl_exec($ch);
     curl_close($ch);
     fclose($fp);
     if (file_exists($destinationFile)) {
         header("Content-Type: application/force-download");
         header("Content-Disposition: attachment; filename=" . basename($downloadLink));
         header("Content-Transfer-Encoding: binary");
         header('Content-Length: ' . filesize($destinationFile));
         ob_clean();
         flush();
         readfile($destinationFile);
     }
     \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($destinationFile);
 }