v26.6.0 updates
This commit is contained in:
@@ -65,11 +65,28 @@ class CalendarTools
|
||||
return $time->format($format);
|
||||
}
|
||||
|
||||
public static function getNumberOfDaysBetweenDates($first, $second)
|
||||
public static function getNumberOfDaysBetweenDates($later, $earlier)
|
||||
{
|
||||
$timeFirst = new \DateTime($first);
|
||||
$timeSecond = new \DateTime($second);
|
||||
$timeFirst = new \DateTime($later);
|
||||
$timeSecond = new \DateTime($earlier);
|
||||
$interval = $timeSecond->diff($timeFirst);
|
||||
return intval($interval->format('%a'));
|
||||
return intval($interval->format('%a')) + 1;
|
||||
}
|
||||
|
||||
public static function getNumberOfMonthsBetweenDates($date1, $date2)
|
||||
{
|
||||
$begin = new \DateTime($date1);
|
||||
$end = new \DateTime($date2);
|
||||
$end = $end->modify('+1 day');
|
||||
|
||||
$interval = \DateInterval::createFromDateString('1 month');
|
||||
|
||||
$period = new \DatePeriod($begin, $interval, $end);
|
||||
$counter = 0;
|
||||
foreach ($period as $dt) {
|
||||
$counter++;
|
||||
}
|
||||
|
||||
return $counter;
|
||||
}
|
||||
}
|
||||
|
||||
26
core/src/Utils/NetworkUtils.php
Normal file
26
core/src/Utils/NetworkUtils.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Utils;
|
||||
|
||||
class NetworkUtils
|
||||
{
|
||||
public static function getClientIp()
|
||||
{
|
||||
$ipaddress = '';
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP']))
|
||||
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
|
||||
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
|
||||
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
else if(isset($_SERVER['HTTP_X_FORWARDED']))
|
||||
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
|
||||
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
|
||||
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
|
||||
else if(isset($_SERVER['HTTP_FORWARDED']))
|
||||
$ipaddress = $_SERVER['HTTP_FORWARDED'];
|
||||
else if(isset($_SERVER['REMOTE_ADDR']))
|
||||
$ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
else
|
||||
$ipaddress = 'UNKNOWN';
|
||||
return $ipaddress;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user