Welcome to Geeklog, Anonymous Saturday, August 31 2024 @ 11:31 pm EDT
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.
8
14
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));
}
7
5
Quote
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
bump
9
7
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.
![](http://www.geeklog.net/images/smiles/banghead.gif)
Thank you for the help.
8
7
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;
}
?>
7
9
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.
24
5
Quote
Status: offline
comicbookguy
Forum User
Regular Poster
Registered: 05/15/04
Posts: 97
![](http://www.geeklog.net/images/smiles/icon_lol.gif)
7
8
Quote
All times are EDT. The time is now 11:31 pm.
- 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