diff --git a/codepot/src/codepot/controllers/user.php b/codepot/src/codepot/controllers/user.php index e958099a..cbf6f850 100644 --- a/codepot/src/codepot/controllers/user.php +++ b/codepot/src/codepot/controllers/user.php @@ -235,6 +235,65 @@ class User extends Controller $this->load->view ($this->VIEW_SETTINGS, $data); } } + + function icon ($userid = '') + { + // TODO: ETag, If-None-Match??? + $userid_len = strlen($userid); + if ($userid_len > 0) + { + $userid = $this->converter->HexToAscii ($userid); + $userid_len = strlen($userid); + } + + if ($userid_len > 0) + { + $icon_path = CODEPOT_USERICON_DIR . '/' . $userid . '.png'; + $icon_size = @filesize ($icon_path); + if (@file_exists($icon_path) === TRUE && + ($icon_size = @filesize($icon_path)) !== FALSE && + @getimagesize($icon_path) !== FALSE) + { + header ("Content-Type: image/png"); + header ("Content-Length: $icon_size"); + @readfile ($icon_path); + return $icon_size; + } + } + + $img = imagecreate (50, 50); + + $bgcolor = imagecolorallocate($img, 250, 255, 250); + imagefill ($img, 0, 0, $bgcolor); + + if ($userid_len > 0) + { + $fgcolor = imagecolorallocate($img, 0, 0, 0); + $font_size = 4; + $font_width = imagefontwidth(5); + $font_height = imagefontheight(5); + $img_width = imagesx($img); + $y = 2; + $k = 1; + for ($i = 0; $i < $userid_len; $i++) + { + $x = $k * $font_width; + if ($x > $img_width - $font_width) + { + $k = 1; + $y += $font_height + 2; + $x = $k * $font_width; + } + + $k++; + imagechar ($img, $font_size, $x, $y, $userid[$i], $fgcolor); + } + } + + header ("Content-Type: image/png"); + imagepng ($img); + imagedestroy ($img); + } } ?> diff --git a/codepot/src/codepot/helpers/codepot_helper.php b/codepot/src/codepot/helpers/codepot_helper.php index 045caa20..c3dac77a 100644 --- a/codepot/src/codepot/helpers/codepot_helper.php +++ b/codepot/src/codepot/helpers/codepot_helper.php @@ -15,3 +15,15 @@ if ( ! function_exists('base_url_make')) } } +if ( ! function_exists('codepot_merge_path')) +{ + function codepot_merge_path($base, $path) + { + if (substr($base, -1) == '/') + { + for ($i = 0; substr($path, $i, 1) == '/'; $i++); + return $base . substr($path, $i); + } + else return $base . $path; + } +} diff --git a/codepot/src/codepot/views/code_diff.php b/codepot/src/codepot/views/code_diff.php index 63c32033..a459443b 100644 --- a/codepot/src/codepot/views/code_diff.php +++ b/codepot/src/codepot/views/code_diff.php @@ -308,11 +308,11 @@ if (FALSE) // don't want to delete code for the original diff view. else { $http_user_agent = $_SERVER['HTTP_USER_AGENT']; - $is_msie = (stristr($http_user_agent, 'MSIE') != FALSE && - stristr($http_user_agent, 'Opera') == FALSE); + $is_msie = (stristr($http_user_agent, 'MSIE') !== FALSE && + stristr($http_user_agent, 'Opera') === FALSE); if (!$is_msie) { - $is_msie = (preg_match ("/^Mozilla.+\(Windows.+\) like Gecko$/", $http_user_agent) != FALSE); + $is_msie = (preg_match ("/^Mozilla.+\(Windows.+\) like Gecko$/", $http_user_agent) !== FALSE); } print '