Mal eine Frage: Ich nutze das Plugin und mein Forum hat morgen sechsjährigen Geburtstag. Durch die ungenaue Berechnung war das 6te Jahr schon vor einigen Tagen eingetreten, was nicht schlimm ist, allerdings steht da 5 Jahre, 12 Monate und 4 Tage. Wie kann man erreichen, dass das Plugin auf 6 Jahre springt?
Code:
<?php
//Test myBB
if(!defined("IN_MYBB"))
{
die("Acest fisier nu poate fi accesat direct.");
}
//Our hook
$plugins->add_hook("index_start", "forumage_start");
//Plugin information
function forumage_info()
{
return array(
"name" => "Forum Age",
"description" => "shows how old your forum is.",
"website" => "http://nasyr.net/",
"author" => "Nasyr",
"authorsite" => "http://nasyr.net/",
"version" => "1.0",
"guid" => "",
'compatibility' => '18*',
);
}
//Activate plugin
function forumage_activate()
{
global $db;
$grup_de_setari = array(
"gid" => NULL,
"name" => "fa_hsc",
"title" => "Forum Age",
"description" => "What is your forum age?",
"disporder" => "35",
"isdefault" => "no"
);
$db->insert_query("settinggroups", $grup_de_setari);
$gid = $db->insert_id();
$setare_1 = array(
"sid" => NULL,
"name" => "fa_enabled",
"title" => "Is enabled?",
"description" => "Can this plugin do his job?",
"optionscode" => "yesno",
"value" => "no",
"disporder" => "1",
"gid" => intval($gid)
);
$setare_2 = array(
"sid" => NULL,
"name" => "fa_mode",
"title" => "What is your mode?",
"description" => "Please specify your custom mode! (if you have a theme without icons on Who`s Online then you must select Simple Mode, else you have to select Advanced Mode)",
"optionscode" => "select\n0=Simple Mode\n1=Advanced Mode",
"value" => "0",
"disporder" => "2",
"gid" => intval($gid)
);
$setare_3 = array(
"sid" => NULL,
"name" => "fa_list",
"title" => "Display list:",
"description" => "Please select your display list!",
"optionscode" => "select\n0=Years,Months,Days\n1=Years,Months,Days,Hours\n2=Years,Months,Days,Hours,Minutes",
"value" => "0",
"disporder" => "3",
"gid" => intval($gid)
);
$db->insert_query("settings", $setare_1);
$db->insert_query("settings", $setare_2);
$db->insert_query("settings", $setare_3);
rebuild_settings();
$sablon = array(
"tid" => NULL,
"title" => "fa_template",
"template" => "{\$fa_final}",
"sid" => "-1"
);
$db->insert_query("templates", $sablon);
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index_boardstats", '#{\$forumstats}#', "{\$forumstats}\n{\$faforumage}");
}
//Deactivate plugin
function forumage_deactivate()
{
global $db;
$db->delete_query('settings', 'name IN("fa_enabled","fa_mode","fa_list")');
$db->delete_query('settinggroups', 'name = "fa_hsc"');
rebuild_settings();
$db->delete_query('templates', 'title = "fa_template"');
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index_boardstats", '#(\n?){\$faforumage}#', '', 0);
}
//Aditional functions
function forumage_get($diferenta)
{
$ani = floor($diferenta / (365*60*60*24));
$luni = floor(($diferenta - $ani * 365*60*60*24) / (30*60*60*24));
$zile = floor(($diferenta - $ani*365*60*60*24 - $luni*30*60*60*24)/ (60*60*24));
$ore = floor(($diferenta - $ani*365*60*60*24 - $luni*30*60*60*24 - $zile*60*60*24)/ (60*60));
$minute = floor(($diferenta - $ani*365*60*60*24 - $luni*30*60*60*24 - $zile*60*60*24 - $ore*60*60)/ 60);
return "".$ani."|".$luni."|".$zile."|".$ore."|".$minute."";
}
function forumage_parse($ani,$luni,$zile,$ore,$minute,$timp)
{
global $lang,$mybb;
$lang->load("forumage");
$v = ",";
$a = $lang->fa_and;
if (($ani == "0")&&($luni == "0"))
switch ($mybb->settings['fa_list'])
{
case 0 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$zile."".$lang->fa_days.".";
break;
case 1 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$zile."".$lang->fa_days." ".$a." ".$ore."".$lang->fa_hours.".";
break;
case 2 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$zile."".$lang->fa_days."".$v." ".$ore."".$lang->fa_hours." ".$a." ".$minute."".$lang->fa_minutes.".";
break;
}
else
{
if ($ani == "0")
switch ($mybb->settings['fa_list'])
{
case 0 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$luni."".$lang->fa_months." ".$a." ".$zile."".$lang->fa_days.".";
break;
case 1 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$luni."".$lang->fa_months."".$v." ".$zile."".$lang->fa_days." ".$a." ".$ore."".$lang->fa_hours.".";
break;
case 2 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$luni."".$lang->fa_months."".$v." ".$zile."".$lang->fa_days."".$v." ".$ore."".$lang->fa_hours." ".$a." ".$minute."".$lang->fa_minutes.".";
break;
}
else
switch ($mybb->settings['fa_list'])
{
case 0 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$ani."".$lang->fa_years."".$v." ".$luni."".$lang->fa_months." ".$a." ".$zile."".$lang->fa_days.".";
break;
case 1 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$ani."".$lang->fa_years."".$v." ".$luni."".$lang->fa_months."".$v." ".$zile."".$lang->fa_days." ".$a." ".$ore."".$lang->fa_hours.".";
break;
case 2 :
return $lang->fa_boardstartedon1."".date('d.m.Y',$timp)."".$lang->fa_boardstartedon2."".$ani."".$lang->fa_years."".$v." ".$luni."".$lang->fa_months."".$v." ".$zile."".$lang->fa_days."".$v." ".$ore."".$lang->fa_hours." ".$a." ".$minute."".$lang->fa_minutes.".";
break;
}
}
}
//Functia de initializare
function forumage_start()
{
//Variabile globale
global $db, $mybb, $faforumage, $templates;
//Variabile de lucru
$final = "";
if ($mybb->settings['fa_enabled'] == 1)
{
$data_inregistrarii = 1350848400;
$data_acum = time();
//Diferenta de timp este = ...
$diferenta = $data_acum - $data_inregistrarii;
$rezultat = explode('|',forumage_get($diferenta));
//Se parseaza datele obtinute si se formeaza string-ul final
$final = forumage_parse($rezultat[0],$rezultat[1],$rezultat[2],$rezultat[3],$rezultat[4],$data_inregistrarii);
if ($mybb->settings['fa_mode'] == 1)
{
//Advanced Mode - template
$fa_final = "<tr>
<td class=\"trow1_smalltext_fa\" align=\"center\" width=\"1\"><img src=\"images/fa_image.png\" alt=\"Group Legend\" />
</td>
<td colspan=\"6\" class=\"trow1fa\">
<span class=\"smalltextfa\">
".$final."
</span>
</td>
</tr>";
}
else
{
//Simple Mode - template
$fa_final = "<tr>
<td class=\"fatrow1\">
<span class=\"fasmalltext\">
".$final."
</span>
</td>
</tr>";
}
}
else
{
$fa_final = "";
}
eval("\$faforumage = \"".$templates->get("fa_template")."\";");
}
?>