-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFakeNameGeneratorAPI.php
More file actions
129 lines (99 loc) · 4.93 KB
/
Copy pathFakeNameGeneratorAPI.php
File metadata and controls
129 lines (99 loc) · 4.93 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Created by PhpStorm.
* User: RAMS
* Date: 25.03.2019
* Time: 9:39
*/
namespace FakeNameGenerator;
class FakeNameGeneratorAPI
{
/**
* If you need just random user without any settings
*/
public function getRandom()
{
$this->CreateIdentity();
}
/**
* @param string $gender Male or female
* @param string $nameSet please use one of constants from FakeNameGeneratorNameSet class
* @param string $country please use one of constans from FakeNameGeneratorCountries class
* @return array
*/
public function CreateIdentity($gender = '', $nameSet = '', $country = '')
{
if (empty($gender) AND empty($nameSet) AND empty($country)) {
$url = "https://www.fakenamegenerator.com/";
} else {
if (empty($gender) OR empty($nameSet) OR empty($country)) {
return ['error' => true, 'msg' => 'You must Enter Gender, Name Set and country'];
}else{
$url = "https://www.fakenamegenerator.com/gen-".$gender."-".$nameSet."-".$country.".php";
}
}
if ($curl = curl_init()) {
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
$out = curl_exec($curl);
$info = curl_getinfo($curl);
curl_close($curl);
if (empty($out)) {
return ['error' => true, 'msg' => 'Empty server response', 'info'=>$info];
}
$UserIdentity = new \stdClass();
preg_match("/<h3>(.*?)</", $out, $match);
$UserIdentity->Name = trim($match[1]);
preg_match("/\"adr\">(.*?)<\//s", $out, $match);
$address = trim($match[1]);
preg_match("/(.*?)<br \/>(.*?)$/", $address, $match);
$UserIdentity->AddressLine = trim($match[1]);
$UserIdentity->AddressLine2 = trim($match[2]);
$UserIdentity->AddressFull = $UserIdentity->AddressLine . " " . $UserIdentity->AddressLine2;
preg_match("/<.dt>\\n\\s*<dd>(.*)<./", $out, $match);
$UserIdentity->MaidenName = trim($match[1]);
preg_match("/SSN<.dt><dd>(.*?)<div class=/", $out, $match);
$UserIdentity->SSN = !empty($match[1]) ? trim($match[1]) : "N/A";
preg_match("/Phone<.dt>\\n\\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->Phone = trim($match[1]);
preg_match("/Country code<.dt>\\n\\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->CountryCode = trim($match[1]);
preg_match("/Birthday<.dt>\\n\\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->Birthday = trim($match[1]);
$UserIdentity->Age = round((time() - strtotime($UserIdentity->Birthday)) / (60 * 60 * 24 * 365));
preg_match("/Email Address<.dt>\n\n\s*<dd>(.*?)<div/", $out, $match);
$UserIdentity->Email = trim($match[1]);
preg_match("/Username<.dt>\n\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->Username = trim($match[1]);
preg_match("/Password<.dt>\n\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->Password = trim($match[1]);
preg_match("/Website<.dt>\n\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->Website = trim($match[1]);
preg_match("/Browser user agent<.dt>\n\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->UserAgent = trim($match[1]);
preg_match("/Finance<\/h3>(.*?)<\/dl/s", $out, $match);
preg_match("/<dt>(.*?)<.dt>/", $match[1], $matchCardNumber);
preg_match("/<dd>(.*?)<.dd>/", $match[1], $matchCardType);
$UserIdentity->CardNumber = trim($matchCardNumber[1]);
$UserIdentity->CardType = trim($matchCardType[1]);
preg_match("/<dt>Expires<.dt>\n\s*<dd>(.*?)<\/dd>/", $out, $match);
$UserIdentity->CardExpiration = trim($match[1]);
preg_match("/<dt>Company<.dt>\n\s*<dd>(.*?)<\/dd>/", $out, $match);
$UserIdentity->Company = trim($match[1]);
preg_match("/<dt>Occupation<.dt>\n\s*<dd>(.*?)<\/dd>/", $out, $match);
$UserIdentity->Occupation = trim($match[1]);
preg_match("/<dt>Height<.dt>\n\s*<dd>(.*?)<\/dd>/", $out, $match);
$UserIdentity->Height = trim($match[1]);
preg_match("/<dt>Weight<.dt>\n\s*<dd>(.*?)<\/dd>/", $out, $match);
$UserIdentity->Weight = trim($match[1]);
preg_match("/<dt>Blood type<.dt>\n\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->BloodType = trim($match[1]);
preg_match("/<dt>Vehicle<.dt>\n\s*<dd>(.*?)<.dd>/", $out, $match);
$UserIdentity->Vehicle = trim($match[1]);
return ['error' => false, 'userIdentity' => $UserIdentity];
} else {
return ['error' => true, 'msg' => 'Cant initialize curl'];
}
}
}