Beispiel #1
0
function PageMain()
{
    global $TMPL, $LNG, $CONF, $db, $loggedIn, $settings;
    if (isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
        $verify = $loggedIn->verify();
        if (empty($verify['username'])) {
            // If fake cookies are set, or they are set wrong, delete everything and redirect to home-page
            $loggedIn->logOut();
            header("Location: " . $CONF['url'] . "/index.php?a=welcome");
        } else {
            // Start displaying the Feed
            $feed = new feed();
            $feed->db = $db;
            $feed->url = $CONF['url'];
            $feed->user = $verify;
            $feed->id = $verify['idu'];
            $feed->username = $verify['username'];
            $feed->per_page = $settings['perpage'];
            $feed->time = $settings['time'];
            $feed->censor = $settings['censor'];
            $feed->smiles = $settings['smiles'];
            $feed->c_per_page = $settings['cperpage'];
            $feed->c_start = 0;
            $feed->l_per_post = $settings['lperpost'];
            $feed->online_time = $settings['conline'];
            $feed->friends_online = $settings['ronline'];
            $feed->subscriptionsList = $feed->getSubs($verify['idu'], 0);
            $feed->subscribersList = $feed->getSubs($verify['idu'], 1);
            $feed->updateStatus($verify['offline']);
            // Useed in timeline javascript which checks for new messages
            $TMPL['subs'] = 1;
            $TMPL_old = $TMPL;
            $TMPL = array();
            $skin = new skin('shared/rows');
            $rows = '';
            if (empty($_GET['filter'])) {
                $_GET['filter'] = '';
            }
            // Allowed types
            list($timeline, $message) = $feed->getFeed(0, $_GET['filter']);
            $TMPL['messages'] = $timeline;
            $rows = $skin->make();
            $skin = new skin('feed/sidebar');
            $sidebar = '';
            $TMPL['editprofile'] = $feed->fetchProfileWidget($verify['username'], realName($verify['username'], $verify['first_name'], $verify['last_name']), $verify['image']);
            $TMPL['sidebar'] = $feed->sidebarTypes($_GET['filter'], $feed->subscriptions);
            $TMPL['dates'] = $feed->sidebarDates($_GET['filter'], $feed->subscriptions);
            $TMPL['trending'] = $feed->sidebarTrending($_GET['tag'], 5);
            $TMPL['users'] = $feed->onlineUsers();
            $TMPL['subscriptions'] = $feed->sidebarSubs(0, 0);
            $TMPL['subscribers'] = $feed->sidebarSubs(1, 0);
            $TMPL['friendsactivity'] = $feed->sidebarFriendsActivity(20, 1);
            if (count($feed->subscriptionsList[0]) < 6) {
                $TMPL['suggestions'] = $feed->sidebarSuggestions();
            }
            $TMPL['ad'] = generateAd($settings['ad3']);
            $sidebar = $skin->make();
            $skin = new skin('shared/top');
            $top = '';
            // $TMPL['top'] = $feed->getForm();
            $TMPL['theme_url'] = $CONF['theme_url'];
            $TMPL['private_message'] = $verify['privacy'];
            $TMPL['avatar'] = $verify['image'];
            $TMPL['url'] = $CONF['url'];
            $top = $skin->make();
            $TMPL = $TMPL_old;
            unset($TMPL_old);
            $TMPL['top'] = $top;
            $TMPL['rows'] = $rows;
            $TMPL['sidebar'] = $sidebar;
            // If the username input string is an e-mail, switch the query
            if (isset($_SESSION['username'])) {
                if (filter_var($_SESSION['username'], FILTER_VALIDATE_EMAIL)) {
                    $result = $db->query("SELECT * FROM `users` WHERE `email` = '" . $_SESSION['username'] . "' AND `password` = '" . $_SESSION['password'] . "'");
                } else {
                    $result = $db->query("SELECT * FROM `users` WHERE `username` = '" . $_SESSION['username'] . "' AND `password` = '" . $_SESSION['password'] . "'");
                }
            } elseif (isset($_COOKIE['username'])) {
                if (filter_var($_COOKIE['username'], FILTER_VALIDATE_EMAIL)) {
                    $result = $db->query("SELECT * FROM `users` WHERE `email` = '" . $_COOKIE['username'] . "' AND `password` = '" . $_COOKIE['password'] . "'");
                } else {
                    $result = $db->query("SELECT * FROM `users` WHERE `username` = '" . $_COOKIE['username'] . "' AND `password` = '" . $_COOKIE['password'] . "'");
                }
            }
            while ($row = $result->fetch_assoc()) {
                $status = $row['status'];
            }
            if ($status == 0) {
                header("Location: " . $CONF['url'] . "/index.php?a=contact");
            } elseif ($status == 1) {
                header("Location: " . $CONF['url'] . "/index.php?a=employee");
            }
        }
    } else {
        // If the session or cookies are not set, redirect to home-page
        header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    if (isset($_GET['logout']) == 1) {
        $loggedIn->logOut();
        header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    $TMPL['url'] = $CONF['url'];
    $TMPL['title'] = $LNG['title_feed'] . ' - ' . $settings['title'];
    $skin = new skin('shared/timeline');
    return $skin->make();
}
Beispiel #2
0
 function embedStats($id)
 {
     global $LNG;
     // Get the likes, views, and other info
     $query = sprintf("SELECT `id`,`uid`, `buy`, `public`, `likes`, `downloads`, `views` FROM `tracks` WHERE `id` = '%s'", $this->db->real_escape_string($id));
     // Run the query
     $result = $this->db->query($query);
     // Get the array element for the like
     $get = $result->fetch_assoc();
     if ($this->l_per_post) {
         $query = sprintf("SELECT * FROM `likes`,`users` WHERE `likes`.`track` = '%s' and `likes`.`by` = `users`.`idu` ORDER BY `likes`.`id` DESC LIMIT %s", $this->db->real_escape_string($id), $this->db->real_escape_string($this->l_per_post));
         $result = $this->db->query($query);
         while ($row = $result->fetch_assoc()) {
             $array[] = $row;
         }
         // Define the $people who liked variable
         $people = '';
         foreach ($array as $row) {
             $people .= '<a href="' . $this->url . '/index.php?a=profile&u=' . $row['username'] . '" target="_blank"><img src="' . $this->url . '/thumb.php?src=' . $row['image'] . '&w=25&h=25&t=a" title="' . realName($row['username'], $row['first_name'], $row['last_name']) . ' ' . $LNG['liked_this'] . '" /></a> ';
         }
     }
     $getComments = $this->db->query(sprintf("SELECT COUNT(*) FROM `comments` WHERE `tid` = '%s'", $this->db->real_escape_string($id)));
     $comments = $getComments->fetch_row();
     $url = $this->url . '/index.php?a=track&id=' . $id;
     // Actions
     $views_stats = $get['views'] ? '<div class="counter views_counter" title="' . sprintf($LNG['listened_x_times'], $get['views']) . '">' . $get['views'] . '</div>' : '';
     $comments_stats = $comments[0] ? '<div class="counter comments_counter" title="' . $comments[0] . ' ' . $LNG['comments'] . '">' . $comments[0] . '</div>' : '';
     $likes_stats = $get['likes'] ? '<div class="counter like_btn" id="like_btn' . $id . '" title="' . $get['likes'] . ' ' . $LNG['likes'] . '">' . $get['likes'] . '</div>' : '';
     $downloads_stats = $get['downloads'] ? '<div class="counter downloads_counter" title="' . sprintf($LNG['downloaded_x_times'], $get['downloads']) . '">' . $get['downloads'] . '</div>' : '';
     // Output variable
     $actions = '<div class="track-likes" id="users_likes' . $id . '" style="' . (empty($people) ? 'margin: 0;' : '') . '">' . $people . '<a href="' . $this->url . '/index.php?a=track&id=' . $id . '" target="_blank"><div class="track-stats">' . $views_stats . $comments_stats . $likes_stats . $downloads_stats . '</div></a></div>';
     return $actions;
 }
Beispiel #3
0
function PageMain()
{
    global $TMPL, $LNG, $CONF, $db, $loggedIn, $settings;
    $_GET['u'] = htmlspecialchars($_GET['u']);
    if (isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
        $verify = $loggedIn->verify();
        if (empty($verify['username'])) {
            // If fake cookies are set, or they are set wrong, delete everything and redirect to home-page
            $loggedIn->logOut();
            header("Location: " . $CONF['url'] . "/index.php?a=welcome");
        }
        // If the $_GET user is empty, define default user as current logged in user, else redirect to home-page
        if ($_GET['u'] == '') {
            $_GET['u'] = !empty($verify['username']) ? $verify['username'] : header("Location: " . $CONF['url'] . "/index.php?a=welcome");
        }
    }
    // Start displaying the Feed
    $feed = new feed();
    $feed->db = $db;
    $feed->url = $CONF['url'];
    $feed->user = $verify;
    $feed->id = $verify['idu'];
    $feed->username = $verify['username'];
    $feed->per_page = $settings['perpage'];
    $feed->categories = $feed->getCategories();
    $feed->time = $settings['time'];
    $feed->c_per_page = $settings['cperpage'];
    $feed->c_start = 0;
    $feed->l_per_post = $settings['lperpost'];
    if ($verify['username']) {
        $feed->updateStatus($verify['offline']);
    }
    // If the $_GET user is empty, define default user as current logged in user, else redirect to home-pag
    if ($_GET['u'] == '') {
        $_GET['u'] = !empty($feed->username) ? $feed->username : header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    $feed->profile = $_GET['u'];
    $feed->profile_data = $feed->profileData($_GET['u']);
    $feed->subscriptionsList = $feed->getSubs($feed->profile_data['idu'], 0, null);
    $feed->subscribersList = $feed->getSubs($feed->profile_data['idu'], 1, null);
    $TMPL_old = $TMPL;
    $TMPL = array();
    $skin = new skin('shared/rows');
    $rows = '';
    if (empty($_GET['filter'])) {
        $_GET['filter'] = '';
    }
    // Allowed types
    list($timeline, $message) = $feed->getProfile(0, $_GET['filter']);
    if ($_GET['r'] == 'subscriptions') {
        if ($message !== 1) {
            $feed->s_per_page = $settings['sperpage'];
            $feed->subsList = $feed->getSubs($feed->profile_data['idu'], 0, 0);
            $TMPL['messages'] = $feed->listSubs(0);
        } else {
            $TMPL['messages'] = $timeline;
        }
        $title = $LNG['subscriptions'];
    } elseif ($_GET['r'] == 'subscribers') {
        if ($message !== 1) {
            $feed->s_per_page = $settings['sperpage'];
            $feed->subsList = $feed->getSubs($feed->profile_data['idu'], 1, 0);
            $TMPL['messages'] = $feed->listSubs(1);
        } else {
            $TMPL['messages'] = $timeline;
        }
        $title = $LNG['subscribers'];
    } elseif ($_GET['r'] == 'likes') {
        if ($message !== 1) {
            $likes = $feed->getLikes(0, 1);
            $TMPL['messages'] = $likes[0];
        } else {
            $TMPL['messages'] = $timeline;
        }
        $title = $LNG['likes'];
    } elseif ($_GET['r'] == 'playlists') {
        if ($message !== 1) {
            $TMPL['messages'] = $feed->getPlaylists(0, 1);
        } else {
            $TMPL['messages'] = $timeline;
        }
        $title = $LNG['playlists'];
    } else {
        $TMPL['messages'] = $timeline;
    }
    $rows = $skin->make();
    $skin = new skin('profile/sidebar');
    $sidebar = '';
    // If the username doesn't exist
    if ($message !== 1) {
        $TMPL['about'] = $feed->fetchProfileInfo($feed->profileData($_GET['u']));
        $TMPL['dates'] = $feed->sidebarDates($_GET['filter'], 'profile');
        $TMPL['ad'] = generateAd($settings['ad4']);
    } else {
        $skin = new skin('profile/sidebar');
        $sidebar = '';
        $TMPL['ad'] = generateAd($settings['ad4']);
    }
    $sidebar = $skin->make();
    $TMPL = $TMPL_old;
    unset($TMPL_old);
    $TMPL['rows'] = $rows;
    $TMPL['sidebar'] = $sidebar;
    $TMPL['cover'] = $feed->fetchProfile($feed->profile_data);
    if (isset($_GET['logout']) == 1) {
        $loggedIn->logOut();
        header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    $TMPL['url'] = $CONF['url'];
    $TMPL['title'] = (!empty($title) ? $title : $LNG['title_profile']) . ' - ' . realName($_GET['u'], $feed->profile_data['first_name'], $feed->profile_data['last_name'], 1) . ' - ' . $settings['title'];
    $TMPL['meta_description'] = realName($_GET['u'], $feed->profile_data['first_name'], $feed->profile_data['last_name'], 1) . ' ' . $feed->profile_data['description'];
    $skin = new skin('shared/content');
    return $skin->make();
}
function PageMain()
{
    global $TMPL, $LNG, $CONF, $db, $loggedIn, $settings;
    if (isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
        $verify = $loggedIn->verify();
        if (empty($verify['username'])) {
            // If fake cookies are set, or they are set wrong, delete everything and redirect to home-page
            $loggedIn->logOut();
            header("Location: " . $CONF['url'] . "/index.php?a=welcome");
        } else {
            // Start displaying the Feed
            $feed = new feed();
            $feed->db = $db;
            $feed->url = $CONF['url'];
            $feed->user = $verify;
            $feed->id = $verify['idu'];
            $feed->username = $verify['username'];
            $feed->per_page = $settings['perpage'];
            $feed->time = $settings['time'];
            $feed->censor = $settings['censor'];
            $feed->smiles = $settings['smiles'];
            $feed->c_per_page = $settings['cperpage'];
            $feed->c_start = 0;
            $feed->l_per_post = $settings['lperpost'];
            $feed->online_time = $settings['conline'];
            $feed->friends_online = $settings['ronline'];
            $feed->subscriptionsList = $feed->getSubs($verify['idu'], 0);
            $feed->subscribersList = $feed->getSubs($verify['idu'], 1);
            $feed->updateStatus($verify['offline']);
            $TMPL['uid'] = $verify['idu'];
            $TMPL_old = $TMPL;
            $TMPL = array();
            $skin = new skin('shared/rows');
            $rows = '';
            if (empty($_GET['filter'])) {
                $_GET['filter'] = '';
            }
            // Allowed types
            list($timeline, $message) = $feed->getTimeline(0, $_GET['filter']);
            $TMPL['messages'] = $timeline;
            $rows = $skin->make();
            $skin = new skin('timeline/sidebar');
            $sidebar = '';
            $TMPL['editprofile'] = $feed->fetchProfileWidget($verify['username'], realName($verify['username'], $verify['first_name'], $verify['last_name']), $verify['image']);
            $TMPL['sidebar'] = $feed->sidebarTypes($_GET['filter'], 'timeline');
            $TMPL['dates'] = $feed->sidebarDates($_GET['filter'], 'timeline');
            $TMPL['trending'] = $feed->sidebarTrending($_GET['tag'], 5);
            $TMPL['users'] = $feed->onlineUsers();
            $TMPL['subscriptions'] = $feed->sidebarSubs(0, 0);
            $TMPL['subscribers'] = $feed->sidebarSubs(1, 0);
            $TMPL['friendsactivity'] = $feed->sidebarFriendsActivity(20, 1);
            if (count($feed->subscriptionsList[0]) < 6) {
                $TMPL['suggestions'] = $feed->sidebarSuggestions();
            }
            $TMPL['ad'] = generateAd($settings['ad2']);
            $sidebar = $skin->make();
            $skin = new skin('shared/top');
            $top = '';
            // $TMPL['top'] = $feed->getForm();
            $TMPL['theme_url'] = $CONF['theme_url'];
            $TMPL['private_message'] = $verify['privacy'];
            $TMPL['avatar'] = $verify['image'];
            $TMPL['url'] = $CONF['url'];
            $top = $skin->make();
            $TMPL = $TMPL_old;
            unset($TMPL_old);
            $TMPL['top'] = $top;
            $TMPL['rows'] = $rows;
            $TMPL['sidebar'] = $sidebar;
        }
    } else {
        // If the session or cookies are not set, redirect to home-page
        header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    if (isset($_GET['logout']) == 1) {
        $loggedIn->logOut();
        header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    $TMPL['url'] = $CONF['url'];
    $TMPL['title'] = $LNG['title_timeline'] . ' - ' . $settings['title'];
    $skin = new skin('shared/timeline');
    return $skin->make();
}
Beispiel #5
0
 function outputBlocked($id, $profile, $state)
 {
     global $LNG;
     if ($state) {
         $x = '<span class="class="unblock-button""><a onclick="doBlock(' . $id . ', 1)" title="Unblock ' . realName($profile['username'], $profile['first_name'], $profile['last_name']) . '">' . $LNG['unblock'] . '</a></span>';
     } else {
         $x = '<a onclick="doBlock(' . $id . ', 1)" title="Block ' . realName($profile['username'], $profile['first_name'], $profile['last_name']) . '">' . $LNG['block'] . '</a>';
     }
     return $x;
 }
function menu($user)
{
    global $CONF, $settings, $LNG;
    if ($user !== false) {
        // If the result is not 0 (int) then show the menu
        return '
		<a href="' . $CONF['url'] . '/index.php?a=feed&logout=1"><div class="menu_btn tooltipz" data-title="' . $LNG['log_out'] . '"><img src="' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/logout.png" /></div></a>
		<a onclick="showNotification(\'\', \'1\')"><div class="menu_btn tooltipz" id="notifications_btn" data-title="' . $LNG['title_notifications'] . '"><img src="' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/notification.png" id="notifications_img" /></div></a>
		<a href="' . $CONF['url'] . '/index.php?a=messages" id="messages_url"><div class="menu_btn tooltipz" id="messages_btn" data-title="' . $LNG['title_messages'] . '"><img src="' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/message.png" /></div></a>
		<a href="' . $CONF['url'] . '/index.php?a=timeline"><div class="menu_btn tooltipz" data-title="' . $LNG['title_timeline'] . '"><img src="' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/timeline.png" /></div></a>
		<a href="' . $CONF['url'] . '/index.php?a=feed"><div class="menu_btn tooltipz" data-title="' . $LNG['title_feed'] . '"><img src="' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/feed.png" /></div></a>
        <a href="' . $CONF['url'] . '/index.php?a=directory"><div class="menu_btn tooltipz" data-title="Directory"><img src="' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/dir.png" /></div></a>
		<a href="' . $CONF['url'] . '/index.php?a=profile&u=' . $user['username'] . '"><div class="menu"><div class="menu_img"><img src="' . $CONF['url'] . '/thumb.php?src=' . $user['image'] . '&t=a&w=50&h=50" /></div><div class="menu_name"><strong>' . realName($user['username'], $user['first_name'], $user['last_name']) . '</strong></div></div></a>
		<div class="notification-container">
			<div class="notification-content">
				<div class="notification-inner">
					<span id="global_page_url"><a href="' . $CONF['url'] . '/index.php?a=notifications"><strong>' . $LNG['view_all_notifications'] . '</strong></a></span>
					<span id="chat_page_url"><a href="' . $CONF['url'] . '/index.php?a=notifications&filter=chats"><strong>' . $LNG['view_chat_notifications'] . '</strong></a></span>
					<a onclick="showNotification(\'close\')" title="' . $LNG['close_notifications'] . '"><div class="delete_btn"></div></a>
				</div>
				<div id="notifications-content"></div>
				<div class="notification-row"><div class="notification-padding"><a href="' . $CONF['url'] . '/index.php?a=settings&b=notifications">' . $LNG['notifications_settings'] . '</a></div></div>
			</div>
		</div>
		<script type="text/javascript">
		function checkNewNotifications(x) {
			// Retrieve the current notification values
			xy = $("#notifications_btn .notifications-number").html();
			xz = $("#messages_btn .notifications-number").html();
			
			// If there are not current values, reset them to 0
			if(!xy) {
				xy = 0;
			}
			if(!xz) {
				xz = 0;
			}
			$.ajax({
				type: "POST",
				url: "' . $CONF['url'] . '/requests/check_notifications.php",
				data: "for=1",
				success: function(html) {
					// If the response does not include "No notifications" and is not empty show the notification
					if(html.indexOf("' . $LNG['no_notifications'] . '") == -1 && html !== "" && html !== "0") {
						result = jQuery.parseJSON(html);
						if(result.response.global > 0) {
							$("#notifications_btn").html(getNotificationImage()+"<span class=\\"notificatons-number-container\\"><span class=\\"notifications-number\\">"+result.response.global+"</span></span>");
						} else {
							$("#notifications_btn").html(getNotificationImage());
						}
						if(result.response.messages > 0) {
							$("#messages_btn").html(getMessagesImageUrl(1)+"<span class=\\"notificatons-number-container\\"><span class=\\"notifications-number\\">"+result.response.messages+"</span></span>");
							$("#messages_url").attr("onclick", "showNotification(\'\', \'2\')");
							$("#messages_url").removeAttr("href");
						} else {
							$("#messages_btn").html(getMessagesImageUrl(1));
							$("#messages_url").removeAttr("onclick");
							$("#messages_url").attr("href", getMessagesImageUrl());
						}
						
						// If the new value is higher than the current one, and the current one is not equal to 0

						if(result.response.global > xy && xy != 0 || result.response.global == 1 && xy == 0) {
							checkAlert();
						} else if(result.response.messages > xz && xz != 0 || result.response.messages == 1 && xz == 0) {
							checkAlert();
						}
					}
					stopNotifications = setTimeout(checkNewNotifications, ' . $settings['intervaln'] . ');
			   }
			});
		}
		checkNewNotifications();
		
		function checkAlert() {
			if(!document.hasFocus()) {						
				// If the current document title doesn\'t have an alert, add one
				if(document.title.indexOf("(!)") == -1) {
					document.title = "(!) " + document.title;
				}
				notificationTitle(2);
			}
		}
		function getNotificationImage() {
			return "<img src=\\"' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/notification.png\\" />";
		}
		function getMessagesImageUrl(x) {
			if(x) {
				return "<img src=\\"' . $CONF['url'] . '/' . $CONF['theme_url'] . '/images/message.png\\" />";
			} else {
				return "' . $CONF['url'] . '/index.php?a=messages";
			}
		}
		
		</script>' . audioContainer('Notification', $user['sound_new_notification']);
    } else {
        // Else show the LogIn Register button
        return '
		
		<a href="' . $CONF['url'] . '/index.php?a=verify"><div class="menu_visitor"><strong>Sign Up</strong></div></a>
		<a href="' . $CONF['url'] . '/index.php?a=directory"><div class="menu_visitor"><strong>Directory</strong></div></a>';
    }
}
    function dirgetUsers($start)
    {
        global $LNG;
        // If the $start value is 0, empty the query;
        if ($start == 0) {
            $start = '';
        } else {
            // Else, build up the query
            $start = 'WHERE `idu` < \'' . $this->db->real_escape_string($start) . '\'';
        }
        // Query the database and get the latest 20 users
        // If load more is true, switch the query for the live query
        $query = sprintf("SELECT * FROM `users` %s ORDER BY `idu` DESC LIMIT %s", $start, $this->db->real_escape_string($this->per_page + 1));
        $result = $this->db->query($query);
        while ($row = $result->fetch_assoc()) {
            $rows[] = $row;
        }
        if (array_key_exists($this->per_page, $rows)) {
            $loadmore = 1;
            // Unset the last array element because it's not needed, it's used only to predict if the Load More Messages should be displayed
            array_pop($rows);
        }
        $users = '';
        // Define the rows variable
        foreach ($rows as $row) {
            if ($row['course'] == 'btech') {
                $course = 'Bachelor Of Technology';
            } elseif ($row['course'] == 'mca') {
                $course = 'Master of Computer Applications';
            } elseif ($row['course'] == 'mba') {
                $course = 'Master of Business Administration"';
            }
            if ($row['branch'] == 'ece') {
                $branch = 'Electronics and Communication Engineering';
            } elseif ($row['branch'] == 'cse') {
                $branch = 'Computer Science Engineering';
            } elseif ($row['branch'] == 'mae') {
                $branch = 'Mechanical and Automation Engineering';
            } elseif ($row['branch'] == 'eee') {
                $branch = 'Electrical and Electronics Engineering';
            } elseif ($row['branch'] == 'it') {
                $branch = 'Information and Technology';
            } elseif ($row['branch'] == 'ce') {
                $branch = 'Civil Engineering';
            } elseif ($row['branch'] == 'ene') {
                $branch = 'Environmental Engineering';
            }
            $usera = '
				<div class="pin">
					<div id="dir-card">
				<div class="dir-card-cover"><img src="' . $this->url . '/thumb.php?src=' . (!empty($row['cover']) ? $row['cover'] : 'default.png') . '&w=900&h=300&t=c"></div>
			<div class="dir-card-avatar">
				<a href="' . $this->url . '/' . $row['username'] . '"><img src="' . $this->url . '/thumb.php?src=' . (!empty($row['image']) ? $row['image'] : 'default.png') . '&t=a&w=112&h=112" /></a>
			</div>
			<div class="dir-card-info">
				<a href="' . $this->url . '/' . $row['username'] . '"><span id="author' . $row['idu'] . $row['username'] . '"></span><span id="time' . $row['idu'] . $row['username'] . '"></span><div class="cover-username">' . realName($row['username'], $row['first_name'], $row['last_name']) . '' . (!empty($row['verified']) ? '<img src="' . $this->url . '/themes/skins/images/icons/verified.png" title="' . $LNG['verified_user'] . '" />' : '') . '</div></a>
			</div><div class="dir-card-divider"></div>
			' . (!empty($row['course']) ? '<div class="dir-card-bio">' . $course . '<br>' . (!empty($row['branch']) ? $branch : '') . '<br>' . (!empty($row['join']) ? $row['join'] : '') . '</div>' : '') . '</div></div>';
            $users .= str_replace('"', '\'', $usera);
            $last = $row['idu'];
        }
        if ($loadmore) {
            $users .= "<div class='show-more'><div class='admin-load-more'><div class='message-container' id='more_dirusers'>\n\t\t\t\t\t<div class='load_more' id='" . $last . "'><a onclick='manage_the_dir(" . $last . ")'>Load More</a>\t\t\t\t\n\t\t\t\t\t</div>\n\t\t\t\t</div></div></div>";
        }
        // Return the array set
        return $users;
    }
function PageMain()
{
    global $TMPL, $LNG, $CONF, $db, $loggedIn, $settings;
    if (isset($_SESSION['username']) && isset($_SESSION['password']) || isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
        $verify = $loggedIn->verify();
        if (empty($verify['username'])) {
            // If fake cookies are set, or they are set wrong, delete everything and redirect to home-page
            $loggedIn->logOut();
            header("Location: " . $CONF['url'] . "/index.php?a=welcome");
        } else {
            // Start displaying the Feed
            $feed = new feed();
            $feed->db = $db;
            $feed->url = $CONF['url'];
            $feed->username = $verify['username'];
            $feed->id = $verify['idu'];
            $feed->per_page = $settings['perpage'];
            $feed->time = $settings['time'];
            $feed->censor = $settings['censor'];
            $feed->smiles = $settings['smiles'];
            $feed->c_per_page = $settings['cperpage'];
            $feed->c_start = 0;
            $feed->subscriptionsList = $feed->getSubs($verify['idu'], 0);
            $feed->subscribersList = $feed->getSubs($verify['idu'], 1);
            // $feed->image = $verify['image'];
            $TMPL['uid'] = $verify['idu'];
            $TMPL_old = $TMPL;
            $TMPL = array();
            $skin = new skin('shared/rows');
            $rows = '';
            if (empty($_GET['filter'])) {
                $_GET['filter'] = '';
            }
            // Allowed types
            if ($_GET['filter'] == 'likes') {
                $x = $feed->checkNewNotifications($settings['nperpage'], 2, 2, 1, null, null, null, null);
            } elseif ($_GET['filter'] == 'comments') {
                $x = $feed->checkNewNotifications($settings['nperpage'], 2, 2, null, 1, null, null, null);
            } elseif ($_GET['filter'] == 'shared') {
                $x = $feed->checkNewNotifications($settings['nperpage'], 2, 2, null, null, 1, null, null);
            } elseif ($_GET['filter'] == 'friendships') {
                $x = $feed->checkNewNotifications($settings['nperpage'], 2, 2, null, null, null, 1, null);
            } elseif ($_GET['filter'] == 'chats') {
                $x = $feed->checkNewNotifications($settings['nperpage'], 2, 2, null, null, null, null, 1);
            } else {
                $x = $feed->checkNewNotifications($settings['nperpage'], 2, 2, 1, 1, 1, 1, 1);
            }
            $TMPL['messages'] = '<div class="message-container"><div class="message-content" id="notifications-page"><div style="margin-top:-1px;">' . $x . '</div></div></div>';
            $rows = $skin->make();
            $skin = new skin('feed/sidebar');
            $sidebar = '';
            $TMPL['editprofile'] = $feed->fetchProfileWidget($verify['username'], realName($verify['username'], $verify['first_name'], $verify['last_name']), $verify['image']);
            $TMPL['sidebar'] = $feed->sidebarNotifications($_GET['filter'], 'feed');
            $TMPL['subscriptions'] = $feed->sidebarSubs(0, 0);
            $TMPL['subscribers'] = $feed->sidebarSubs(1, 0);
            $TMPL['ad3'] = generateAd($settings['ad3']);
            $sidebar = $skin->make();
            $TMPL = $TMPL_old;
            unset($TMPL_old);
            $TMPL['rows'] = $rows;
            $TMPL['sidebar'] = $sidebar;
        }
    } else {
        // If the session or cookies are not set, redirect to home-page
        header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    if (isset($_GET['logout']) == 1) {
        $loggedIn->logOut();
        header("Location: " . $CONF['url'] . "/index.php?a=welcome");
    }
    $TMPL['url'] = $CONF['url'];
    $TMPL['title'] = $LNG['title_notifications'] . ' - ' . $settings['title'];
    $skin = new skin('shared/timeline');
    return $skin->make();
}