MyBB Community Forums

Full Version: Check if all users avatars are working?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
is it possible somehow to check if some of my users avatars links are broken?
I don't think its possible with just one and two lines. I had written a massive plugin to check the broken/live links. The links for avatars have similar concept too.
(2012-05-28, 12:38 PM)Yaldaram Wrote: [ -> ]I don't think its possible with just one and two lines. I had written a massive plugin to check the broken/live links. The links for avatars have similar concept too.

Where can I find that plugin?
Its custom. Also it will not be the exact plugin you're looking here. I just given you an example how such things work.
Why not make a custom PHP page, connect it to the mybb database. And let it print out every single avatar with the username behind it?

Yes it doesnt correct the problem or something. But this would create a giant list of avatar images and usernames behind it. You could just scroll through it and find the avatars that are broken.

You could probably even sort it out to only display images that are not there using something like:

if(!file($variable)) etc.
For external images you would want to use : getimagesize to check if the image exists

The most basic one would be:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Checking If Images exist</title>
</head>
<body>
<table border="1" padd>
<tr>
<td width="150">Username: </td><td width="200"></td><td width="600">Url link to image: </td>
<?php 
//things you are can Edit//
//Information to connect to your database
 $host = ' ';  //hostname
 $user = ' ';  //username
 $psw = ' ';   //password
 //MyBB database name (for example  'name_mybb1')
 $dbName = ' ';
 
 //Your site URL (http://yoursite.com/ use the complete URL! )
 $uploadFolder = ' ';  //link to upload folder
 $imageFolder = ' '; //link to image folder

 //DONT EDIT ANY PHP code BELOW unless you know what you are doing//
 
 
 // Connects to your Database 
 $link = mysql_connect($host, $user, $psw); 
 if (!$link) {
    die('Not connected to the database: ' . mysql_error());
}
 $data = mysql_query("SELECT * FROM ".$dbName.".mybb_users ORDER BY `uid`");
 if (!$data) {
    die ('Not able to run the MySQL query : ' . mysql_error());
}
 while($picture = mysql_fetch_array( $data )) 
 { 
 $iPath = $picture['avatar'];  //images url
 
 
 //making sure avatar/uploaded avatars work
 $uri = $iPath;
 $newuri = str_replace("./uploads/",$uploadFolder,$uri);
 $newuri2 = str_replace("images/",$imageFolder,$uri);
 
 
 if($iPath !== '')
   { 
   if (@GetImageSize($newuri) || @GetImageSize($newuri2)) 
	{
 	echo "";
   	}
   else
   	{
   	$username = $picture['username'];
   	echo "<tr><td>".$username."</td><td><strong>This Image is not Valid</strong></td><td>".$iPath."</rd></tr>";
   	}
   
   }
} 
?> 
</tr>
</table>
</body> 
</html>

That code should do the job for you. Just create a new php file in the root of your mybb folder. Change the information on the top:

//things you are can Edit//
//Information to connect to your database
 $host = ' ';  //hostname
 $user = ' ';  //username
 $psw = ' ';   //password
 //MyBB database name (for example  'name_mybb1')
 $dbName = ' ';
 
 //Your site URL (http://yoursite.com/ use the complete URL! )
 $uploadFolder = ' ';  //link to upload folder
 $imageFolder = ' '; //link to image folder

And then everything should work. Which should give you something like this:

[Image: result.jpg]

If there is a problem give a shout. And for people who know how to use the mybb database short cuts etc. feel free to modify my code.