03-22-2007, 06:25 PM
... if you have curl library...
the problem
when you try to use remote avatar if you don't have set to true the allow_url_fopen in your (your host) php.ini you could not use the avatar because server politic don't grant to u the ability to have access to remote file (file placed in other server).
the solution
use the curl library
the requirements
- you must have the curl library, of course
- create and give chmod to the directory in your forum: /uploads/tmpavatar
- add the code of the new my_getimagesize function in inc/functions.php
- change every getimagesize function call in my_getimagesize [there is in three file: usercp.php, functions_upload.php, functions_image]
the code
the problem
when you try to use remote avatar if you don't have set to true the allow_url_fopen in your (your host) php.ini you could not use the avatar because server politic don't grant to u the ability to have access to remote file (file placed in other server).
the solution
use the curl library
the requirements
- you must have the curl library, of course
- create and give chmod to the directory in your forum: /uploads/tmpavatar
- add the code of the new my_getimagesize function in inc/functions.php
- change every getimagesize function call in my_getimagesize [there is in three file: usercp.php, functions_upload.php, functions_image]
the code
PHP Code:
function my_getimagesize($url)
{
if (eregi('^(http|ftp)://', substr($url, 0, 10))) {
if (!ini_get('allow_url_fopen')) {
$ch = curl_init($url);
$n = 'uploads/tmpavatar/tmp'.str_replace(array(" ",'.'),array('',''),microtime());
$fn = tempnam("",$n);
$fp = fopen($n, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
$ret = @getimagesize($n);
unlink($n);
return $ret;
}
}
}