Example #1
0
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;
    }
}
Example #2
0
			div.note {
				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 "&emsp;<div class='note'>\"" . $n['notif'] . "\"</div>";
    echo "</td></tr>";
}
<html>
<head>
	<title></title>
</head>
<body>
<?php 
$email = $_POST["email"];
$password = $_POST["password"];
$confirmPassword = $_POST["confirmPassword"];
$passwordHash = sha1($password);
if ($password !== $confirmPassword) {
    echo "Passwords do not match kindly go back and re enter.";
} else {
    try {
        require_once 'conf.php';
        $conn = mysqlConnector();
        $sth = $conn->prepare("SELECT * FROM user_data WHERE userEmail='{$email}'");
        $sth->execute();
        $result = $sth->fetch(PDO::FETCH_OBJ);
        $targetEmail = $result->userEmail;
        if ($targetEmail == $email) {
            echo "Sorry this email id/username is already registered! ";
        } else {
            $path = "/var/lib/openshift/52106d8ce0b8cd5b44000013/app-root/data/" . $email;
            mkdir($path, 0777, true);
            $query = "INSERT INTO user_data(userEmail,userPassword) VALUES('{$email}' , '{$passwordHash}' )";
            if ($updateDb = $conn->query($query) or die($conn->error)) {
                echo "Congrats! <a href=\"index.php\" > Go back to home and login </a> ! ";
            }
        }
    } catch (PDOException $e) {