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 '
'; diff --git a/codepot/src/codepot/views/code_history.php b/codepot/src/codepot/views/code_history.php index e2f0c1e4..cd6d3533 100644 --- a/codepot/src/codepot/views/code_history.php +++ b/codepot/src/codepot/views/code_history.php @@ -83,10 +83,10 @@ $this->load->view ( converter->AsciiToHex (($fullpath == '')? '.': $fullpath); - $graph_url = site_url() . "/code/graph/commits-by-users/{$project->id}/{$xfullpath}"; + $graph_url = codepot_merge_path (site_url(), "/code/graph/commits-by-users/{$project->id}/{$xfullpath}"); print ""; - $graph_url = site_url() . "/code/graph/commit-share-by-users/{$project->id}/{$xfullpath}"; + $graph_url = codepot_merge_path (site_url(), "/code/graph/commit-share-by-users/{$project->id}/{$xfullpath}"); print ""; ?> diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index 479f9466..dd7a4857 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -98,6 +98,7 @@ $this->load->view ( $m = $members[$i]; if ($m == '') continue; + /* $icon_src = ''; if (array_key_exists($m, $icons)) { @@ -115,6 +116,9 @@ $this->load->view ( } print "
  • {$icon_src}{$m}
  • "; + */ + $user_icon_url = codepot_merge_path (site_url(), '/user/icon/' . $this->converter->AsciiToHex($m)); + print "
  • {$m}
  • "; } ?> diff --git a/codepot/src/codepot/views/taskbar.php b/codepot/src/codepot/views/taskbar.php index d8fd6f16..42e0e6a4 100644 --- a/codepot/src/codepot/views/taskbar.php +++ b/codepot/src/codepot/views/taskbar.php @@ -11,6 +11,7 @@ function show_taskbar ($con, $login) $title = (isset($login['email']) && $login['email'] != '')? ('title=' . htmlspecialchars($login['email'])): ''; + /* // attempt to load the user icon regardless of its upload state. // if it has not been uploaded, it won't be found. // check a file system may be faster than checking the database. @@ -26,6 +27,9 @@ function show_taskbar ($con, $login) ); } print $icon_src; + */ + $user_icon_url = codepot_merge_path (site_url(), '/user/icon/' . $con->converter->AsciiToHex($login['id'])); + print ""; print anchor ('user/home', htmlspecialchars($login['id']), $title); diff --git a/codepot/src/css/common.css b/codepot/src/css/common.css index ddde706b..3b2a4061 100644 --- a/codepot/src/css/common.css +++ b/codepot/src/css/common.css @@ -68,6 +68,7 @@ body { .content .taskbar .boxb .user_icon_img { height: 2em; /* as large as line-height of taskbar */ + width: auto; vertical-align: middle; } @@ -493,9 +494,11 @@ pre.prettyprint li.L9 { background: #eee } .content .sidebar .box .user_icon_img { height: 2em; + width: auto; vertical-align: middle; padding-top: 1px; padding-bottom: 1px; + padding-right: 1px; } .content .sidebar .boxtitle {