Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter cody@joasurveys

    (@codyjoasurveys)

    Thanks for the reply’s Eric!

    Talked to the server people and they found no problems. No log errors were showing up for pdf downloads.

    Talked to the web design company and they went through and found this:

    “It looks like when the caching plugin (super cache) updated, it broke the JavaScript files concatenation. I removed that caching plugin and added a new one that’s less aggressive (quick cache). I also added a rule that prohibits the scripts concatenating, which can break them and cause things that depend on AJAX to break.”

    They changed the site so that pdf’s are hyper-linked in the wp page editor to open in a new tab, not as slick as wp pub archive but gets the job done.

    Thanks!

    Thread Starter cody@joasurveys

    (@codyjoasurveys)

    So I am over my head in all this, but still in the fight. A copy of the download link looks like this:

    http://joasurveys.com/wp-content/plugins/wp-publication-archive/includes/openfile.php?file=http|joasurveys.com/wp-content/uploads/2012/11/tides1.pdf

    If you cut it down to just the file location (joasurveys.com/wp-content/uploads/2012/11/tides1.pdf) it opens the pdf in the browser.

    Here’s a cut and paste of the openfile.php, in case anything jumps out at you.

    <?php
    if ( ! isset($_GET[‘file’]) )
    die();

    if ( strpos( $_GET[‘file’], (isset($_SERVER[‘HTTPS’]) ? ‘https|’ : ‘http|’) . $_SERVER[‘SERVER_NAME’] ) === false )
    die();

    require_once(‘../lib/class.mimetype.php’);
    $mime = new mimetype();

    $fPath = str_replace(‘http|’, ‘http://&#8217;, $_GET[‘file’]);
    $fPath = str_replace(‘https|’, ‘https://&#8217;, $fPath);
    $fType = $mime->getType( $fPath );
    $fName = basename($fPath);

    $origname = preg_replace(‘/_#_#\d*/’,”,$fName);

    $fContent = fetch_content( $fPath );

    output_content( $fContent, $origname );

    function fetch_content( $url ) {
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_HEADER, 0 );

    ob_start();

    curl_exec( $ch );
    curl_close( $ch );

    $fContent = ob_get_contents();

    ob_end_clean();

    return $fContent;
    }

    function output_content( $content, $name ) {
    header( “Expires: Wed, 9 Nov 1983 05:00:00 GMT” );
    header( “Last-Modified: ” . gmdate(“D, d M Y H:i:s”) . ” GMT” );
    header( “Content-Disposition: attachment; filename=” . $name );
    header( “Content-type: application/octet-stream” );
    header( “Content-Transfer-Encoding: binary” );

    echo $content;
    }
    ?>

    Thanks for getting back to me!

Viewing 2 replies - 1 through 2 (of 2 total)