Example #1
0
/**
 * Send a download.
 *
 * @since 0.1.0
 *
 * @param string $file An absolute file path.
 */
function satispress_send_file($file)
{
    @session_write_close();
    if (function_exists('apache_setenv')) {
        @apache_setenv('no-gzip', 1);
    }
    if (get_magic_quotes_runtime()) {
        @set_magic_quotes_runtime(0);
    }
    @ini_set('zlib.output_compression', 'Off');
    @set_time_limit(0);
    @ob_end_clean();
    if (ob_get_level()) {
        @ob_end_clean();
        // Zip corruption fix.
    }
    nocache_headers();
    header('Robots: none');
    header('Content-Type: application/force-download');
    header('Content-Description: File Transfer');
    header('Content-Disposition: attachment; filename="' . basename($file) . '";');
    header('Content-Transfer-Encoding: binary');
    if ($size = @filesize($file)) {
        header('Content-Length: ' . $size);
    }
    @readfile_chunked($file) or wp_die(__('File not found', 'satispress'));
    exit;
}
 /**
  * @param Request $request
  *
  * @return Response
  */
 public static function getResponse(Request $request)
 {
     ignore_user_abort(true);
     //turn off gzip compression
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', 1);
     }
     ini_set('zlib.output_compression', 0);
     $response = new Response();
     //removing any content encoding like gzip etc.
     $response->headers->set('Content-Encoding', 'none');
     //check to ses if request is a POST
     if ($request->getMethod() == 'GET') {
         $response->headers->set('Connection', 'close');
         //return 1x1 pixel transparent gif
         $response->headers->set('Content-Type', 'image/gif');
         //avoid cache time on browser side
         $response->headers->set('Content-Length', '42');
         $response->headers->set('Cache-Control', 'private, no-cache, no-cache=Set-Cookie, proxy-revalidate');
         $response->headers->set('Expires', 'Wed, 11 Jan 2000 12:59:00 GMT');
         $response->headers->set('Last-Modified', 'Wed, 11 Jan 2006 12:59:00 GMT');
         $response->headers->set('Pragma', 'no-cache');
         $response->setContent(self::getImage());
     } else {
         $response->setContent(' ');
     }
     return $response;
 }
Example #3
0
function disable_gzip()
{
    @ini_set('zlib.output_compression', 'Off');
    @ini_set('output_buffering', 'Off');
    @ini_set('output_handler', '');
    @apache_setenv('no-gzip', 1);
}
Example #4
0
 public function __construct($config_file = NULL)
 {
     if ($config_file == NULL) {
         $config_file = APP_DIR . '/.env';
     }
     $this->getenv_func = 'getenv';
     if (function_exists('apache_getenv')) {
         $this->getenv_func = 'apache_getenv';
     }
     if (!file_exists($config_file)) {
         Logger::warning('Unable to find the configuration file (only the global environment variable will be available)!');
         return;
     }
     $config = file_get_contents($config_file);
     $lines = explode(PHP_EOL, $config);
     foreach ($lines as $env) {
         $env = trim($env);
         if (!empty($env)) {
             if (function_exists('apache_setenv')) {
                 $raw = explode('=', $env);
                 if (count($raw) == 2) {
                     apache_setenv($raw[0], $raw[1]);
                 } else {
                     Logger::warning('Invalid environment definition: ' . $env);
                 }
                 continue;
             }
             putenv($env);
         }
     }
     unset($lines);
     unset($config);
 }
 /**
  * Attribution pixel
  *
  * @param  PixelRequest $request
  * @return Image
  */
 public function store(PixelRequest $request)
 {
     $this->agent->setUserAgent($request->header('user-agent'));
     ignore_user_abort(true);
     // Turn off gzip compression
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', 1);
     }
     ini_set('zlib.output_compression', 0);
     // Turn on output buffering if necessary
     if (ob_get_level() == 0) {
         ob_start();
     }
     // Remove any content encoding
     header('Content-encoding: none', true);
     if (!$request->isMethod('post')) {
         // Create attribution entry
         $attribution = Attribution::create(['landing_page_id' => $request->get('lp'), 'email' => $request->get('em'), 'tracking_id' => $request->get('t'), 'converting_source' => $request->get('cs'), 'converting_medium' => $request->get('cm'), 'converting_keyword' => $request->get('ck'), 'converting_content' => $request->get('ccn'), 'converting_campaign' => $request->get('cc'), 'converting_landing_page' => $request->get('cl'), 'converting_timestamp' => Carbon::createFromTimeStamp($request->get('ct'))->toDateTimeString(), 'original_source' => $request->get('os'), 'original_medium' => $request->get('om'), 'original_keyword' => $request->get('ok'), 'original_content' => $request->get('ocn'), 'original_campaign' => $request->get('oc'), 'original_landing_page' => $request->get('ol'), 'original_timestamp' => Carbon::createFromTimeStamp($request->get('ot'))->toDateTimeString(), 'refer_url' => $request->get('r'), 'platform' => $this->agent->platform(), 'device' => $this->agent->device(), 'browser' => $this->agent->browser(), 'version' => $this->agent->version($this->agent->browser())]);
         // Link attribution entry to lead
         \Event::fire(new AttributionSubmitted($attribution));
         // Return 1x1 pixel transparent gif
         header("Content-type: image/gif");
         header("Content-Length: 42");
         header("Cache-Control: private, no-cache, no-cache=Set-Cookie, proxy-revalidate");
         header("Pragma: no-cache");
         echo base64_decode('R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEA');
     }
     // Flush output buffers
     ob_flush();
     flush();
     ob_end_flush();
 }
 public function init()
 {
     if (file_exists($this->sock)) {
         $this->log->error("Sock file already exists, concurrent process cannot be started");
         exit;
     }
     $this->log->info('Streamer initialization');
     // connection keep-alive, in other case browser will close it when receive last frame
     header('Connection: keep-alive');
     // disable caches
     header('Cache-Control: no-cache');
     header('Cache-Control: private');
     header('Pragma: no-cache');
     // x-mixed-replace to stream JPEG images
     header('Content-type: multipart/x-mixed-replace; boundary=' . self::$BOUNDARY);
     // set unlimited so PHP doesn't timeout during a long stream
     set_time_limit(0);
     // ignore user abort script
     ignore_user_abort(true);
     @apache_setenv('no-gzip', 1);
     // disable apache gzip compression
     @ini_set('zlib.output_compression', 0);
     // disable PHP zlib compression
     @ini_set('implicit_flush', 1);
     // flush all current buffers
     $k = ob_get_level();
     for ($i = 0; $i < $k; $i++) {
         ob_end_flush();
     }
     register_shutdown_function(array($this, 'shutdown'));
     fclose(fopen($this->sock, 'w'));
     $this->initialized = true;
 }
Example #7
0
	function __construct(){
		$this->cache_token = obcer::cache_token((COUCH?'db':NULL));
		$this->start_time = (float) array_sum(explode(' ',microtime()));
		$this->oh_memory = round(memory_get_usage() / 1024);
		// set up the 'filter' variable to determine what columns to show
		if(SHOW_ALL == FALSE){
			if(SHOW_LANGUAGE == false  ) $this->c_filter []='language';
			if(SHOW_SUPPRESS == false) $this->c_filter []='suppress';
			if(SHOW_RXCUI == false) $this->c_filter []='rxcui';
			if(SHOW_NAME == false) $this->c_filter []='name';
			if(SHOW_ALL_SYNONYM == FALSE) $this->c_filter []= 'synonym';
			if(SHOW_TTY == false) $this->c_filter []='tty';
			if(SHOW_UML == false) $this->c_filter []= 'umlscui';
		}
		// of course I could make a checkbox panel to allow for any combination of display fields, and cache entire returned xml results to do manipulations
		if(PROGRESSIVE_LOAD){
   	 	    @apache_setenv('no-gzip', 1);
			@ini_set('zlib.output_compression', 0);
			@ini_set('implicit_flush', 1);
			for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
			flush();
			ob_implicit_flush(1);
			ob_start();
		}
		// process any post if existant
		if($_POST) self::post_check();

		// if we haven't died by now then close and flush the ob cache for the final time

		// echo the footer and stats to screen.
		echo '<div id="stats">' . $this->stats().'</div>';

	}
Example #8
0
    /**
     * Resets the entire Database
     */
    function reset()
    {
        $this->load->dbforge();
        try {
            // force disabling of g-zip so output can be streamed
            apache_setenv('no-gzip', '1');
        } catch (Exception $e) {
            /* ignore */
        }
        //        @todo: Abrir views especifica para o load das tables;
        ?>
<div class="database_setup"><?php 
        $this->_message('Creating the database at <strong>' . $this->db->database . '</strong><br/>', '');
        $success = $this->_drop_tables();
        echo "<br/><br/>";
        $success = $success && $this->_create_tables();
        echo "<br/><br/>";
        $success = $success && $this->_init_data();
        ?>
</div><?php 
        if ($success) {
            ?>
<p><a href="<?php 
            echo site_url('welcome');
            ?>
">Continue</a></p><?php 
        } else {
            ?>
An error occurred.  Please reset the database and try again.<?php 
        }
    }
 /**
  * Disables the output compression used by the server or PHP.
  * @codeCoverageIgnore
  */
 protected function disableCompression()
 {
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', 1);
     }
     ini_set('zlib.output_compression', 0);
 }
Example #10
0
 public function response()
 {
     if (function_exists('apache_setenv')) {
         @apache_setenv('no-gzip', 1);
     }
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_clean();
     }
     ob_implicit_flush(1);
     header('Content-Type: ' . (isset($_GET['callback']) ? 'text/javascript' : 'application/json'));
     header('Access-Control-Allow-Origin: *');
     try {
         if ($this->auth()) {
             $this->handler = new RestHandler($this->method, $this);
             $response = $this->handler->response();
             echo $this->formatResponse($response);
         } else {
             throw new RestException(RestException::APP_NOT_AUTHORIZED);
         }
     } catch (RestException $e) {
         echo $this->formatResponse($e);
     }
     @ob_flush();
     @flush();
 }
function disable_ob()
{
    // Turn off output buffering
    ini_set('output_buffering', 'off');
    // Turn off PHP output compression
    ini_set('zlib.output_compression', false);
    // Implicitly flush the buffer(s)
    ini_set('implicit_flush', true);
    ob_implicit_flush(true);
    // Clear, and turn off output buffering
    while (ob_get_level() > 0) {
        // Get the curent level
        $level = ob_get_level();
        // End the buffering
        ob_end_clean();
        // If the current level has not changed, abort
        if (ob_get_level() == $level) {
            break;
        }
    }
    // Disable apache output buffering/compression
    if (function_exists('apache_setenv')) {
        apache_setenv('no-gzip', '1');
        apache_setenv('dont-vary', '1');
    }
}
 /**
  * {@inheritdoc}
  */
 public function send()
 {
     // Disable gzip compression on Apache configurations
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', '1');
     }
     parent::send();
 }
Example #13
0
 public static function sendFile($localFileName, $asRemoteFileName, $mimeType, $desc, $cleanUpFunc = null)
 {
     // Turn off server-side auto compression if it is present...
     @apache_setenv('no-gzip', 1);
     @ini_set('zlib.output_compression', 0);
     $okay = TRUE;
     $status = 200;
     $result = FALSE;
     if (!is_file($localFileName)) {
         header('HTTP/1.0 404 Not Found');
         $okay = FALSE;
         $status = 404;
     }
     if ($okay === TRUE && !is_readable($localFileName)) {
         header('HTTP/1.0 403 Forbidden');
         $okay = FALSE;
         $status = 403;
     }
     if ($okay == TRUE) {
         // Set the headers...
         header('Pragma: public');
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         // some day in the past
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header("Cache-Control: private", false);
         // required for certain browsers
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($localFileName)) . ' GMT');
         if ($desc !== null) {
             header('Content-Description: ' . $desc);
         }
         if ($mimeType !== null) {
             header('Content-Type: ' . $mimeType);
         } else {
             header('Content-Type: application/octet-stream');
         }
         if ($asRemoteFileName == null) {
             header('Content-Disposition: attachment');
         } else {
             header('Content-Disposition: attachment; filename="' . $asRemoteFileName . '"');
         }
         header('Content-Transfer-Encoding: binary');
         $len = filesize($localFileName);
         header('Content-Length: ' . $len);
         flush();
         ob_clean();
         ob_end_flush();
         // Send the file...
         $result = @readfile($localFileName);
         if ($result === FALSE || $result !== $len) {
             $okay = FALSE;
             $status = 0;
         }
     }
     if ($cleanUpFunc !== null) {
         @call_user_func($cleanUpFunc, $localFileName, $result, $status);
     }
     exit;
 }
Example #14
0
    public function upgrade()
    {
        $this->output->enable_profiler(FALSE);
        if (!extension_loaded('zip')) {
            $this->alert->set('warning', $this->lang->line('alert_zip_warning'));
            redirect('updates');
        }
        if (!$this->uri->rsegment(3)) {
            $this->alert->set('warning', $this->lang->line('alert_bad_request'));
            redirect('updates');
        } else {
            if (!$this->user->hasPermission('Site.Updates.Add')) {
                $this->alert->set('warning', $this->lang->line('alert_permission_warning'));
                redirect('updates');
            }
        }
        $update_type = $this->uri->rsegment(3);
        $this->setHTMLHead();
        set_time_limit(300);
        // 5 minutes
        if (function_exists('apache_setenv')) {
            @apache_setenv('no-gzip', 1);
        }
        @ini_set('zlib.output_compression', 0);
        @ini_set('implicit_flush', 1);
        ob_implicit_flush(TRUE);
        ignore_user_abort(TRUE);
        if (ob_get_level() == 0) {
            ob_start();
        }
        flush_output($this->load->view($this->config->item('admin', 'default_themes') . 'updates_upgrade', '', TRUE), FALSE);
        if ($update_type === 'core') {
            // Enable maintenance mode, will be disabled after update
            flush_output($this->lang->line('progress_enable_maintenance') . "<br />");
            $maintenance_mode = $this->config->item('maintenance_mode');
            $this->config->set_item('maintenance_mode', 0);
            $this->Updates_model->update($update_type);
            // Restore maintenance mode
            flush_output($this->lang->line('progress_disable_maintenance'));
            $this->config->set_item('maintenance_mode', $maintenance_mode);
            flush_output(sprintf($this->lang->line('text_complete_installation'), base_url()));
        } else {
            if ($updates = $this->input->get('updates')) {
                foreach ($updates as $update) {
                    $update = explode('|', $update);
                    if (count($update) === 2) {
                        $this->Updates_model->update($update_type, $update[0], $update[1]);
                    }
                }
            }
        }
        flush_output('<script type="text/javascript">
			parent.jQuery(\'#updateProgress\').attr(\'class\', \'fa fa-check\')
			.attr(\'title\', \'Complete\');
		</script>', FALSE);
        flush_output('</body></html>', FALSE);
        ob_end_flush();
    }
Example #15
0
 /**
  * Set the file headers and force the download of a given file
  *
  * @return void
  */
 public function download()
 {
     if (isset($_GET['download']) && isset($_GET['payment_id'])) {
         $transaction_id = urldecode($_GET['download']);
         $payment_id = urldecode($_GET['payment_id']);
         $product_id = urldecode($_GET['product_id']);
         // Old download links might not have attachment_id set.
         // This means they were purchased before we added support
         // for multiple attachments. So, we just grab the first
         // attachment_id saved in post meta.
         $attachment_id = !empty($_GET['attachment_id']) ? urldecode($_GET['attachment_id']) : sell_media_get_attachment_id($product_id);
         $size_id = !empty($_GET['size_id']) ? urldecode($_GET['size_id']) : null;
         $verified = apply_filters('sell_media_verify_download', $this->verify($transaction_id, $payment_id), $product_id);
         if ($verified) {
             $file = Sell_Media()->products->get_protected_file($product_id, $attachment_id);
             if (!file_exists($file)) {
                 wp_die(__('The original high resolution file doesn\'t exist here: %1$s', 'sell_media'), $file);
                 exit;
             }
             $file_type = wp_check_filetype($file);
             if (!ini_get('safe_mode')) {
                 set_time_limit(0);
             }
             if (function_exists('get_magic_quotes_runtime') && get_magic_quotes_runtime()) {
                 set_magic_quotes_runtime(0);
             }
             if (function_exists('apache_setenv')) {
                 @apache_setenv('no-gzip', 1);
             }
             @ini_set('zlib.output_compression', 'Off');
             nocache_headers();
             header("Robots: none");
             header("Content-Type: " . $file_type['type'] . "");
             header("Content-Description: File Transfer");
             header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
             header("Content-Transfer-Encoding: binary");
             // If image, generate the image sizes purchased and create a download
             if (wp_attachment_is_image($attachment_id)) {
                 $this->download_image($product_id, $attachment_id, $size_id);
             } else {
                 $this->download_file($file);
             }
             do_action('sell_media_after_successful_download', $product_id);
             exit;
         } else {
             do_action('sell_media_before_failed_download', $product_id, $attachment_id);
             wp_die(__('You do not have permission to download this file', 'sell_media'), __('Purchase Verification Failed', 'sell_media'));
         }
         exit;
     }
     // Rend purchase receipt?
     if (isset($_GET['resend_email']) && isset($_GET['payment_id'])) {
         $payment_id = $_GET['payment_id'];
         $payment_email = get_meta_key($payment_id, 'email');
         Sell_Media()->payments->email_receipt($payment_id, $payment_email);
     }
 }
Example #16
0
function apache_log($key, $value)
{
    static $log = array();
    if (function_exists('apache_setenv')) {
        $log['env'] = mfwServerEnv::getEnv();
        $log[$key] = $value;
        apache_setenv('LOGMSG', json_encode($log));
    }
}
Example #17
0
 /**
  * Disables GZIP compression.
  *
  * @since 150424 Initial release.
  */
 public function gzipOff()
 {
     if (headers_sent()) {
         throw $this->c::issue('Heading already sent!');
     }
     @ini_set('zlib.output_compression', 'off');
     if ($this->c::canCallFunc('apache_setenv')) {
         @apache_setenv('no-gzip', '1');
     }
 }
Example #18
0
 /**
  * If enabled and logged in, save login name of user in Apache session variable for Apache logs.
  *
  * Implements 'core.init' event when Zikula_Core::STAGE_SESSIONS.
  *
  * @param Zikula_Event $event The event handler.
  *
  * @return void
  */
 public function sessionLogging(Zikula_Event $event)
 {
     if ($event['stage'] & Zikula_Core::STAGE_SESSIONS) {
         // If enabled and logged in, save login name of user in Apache session variable for Apache logs
         if (isset($GLOBALS['ZConfig']['Log']['log.apache_uname']) && $GLOBALS['ZConfig']['Log']['log.apache_uname'] && UserUtil::isLoggedIn()) {
             if (function_exists('apache_setenv')) {
                 apache_setenv('Zikula-Username', UserUtil::getVar('uname'));
             }
         }
     }
 }
Example #19
0
 static function enable_implicit_flush()
 {
     @apache_setenv('no-gzip', 1);
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_flush();
     }
     ob_implicit_flush(1);
     echo "<!-- " . str_repeat(' ', 2000) . " -->";
 }
 /**
  * Handles Security Badge Status API.
  *
  * @package s2Member\Security_Badges
  * @since 110524RC
  *
  * @attaches-to ``add_action("init");``
  *
  * @return null Exits script execution after status output.
  */
 public static function s_badge_status()
 {
     do_action("ws_plugin__s2member_before_s_badge_status", get_defined_vars());
     if (!empty($_GET["s2member_s_badge_status"])) {
         status_header(200);
         // Send a 200 OK status.
         header("Content-Type: text/plain; charset=UTF-8");
         @ini_set("zlib.output_compression", 0);
         if (function_exists("apache_setenv")) {
             @apache_setenv("no-gzip", "1");
         }
         while (@ob_end_clean()) {
         }
         // Clean any existing output buffers.
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["s_badge_status_enabled"]) {
             if (strlen($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["sec_encryption_key"]) >= 56) {
                 if (defined("AUTH_KEY") && strlen(AUTH_KEY) >= 60 && stripos(AUTH_KEY, "unique phrase") === false) {
                     if (defined("SECURE_AUTH_KEY") && strlen(SECURE_AUTH_KEY) >= 60 && stripos(SECURE_AUTH_KEY, "unique phrase") === false) {
                         if (defined("AUTH_SALT") && strlen(AUTH_SALT) >= 60 && stripos(AUTH_SALT, "unique phrase") === false) {
                             if (defined("SECURE_AUTH_SALT") && strlen(SECURE_AUTH_SALT) >= 60 && stripos(SECURE_AUTH_SALT, "unique phrase") === false) {
                                 if (defined("LOGGED_IN_KEY") && strlen(LOGGED_IN_KEY) >= 60 && stripos(LOGGED_IN_KEY, "unique phrase") === false) {
                                     if (defined("LOGGED_IN_SALT") && strlen(LOGGED_IN_SALT) >= 60 && stripos(LOGGED_IN_SALT, "unique phrase") === false) {
                                         if (defined("NONCE_KEY") && strlen(NONCE_KEY) >= 60 && stripos(NONCE_KEY, "unique phrase") === false) {
                                             if (defined("NONCE_SALT") && strlen(NONCE_SALT) >= 60 && stripos(NONCE_SALT, "unique phrase") === false) {
                                                 if (defined("DB_USER") && DB_USER && defined("DB_PASSWORD") && DB_PASSWORD && DB_USER !== DB_PASSWORD) {
                                                     if (!apply_filters("ws_plugin__s2member_disable_all_ip_restrictions", false, get_defined_vars()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_simultaneous_logins"]) {
                                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_failed_login_attempts"]) {
                                                             if (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"] && !glob($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"] . '/*') || $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"] !== $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["default_logs_dir"]) {
                                                                 exit("1");
                                                                 // OK good. Things look pretty secure here.
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             exit("0");
             // Else, NOT secure.
         } else {
             exit("-");
         }
         // Else, service NOT enabled.
     }
     do_action("ws_plugin__s2member_after_s_badge_status", get_defined_vars());
 }
Example #21
0
 /**
  * Initializing console mode
  *
  * @return voide
  */
 public function init_console()
 {
     self::$console_mode = true;
     echo "<pre>";
     @apache_setenv('no-gzip', 1);
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_flush();
     }
     ob_implicit_flush(1);
     # writing debug
     self::add_debug_msg("# Console mode activated");
 }
Example #22
0
 public function handle_downloads()
 {
     // Called in init
     if (!isset($_GET['pdfemb-serveurl']) && !isset($_GET['pdfemb-nonce'])) {
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] !== 'POST' && !isset($_GET['pdfemb-nonce'])) {
         return;
     }
     $direct_download = false;
     if (isset($_GET['pdfemb-nonce'])) {
         if (!wp_verify_nonce($_GET['pdfemb-nonce'], 'pdfemb-secure-download-' . $_GET['pdfemb-serveurl'])) {
             return;
         } else {
             $direct_download = true;
         }
     }
     $pdfurl = $_GET['pdfemb-serveurl'];
     $filepath = $this->getSecurePath($pdfurl);
     if ($filepath != '') {
         $filename = basename($filepath);
         if (!$this->is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
             @set_time_limit(0);
         }
         if (function_exists('get_magic_quotes_runtime') && get_magic_quotes_runtime() && version_compare(phpversion(), '5.4', '<')) {
             set_magic_quotes_runtime(0);
         }
         @session_write_close();
         if (function_exists('apache_setenv')) {
             @apache_setenv('no-gzip', 1);
         }
         @ini_set('zlib.output_compression', 'Off');
         ob_clean();
         // Clear output buffer in case Unicode BOM was added by a PHP file saved in wrong encoding.
         nocache_headers();
         header("Robots: none");
         header("Content-Type: application/octet-stream");
         header("Content-Description: File Transfer");
         header("Content-Disposition: attachment; filename=\"" . $filename . ($direct_download ? "" : ".binary") . "\"");
         header("Content-Transfer-Encoding: binary");
         if (!class_exists('pdfembSimpleRC4')) {
             include_once dirname(__FILE__) . '/rc4_simple.php';
         }
         $myrc4 = $direct_download ? new pdfembDirectRC4('') : new pdfembSimpleRC4($this->getSecretKey());
         $this->readfile_chunked($filepath, true, $myrc4);
     } else {
         header("Location: " . $pdfurl);
     }
     exit;
 }
Example #23
0
 /**
  * Force browser to display response to user and continue executing
  * 
  * @return void;
  */
 protected function forceSendResponse()
 {
     ignore_user_abort(true);
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', 1);
     }
     if (session_id()) {
         session_write_close();
     }
     header('Connection: close');
     header('Content-Length: ' . ob_get_length());
     ob_end_flush();
     ob_flush();
     flush();
 }
Example #24
0
 /**
  * @inheritdoc
  */
 protected function printReply($reply, array $headers = [])
 {
     foreach ($headers as $headerLine) {
         header($headerLine);
     }
     // Disable output compression, so that the response can be sent immediately.
     ini_set('zlib.output_compression', false);
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', 1);
     }
     echo $reply;
     while (ob_get_level() > 0) {
         ob_end_flush();
     }
     flush();
 }
Example #25
0
function set()
{
    ignore_user_abort(true);
    if (function_exists('apache_setenv')) {
        apache_setenv('no-gzip', 1);
    }
    ini_set('zlib.output_compression', 0);
    if (ob_get_level() == 0) {
        ob_start();
    }
    header('Content-encoding: none', true);
    if (!empty($_GET['return']) && $_GET['return'] == 'pixel') {
        returnImage();
    } else {
        returnJSON();
    }
}
 /**
  * Initializing console mode
  *
  * @return void
  */
 public function init_console()
 {
     self::$console_mode = true;
     echo "<pre>";
     # Internal Server Error fix in case no apache_setenv() function exists
     if (function_exists('apache_setenv')) {
         @apache_setenv('no-gzip', 1);
     }
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_flush();
     }
     ob_implicit_flush(1);
     # writing debug
     self::add_debug_msg("# Console mode activated");
 }
Example #27
0
function wp_smushit_bulk_preview()
{
    if (function_exists('apache_setenv')) {
        @apache_setenv('no-gzip', 1);
    }
    @ini_set('output_buffering', 'on');
    @ini_set('zlib.output_compression', 0);
    @ini_set('implicit_flush', 1);
    $attachments = null;
    $auto_start = false;
    if (isset($_REQUEST['ids'])) {
        $attachments = get_posts(array('numberposts' => -1, 'include' => explode(',', $_REQUEST['ids']), 'post_type' => 'attachment', 'post_mime_type' => 'image'));
        $auto_start = true;
    } else {
        $attachments = get_posts(array('numberposts' => -1, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
    }
    require dirname(__FILE__) . '/bulk.php';
}
 public function executeAdd($request)
 {
     $request = $this->getRequest();
     $request->setTimeLimit(0);
     // ∞
     $request->setIgnoreUserAbort(TRUE);
     $this->form = new TorrentForm();
     // setup defaults
     $this->form->setDefaults(array('episode_id' => $request->getParameter('episode_id'), 'feed_id' => $request->getParameter('feed_id')), array());
     if (!$request->isMethod('post')) {
         return sfView::ERROR;
     }
     $params = $request->getPostParameters();
     $this->form->bind($params);
     if (!$this->form->isValid()) {
         return sfView::ERROR;
     }
     $is_replace = false;
     if (isset($params['web_url'])) {
         if (function_exists("apache_setenv")) {
             // could be running under fastcgi or in non-apache env
             apache_setenv('no-gzip', 1);
         }
         ini_set('zlib.output_compression', 0);
         $file = new sfValidatedFileFromUrl($params['web_url'], array($this, 'progress'));
         $is_replace = true;
     }
     $obj = $this->form->save();
     try {
         $obj->setFile($file, false);
         $obj->save();
     } catch (sfException $sfe) {
         //todo setflash $sfe
         $this->form->getObject()->delete();
         return sfView::ERROR;
     }
     if (!$is_replace) {
         $this->redirect('episode/edit?id=' . $torrent->getEpisodeId());
     } else {
         exit;
         return sfView::NONE;
     }
     // throw new sfException('Form valdation passed but somehow we do not have anything to do with it');
 }
Example #29
0
function disable_ob()
{
    ini_set('output_buffering', 'off');
    ini_set('zlib.output_compression', false);
    ini_set('implicit_flush', true);
    ob_implicit_flush(true);
    while (ob_get_level() > 0) {
        $level = ob_get_level();
        ob_end_clean();
        if (ob_get_level() == $level) {
            break;
        }
    }
    // Disable apache output buffering/compression
    if (function_exists('apache_setenv')) {
        apache_setenv('no-gzip', '1');
        apache_setenv('dont-vary', '1');
    }
}
Example #30
-1
 /**
  * Event stream.
  *
  * @return void
  */
 public function events()
 {
     $this->autoLayout = false;
     header('Content-Type: text/event-stream');
     header('Cache-Control: no-cache');
     ini_set('output_buffering', 'off');
     ini_set('zlib.output_compression', false);
     ini_set('implicit_flush', true);
     ob_implicit_flush(true);
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', '1');
         apache_setenv('dont-vary', '1');
     }
     foreach (DashboardWidget::widgets() as $widget => $path) {
         $listener = $widget . 'WidgetWorker';
         $path .= 'worker.php';
         if (!file_exists($path)) {
             continue;
         }
         require $path;
         $this->eventManager()->attach(new $listener());
     }
     $events = TableRegistry::get('Gourmet/Dashboard.Events');
     while (true) {
         $this->dispatchEvent('Dashboard.beforePoll');
         $ids = [];
         foreach ($events->stream() as $event) {
             echo $event->content . "\n\n";
             $ids[] = $event->id;
         }
         $events->updateAll(['view_cnt = view_cnt + 1'], ['id IN' => $ids]);
         flush();
         sleep(1);
     }
 }