-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kasparkivistik
committed
Dec 5, 2017
1 parent
216f6c5
commit 16c2a89
Showing
11 changed files
with
364 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function notWorking() { | ||
alert("this shit not real"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,66 @@ | ||
<?php | ||
session_start(); | ||
include("config.php"); | ||
|
||
$connection = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); | ||
|
||
|
||
if (!$connection) { | ||
echo "kle vaata oma db üle, armas inimene, eks"; | ||
} | ||
?> | ||
|
||
|
||
<!DOCTYPE html> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Log in \\ REDDIT</title> | ||
<title>Authenticate yourself \\ REDDIT</title> | ||
<meta name="author" content="Kaspar Kivistik"> | ||
<meta http-equiv="X-UA-Compatible" content="IE-edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="https://bootswatch.com/3/simplex/bootstrap.min.css"/> | ||
<link rel="stylesheet" href=""> | ||
<link rel="stylesheet" href="stylesheet.css"> | ||
</head> | ||
<body> | ||
<form> | ||
<div class="container"> | ||
<label><b>Username</b></label> | ||
<input type="text" placeholder="Enter Username" name="username" required/> | ||
|
||
<label><b>Password</b></label> | ||
<input type="password" placeholder="Enter Password" name="password" required/> | ||
|
||
<button type="submit">Login</button> | ||
<label> | ||
<input type="checkbox" checked="checked"/> | ||
</label> Remember me | ||
</div> | ||
|
||
<div class="container" style="background-color:#f1f1f1"> | ||
<button type="button" class="cancelbtn">Cancel</button> | ||
<span>Forgot <a href="#">password?</a></span> | ||
</div> | ||
<?php | ||
include("header.php"); | ||
?> | ||
<body class="centered-wrapper"> | ||
<form class="centered-content form-horizontal" method="post"> | ||
<fieldset> | ||
<legend>log in to this WONDERFUL site</legend> | ||
<div class="form-group"> | ||
<label class="col-lg-2 control-label">Username</label> | ||
<div class="col-lg-10"> | ||
<input type="text" class="form-control" name="username" placeholder="Username" required> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-lg-2 control-label">Password</label> | ||
<div class="col-lg-10"> | ||
<input type="password" class="form-control" name="password" placeholder="Password" required> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-lg-10 col-lg-offset-2"> | ||
<input type="submit" class="btn btn-primary"/> | ||
</div> | ||
</div> | ||
</fieldset> | ||
<?php | ||
if (isset($_REQUEST['username']) and isset($_REQUEST['password'])) { | ||
$username = $_REQUEST['username']; | ||
$password = escape($connection, $_REQUEST['password']); | ||
$query = "SELECT * FROM 164347_users WHERE user_name = '$username' AND password = '$password'"; | ||
if (count(mysqli_fetch_array(mysqli_query($connection, $query)))) { | ||
$_SESSION['username'] = $username; | ||
$message = "successfully logged in"; | ||
echo "<script type='text/javascript'>alert('$message');</script>"; | ||
header("Location: index.php"); | ||
} else { | ||
echo "<script type='text/javascript'>alert(\"invalid username or password\");</script>"; | ||
} | ||
} | ||
?> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
if (!defined('DB_SERVER')) define('DB_SERVER', 'localhost'); | ||
if (!defined('DB_USERNAME')) define('DB_USERNAME', 'st2014'); | ||
if (!defined('DB_PASSWORD')) define('DB_PASSWORD', 'progress'); | ||
if (!defined('DB_DATABASE')) define('DB_DATABASE', 'st2014'); | ||
|
||
function escape($db, $string) { | ||
$string = mysqli_real_escape_string($db, $string); | ||
$string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); | ||
return $string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,56 @@ | ||
<?php | ||
session_start(); | ||
include("config.php"); | ||
|
||
$connection = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); | ||
|
||
if (!$connection) { | ||
echo "kle vaata oma server üle, armas inimene, eks"; | ||
} | ||
|
||
if (!$_SESSION['username']) { | ||
header("Location: index.php"); | ||
} | ||
?> | ||
|
||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Create a new post onto this magnificent site // Reddit</title> | ||
<title>Create a new post onto this magnificent site \\ Reddit</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="https://bootswatch.com/3/simplex/bootstrap.min.css"/> | ||
<meta http-equiv="X-UA-Compatible" content="IE-edge"> | ||
<link rel="stylesheet" href="stylesheet.css"/> | ||
</head> | ||
<body> | ||
<h3>Hello create new post thanks</h3> | ||
<textarea id="postname"></textarea> | ||
<textarea id="content"></textarea> | ||
<?php | ||
include("header.php"); | ||
?> | ||
<body class="centered-wrapper"> | ||
<div class="centered-content"> | ||
<form method="post"> | ||
<legend>Hello create new post thanks</legend> | ||
<label><b>The title of your new postitus</b></label><br> | ||
<input type="text" style="width: 500px" name="title"/><br> | ||
<label><b>The content of your new postitus</b></label><br> | ||
<input type="text" style="width: 500px; height: 250px" name="content"/><br><br> | ||
<input type="submit"> | ||
<?php | ||
|
||
if (isset($_REQUEST['title']) and isset($_REQUEST['content'])) { | ||
$title = escape($connection, $_REQUEST['title']); | ||
$content = escape($connection, $_REQUEST['content']); | ||
$name = $_SESSION['username']; | ||
$sql = "INSERT INTO 164347_posts (content, time, username, title) VALUES ('$content', NOW(), '$name', '$title')"; | ||
if ($connection->query($sql) === true) { | ||
$message = "Success!"; | ||
echo "<script type='text/javascript'>alert('$message');</script>"; | ||
header("Location: index.php"); | ||
} | ||
} | ||
?> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script src="app.js"></script> | ||
<nav class="navbar navbar-default"> | ||
<div class="container-fluid"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="index.php">reffit</a> | ||
<ul class="nav navbar-nav"> | ||
<li><a onclick="notWorking()">hot</a></li> | ||
<li><a onclick="notWorking()">new</a></li> | ||
<li><a onclick="notWorking()">rising</a></li> | ||
<li><a onclick="notWorking()">top</a></li> | ||
<li><a onclick="notWorking()">gilded</a></li> | ||
</ul> | ||
</div> | ||
<?php | ||
if (!isset($_SESSION['username'])) { | ||
echo '<ul class="nav navbar-nav navbar-right"> | ||
<li><a href="auth.php">log in</a></li> | ||
<li><a href="signup.php">sign up</a></li> | ||
</ul>'; | ||
} else { | ||
echo '<ul class="nav navbar-nav navbar-right"> | ||
<li><a href="createpost.php">make new postitus</a></li> | ||
<li><a href="logout.php">log out (' . $_SESSION['username'] . ')</a></li> | ||
</ul>'; | ||
} | ||
?> | ||
</div> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,49 @@ | ||
<?php | ||
session_start(); | ||
include("config.php"); | ||
|
||
$connection = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); | ||
|
||
if (!$connection || $connection->connect_error) { | ||
echo "kle vaata oma andmebaas üle, armas inimene, eks"; | ||
} | ||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Index // Reddit</title> | ||
<title>Index \\ Reddit</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="https://bootswatch.com/3/simplex/bootstrap.min.css"/> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> | ||
<meta http-equiv="X-UA-Compatible" content="IE-edge"> | ||
<link rel="stylesheet" href="stylesheet.css"/> | ||
</head> | ||
<body> | ||
<?php | ||
include("header.php"); | ||
?> | ||
<body class="centered-wrapper"> | ||
|
||
<?php | ||
$query = "SELECT * FROM 164347_posts ORDER BY username ASC"; | ||
$res = mysqli_query($connection, $query); | ||
while ($row = mysqli_fetch_assoc($res)) { | ||
$row = array_values($row); | ||
$sql = "SELECT IFNULL(SUM(vote), 0) AS score FROM 164347_votes WHERE post = $row[0]"; | ||
$points = mysqli_fetch_array(mysqli_query($connection, $sql))[0]; | ||
echo '<div style="border: 1px solid black; padding: 10px" class="centered-content"> | ||
<a href="viewpost.php?id=' . $row[0] . '"><h3>' . htmlspecialchars($row[4]) . '</h3></a><p>' . htmlspecialchars($row[1]) . '</p> | ||
<p>created by <b>' . $row[3] . '</b></p><p>at ' . $row[2] . '</p><p><i>points </i>' . $points . '</p> | ||
<a href="vote.php?post=' . $row[0] . '&score=up"><i class="fa fa-smile-o fa-2x" aria-hidden="true"></i></a> | ||
<a href="vote.php?post=' . $row[0] . '&score=down"><i class="fa fa-frown-o fa-2x" aria-hidden="true"></i></a> | ||
</div><br>'; | ||
} | ||
?> | ||
<div class="well well-sm"> | ||
tere see oli minu võrgurakenduste neljanda praksi töö<br> | ||
ma olen kaspar kivistik mu matriklinumber on 164347IABB<br> | ||
andke palju punkte palun | ||
</div> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
session_start(); | ||
|
||
if (session_destroy()) { | ||
header("Location: index.php"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,92 @@ | ||
<?php | ||
?> | ||
session_start(); | ||
include("config.php"); | ||
|
||
$connection = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); | ||
|
||
if (!$connection || $connection->connect_error) { | ||
echo "kle vaata oma server üle, armas inimene, eks"; | ||
} | ||
|
||
?> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Sing up // Reddit</title> | ||
<title>sing up \\ Reddit</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="IE-edge"> | ||
<link rel="stylesheet" href="https://bootswatch.com/3/simplex/bootstrap.min.css"/> | ||
<link rel="stylesheet" href="stylesheet.css"/> | ||
</head> | ||
<body> | ||
<form> | ||
<div class="container"> | ||
<p><label><b>Email</b></label></p> | ||
<input type="text" placeholder="Enter Email" required> | ||
|
||
<label><b>Password</b></label> | ||
<input type="password" placeholder="Enter Password"required> | ||
|
||
<label><b>Repeat Password</b></label> | ||
<input type="password" placeholder="Repeat Password" required> | ||
<input type="checkbox" checked="checked"> Remember me | ||
<p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p> | ||
|
||
<div> | ||
<button type="button">Cancel</button> | ||
<button type="submit">Sign Up</button> | ||
<body class="centered-wrapper"> | ||
<?php | ||
include("header.php"); | ||
?> | ||
<form class="form-horizontal" method="post"> | ||
<fieldset class="centered-content"> | ||
<legend>sing up to our WONDERFUL site</legend> | ||
<div class="form-group"> | ||
<label class="col-lg-2 control-label">Username</label> | ||
<div class="col-lg-10"> | ||
<input type="text" name="username" class="form-control" placeholder="Username" | ||
required> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="col-lg-2 control-label">Full name</label> | ||
<div class="col-lg-10"> | ||
<input type="text" name="fullname" class="form-control" placeholder="Full name" | ||
required> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="inputEmail" class="col-lg-2 control-label">Email</label> | ||
<div class="col-lg-10"> | ||
<input type="email" name="email" class="form-control" placeholder="Email" required> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="inputPassword" class="col-lg-2 control-label">Password</label> | ||
<div class="col-lg-10"> | ||
<input type="password" name="password" class="form-control" placeholder="Password" | ||
required> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-lg-10 col-lg-offset-2"> | ||
<button type="reset" class="btn btn-default">Reset everytghing</button> | ||
<input type="submit" class="btn btn-primary"/> | ||
</div> | ||
</div> | ||
</fieldset> | ||
</form> | ||
<?php | ||
|
||
function validifyData($username, $db) { | ||
$result = mysqli_query($db, "SELECT * FROM 164347_users WHERE user_name = '$username'"); | ||
if (count(mysqli_fetch_array($result)) != 0) { | ||
$message = "name exists"; | ||
echo "<script type='text/javascript'>alert('$message');</script>"; | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
if (isset($_REQUEST['username']) and isset($_REQUEST['password']) and isset($_REQUEST['fullname']) and isset($_REQUEST['email'])) { | ||
$username = escape($connection, $_REQUEST['username']); | ||
$password = escape($connection, $_REQUEST['password']); | ||
$fullname = escape($connection, $_REQUEST["fullname"]); | ||
$email = escape($connection, $_REQUEST["email"]); | ||
if (validifyData($username, $connection)) { | ||
$sql = "INSERT INTO 164347_users VALUES ('$username', '$password', '$fullname', '$email')"; | ||
if ($connection->query($sql) === true) { | ||
$message = "Success!"; | ||
echo "<script type='text/javascript'>alert('$message');</script>"; | ||
header("Location: index.php"); | ||
} | ||
} | ||
} | ||
?> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.centered-wrapper { | ||
position: relative; | ||
text-align: center; | ||
} | ||
|
||
.centered-wrapper:before { | ||
position: relative; | ||
display: inline-block; | ||
width: 0; height: 100%; | ||
vertical-align: middle; | ||
} | ||
|
||
.centered-content { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} |
Oops, something went wrong.