Welcome to Geeklog, Anonymous Monday, December 23 2024 @ 04:17 am EST
Geeklog Forums
Random Member Block
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
I have spent quite a bit of time trying to figure out this error with no luck. Here is the error message I am getting:
Warning: getimagesize(http://www.planetdouglas.com/images/userphotos/birdgirl.jpg): failed to open stream: Permission denied in /home/***/system/lib-custom.php on line 365
Warning: Division by zero in /home/***/system/lib-custom.php on line 379
I have changed the name of my database (to protect the innocent) to ***. The problem is with the random member block which randomly displays a random members image.
If anyone has any ideas I would appreciate your help.
Thank you.
Text Formatted Code
Warning: getimagesize(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/***/system/lib-custom.php on line 365Warning: getimagesize(http://www.planetdouglas.com/images/userphotos/birdgirl.jpg): failed to open stream: Permission denied in /home/***/system/lib-custom.php on line 365
Warning: Division by zero in /home/***/system/lib-custom.php on line 379
I have changed the name of my database (to protect the innocent) to ***. The problem is with the random member block which randomly displays a random members image.
If anyone has any ideas I would appreciate your help.
Thank you.
12
17
Quote
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
Here is the code from my lib-custom.php file beginning at line 363.
$uphoto_url = "{$_CONF['site_url']}/images/userphotos/$uinfo[photo]";
$uphoto_size = getimagesize($uphoto_url); // returns an array
$uphoto_width = $uphoto_size[0];
$uphoto_height = $uphoto_size[1];
// determine which dimension is larger
if ($uphoto_height > $uphoto_width) {
$largest = "uphoto_height";
} elseif ($uphoto_width > $uphoto_height) {
$largest = "uphoto_width";
} else { // they are equal
$largest = "uphoto_height";
}
// determines the percentage of shrinkage we'll need to use
$shrink_amount = ($image_max_bounds*100) / $$largest;
$shrink_amount = ceil($shrink_amount);
if ($shrink_amount > 99) { // it's already smaller - don't change it
$iwidth = $uphoto_width;
$iheight = $uphoto_height;
} else { // determine the new image size after shrinking
$iwidth = ceil($uphoto_width * ($shrink_amount / 100));
$iheight = ceil($uphoto_height * ($shrink_amount / 100));
}
Text Formatted Code
// Get and size Picture$uphoto_url = "{$_CONF['site_url']}/images/userphotos/$uinfo[photo]";
$uphoto_size = getimagesize($uphoto_url); // returns an array
$uphoto_width = $uphoto_size[0];
$uphoto_height = $uphoto_size[1];
// determine which dimension is larger
if ($uphoto_height > $uphoto_width) {
$largest = "uphoto_height";
} elseif ($uphoto_width > $uphoto_height) {
$largest = "uphoto_width";
} else { // they are equal
$largest = "uphoto_height";
}
// determines the percentage of shrinkage we'll need to use
$shrink_amount = ($image_max_bounds*100) / $$largest;
$shrink_amount = ceil($shrink_amount);
if ($shrink_amount > 99) { // it's already smaller - don't change it
$iwidth = $uphoto_width;
$iheight = $uphoto_height;
} else { // determine the new image size after shrinking
$iwidth = ceil($uphoto_width * ($shrink_amount / 100));
$iheight = ceil($uphoto_height * ($shrink_amount / 100));
}
10
8
Quote
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
bump
13
10
Quote
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
What version of PHP are you using?
I am using 4.3.8
try changing $$largest to $largest.
I thought about that myself but I have been told by a php guy that that is not the problem. I will give it a try anyway and see what happens.
I think it is a logic problem with resizing the images. I suspect the images that are causing the errors are all the same size.
Thank you for the help.
13
10
Quote
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
Here is the whole thing:
global $_CONF;
// this function pulls a random member's information
// and displays it in a block - only if they have a photo uploaded though
// written by Benjamin Costello of http://chilax.com/ <benjamin@chilax.com>
// idea inspired by MemberPhotos hack by Mr. GXBlock (http://www.gxblock.com/)
// set the preferred maximum size (will fit within a square this size)
$image_max_bounds = "100";
$pathtoimages = $_CONF['path_html'] . 'images/userphotos';
// Do database query
$sql = "SELECT * FROM gl_users WHERE photo <> 'NULL' && (photo <> '') ORDER BY RAND() LIMIT 1";
$result = mysql_query($sql);
$uinfo = mysql_fetch_array($result);
// Get and size Picture
$uphoto_url = "{$_CONF['site_url']}/images/userphotos/$uinfo[photo]";
$uphoto_size = getimagesize($uphoto_url); // returns an array
$uphoto_width = $uphoto_size[0];
$uphoto_height = $uphoto_size[1];
// determine which dimension is larger
if ($uphoto_height > $uphoto_width) {
$largest = "uphoto_height";
} elseif ($uphoto_width > $uphoto_height) {
$largest = "uphoto_width";
} else { // they are equal
$largest = "uphoto_height";
}
// determines the percentage of shrinkage we'll need to use
$shrink_amount = ($image_max_bounds*100) / $$largest;
$shrink_amount = ceil($shrink_amount);
if ($shrink_amount > 99) { // it's already smaller - don't change it
$iwidth = $uphoto_width;
$iheight = $uphoto_height;
} else { // determine the new image size after shrinking
$iwidth = ceil($uphoto_width * ($shrink_amount / 100));
$iheight = ceil($uphoto_height * ($shrink_amount / 100));
}
$retval .= "<CENTER>";
$retval .= "<IMG SRC="{$_CONF['site_url']}/images/userphotos/$uinfo[photo]" WIDTH="$iwidth" HEIGHT="$iheight" ALT="" VSPACE=4>";
$retval .= "n<BR>n";
$retval .= "<B><A HREF="{$_CONF['site_url']}/users.php?mode=profile&uid=$uinfo[uid]">$uinfo[username]</A></B>";
return $retval;
}
?>
Text Formatted Code
function phpblock_randMember() {global $_CONF;
// this function pulls a random member's information
// and displays it in a block - only if they have a photo uploaded though
// written by Benjamin Costello of http://chilax.com/ <benjamin@chilax.com>
// idea inspired by MemberPhotos hack by Mr. GXBlock (http://www.gxblock.com/)
// set the preferred maximum size (will fit within a square this size)
$image_max_bounds = "100";
$pathtoimages = $_CONF['path_html'] . 'images/userphotos';
// Do database query
$sql = "SELECT * FROM gl_users WHERE photo <> 'NULL' && (photo <> '') ORDER BY RAND() LIMIT 1";
$result = mysql_query($sql);
$uinfo = mysql_fetch_array($result);
// Get and size Picture
$uphoto_url = "{$_CONF['site_url']}/images/userphotos/$uinfo[photo]";
$uphoto_size = getimagesize($uphoto_url); // returns an array
$uphoto_width = $uphoto_size[0];
$uphoto_height = $uphoto_size[1];
// determine which dimension is larger
if ($uphoto_height > $uphoto_width) {
$largest = "uphoto_height";
} elseif ($uphoto_width > $uphoto_height) {
$largest = "uphoto_width";
} else { // they are equal
$largest = "uphoto_height";
}
// determines the percentage of shrinkage we'll need to use
$shrink_amount = ($image_max_bounds*100) / $$largest;
$shrink_amount = ceil($shrink_amount);
if ($shrink_amount > 99) { // it's already smaller - don't change it
$iwidth = $uphoto_width;
$iheight = $uphoto_height;
} else { // determine the new image size after shrinking
$iwidth = ceil($uphoto_width * ($shrink_amount / 100));
$iheight = ceil($uphoto_height * ($shrink_amount / 100));
}
$retval .= "<CENTER>";
$retval .= "<IMG SRC="{$_CONF['site_url']}/images/userphotos/$uinfo[photo]" WIDTH="$iwidth" HEIGHT="$iheight" ALT="" VSPACE=4>";
$retval .= "n<BR>n";
$retval .= "<B><A HREF="{$_CONF['site_url']}/users.php?mode=profile&uid=$uinfo[uid]">$uinfo[username]</A></B>";
return $retval;
}
?>
10
12
Quote
Status: offline
zipstart
Forum User
Chatty
Registered: 09/13/04
Posts: 60
Looks like it's failing on users with a space in their name. Place this before // Get and size Picture...
$user_photo = str_replace(" ","%20",$uinfo[photo]);
and replace $uinfo[photo] with $user_photo. Works fine on my site after that.
Text Formatted Code
//replace spaces in user photo name$user_photo = str_replace(" ","%20",$uinfo[photo]);
and replace $uinfo[photo] with $user_photo. Works fine on my site after that.
27
8
Quote
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
Thanks. I will try that tonight when i get home.
11
11
Quote
All times are EST. The time is now 04:17 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content