plugins/SpecialUserFuncs.php
changeset 621 68f8a9cc0a18
parent 614 78d1e71dc720
child 684 15dbbe7e7674
equal deleted inserted replaced
620:58852672ff12 621:68f8a9cc0a18
  2077   $aggressive_optimize_html = false;
  2077   $aggressive_optimize_html = false;
  2078   
  2078   
  2079   $img_types = array(
  2079   $img_types = array(
  2080       IMAGE_TYPE_PNG => 'png',
  2080       IMAGE_TYPE_PNG => 'png',
  2081       IMAGE_TYPE_GIF => 'gif',
  2081       IMAGE_TYPE_GIF => 'gif',
  2082       IMAGE_TYPE_JPG => 'jpg'
  2082       IMAGE_TYPE_JPG => 'jpg',
       
  2083       IMAGE_TYPE_GRV => 'grv'
  2083     );
  2084     );
  2084   
  2085   
  2085   $avi_id = $paths->getParam(0);
  2086   $avi_id = $paths->getParam(0);
  2086   if ( !$avi_id || !@preg_match('/^[a-f0-9]+$/', $avi_id) )
  2087   if ( !$avi_id || !@preg_match('/^[a-f0-9]+$/', $avi_id) )
  2087   {
  2088   {
  2104     return true;
  2105     return true;
  2105   }
  2106   }
  2106   
  2107   
  2107   // build file path
  2108   // build file path
  2108   $avi_type = $img_types[$avi_id_dec['img_type']];
  2109   $avi_type = $img_types[$avi_id_dec['img_type']];
       
  2110   
       
  2111   // is this a gravatar?
       
  2112   if ( $avi_type == 'grv' )
       
  2113   {
       
  2114     // yes, we'll have to redirect
       
  2115     // sanitize UID
       
  2116     $uid = intval($avi_id_dec['uid']);
       
  2117     
       
  2118     // fetch email
       
  2119     $q = $db->sql_query('SELECT email FROM ' . table_prefix . "users WHERE user_id = $uid;");
       
  2120     if ( !$q )
       
  2121       $db->_die();
       
  2122     if ( $db->numrows() < 1 )
       
  2123       return false;
       
  2124     
       
  2125     list($email) = $db->fetchrow_num();
       
  2126     $db->free_result();
       
  2127     
       
  2128     $url = make_gravatar_url($url);
       
  2129     
       
  2130     // ship out the redirect
       
  2131     header('HTTP/1.1 302 Permanent Redirect');
       
  2132     header("Location: $url");
       
  2133   }
       
  2134   
  2109   $avi_path = ENANO_ROOT . '/' . getConfig('avatar_directory') . '/' . $avi_id_dec['uid'] . '.' . $avi_type;
  2135   $avi_path = ENANO_ROOT . '/' . getConfig('avatar_directory') . '/' . $avi_id_dec['uid'] . '.' . $avi_type;
  2110   if ( file_exists($avi_path) )
  2136   if ( file_exists($avi_path) )
  2111   {
  2137   {
  2112     $avi_mod_time = @filemtime($avi_path);
  2138     $avi_mod_time = @filemtime($avi_path);
  2113     $avi_mod_time = date('r', $avi_mod_time);
  2139     $avi_mod_time = date('r', $avi_mod_time);