diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-05-17 08:20:45 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-05-17 08:20:45 -0400 |
commit | 3803cf2153091c4f319c379c3ac24cc8fc844b0a (patch) | |
tree | 11819210fbca89a8293c2cba1c0b1042cf3ddf6c /lib/common.php | |
parent | fac522f4d7cce9a35e605fac2bba0b2d23616ad0 (diff) |
upload and change avatars
code to upload and change avatars.
combined some code in the settings area, too.
darcs-hash:20080517122045-84dde-8e13994e627805f29679c9533c2f62db81dc0925.gz
Diffstat (limited to 'lib/common.php')
-rw-r--r-- | lib/common.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/common.php b/lib/common.php index f30096796..b4c2f9b6e 100644 --- a/lib/common.php +++ b/lib/common.php @@ -22,6 +22,7 @@ if (!defined('LACONICA')) { exit(1) } define('AVATAR_PROFILE_SIZE', 96); define('AVATAR_STREAM_SIZE', 48); define('AVATAR_MINI_SIZE', 24); +define('MAX_AVATAR_SIZE', 256 * 1024); # global configuration object @@ -30,6 +31,9 @@ define('AVATAR_MINI_SIZE', 24); $config = array('site' => array('name' => 'Just another µB'), + 'avatar' => + array('directory' => INSTALLDIR . 'files', + 'path' => '/files'), 'dsn' => array('phptype' => 'mysql', 'username' => 'stoica', @@ -228,6 +232,28 @@ function common_render_content($text) { return htmlspecialchars($text); } +// where should the avatar go for this user? + +function common_avatar_filename($user, $extension, $size=NULL) { + global $config; + + if ($size) { + return $user->id . '-' . $size . $extension; + } else { + return $user->id . '-original' . $extension; + } +} + +function common_avatar_path($filename) { + global $config; + return $config['avatar']['directory'] . '/' . $filename; +} + +function common_avatar_url($filename) { + global $config; + return $config['avatar']['path'] . '/' . $filename; +} + // XXX: set up gettext function _t($str) { $str } |