membership call is preventing readfile() somehow

By markr - August 6, 2014

This readfile() procedure works fine until I add the viewer and login lines for membership. Then the file become corrupted (or something) and won't display.

Can you think of why securing the page is messing with the latter code? See any options I could try to unfetter the readfile() ?

require_once '/myhost/public_html/cmsAdmin/lib/viewer_functions.php';
if (!$CURRENT_USER) {websiteLogin_redirectToLogin();}

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/pdf');
    header('Content-Disposition: inline; filename='.basename($file));
    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));
    ob_clean();
    flush();
    readfile($file);
    exit;
    } // endif

By markr - August 7, 2014

I removed the login requirement and just loaded the viewer and have the same problem.

It if matters, this topic can therefore be moved to the general forum.

Btw, I'm using the readfile() snippet in order to load a file stored in directory above public_html. Like I wrote, it works great until I load the viewer.