PATH:
home
/
centosnipponia
/
public_html
/
ticketing.nipponia.com
/
include
<?php /********************************************************************* class.avatar.php Avatar sources for users and agents Jared Hancock <jared@osticket.com> Peter Rotich <peter@osticket.com> Copyright (c) 2006-2015 osTicket http://www.osticket.com Released under the GNU General Public License WITHOUT ANY WARRANTY. See LICENSE.TXT for details. vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ abstract class Avatar { var $user; function __construct($user) { $this->user = $user; } abstract function getUrl($size); function getImageTag($size=null) { $style = ($size) ? sprintf('style="max-height:%spx"', $size) : ''; return "<img {$style} class=\"avatar\" alt=\"" .__('Avatar').'" src="'.$this->getUrl($size).'" />'; } function __toString() { return $this->getImageTag(); } function isChangeable() { return false; } function toggle() {} } abstract class AvatarSource { static $id; static $name; var $mode; function __construct($mode=null) { if (isset($mode)) $this->mode = $mode; } static function getName() { return __(static::$name); } abstract function getAvatar($user); static $registry = array(); static function register($class) { if (!class_exists($class)) throw new Exception($class.': Does not exist'); if (!isset($class::$id)) throw new Exception($class.': AvatarClass must specify $id'); static::$registry[$class::$id] = $class; } static function lookup($id, $mode=null) { $class = static::$registry[$id]; if (!isset($class)) ; // TODO: Return built-in avatar source if (is_string($class)) $class = static::$registry[$id] = new $class($mode); return $class; } static function allSources() { return static::$registry; } static function getModes() { return null; } } class LocalAvatarSource extends AvatarSource { static $id = 'local'; static $name = /* @trans */ 'Built-In'; var $mode = 'ateam'; static function getModes() { return array( 'ateam' => __("Oscar's A-Team"), ); } function getAvatar($user) { return new LocalAvatar($user, $this->mode); } } AvatarSource::register('LocalAvatarSource'); class LocalAvatar extends Avatar { var $mode; var $code; var $size; function __construct($user, $mode) { parent::__construct($user); $this->mode = $mode; } function setSize($size) { $this->size = $size; } function getUrl($size) { $code = $this->code; if (!$code && method_exists($this->user, 'getExtraAttr')) $code = $this->user->getExtraAttr('avatar'); if ($code) $uid = md5($code); else // Generate a random string of 0-6 chars for the avatar signature $uid = md5(strtolower($this->user->getEmail())); $args = array('uid'=>$uid, 'mode' => $this->mode); if ($this->size) $args['size'] = $this->size; return ROOT_PATH . 'avatar.php?' . Http::build_query($args); } function toggle() { $this->code = Misc::randCode(21); return $this->code; } function isChangeable() { return true; } } class RandomAvatar { var $mode; static $sprites = array( 'ateam' => array( 'file' => 'images/avatar-sprite-ateam.png', 'grid' => 96, ), ); function __construct($mode) { $this->mode = $mode; } function makeAvatar($uid, $size=null) { $sprite = self::$sprites[$this->mode]; if (!$sprite || !is_readable(ROOT_DIR . $sprite['file']) || !extension_loaded('gd')) Http::redirect(ROOT_PATH.'images/mystery-oscar.png'); $source = imagecreatefrompng(ROOT_DIR . $sprite['file']); $grid = $sprite['grid']; $avatar = imagecreatetruecolor($grid, $grid); $width = imagesx($source) / $grid; $height = imagesy($source) / $grid; // Start with a white matte $white = imagecolorallocate($avatar, 255, 255, 255); imagefill($avatar, 0, 0, $white); for ($i=0, $k=$height; $i<$k; $i++) { $idx = hexdec($uid[$i]) % $width; imagecopy($avatar, $source, 0, 0, $idx*$grid, $i*$grid, $grid, $grid); } // Resize the avatar (if applicable) if ($size) { $avatar = imagescale($avatar, $size, $size); } return $avatar; } } class AvatarsByGravatar extends AvatarSource { static $name = 'Gravatar'; static $id = 'gravatar'; var $mode; function __construct($mode=null) { $this->mode = $mode ?: 'retro'; } static function getModes() { return array( 'mm' => __('Mystery Man'), 'identicon' => 'Identicon', 'monsterid' => 'Monster', 'wavatar' => 'Wavatar', 'retro' => 'Retro', ); } function getAvatar($user) { return new Gravatar($user, $this->mode); } } AvatarSource::register('AvatarsByGravatar'); class Gravatar extends Avatar { var $email; var $d; var $size; function __construct($user, $imageset) { $this->email = $user->getEmail(); $this->d = $imageset; } function setSize($size) { $this->size = $size; } /** * Get either a Gravatar URL or complete image tag for a specified email address. * * @param string $email The email address * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] * @param boole $img True to return a complete IMG tag False for just the URL * @param array $atts Optional, additional key/value attributes to include in the IMG tag * @return String containing either just a URL or a complete image tag * @source http://gravatar.com/site/implement/images/php/ */ function getUrl($size=null) { $size = $this->size ?: 80; $url = '//www.gravatar.com/avatar/'; $url .= md5( strtolower( $this->email ) ); $url .= "?s=$size&d={$this->d}"; return $url; } }
[+]
..
[-] class.model.php
[edit]
[-] ajax.i18n.php
[edit]
[-] class.json.php
[edit]
[-] class.mime.php
[edit]
[-] class.orm.php
[edit]
[-] class.dept.php
[edit]
[-] ajax.filter.php
[edit]
[-] api.tickets.php
[edit]
[-] ajax.note.php
[edit]
[-] class.2fa.php
[edit]
[-] class.setup.php
[edit]
[-] ajax.orgs.php
[edit]
[-] class.format.php
[edit]
[-] class.message.php
[edit]
[-] class.xml.php
[edit]
[-] class.priority.php
[edit]
[-] class.app.php
[edit]
[-] index.php
[edit]
[-] ajax.forms.php
[edit]
[-] ajax.config.php
[edit]
[-] ajax.tickets.php
[edit]
[-] ajax.content.php
[edit]
[-] class.file.php
[edit]
[-] ajax.email.php
[edit]
[-] class.cli.php
[edit]
[-] class.company.php
[edit]
[-] class.mailer.php
[edit]
[-] class.list.php
[edit]
[-] class.canned.php
[edit]
[-] class.client.php
[edit]
[+]
upgrader
[-] class.csrf.php
[edit]
[-] ost-sampleconfig.php
[edit]
[-] class.http.php
[edit]
[-] ajax.staff.php
[edit]
[-] class.search.php
[edit]
[-] JSON.php
[edit]
[-] class.avatar.php.bak
[edit]
[-] class.error.php
[edit]
[-] class.mail.php
[edit]
[-] class.sla.php
[edit]
[-] class.draft.php
[edit]
[-] class.dispatcher.php
[edit]
[-] class.note.php
[edit]
[-] class.mailparse.php
[edit]
[-] class.filter_action.php
[edit]
[-] class.queue.php
[edit]
[-] class.i18n.php
[edit]
[-] class.osticket.php
[edit]
[-] ajax.users.php
[edit]
[-] class.staff.php
[edit]
[+]
fpdf
[-] class.crypto.php
[edit]
[+]
laminas-mail
[-] class.misc.php
[edit]
[-] class.auth.php
[edit]
[-] html2text.php
[edit]
[-] class.translation.php
[edit]
[-] class.util.php
[edit]
[-] class.schedule.php
[edit]
[-] class.banlist.php
[edit]
[-] class.config.php
[edit]
[-] ajax.upgrader.php
[edit]
[+]
mpdf
[-] class.email.php
[edit]
[-] ajax.admin.php
[edit]
[+]
config
[-] ajax.thread.php
[edit]
[-] class.user.php
[edit]
[-] class.passwd.php
[edit]
[-] class.import.php
[edit]
[+]
client
[-] ajax.tips.php
[edit]
[-] tnef_decoder.php
[edit]
[-] class.oauth2.php
[edit]
[-] class.plugin.php
[edit]
[-] class.timezone.php
[edit]
[-] class.ticket.php
[edit]
[-] class.nav.php
[edit]
[-] class.category.php
[edit]
[-] class.charset.php
[edit]
[+]
cli
[-] class.cron.php
[edit]
[-] class.captcha.php
[edit]
[-] class.dynamic_forms.php
[edit]
[-] class.faq.php
[edit]
[+]
plugins
[-] class.pdf.php
[edit]
[-] ajax.schedule.php
[edit]
[-] class.usersession.php
[edit]
[-] class.topic.php
[edit]
[-] class.base32.php
[edit]
[-] htmLawed.php
[edit]
[-] ajax.sequence.php
[edit]
[+]
i18n
[-] class.signal.php
[edit]
[-] class.mailfetch.php
[edit]
[-] UniversalClassLoader.php
[edit]
[-] class.sequence.php
[edit]
[-] class.businesshours.php
[edit]
[-] class.role.php
[edit]
[+]
pear
[-] class.yaml.php
[edit]
[-] Spyc.php
[edit]
[-] mysqli.php
[edit]
[-] class.thread_actions.php
[edit]
[-] class.export.php
[edit]
[-] ajax.plugins.php
[edit]
[-] class.collaborator.php
[edit]
[-] class.ostsession.php
[edit]
[+]
staff
[-] class.attachment.php
[edit]
[-] class.template.php
[edit]
[-] class.filter.php
[edit]
[-] class.controller.php
[edit]
[-] class.team.php
[edit]
[-] class.session.php
[edit]
[-] class.avatar.php
[edit]
[-] ajax.kbase.php
[edit]
[-] class.variable.php
[edit]
[-] class.validator.php
[edit]
[-] ajax.tasks.php
[edit]
[-] class.upgrader.php
[edit]
[-] class.page.php
[edit]
[-] ajax.export.php
[edit]
[-] ajax.search.php
[edit]
[-] PasswordHash.php
[edit]
[-] class.report.php
[edit]
[-] class.forms.php
[edit]
[-] class.task.php
[edit]
[-] class.migrater.php
[edit]
[-] class.lock.php
[edit]
[-] class.organization.php
[edit]
[-] class.pagenate.php
[edit]
[-] api.cron.php
[edit]
[-] class.api.php
[edit]
[-] class.thread.php
[edit]
[-] class.knowledgebase.php
[edit]
[-] .MANIFEST
[edit]
[-] class.log.php
[edit]
[-] ajax.draft.php
[edit]
[-] class.ajax.php
[edit]
[-] ost-config.php
[edit]
[-] txets.php
[edit]
[-] .htaccess.disabled
[edit]