Avatar

Test file with getAvatar-Function (General)

by Micha ⌂, Wednesday, November 30, 2016, 08:40 (2703 days ago) @ Magma

Hi,

I did this, all I can see is the following text:

Okay, the function works fine without problems. The path, the image name and the path with image is returned.

We know, this function works, so, can you add it to the function.inc.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;
}


After adding this code, the forum should still running without an error because the function is never called. Is this right?

Now, please add a sample output. Please edit the avatar.inc.php. Look for:

if($settings['avatars']>0 && isset($_SESSION[$settings['session_prefix'].'user_id']))
 {
  if(isset($_GET['delete']))
   {

and add the function call behind the first if-statement

if($settings['avatars']>0 && isset($_SESSION[$settings['session_prefix'].'user_id']))
 {
  // START NEW LINE
  var_dump(getAvatar($_SESSION[$settings['session_prefix'].'user_id']));
  // END NEW LINE
  if(isset($_GET['delete']))
   {


Please visit your user profile and click on the link to change your avatar. You should get an output like:

array(3) { [0]=> string(15) "images/avatars/" [1]=> string(7) "243.png" [2]=> string(22) "images/avatars/243.png" }

Do you get the output (or a similar one)?

Please remove the line from avatar.inc.php, if the check is done. ;-)

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences


Complete thread:

 RSS Feed of thread