Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit aed2c40

Browse files
author
Samuel Janda
committed
Tidied up the registration process
1 parent 0fb9b56 commit aed2c40

File tree

5 files changed

+107
-101
lines changed

5 files changed

+107
-101
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.htaccess
2+
mail_template.html

controller/account.php

+29-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
$location->setID(intval($_GET['id']));
3737

3838
$query_id = $location->getID();
39-
$query = $writeDB->prepare("SELECT `business_name`, `auth_contact`, `avatar_mime`, `phone`, `street_address`, `suburb`, `state`, `postcode`, `email`, `checklist_select_all` FROM `accounts` WHERE id=:id");
39+
$query = $writeDB->prepare("SELECT `business_name`, `abn`, `auth_contact`, `avatar_mime`, `phone`, `street_address`, `suburb`, `state`, `postcode`, `email`, `checklist_select_all` FROM `accounts` WHERE id=:id");
4040
$query->bindParam(':id', $query_id, PDO::PARAM_STR);
4141
$query->execute();
4242

@@ -52,6 +52,7 @@
5252

5353
$row = $query->fetch(PDO::FETCH_ASSOC);
5454
$location->setName($row['business_name']);
55+
$location->setABN($row['abn']);
5556
$location->setAuthContact($row['auth_contact']);
5657
$location->setAvatar($row['avatar_mime'] !== "NULL");
5758
$location->setPhoneNumber($row['phone']);
@@ -73,6 +74,7 @@
7374

7475
$response_data = [
7576
'name' => $location->getName(),
77+
'abn' => $location->getABN(),
7678
'authContact' => $location->getAuthorisedContact(),
7779
'logo' => $location->getAvatar(),
7880
'phone' => $location->getPhoneNumber(),
@@ -201,14 +203,36 @@
201203
exit();
202204
}
203205

204-
//TODO - insert shortname generator here
206+
$shortnames = Config::ShortnameGenerator($location->getName());
207+
$query_sn = join(", ", $shortnames);
208+
$query = $writeDB->prepare("SELECT id, shortname FROM `accounts` WHERE shortname IN (:sn)");
209+
$query->bindParam(":sn", $query_sn, PDO::PARAM_STR);
210+
$query->execute();
211+
212+
$row_count = $query->rowCount();
213+
if ($row_count > 0) {
214+
$column = $query->fetchAll(PDO::FETCH_COLUMN, 1);
215+
$options = array_diff($shortnames, $column);
216+
if (count($options) === 0) {
217+
$test = $shortnames[0] . "%";
218+
$query = $writeDB->query("SELECT id, shortname FROM `accounts` WHERE shortname LIKE $test ORDER BY id DESC LIMIT 1");
219+
$n = intval(str_replace($shortnames[0], "", $query->fetch(PDO::FETCH_ASSOC)['shortname'])) + 1;
220+
$shortname = $shortnames[0] . $n;
221+
} else {
222+
$shortname = $options[0];
223+
}
224+
} else {
225+
$shortname = $shortnames[0];
226+
}
227+
$location->setShortname($shortname);
205228

206229
$passwordHash = password_hash($json_data->password, PASSWORD_DEFAULT);
207230

208231
$query_id = $location->getID();
209232
$query_abn = $location->getABN();
210233
$query_contact = $location->getAuthorisedContact();
211234
$query_avatar = $location->getAvatar();
235+
$query_shortname = $location->getShortname();
212236
$query_name = $location->getName();
213237
$query_email = $location->getEmailAddress();
214238
$query_phone = $location->getPhoneNumber();
@@ -217,14 +241,15 @@
217241
$query_address = $location->address()->getStreetAddress();
218242
$query_suburb = $location->address()->getSuburb();
219243
$query = $writeDB->prepare("INSERT INTO `accounts`
220-
(id, ABN, auth, auth_contact, avatar, business_name, email, phone, postcode, `state`, street_address, suburb) VALUES
221-
(:id, :abn, :auth, :authContact, :avatar, :business, :email, :phone, :postcode, :state, :address, :suburb)");
244+
(id, ABN, auth, auth_contact, avatar, business_name, shortname, email, phone, postcode, `state`, street_address, suburb) VALUES
245+
(:id, :abn, :auth, :authContact, :avatar, :business, :sn, :email, :phone, :postcode, :state, :address, :suburb)");
222246
$query->bindParam(':id', $query_id, PDO::PARAM_STR);
223247
$query->bindParam(':abn', $query_abn, PDO::PARAM_STR);
224248
$query->bindParam(':auth', $passwordHash, PDO::PARAM_STR);
225249
$query->bindParam(':authContact', $query_contact, PDO::PARAM_STR);
226250
$query->bindParam(':avatar', $query_avatar, PDO::PARAM_STR);
227251
$query->bindParam(':business', $query_name, PDO::PARAM_STR);
252+
$query->bindParam(':sn', $query_shortname, PDO::PARAM_STR);
228253
$query->bindParam(':email', $query_email, PDO::PARAM_STR);
229254
$query->bindParam(':phone', $query_phone, PDO::PARAM_STR);
230255
$query->bindParam(':postcode', $query_postcode, PDO::PARAM_STR);

controller/register_mail.php

+38-91
Original file line numberDiff line numberDiff line change
@@ -3,105 +3,52 @@
33
$subject = "CovidVault registration details for $query_name";
44
55
$headers = 'MIME-Version: 1.0' . "\r\n";
6-
$headers .= 'Content-type: text/html; charset=unicode' . "\r\n";
6+
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
77
$headers .= 'From: '.$from."\r\n".
88
'Reply-To: '.$from."\r\n" .
99
'X-Mailer: PHP/' . phpversion();
1010
$content = <<<CONTENT
1111
<html>
1212
<head>
13+
<style type="text/css">
14+
body {
15+
margin: 1rem;
16+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
17+
}
18+
</style>
1319
</head>
14-
<body lang=EN-AU link="#0563C1" vlink="#954F72" style='tab-interval:36.0pt'>
15-
<div class=WordSection1>
16-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
17-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Hello {$query_contact},</span></p>
18-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
19-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
20-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
21-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Thank you
22-
for using CovidVault for the storage of your patron data for the purposes of
23-
contact tracing.</span></p>
24-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
25-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
26-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
27-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>You are
28-
now ready to go!</span></p>
29-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
30-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
31-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
32-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>You will
33-
receive your business’ short URL (eg: <a href="http://b.link/SPAU">http://b.link/SPAU</a>)
34-
within the next 24 hours. In the meantime, your customers can start using your
35-
QR code to submit their contact details.</span></p>
36-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
37-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
38-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
39-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Please
40-
ensure the details below are accurate:</span></p>
41-
<p class=MsoNormal><b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
42-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Account
43-
ID: </span></b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
44-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>{$query_id}</span><br />
45-
<b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
46-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Business
47-
Name: </span></b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
48-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>{$query_name}</span><br />
49-
<b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
50-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Business
51-
Address: </span></b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
52-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>{$location->address()->getStreetAddress()}, {$location->address()->getSuburb()}, {$location->address()->getState()}, {$location->address()->getPostcode()}.</span><br />
53-
<b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
54-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Authorised
55-
Contact: </span></b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
56-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>{$query_contact}</span><br />
57-
<b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
58-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Contact
59-
Number: </span></b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
60-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>{$query_phone}</span></p>
61-
<p class=MsoNormal><b><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
62-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>{$query_name} QR Code:</span></b><br />
63-
<span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
64-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'><img src="http://chart.googleapis.com/chart?cht=qr&chs=300x300&chld=M&chl=https://www.simpleprogramming.com.au/covid/?id=' . $query_id" alt="QR Code" /></span></p>
65-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
66-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>You can add this QR code to the template document available <a href="https://www.simpleprogramming.com.au/covid/templates/Template-Scan.docx">here</a> for your customers to scan upon arriving at your venue.</span></p>
67-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
68-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>If you
69-
have a data request (or any questions), you are welcome to contact me via
70-
either of the following methods:</span></p>
71-
<ul style='margin-top:0cm' type=disc>
72-
<li class=MsoListParagraph style='color:#7F7F7F;mso-themecolor:text1;
73-
mso-themetint:128;margin-left:0cm;mso-list:l0 level1 lfo3'><span
74-
style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:VIC'>Email: <a
75-
76-
or</span></li>
77-
<li class=MsoListParagraph style='color:#7F7F7F;mso-themecolor:text1;
78-
mso-themetint:128;margin-left:0cm;mso-list:l0 level1 lfo3'><span
79-
style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-family:VIC'>Phone:
80-
0417-227-152</span></li>
20+
<body>
21+
<p>Hello {$query_contact},</p>
22+
<p>Thank you for using <a href="https://www.covidvault.com.au/">CovidVault</a> for the storage of your patron data for the purposes of contact tracing.</p>
23+
<p>You are now ready to go!</p>
24+
<p>Please ensure the details below are accurate:
25+
<ul>
26+
<li><b>Account ID</b>: {$query_id}</li>
27+
<li><b>Business Name</b>: {$query_name}</li>
28+
<li><b>Business Address</b>: {$location->address()->getStreetAddress()}, {$location->address()->getSuburb()}, {$location->address()->getState()}, {$location->address()->getPostcode()}</li>
29+
<li><b>Authorised Contact</b>: {$query_contact}</li>
30+
<li><b>Contact Number</b>: {$query_phone}</li>
8131
</ul>
82-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
83-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
84-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
85-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>A
86-
business owner portal where you will be able to access customer details for
87-
contact tracing without external assistance will be implemented in the near
88-
future. Due to the sensitive nature of the data being stored, the level of
89-
security must be sufficient prior to releasing such a system.</span></p>
90-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
91-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
92-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
93-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Cheers</span></p>
94-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
95-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
96-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
97-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'></span></p>
98-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
99-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'>Sam</span></p>
100-
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:11.0pt;
101-
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;color:#7F7F7F;mso-themecolor:text1;mso-themetint:128'><a
102-
href="https://www.simpleprogramming.com.au/">Simple Programming</a> is proudly
103-
made in North Melbourne, Australia.</span></p>
104-
</div>
32+
</p>
33+
<p>Visitors will now be able to sign in using either the QR Code or the shortlink below.<br />
34+
{$query_name} QR Code:<br />
35+
<img src="http://chart.googleapis.com/chart?cht=qr&chs=300x300&chld=M&chl=https://www.covidvault.com.au/checkin/?id={$query_id}" />
36+
</p>
37+
<p>{$query_name} short URL:<br />
38+
covidvault.com.au/{$query_shortname}</p>
39+
<p>If you have a check-in kiosk set up at your entrance with a tablet device, use the following URL to enable kiosk mode:
40+
<a href="https://www.covidvault.com.au/checkin/?id={$query_id}&kiosk">https://www.covidvault.com.au/checkin/?id={$query_id}&kiosk</a></p>
41+
<p>To update your account details, please sign in to the <a href="https://www.covidvault.com.au/dashboard">account dashboard</a>.</p>
42+
<p>If you have a data request (or any questions), you are welcome to contact me via either of the following methods:
43+
<ul>
44+
<li>Email: <a href="mailto: [email protected]">[email protected]</a> or</li>
45+
<li>Phone: <a href="tel:+61390133909">+613 9013 3909</a></li>
46+
</ul>
47+
</p>
48+
<p>CovidVault is free for up to 3,000 API calls per month per business and charged at 0.1 cents per each API call thereafter. Payment details will only be requested upon reaching the requisite usage in a given month. This ensures the application can be sufficiently tested prior to any payment. If you have any questions, please do not hesitate to contact me on the details above.</p>
49+
<p>Kind regards, <br /></p>
50+
<p>Sam<br />
51+
Simple Programming is proudly made in North Melbourne, Australia.</p>
10552
</body>
10653
</html>
10754
CONTENT;

model/Config.php

+27-5
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,40 @@ public static function ValidatePhoneNumber(string $pn):bool {
2424
public static function RegisterAPIAccess(int $id, string $endpoint) {
2525
require_once("DB.php");
2626
$writeDB = DB::connectWriteDB();
27-
$query = $writeDB->prepare("INSERT INTO `actions`(`account_id`,`endpoint`) VALUES (:id, :e)");
27+
$ip = self::GetIPAddress();
28+
$query = $writeDB->prepare("INSERT INTO `actions`(`account_id`, `endpoint`, `ip_address`) VALUES (:id, :e, :ip)");
2829
$query->bindParam(':id', $id, PDO::PARAM_STR);
2930
$query->bindParam(':e', $endpoint, PDO::PARAM_STR);
31+
$query->bindParam(':ip', $ip, PDO::PARAM_STR);
3032
$query->execute();
3133
}
3234

3335
public static function ShortnameGenerator(string $name) {
34-
$name_arr = array_fill(0, 5, $name);
35-
$patterns = ['/[A-Z]/', '/[A-Z][^aeiou]?/', '/[A-Z][^aeiou]*/', '/[A-Z][a-z]/', '/[A-Z][aeiouAEIOU]?/'];
36-
$replace = ['$0$1$2$3$4$5'];
37-
return preg_replace($patterns, $replace, $name_arr);
36+
$name_arr = [];
37+
preg_match_all('/[A-Z]/', $name, $matches);
38+
$name_arr[] = implode($matches[0]);
39+
preg_match_all('/[A-Z][^aeiou]?/', $name, $matches);
40+
$name_arr[] = implode($matches[0]);
41+
preg_match_all('/[A-Z]/', $name, $matches, PREG_PATTERN_ORDER, 2);
42+
$name_arr[] = substr($name, 0, 2) . implode($matches[0]);
43+
preg_match_all('/[A-Z][a-z]/', $name, $matches);
44+
$name_arr[] = implode($matches[0]);
45+
return $name_arr;
3846
}
47+
48+
private static function GetIPAddress() {
49+
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key){
50+
if (array_key_exists($key, $_SERVER) === true){
51+
foreach (explode(',', $_SERVER[$key]) as $ip){
52+
$ip = trim($ip); // just to be safe
53+
54+
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false){
55+
return $ip;
56+
}
57+
}
58+
}
59+
}
60+
}
3961
}
4062

4163
class APIException extends Error {}

0 commit comments

Comments
 (0)