function setSession() { if (!isset($_SESSION)) { session_start(); } if (!isset($_SESSION['top_friends'])) { $facebook = fbInit(); $user = $facebook->getUser(); $accessToken = $facebook->getAccessToken(); $logoutUrl = $facebook->getLogoutUrl(array('next' => 'logout.html')); $params = array('method' => 'fql.query', 'query' => 'SELECT uid, pic_square, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY mutual_friend_count DESC LIMIT 100'); $_SESSION['top_friends'] = $facebook->api($params); shuffle($_SESSION['top_friends']); } if (!isset($_SESSION['tfIDs'])) { $_SESSION['tfIDs'] = array(); foreach ($_SESSION['top_friends'] as $t) { array_push($_SESSION['tfIDs'], $t['uid']); } } if (!isset($_SESSION['comments'])) { $db = mysqlConnector(); $csvFs = implode("','", $_SESSION['tfIDs']); $sql = "SELECT * FROM `comments` WHERE `to` IN ('" . $csvFs . "')"; $statement = $db->prepare($sql); $statement->execute(); $_SESSION['comments'] = $statement->fetchAll(); shuffle($_SESSION['comments']); } if (!isset($_SESSION['playCount'])) { $_SESSION['playCount'] = 1; } if (!isset($_SESSION['i'])) { $_SESSION['i'] = 0; } }
font-style:italic; } td.reftd { right:0px; width:40px; } </style> </head> <body> <h2>Notifications</h2> <?php require '../lib/setters.php'; require '../lib/facebook.php'; $db = mysqlConnector(); $facebook = fbInit(); $user = $facebook->getUser(); $sql = "SELECT * FROM notifications WHERE user_id='" . $user . "' ORDER BY id DESC LIMIT 30"; $statement = $db->prepare($sql); $statement->execute(); $notes = $statement->fetchAll(); echo "<table border=0 cellpadding=25 width=600><tr><td>"; echo "<input type='button' value='Clear new notifications' onclick=\"location.href='clearNotifs.php?last=" . $notes[0]['id'] . "&user="******"'\" style='width:250px;height:45px;'/>"; echo "<td class='reftd'><button><a href='notifications.php'><img height=40 width=40 src='../images/refresh.png'></a></button></td></t>"; foreach ($notes as $n) { echo "<tr class=" . ($n['read'] == 0 ? "unread" : "read") . "><td colspan='2'>"; echo "<div class='head'>" . $n['header'] . "</div>"; echo " <div class='note'>\"" . $n['notif'] . "\"</div>"; echo "</td></tr>"; } echo "</table>";