-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_image.php
More file actions
88 lines (76 loc) · 3.36 KB
/
Copy pathview_image.php
File metadata and controls
88 lines (76 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
//Get logged in user. If no user is logged in, redirect to login page.
session_start();
if (!isset($_SESSION["loggedInUser"])){
header("Location:login.php");}
else{
$loggedInUser = $_SESSION["loggedInUser"];}
//Connect to database
$serverName = "localhost\sqlexpress";
$connectionInfo = array("Database"=>"social_network", "UID"=>"ben", "PWD"=>"password123");
$conn = sqlsrv_connect($serverName, $connectionInfo);
//Get userID of loggedInUser
$getCurrentUserIDQuery = "SELECT id FROM users WHERE username = '$loggedInUser'";
$getCurrentUserID = sqlsrv_query($conn, $getCurrentUserIDQuery, array());
$currentUserID = sqlsrv_fetch_array($getCurrentUserID);
$currentUserID = $currentUserID[0];
//Get pending friend requests of loggedInUser
$getPendingRequestsQuery = "SELECT * FROM friends WHERE friendid = '$currentUserID' AND accepted = 'False'";
$getPendingRequests = sqlsrv_query($conn, $getPendingRequestsQuery, array(), array( "Scrollable" => 'static' ));
$pendingRequestsCount = sqlsrv_num_rows($getPendingRequests);
$selectedImage = $_GET["selectedImage"];
$postIDFromFilename = pathinfo($selectedImage, PATHINFO_FILENAME);
$getPostQuery = "SELECT * FROM posts WHERE post_id = '$postIDFromFilename' ";
$getPost = sqlsrv_query($conn, $getPostQuery, array());
$post = sqlsrv_fetch_array($getPost);
?>
<html>
<head>
<title>Welcome to Social Network</title>
<link rel="stylesheet" type="text/css" href="default.css">
</head>
<body>
<center>
<!--Logo-->
<div class="header" id="header">
<h1><a href="index.php">Social Network</a></h1>
</div>
<!--Options bar-->
<div id="options">
<span id="search">
<?php
echo '<form action="search.php" method="post" style="display: inline;"><input type="text" name="search" placeholder="Search"><input type="submit" value="Submit" name="submitSearch"></form>';
if ($pendingRequestsCount > 0){
echo ' <a href="requests.php" id="requests">'.$pendingRequestsCount.' new friend requests</a>';
}
?>
</span>
<span id="userOptions">
<?php if (!isset($_SESSION["loggedInUser"])){echo '<a href="register.php">Register</a> ';} ?>
<?php if (!isset($_SESSION["loggedInUser"])){echo '<a href="login.php"44>Log in</a> ';} ?>
<?php if (isset($_SESSION["loggedInUser"])){echo '<a href="logout.php">Log out</a>';} ?>
<?php if (isset($_SESSION["loggedInUser"])){echo 'Welcome, <a href="profile.php?selectedUser=' . $loggedInUser . '">' .$loggedInUser. '</a>';}
?>
</span>
</div>
<!--Image-->
<div class="contents">
<span id="image">
<?php
//Display image
echo "<img src='images/" . $selectedImage . "'><br><br>";
if (isset($_GET["imageType"])){
echo $selectedImage;
}
else {
//Display username of poster
echo "<font color='#0080ff'><b></a>" . "<a href='profile.php?selectedUser=" . $post[2] . "'>" . $post[2] . "</a>" . "</b></font> ";
//Display datetime posted
echo "<font color='gray' size='2'>" . date_format($post[3], "m/d/Y h:ia") . "</font><br>";
}
?>
</div>
</div>
</center>
</body>
</html>