Wollte fragen, ob Du diesen Mod kennst?
Damit kann man angeblich Fotos von einer URL hochladen. Habe gesehen, dass er bei Dir nicht eingebaut ist... also ich habe es mehrfach probiert, bei mir funtzt der nicht##############################################################
## 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.1\r\n");
@fputs($fsock, "HOST: " . $url_ary[2] . "\r\n");
@fputs($fsock, "Connection: close\r\n\r\n");
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" /> <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.1\r\n");
@fputs($fsock, "HOST: " . $url_ary[2] . "\r\n");
@fputs($fsock, "Connection: close\r\n\r\n");
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.1\r\n");
@fputs($fsock, "HOST: " . $url_ary[2] . "\r\n");
@fputs($fsock, "Connection: close\r\n\r\n");
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.1\r\n");
@fputs($fsock, "HOST: " . $url_ary[2] . "\r\n");
@fputs($fsock, "Connection: close\r\n\r\n");
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
das "add URL" Feld kommt irgendwo anders, und es tut sich nichts...
ich denke doch, das wäre ein interessanter Mod, der würde vieles vereinfachen für die User.
Haste den vielleicht schon mal probiert? Weisst Du vielleicht, woran es hakt?