PluginProbe
The Innovative Form Builder – IvyForms / 0.3
The Innovative Form Builder – IvyForms v0.3
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Repository / Entry / EntryRequestHelper.php

EntryRequestHelper.php in The Innovative Form Builder – IvyForms 0.3, at backend/src/Repository/Entry/EntryRequestHelper.php

62 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Repository\Entry;
4
5 class EntryRequestHelper
6 {
7 /**
8 * Get the client IP address.
9 *
10 * @return string|null
11 */
12 public static function getClientIpAddress(): ?string
13 {
14 $ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
15 return $ip ?: null;
16 }
17
18 /**
19 * Get the user agent string.
20 *
21 * @return string
22 */
23 public static function getUserAgent(): string
24 {
25 $userAgent = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT');
26 return $userAgent ?: '';
27 }
28
29 /**
30 * Get the source URL.
31 *
32 * @return string|null
33 */
34 public static function getSourceURL(): ?string
35 {
36 $sourceURL = filter_input(INPUT_SERVER, 'HTTP_REFERER');
37 return $sourceURL ?: '';
38 }
39
40 /**
41 * Get the browser name from the user agent string.
42 *
43 * @param string $userAgent
44 * @return string
45 */
46 public static function getBrowserName(string $userAgent): string
47 {
48 if (str_contains($userAgent, 'Firefox')) {
49 return 'Mozilla Firefox';
50 } elseif (str_contains($userAgent, 'Chrome') && !str_contains($userAgent, 'Edg')) {
51 return 'Google Chrome';
52 } elseif (str_contains($userAgent, 'Safari') && !str_contains($userAgent, 'Chrome')) {
53 return 'Apple Safari';
54 } elseif (str_contains($userAgent, 'Edg')) {
55 return 'Microsoft Edge';
56 } elseif (str_contains($userAgent, 'MSIE') || str_contains($userAgent, 'Trident')) {
57 return 'Internet Explorer';
58 }
59 return 'Unknown';
60 }
61 }
62