<?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://johncms.com JohnCMS Project
 * @copyright   Copyright (C) JohnCMS Community
 * @license     GPL-3
 */

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

/*
-----------------------------------------------------------------
Masterscliq Main right menu
-----------------------------------------------------------------
*/
if (!$systemUser->isValid() || ($systemUser->id && $config->mod_fsearch != 0)) {
$search_post = isset($_POST['search']) ? trim($_POST['search']) : false;
$search_get = isset($_GET['search']) ? rawurldecode(trim($_GET['search'])) : false;
$search = $search_post ? $search_post : $search_get;
$search_t = isset($_REQUEST['t']);
echo '<div class="mainblok"><div class="phdr"><img src="/images/subfldr.png" width="16" height="16" class="left"/>&nbsp;<b>' . _t('Forum') . '&nbsp;search</b></div>' .
'<div class="gmenu"><form action="../forum/search.php" method="post"><p>' .
'<input type="text" value="' . ($search ? $tools->checkout($search) : '') . '" name="search" />' .
'<input type="submit" value="' . _t('Search') . '" name="submit" /><br />' .
'<input name="t" type="checkbox" value="1" ' . ($search_t ? 'checked="checked"' : '') . ' />&nbsp;Search in thread</p></form></div></div>';
}

/*
-----------------------------------------------------------------
Masterscliq Shoutbox
-----------------------------------------------------------------
*/
$cshout = $db->query("SELECT COUNT(*) FROM `shout` WHERE `adm`='0'")->fetchColumn();
$token = mt_rand(1000, 100000);
$_SESSION['token'] = $token;
echo '<div class="mainblok"><div class="phdr"><table width="100%" cellpadding="0" cellspacing="0"><tr><td align="left" valign=""><img src="/images/shout.png" width="16" height="16" alt=""/><a href="/shoutbox/index.php">&#160;<b>' . _t('ShoutBox') . '</b></a></td><td width="auto" align="right" valign="">';
if ($systemUser->rights >= 3) {
echo '<a href="/shoutbox/botpanel.php">Botboy</a> &bull; <a href="/shoutbox/slavepanel.php">Botgirl</a>&#160;';
} else {
#FOR MEMBERS ONLY
}
echo '</td></tr></table></div>';
if (!$systemUser->isValid()) {
echo '<div class="textshout">' . _t('Access to guest is forbidden) . '</div>';
}
elseif ($systemUser->ban['1'] || $systemUser->ban['13']) {
echo '<div class="alert"><font color="red"><b>You are banned..!!</b></font><br/><img src="../images/prvs.gif"/> We are sorry..<br>You are not allowed to post in shout..!!<br/>' . _t('Banned') . '&#160;<a href="' . $set['homeurl'] . '/profile/index.php?act=ban">' . _t('Reasons') . '</a></div>';
} else {
echo '<div class="textshout"><form name="form_shout" action="/shoutbox/index.php?act=say" method="post">';
if (!$is_mobile)
echo bbcode::auto_bb('form_shout', 'msg');
echo '<textarea rows="' . $set_user['field_h'] . '" cols="17" name="msg"></textarea><br/>';
echo '<input type="hidden" name="token" value="' . $token . '"/><input type="submit" title="post message" name="submit" value="Shout"/></form></div>';
}
echo '<div class="gmenu"><form name="form_shout" action="/shoutbox/index.php?act=say" method="post">';
echo $bbcode->buttons('form_shout', 'msg');
echo '<textarea rows="' . $systemUser->getConfig()->fieldHeight . '" cols="17" name="msg"></textarea><br/>';
echo '<input type="hidden" name="token" value="' . $token . '"/><input type="submit" title="post message" name="submit" value="Shout"/></input></form></div>';
}
if ($cshout) {
$creq = $db->query("SELECT `shout`.*, `shout`.`id` AS `sid`, `users`.`rights`, `users`.`lastdate`, `users`.`sex`, `users`.`status`, `users`.`datereg`, `users`.`id`
FROM `shout` LEFT JOIN `users` ON `shout`.`user_id` = `users`.`id`
WHERE `shout`.`adm`='0' ORDER BY `time` DESC LIMIT 3");
while ($cres = $creq->fetch()) {
echo ceil(ceil($adepeter / 2) - ($adepeter / 2)) == 0 ? '<div class="list1">' : '<div class="list1">';
// User rights
$rank = array(
0 => '<font color="orange">',
1 => '<font color="#3399ff">',
2 => '<font color="#3399ff">',
3 => '<font color="#3399ff">',
4 => '<font color="#3399ff">',
5 => '<font color="#3399ff">',
6 => '<font color="#3399ff">',
7 => '<font color="green">',
9 => '<font color="cc0000">'
);
if ($cres['user_id']) {
if ($cres['sex'])
echo '<img src="../images/' . ($cres['sex'] == 'm' ? 'm' : 'w') . ($cres['datereg'] > time() - 86400 ? '_new' : '')
. '.png" width="16" height="16" align="left" alt="' . ($cres['sex'] == 'm' ? 'es' : 'eu') . '" />&#160;';
echo '<a href="' . $config['homeurl'] . '/profile/info.php?user=' . $cres['user_id'] . '">' . $rank[$cres['rights']] . '<b>' . $cres['name'] . '</b></a></font>';
echo (time() > $cres['lastdate'] + 300 ? '<span class="red">&nbsp;<img src="/images/offline.gif" width="8" height="10" alt="off"/></span>' : '<span class="green">&nbsp;<img src="/images/online.gif" width="8" height="10" alt="on"/></span>');
echo '<br/>';
}
if (!empty($cres['status']))
$text = htmlentities($cres['text'], ENT_QUOTES, 'UTF-8');
$cpost = $bbcode->adepeter($cpost);
$cpost = str_replace("\r\n", "<br/>", $cpost);
if ($cres['user_id']) {
$cpost = $tools->cleanString($tools->checkout(mb_substr($cres['text'], 0, 200), 1, 1));
$cpost = $tools->smilies($cpost, $cres['rights'] >= 1 ? 1 : 0);
}
// Display text posting
echo $cpost;
if (mb_strlen($cres['text']) > 200)
echo '...<a href="../shoutbox/index.php">More</a>';
echo '</div>';
++$adepeter;
}
} else {
echo '<div class="rmenu">Shout is empty</div>';
}
echo '<div class="phdr"><center><a href="/help/index.php?act=forum">Rules</a> &bull; <a href="/help/index.php?act=tags">Bbcode</a> &bull; <a href="/help/index.php?act=smilies">Emoticons</a></center></div>';
echo '</div>';
/*
-----------------------------------------------------------------
Masterscliq Extraordinary
-----------------------------------------------------------------
*/
if ($config['mod_active'] != 0) {
echo '<div class="mainblok"><div class="phdr"><img src="/images/subfldr.png" width="16" height="16" class="left"/>&nbsp;<b>Extraordinary</b></div>' .
'<div class="menu"><img src="/images/news.png" width="14" height="14" class="left"/>&nbsp;<a href="/news/index.php">' . _t('News Archive') . '</a></div>';
echo '<div class="menu"><img src="/images/nsite.gif" width="14" height="14" class="left"/>&nbsp;<a href="/floxymods/friendssite.php">Advertise WebLink</a></div>';
echo '<div class="menu"><img src="/images/album.png" width="14" height="14" class="left"/>&nbsp;<a href="/users/album.php">' . _t('Photo albums') . '</a> (' . $counters->album() . ')</div>' .
'<div class="menu"><img src="/images/lbr.png" width="14" height="14" class="left"/>&nbsp;<a href="/library/">' . _t('library') . '</a> (' . $counters->library() . ')</div>' .
'<div class="menu"><img src="/images/lock.png" width="14" height="14" class="left"/>&nbsp;<a href="http://net2ftp.com">Ftp service</a></div></div>';
}
/*
-----------------------------------------------------------------
Masterscliq Link exchange
-----------------------------------------------------------------
*/
echo '<div class="mainblok"><div class="phdr"><table width="100%" cellpadding="0" cellspacing="0"><tr><td align="left" valign=""><img src="/images/subfldr.png" width="16" height="16" class="left"/>&nbsp;<b>Link exchange</b></td><td width="auto" align="right" valign="">';
if ($systemUser->isValid() && !isset($systemUser->ban['1']) && !isset($systemUser->ban['11'])) {
echo '<a href="../floxymods/friendssite.php?act=add_site"><img src="/images/addmore.png" width="16" height="16" class="right"/></a>';
} else {
#FOR MEMBERS ONLY
}
echo '</td></tr></table></div>';
$total = $db->query("SELECT COUNT(*) FROM `friendssite`")->fetchColumn();
if($total) {
$req = $db->query("SELECT COUNT(*) FROM `friendssite` WHERE `type`='1'");
$colmes = $req->fetchColumn();
$req = $db->query("SELECT * FROM `friendssite` WHERE `type`='1' ORDER BY RAND() LIMIT 1 ;");
$i = 0;
while ($res = $req->fetch()) {
echo ($i % 2) ? '<div class="list1">' : '<div class="list1">';
$q = $db->query("SELECT `name`,`id` FROM `users` WHERE `id`='" . $res['iduser'] . "'");
$arr = $q->fetch();
echo '<a href="' .$config->homeurl. '/floxymods/friendssite.php?act=redirect&amp;id=' . $res['id'] . '"><b>' . $tools->checkout($res['name']) . '</b></a> [<span class="red">' . $res['count'] . '</span>]<br/>' . $tools->checkout($res['opis'], 1, 1);
echo '</div>';
++$i;
}
} else {
echo '<div class="list1">Site list was empty..!!</div>';
}
echo '</div>';
/*
-----------------------------------------------------------------
Masterscliq Last forum upload
-----------------------------------------------------------------
*/
echo '<div class="mainblok"><div class="phdr"><img src="/images/subfldr.png" width="16" height="16" class="left"/>&nbsp;<b>Last Forum Upload</b></div>';
$req = $db->query("SELECT * FROM `cms_forum_files` ORDER BY `id` DESC LIMIT 6");
$i = 0;
while($file = $req->fetch()) {
echo ($i % 2) ? '<div class="list2">' : '<div class="list1">';
$path = $file['filename'];
$fls = round(@filesize('../files/forum/attach/' . $path) / 1024, 2);
if (empty($systemUser->id) || $systemUser->ban['1'] || $systemUser->ban['12'] || $systemUser->ban['11']) {
echo '<img src="/images/lock.png" align="left" alt="attach"/>&#160;<span class="red">For authorized only..!!</span>';
}
elseif ($systemUser['postforum'] < $config['puf']) {
echo '<img src="/images/attach.png" align="left" alt="file"/>&#160;Required ' . $config['puf'] . ' post forum';
} else {
echo '<img src="/images/attach.png" align="left" alt="'.$file['id'].'"/>&#160;<a href="../forum/index.php?act=file&id='.$file['id'].'">'.$file['filename'].'</a>';
}
echo '</div>';
++$i;
}
echo '</div>';
/*
-----------------------------------------------------------------
Masterscliq Statistic
-----------------------------------------------------------------
*/
if (!$systemUser->isValid() || ($systemUser->id && $config->mod_fstat != 0)) {
$total_cat = $db->query("SELECT COUNT(*) FROM `forum` WHERE `type` = 'f'")->fetchColumn();
$total_sub = $db->query("SELECT COUNT(*) FROM `forum` WHERE `type` = 'r'")->fetchColumn();
$total_thm = $db->query("SELECT COUNT(*) FROM `forum` WHERE `type` = 't'")->fetchColumn();
$total_msg = $db->query("SELECT COUNT(*) FROM `forum` WHERE `type` = 'm'")->fetchColumn();
$total_files = $db->query("SELECT COUNT(*) FROM `cms_forum_files`")->fetchColumn();
echo '<div class="mainblok"><div class="phdr"><img src="../images/rate.gif" width="16" height="16" class="left"/>&nbsp;<b>' . _t('Statistics') . '</b></div><div class="menu">' .
'<font  style="color:#3399ff">&bull;</font>&#160;Total categories:&#160;<span class="red">' . $total_cat . '</span><br/>' .
'<font  style="color:#3399ff">&bull;</font>&#160;Total sections:&#160;<span class="red">' . $total_sub . '</span><br/>' .
'<font  style="color:#3399ff">&bull;</font>&#160;Total threads:&#160;<span class="red">' . $total_thm . '</span><br/>' .
'<font  style="color:#3399ff">&bull;</font>&#160;Total post:&#160;<span class="red">' . $total_msg . '</span><br/>' .
'<font  style="color:#3399ff">&bull;</font>&#160;Total files:&#160;<span class="red">' . $total_files . '</span></div>';
echo '</div>';
}

/*
-----------------------------------------------------------------
Masterscliq Online members
-----------------------------------------------------------------
*/
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();
echo '<div class="mainblok"><div class="phdr"><img src="/images/memb.png" width="16" height="16" class="left"/>&#160;<b>Whats going on..</b></a></div>';
$online = $_GET['online'];
echo '<div class="bmenu" id="online" name="online">'.($online ? '<a href="' . $_SERVER['HTTP_REFERER'] . '#online">Online</a>' : '<b>Online</b>').' <font  style="color:#3399ff">&bull;</font> '.($online == '24h' ? '<b>History</b>' : '<a href="index.php?online=24h#online">History</a>').' <font  style="color:#3399ff">&bull;</font> <b>Guest on</b>&#160;';
if ($guests >= 1)
echo '<a href="' . $config['homeurl'] . '/users/index.php?act=online&amp;mod=guest"><span class="red">' . $guests . '</a></span>';
else
echo '<span class="red">0..</a></span>';
echo '</div>';
echo '<div class="list1">Members:&#160;<a href="../users/index.php">' . $counters->users() . ' </a><br/><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 'Currently:&#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 'Active Member:&#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><br/>';
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 'Birthday members:&#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'] . '/users/profile.php?user='.$res['id'].'">'.$res['name'].'</a>, ';
}
}
if ($total) {
echo '<br/>';
} 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 'New Joined Member:&#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'] . '/users/profile.php?user=' . $arr['id'] . '"><font color="blue">'.$arr['name'] .'</font></a>';
}
if ($systemUser->isValid() || $config['active']) {
echo '<form action="' . $config['homeurl'] . '/users/?act=setskin" method="post" >' .
'Theme options:<br><select name="skin">';
foreach (glob(ROOT_PATH . 'theme/*/*.css') as $val) {
$dir = explode('/', dirname($val));
$theme = array_pop($dir);
echo '<option' . ($systemUser->getConfig()->skin == $theme ? ' selected="selected">' : '>') . $theme . '</option>';
}
echo '</select>' .
'<input type="submit" name="submit" value="Change Design"/></form></div>';
}

$konga = '<script type="text/javascript" src="http://konga.postaffiliatepro.com/scripts/banner.php?k_id=adepeter&k_bid=2425b517"></script>';
echo '<div class="mainblok"><div class="phdr">Online Shopping Agent</div>';
echo '<div class="gmenu"><a rel="nofollow" href="http://www.konga.com?utm_source=VerifiedBlogger"><img src="http://www.konga.com/blog/wp-content/uploads/2015/08/VerifiedBlogger.png" alt="Konga Verified Blogger" width="200px"/></a></div>';
echo '<div class="gmenu">' . $konga . '</div>';


echo '</div>';
?>