-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.php
118 lines (94 loc) · 3.64 KB
/
gen.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
112
<?php
require_once("config.php");
require($docRoot .'/Box.php');
$font = $docRoot ."/ttf/Laffayette_Comic_Pro.ttf";
$textRobin = (isset($_GET["r"]))? $_GET["r"] : "Batman...";
$textBatman =(isset($_GET["b"]))? $_GET["b"] : "Callate!";
$textRobin2 = (isset($_GET["r2"]))? $_GET["r2"] : "Pero...";
$textBatman2 =(isset($_GET["b2"]))? $_GET["b2"] : "Que te calles!!!";
$t = (isset($_GET["t"]))? $_GET["t"] : "1";
$c = (isset($_GET["c"]))? $_GET["c"] : "0";
switch($t) {
case "1" : $backgroundFile = "/img/master.png";
break;
case "2" : $backgroundFile = "/img/master2.png";
break;
}
// background plantilla
$im = imagecreatefrompng($docRoot . $backgroundFile);
if($t == "1") {
// texto 1
$box = new Box($im);
$box->setFontFace($font);
$box->setFontSize(18);
$box->setLeading(1);
$box->setBox(3, 3, 290, 120);
$box->setTextAlign('center', 'center');
$box->draw($textRobin);
// texto2
$box = new Box($im);
$box->setFontFace($font);
$box->setFontSize(18);
$box->setLeading(1);
$box->setBox(337, 3, 306, 120);
$box->setTextAlign('center', 'center');
$box->draw($textBatman);
} else if($t == "2") {
// texto Robin 1
$box = new Box($im);
$box->setFontFace($font);
$box->setFontSize(16);
$box->setLeading(1);
$box->setBox(62, 3, 264, 101);
$box->setTextAlign('center', 'center');
$box->draw($textRobin);
// texto Batman 1
$box = new Box($im);
$box->setFontFace($font);
$box->setFontSize(16);
$box->setLeading(1);
$box->setBox(334, 45, 295, 101);
$box->setTextAlign('center', 'center');
$box->draw($textBatman);
// texto Robin 2
$box = new Box($im);
$box->setFontFace($font);
$box->setFontSize(16);
$box->setLeading(1);
$box->setBox(35, 128, 277, 128);
$box->setTextAlign('center', 'center');
$box->draw($textRobin2);
// texto Batman 2
$box = new Box($im);
$box->setFontFace($font);
$box->setFontSize(16);
$box->setLeading(1);
$box->setBox(331, 170, 291, 137);
$box->setTextAlign('center', 'center');
$box->draw($textBatman2);
} // textos
// texto3
$box = new Box($im);
$box->setFontFace($docRoot ."/ttf/arial.ttf");
$box->setFontSize(10);
$box->setLeading(1);
$box->setBox(3, 617, 620, 30);
$box->setTextAlign('right', 'top');
$box->draw("generado con batSlapGenerator - www.whitecat.com.ar/demos/batslap");
$now = date("Ymdhis");
if(isset($_GET["c"]) && !isset($_GET["d"])) { // si esta seteado Compartir
header('Content-Type: application/json');
imagejpeg($im, $docRoot ."/img/gen/batslap_$now.jpg");
echo('{"url" : "'. $urlRoot .'/img/gen/batslap_'. $now .'.jpg"}');
} else if(isset($_GET["d"]) && !isset($_GET["c"])) { // si esta seteado descargar
header("Cache-control: private"); header('Pragma: private');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Disposition: attachment; filename="batslap_'. $now .'.jpg"');
imagejpeg($im, $docRoot ."/img/gen/batslap_$now.jpg");
imagejpeg($im);
} else { // si no esta seteado nada o es incompatible la combinacion : PREVIEW
header('Content-Type: image/jpeg');
imagejpeg($im);
}
imagedestroy($im);
?>