profile icon with non alfanumeric values

Sorry if someone has talked about this before. I had a problem with spanish accents (tildes) and couldn't find the solution. So I have investigated it and I think that I have a workaround for this.

For Elgg 1.5

The Problem:

If your users set a username with non-alfanumeric values (for example: ñ, á, é, í, ó, ú ...) which is really common in spanish, the user icon will not display properly. But this happens only sometimes. I think that it only happens when the site caché is on.

This happens because the icon is stored under a directory tree formed with the letters of the username. And many systems aren't capable of managing this kind of letters.

The Solution (not really a solution, just a workaround, sorry):



I commented the code for when the caché is set to on and the profile icon is not found. It's around line 76 until the end. And copied the same code for when the cache is off. I know that it is a dirty solution, but it worked and I didn't want to touch a lot more.


if ($simplecache_enabled) {
   $filename = $dataroot . $matrix . "{$username}/profile/" . $username . $size . ".jpg";
   $contents = @file_get_contents($filename);
   if (empty($contents)) { 
    require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
    global $viewinput;
    $viewinput['view'] = 'icon/user/default/'.$size;
    $loc = ob_get_clean();
    header('Location: ' . $loc);
    //$contents = @file_get_contents(dirname(__FILE__) . "/graphics/default{$size}.jpg");
   } else {  

    header("Content-type: image/jpeg");
    header('Expires: ' . date('r',time() + 864000));
    header("Pragma: public");
    header("Cache-Control: public");
    header("Content-Length: " . strlen($contents));
    $splitString = str_split($contents, 1024);
    foreach($splitString as $chunk)
     echo $chunk;
  } else {
    require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");