forked from gautamkrishnar/Be-Like-Bill
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbillgen-API.php
More file actions
66 lines (60 loc) · 2.11 KB
/
Copy pathbillgen-API.php
File metadata and controls
66 lines (60 loc) · 2.11 KB
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
<?php
/*
* Created with <3 By Gautam Krishna R
* www.github.com/gautamkrishnar
* Be like bill API
*/
header('Content-type: image/jpeg');
$text="Use:\nbillgen-API.php?default=1 :- To generate meme from \ndefault text.\n\n"
. "billgen-API.php?default=1&name=anu&sex=f :- specifies \nthe name\n"
. "and sex. Generate the input based default memes.\n\n"
. "billgen-API.php?text=your text here :- Generate meme \nusing"
. " your own text. use '%0D%0A' for newline. \n"
. "eg:billgen-API.php?text=Bill is smart%0D%0ABe like Bill";
if ( filter_input(INPUT_POST, 'default')){ $def = filter_input(INPUT_POST, 'default');}
else { $def = filter_input(INPUT_GET, 'default');}
if($def==1)
{
if ( filter_input(INPUT_POST, 'name')){$name = filter_input(INPUT_POST, 'name');}
else { $name = filter_input(INPUT_GET, 'name');}
if ( filter_input(INPUT_POST, 'sex')){$name = filter_input(INPUT_POST, 'sex');}
else { $sex = filter_input(INPUT_GET, 'sex');}
// Including result array from memelist.php file
require_once 'memelist.php';
// Randomizing results
$ran_mem=array_rand($memlist,1);
$text = $memlist[$ran_mem];
// if user inputs his name
if($name)
{
$name=ucfirst($name);
$text = preg_replace('/\bBill\b/', $name, $text);
$text = preg_replace('/\bbill\b/', $name, $text);
}
// if bill is female
if($sex=='f')
{
$text = preg_replace('/\bhis\b/', 'her', $text);
$text = preg_replace('/\bHis\b/', 'Her', $text);
$text = preg_replace('/\bhe\b/', 'she', $text);
$text = preg_replace('/\bHe\b/', 'She', $text);
$text = preg_replace('/\bhimself\b/', 'herself', $text);
$img = imagecreatefromjpeg('bill-ovl-f.jpg');
}
else
$img = imagecreatefromjpeg('bill-ovl.jpg');
}
else if(filter_input(INPUT_GET, 'text')) {
$text=filter_input(INPUT_GET, 'text');
$text=wordwrap($text,40,"\n",true);
}
else if(filter_input(INPUT_POST, 'text')) {
$text=filter_input(INPUT_POST, 'text');
$text=wordwrap($text,40,"\n",true);
}
$clr = imagecolorallocate($img, 0, 0, 0);
$font_path = 'arialbd.ttf';
imagettftext($img, 18, 0, 30, 100, $clr,$font_path, $text);
imagejpeg($img);
imagedestroy($img);
?>