v26.6.0 updates

This commit is contained in:
Thilina Hasantha
2019-07-26 03:53:24 +02:00
parent c3344b99fa
commit fd99ea299e
195 changed files with 18838 additions and 2639 deletions

View File

@@ -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;
}
}

View 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;
}
}