Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts

    Loading external image bypassing SSL

    Morning all. I was wondering, as im at the hair pulling stage, how i can load an external image without causing SSL errors. I thought there might be a php solution, using maybe the GD lib but you need to declair the header but there is other info on page. Anyone any ideas?
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    I've worked out a work around but not really the answer. uploading images that are viewed on the fly by working out the absolute path, get contents, if not exist, write to file then view in place by replacing the src.
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    84
    Thanks
    1
    Thanked 7 Times in 7 Posts
    That's fairly easy to do, IMO.

    lib.php
    Code:
    <?php
    // Uses URLs like lib.php?img=http://blah.com/blah.gif (URL ENCODED OF COURSE)
    
    $file = isset($_GET['img']) && !empty($_GET['img']) ? $_GET['img'] : false;
    
    if(!$file) {
      echo 'Invalid IMG URL';
      exit;
    }
    
    $ext = substr(strrchr($file, '.'), 1);
    
    switch($ext) {
      case 'jpg': case 'jpe': case 'jpeg':
        $type = 'jpeg';
        break;
      default:
        $type = $ext;
        break;
    }
    
    if(!in_array($ext, array('png', 'jpeg', 'gif', 'bmp'))) {
      echo 'Invalid Image.';
      exit;
    }
    
    header('Content-type:  image/'. $type);
    readfile($file);
    ?>

    That's the method I use. If you want to add compression, you can add ob_start('ob_gzhandler'); to the beginning.

    Doesn't even require a script to transfer files to your server.
    Last edited by orca8767; 10-14-2009 at 01:25 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •