Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

JohnnyDoomo's Achievements


Member (2/5)



  1. I'm using php code I got from StackOverload that looks like this: <?php // Some URL for testing $url = 'https://www.google.de/favicon.ico'; // Time to cache the files (here: 10 minutes) define('time_to_cache', 600); // Create a local file representation $local = './cache/' . urlencode($url); // Determine whether the local file is too old if (@filemtime($local) + time_to_cache < time()) { // Download a fresh copy copy ($url, $local); // Store headers in case we need them (see alternative below) file_put_contents($local . '.hdr', join($http_response_header, "\n")); } // Solution 1: Redirect to the local cache file header('Location: ' . urlencode($local)); exit(); // Alternative: Send headers and the actual file // Note that this might cause problems, e.g. due // to cache fields and the like. // Read and send headers foreach(file($local . '.hdr') as $line) header($line); // Read and send the actual file readfile($local); ?> I've remarked out the "solution 1" lines, because that method doesn't work at all on my server. The alternative works, except for an https problem. I'm loading a bunch of images from 3rd party sites. My site is only https, and I want to keep all local images using https. I have lazyloading js applied to all images that load on the page, and when I use the above php, as I scroll down my page, my browser https lock will turn to unsecure. So I can assume, that lots of the images are loading properly from https, and then suddenly, it loads an image from http instead of https. So for some reason, the above php is not keeping my https, despite that the script looks to only call the image from my local location. I'm fairly new to learning php, but am I missing something here? From what I can see from the "readfile" line, all images should be shown from my cached area, which I've already stated as https, and have tried both "//" and specifically hardcoding "https" into the img src, but I still get these problems, where as I scroll down the page, the browser https secure lock will change to the mixed content, indicating that the browser has just loaded something NOT from https. Can anybody help me with what I need to add, so that the above code either keeps my secure protocol or doesn't try to load the image if it's not from https? Any help would be appreciated!
  2. My image gallery creates folders that look like this: thumbnail: http://blah.com/data/99999/thumbs/abc.jpg medium: http://blah.com/data/99999/medium/abc.jpg original: http://blah.com/data/99999/abc.jpg The script dynamically creates new folder IDs where the "99999" are. I would like the .htaccess file to allow the /thumbs/ and /medium/ folders to always allow hotlinking, but I want to protect the fullsize image and replace it with the medium image if it's ever coming from a domain other than my blah.com. I cannot create an htaccess file for every ID folder, so I need an htaccess rule that wildcards the ID folder, and sits in /data/. Can anybody help with the code required to do this? Or is something like this not possible until I get the fullsized images OUTSIDE of the folder where the thumbnails, and medium sized images are? I have very little knowledge of htaccess, so the exact code I can paste is greatly appreciated. Thanks for any help you can provide.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.