Hoi Dark Inca,
Ik neem aan dat je dit stukje code bedoeld:
Code: Selecteer alles
function import_image($file, $destination = true)
{
global $config, $convert, $phpbb_root_path, $phpEx;
if($file === NULL or $file == '')
{
return '';
}
else
{
if( !is_string($destination))// always be string, no string then change it as deafult to icons_path
{
$destination = $config['icons_path'];
}
if( !preg_match('/^(https|http|ftp):\/\//', $file) || preg_match('/^'. preg_replace('/\//','\/',generate_oldboard_url(true)).'/', $file))//only images on the local server.
{
if(preg_match('/^'.preg_replace('/\//','\/',generate_oldboard_url(true)).'/', $file) && !preg_match('/^'.preg_replace('/\//','\/',generate_oldboard_url()).'/', $file))// images on local server but not in forum dirs
{
$script_path = get_config_value('script_path');
$temp_path = explode("/",$script_path);
unset($temp_path[0]);
$depth = sizeof($temp_path);
$file_path = "";
for($i = 1;$i < $depth; $i++)
{
$file_path .= "../";
}
$file = $file_path . substr($file,strlen(generate_oldboard_url(true))+1);
}
else if(preg_match('/^'.preg_replace('/\//','\/',generate_oldboard_url()).'/', $file)) // images in forum dirs
{
$file = substr($file,strlen(generate_oldboard_url())+1);
}
$filenames = explode("/",$file);
$filename = $filenames[sizeof($filenames)-1];
if (strpos($filename, '.') === false)
{
return '';
}
unset($filenames[sizeof($filenames)-1]);
if( empty($filenames[0]))
{
unset($filenames[0]);
}
$file_path = implode("/", $filenames);
copy_file($file_path. "/" . $filename, $destination."/".$filename, false, false);
return $destination."/".$filename;
}
else//remote upload from an url
{
//thanks to function avatar_upload :)
if( !class_exists('fileupload'))
{
include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
}
$upload = new fileupload('',array('jpg', 'jpeg', 'gif', 'png'));
$file = $upload->remote_upload($file);
if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\')
{
$destination = substr($destination, 0, -1);
}
$destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
if ($destination && ($destination[0] == '/' || $destination[0] == "\\"))
{
$destination = '';
}
$file->move_file($destination, true);
if (sizeof($file->error))
{
$file->remove();
}
return substr($file->get('destination_file'),5); // deleting ./../ because in install folder
}
}
}
IIG bedankt voor je tip.