Final
Final
@@ -1,16 +0,0 @@
|
||||
<?php // Example 06: checkuser.php
|
||||
require_once 'functions.php';
|
||||
|
||||
if (isset($_POST['user']))
|
||||
{
|
||||
$user = sanitizeString($_POST['user']);
|
||||
$result = queryMysql("SELECT * FROM members WHERE user='$user'");
|
||||
|
||||
if ($result->rowCount())
|
||||
echo "<span class='taken'> ✘ " .
|
||||
"The username '$user' is taken</span>";
|
||||
else
|
||||
echo "<span class='available'> ✔ " .
|
||||
"The username '$user' is available</span>";
|
||||
}
|
||||
?>
|
||||
@@ -1,83 +0,0 @@
|
||||
<?php // Example 10: friends.php
|
||||
require_once 'header.php';
|
||||
|
||||
if (!$loggedin) die("</div></body></html>");
|
||||
|
||||
if (isset($_GET['view'])) $view = sanitizeString($_GET['view']);
|
||||
else $view = $user;
|
||||
|
||||
if ($view == $user)
|
||||
{
|
||||
$name1 = $name2 = "Your";
|
||||
$name3 = "You are";
|
||||
}
|
||||
else
|
||||
{
|
||||
$name1 = "<a data-transition='slide'
|
||||
href='members.php?view=$view&r=$randstr'>$view</a>'s";
|
||||
$name2 = "$view's";
|
||||
$name3 = "$view is";
|
||||
}
|
||||
|
||||
// Uncomment this line if you wish the user’s profile to show here
|
||||
// showProfile($view);
|
||||
|
||||
$followers = array();
|
||||
$following = array();
|
||||
|
||||
$result = queryMysql("SELECT * FROM friends WHERE user='$view'");
|
||||
|
||||
while ($row = $result->fetch())
|
||||
{
|
||||
$followers[$j] = $row['friend'];
|
||||
}
|
||||
|
||||
$result = queryMysql("SELECT * FROM friends WHERE friend='$view'");
|
||||
|
||||
while ($row = $result->fetch())
|
||||
{
|
||||
$following[$j] = $row['user'];
|
||||
}
|
||||
|
||||
$mutual = array_intersect($followers, $following);
|
||||
$followers = array_diff($followers, $mutual);
|
||||
$following = array_diff($following, $mutual);
|
||||
$friends = FALSE;
|
||||
|
||||
echo "<br>";
|
||||
|
||||
if (sizeof($mutual))
|
||||
{
|
||||
echo "<span class='subhead'>$name2 mutual friends</span><ul>";
|
||||
foreach($mutual as $friend)
|
||||
echo "<li><a data-transition='slide'
|
||||
href='members.php?view=$friend&r=$randstr'>$friend</a>";
|
||||
echo "</ul>";
|
||||
$friends = TRUE;
|
||||
}
|
||||
|
||||
if (sizeof($followers))
|
||||
{
|
||||
echo "<span class='subhead'>$name2 followers</span><ul>";
|
||||
foreach($followers as $friend)
|
||||
echo "<li><a data-transition='slide'
|
||||
href='members.php?view=$friend&r=$randstr'>$friend</a>";
|
||||
echo "</ul>";
|
||||
$friends = TRUE;
|
||||
}
|
||||
|
||||
if (sizeof($following))
|
||||
{
|
||||
echo "<span class='subhead'>$name3 following</span><ul>";
|
||||
foreach($following as $friend)
|
||||
echo "<li><a data-transition='slide'
|
||||
href='members.php?view=$friend&r=$randstr'>$friend</a>";
|
||||
echo "</ul>";
|
||||
$friends = TRUE;
|
||||
}
|
||||
|
||||
if (!$friends) echo "<br>You don't have any friends yet.";
|
||||
?>
|
||||
</div><br>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php // Example 01: functions.php
|
||||
$host = 'localhost'; // Change as necessary
|
||||
$data = 'publications'; // Change as necessary
|
||||
$user = 'root'; // Change as necessary
|
||||
$pass = 'mysql'; // Change as necessary
|
||||
$chrs = 'utf8mb4';
|
||||
$attr = "mysql:host=$host;dbname=$data;charset=$chrs";
|
||||
$opts =
|
||||
[
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
];
|
||||
|
||||
try
|
||||
{
|
||||
$pdo = new PDO($attr, $user, $pass, $opts);
|
||||
}
|
||||
catch (\PDOException $e)
|
||||
{
|
||||
throw new \PDOException($e->getMessage(), (int)$e->getCode());
|
||||
}
|
||||
|
||||
function createTable($name, $query)
|
||||
{
|
||||
queryMysql("CREATE TABLE IF NOT EXISTS $name($query)");
|
||||
echo "Table '$name' created or already exists.<br>";
|
||||
}
|
||||
|
||||
function queryMysql($query)
|
||||
{
|
||||
global $pdo;
|
||||
return $pdo->query($query);
|
||||
}
|
||||
|
||||
function destroySession()
|
||||
{
|
||||
$_SESSION=array();
|
||||
|
||||
if (session_id() != "" || isset($_COOKIE[session_name()]))
|
||||
setcookie(session_name(), '', time()-2592000, '/');
|
||||
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
function sanitizeString($var)
|
||||
{
|
||||
global $pdo;
|
||||
$var = strip_tags($var);
|
||||
$var = htmlentities($var);
|
||||
if (get_magic_quotes_gpc())
|
||||
$var = stripslashes($var);
|
||||
$result = $pdo->quote($var); // This adds single quotes
|
||||
return str_replace("'", "", $result); // So now remove them
|
||||
}
|
||||
|
||||
function showProfile($user)
|
||||
{
|
||||
if (file_exists("$user.jpg"))
|
||||
echo "<img src='$user.jpg' style='float:left;'>";
|
||||
|
||||
$result = queryMysql("SELECT * FROM profiles WHERE user='$user'");
|
||||
|
||||
if ($result->num_rows)
|
||||
{
|
||||
$row = $result->fetch_array(MYSQLI_ASSOC);
|
||||
echo stripslashes($row['text']) . "<br style='clear:left;'><br>";
|
||||
}
|
||||
else echo "<p>Nothing to see here, yet</p><br>";
|
||||
}
|
||||
?>
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php // Example 02: header.php
|
||||
session_start();
|
||||
|
||||
echo <<<_INIT
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='stylesheet' href='jquery.mobile-1.4.5.min.css'>
|
||||
<link rel='stylesheet' href='styles.css' type='text/css'>
|
||||
<script src='javascript.js'></script>
|
||||
<script src='jquery-2.2.4.min.js'></script>
|
||||
<script src='jquery.mobile-1.4.5.min.js'></script>
|
||||
|
||||
_INIT;
|
||||
|
||||
require_once 'functions.php';
|
||||
|
||||
$userstr = 'Welcome Guest';
|
||||
$randstr = substr(md5(rand()), 0, 7);
|
||||
|
||||
if (isset($_SESSION['user']))
|
||||
{
|
||||
$user = $_SESSION['user'];
|
||||
$loggedin = TRUE;
|
||||
$userstr = "Logged in as: $user";
|
||||
}
|
||||
else $loggedin = FALSE;
|
||||
|
||||
echo <<<_MAIN
|
||||
<title>Robin's Nest: $userstr</title>
|
||||
</head>
|
||||
<body>
|
||||
<div data-role='page'>
|
||||
<div data-role='header'>
|
||||
<div id='logo' class='center'>R<img id='robin' src='robin.gif'>bin's Nest</div>
|
||||
<div class='username'>$userstr</div>
|
||||
</div>
|
||||
<div data-role='content'>
|
||||
|
||||
_MAIN;
|
||||
|
||||
if ($loggedin)
|
||||
{
|
||||
echo <<<_LOGGEDIN
|
||||
<div class='center'>
|
||||
<a data-role='button' data-inline='true' data-icon='home'
|
||||
data-transition="slide" href='members.php?view=$user&r=$randstr'>Home</a>
|
||||
<a data-role='button' data-inline='true' data-icon='user'
|
||||
data-transition="slide" href='members.php?r=$randstr'>Members</a>
|
||||
<a data-role='button' data-inline='true' data-icon='heart'
|
||||
data-transition="slide" href='friends.php?r=$randstr'>Friends</a><br>
|
||||
<a data-role='button' data-inline='true' data-icon='mail'
|
||||
data-transition="slide" href='messages.php?r=$randstr'>Messages</a>
|
||||
<a data-role='button' data-inline='true' data-icon='edit'
|
||||
data-transition="slide" href='profile.php?r=$randstr'>Edit Profile</a>
|
||||
<a data-role='button' data-inline='true' data-icon='action'
|
||||
data-transition="slide" href='logout.php?r=$randstr'>Log out</a>
|
||||
</div>
|
||||
|
||||
_LOGGEDIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo <<<_GUEST
|
||||
<div class='center'>
|
||||
<a data-role='button' data-inline='true' data-icon='home'
|
||||
data-transition='slide' href='index.php?r=$randstr''>Home</a>
|
||||
<a data-role='button' data-inline='true' data-icon='plus'
|
||||
data-transition="slide" href='signup.php?r=$randstr''>Sign Up</a>
|
||||
<a data-role='button' data-inline='true' data-icon='check'
|
||||
data-transition="slide" href='login.php?r=$randstr''>Log In</a>
|
||||
</div>
|
||||
<p class='info'>(You must be logged in to use this app)</p>
|
||||
|
||||
_GUEST;
|
||||
}
|
||||
?>
|
||||
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 227 B |
|
Before Width: | Height: | Size: 244 B |
|
Before Width: | Height: | Size: 243 B |
|
Before Width: | Height: | Size: 146 B |
|
Before Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 173 B |
|
Before Width: | Height: | Size: 159 B |
|
Before Width: | Height: | Size: 171 B |
|
Before Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 156 B |
|
Before Width: | Height: | Size: 147 B |
|
Before Width: | Height: | Size: 152 B |
|
Before Width: | Height: | Size: 147 B |
|
Before Width: | Height: | Size: 163 B |
|
Before Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 163 B |
|
Before Width: | Height: | Size: 165 B |
|
Before Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 307 B |
|
Before Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 240 B |
|
Before Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 135 B |
|
Before Width: | Height: | Size: 147 B |
|
Before Width: | Height: | Size: 152 B |
|
Before Width: | Height: | Size: 146 B |
|
Before Width: | Height: | Size: 143 B |
|
Before Width: | Height: | Size: 250 B |
|
Before Width: | Height: | Size: 251 B |
|
Before Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 213 B |
|
Before Width: | Height: | Size: 174 B |
|
Before Width: | Height: | Size: 177 B |
|
Before Width: | Height: | Size: 184 B |
|
Before Width: | Height: | Size: 194 B |
|
Before Width: | Height: | Size: 196 B |
|
Before Width: | Height: | Size: 204 B |
|
Before Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 316 B |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 210 B |
|
Before Width: | Height: | Size: 165 B |
|
Before Width: | Height: | Size: 160 B |
|
Before Width: | Height: | Size: 171 B |
|
Before Width: | Height: | Size: 185 B |
|
Before Width: | Height: | Size: 163 B |
|
Before Width: | Height: | Size: 170 B |
|
Before Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 299 B |
|
Before Width: | Height: | Size: 308 B |
|
Before Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 243 B |
|
Before Width: | Height: | Size: 318 B |
|
Before Width: | Height: | Size: 302 B |
|
Before Width: | Height: | Size: 160 B |
|
Before Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 150 B |
|
Before Width: | Height: | Size: 154 B |
|
Before Width: | Height: | Size: 250 B |
|
Before Width: | Height: | Size: 251 B |
|
Before Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 247 B |
|
Before Width: | Height: | Size: 204 B |
|
Before Width: | Height: | Size: 207 B |
|
Before Width: | Height: | Size: 226 B |
|
Before Width: | Height: | Size: 227 B |
|
Before Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 241 B |
|
Before Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 274 B |
|
Before Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 124 B |
|
Before Width: | Height: | Size: 292 B |
|
Before Width: | Height: | Size: 302 B |
|
Before Width: | Height: | Size: 243 B |
|
Before Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 295 B |
|
Before Width: | Height: | Size: 301 B |
|
Before Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 321 B |
|
Before Width: | Height: | Size: 174 B |
|
Before Width: | Height: | Size: 173 B |
|
Before Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 239 B |