-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathpicture.php
111 lines (90 loc) · 3.34 KB
/
picture.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/****************************************************************************************
* LiveZilla picture.php
*
* Copyright 2017 LiveZilla GmbH
* All rights reserved.
* LiveZilla is a registered trademark.
*
* Improper changes to this file may cause critical errors.
***************************************************************************************/
define("IN_LIVEZILLA",true);
if(!defined("LIVEZILLA_PATH"))
define("LIVEZILLA_PATH","./");
require(LIVEZILLA_PATH . "_definitions/definitions.inc.php");
require(LIVEZILLA_PATH . "_lib/functions.global.inc.php");
require(LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php");
require(LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php");
header("Content-Type: image/jpg;");
@set_error_handler("handleError");
$operator = null;
if(isset($_GET["operator"]) && Server::InitDataProvider())
{
Server::InitDataBlock(array("INTERNAL"));
$id = Operator::GetSystemId(Operator::ReadParams());
if(isset(Server::$Operators[$id]))
{
$operator = Server::$Operators[$id];
if(!isset($_GET["np"]))
{
if(!empty(Server::$Operators[$id]->WebcamPicture))
exit(base64_decode(Server::$Operators[$id]->WebcamPicture));
else if(!empty(Server::$Operators[$id]->ProfilePicture))
exit(base64_decode(Server::$Operators[$id]->ProfilePicture));
}
}
}
if(isset($_GET["g"]))
exit(IOStruct::GetFile("./images/avatar_group.png"));
if(function_exists("imagecreatetruecolor"))
{
$w=80;$h=60;
$im = imagecreatetruecolor($w, $h);
$ca = Colors::TransformHEXToRGB('#839bae');
$colbg = imagecolorallocate($im,$ca[0],$ca[1],$ca[2]);
$colfont = imagecolorallocate($im, 255, 255, 255);
$font_file = __DIR__ . "/fonts/roboto-v18-ml.ttf";
$font_size = 26;
$angle = 0;
$text='??';
if($operator != null)
{
if(!empty($operator->Color))
{
$ca = Colors::TransformHEXToRGB($operator->Color);
$colbg = imagecolorallocate($im,$ca[0],$ca[1],$ca[2]);
}
$text = $operator->Fullname;
}
else if(isset($_GET["name"]))
$text = (Communication::ReadParameter("name",""));
if(isset($_GET["ebg"]))
{
$ebg = Colors::TransformHEXToRGB(Colors::CorrectHEX(Communication::ReadParameter("ebg",""),true));
$colbg = imagecolorallocate($im,$ebg[0],$ebg[1],$ebg[2]);
}
//$text = preg_replace('/[^ \w]+/', '', $text);
$text = mb_strtoupper($text);
if(str_replace(' ','',$text)=='')
$text = '??';
$parts = explode(" ",$text);
$text = "";
$text .= mb_substr($parts[0],0,1);
if(count($parts)>1)
$text .= mb_substr($parts[count($parts)-1],0,1);
else if(mb_strlen($parts[0])>1)
$text .= mb_substr($parts[0],1,1);
//$text = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
$text = preg_replace('~^(&([a-zA-Z0-9]);)~',htmlentities('${1}'),$text);
imagefilledrectangle($im, 0, 0, $w, $h, $colbg);
$max_width=$w;
$max_height=$h;
$line_width = imagettfbbox($font_size, 0, $font_file, $text);
$x_start = ceil(($max_width - $line_width[2] - $line_width[0]) / 2);
$y_start = ceil(($max_height /2) - (($line_width[5] - $line_width[0]) / 2))-1;
imagettftext($im, $font_size, $angle ,$x_start, $y_start, $colfont, $font_file, $text);
imagepng($im);
imagedestroy($im);
}
exit(IOStruct::GetFile("./images/avatar.png"));
?>