https://www.icyphoenix.com/viewtopic.php?f=26&t=1744&p=18149#p18149
-----------------------------------
pepi
Sun 29 Jul, 2007 15:07

Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
-----------------------------------
Hello 
The Problem is this
[spoiler][code linenumbers=false]#
#-----[ OPEN ]----------------------------------------
#
album_thumbnail.php

#
#-----[ FIND ]----------------------------------------
#
if( empty($thispic) or !file_exists(ALBUM_UPLOAD_PATH . $pic_filename) )


#
#-----[ REPLACE WITH ]----------------------------------------
#
// Remote download/link mod
preg_match('/^(http://)?([w-.]+):?([0-9]*)/(.*)$/', $pic_filename, $url_ary);
if($url_ary[1]=="http://" or $url_ary[1]=="ftp://")
{
  $base_get = '/' . $url_ary[4];
  $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;

  if ( !($fsock = fsockopen($url_ary[2], $port, $errno, $errstr)) ) die('Could not open URL.');

  @fputs($fsock, "GET $base_get HTTP/1.1rn");
  @fputs($fsock, "HOST: " . $url_ary[2] . "rn");
  @fputs($fsock, "Connection: closernrn");

  unset($remote_data);
  $remote_data = @fread($fsock, 1024);
  @fclose($fsock);

  if (!preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $remote_data, $file_data))
  {
    //Server hasn't sent correct headers, typical so lets do it the cheap way.
    if(substr_count( strtolower($url_ary[4]), strtolower(".jpg")) or substr_count( strtolower($url_ary[4]), strtolower(".jpeg"))) $file_data2[1]="jpeg";
    if(substr_count( strtolower($url_ary[4]), strtolower(".png"))) $file_data2[1]="png";
    if(substr_count( strtolower($url_ary[4]), strtolower(".gif"))) $file_data2[1]="gif";
  }

  switch ($file_data[1])
  {
    case 'jpeg':
    case 'jpg':
    case 'pjpeg':
      $pic_filetype = '.jpg';
      break;
    case 'png':
    case 'x-png':
      $pic_filetype = '.png';
      break;
    case 'gif':
      $pic_filetype = '.gif';
      break;
  }
}
// end Remote download/link mod - next line also modded
if( empty($thispic) or (!file_exists(ALBUM_UPLOAD_PATH . $pic_filename) and !($url_ary[1]=="http://" or $url_ary[1]=="ftp://")) )

#
#-----[ FIND ]----------------------------------------
#
  if (!$gd_errored)

#
#-----[ BEFORE ADD ]----------------------------------------
#
  // Remote download/link Mod
  if($url_ary[1]=="http://" or $url_ary[1]=="ftp://") @unlink(ALBUM_UPLOAD_PATH . $pic_filename);
  // End Remote download/link Mod
[/code][/spoiler]
and
[spoiler][code linenumbers=false]#
#-----[ OPEN ]----------------------------------------
#
album_pic.php

#
#-----[ FIND ]----------------------------------------
#
if( empty($thispic) or !file_exists(ALBUM_UPLOAD_PATH . $pic_filename) )

#
#-----[ REPLACE WITH ]----------------------------------------
#
// Remote download/link mod
preg_match('/^(http://)?([w-.]+):?([0-9]*)/(.*)$/', $pic_filename, $url_ary);
if($url_ary[1]=="http://" or $url_ary[1]=="ftp://")
{
  $base_get = '/' . $url_ary[4];
  $port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;

  if ( !($fsock = fsockopen($url_ary[2], $port, $errno, $errstr)) ) die('Could not open URL.');

  @fputs($fsock, "GET $base_get HTTP/1.1rn");
  @fputs($fsock, "HOST: " . $url_ary[2] . "rn");
  @fputs($fsock, "Connection: closernrn");

  unset($remote_data);
  $remote_data = @fread($fsock, 1024);
  @fclose($fsock);

  preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $remote_data, $file_data);

  switch ($file_data[1])
  {
    case 'jpeg':
    case 'jpg':
    case 'pjpeg':
      $pic_filetype = '.jpg';
      break;
    case 'png':
    case 'x-png':
      $pic_filetype = '.png';
      break;
    case 'gif':
      $pic_filetype = '.gif';
      break;
  }
}
// end Remote download/link mod - next line also modded
if( empty($thispic) or (!file_exists(ALBUM_UPLOAD_PATH . $pic_filename) and !($url_ary[1]=="http://" or $url_ary[1]=="ftp://")) )
[/code][/spoiler]
Dosn't find this code to edit

pepi


