Skip to content

Instantly share code, notes, and snippets.

@slawkens
Last active May 25, 2023 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slawkens/ab98fad2cf0e9a4b101ed897191374c9 to your computer and use it in GitHub Desktop.
Save slawkens/ab98fad2cf0e9a4b101ed897191374c9 to your computer and use it in GitHub Desktop.
MyAAC Events Box (For tibiacom template)
<?php
/**
* Installation:
* 1) place this file into "templates/tibiacom/boxes/"
* 2) place events.png that can be found below this script, into "templates/tibiacom/images/themeboxes"
* 3) edit config.ini in tibiacom folder and add "events" into "boxes", so it looks like this:
* boxes = "highscores,newcomer,gallery,networks,poll,events"
*
* Original author: Rusherzin
* Found on: https://tibiaking.com/forums/topic/76526-widget-upcoming-events-para-tfs-12/?do=findComment&comment=429655
*/
$config['event_count'] = array(
"CTF Event" => array("Mon,Tue,Wed,Thu,Fri,Sat,Sun", "13:08"),
"Battlefield Event" => array("Tue,Wed,Thu,Fri,Sat,Sun", "16:18"),
"Zombie Event" => array("Tue,Wed,Thu,Fri,Sat,Sun", "16:50"),
"Snowball Event" => array("Tue,Wed,Thu,Fri,Sat,Sun", "17:50")
);
?>
<script>
var _0x407d=["\x66\x6C\x6F\x6F\x72","\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C","\x63\x6F\x75\x6E\x74\x64\x6F\x77\x6E","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64","\x30","\x3A","\x65\x76\x65\x6E\x74\x43\x6F\x75\x6E\x74\x28","\x2C\x20\x27","\x27\x29","\x45\x76\x65\x6E\x74\x20\x4F\x70\x65\x6E\x65\x64\x2E"];function eventCount(_0x473dx2,_0x473dx3){var _0x473dx4;var _0x473dx5=_0x473dx2- 1;var _0x473dx6=_0x473dx3;var _0x473dx7=Math[_0x407d[0]](_0x473dx5/ 60/ 60);var _0x473dx8=Math[_0x407d[0]]((_0x473dx5- _0x473dx7* 3600)/ 60);var _0x473dx9=Math[_0x407d[0]]((_0x473dx5- (_0x473dx8* 60)- (_0x473dx7* 3600)));if(_0x473dx5> 0){document[_0x407d[3]](_0x407d[2]+ _0x473dx6)[_0x407d[1]]= (_0x473dx7< 10?_0x407d[4]+ _0x473dx7:_0x473dx7)+ _0x407d[5]+ (_0x473dx8< 10?_0x407d[4]+ _0x473dx8:_0x473dx8)+ _0x407d[5]+ (_0x473dx9< 10?_0x407d[4]+ _0x473dx9:_0x473dx9);_0x473dx4= setTimeout(_0x407d[6]+ _0x473dx5+ _0x407d[7]+ _0x473dx6+ _0x407d[8],1000)}else {document[_0x407d[3]](_0x407d[2]+ _0x473dx6)[_0x407d[1]]= _0x407d[9];cleanTimeOut(_0x473dx4)}}
</script>
<div id="NetworksBox" class="Themebox" style="background-image:url(<?PHP echo $template_path;?>/images/themeboxes/events.png);">
<?php
echo '<div style="padding-top:40px;">';
foreach($config['event_count'] as $key => $datearray){
$dates = explode(",", $datearray[0]);
$datesave = array();
$i=0;
foreach($dates as $date){
if(in_array(date("D", strtotime("now")), $dates)){
if(date("H:i", strtotime("now")) > $datearray[1]){
$datesave[$i] = strtotime("next ".$date.$datearray[1])-time();
$i++;
} else{
$datesave[0] = strtotime(date("Y-m-d", time())." ".$datearray[1]) - time();
}
} else {
$datesave[$i] = strtotime("next ".$date.$datearray[1])-time();
$i++;
}
}
echo '<center><div style="font-size:14px;"><b>'.$key.'</b></div><div style="font-size:14px;" id="countdown'.$key.'"></div>';
echo "<script>eventCount(".min($datesave).",'".$key."')</script>";
}
echo '</center></div>';
?>
<div class="Bottom" style="background-image:url(<?PHP echo $template_path; ?>/images/general/box-bottom.gif);"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment