Avatar

Test file with getAvatar-Function (General)

by Milo ⌂, Tuesday, November 29, 2016, 18:27 (376 days ago) @ Magma

Hi,

please create a test.php file with the following content and load up this file to the root directory of your forum:

<?php
 
function getAvatar($user_id) {
 $avatar_images_path = 'images/avatars/';
 $fileList = glob( $avatar_images_path . intval($user_id) . "[_.]*{png,jpg,jpeg,gif,bmp}" , GLOB_BRACE);
 if (isset($fileList) && count($fileList) > 0) {
  foreach ($fileList as $file) {
   if (preg_match("/^(" . preg_quote($avatar_images_path, '/') . ")(" . preg_quote(intval($user_id)) . "(_\d+)?\.(jpg|gif|png|jpeg,bmp))$/", $file, $matches)) {
    //var_dump($matches);
    $filename = $matches[2];
    if (file_exists($avatar_images_path.$filename))
     return array($avatar_images_path, $filename, $avatar_images_path.$filename);
   }
  }
 }
 return false;
}
 
$user_id = 1; // <---- Set this value to a valid user id.
var_dump(getAvatar($user_id));
 
?>

Edit the $user_id to a valid user id with existing avatar image. Call http://<yourForumAdress>/test.php. What is happens?

/Micha

--
Surveyor-Software: Geodetic Network Adjustment & Deformation-Analysis and Transformation


Complete thread:

 RSS Feed of thread

powered by my little forum