<?php
/**
* MyBB 1.6
* Copyright © 2010 Samuel
*/
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("index_start", "adstats");
function adstats_info()
{
return array(
"name" => "آمار اضافی",
"description" => "افزودن آمار اضافی به صفحه اصلی. <br><i> فارسی سازی شده توسط : <i><b><a href=\"http://www.mybbiran.com\"><font color=\"#FF0000\">MyBBIran.com</font></a></b></i>",
"website" => "",
"author" => "Samuel",
"authorsite" => "",
"version" => "3.0",
"guid" => "e6ff63b6892e70ca46bc547b3d67581f",
"compatibility" => "16*"
);
}
function adstats_activate()
{
global $db, $lang;
$adstats_group = array(
"name" => "adstats",
"title" => "آمار اضافی در صفحه اصلی",
"description" => "آمار اضافی در قسمت آمار صفحه اصلی",
"disporder" => "401",
"isdefault" => "no",
);
$group['gid'] = $db->insert_query("settinggroups", $adstats_group);
$gid = $db->insert_id();
$set_adstats_displayveiw = array(
"name" => "set_adstats_displayveiw",
"title" => "نمایش دادن",
"description" => "آمار اضافی به صورت زیر هم نمایش داده شوند یا دنبال هم، بله = زیر هم",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $set_adstats_displayveiw);
$set_adstats_newuser = array(
"name" => "set_adstats_newuser",
"title" => "کاربر های جدید امروز",
"description" => "کاربر های جدید امروز در صفحه اصلی نمایش داده شود؟",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query("settings", $set_adstats_newuser);
$set_adstats_activeuser = array(
"name" => "set_adstats_activeuser",
"title" => "حساب های کاربری فعال شده امروز",
"description" => "حساب های کاربری فعال شده امروز در صفحه اصلی نمایش داده شود؟",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "3",
"gid" => intval($gid),
);
$db->insert_query("settings", $set_adstats_activeuser);
$set_adstats_nummsg = array(
"name" => "set_adstats_nummsg",
"title" => "موضوع ها و ارسال های امروز",
"description" => "موضوع ها و ارسال های امروز در صفحه اصلی نمایش داده شود؟",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "4",
"gid" => intval($gid),
);
$db->insert_query("settings", $set_adstats_nummsg);
$set_adstats_attach = array(
"name" => "set_adstats_attach",
"title" => "تمامی پیوست ها",
"description" => "تمامی پیوست ها و فضای استفاده شده در صفحه اصلی نمایش داده شود؟",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "5",
"gid" => intval($gid),
);
$db->insert_query("settings", $set_adstats_attach);
$set_adstats_poll = array(
"name" => "set_adstats_poll",
"title" => "نظر سنجی ها",
"description" => "نظرسنجی های جدید، تعداد کل نظر سنجی ها و نظر های داده شده در صفحه اصلی نمایش داده شود؟",
"optionscode" => "yesno",
"value" => "1",
"disporder" => "6",
"gid" => intval($gid),
);
$db->insert_query("settings", $set_adstats_poll);
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index_stats", "#".preg_quote('{$lang->stats_mostonline}')."#i", '{\$lang->stats_mostonline}{\$adstats}');
rebuild_settings();
}
function adstats_deactivate()
{
global $db;
$db->delete_query("settinggroups", "name = 'adstats'");
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index_stats", "#".preg_quote('{$adstats}')."#i", '', 0);
$db->write_query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN(
'set_adstats_displayveiw',
'set_adstats_newuser',
'set_adstats_activeuser',
'set_adstats_nummsg',
'set_adstats_attach',
'set_adstats_poll'
)");
rebuild_settings();
}
function adstats()
{
global $db, $mybb, $templates, $adstats;
$timecut = time() - 86400;
$adstats = "";
if($mybb->settings['set_adstats_displayveiw'] == 1)
{
if($mybb->settings['set_adstats_newuser'] == 1)
{
$newusers = $db->fetch_field($db->simple_select("users", "COUNT(*) AS newusers", "regdate>'$timecut'"), "newusers");
$adstats = "<br />کاربر های جدید امروز: {$newusers}";
}
if($mybb->settings['set_adstats_activeuser'] == 1)
{
$activeusers = $db->fetch_field($db->simple_select("users", "COUNT(*) AS activeusers", "regdate>'$timecut'"), "activeusers");
$adstats .= "<br />حساب های کاربری فعال شده در امروز: <a href=\"online.php?action=today\">{$activeusers}</a>";
}
if($mybb->settings['set_adstats_nummsg'] == 1)
{
$newthreads = $db->fetch_field($db->simple_select("threads", "COUNT(*) AS newthreads", "dateline>'$timecut' AND visible='1' AND closed NOT LIKE 'moved|%'"), "newthreads");
$newposts = $db->fetch_field($db->simple_select("posts", "COUNT(*) AS newposts", "dateline>'$timecut' AND visible='1'"), "newposts");
$adstats .= "<br />موضوع ها و ارسال های جدید امروز: {$newthreads} - <a href=\"search.php?action=getdaily\">{$newposts}</a>";
}
if($mybb->settings['set_adstats_attach'] == 1)
{
$query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused", "visible='1' AND pid>0");
$attachs = $db->fetch_array($query);
$adstats .= "<br />تمامی پیوست ها و فضای استفاده شده: {$attachs['numattachs']} - ".get_friendly_size($attachs['spaceused']);
}
if($mybb->settings['set_adstats_poll'] == 1)
{
$newpolls = $db->fetch_field($db->simple_select("polls", "COUNT(*) AS newpolls", "dateline>'$timecut'"), "newpolls");
$totalpolls = $db->fetch_field($db->simple_select("polls", "COUNT(*) AS totalpolls"), "totalpolls");
$pollvotes = $db->fetch_field($db->simple_select("pollvotes", "COUNT(*) AS pollvotes"), "pollvotes");
$adstats .= "<br />نظرسنجی های جدید، تمامی نظرسنجی ها و تمامی نظر ها: {$newpolls} - {$totalpolls} - {$pollvotes}";
}
}
if($mybb->settings['set_adstats_displayveiw'] == 0)
{
if($mybb->settings['set_adstats_newuser'] == 1)
{
$newusers = $db->fetch_field($db->simple_select("users", "COUNT(*) AS newusers", "regdate>'$timecut'"), "newusers");
$adstats = "<br />کاربر های جدید امروز {$newusers}";
}
if($mybb->settings['set_adstats_activeuser'] == 1)
{
$activeusers = $db->fetch_field($db->simple_select("users", "COUNT(*) AS activeusers", "regdate>'$timecut'"), "activeusers");
$adstats .= ", حساب های کاربری فعال شده در امروز <a href=\"online.php?action=today\">{$activeusers}</a>";
}
if($mybb->settings['set_adstats_nummsg'] == 1)
{
$newthreads = $db->fetch_field($db->simple_select("threads", "COUNT(*) AS newthreads", "dateline>'$timecut' AND visible='1' AND closed NOT LIKE 'moved|%'"), "newthreads");
$newposts = $db->fetch_field($db->simple_select("posts", "COUNT(*) AS newposts", "dateline>'$timecut' AND visible='1'"), "newposts");
$adstats .= ", موضوع ها و ارسال های جدید امروز {$newthreads} - <a href=\"search.php?action=getdaily\">{$newposts}</a>";
}
if($mybb->settings['set_adstats_attach'] == 1)
{
$query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused", "visible='1' AND pid>0");
$attachs = $db->fetch_array($query);
$adstats .= ", تمامی پیوست ها و فضای استفاده شده {$attachs['numattachs']} - ".get_friendly_size($attachs['spaceused']);
}
if($mybb->settings['set_adstats_poll'] == 1)
{
$newpolls = $db->fetch_field($db->simple_select("polls", "COUNT(*) AS newpolls", "dateline>'$timecut'"), "newpolls");
$totalpolls = $db->fetch_field($db->simple_select("polls", "COUNT(*) AS totalpolls"), "totalpolls");
$pollvotes = $db->fetch_field($db->simple_select("pollvotes", "COUNT(*) AS pollvotes"), "pollvotes");
$adstats .= "<br /> نظرسنجی های جدید، تمامی نظرسنجی ها و تمامی نظر ها {$newpolls} - {$totalpolls} - {$pollvotes}";
}
}
}
?>