<?php if ($user_id) { $USER = getUserFromCache($user_id); } else { header('Location: ' . $baseurl . '#login'); exit; } if (!isset($USER)) { header('Location: ' . $baseurl); exit; } $is_admin = $USER['user_isadmin']; if (!$is_admin) { header('Location: ' . $baseurl); exit; } $PROFILE_PIC = $USER['user_pic'] ? $baseurl . '/images/user_pics/' . $USER['user_pic'] : $baseurl . "/images/avatar3.png"; $USERNAME = $USER['user_name'];
<?php require_once '../include/config.php'; require_once $basedir . "/include/functions.php"; require_once $basedir . '/include/user_functions.php'; if (!$user_id) { // go to login page header('Location: ' . $baseurl . '#login'); exit; } $categories = getCategories(); $user = getUserFromCache($user_id); $ppage = $user['user_privacy_page']; $presult = $user['user_privacy_result']; $settingsmenu = 'active'; $privacymenu = 'active'; ?> <!DOCTYPE HTML> <html> <?php include $basedir . '/common/header.php'; ?> <body> <?php include $basedir . '/common/head.php'; ?> <div class="container row">
function getActivities($user_id) { global $config, $lang, $suffix; $basedir = $config['basedir']; $baseurl = $config['baseurl']; $data = array(); $games = array(); $users = array(); $ret = array(); $max_rec = 10; $limit = 1; $q = "SELECT * FROM user_activities WHERE user_id = '{$user_id}' AND ua_seen = 0 ORDER BY ua_id DESC limit 0, {$max_rec}"; $result = mysql_query($q); $numrows = mysql_num_rows($result); if ($numrows) { while ($row = mysql_fetch_array($result)) { $data[] = $row; } if ($numrows < $max_rec) { $limit = $max_rec - $numrows; } } else { $limit = $max_rec; } $q = "SELECT * FROM user_activities WHERE user_id = '{$user_id}' AND ua_seen = 1 ORDER BY ua_id DESC limit 0, {$limit}"; $result = mysql_query($q); $numrows = mysql_num_rows($result); if ($numrows) { while ($row = mysql_fetch_array($result)) { $data[] = $row; } } $i = 0; $unseen = 0; foreach ($data as $d) { // 'like','unlike','withdraw','deposit','userfollow','bookmark','unbookmark','won','joinedgame','gamecancelled','changepass' $activity = $d['ua_activity']; switch ($activity) { case 'like': $g_id = $d['ua_fieldvalue']; $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id]; $game_title = $games[$g_id]['g_title' . $suffix]; if (strlen($game_title) > 30) { $game_title = substr($game_title, 0, 30) . '...'; } $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[419]); $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image']; $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id); break; case 'unlike': $g_id = $d['ua_fieldvalue']; $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id]; $game_title = $games[$g_id]['g_title' . $suffix]; if (strlen($game_title) > 30) { $game_title = substr($game_title, 0, 30) . '...'; } $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[427]); $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image']; $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id); break; case 'deposit': break; case 'userfollow': if ($d['ua_seen'] == 0) { $unseen++; } break; case 'bookmark': $g_id = $d['ua_fieldvalue']; $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id]; $game_title = $games[$g_id]['g_title' . $suffix]; if (strlen($game_title) > 30) { $game_title = substr($game_title, 0, 30) . '...'; } $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[428]); $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image']; $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id); break; case 'unbookmark': $g_id = $d['ua_fieldvalue']; $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id]; $game_title = $games[$g_id]['g_title' . $suffix]; if (strlen($game_title) > 30) { $game_title = substr($game_title, 0, 30) . '...'; } $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[429]); $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image']; $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id); break; case 'won': if ($d['ua_seen'] == 0) { $unseen++; } $g_id = $d['ua_fieldvalue']; $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id]; $game_title = $games[$g_id]['g_title' . $suffix]; if (strlen($game_title) > 30) { $game_title = substr($game_title, 0, 30) . '...'; } $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[430]); $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image']; $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id); break; case 'joinedgame': $g_id = $d['ua_fieldvalue']; $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id]; $game_title = $games[$g_id]['g_title' . $suffix]; if (strlen($game_title) > 30) { $game_title = substr($game_title, 0, 30) . '...'; } $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[431]); $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image']; $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id); break; case 'gamecancelled': if ($d['ua_seen'] == 0) { $unseen++; } $g_id = $d['ua_fieldvalue']; $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id]; $game_title = $games[$g_id]['g_title' . $suffix]; if (strlen($game_title) > 30) { $game_title = substr($game_title, 0, 30) . '...'; } $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[432]); $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image']; $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id); break; case 'changepass': $user_id = $d['user_id']; $users[$user_id] = !isset($users[$user_id]) ? getUserFromCache($user_id) : $users[$user_id]; $ret[$i]['message'] = $lang[434]; $ret[$i]['time'] = _timeSince($d['ua_date']); $ret[$i]['image'] = $baseurl . '/images/user_pics/' . $users[$user_id]['user_pic']; $ret[$i]['href'] = $baseurl . '/settings/password.php'; break; } $i++; } if ($ret) { return array('ret' => $ret, 'unseen' => $unseen); } else { return false; } //return $ret; }
<?php $activities = false; $unseen = 0; if ($user_id) { $user = isset($user) ? $user : getUserFromCache($user_id); $activities_array = getActivities($user_id); if ($activities_array) { $activities = $activities_array['ret']; $unseen = $activities_array['unseen']; } } $notifications = str_replace('$VAR', $unseen, $lang['433']); ?> <header role="banner" class="row"> <div class="container row"> <div class="col span_12"> <div class="site-title-group"> <h1 class="site-title"><a href="<?php echo $baseurl; ?> " title="<?php echo $config['site name']; ?> " rel="home"><?php echo $config['site name']; ?> </a></h1> </div><!-- .site-title-group -->