Marijn button #99
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
include_once("../../queries/private_message.php");
|
||||
session_start();
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/private_message.php");
|
||||
|
||||
if (isset($_POST["lastID"]) && $_POST["lastID"] != "") {
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
include_once("../../queries/private_message.php");
|
||||
session_start();
|
||||
require_once("../../queries/connect.php");
|
||||
require_once("../../queries/private_message.php");
|
||||
|
||||
if (isset($_POST["destination"]) &&
|
||||
isset($_POST["content"])) {
|
||||
|
||||
@@ -46,12 +46,12 @@ if(empty($_GET["username"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$userID = getUserID($db, $_GET["username"]);
|
||||
$userID = getUserID($_GET["username"]);
|
||||
|
||||
$user = selectUser($db, $userID);
|
||||
$friends = selectAllFriends($db, $userID);
|
||||
$groups = selectAllUserGroups($db, $userID);
|
||||
$posts = selectAllUserPosts($db, $userID);
|
||||
$user = selectUser($userID);
|
||||
$friends = selectAllFriends($userID);
|
||||
$groups = selectAllUserGroups($userID);
|
||||
$posts = selectAllUserPosts($userID);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
include_once("../queries/connect.php");
|
||||
include_once("../queries/friendship.php");
|
||||
|
||||
$friends = selectAllFriends($db, 666);
|
||||
$friends = selectAllFriends(666);
|
||||
while($friend = $friends->fetch(PDO::FETCH_ASSOC)) {
|
||||
echo $friend['username'].' '.$friend['onlinestatus'] . "<br />";
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
require("connect.php");
|
||||
|
||||
function selectAllFriends($db, $userID) {
|
||||
$stmt = $db->prepare("
|
||||
function selectAllFriends($userID) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`userID`,
|
||||
`username`,
|
||||
@@ -27,5 +26,6 @@ function selectAllFriends($db, $userID) {
|
||||
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
function selectAllGroupsFromUser($db, $userID) {
|
||||
return $db->query("
|
||||
function selectAllGroupsFromUser($userID) {
|
||||
return $GLOBALS["db"]->query("
|
||||
SELECT
|
||||
`group_page`.`name`,
|
||||
`group_page`.`picture`
|
||||
@@ -15,7 +15,3 @@ function selectAllGroupsFromUser($db, $userID) {
|
||||
`group_page`.`status` != 0
|
||||
");
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
function selectGroupById($db, $groupID) {
|
||||
return $db->query("
|
||||
function selectGroupById($groupID) {
|
||||
return $GLOBALS["db"]->query("
|
||||
SELECT
|
||||
`group_page`.`name`,
|
||||
`group_page`.`picture`,
|
||||
@@ -15,8 +15,8 @@ function selectGroupById($db, $groupID) {
|
||||
");
|
||||
}
|
||||
|
||||
function select20GroupsFromN($db, $n) {
|
||||
return $db->query("
|
||||
function select20GroupsFromN($n) {
|
||||
return $GLOBALS["db"]->query("
|
||||
SELECT
|
||||
`group_page`.`groupID`,
|
||||
`group_page`.`name`,
|
||||
@@ -33,8 +33,8 @@ function select20GroupsFromN($db, $n) {
|
||||
");
|
||||
}
|
||||
|
||||
function select20GroupsByStatusFromN($db, $n, $status) {
|
||||
return $db->query("
|
||||
function select20GroupsByStatusFromN($n, $status) {
|
||||
return $GLOBALS["db"]->query("
|
||||
SELECT
|
||||
`group_page`.`groupID`,
|
||||
`group_page`.`name`,
|
||||
@@ -53,8 +53,8 @@ function select20GroupsByStatusFromN($db, $n, $status) {
|
||||
");
|
||||
}
|
||||
|
||||
function search20GroupsFromNByStatus($db, $n, $keyword, $status) {
|
||||
$q = $db->prepare("
|
||||
function search20GroupsFromNByStatus($n, $keyword, $status) {
|
||||
$q = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`groupID`,
|
||||
`name`,
|
||||
@@ -80,8 +80,8 @@ function search20GroupsFromNByStatus($db, $n, $keyword, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
function changeGroupStatusByID($db, $id, $status) {
|
||||
$q = $db->query("
|
||||
function changeGroupStatusByID($id, $status) {
|
||||
$q = $GLOBALS["db"]->query("
|
||||
UPDATE
|
||||
`group_page`
|
||||
SET
|
||||
@@ -92,8 +92,3 @@ function changeGroupStatusByID($db, $id, $status) {
|
||||
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -13,8 +13,9 @@ function getHeaderInfo() {
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
|
||||
$stmt->bindParam(":userID", $_SESSION["userID"]);
|
||||
$stmt->execute();
|
||||
return $stmt->fetch();
|
||||
|
||||
return $stmt->fetch();
|
||||
}
|
||||
@@ -15,5 +15,3 @@ function hashPassword() {
|
||||
$stmt->execute();
|
||||
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
<?php
|
||||
|
||||
require_once("connect.php");
|
||||
|
||||
session_start();
|
||||
|
||||
function getOldChatMessages($user2ID) {
|
||||
$db = $GLOBALS["db"];
|
||||
$user1ID = $_SESSION["userID"];
|
||||
|
||||
$stmt = $db->prepare("
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
@@ -31,8 +26,7 @@ function getOldChatMessages($user2ID) {
|
||||
}
|
||||
|
||||
function sendMessage($destination, $content) {
|
||||
$db = $GLOBALS["db"];
|
||||
$stmt = $db->prepare("
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
INSERT INTO
|
||||
`private_message`
|
||||
(
|
||||
@@ -56,10 +50,7 @@ function sendMessage($destination, $content) {
|
||||
}
|
||||
|
||||
function getNewChatMessages($lastID, $destination) {
|
||||
$db = $GLOBALS["db"];
|
||||
$origin = $_SESSION["userID"];
|
||||
|
||||
$stmt = $db->prepare("
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
@@ -75,7 +66,7 @@ function getNewChatMessages($lastID, $destination) {
|
||||
`messageID` ASC
|
||||
");
|
||||
|
||||
$stmt->bindParam(':user1', $origin);
|
||||
$stmt->bindParam(':user1', $_SESSION["userID"]);
|
||||
$stmt->bindParam(':user2', $destination);
|
||||
$stmt->bindParam(':lastID', $lastID);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
require("connect.php");
|
||||
|
||||
function getUserID($db, $username) {
|
||||
$stmt = $db->prepare("
|
||||
function getUserID($username) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`userID`
|
||||
FROM
|
||||
@@ -16,8 +16,8 @@ function getUserID($db, $username) {
|
||||
return $stmt->fetch()["userID"];
|
||||
}
|
||||
|
||||
function selectUser($db, $userID) {
|
||||
$stmt = $db->prepare("
|
||||
function selectUser($userID) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`username`,
|
||||
IFNULL(
|
||||
@@ -41,8 +41,8 @@ function selectUser($db, $userID) {
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
function selectAllUserGroups($db, $userID) {
|
||||
$stmt = $db->prepare("
|
||||
function selectAllUserGroups($userID) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`group_page`.`groupID`,
|
||||
`name`,
|
||||
@@ -64,8 +64,8 @@ function selectAllUserGroups($db, $userID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function selectAllUserPosts($db, $userID) {
|
||||
$stmt = $db->prepare("
|
||||
function selectAllUserPosts($userID) {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`postID`,
|
||||
`author`,
|
||||
@@ -86,8 +86,8 @@ function selectAllUserPosts($db, $userID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function select20UsersFromN($db, $n) {
|
||||
return $db->query("
|
||||
function select20UsersFromN($n) {
|
||||
return $GLOBALS["db"]->query("
|
||||
SELECT
|
||||
`userID`,
|
||||
`username`,
|
||||
@@ -103,8 +103,8 @@ function select20UsersFromN($db, $n) {
|
||||
");
|
||||
}
|
||||
|
||||
function search20UsersFromN($db, $n, $keyword) {
|
||||
$q = $db->prepare("
|
||||
function search20UsersFromN($n, $keyword) {
|
||||
$q = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`userID`,
|
||||
`username`,
|
||||
@@ -127,8 +127,8 @@ function search20UsersFromN($db, $n, $keyword) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
function search20UsersFromNByStatus($db, $n, $keyword, $status) {
|
||||
$q = $db->prepare("
|
||||
function search20UsersFromNByStatus($n, $keyword, $status) {
|
||||
$q = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`userID`,
|
||||
`username`,
|
||||
@@ -155,8 +155,8 @@ function search20UsersFromNByStatus($db, $n, $keyword, $status) {
|
||||
return $q;
|
||||
}
|
||||
|
||||
function changeUserStatusByID($db, $id, $status) {
|
||||
$q = $db->query("
|
||||
function changeUserStatusByID($id, $status) {
|
||||
$q = $GLOBALS["db"]->query("
|
||||
UPDATE
|
||||
`user`
|
||||
SET
|
||||
|
||||
@@ -61,9 +61,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
}
|
||||
|
||||
if (!empty($_POST["actions"]) && !empty($_POST["userID"])) {
|
||||
changeUserStatusByID($db, $_POST["userID"], $_POST["actions"]);
|
||||
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
|
||||
} elseif (!empty($_POST["actions"]) && !empty($_POST["groupID"])) {
|
||||
changeGroupStatusByID($db, $_POST["groupID"], $_POST["actions"]);
|
||||
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -183,7 +183,7 @@ function test_input($data) {
|
||||
<!-- Table construction via php PDO. -->
|
||||
<?php
|
||||
if ($pagetype == 'user') {
|
||||
$q = search20UsersFromNByStatus($db, $listnr, $search, $status);
|
||||
$q = search20UsersFromNByStatus($listnr, $search, $status);
|
||||
|
||||
while($user = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||
$userID = $user['userID'];
|
||||
@@ -218,7 +218,7 @@ function test_input($data) {
|
||||
");
|
||||
}
|
||||
} else {
|
||||
$q = search20GroupsFromNByStatus($db, $listnr, $search, $groupstatus);
|
||||
$q = search20GroupsFromNByStatus($listnr, $search, $groupstatus);
|
||||
|
||||
while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||
$groupID = $group['groupID'];
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
<?php
|
||||
include_once("../queries/friendship.php");
|
||||
|
||||
if (empty($_SESSION["userID"]))
|
||||
$_SESSION["userID"] = 2;
|
||||
|
||||
// Get all the friends of a user.
|
||||
$friends = selectAllFriends($db, $_SESSION["userID"]);
|
||||
$friends = selectAllFriends($_SESSION["userID"]);
|
||||
$i = 0;
|
||||
|
||||
// Print all the users.
|
||||
|
||||
@@ -9,11 +9,8 @@
|
||||
// Load file.
|
||||
include_once("../queries/friendship.php");
|
||||
|
||||
if (empty($_SESSION["userID"]))
|
||||
$_SESSION["userID"] = 2;
|
||||
|
||||
// Get all the friends of a user.
|
||||
$friends = selectAllFriends($db, $_SESSION["userID"]);
|
||||
$friends = selectAllFriends($_SESSION["userID"]);
|
||||
$i = 0;
|
||||
|
||||
// Print all the users.
|
||||
@@ -69,7 +66,7 @@
|
||||
include_once("../queries/group_member.php");
|
||||
|
||||
// Get all the friends of a user.
|
||||
$groups = selectAllGroupsFromUser($db, $_SESSION["userID"]);
|
||||
$groups = selectAllGroupsFromUser($_SESSION["userID"]);
|
||||
$i = 0;
|
||||
|
||||
// Print all the users.
|
||||
|
||||
Reference in New Issue
Block a user