且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在HTTPS连接上显示非SSL图像?

更新时间:2023-02-06 22:21:53

你可以自己创建ssl代理。

you can make your own ssl proxy.

运行所有图片这个脚本。
只需创建一个文件并将此PHP代码放入其中。使用 curl file_get_contents 来回显内容。

Run all the images through this script. Just make a file and put this PHP code inside. Use curl or file_get_contents to echo out the content.

因此,如果你想调用安全图像,你可以这样称呼:

So if you want to call the secure image, you call it like this:

https://mysecureserver.com/path_to_this_script/?url = [base64编码图像链接]

<?php   
  $strFile = base64_decode(@$_GET['url']);
  $strFileExt = end(explode('.' , $strFile));
  if($strFileExt == 'jpg' or $strFileExt == 'jpeg'){
    header('Content-Type: image/jpeg');
  }elseif($strFileExt == 'png'){
    header('Content-Type: image/png');
  }elseif($strFileExt == 'gif'){
    header('Content-Type: image/gif');
  }else{
    die('not supported');
  }
  if($strFile != ''){
    $cache_ends = 60*60*24*365;
    header("Pragma: public");
    header("Cache-Control: maxage=". $cache_ends);
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache_ends).' GMT');

    //... [and get the content using curl or file_get_contents and echo it out ]

  }
  exit;
?>