-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmsg.php
50 lines (44 loc) · 1.56 KB
/
msg.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
<?PHP
include_once('/var/www/secure.php'); //outside webserver
include_once('functions.php'); //outside webserver
$q = "select * from coronavirus_msg order by id desc limit 1";
$r = $covid_db->query($q);
$d = mysqli_fetch_array($r);
$date = $d['msg_made_datetime'];
$str = str_replace('<h3>Covid19math.net Update</h3>','',$d['msg']); // remove web title
$str = str_replace('</h4>','
',$str); // line break after sub title
$str = str_replace('</div>','
',$str);
$clean = strip_tags($str);
$msg="
$clean".$date;
// GD Code Here
header('Content-Type: image/png');
$height = strlen($msg) * 1.10;
$width = '450';
$im = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
$width_rec = $width - 1;
$height_rec = $height - 1;
imagefilledrectangle($im, 0, 0, $width_rec, $height_rec, $white);
$text = $msg;
$Regular = 'fonts/OpenSans-Regular.ttf';
$BoldItalic = 'fonts/OpenSans-BoldItalic.ttf';
$title = 'Covid19math.net Update';
// https://www.php.net/manual/en/function.imagettftext.php
$font_size_title = '25';
$x = '11';
$y = '25';
imagettftext($im, $font_size_title, 0, $x, $y, $grey, $BoldItalic, $title);
imagettftext($im, $font_size_title, 0, $x-1, $y-1, $black, $BoldItalic, $title);
$x = 20; // how far from the left
$y = 30; // how far down from the top
$font_size_text = '20';
imagettftext($im, $font_size_text, 0, $x, $y, $grey, $Regular, $text);
imagettftext($im, $font_size_text, 0, $x-1, $y-1, $black, $Regular, $text);
imagepng($im);
imagedestroy($im);
?>