sql_query($sql)) { $error = $db->sql_error(); die("Could not get avatar information! $error[code] : $error[message]"); } // Create a hash to keep track of all the user that is using the uploaded avatar while ($avatar_rowset = $db->sql_fetchrow($result)) { $avatar_usage[$avatar_rowset['user_avatar']] = $avatar_rowset['username']; } // This is the variable that points to the path of the avatars // You may need to ajust this to meet your needs ;) $real_avatar_dir = $phpbb_root_path . '../../' . $board_config['avatar_path']; echo '

Avatar Management

The table below shows all currently stored uploaded avatars. These are only the avatars which were selected to be uploaded by users, this will not show avatars currently in the gallery. If any of the listed avatars are no longer used by any user an option to delete it will appear. This is a permanent delete, once you have selected to delete an avatar it will be removed from the server and no longer be available. You will be prompted for confirmation (requires Javascript).

'; switch ($mode) { case 'delete': echo ''; if (unlink($real_avatar_dir.'/'.$target)) { echo ""; } else { echo ""; } echo '
Success, ".$target." deleted!
Continue
FAILED to delete ".$target."!
Go Back
'; break; default: echo ' '; $alt1 = '#ccccff'; $alt2 = '#eeeeee'; $alter = $alt2; // This is where we go through the avatar directory and report whether they are not // used or if they are used, by who. if ($avatar_dir = @opendir($real_avatar_dir)) { while ($file = @readdir($avatar_dir)) { // This is where the script will filter out any file that doesn't match the patterns if (($file != '.') && ($file != '..') && ereg("\.(gif|jpg|jpeg|png)$",$file)) { $stats = stat($real_avatar_dir.'/'.$file); // Alternating row colows code if ($alter == $alt1) { $alter = $alt2; } elseif ($alter == $alt2) { $alter = $alt1; } if (isset($avatar_usage[$file])) { // Since we need to supply a link with a valid sid later in html, let's build it now $av_id = $avatar_usage[$file]; $sql = "SELECT user_id FROM " . USERS_TABLE . " WHERE username = '$av_id'"; if (!$result = $db->sql_query($sql)) { $error = $db->sql_error(); die("Could not get user information! $error[code] : $error[message]"); } $av_uid = $db->sql_fetchrow($result); $avatar_uid = $av_uid['user_id']; $edit_url = append_sid("admin_users.$phpEx?mode=edit&u=$avatar_uid"); // Bingo, someone is using this avatar echo " \n"; } else { // Not used, safe to display delete link for admin $delete_html = append_sid("admin_avatar.$phpEx?mode=delete&target=$file""); echo " \n"; } } } } else { // If we made it to this else there was a problem trying to read the avatar directory // If you see this error message check this variable: // $real_avatar_dir -> This may be set incorrectly for your site. echo 'Avatar directory unavailable!'; } echo '
Avatar Size Usage Edit user

".$file."
".$stats[7]." Bytes ".$avatar_usage[$file]." Edit ".$avatar_usage[$file]."

".$file."
".$stats[7]." Bytes Not Used
Delete
 
'; break; } ?>