forked from osTicket/osTicket
-
Notifications
You must be signed in to change notification settings - Fork 2
/
avatar.php
36 lines (28 loc) · 1.06 KB
/
avatar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/*********************************************************************
avatar.php
Simple download utility for internally-generated avatars
Peter Rotich <[email protected]>
Jared Hancock <[email protected]>
Copyright (c) 2006-2014 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:
**********************************************************************/
require('client.inc.php');
if (!isset($_GET['uid']) || !isset($_GET['mode']))
Http::response(400, '`uid` and `mode` parameters are required');
require_once INCLUDE_DIR . 'class.avatar.php';
try {
$ra = new RandomAvatar($_GET['mode']);
$avatar = $ra->makeAvatar($_GET['uid'], $_GET['size']);
Http::response(200, false, 'image/png', false);
Http::cacheable($_GET['uid'], false, 86400);
imagepng($avatar, null, 1);
imagedestroy($avatar);
exit;
}
catch (InvalidArgumentException $ex) {
Http::response(422, 'No such avatar image set');
}