FAP CUSTOMIZATION - FAP With REMOTE URL DOWNLOAD/LINK MOD


Subject: FAP CUSTOMIZATION - FAP With REMOTE URL DOWNLOAD/LINK MOD
Hallo, and thanks for your work Mighty Gorgon! :)

I decided to update from Smartors album to FAP, but I have a little problem - the FAP don't works with ROMOTE URL DOWNLOAD/LINK MOD from Smartor's site. Images are not shown and I can't download/link them. :( Maybe you can help me with some changes in this mod to get it work with FAP? Thanks!

Code: [Download] [Hide] [Select]
##############################################################
## MOD Title: ROMOTE URL DOWNLOAD/LINK MOD
## for Photo Album Addon v2 for phpBB2
## MOD Author: I'm not admitting to writing this one either.
## MOD Description:
##
## Download or Link to an image from another website.
##
## Tested with: phpBB 2.0.8 - PHP4.3.3
## MySQL 3.23.x and Smartor's Photo Album Addon v2 for phpBB2
##
## MOD Version:
##
## Installation Level: easy
## Installation Time: 15 minutes
##
## Files To Edit: 5
## album_upload.php
## album_thumbnail.php
## album_pic.php
## templates/subSilver/album_upload_body.tpl
## language/lang_english/lang_main_album.php
##
##############################################################
## Author Notes:
##
## Limited testing. Feedback is always nice.
## Take this as a beta version.
##
##############################################################
## Before Adding This MOD To Your Photo Album,
## You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]-------------------------------------------------------
#
album_upload.php

#
#-----[ FIND ]----------------------------------------
#
'L_MAX_FILESIZE' => $lang['Max_file_size'],
'S_MAX_FILESIZE' => $album_config['max_file_size'],

#
#-----[ BEFORE ADD ]----------------------------------------
#
'L_REMOTE_URL' => $lang['Remote_url'],
'L_REMOTE_DL' => $lang['Remote_DL'],

#
#-----[ FIND ]----------------------------------------
#
// --------------------------------
// Prepare variables
// --------------------------------

$pic_time = time();
$pic_user_id = $userdata['user_id'];
$pic_user_ip = $userdata['session_ip'];

#
#-----[ AFTER ADD ]----------------------------------------
#
// -----------------------
// Remote url download mod
// -----------------------
if( $HTTP_POST_FILES['pic_file']['size']==0 and $HTTP_POST_VARS['remote_url'] != "" and empty($HTTP_POST_VARS['remote_dl']) ) $HotLinked = true;
if( $HTTP_POST_FILES['pic_file']['size']==0 and $HTTP_POST_VARS['remote_url'] != "" )
{
$remote_filename = $HTTP_POST_VARS['remote_url'];

if ( preg_match('/^(http://)?([w-.]+):?([0-9]*)/(.*)$/', $remote_filename, $url_ary) )
{
if ( empty($url_ary[4]) )
{
message_die(GENERAL_ERROR, 'Incomplete URL.', '', __LINE__, __FILE__);
}

$base_get = '/' . $url_ary[4];
$port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;

if ( !($fsock = fsockopen($url_ary[2], $port, $errno, $errstr)) )
{
message_die(GENERAL_ERROR, 'Could not open URL.', '', __LINE__, __FILE__);
}

@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);

if (!preg_match('#Content-Length: ([0-9]+)[^ /][s]+#i', $remote_data, $file_data1) || !preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $remote_data, $file_data2))
{
//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";
if(substr_count( strtolower($url_ary[4]), strtolower(".php"))) preg_match('#Content-Type: image/[x-]*([a-z]+)[s]+#i', $remote_data, $file_data2);
//Need to download the data in a different way.
$handle = fopen ($url_ary[0], "rb");
unset($remote_data);
do
{
$data = fread($handle, 8192);
if (strlen($data) == 0) break;
$remote_data .= $data;
} while(true);
fclose ($handle);
$file_data1[1] = strlen($remote_data);
}
else
{
while( !@feof($fsock) )
{
$remote_data .= @fread($fsock, 1024);
}
@fclose($fsock);
}

$remote_filesize = $file_data1[1];
$remote_filetype = $file_data2[1];

switch ($remote_filetype)
{
case 'jpeg':
case 'jpg':
case 'pjpeg':
if ($album_config['jpg_allowed'] == 0)
{
message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']);
}
$pic_filetype = '.jpg';
break;

case 'png':
case 'x-png':
if ($album_config['png_allowed'] == 0)
{
message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']);
}
$pic_filetype = '.png';
break;

case 'gif':
if ($album_config['gif_allowed'] == 0)
{
message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']);
}
$pic_filetype = '.gif';
break;
default:
message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']);
}

if ( $remote_filesize > 0 and $remote_filesize < $album_config['max_file_size'] )
{
$remote_data = substr($remote_data, strlen($remote_data) - $remote_filesize, $remote_filesize);

srand((double)microtime()*1000000);
do
{
$pic_filename = md5(uniqid(rand())) . $pic_filetype;
} while( file_exists(ALBUM_UPLOAD_PATH . $pic_filename) or file_exists(ALBUM_CACHE_PATH . $pic_filename) );

$fptr = fopen(ALBUM_UPLOAD_PATH . $pic_filename, 'wb');
$bytes_written = fwrite($fptr, $remote_data, $remote_filesize);
fclose($fptr);

if ( $bytes_written != $remote_filesize )
{
unlink(ALBUM_UPLOAD_PATH . $pic_filename);
message_die(GENERAL_ERROR, 'Could not write file to local storage.', '', __LINE__, __FILE__);
}
}
else
{
message_die(GENERAL_MESSAGE, $lang['Bad_upload_file_size']);
}
}
}
else
{
// ---------------------------
// End remote url download mod
// ---------------------------

#
#-----[ FIND ]----------------------------------------
#
// --------------------------------
// Well, it's an image. Check its image size
// --------------------------------

#
#-----[ BEFORE ADD ]----------------------------------------
#
// Remote url download mod
}
// -----------------------

#
#-----[ FIND ]----------------------------------------
#
while( file_exists(ALBUM_UPLOAD_PATH . $pic_filename) );

#
#-----[ REPLACE WITH ]----------------------------------------
#
while( file_exists(ALBUM_UPLOAD_PATH . $pic_filename) or file_exists(ALBUM_CACHE_PATH . $pic_filename) );



#
#-----[ FIND ]----------------------------------------
#
// --------------------------------
// Insert into DB
// --------------------------------

#
#-----[ AFTER ADD ]----------------------------------------
#
if( $HTTP_POST_FILES['pic_file']['size']==0 and $HTTP_POST_VARS['remote_url'] != "" and empty($HTTP_POST_VARS['remote_dl']) )
{
@unlink(ALBUM_UPLOAD_PATH . $pic_filename);
$pic_filename = $url_ary[0];
}

#
#-----[ OPEN ]----------------------------------------
#(for all your templates, subsilver etc)
album_upload_body.tpl

#
#-----[ FIND ]----------------------------------------
#
else if (document.upload.pic_file.value.length < 2)

#
#-----[ REPLACE WITH ]----------------------------------------
#
else if (document.upload.pic_file.value.length < 2 && document.upload.remote_url.value.length < 2)

#
#-----[ FIND ]----------------------------------------
#
<!-- END switch_manual_thumbnail -->

#
#-----[ AFTER ADD ]----------------------------------------
#
<tr>
<td class="row1" height="28"><span class="gen">{L_REMOTE_URL}</span></td>
<td class="row2"><input class="post" type="text" name="remote_url" size="45" />&nbsp;&nbsp;<input type="checkbox" name="remote_dl"><span class="gensmall">{L_REMOTE_DL}</span></td>
</tr>

#
#-----[ OPEN ]----------------------------------------
#(for all your languages)
lang_main_album.php

#
#-----[ FIND ]----------------------------------------
#
?>

#
#-----[ BEFORE ADD ]----------------------------------------
#
$lang['Remote_url'] = "Upload image from URL";
$lang['Remote_DL'] = "Download";

#
#-----[ 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 ]----------------------------------------
#
// --------------------------------
// Hmm, cache is empty. Try to re-generate!
// --------------------------------

#
#-----[ BEFORE ADD ]----------------------------------------
#
// Remote download/link Mod
// Cache is empty so i guess we need to download again.
if($url_ary[1]=="http://" or $url_ary[1]=="ftp://")
{
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);
if (!preg_match('#Content-Length: ([0-9]+)[^ /][s]+#i', $remote_data, $file_data1))
{
//Need to download the data in a different way.
$handle = fopen ($url_ary[0], "rb");
unset($remote_data);
do
{
$data = fread($handle, 8192);
if (strlen($data) == 0) break;
$remote_data .= $data;
} while(true);
fclose ($handle);
$file_data1[1] = strlen($remote_data);
}
else
{
while( !@feof($fsock) )
{
$remote_data .= @fread($fsock, 1024);
}
@fclose($fsock);
}
$pic_filesize = $file_data1[1];
if ( $pic_filesize > 0 )
{
$remote_data = substr($remote_data, strlen($remote_data) - $pic_filesize, $pic_filesize);
srand((double)microtime()*1000000);
do
{
$pic_filename = md5(uniqid(rand())) . $pic_filetype;
} while( file_exists(ALBUM_UPLOAD_PATH . $pic_filename) or file_exists(ALBUM_CACHE_PATH . $pic_filename) );

$fptr = fopen(ALBUM_UPLOAD_PATH . $pic_filename, 'wb');
$bytes_written = fwrite($fptr, $remote_data, $pic_filesize);
fclose($fptr);

if ( $bytes_written != $pic_filesize )
{
unlink(ALBUM_UPLOAD_PATH . $pic_filename);
die('Could not write file to local storage.');
}
}
else
{
die($lang['Bad_upload_file_size']);
}
}
// End Remote download/link mod

#
#-----[ 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

#
#-----[ 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://")) )

#
#-----[ FIND ]----------------------------------------
#
// ------------------------------------
// Okay, now we can send image to the browser
// ------------------------------------

#
#-----[ BEFORE ADD ]----------------------------------------
#
// Remote download/link mod
if($url_ary[1]=="http://" or $url_ary[1]=="ftp://")
{
header("Location: $pic_filename");
exit;
}

// End Remote download/link mod

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Still not solved :cry:

Here is the topic of this MOD:
http://smartor.is-root.com/viewtopic.php?t=1209

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Darkheart wrote: [View Post]
Still not solved :cry:

Here is the topic of this MOD:
http://smartor.is-root.com/viewtopic.php?t=1209

That link take me to the topic - last 24 hrs users in italics?

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Sorry, I have not copied whole link, there is one number missing. Here is the right link, please:
http://smartor.is-root.com/viewtopic.php?t=12091

nuffmon wrote: 
Been away for a while and didn't realise anyone still used this. There are huge changes in FAP. I think it would take a while to get it running. It may be worth mentioning it to MG as a future enhancement.


I think that would be a usefull feature in FAP.
Mighty Gorgon, what do you think about this? :roll:

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Hi

I have tried to install this MOD but did not run into FAP IP :( :( :(

Pepi

Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
sos

Somebody?! :roll:

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
PLEASE, i need it too!! :(

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
:( :( :(

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
pepi wrote: [View Post]
Hi

I have tried to install this MOD but did not run into FAP IP :( :( :(

Pepi

Artie and Mighty please help

Pepi

Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Artie is busy trying to get his own site together at the moment.
Don't know that I would have any better luck getting this to work than you did, pepi :wink:

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
I'll try to have a look... but since I'm busy in porting FAP into phpBB 3 this may not happen soon... I hope you may be a bit patient and still try to figure out yourself why it is not working... :roll:

Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Hello
The Problem is this
Spoiler: [ Show ]

and
Spoiler: [ Show ]

Dosn't find this code to edit

pepi

Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Because those files are now totally different from the original ones.

I'll try to have a look, and I can point you where that code has to be inserted... but I have no time to get it working.

Next time I'll open FAP files I'll have a look.

Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
Since smartor-is-root has been down for a couple weeks, can someone post the mod files?

Profile PM  
Subject: Re: FAP With REMOTE URL DOWNLOAD/LINK MOD
has anyone fix this yet. It does not work with the newest FAP.


Page 1 of 2


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.1855s (PHP: 12% SQL: 88%)
SQL queries: 10 - Debug Off - GZIP Enabled