<?php
/*
 * JohnCMS NEXT Mobile Content Management System (http://johncms.com)
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://socialbux.epizy.com  -  Nairaland Project
 * @copyright   Copyright (C) Socialbux Community
 * @license     GPL-3
 */

defined('_IN_JOHNCMS') or die('Error: restricted access');

/** @var Psr\Container\ContainerInterface $container */
$container = App::getContainer();

/** @var Johncms\Api\UserInterface $systemUser */
$systemUser = $container->get(Johncms\Api\UserInterface::class);

/** @var Johncms\Api\ConfigInterface $config */
$config = $container->get(Johncms\Api\ConfigInterface::class);

/** @var Johncms\Counters $counters */
$counters = $container->get('counters');

$mp = new Johncms\NewsWidget();

// Блок информации
!$systemUser->id ?: include './system/bonus.inc.php';
echo '<a name="top"></a><table class="boards"><tr><th><h3>SOCIALBUX NIGERIAN FORUMS</h3><tr><td class="l w"><a href="' . $config['homeurl'] . '/forum/index.php?id=1" title=" class=g"><b>' . $config->copyright . ' / General</b></a>: <a href="' . $config['homeurl'] . '/forum/index.php?id=20" title="Our country Nigeria is the giant of Africa!"><b>Politics</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=21" title=""><b>Crime</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=22" title="Discuss dating, courtship, and romance in marriage."><b>Romance</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=23" title="Job/Employment Opportunities; Vacancies In Nigeria!"><b>Jobs/Vacancies</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=24" title="Talk about workplace experiences and incidents, professional training and certification, career management, etc.  Employed, self-employed, job seekers."><b>Career</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=25" title="Entrepreneurship, Startups, Economics, etc"><b>Business</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=26" title="For Investors. Nigerian Stock Exchange (NSE) Stocks, Bonds, T-bills, Real-Estate, etc."><b>Investment</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=27" title="National Youth Service Corps (NYSC) Discussions. Corpers, etc."><b>NYSC</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=28" title="' . $config->copyright . ' Students Forum: Primary and secondary school, universities, polytechnics, et cetera."><b>Education</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=29" title="Cars, motorbikes, airplanes, et cetera."><b>Autos</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=30" title="Let&#x27;s talk about cars here"><b>Car Talk</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=31" title="Real Estate: Land, Houses, Flats, Etc."><b>Properties</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=32" title="Health related topics."><b>Health</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=33" title="Tourism, travel.  Interesting destinations within Nigeria and abroad. And motoring!"><b>Travel</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=34" title="Marriage/Family issues including husband to wife, parent to child, sibling and extended family relationships"><b>Family</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=35" title="Nigerian languages, traditions, practices, et cetera."><b>Culture</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=36" title="Share your faith and belief in God or higher powers here."><b>Religion</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=37" title="Delicious foods and how to prepare them.  Anything about food or drink goes here.  This is the ' . $config->copyright . ' kitchen!"><b>Food</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=38" title="Write about your life and let the whole world read you.  You won&#x27;t even be interrupted by comments.   ' . $config->copyright . ' members only!"><b>Diaries</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=41" title="' . $config->copyright . ' Direct Adverts"><b>' . $config->copyright . ' Ads</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=42" title="Discuss dogs/puppies, cats/kittens, and other pets. Buy and sell them"><b>Pets</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=43" title="The business and science of crop and livestock production, Agric Science, Agric Economics, etc"><b>Agriculture</b></a><tr><td class="l "><a href="' . $config['homeurl'] . '/forum/index.php?id=2" title="Entertainment threads that won&#x27;t fit into any child board. class=g"><b>Entertainment</b></a>: <a href="' . $config['homeurl'] . '/forum/index.php?id=10" title="Riddles and jokes that fellow Nigerians can appreciate."><b>Jokes Etc</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=11" title="Local television programmes, local and foreign movies available in Nigeria."><b>TV/Movies</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=12" title="Talk about your favorite songs, music albums, artists and bands."><b>Music/Radio</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=13" title="Celebrity obsession, Nollywood gossip, etc."><b>Celebrities</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=14" title="Clothes, dresses, make-up routines, and modeling."><b>Fashion</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=15" title="Birthdays, Weddings, other Occasions. Planning, Announcement, Gifts."><b>Events</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=16" title="We are Nigerians; and we love soccer and many other sports!"><b>Sports</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=17" title="Welcome to the world of computer, Internet, video, and board games.  Xbox, PS2, Chess, whatever!"><b>Gaming</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=18" title="Play various addictive forum games with fellow members of ' . $config->copyright . '."><b>Forum Games</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=19" title="For writers and lovers of books."><b>Literature</b></a><tr><td class="l w"><a href="' . $config['homeurl'] . '/forum/index.php?id=3" title=" class=g"><b>Science/Technology</b></a>: <a href="' . $config['homeurl'] . '/forum/index.php?id=4" title="Software programming, development of applications.."><b>Programming</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=5" title="Website design and development, management of forums, blogs, wikis, and all sorts of websites. 🥹🤯🥳🇳🇬💸💸💸"><b>Webmasters</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=6" title="Personal Computing, etc."><b>Computers</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=7" title="Nigerian GSM networks, telephone companies, et cetera. ISPs, Modems, Websites, etc"><b>Phones</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=8" title="Digital Video and Film, Computer Graphics and Animation.  Tips, Tricks &amp; Tools."><b>Art, Graphics &amp; Video</b></a>, <a href="' . $config['homeurl'] . '/forum/index.php?id=9" title="Buy and sell Phones, Computers and PC accessories here."><b>Technology Market</b></a></table>';

	//echo'<a name="featured"></a><div class=vertipics><a href="' . $config['homeurl'] . '/forum/index.php?id=50" rel=sponsored target="_blank"><img src="https://www.' . $config->copyright . '.com/vertipics/s1zc4y831jz1nru8xizfym1r3fvi51wx.jpg"></a></div>';




	//Ads 1 in middle Mainmenu.php
	echo'<a name="featured"></a><div class=vertipics><a href="' . $config['homeurl'] . '/forum/index.php?id=50" rel=sponsored target="_blank"><img src="' . $config['homeurl'] . '/ads.png"></a></div>';


	echo'<table class=boards><tr><td><img src="' . $config['homeurl'] . '/icons/smiley.gif" alt=> <b><a href="/news">Latest News</a></b> / <b><a href="http://twitter.com/">Twitter</a></b>  / <b><a href="http://facebook.com/">Facebook</a></b>  / <b><a href="' . $config['homeurl'] . '/forum/index.php?id=147">How To Advertise</a></b> <img src="' . $config['homeurl'] . '/icons/smiley.gif">';


echo'<tr><td class="featured w">';
//Features or Latest post in forum becareful when changing codes here
if ($config->mod_forum || $systemUser->rights >= 7) {
    $req = $db->query("SELECT `forum`.*, `users`.`rights` FROM `forum` INNER JOIN `users` ON `forum`.`user_id` = `users`.`id` WHERE `type`='t'" . ($systemUser->rights >= 7 ? "" : " AND `close` != '1'") . " ORDER BY `vip` DESC, `time` DESC LIMIT $start, $kmess");
  $total = $req->rowCount();

  if ($total > 0) {
      for ($i = 0; $res = $req->fetch(); ++$i) {
          if ($res['close'])
echo'';
else
              echo $i % 2 ? '<hr>»' : '<hr>»';

          $razd = $db->query("SELECT `id`, `refid`, `text` FROM `forum` WHERE `type` = 'r' AND `id` = '" . $res['refid'] . "' LIMIT 1")->fetch();
          $frm = $db->query("SELECT `id`, `text` FROM `forum` WHERE `type`='f' AND `id` = '" . $razd['refid'] . "' LIMIT 1")->fetch();
          $colmes = $db->query("SELECT `forum`.`from`, `forum`.`time`, `forum`.`user_id`, `users`.`rights` FROM `forum` INNER JOIN `users` ON `users`.`id` = `forum`.`user_id` WHERE `refid` = '" . $res['id'] . "' AND `type` = 'm'" . ($systemUser->rights >= 7 ? '' : " AND `close` != '1'") . " ORDER BY `forum`.`time` DESC");
          $colmes1 = $colmes->rowCount();
          $cpg = ceil($colmes1 / $kmess);
          $nick = $colmes->fetch();
          $icons = [
                        (isset($np) ? (!$res['vip'] ? $tools->image('normal_post.gif') : '') : $tools->image('/normal_post.gif')),
                        ($res['vip'] ? $tools->image('pt.gif') : ''),
                        ($res['realid'] ? $tools->image('rate.gif') : ''),
                        ($res['edit'] ? $tools->image('tz.gif') : ''),
                   ];
          //echo implode('', array_filter($icons));
          echo ' <a style="font-size:12pt" href="' . $tools->rewriteUrl($res['text'], $res['id']) . '"><b>' . (empty($res['text']) ? '-----' : $res['text']) .
              '</b></a>&#160;(' . $colmes1 . ') « ';
          if ($cpg > 1)
              echo '&#160;<a href="' . $tools->rewriteUrl($res['text'], $res['id'], $cpg) . '">&gt;&gt;</a>«';
          //echo ' <br>';
         // if ($systemUser->isValid() && $systemUser->id != $res['user_id'])
             //   echo 'Topic author: <font color="black"><b><a href="../profile/?user=' . $res['user_id'] . '">' . $tools->displayUsername($res['from'], $res['rights']) . '</a></b></font><br>';
           // else
               // echo $tools->displayUsername($res['from'], $res['rights']);
            //if ($colmes1 > 1)
               // if ($systemUser->isValid() && $systemUser->id != $nick['user_id'])
                //    echo '<br>&#160;-&#160;<a href="../profile/?user=' . $nick['user_id'] . '">Last reply: <font color="black"><b>' . $tools->displayUsername($nick['from'], $nick['rights']) . '</a></b></font><br>';
               // else
               //     echo 'Last  comment: <font color="black"><b>' . $tools->displayUsername($nick['from'], $nick['rights']);
       // echo '</b></font><span class="time"> (' . $tools->displayDate($nick['time']) . ')</span><br/>';
         // echo '<a href="' . $tools->rewriteUrl($frm['text'], $frm['id']) . '">' . $frm['text'] . '</a>&#160;/&#160;<a href="' . $tools->rewriteUrl($razd['text'], $razd['id']) . '">' . $razd['text'] . '</a>';
     }
  } else {
      echo '<div class="menu"><p>' . _t('No latest post for now, please check back', 'system') . '</p></div>';
  }
  if ($total > $kmess) {
      echo '<div class="topmenu">' . $tools->displaypagination('index.php?', $start, $total, $kmess) . '</div>' .
          '<p><form action="index.php" method="get">' .
          '<input type="text" name="page" size="2"/>' .
          '<input type="submit" value="' . _t('To Page') . ' &gt;&gt;"/>' .
          '</form></p>';
  }
  }




  	//pagination links
	echo'<tr><td>(<b>1</b>)  <a href="/">(<b>2</b>)</a>  <a href="/">(<b>3</b>)</a></table>';

	//Ads 2 in middle Mainmenu.php
 	echo'<div class=vertipics><a href="' . $config['homeurl'] . '/forum/index.php?id=50" rel=sponsored target="_blank"><img src="' . $config['homeurl'] . '/ads.png"></a></div>';

	//Statistics in Mainmenu.php
	$users = $db->query("SELECT COUNT(*) FROM `users` WHERE `lastdate` > '" . (time() - 300) . "'")->fetchColumn();
	$guests = $db->query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '" . (time() - 300) . "'")->fetchColumn();
	$online = $_GET['online'];
	echo'<table><tr><td class=w><h3>Members Online:</h3> (<b>' . $users . ' Members</b> and <b>' . $guests . ' Guests</b> online in <b>last 5 minutes</b>!)</table>';

// Floxywap Online
function showOnline($user = [], $status = 0, $ip = 0, $str = '', $text = '', $sub = '') {
global $systemUser, $config;
$out = false;
if ($user['rights'] == 0) {
$colornick['colornick'] = 'FF9900';
}
if ($user['rights'] == 1) {
$colornick['colornick'] = '3399FF';
}
if ($user['rights'] == 2) {
$colornick['colornick'] = '3399FF';
}
if ($user['rights'] == 3) {
$colornick['colornick'] = '3399FF';
}
if ($user['rights'] == 4) {
$colornick['colornick'] = '3399FF';
}
if ($user['rights'] == 5) {
$colornick['colornick'] = '3399FF';
}
if ($user['rights'] == 6) {
$colornick['colornick'] = '3399FF';
}
if ($user['rights'] == 7) {
$colornick['colornick'] = '339900';
}
if ($user['rights'] == 8) {
$colornick['colornick'] = 'EE2C2C';
}
if ($user['rights'] == 9) {
$colornick['colornick'] = 'CC0000';
}
if ($user['rights'] == 10) {
$colornick['colornick'] = '7192A8';
}
$out .= !$systemUser->isValid() || $systemUser->id == $user['id'] ? '<span style = "color:#' . $colornick['colornick'] . '">' . $user['name'] . '</span>' : '<a href="../users/profile.php?user=' . $user['id'] . '"><span style="color:#' . $colornick['colornick'] . '">' . $user['name'] . '</span></a>';
return $out;
}
function timecount($var) {
global $config;
if ($var < 0)
$var = 0;
$day = ceil($var/86400);
if ($var > 345600) {
$str = $day . ' ' . _t('Day');
}
elseif ($var >= 172800) {
$str = $day . ' ' . _t('Days');
}
elseif ($var >= 86400) {
$str = '1 ' . $_('Day');
} else {
$str = date("G:i:s", mktime(0, 0, $var));
}
return $str;
}
$users_boys = $db->query("SELECT COUNT(*) FROM `users` WHERE `sex` = 'm';")->fetchColumn();
$users_girls = $db->query("SELECT COUNT(*) FROM `users` WHERE `sex` = 'zh';")->fetchColumn();
$users = $db->query("SELECT COUNT(*) FROM `users` WHERE `lastdate` > '" . (time() - 300) . "'")->fetchColumn();
$guests = $db->query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '" . (time() - 300) . "'")->fetchColumn();
$online = $_GET['online'];
echo '<table><tr><td class=w><b>Statistic:</b>  ';
if ($guests >= 1)
echo '<a href="' . $config['homeurl'] . '/users/index.php?act=online&amp;mod=guest"><span class="red">Guest Online' . $guests . '</a></span>';
else
//echo '<span class="red">No Guest</a></span>';
//echo '<div class="">Members:&#160;<a href="../users/index.php">' . $counters->users() . ' </a><br/>';
echo'<span class="red">' . $users_boys . '</span> Boys and <span class="red">' . $users_girls . '</span> Girls<br/>';
//echo '<a href="index.php?online=freaks#online">View the online records..</a><br/>';
if ($users >= 1)
echo '<b>Currently:</b>&#160;<span class="green">' . $users . '</span>&#160;member online<br/>';
switch($online) {
default:
$onltime = time() - 600;
$total = $db->query("SELECT COUNT(*) FROM `" . ($act == 'guest' ? 'cms_guests' : 'users') . "` WHERE `lastdate` > '$onltime'")->fetchColumn();
$gbot = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
$yanbot = 'Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)';
$bing = 'Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)';
$bd = 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)';
$googlebot = $db->query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '$onltime' AND `browser`='$gbot'")->fetchColumn();
$yandexbot = $db->query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '$onltime' AND `browser`='$yanbot'")->fetchColumn();
$bingbot = $db->query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '$onltime' AND `browser`='$bing'")->fetchColumn();
$baidu = $db->query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '$onltime' AND `browser`='$bd'")->fetchColumn();
$total = $total+$googlebot+$yandexbot+$bingbot+$baidu;
echo '<b>Active Member:</b>&#160;';
if ($total) {
echo ''.($googlebot ? '<font color="#7192a8">Google[bot]</font>, ' : '').''.($yandexbot ? '<font color="#7192a8">Yandex[bot]</font>, ' : '').''.($bingbot ? '<font color="#7192a8">Bing[bot]</font>, ' : '').''.($baidu ? '<font color="#7192a8">Baidu[bot]</font>, ' : '').'';
$req = $db->query("SELECT * FROM `" . ($act == 'guest' ? 'cms_guests' : 'users') . "` WHERE `preg`='1' and `lastdate` > '" . (time() - 300) . "' ORDER BY " . ($act == 'guest' ? "`movings` DESC" : "`name` ASC") . " LIMIT 1000");
while ($res = $req->fetch()) {
echo showOnline($res, 0, ($act == 'guest' || ($systemUser->rights >= 1 && $systemUser->rights >= $res['rights']) ? ($systemUser->rights >= 6 ? 2 : 1) : 0), ' (' . $res['movings'] . ' - ' . timecount($realtime - $res['sestime']) . ') ' . $place);
echo ', ';
++$l;
}
echo'<br/>';
} else {
echo 'No members online..!!<br/>';
}
break;
case '24h':
$total = $db->query("SELECT COUNT(*) FROM `" . ($act == 'guest' ? 'cms_guests' : 'users') . "` WHERE `lastdate` > '" . (time() - 96000) . "'")->fetchColumn();
echo 'Last 24 hours:&#160;';
if ($total > 0) {
$req = $db->query("SELECT * FROM `" . ($act == 'guest' ? 'cms_guests' : 'users') . "` WHERE `preg`='1' and `lastdate` > '" . (time() - 96000) . "' ORDER BY " . ($act == 'guest' ? "`movings` DESC" : "`name` ASC") . " LIMIT 1000");
while ($res = $req->fetch()) {
echo showOnline($res, 0, ($act == 'guest' || ($systemUser->rights >= 1 && $systemUser->rights >= $res['rights']) ? ($systemUser->rights >= 6 ? 2 : 1) : 0), ' (' . $res['movings'] . ' - ' . timecount($realtime - $res['sestime']) . ') ' . $place);
echo ', ';
++$l;
}
echo '<br/>';
} else {
echo 'No members online..!!<br/>';
}
break;
case 'freaks':
$rea = $db->query("SELECT COUNT(*) FROM `users` WHERE `lastdate` > '" . (time() - 172800) . "'")->fetchColumn();
$reb = $db->query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '" . (time() - 172800) . "'")->fetchColumn();
$vr = date("d F Y g:i:s a",time()+(7*3600));
echo 'Record at online <span class="red">'.$vr.'</span> are <span class="red">'.$rea.'</span> Members and <span class="red">'.$reb.'</span> Guest, results show the
largest number of people online at the same time at <font color="green">' . $config['copyright'] . '</font>';
break;
}
$total = $db->query("SELECT COUNT(*) FROM `users` WHERE `dayb` = '" . date('j', time()) . "' AND `monthb` = '" . date('n', time()) . "' AND `preg` = '1'")->fetchColumn();
if ($total) {
echo 'Today Birthday:&#160;';
$req = $db->query("SELECT * FROM `users` WHERE `dayb` = '" . date('j', time()) . "' AND `monthb` = '" . date('n', time()) . "' AND `preg` = '1' ORDER BY `name` DESC LIMIT 100");
while($res = $req->fetch()) {
//echo '<a href="' . $config['homeurl'] . '/profile/?user='.$res['id'].'"><img src="' . $config['homeurl'] . '/images/empty.png" width="32" height="32" alt="" />'.$res['name'].'</a> ';
if (file_exists('../files/users/avatar/'.$res['id'].'.png')) {
 echo'<a href="' . $config['homeurl'] . '/profile/?user='.$res['id'].'"><img src="' . $config['homeurl'] . '/files/users/avatar/'.$res['id'].'.png" height="32px" width="32px" alt="'.$res['name'].', profile picture">'.$res['name'].'</a>,';}else{
echo'<a href="' . $config['homeurl'] . '/profile/?user='.$res['id'].'"><img src="' . $config['homeurl'] . '/images/empty.png" height="32px" width="32px" alt="'.$res['name'].', profile picture">'.$res['name'].'</a>,';}
}
}
if ($total) {
echo '</div>';
} else {
#NO DATA
}
$cox = @$db->query("SELECT * FROM `users` WHERE `lastdate` >= '" . intval(time() - 300) . "' ORDER BY RAND() LIMIT 1;");
$count = $cox->rowCount();
while ($arr = $cox->fetch()) {
echo '<b> Last Register:</b>&#160;';
$req = $db->query("SELECT `id`, `name`, `datereg` FROM `users` WHERE (preg='1') ORDER BY `datereg` DESC LIMIT 1;");
$arr = $req->fetch();
echo '<a href="' . $config['homeurl'] . '/profile/?user=' . $arr['id'] . '"><font color="blue">'.$arr['name'] .'</font></a>';
}
echo'</table>';
  
