mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-23 19:47:13 +00:00
fix: beginner's protection shown wrong date and time in profile picture
This commit is contained in:
@@ -98,7 +98,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tsdiffact = $datetime - $now;
|
$tsdiffact = $datetime - $now;
|
||||||
$timetoecho = $timeformat->getTimeFormat($tsdiffact);
|
$timetoecho = \App\Utils\DateTime::getTimeFormat($tsdiffact);
|
||||||
echo '<img src="../gpack/travian_default/img/new/tick.png" title="Ends: '.date('d.m.Y H:i',$user['protect']+3600*2).'">';
|
echo '<img src="../gpack/travian_default/img/new/tick.png" title="Ends: '.date('d.m.Y H:i',$user['protect']+3600*2).'">';
|
||||||
echo "<font color=\"blue\"> $timetoecho</font>";
|
echo "<font color=\"blue\"> $timetoecho</font>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,29 +24,6 @@ include_once ("../GameEngine/Lang/" . LANG . ".php");
|
|||||||
include_once("../GameEngine/Admin/database.php");
|
include_once("../GameEngine/Admin/database.php");
|
||||||
include_once("../GameEngine/Data/buidata.php");
|
include_once("../GameEngine/Data/buidata.php");
|
||||||
|
|
||||||
class timeFormatGenerator
|
|
||||||
{
|
|
||||||
public function getTimeFormat($time)
|
|
||||||
{
|
|
||||||
$min = 0;
|
|
||||||
$hr = 0;
|
|
||||||
$days = 0;
|
|
||||||
while ($time >= 60): $time -= 60; $min += 1; endwhile;
|
|
||||||
while ($min >= 60): $min -= 60; $hr += 1; endwhile;
|
|
||||||
while ($hr >= 24): $hr -= 24; $days +=1; endwhile;
|
|
||||||
if ($min < 10)
|
|
||||||
{
|
|
||||||
$min = "0".$min;
|
|
||||||
}
|
|
||||||
if($time < 10)
|
|
||||||
{
|
|
||||||
$time = "0".$time;
|
|
||||||
}
|
|
||||||
return $days ." day ".$hr."h ".$min."m ".$time."s";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$timeformat = new timeFormatGenerator;
|
|
||||||
|
|
||||||
include('Templates/ver.tpl');
|
include('Templates/ver.tpl');
|
||||||
include('Templates/update_latest.tpl');
|
include('Templates/update_latest.tpl');
|
||||||
$up_avl = $latest - $ver ;
|
$up_avl = $latest - $ver ;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ if($displayarray['protect'] > time()){
|
|||||||
$secondsDiff = $displayarray['protect'] - time();
|
$secondsDiff = $displayarray['protect'] - time();
|
||||||
$remainingDay = floor($secondsDiff/(3600*24));
|
$remainingDay = floor($secondsDiff/(3600*24));
|
||||||
|
|
||||||
$left = "$remainingDay days ".date("H:i:s", $secondsDiff);
|
$left = \App\Utils\DateTime::getTimeFormat($secondsDiff);
|
||||||
$profiel = preg_replace("/\[#0]/is",'<img src="'.$gpack.'img/t/tn.gif" border="0" onmouseout="med_closeDescription()" onmousemove="med_mouseMoveHandler(arguments[0],\'<table><tr><td>This player has '.$left.' hours of beginners protection left.</td></tr></table>\')">', $profiel, 1);
|
$profiel = preg_replace("/\[#0]/is",'<img src="'.$gpack.'img/t/tn.gif" border="0" onmouseout="med_closeDescription()" onmousemove="med_mouseMoveHandler(arguments[0],\'<table><tr><td>This player has '.$left.' hours of beginners protection left.</td></tr></table>\')">', $profiel, 1);
|
||||||
} else {
|
} else {
|
||||||
$geregistreerd=date('d-m-Y', ($displayarray['regtime']));
|
$geregistreerd=date('d-m-Y', ($displayarray['regtime']));
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
#################################################################################
|
||||||
|
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||||
|
## --------------------------------------------------------------------------- ##
|
||||||
|
## Project: TravianZ ##
|
||||||
|
## Filename Math.php ##
|
||||||
|
## Developed by: martinambrus ##
|
||||||
|
## License: TravianZ Project ##
|
||||||
|
## Copyright: TravianZ (c) 2010-2017. All rights reserved. ##
|
||||||
|
## URLs: https://travian.martinambrus.com ##
|
||||||
|
## Source code: https://github.com/Shadowss/TravianZ ##
|
||||||
|
## ##
|
||||||
|
#################################################################################
|
||||||
|
|
||||||
|
namespace App\Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Date and Time related helpers.
|
||||||
|
*
|
||||||
|
* @author martinambrus
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class DateTime {
|
||||||
|
|
||||||
|
public static function getTimeFormat($time)
|
||||||
|
{
|
||||||
|
$min = 0;
|
||||||
|
$hr = 0;
|
||||||
|
$days = 0;
|
||||||
|
while ($time >= 60): $time -= 60; $min += 1; endwhile;
|
||||||
|
while ($min >= 60): $min -= 60; $hr += 1; endwhile;
|
||||||
|
while ($hr >= 24): $hr -= 24; $days +=1; endwhile;
|
||||||
|
if ($min < 10)
|
||||||
|
{
|
||||||
|
$min = "0".$min;
|
||||||
|
}
|
||||||
|
if($time < 10)
|
||||||
|
{
|
||||||
|
$time = "0".$time;
|
||||||
|
}
|
||||||
|
return $days ." day ".$hr."h ".$min."m ".$time."s";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user