Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions acomment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
// comment_add.php
include 'mysql.php';
date_default_timezone_set('Asia/Jakarta');

$PostID=$_POST['id'];
$name=$_POST['name'];
$email=$_POST['email'];
$content=$_POST['content'];

$query = mysql_safe_query('INSERT INTO comment (PostID,Date,Name,Email,Comment) VALUES (%s,%s,%s,%s,%s)', $PostID, date('Y-m-d H:i:s'), $name, $email, $content);
if ($query) {
echo "sent";
}

?>
13 changes: 13 additions & 0 deletions add_post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
include 'mysql.php';
date_default_timezone_set('Asia/Jakarta');

if (!empty($_POST)){
if (!mysql_safe_query('INSERT INTO post(Title,Date,Content) VALUES (%s,%s,%s)', $_POST['Judul'],$_POST['Tanggal'],$_POST['Konten'])){
echo mysql_error();
}
else{
redirect("index.php");
}
}
?>
17 changes: 14 additions & 3 deletions assets/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,15 @@ a:hover {
margin-left: -490px; /* Half width of nav */
border-bottom: 1px solid #333;
z-index: 2;
background-image: url('../../images/1.jpg');
background-repeat: no-repeat;
}
.nav.fixed {
position: fixed;
}
#logo {
float: left;
margin-left: 23%;
}
.nav-primary {
float: right;
Expand Down Expand Up @@ -222,18 +225,20 @@ div.cover > img {
================================================== */
.art {
margin-top: -131px;

}
/* Header */
.art-header {
height: 900px;
height: 660px;
/* Background image is defined in the post */
background-position: top center;
background-attachment: fixed;
background-attachment: relative;
overflow: hidden;

}
/* Contains the time, title and subtitle for an article */
.art-header-inner {
position: fixed;
position: relative;
top: 300px;
left: 50%;
margin-left: -490px;
Expand Down Expand Up @@ -382,10 +387,13 @@ div.cover > img {
================================================== */
.art-list {
padding: 120px 0 0;

background-repeat: none;
}
.art-list-body {
position: relative;
overflow: hidden;

}
.art-list-item {
padding: 40px 0;
Expand Down Expand Up @@ -435,6 +443,9 @@ div.cover > img {
padding: 30px 0 40px;
overflow: hidden;
border-top: 1px solid #ccc;
background-image: url(../../images/2.jpg);
background-repeat: no-repeat;
background-size: 800px 230px;
}
.footer,
.footer a {
Expand Down
8 changes: 8 additions & 0 deletions dcomment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
// comment_add.php
include 'mysql.php';
date_default_timezone_set('Asia/Jakarta');

mysql_safe_query('DELETE FROM comment WHERE ComID = %s', $_GET['ComID']);
redirect('post.php?PostID='.$_GET['PostID'].'');
?>
8 changes: 8 additions & 0 deletions delete_post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
// post_delete.php
include 'mysql.php';
date_default_timezone_set('Asia/Jakarta');
mysql_safe_query('DELETE FROM post WHERE PostID=%s LIMIT 1', $_GET['PostID']);
mysql_safe_query('DELETE FROM comment WHERE PostID=%s', $_GET['PostID']);
redirect('index.php');
?>
64 changes: 34 additions & 30 deletions new_post.html → edit_post.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,66 @@
<meta property="og:site_name" content="Simple Blog">

<link rel="stylesheet" type="text/css" href="assets/css/screen.css" />
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="images/t.png">

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<title>Simple Blog | Tambah Post</title>
<title>Simple Blog | Edit Post</title>


</head>

<?php
// post_edit.php
include 'mysql.php';

if(!empty($_POST)) {
if(mysql_safe_query('UPDATE post SET Title=%s, Date=%s, Content=%s WHERE PostID=%s', $_POST['Judul'], $_POST['Tanggal'], $_POST['Konten'], $_GET['PostID'])){

redirect('index.php?');
}
else{
echo mysql_error();
}
}

$result = mysql_safe_query('SELECT * FROM post WHERE PostID=%s', $_GET['PostID']);

if(!mysql_num_rows($result)) {
echo 'Post #'.$_GET['PostID'].' not found';
exit;
}

$row = mysql_fetch_assoc($result);
?>

<body class="default">
<div class="wrapper">

<nav class="nav">
<a style="border:none;" id="logo" href="index.html"><h1>Simple<span>-</span>Blog</h1></a>
<ul class="nav-primary">
<li><a href="new_post.html">+ Tambah Post</a></li>
</ul>
</nav>

<article class="art simple post">


<h2 class="art-title" style="margin-bottom:40px">-</h2>

<div class="art-body">
<div class="art-body-inner">
<h2>Tambah Post</h2>
<h2>Edit Post</h2>

<div id="contact-area">
<form method="post" action="#">
<label for="Judul">Judul:</label>
<input type="text" name="Judul" id="Judul">

<label for="Tanggal">Tanggal:</label>
<input type="text" name="Tanggal" id="Tanggal">
<input type="text" name="Judul" id="Judul" <?php echo 'value="'.$row['Title'].'"'?> >

<label for="Tanggal">Tanggal:</label>
<input type="text" name="Tanggal" id="Tanggal" <?php echo 'value="'.$row['Date'].'"'?> >

<label for="Konten">Konten:</label><br>
<textarea name="Konten" rows="20" cols="20" id="Konten"></textarea>
<textarea name="Konten" rows="20" cols="20" id="Konten" ></textarea>

<input type="submit" name="submit" value="Simpan" class="submit-button">
</form>
Expand All @@ -73,9 +93,9 @@ <h2>Tambah Post</h2>
</article>

<footer class="footer">
<div class="back-to-top"><a href="">Back to top</a></div>
<div class="back-to-top"><a href="index.php">Home</a></div>
<!-- <div class="footer-nav"><p></p></div> -->
<div class="psi">&Psi;</div>
<div class="psi">Teofebano 13512050</div>
<aside class="offsite-links">
Asisten IF3110 /
<a class="rss-link" href="#rss">RSS</a> /
Expand All @@ -90,22 +110,6 @@ <h2>Tambah Post</h2>

</aside>
</footer>

</div>

<script type="text/javascript" src="assets/js/fittext.js"></script>
<script type="text/javascript" src="assets/js/app.js"></script>
<script type="text/javascript" src="assets/js/respond.min.js"></script>
<script type="text/javascript">
var ga_ua = '{{! TODO: ADD GOOGLE ANALYTICS UA HERE }}';

(function(g,h,o,s,t,z){g.GoogleAnalyticsObject=s;g[s]||(g[s]=
function(){(g[s].q=g[s].q||[]).push(arguments)});g[s].s=+new Date;
t=h.createElement(o);z=h.getElementsByTagName(o)[0];
t.src='//www.google-analytics.com/analytics.js';
z.parentNode.insertBefore(t,z)}(window,document,'script','ga'));
ga('create',ga_ua);ga('send','pageview');
</script>

</body>
</html>
Binary file added images/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/t.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 40 additions & 31 deletions index.html → index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,64 @@
<meta property="og:site_name" content="Simple Blog">

<link rel="stylesheet" type="text/css" href="assets/css/screen.css" />
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="images/t.png">

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<title>Simple Blog</title>
<title>TeBonBon Blog</title>


</head>

<script type="text/javascript" src="comment.js"> </script>
<body class="default">
<div class="wrapper">

<nav class="nav">
<a style="border:none;" id="logo" href="index.html"><h1>Simple<span>-</span>Blog</h1></a>
<a style="border:none;" id="logo" href="index.php"><h1>TeBonBon<span>-</span>Blog</h1></a>
<ul class="nav-primary">
<li><a href="new_post.html">+ Tambah Post</a></li>
<li><a href="new_post.php">+ Add Post</a></li>
</ul>
</nav>

<div id="home">
<div class="posts">
<nav class="art-list">
<br>

<ul class="art-list-body">
<li class="art-list-item">
<br>
<h1>POST</h1>
<?php
include 'mysql.php';
$sorted = mysql_safe_query('SELECT * FROM post ORDER BY Date DESC');
if (!mysql_num_rows($sorted)){
echo 'There is no post yet!!!';
}
else{
while ($row = mysql_fetch_assoc($sorted)){ ?>

<li class="art-list-item">
<div class="art-list-item-title-and-time">
<h2 class="art-list-title"><a href="post.html">Apa itu Simple Blog?</a></h2>
<div class="art-list-time">15 Juli 2014</div>
<h2 class="art-list-title"><?php echo '<a href="post.php?PostID='.$row['PostID'].'">'.$row['Title'].'</a>'; ?> </h2>
<div class="art-list-time"><?php echo ''.$row['Date'].''; ?></div>
<div class="art-list-time"><span style="color:#F40034;">&#10029;</span> Featured</div>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! &hellip;</p>
<p>
<a href="#">Edit</a> | <a href="#">Hapus</a>
<p> <?php
$body = substr($row['Content'], 0, 180);
echo nl2br($body).'...<br/>';
?>
</p>
</li>

<li class="art-list-item">
<div class="art-list-item-title-and-time">
<h2 class="art-list-title"><a href="post.html">Siapa dibalik Simple Blog?</a></h2>
<div class="art-list-time">11 Juli 2014</div>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! &hellip;</p>
<p>
<a href="#">Edit</a> | <a href="#">Hapus</a>
<?php echo '<a href="edit_post.php?PostID='.$row['PostID'].'"> Edit </a>'; ?>| <?php echo '<a href="delete_post.php?PostID='.$row['PostID'].'" class="confirmation"> Hapus </a>'; ?>
</p>
</li>
</li>

<?php
}
}
?>
</ul>
</nav>
</div>
Expand All @@ -78,7 +89,7 @@ <h2 class="art-list-title"><a href="post.html">Siapa dibalik Simple Blog?</a></h
<footer class="footer">
<div class="back-to-top"><a href="">Back to top</a></div>
<!-- <div class="footer-nav"><p></p></div> -->
<div class="psi">&Psi;</div>
<div class="psi">Teofebano 13512050</div>
<aside class="offsite-links">
Asisten IF3110 /
<a class="rss-link" href="#rss">RSS</a> /
Expand All @@ -100,15 +111,13 @@ <h2 class="art-list-title"><a href="post.html">Siapa dibalik Simple Blog?</a></h
<script type="text/javascript" src="assets/js/app.js"></script>
<script type="text/javascript" src="assets/js/respond.min.js"></script>
<script type="text/javascript">
var ga_ua = '{{! TODO: ADD GOOGLE ANALYTICS UA HERE }}';

(function(g,h,o,s,t,z){g.GoogleAnalyticsObject=s;g[s]||(g[s]=
function(){(g[s].q=g[s].q||[]).push(arguments)});g[s].s=+new Date;
t=h.createElement(o);z=h.getElementsByTagName(o)[0];
t.src='//www.google-analytics.com/analytics.js';
z.parentNode.insertBefore(t,z)}(window,document,'script','ga'));
ga('create',ga_ua);ga('send','pageview');
var elems = document.getElementsByClassName('confirmation');
var confirmIt = function (e) {
if (!confirm('Are you sure?')) e.preventDefault();
};
for (var i = 0, l = elems.length; i < l; i++) {
elems[i].addEventListener('click', confirmIt, false);
}
</script>

</body>
</html>
23 changes: 23 additions & 0 deletions mysql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
// mysql.php
function mysql_safe_string($value) {
$value = trim($value);
if(empty($value)) return 'NULL';
elseif(is_numeric($value)) return $value;
else return "'".mysql_real_escape_string($value)."'";
}

function mysql_safe_query($query) {
$args = array_slice(func_get_args(),1);
$args = array_map('mysql_safe_string',$args);
return mysql_query(vsprintf($query,$args));
}

function redirect($uri) {
header('location:'.$uri);
exit;
}

mysql_connect('127.0.0.1','root','');
mysql_select_db('simpleblog');
?>
Loading