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
2 changes: 1 addition & 1 deletion assets/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ hr.featured-article {
text-align: center;
}
hr.featured-article:after {
content: "✭ Featured Article ✭";
content: "✭ The Story ✭";
display: inline-block;
position: relative;
top: -0.8em;
Expand Down
144 changes: 0 additions & 144 deletions assets/js/app.js

This file was deleted.

46 changes: 0 additions & 46 deletions assets/js/fittext.js

This file was deleted.

4 changes: 0 additions & 4 deletions assets/js/jquery.min.js

This file was deleted.

2 changes: 0 additions & 2 deletions assets/js/respond.min.js

This file was deleted.

14 changes: 14 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

function ajax_comment_load()
{
var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function() {
if (ajax.readyState==4 && ajax.status==200) {
document.getElementById('').innderHTML = ajax.responseText;
}
}
ajax.open("GET", url_load_comments, true);
ajax.send();
}

function ajax_
18 changes: 18 additions & 0 deletions assets/sql/schemas.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE DATABASE IF NOT EXISTS lolibook;

CREATE TABLE IF NOT EXISTS posts (
id INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(256),
date DATETIME,
content TEXT
);

CREATE TABLE IF NOT EXISTS comments (
id INT PRIMARY KEY AUTO_INCREMENT,
post_id INT NOT NULL,
name VARCHAR(64),
email VARCHAR(64),
date DATETIME,
content TEXT,
FOREIGN KEY (post_id) REFERENCES posts(id)
);
13 changes: 13 additions & 0 deletions flows/actions/add_post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

require_once dirname(__DIR__) . "/works/post.php";
require_once dirname(__DIR__) . "/assists/url.php";

$title = $_POST["title"];
$date = $_POST["date"];
$content = $_POST["content"];

$postm = new Post();

$id = $postm->insert($title, $date, $content);
header("Location: " . URL::view_post($id, array("add" => true)));
14 changes: 14 additions & 0 deletions flows/actions/edit_post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

require_once dirname(__DIR__) . "/works/post.php";
require_once dirname(__DIR__) . "/assists/url.php";

$id = $_POST["id"];
$title = $_POST["title"];
$date = $_POST["date"];
$content = $_POST["content"];

$postm = new Post();

$postm->update($id, $title, $date, $content);
header("Location: " . URL::view_post($id, array("edit" => true)));
12 changes: 12 additions & 0 deletions flows/ajax/comment_add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require_once dirname(__DIR__) . "/works/comment.php";

$post_id = $_POST["post_id"];
$name = $_POST["name"];
$email = $_POST["email"]
$date = $_POST["date"];
$content = $_POST["content"];

$comt = new Comment();
echo ($comt->insert($post_id, $name, $email, $date, $content) > 0) ? "SUCCESS" : "FAILED";
25 changes: 25 additions & 0 deletions flows/ajax/comment_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require_once "flows/works/comment.php";

$comm = new Comment();
$comments = $comm->get($_GET["post_id"]);
if (mysqli_num_rows($comments) > 0)
{
while ($comment = mysql_fetch_assoc($comments)) {
?>
<li class="art-list-item">
<div class="art-list-item-title-and-time">
<h2 class="art-list-title"><a href="#"><?php echo $comment["name"]; ?></a></h2>
<div class="art-list-time"><?php echo date("l, j F Y", strtotime($comment["date"])); ?></div>
</div>
<p><?php echo $comment["content"]; ?></p>
</li>
<?php
}
} else
{
?>
<P>No comments have been posted for this post.</p>
<?php
}
64 changes: 64 additions & 0 deletions flows/assists/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

require_once dirname(__DIR__) . "/scenario.php";

class DataBase
{
private static $mysqli = null;
private static $connected = false;

public function __construct($auto = false)
{
if ($auto)
{
self::connect();
}
}


public function __destruct()
{
if (self::$connected)
{
mysqli_close(self::$mysqli);
}
}

public function connect()
{
if (! self::$connected)
{
global $db_host, $db_user, $db_pass, $db_name;
self::$mysqli = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (self::$mysqli->connect_errno)
{
echo "Failed to connect: (" . self::$mysqli->connect_errno . ") " . self::$mysqli->connect_error;
} else
{
self::$connected = true;
}
}
}

/* Normal query, not prepared */
public function query($query, $param)
{
self::connect();
if ($param != null)
{
foreach ($param as $key => $value)
{
$query = str_ireplace("%{$key}%", mysqli_real_escape_string(self::$mysqli, $value), $query);
}
}
$result = mysqli_query(self::$mysqli, $query);
if (stripos($query, "INSERT") !== false || stripos($query, "UPDATE") !== false)
{
return mysqli_insert_id(self::$mysqli);
} else
{
return $result;
}
}
}

Empty file added flows/assists/index.php
Empty file.
Loading