blob: c3a962067db3b9b39b36175bb9062fcafd41d9c2 [file] [log] [blame]
matheusfillipeabd513e2021-05-11 03:29:11 -03001<?php
2function generateRandomString($length = 96) {
3 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
4 $charactersLength = strlen($characters);
5 $randomString = '';
6 for ($i = 0; $i < $length; $i++) {
7 $randomString .= $characters[rand(0, $charactersLength - 1)];
8 }
9 return $randomString;
10}
11
12function getClientIP():string
13{
14 $keys=array('HTTP_CLIENT_IP','HTTP_X_FORWARDED_FOR','HTTP_X_FORWARDED','HTTP_FORWARDED_FOR','HTTP_FORWARDED','REMOTE_ADDR');
15 foreach($keys as $k)
16 {
17 if (!empty($_SERVER[$k]) && filter_var($_SERVER[$k], FILTER_VALIDATE_IP))
18 {
19 return $_SERVER[$k];
20 }
21 }
22 return false;
23}
24?>