Ok, Sniko suggested this, its working and tested. Althought i will be adding an editing feature, and a pharser (for videos etc..) This isnt that big'a mod. But works well.
Run these on something like PhpMyAdmin:
CREATE TABLE IF NOT EXISTS `blogs` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(225) NOT NULL DEFAULT '',
`blog` TEXT NOT NULL,
`posted` INT(11) NOT NULL DEFAULT 1,
`time` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY(`ID`)
) ENGINE=MyISAM auto_increment=0;
CREATE TABLE IF NOT EXISTS `blog_comments` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`blogID` INT(11) NOT NULL DEFAULT 0,
`time` INT(11) NOT NULL DEFAULT 0,
`comment` TEXT NOT NULL,
`posted` INT(11) NOT NULL DEFAULT 1,
PRIMARY KEY(`ID`)
) ENGINE=MyISAM auto_increment=0;Save as blog.php or something else, doesnt matter

<?php
/*///////////////////
Copyright of Danny696
Do not sell this mod
Do not re-distribute this mod
Do not claim this as your own mod
Free for members of MakeWebGames - McCodes, Dev-Forum - MagicTallGuy, Cronwerks - Cronus.
Thanks Danny696
This message does nothing to your game. And users cant see it.
Respect others. Respect their mods. Respect this message.
*////////////////////
@include_once(DIRNAME(__FILE__) .'/globals.php');
$_GET['cmd'] = (isset($_GET['cmd']) && !empty($_GET['cmd']) && is_string($_GET['cmd']) && ctype_alpha($_GET['cmd'])) ? trim(strtolower($_GET['cmd'])) : false;
$_GET['view'] = (isset($_GET['view']) && !empty($_GET['view']) && is_int($_GET['view'])) ? @intval($_GET['view']) : false;
switch($_GET['cmd']) {
case'add': add(); break;
case'del': del(); break;
case'view': look(); break;
case'comment': comment(); break;
case'all': all(); break;
default: index(); break;
}
function first($string, $words) { //base of the function from www.nutt.net
$array = explode(' ', $string);
if(count($array) < $words) {
$return = $string;
}
else {
array_splice($array, $words);
$return = implode(' ', $array).' .....';
}
return $return;
}
function index() {
global $db;
echo'Here is the last 5 blogs posted.<br /> <a href="?cmd=all">View all blogs</a>
<table width="80%" class="table">
<tr>
<th width="15%"> </th>
<th width="70%"> </th>
<th> </th>
</tr>';
$get_blogs = $db->query("SELECT * FROM `blogs` ORDER BY `ID` LIMIT 15;");
while($blog = $db->fetch_row($get_blogs)) {
$user = $db->fetch_row($db->query("SELECT `username`, `userid` FROM `users` WHERE (`userid` = ". $blog['posted'] .");"));
echo'<tr>
<td><b>'. ucwords($blog['name']) .'</b><br />Posted By: <a href="viewuser.php?u='.$user['userid'].'">'.$user['username'].'</a><br />Posted On: <small>'. date('F j, Y; g:i:s a', $blog['time']) .'</small></td>
<td>'. first($blog['blog'], 25) .'</td>
<td><a href="?cmd=view&ID='.$blog['ID'].'">Read More</a></td>
</tr>';
}
echo'</table>';
headers::endpage();
}
function look() {
global $db, $ir;
if(!$_GET['ID']) {
exit(index());
}
$blog = $db->fetch_row($db->query("SELECT * FROM `blogs` WHERE (`ID` = ". $_GET['ID'] .");"));
if(!$blog) {
exit(index());
}
$name = $db->fetch_single($db->query("SELECT `username` FROM `users` WHERE (`userid` = ". $blog['posted'] .");"));
echo'<big>'. ucwords($blog['name']) .'</big><br />
<a href="#comments">View comments</a>
<table width="80%" class="table">
<tr>
<th> </th>
<th width="70%"> </th>';
if($blog['posted'] == $ir['userid'] || $ir['user_level'] == 2) {
echo'<th> </th>';
}
echo'
</tr>
<tr>
<td>'. ucwords($blog['name']) .'<br />Posted By: '.$name.'<br />Posted On: '. date('F j, Y; g:i:s a', $blog['time']) .'</td>
<td>'. $blog['blog'] .'</td>';
if($blog['posted'] == $userid || $ir['user_level'] == 2) {
echo'<td><a href="?cmd=del&id='.$blog['ID'].'">Remove</a></td>';
}
echo'
</tr>
</table>';
unset($name);
$get_comments = $db->query("SELECT * FROM `blog_comments` WHERE (`blogID` = ". $blog['ID'] .");");
echo'<h3><a name="comments">Comments</a></h3>
<table width="70%" class="table">
<tr>
<th>Poster Info</th>
<th>Comment</th>
</tr>';
while($comment = $db->fetch_row($comments)) {
$name = $db->fetch_single($db->query("SELECT `username` FROM `users` WHERE (`userid` = ". $comment['posted'] .");"));
echo'<tr>
<td>Posted By: '.$name.'<br />Posted On: '. date('F j, Y; g:i:s a', $comment['time']) .'</td>
<td>'. $comment['comment'] .'</td>
</tr>';
}
echo'</table>';
if(isset($_POST['comment'])) {
echo'<h3>Comment Added!</h3>';
$db->query("INSERT INTO `blog_comments` VALUES('', ". $blog['ID'] .", ". time() .", '". $db->escape(strip_tags($_POST['comment'])) ."', ". $_SESSION['userid'] .");");
exit(headers::endpage());
}
echo'<h3>Add a comment</h3>
<form action="" method="post">
<textarea name="comment"></textarea><br />
<input type="submit" value="Add" />
</form>';
}
function all() {
global $db;
echo'Here is a list of all the blogs
<table width="80%" class="table">
<tr>
<th width="15%"> </th>
<th width="70%"> </th>
<th> </th>
</tr>';
$get_blogs = $db->query("SELECT * FROM `blogs` ORDER BY `ID`");
while($blog = $db->fetch_row($get_blogs)) {
$name = $db->fetch_single($db->query("SELECT `username` FROM `users` WHERE (`userid` = ". $blog['posted'] .");"));
echo'<tr>
<td>'. ucwords($blog['name']) .'<br />Posted By: '.$name.'<br />Posted On: '. date('F j, Y; g:i:s a', $blog['time']) .'</td>
<td>'. first($blog['blog'], 15) .'</td>
<td><a href="?cmd=view&ID='.$blog['ID'].'">Read More</a></td>
</tr>';
}
echo'</table>';
headers::endpage();
}
function del() {
global $db, $ir;
if(isset($_GET['id'])) {
$owner = $db->fetch_single($db->query("SELECT `posted` FROM `blogs` WHERE (`ID` = ". $_GET['id'] .");"));
if(($userid != $owner) AND $ir['user_level'] != 2) {
echo'You are not the owner of this blog, and therefore cannot delete it.';
exit(headers::endpage());
}
$db->query("DELETE FROM `blogs` WHERE (`ID` = ". $_GET['id'] .");");
$db->query("DELETE FROM `blog_comments` WHERE (`blogID` = ". $_GET['id'] .");");
echo'Deleted.';
exit(headers::endpage());
}
echo'Select a blog to delete:
<form action="" metod="get">
<select name="id">';
$get_blogs = $db->query("SELECT `name`, `ID` FROM `blogs` WHERE (`posted` = ". $_SESSION['userid'] .");");
while($blog = $db->fetch_row($get_blogs)) {
echo'<option value="'.$blog['ID'].'">'.$blog['name'].'</option>';
}
echo'</select>
</form>';
exit(headers::endpage());
}
function add() {
global $db, $ir;
if(isset($_POST['message'])) {
$_POST['message'] = strip_tags($_POST['message']);
$_POST['message'] = $db->escape($_POST['message']);
$_POST['name'] = strip_tags($_POST['message']);
$_POST['name'] = $db->escape($_POST['message']);
//insert
$db->query("INSERT INTO `blogs` VALUES ('', '". $_POST['name'] ."', '". $_POST['message'] ."', '". @intval($ir['userid']) ."', ". time() .");");
$id = $db->insert_id();
echo'Blog added. Click <a href="?cmd=view&ID='.$id.'">Here!</a> to view it.';
exit(headers::endpage());
}
echo'Adding a new blog.
<form action="?cmd=add" method="post">
Name: <input type="text" value="" name="name" /><br />
Blog Text:<br /><textarea name="message"></textarea><br />
<input type="submit" value="Add!" />
</form>';
exit(headers::endpage());
}