-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloremipsum.php
More file actions
80 lines (71 loc) · 1.72 KB
/
loremipsum.php
File metadata and controls
80 lines (71 loc) · 1.72 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
class lorem {
const api_url = 'http://www.randomtext.me/api/lorem/';
function request($url) {
$object = curl_init();
curl_setopt($object, CURLOPT_URL, $url);
curl_setopt($object, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($object);
curl_close($object);
$text = json_decode($resp, true);
return $text['text_out'];
}
function url($mode, $n, $min, $max) {
$base = "http://www.randomtext.me/api/lorem/mode-n/min-max";
$search = array("mode", "-n", "min", "max");
if($mode == "h") {
$number = $n;
}
else {
$number = "-" . $n;
}
$replace = array($mode, $number, $min, $max);
$url = str_replace($search, $replace, $base);
return $url;
}
function p($n, $min, $max, $tags = true) {
$url = $this->url('p', $n, $min, $max);
$out = $this->request($url);
if($tags == false) {
$stripped = strip_tags($out);
return $stripped;
}
else {
return $out;
}
}
function ul($n, $min, $max, $tags = true) {
$url = $this->url('ul', $n, $min, $max);
$out = $this->request($url);
if($tags == false) {
$stripped = strip_tags($out);
return $stripped;
}
else {
return $out;
}
}
function ol($n, $min, $max, $tags = true) {
$url = $this->url('ol', $n, $min, $max);
$out = $this->request($url);
if($tags == false) {
$stripped = strip_tags($out);
return $stripped;
}
else {
return $out;
}
}
function h($i, $min, $max, $tags = false) {
$url = $this->url('h', $i, $min, $max);
$out = $this->request($url);
if($tags == false) {
$stripped = strip_tags($out);
return $stripped;
}
else {
return $out;
}
}
}
?>