"Data założenia forum: 06-11-2017 Forum istnieje: 12 miesięcy, 2 dni, 19 godzin oraz 57 minut."
a powinno pokazywać 11 miesięcy, 28 dni
Kod:
<?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" => "Czas forum",
"description" => "Pokazuje, ile lat ma twoje forum.",
"website" => "http://nasyr.net/",
"author" => "Nasyr",
"authorsite" => "http://nasyr.net/",
"version" => "1.0",
"guid" => "",
'compatibility' => '*',
);
}
//Activate plugin
function forumage_activate()
{
global $db;
$grup_de_setari = array(
"gid" => NULL,
"name" => "fa_hsc",
"title" => "Czas forum",
"description" => "Chcesz wiedzieć, ile twoje forum już istnieje? - Ten plugin jest dla ciebie",
"disporder" => "35",
"isdefault" => "no"
);
$db->insert_query("settinggroups", $grup_de_setari);
$gid = $db->insert_id();
$setare_1 = array(
"sid" => NULL,
"name" => "fa_enabled",
"title" => "Włączyć plugin?",
"description" => "Zaznacz tak/nie, jeśli chcesz, żeby plugin był włączony/wyłączony",
"optionscode" => "yesno",
"value" => "no",
"disporder" => "1",
"gid" => intval($gid)
);
$setare_2 = array(
"sid" => NULL,
"name" => "fa_mode",
"title" => "W jakim formacie liczyć?",
"description" => "Zaznacz, w jakim formacie będzie liczony czas założenia forum.",
"optionscode" => "select\n0=Normalny tryb\n1=Zaawansowany tryb",
"value" => "0",
"disporder" => "2",
"gid" => intval($gid)
);
$setare_3 = array(
"sid" => NULL,
"name" => "fa_list",
"title" => "Format liczenia:",
"description" => "Zaznacz format liczenia stażu forum!",
"optionscode" => "select\n0=Lat,Miesięcy,Dni\n1=Lat,Miesięcy,Dni,Godzin\n2=Lat,Miesięcy,Dni,Godzin,Minut",
"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)
{
//Se realizeaza interogarea
$interogare = $db->simple_select("users","regdate","",array("order_by"=>'uid',"limit"=>1));
//Se intoarce din baza de date primul user inregistrat pe forum (admin)
$user = $db->fetch_array($interogare);
$data_inregistrarii = $user['regdate'];
$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 Tryb zaawansowany - template
$fa_final = "<tr>
<td class=\"tcat\">
<span class=\"smalltext\">
Forum istnieje:
{$lang->fa_boardstartedon1}
</span>
</td>
</tr>
<tr>
<td colspan=\"6\" class=\"trow1\">
<span class=\"smalltext\">
".$final."
</span>
</td>
</tr>";
}
else
{
//Simple Mode Prosty tryb - template
$fa_final = "<tr>
<br/>
<td class=\"trow1\" style=\"text-align: right;\">
<span class=\"smalltext\" style=\"font-style: italic; font-size: 0.7em;\">
".$final."
</span>
</td>
</tr>";
}
}
else
{
$fa_final = "";
}
eval("\$faforumage = \"".$templates->get("fa_template")."\";");
}
?>