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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/nbproject/private/
44 changes: 44 additions & 0 deletions commenthandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
$dbh = new PDO( "mysql:dbname=simpleblog;host=localhost", "simpleblog", "simpleblog" );

if(isset($_GET["id"])) {
$curComments = $dbh->prepare("SELECT * FROM comments WHERE PID=?");
$curComments->bindParam(1, $_GET["id"]);
$curComments->execute();
} else if(isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["id"]) && isset($_POST["content"])) {
$stmt = $dbh->prepare("INSERT INTO `simpleblog`.`comments` (`ID`, `PID`, `name`, `email`, `date`, `content`) VALUES (NULL, :id, :name, :email, :date, :content);");
$stmt->bindParam(":name", $_POST["name"]);
$stmt->bindParam(":email", $_POST["email"]);
$stmt->bindParam(":id", $_POST["id"]);
$stmt->bindParam(":content", $_POST["content"]);
$date = date('Y-m-d');
$stmt->bindParam(":date", $date);
$stmt->execute();

$curComments = $dbh->prepare("SELECT * FROM comments WHERE PID=?");
$curComments->bindParam(1, $_POST["id"]);
$curComments->execute();
}

?>

<div class='portocontainer' style="clear:both;">

<?php while ($row = $curComments->fetch(PDO::FETCH_ASSOC)) : ?>

<div class="item">
<div class='detail'>
<p>
<?php echo $row['email'] . "<br /> " . $row['date']; ?>

</p>
</div>
<div class='desc'>
<div class='title'><h1 class='left'><?php echo "Comment by " . $row['name']; ?></h1></div>
<p><?php echo nl2br($row['content']); ?></p>
</div>
</div>

<?php endwhile; ?>

</div>
23 changes: 23 additions & 0 deletions dbclean.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title>Cleaning database</title>
</head>
<body>
Cleaning Database...
<?php
/*
$dbh = new PDO( "mysql:dbname=simpleblog;host=localhost", "simpleblog", "simpleblog" );
$deletor = $dbh->prepare("SELECT * FROM comments WHERE PID=?");
$curComments->execute();
*/
?>
Database Cleaning is not implemented.
</body>
</html>
151 changes: 151 additions & 0 deletions editor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<!--
Copyright (C) 2014 Dalva - dalva24.com
All Rights Reserved.
Hand-Coded in the Aestaria and Quadsitron.
-->

<?php

$title = "Edit a Post - Simple Blog by Dariel Valdano";
$description = "Edit a Post";
$selectedID = 2;
$current_url = "blog.localhost/editor.php";

//$status = "new";
$initialTitle = "";
$initialContent = "";
$initialID = -1;
if (isset($_GET['id'])) {
$dbh = new PDO( "mysql:dbname=simpleblog;host=localhost", "simpleblog", "simpleblog" );
//$status = "editing";
$curEdit = $dbh->prepare("SELECT * FROM posts WHERE ID=?");
$curEdit->bindParam(1, $_GET["id"]);
$curEdit->execute();
$row = $curEdit->fetch(PDO::FETCH_ASSOC);
$initialTitle = $row['title'];
$initialContent = $row['content'];
$initialID = $_GET['id'];
}

if (isset($_POST["title"]) && isset($_POST["date"]) && isset($_POST["content"]) && isset($_POST["id"])) {
$dbh = new PDO( "mysql:dbname=simpleblog;host=localhost", "simpleblog", "simpleblog" );
$initialTitle = $_POST["title"];
$initialContent = $_POST["content"];
if ($_POST["id"] == -1) {
//$status = "posted";
$create = $dbh->prepare("INSERT INTO `simpleblog`.`posts` (`ID`, `title`, `date`, `content`) VALUES (NULL, ?, ?, ?);");
$create->bindParam(1, $_POST["title"]);
$create->bindParam(2, $_POST["date"]);
$create->bindParam(3, $_POST["content"]);
$create->execute();
} else {
//$status = "updated";
$update = $dbh->prepare("UPDATE `simpleblog`.`posts` SET `title` = :title, `date` = :date, `content` = :content WHERE `posts`.`ID` = :id;");
$update->bindParam(':title', $_POST["title"]);
$update->bindParam(':date', $_POST["date"]);
$update->bindParam(':content', $_POST["content"]);
$update->bindParam(':id', $_POST["id"]);
$update->execute();
}
}

?>

<html lang="en">
<head>
<!-- Technical Metadata -->
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="/img/ridecon.png?v=1">
<link rel="stylesheet" type="text/css" href="/res/mainStyle.css"/>
<link rel="stylesheet" type="text/css" href="/res/devFont.css"/>

<!-- SEO and Social Metadata -->
<title><?php echo $title;?></title>
<meta name="description" content="<?php echo $description; ?>">
<link rel="author" href="https://plus.google.com/+DarielValdano"/>
<meta property="fb:admins" content="100000437744017" />
<meta property="og:type" content="website"/>
<meta property="og:title" content="<?php echo $title;?>"/>
<meta property="og:description" content="<?php echo $description; ?>" />
<meta property="og:image" content="http://dalva24.com/img/dalva24.png"/>
<meta property="og:url" content="<?php echo $current_url; ?>">
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="Dariel Valdano's Personal Website" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="<?php echo $title;?>" />
<meta name="twitter:description" content="<?php echo $description; ?>" />
<meta name="twitter:image" content="http://dalva24.com/img/dalva24.png" />
<meta name="twitter:url" content="<?php echo $current_url; ?>" />
</head>
<body onunload=''>
<div class='center'>
<nav>
<a class='menu' <?php if ($selectedID == 1) {echo 'id="selectedMenu" '; } ?>href='index.php'><div class='menu'>Articles</div><div class='desc'>List em all!</div></a>
<a class='menu' <?php if ($selectedID == 2) {echo 'id="selectedMenu" '; } ?>href='editor.php'><div class='menu'>Editor</div><div class='desc'>Make a new post!</div></a>
<div class='menuCenter'><div class='ridecon'></div></div>
<a class='menu' <?php if ($selectedID == 3) {echo 'id="selectedMenu" '; } ?>href='view.php'><div class='menu'>View</div><div class='desc'>View a post</div></a>
<a class='menu' <?php if ($selectedID == 4) {echo 'id="selectedMenu" '; } ?>href='http://dalva24.com'><div class='menu'>My Site</div><div class='desc'>Visit the original</div></a>
</nav>
<main>

<script>
//validator
function checkdate(){
var input = document.getElementById("DateIn");
var validformat=/^\d{4}-\d{2}-\d{2}$/; //Basic check for format validity
var returnval=false;
if (!validformat.test(input.value)) {
alert("Invalid Date Format. Please correct and submit again.");
} else { //Detailed check for valid date ranges
var yearfield=input.value.split("-")[1];
var monthfield=input.value.split("-")[2];
var dayfield=input.value.split("-")[3];
var enteredDate = new Date(yearfield, monthfield-1, dayfield);
var today = new Date();
if (enteredDate.setHours(0,0,0,0) < today.setHours(0,0,0,0)) {
alert("Invalid date: the entered date is earlier than today.");
} else {
returnval=true;
}
}
return returnval;
}
</script>

<?php
$contentheight = "460px";
?>
<div style='height:<?php echo $contentheight ?>' class='content1'>
<div class='title'><h1 class='left'>Editor</h1></div>
Edit stuff here!
</div>
<div style='height:<?php echo $contentheight ?>' class='content3' >
<div class='title'></div>
<form id="mainForm" action="editor.php" method="post" enctype="multipart/form-data" onsubmit="return checkdate()">
<div class="entry" style="width:320px;"><div class="formtext" id="Name">Title</div><input id="TitleIn" name="title" type="text" required value="<?php echo $initialTitle; ?>"/></div>
<div class="entry" style="width:320px;"><div class="formtext" id="Date">Date</div><input id="DateIn" name="date" required type="text"/></div>
<div class="entry" style="width:100%;"><div class="formtext" id="Message">Message</div><textarea class="msg" name="content" required><?php echo $initialContent; ?></textarea></div>
<input id="ID" name="id" type="hidden" value="<?php echo $initialID; ?>"/>
<div class="button"><input id="submitButton" class="button" name="submit" value="Submit" type="submit"/></div>
</form>
</div>

<script>
//Autofill date
var date = new Date();
document.getElementById("DateIn").setAttribute("value", date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate());

</script>

<footer>
Site Design and Code &copy; Dariel Valdano 2014. All rights reserved. This site are simplified and is using dalva24's template from <a href='http://dalva24.com'>Dalva24.com</a>
</footer>
</main>
</div>
<div id="pagefader"></div>
<script src="/res/dalva.js"></script>
</body>
</html>
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added img/bg.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 img/dalva24.png
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 img/menuBG.png
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 img/menuBGH.png
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 img/menuBGS.png
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 img/ridecon.png
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 img/titleBG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!DOCTYPE html>
<!--
Copyright (C) 2014 Dalva - dalva24.com
All Rights Reserved.
Hand-Coded in the Aestaria and Quadsitron.
-->

<?php

$title = "List of Posts - Simple Blog by Dariel Valdano";
$description = "List of Posts";
$selectedID = 1;
$current_url = "blog.localhost/index.php";

$dbh = new PDO( "mysql:dbname=simpleblog;host=localhost", "simpleblog", "simpleblog" );

if (isset($_POST["delete"])) {
$delete = $dbh->prepare("DELETE FROM `simpleblog`.`posts` WHERE `posts`.`ID` = ?");
$delete->bindParam(1, $_POST["delete"]);
$delete->execute();
}

?>

<html lang="en">
<head>
<!-- Technical Metadata -->
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="/img/ridecon.png?v=1">
<link rel="stylesheet" type="text/css" href="/res/mainStyle.css"/>
<link rel="stylesheet" type="text/css" href="/res/devFont.css"/>

<!-- SEO and Social Metadata -->
<title><?php echo $title;?></title>
<meta name="description" content="<?php echo $description; ?>">
<link rel="author" href="https://plus.google.com/+DarielValdano"/>
<meta property="fb:admins" content="100000437744017" />
<meta property="og:type" content="website"/>
<meta property="og:title" content="<?php echo $title;?>"/>
<meta property="og:description" content="<?php echo $description; ?>" />
<meta property="og:image" content="http://dalva24.com/img/dalva24.png"/>
<meta property="og:url" content="<?php echo $current_url; ?>">
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="Dariel Valdano's Personal Website" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="<?php echo $title;?>" />
<meta name="twitter:description" content="<?php echo $description; ?>" />
<meta name="twitter:image" content="http://dalva24.com/img/dalva24.png" />
<meta name="twitter:url" content="<?php echo $current_url; ?>" />
</head>
<body onunload=''>
<div class='center'>
<nav>
<a class='menu' <?php if ($selectedID == 1) {echo 'id="selectedMenu" '; } ?>href='index.php'><div class='menu'>Articles</div><div class='desc'>List em all!</div></a>
<a class='menu' <?php if ($selectedID == 2) {echo 'id="selectedMenu" '; } ?>href='editor.php'><div class='menu'>Editor</div><div class='desc'>Make a new post!</div></a>
<div class='menuCenter'><div class='ridecon'></div></div>
<a class='menu' <?php if ($selectedID == 3) {echo 'id="selectedMenu" '; } ?>href='view.php'><div class='menu'>View</div><div class='desc'>View a post</div></a>
<a class='menu' <?php if ($selectedID == 4) {echo 'id="selectedMenu" '; } ?>href='http://dalva24.com'><div class='menu'>My Site</div><div class='desc'>Visit the original</div></a>
</nav>
<main>


<div class='content'>
<div class='title'><h1 class='left'>A Simple Blog</h1></div>
<p>
A simple blog for IF3110 Assignment No. 1
</p>
</div>
<div class='portocontainer'>

<?php
$list = $dbh->prepare("SELECT * FROM posts");
$list->execute();
?>

<?php while($row = $list->fetch(PDO::FETCH_ASSOC)) : ?>
<div class="item">
<div class='detail'>
<div class='title'><h1 class="right">&rightarrowtail;</h1></div>
<p>
<?php
echo $row['date'] . "<br/>";
$countcomm = $dbh->prepare("SELECT count(ID) FROM comments where comments.PID = " . $row['ID']);
$countcomm->execute();
echo $countcomm->fetchColumn() . " comments<br/>";
?>
<a href=<?php echo "'editor.php?id=" . $row['ID'] . "'"; ?>>Edit</a> |
<a href='#' onclick=<?php echo "'delAsk(" . $row['ID'] . ")'"; ?>>Delete</a>
</p>
</div>
<div class='desc'>
<div class='title'><a href=<?php echo "'view.php?id=" . $row['ID'] . "'"; ?>><h1 class='left'><?php echo $row['title']; ?></h1></a></div>
<p><?php echo nl2br($row['content']); ?></p>
</div>
<form class='hidden' action="index.php" method="post" id=<?php echo "'delForm" . $row['ID'] . "'"; ?>>
<input class=hidden name='delete' value=<?php echo "'" . $row['ID'] . "'"; ?>>
</form>
</div>
<?php endwhile; ?>

<script>
function delAsk(id) {
var r = confirm("Are you sure you want to delete this post?");
if (r === true) {
document.getElementById("delForm" + id).submit();
}
}
</script>

</div>

<footer>
Site Design and Code &copy; Dariel Valdano 2014. All rights reserved. This site are simplified and is using dalva24's template from <a href='http://dalva24.com'>Dalva24.com</a>
</footer>
</main>
</div>
<div id="pagefader"></div>
<script src="/res/dalva.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include.path=${php.global.include.path}
php.version=PHP_55
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.
9 changes: 9 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>www-IF3110-01-Simple-Blog</name>
</data>
</configuration>
</project>
Binary file added res/Abel-Regular.woff
Binary file not shown.
Binary file added res/Gruppo.woff
Binary file not shown.
Binary file added res/OpenSans.woff
Binary file not shown.
Loading