flexible blog + post page
This commit is contained in:
parent
5b47c5999b
commit
6ac3f0108d
13
admin/polacz.php
Normal file
13
admin/polacz.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
function wczytaj($zmienna)
|
||||
{
|
||||
if (!isset($_GET[$zmienna]) || $_GET[$zmienna]=="")
|
||||
die( "Blad! brak zmiennej: ".$zmienna ); // nie podano marki w $
|
||||
return $_GET[$zmienna];
|
||||
}
|
||||
|
||||
|
||||
$baza = new mysqli("localhost", "root", "", "tas");
|
||||
if (mysqli_connect_errno()) die( "Blad: ".mysqli_connect_error() );
|
||||
mysqli_set_charset( $baza, 'utf8');
|
||||
?>
|
36
blog-post/404.php
Normal file
36
blog-post/404.php
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
|
||||
<title>404 PAGE NOT FOUND</title>
|
||||
|
||||
<!-- Google font -->
|
||||
<link href="https://fonts.googleapis.com/css?family=Cabin:400,700" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:900" rel="stylesheet">
|
||||
|
||||
<!-- Custom stlylesheet -->
|
||||
<link type="text/css" rel="stylesheet" href="css/style.css" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="notfound">
|
||||
<div class="notfound">
|
||||
<div class="notfound-404">
|
||||
<h3>Oops! Page not found</h3>
|
||||
<h1><span>4</span><span>0</span><span>4</span></h1>
|
||||
</div>
|
||||
<h2>we are sorry, but the page you requested was not found</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,3 +1,6 @@
|
||||
<?php if( !isset( $_SESSION ) ) session_start();
|
||||
$_SESSION['user_id']=$_GET['user_id'];
|
||||
?>
|
||||
<html lang="pl-PL">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@ -23,20 +26,8 @@
|
||||
|
||||
<body>
|
||||
|
||||
<?php include "menu.php" ?>
|
||||
|
||||
<div class="dropdown">
|
||||
<div id="menuwrap">
|
||||
<button class="btn btn-light dropdown-toggle btn-lg" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Menu
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||
<li><a href="#about">O mnie</a></li>
|
||||
<li><a href="#post">Posty</a></a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="../index.html">Strona główa</a></li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="aboutdown">
|
||||
<section id="about" name="about"></section>
|
||||
@ -52,22 +43,29 @@
|
||||
|
||||
<?php
|
||||
include "../settings/db_connect.php";
|
||||
|
||||
|
||||
if ($sql = $mysqli->prepare("SELECT * FROM user WHERE user_id = 2 "))
|
||||
if(isset($_GET['user_id'])){
|
||||
$user_id = $_GET['user_id'];
|
||||
$checkIfExists = $mysqli->query("SELECT * FROM user WHERE user_id =$user_id");
|
||||
if ($checkIfExists) {
|
||||
if($checkIfExists->num_rows === 0)
|
||||
{
|
||||
include "404.php";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($sql = $mysqli->prepare("SELECT * FROM user WHERE user_id =$user_id "))
|
||||
{
|
||||
$sql->execute();
|
||||
$sql->bind_result($user_id,$username,$email,$password,$avatar, $about_short, $about_me, $about_blog, $FB, $TW);
|
||||
while ($sql->fetch())
|
||||
{
|
||||
echo "<div class=\"col-lg-8 name-desc\">
|
||||
<h2>$about_short</h2>
|
||||
{ ?>
|
||||
<div class="col-lg-8 name-desc">
|
||||
<h2><?php echo $about_short; ?></h2>
|
||||
|
||||
|
||||
<div class=\"col-md-11\">
|
||||
<p>$about_me
|
||||
</p>
|
||||
<p>$about_blog</p>
|
||||
<div class="col-md-11">
|
||||
<p><?php echo $about_me; ?></p>
|
||||
<p><?php echo $about_blog; ?></p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -75,23 +73,25 @@ if ($sql = $mysqli->prepare("SELECT * FROM user WHERE user_id = 2 "))
|
||||
|
||||
|
||||
|
||||
<div class=\"col-lg-4 name foto cover foto1\">
|
||||
<img src=\"$avatar\" class=\"align-text-bottom\">
|
||||
<p>$username</p>
|
||||
<div class="col-lg-4 name foto cover foto1">
|
||||
<img src="<?php echo $avatar; ?>" class="align-text-bottom">
|
||||
<p><?php echo $username; ?></p>
|
||||
|
||||
<a href=\"https://www.facebook.com/$FB\">
|
||||
<div class=\"col-md-6\">
|
||||
<div class=\"fa fa-facebook-official\" style=\"font-size:36px\">
|
||||
<a href="https://www.facebook.com/<?php echo $FB; ?>">
|
||||
<div class="col-md-6">
|
||||
<div class="fa fa-facebook-official" style="font-size:36px">
|
||||
|
||||
<div class=\"ikona\"> <i><p1> $FB </p1></i> </div>
|
||||
<div class="ikona"> <i><p1> <?php echo $FB; ?> </p1></i> </div>
|
||||
</div> </div> </a>
|
||||
|
||||
|
||||
<a href=\"https://twitter.com/$TW\">
|
||||
<div class=\"col-md-6\">
|
||||
<div class=\"fa fa-twitter-square\" style=\"font-size:36px\"\">
|
||||
<div class=\"ikona\"><i><p1> $TW </p1></i> </div>
|
||||
</div> </a> </div>
|
||||
<a href="https://twitter.com/<?php echo $TW; ?>">
|
||||
<div class="col-md-6">
|
||||
<div class="fa fa-twitter-square" style="font-size:36px">
|
||||
<div class="ikona"><i><p1> <?php echo $TW; ?> </p1></i> </div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -103,12 +103,12 @@ if ($sql = $mysqli->prepare("SELECT * FROM user WHERE user_id = 2 "))
|
||||
|
||||
|
||||
|
||||
<section id=\"post\" name=\"post\"></section>
|
||||
<div id=\"postwrap\">
|
||||
<div class=\"container\">
|
||||
<div class=\"row\">
|
||||
<h2>NAJNOWSZE WPISY</h2>";
|
||||
}
|
||||
<section id="post" name="post"></section>
|
||||
<div id="postwrap">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h2>NAJNOWSZE WPISY</h2>
|
||||
<?php }
|
||||
$sql->close();
|
||||
}
|
||||
else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
|
||||
@ -116,44 +116,39 @@ else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
|
||||
|
||||
|
||||
$trash = '';
|
||||
if ($sql = $mysqli->prepare("SELECT * FROM post ORDER BY data_dodania"))
|
||||
if ($sql = $mysqli->prepare("SELECT * FROM post WHERE blog_id=$user_id ORDER BY data_dodania"))
|
||||
{
|
||||
$sql->execute();
|
||||
$sql->bind_result($post_id,$trash,$title,$description,$main,$image,$date,$mod_date);
|
||||
while ($sql->fetch())
|
||||
{
|
||||
echo " <div class=\"col-lg-4 col-md-6 col-sm-6 col-xs-12 desc\">
|
||||
{ ?>
|
||||
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12 desc">
|
||||
|
||||
<div class=\"project\">
|
||||
<div class=\"photo-wrapper\">
|
||||
<div class=\"photo foto cover\">
|
||||
<div class="project">
|
||||
<div class="photo-wrapper">
|
||||
<div class="photo foto cover">
|
||||
|
||||
<a href=\"post.php\"><img class=\"img-responsive\" src=\"$image\" alt=\"\">
|
||||
<div class=\"text-block\">
|
||||
<p1>$date</p1>
|
||||
<a href="post.php?post=<?php echo $post_id; ?>"><img class="img-responsive" src="<?php echo $image; ?>" alt="">
|
||||
<div class="text-block">
|
||||
<p1><?php echo $date; ?></p1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> <h1> $title</h1></a>
|
||||
</div>";
|
||||
}
|
||||
</div> <h1> <?php echo $title; ?></h1></a>
|
||||
</div>
|
||||
<?php }
|
||||
$sql->close();
|
||||
}
|
||||
else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
|
||||
|
||||
$mysqli->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
include "404.php";
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
include "../settings/db_connect.php";
|
||||
$_SESSION['message'] = '';
|
||||
$post=$_GET['post'];
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
$tekst = $mysqli->real_escape_string($_POST['tekst']);
|
||||
$_SESSION['tekst'] = $tekst;
|
||||
@ -9,7 +10,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
|
||||
if($mysqli->query($sql) === true){
|
||||
$_SESSION['message'] = "Dodanie komentarza się powiodło!";
|
||||
header("location:post.php");
|
||||
header("location:post.php?post=$post");
|
||||
}
|
||||
else{
|
||||
$_SESSION['message'] = "Nie udało się dodać komentarza!";
|
||||
|
13
blog-post/menu.php
Normal file
13
blog-post/menu.php
Normal file
@ -0,0 +1,13 @@
|
||||
<div class="dropdown">
|
||||
<div id="menuwrap">
|
||||
<button class="btn btn-light dropdown-toggle btn-lg" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Menu
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||
<li><a href="#about">O mnie</a></li>
|
||||
<li><a href="#post">Posty</a></a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="../index.html">Strona główna</a></li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,3 +1,6 @@
|
||||
<?php if( !isset( $_SESSION ) ) session_start();
|
||||
$user_id = $_SESSION['user_id'];
|
||||
?>
|
||||
<html lang="pl-PL">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@ -22,22 +25,17 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="dropdown">
|
||||
<div id="menuwrap">
|
||||
<button class="btn btn-light dropdown-toggle btn-lg" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
Menu
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||
<li><a href="blog.php#about">O mnie</a></li>
|
||||
<li><a href="blog.php#post">Posty</a></a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="../index.html">Strona główa</a></li>
|
||||
<li><a href="blog.php?user_id=<?php echo $user_id; ?>">Wróć do bloga</a></li>
|
||||
<li><a href="../index.html">Strona główna</a></li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="aboutdown">
|
||||
<section id="about" name="about"></section>
|
||||
|
||||
@ -53,59 +51,56 @@
|
||||
<?php
|
||||
include "../settings/db_connect.php";
|
||||
|
||||
|
||||
$post = $_GET['post'];
|
||||
$trash = '';
|
||||
if ($sql = $mysqli->prepare("SELECT * FROM post WHERE post_id = 18"))
|
||||
if ($sql = $mysqli->prepare("SELECT * FROM post WHERE post_id =$post"))
|
||||
{
|
||||
$sql->execute();
|
||||
$sql->bind_result($post_id,$trash,$title,$description,$main,$image,$date,$mod_date);
|
||||
while ($sql->fetch())
|
||||
{
|
||||
echo "
|
||||
{ ?>
|
||||
<div class="col-lg-12 name foto2 cover foto1">
|
||||
|
||||
|
||||
<div class=\"col-lg-12 name foto2 cover foto1\">
|
||||
<img class="align-text-bottom" src="<?php echo $image; ?>" alt="">
|
||||
|
||||
|
||||
<img class=\"align-text-bottom\" src=\"$image\" alt=\"\">
|
||||
|
||||
|
||||
<h1> $title</h1>
|
||||
<h1><?php echo $title; ?></h1>
|
||||
</div>
|
||||
|
||||
<div class=\"col-lg-12 name-desc\">
|
||||
<h3>$description</h3>
|
||||
<div class="col-lg-12 name-desc">
|
||||
<h3><?php echo $description; ?></h3>
|
||||
</div>
|
||||
|
||||
<div class=\"col-lg-12 name-desc\">
|
||||
<post>$main</post>
|
||||
<div class="col-lg-12 name-desc">
|
||||
<post><?php echo $main; ?></post>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<div id=\"particles-js\">
|
||||
<div class=\"container\">
|
||||
<form class=\"form\" action=\"rating.php\" method=\"post\" enctype=\"multipart/form-data\" autocomplete=\"off\">
|
||||
<div class=\"row registerMain\">
|
||||
<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 name-desc\">
|
||||
<h4>$date</h4>
|
||||
<div id="particles-js">
|
||||
<div class="container">
|
||||
<form class="form" action="rating.php?post=<?php echo $post; ?>" method="post" enctype="multipart/form-data" autocomplete="off">
|
||||
<div class="row registerMain">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 name-desc">
|
||||
<h4><?php echo $date; ?></h4>
|
||||
</div><br>
|
||||
<div class=\"col-lg-6 col-md-6 col-sm-6 col-xs-12 name-desc elementsOnRegisterMain\">
|
||||
<div class=\"form-group inputmain\">
|
||||
<div class=\"form-group\">
|
||||
<div class=\"rate\">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 name-desc elementsOnRegisterMain">
|
||||
<div class="form-group inputmain">
|
||||
<div class="form-group">
|
||||
<div class="rate">
|
||||
<z>Ocena:</z>
|
||||
|
||||
<input type=\"submit\" id=\"star5\" name=\"rating\" value=5 />
|
||||
<input type=\"submit\" id=\"star4\" name=\"rating\" value=4 />
|
||||
<input type=\"submit\" id=\"star3\" name=\"rating\" value=3 />
|
||||
<input type=\"submit\" id=\"star2\" name=\"rating\" value=2 />
|
||||
<input type=\"submit\" id=\"star1\" name=\"rating\" value=1 />
|
||||
<input type="submit" id="star5" name="rating" value=5 />
|
||||
<input type="submit" id="star4" name="rating" value=4 />
|
||||
<input type="submit" id="star3" name="rating" value=3 />
|
||||
<input type="submit" id="star2" name="rating" value=2 />
|
||||
<input type="submit" id="star1" name="rating" value=1 />
|
||||
|
||||
<label for=\"star5\" title=\"5 gwiazdek\">5 stars</label>
|
||||
<label for=\"star4\" title=\"4 gwiazdki\">4 stars</label>
|
||||
<label for=\"star3\" title=\"3 gwiazdki\">3 stars</label>
|
||||
<label for=\"star2\" title=\"2 gwiazdki\">2 stars</label>
|
||||
<label for=\"star1\" title=\"1 gwiazdka\">1 star</label>
|
||||
<label for="star5" title="5 gwiazdek">5 stars</label>
|
||||
<label for="star4" title="4 gwiazdki">4 stars</label>
|
||||
<label for="star3" title="3 gwiazdki">3 stars</label>
|
||||
<label for="star2" title="2 gwiazdki">2 stars</label>
|
||||
<label for="star1" title="1 gwiazdka">1 star</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -115,9 +110,9 @@ if ($sql = $mysqli->prepare("SELECT * FROM post WHERE post_id = 18"))
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>";
|
||||
</div>
|
||||
|
||||
}
|
||||
<?php }
|
||||
$sql->close();
|
||||
}
|
||||
else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
|
||||
@ -127,54 +122,40 @@ else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
|
||||
if ($sql = $mysqli->prepare("SELECT * FROM comments ORDER BY comment_id"))
|
||||
{
|
||||
$sql->execute();
|
||||
$sql->bind_result($comment_id,$post_id,$username,$tekst,$data_dodania, $data_modyfikacji);
|
||||
echo " <div class=\"name-desc\"> <h1> Komentarze</h1> </div> ";
|
||||
while ($sql->fetch())
|
||||
{
|
||||
|
||||
echo "
|
||||
<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12 name-desc\">
|
||||
<a href=\"blog.php\"><po> $username</po></a>
|
||||
<h6>$tekst </h6>
|
||||
<h5>$data_modyfikacji</h5>
|
||||
</div>";
|
||||
}
|
||||
$sql->bind_result($comment_id,$post_id,$username,$tekst,$data_dodania, $data_modyfikacji); ?>
|
||||
<div class="name-desc"> <h1> Komentarze</h1> </div>
|
||||
<?php while ($sql->fetch())
|
||||
{ ?>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 name-desc">
|
||||
<a href="blog.php"><po><?php echo $username; ?></po></a>
|
||||
<h6><?php echo $tekst; ?></h6>
|
||||
<h5><?php echo $data_modyfikacji; ?></h5>
|
||||
</div>
|
||||
<?php }
|
||||
$sql->close();
|
||||
}
|
||||
else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." );
|
||||
$mysqli->close();
|
||||
} ?>
|
||||
<div class="name"> <h2> Dodaj komentarz:</h2> </div>
|
||||
|
||||
|
||||
echo " <div class=\"name\"> <h2> Dodaj komentarz:</h2> </div>
|
||||
|
||||
|
||||
|
||||
<div id=\"particles-js\">
|
||||
<div class=\"container\">
|
||||
<form class=\"form\" action=\"comment.php\" method=\"post\" enctype=\"multipart/form-data\" autocomplete=\"off\">
|
||||
<div class=\"row registerMain\">
|
||||
<div class=\"offset-3 col-6 offset-3 elementsOnRegisterMain\">
|
||||
<div class=\"form-group inputmain\">
|
||||
<div class=\"form-group\">
|
||||
<textarea class=\"form-control\" rows=\"4\" id=\"tekst\" name=\"tekst\" required></textarea>
|
||||
<div class="container">
|
||||
<form class="form" action="comment.php?post=<?php echo $post; ?>" method="post" enctype="multipart/form-data" autocomplete="off">
|
||||
<div class="row registerMain">
|
||||
<div class="offset-3 col-6 offset-3 elementsOnRegisterMain">
|
||||
<div class="form-group inputmain">
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" rows="4" id="tekst" name="tekst" required></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=\"row registerFooter\">
|
||||
<div class=\"offset-3 col-6 offset-3 elementsOnRegisterFooter\">
|
||||
<div class="row registerFooter">
|
||||
<div class="offset-3 col-6 offset-3 elementsOnRegisterFooter">
|
||||
<div>
|
||||
<input type=\"submit\" value=\"Dodaj\" name=\"register\" class=\"btn btn-block\" />
|
||||
<input type="submit" value="Dodaj" name="register" class="btn btn-block" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>";
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
include "../settings/db_connect.php";
|
||||
$_SESSION['message'] = '';
|
||||
$post=$_GET['post'];
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
$rating = $mysqli->real_escape_string($_POST['rating']);
|
||||
$_SESSION['rating'] = $rating;
|
||||
@ -9,7 +10,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
|
||||
if($mysqli->query($sql) === true){
|
||||
$_SESSION['message'] = "Dodanie oceny się powiodło!";
|
||||
header("location:post.php");
|
||||
header("location:post.php?post=$post");
|
||||
}
|
||||
else{
|
||||
$_SESSION['message'] = "Nie udało się dodać ooceny!";
|
||||
|
@ -1,4 +1,4 @@
|
||||
Ogółem:
|
||||
Ogółem:
|
||||
• Zakładanie konta/bloga (wielu użytkowników) check
|
||||
• Nagłówek bloga (Tytuł, krótki opis) check
|
||||
• Kategoryzowanie wpisów nope
|
||||
|
Loading…
Reference in New Issue
Block a user