Split project into multiple files, added a way to post to the blog and rewrote README file

This commit is contained in:
Jack-Benny Persson 2013-07-25 06:12:02 +02:00
parent b14dc108c3
commit 36751401ca
6 changed files with 77 additions and 29 deletions

17
COPYRIGHT Normal file
View File

@ -0,0 +1,17 @@
Copyright (C) 2013 Jack-Benny Persson <jack-benny@cyberinfo.se>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

View File

@ -1,12 +1,11 @@
simplog
=======
simplog is a (very) simply PHP blog engine. It's supposed to be implemented into an existing webpage since this in only the engine part and does not contain a ccomplete webpage/blog of any kind.
simplog is a (very) simply PHP blog engine. It's supposed to be implemented into an existing webpage since this in only the engine part and does not contain a ccomplete webpage/blog of any kind. It's also intended to only have a single user.
What's missing?
---------------
Pretty much everything, depending on how you plan to use it. simplog as of right now does not include anything to acually write/post blog posts. To create a blog post you have to manually create it in a MySQL database.
As of right now the only thing it can do is to display posts already created.
Pretty much everything, depending on how you plan to use it. Included is a template to create the MySQL table, a small HTML and PHP file to create new posts, an index.php that displays your posts and a config file to connect to a database and set number of posts per page. What's currently missing is a way to edit posts. Also you need to protect the user directory yourself (with for example a .htaccess file), or else everyone can post to your blog.
How do I create the MySQL table?
--------------------------------

12
config.php Normal file
View File

@ -0,0 +1,12 @@
<?php
// MySQL config options
$host = "localhost";
$database = "test_db";
$user = "test_db";
$password = "test_pw";
// How many posts do we want on each page
$posts_per_page = 5;
?>

View File

@ -1,31 +1,7 @@
<?php
// Copyright (C) 2013 Jack-Benny Persson <jack-benny@cyberinfo.se>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// MySQL config options
$host = "localhost";
$database = "test_db";
$user = "test_db";
$password = "test_pw";
// How many posts do we want on each page
$posts_per_page = 5;
// Include config file
require "config.php";
// Connect to MySQL database
$link = mysql_connect($host, $user, $password)

28
user/createpost.php Normal file
View File

@ -0,0 +1,28 @@
<?php
// Include config file
require "../config.php";
// Connect to MySQL database
$link = mysql_connect($host, $user, $password)
or die("Could not connect...");
mysql_select_db($database)
or die("Could not open database");
$query = "INSERT INTO blog (date, title, posttext) VALUES
('$_POST[date]','$_POST[title]','$_POST[post]')";
if (!mysql_query($query))
{
die ("Something went wrong!");
}
print "Post added";
// Close MySQL link
mysql_close($link);
?>

16
user/newpost.html Normal file
View File

@ -0,0 +1,16 @@
<html><title>Create a new post</title>
<body>
<form action="createpost.php" method="post">
Date: (YYYY-MM-DD) <input type="date" name="date">
<br />
Title: <input type="text" name="title">
<br />
Text: <br />
<textarea cols="50" rows="10" name="post"></textarea>
<br />
<input type="submit">
</form>
</body>
</html>