Location: PHPKode > projects > Odysseus Blog > OdysseusBlog-2.0.0-Alpha2/comments.php
<?PHP
/* 
ODYSSEUS BLOG - comments.php - VERSION 1.0
This file is intended for controlling all comments
on a users weblog and viewing it.
*/
require 'Smarty_libs/Smarty.class.php'; //Adding Template support
include 'save.php';
include 'info.php';
session_start();
if (!isset($_GET['user'])) {
	if ($_SESSION['username'] != "" || $_SESSION['username'] != null) {
		$user = $_SESSION['username'];
	} else {
		$user = $admin;
	}
} else {
	$user = $_GET['user'];
}
$lcuser = strtolower($user);
if (UserExists($lcuser) == 1) {
	echo "Username not found!";
} else {
	$data = ReadData($lcuser,"info");
	$splt_items = explode("|,|", $data);
	//user,name,bday,gender,intrests,expertise,email,website,aim,msn,gmail,yahoo,joined date
	//New way
	$username =  ParseOBML("username",$data);
	$name =  ParseOBML("name",$data);
	$bday =  ParseOBML("bday",$data);
	$gender =  ParseOBML("gender",$data);
	$location =  ParseOBML("location",$data);
	$icq =  ParseOBML("icq",$data);
	$email =  ParseOBML("email",$data);
	$website =  ParseOBML("website",$data);
	$aim =  ParseOBML("aim",$data);
	$msn =  ParseOBML("msn",$data);
	$gmail =  ParseOBML("gmail",$data);
	$yim =  ParseOBML("yahoo",$data);
	$joined = ParseOBML("date",$data);
	
	// Fix any issues with their stuff
	if (substr($website,0,7) != "http://") {
		$website = "http://$website";
	}
	if ($website != "" && $website != null) {
		$website = "<span id='profWebsite'><b>Website:</b> </span><span id='profWebsite1'><a href='$website'>visit my website</a></span><br />";
	}
	if ($aim != "" && $aim != null) {
		$aim = "<span id='profIM1'><b>AIM:</b> </span><span id='profIM11'><img border='0' align='absmiddle' src='http://big.oscar.aol.com/$aim?on_url=http://www.aol.com:80/aim/gr/online.gif&off_url=http://www.aol.com:80/aim/gr/offline.gif'> <a href='aim:goim?screenname=$aim'>$aim</a></span><br />";
		$aim = stripslashes($aim);
	}
	if ($msn != "" && $msn != null) {
		$msn = "<span id='profIM2'><b>MSN:</b> </span><span id='profIM21'><a href='http://members.msn.com/$msn'>$msn</a></span><br />";
		$msn = stripslashes($msn);
	}
	if ($gmail != "" && $gmail != null) {
		$gmail = "<span id='profIM3'><b>GoogleTalk:</b> </span><span id='profIM31'>$gmail</span><br />";
		$gmail = stripslashes($gmail);
	}
	if ($yim != "" && $yim != null) {
		$yim = "<span id='profIM4'><b>Yahoo:</b> </span><span id='profIM41'><img src='http://opi.yahoo.com/online?u=$yim&m=g&t=0' width='12' height='12' /> <a href='http://edit.yahoo.com/config/send_webmesg?.target=$yim&.src=pg'>$yim</a></span>";
		$yim = stripslashes($yim);
	}
	$sideinfo = "$website$aim$msn$gmail$yim";

	$friends = ReadData($lcuser,"friends");
	//We only want to show the first 8 people
	for ($i = 0; $i < 8; $i++) {
		$tmp = ParseOBML("friend",$friends); //Get the first one in the list
		if ($tmp == "" || $tmp == null) {
			$i = 8;
		} else {
			$friends = str_replace("<friend>$tmp</friend>","",$friends); //Clear them out for the next go
			$friendsout = $friendsout . "<a href='blog.php?user=$tmp'><b>$tmp</b><br /><img src='image.php?user=$tmp' width='70'><br />"; //Add them to the output
		}
	}
	$friends = $friendsout;
	/* //Old way
	$splt_friends = explode("<!--Next Friend-->",$friends);
	$friends = "";
	for ($i = 1; $i < 10; $i++) {
		if ($splt_friends[$i] != "") {
			$friends = $friends . "<!--Next Friend--><a href='blog.php?user=$splt_friends[$i]'><b>$splt_friends[$i]</b>&nbsp;<br /><img src='image.php?user=$splt_friends[$i]' width='70'></a><!--Next Friend--><br />";
		}
	}
	*/
	$css = ReadData($lcuser,"css");

	$about = ReadData($lcuser,"about");
	$about = stripslashes($about);


	if (!session_is_registered("$lcuser")) { // It's not their page
		if ($_SESSION['username'] != "" && $_SESSION['username'] != null) { //But they are registered
			if (!isset($_POST['data'])) {
				if (!isset($_GET['id'])) {
					$postid = 1;
				} else {
					$postid = $_GET['id'];
				}
				$old = ReadData($lcuser,"blogs");
				$splt_items = explode("|,|", $old);
				$div = count($splt_items);
				$blogtitle = $splt_items[$div-$postid];
				$comments = ReadData($lcuser,"posts/$blogtitle");
				$posts = "$comments<BR><HR><BR><form name='form' action='update.php' method='POST'>Your Comments:<BR><textarea name='data' rows='10' cols='60'></textarea><BR><input type='hidden' name='file' value='comment'><input type='hidden' name='id' value='$blogtitle'><input type='hidden' name='cur' value='$postid'><input type='hidden' name='tuser' value='$lcuser'><input type='submit' name='submit' value='Comment!'>";
			}
			$body = "<html><title>$sitename - $username</title>$css<body><center><span><div style='height: 130px'><img src='header.png' height='130' alt='$username'></div><table border='0' cellspacing='0' cellpadding='4' width='100%' class='navigation'><tr><td><b>$username: <a href='update.php?file=friends&action=add&index=$username'>Add to Friends! </a></b></td><td align='right' width='0'><div class='smalltext' style='position: relative;'><a href='home.php?user=" . strtolower($_SESSION['username']) . "'>My Page</a> - <a href='blog.php?user=" . strtolower($_SESSION['username']) . "'>My Blog</a> - <a href='signout.php'>sign out</a></div></td></tr></table><table class='main' cellSpacing='0' cellPadding='4' width='100%' border='0'><tr><td class='mainleft' vAlign='top' width='200'><!--Side Pannel--><table class='left' cellSpacing='0' cellPadding='4' width='100%' border='1'><tr><th align='left' vAlign='top' class='left'><strong>$username</strong></th></tr><tr><td class='left' vAlign='top'><span class='smalltext' id='ProfileModule1_links'></span><span id='ProfileModule1_lblImage'><br /><center><img src='image.php?user=$lcuser' width='170' border='0' alt='$name' /></center></span><span id='ProfileModule1_lblStatement'></span><span id='ProfileModule1_lblBasic'><br /><span id='profName'><b>Name:</b> </span><span id='profName1'>$name</span><br /><span id='profBirthday'><b>Birthday:</b> </span><span id='profBirthday1'>$bday</span><br /><span id='profGender'><b>Gender:</b> </span><span id='profGender1'>$gender</span></span><span id='ProfileModule1_lblInterests'><br /><br /><span id='profInterests'><b>Interests:</b> </span><span id='profInterests1'>$interests</span><br /><span id='profExpertise'><b>Expertise:</b> </span><span id='profExpertise1'>$expertise</span></span><span id='ProfileModule1_lblContact'><br /><br /><span id='profEmail'><b>Email:</b> </span><span id='profEmail1'><a href='mailto:$email'>email me</a></span><br />$sideinfo</span><br><span id='ProfileModule1_lblBr'><br></span><span class='smalltext' id='profMember'><b>Joined:</b></span>$joined</td></tr></table><br><table border='1' cellspacing='0' cellpadding='4' width='100%' class='left'><tr><th align='left' valign='top' class='left'><strong>Friends</strong></th></tr><tr><td valign='top' class='left'>$friends</td></tr></table><br /><table border='1' cellspacing='0' cellpadding='4' width='100%' class='left'><tr><th align='left' valign='top' class='left'><strong>About Me </strong></th></tr><tr><td valign='top' class='left'>$about</td></tr></table><br /><span style='display:none'><table><tr><th><b>Get Involved!</b></th></tr><tr><td><p><a>Suggest a link</a></p><p><a>Recommend to friend</a></p><p><a>Create a site</a></p></td></tr></table></span></td><td class='maincenter' vAlign='top'>$posts<br><hr size='1' noshade='noshade' />$next</td></tr></table><span id='lblReadOnly' style='display: none'>False</span></span><table border='0' cellspacing='0' cellpadding='4' width='725' class='footer'><tr><td align='center' valign='top'><a href='http://odysseusblog.sourceforge.net/'>Odysseus Blog Created by Justin Williams</a></td></tr></table></center></body></html>";
		} else { //Not even Logged In.
			if (!isset($_GET['id'])) {
				$postid = 1;
			} else {
				$postid = $_GET['id'];
			}
			$old = ReadData($lcuser,"blogs");
			$splt_items = explode("|,|", $old);
			$div = count($splt_items);
			$blogtitle = $splt_items[$div-$postid];
			$posts = ReadData($lcuser,"posts/$blogtitle");
			$posts = str_replace("<!---->","<!----><BR><b>You must be logged in to place comments.</b><BR>",$posts);
			$body = "<html><title>$sitename - $username</title>$css<body><center><span><div style='height: 130px'><img src='header.png' height='130' alt='$username'></div><table border='0' cellspacing='0' cellpadding='4' width='100%' class='navigation'><tr><td><b>$username</b></td><td align='right' width='0'><div class='smalltext' style='position: relative;'><a href='signup.html'>signup</a> - <a href='signin.php'>signin</a></div></td></tr></table><table class='main' cellSpacing='0' cellPadding='4' width='100%' border='0'><tr><td class='mainleft' vAlign='top' width='200'><!--Side Pannel--><table class='left' cellSpacing='0' cellPadding='4' width='100%' border='1'><tr><th align='left' vAlign='top' class='left'><strong>$username</strong></th></tr><tr><td class='left' vAlign='top'><span class='smalltext' id='ProfileModule1_links'></span><span id='ProfileModule1_lblImage'><br /><center><img src='image.php?user=$lcuser' width='170' border='0' alt='$name' /></center></span><span id='ProfileModule1_lblStatement'></span><span id='ProfileModule1_lblBasic'><br /><span id='profName'><b>Name:</b> </span><span id='profName1'>$name</span><br /><span id='profBirthday'><b>Birthday:</b> </span><span id='profBirthday1'>$bday</span><br /><span id='profGender'><b>Gender:</b> </span><span id='profGender1'>$gender</span></span><span id='ProfileModule1_lblInterests'><br /><br /><span id='profInterests'><b>Interests:</b> </span><span id='profInterests1'>$interests</span><br /><span id='profExpertise'><b>Expertise:</b> </span><span id='profExpertise1'>$expertise</span></span><span id='ProfileModule1_lblContact'><br /><br /><span id='profEmail'><b>Email:</b> </span><span id='profEmail1'><a href='mailto:$email'>email me</a></span><br />$sideinfo</span><br><span id='ProfileModule1_lblBr'><br></span><span class='smalltext' id='profMember'><b>Joined:</b></span>$joined</td></tr></table><br><table border='1' cellspacing='0' cellpadding='4' width='100%' class='left'><tr><th align='left' valign='top' class='left'><strong>Friends</strong></th></tr><tr><td valign='top' class='left'>$friends</td></tr></table><br /><table border='1' cellspacing='0' cellpadding='4' width='100%' class='left'><tr><th align='left' valign='top' class='left'><strong>About Me </strong></th></tr><tr><td valign='top' class='left'>$about</td></tr></table><br /><span style='display:none'><table><tr><th><b>Get Involved!</b></th></tr><tr><td><p><a>Suggest a link</a></p><p><a>Recommend to friend</a></p><p><a>Create a site</a></p></td></tr></table></span></td><td class='maincenter' vAlign='top'>$posts<br><hr size='1' noshade='noshade' />$next</td></tr></table><span id='lblReadOnly' style='display: none'>False</span></span><table border='0' cellspacing='0' cellpadding='4' width='725' class='footer'><tr><td align='center' valign='top'><a href='http://odysseusblog.sourceforge.net/'>Odysseus Blog Created by Justin Williams</a></td></tr></table></center></body></html>";
		}
	} else { //It is their page... No posting here!!!
		if (!isset($_GET['id'])) {
			$postid = 1;
		} else {
			$postid = $_GET['id'];
		}
		$old = ReadData($lcuser,"blogs");
		$splt_items = explode("|,|", $old);
		$div = count($splt_items);
		$blogtitle = $splt_items[$div-$postid];
		$comments = ReadData($lcuser,"posts/$blogtitle");
		$posts = "$comments<BR>"; //Don't let them comment... Just give them the ones they have... It's their own freaking page!
		$body = "<html><title>$sitename - $username</title>$css<body><center><span><div style='height: 130px'><img src='header.png' height='130' alt='$username'></div><table border='0' cellspacing='0' cellpadding='4' width='100%' class='navigation'><tr><td><b>$username:&nbsp; <a href='edit.php?action=friends'>Edit Friends </a>&nbsp;&nbsp;<a href='edit.php?action=blog'>New Blog Entry </a>&nbsp;&nbsp;<a href='$lcuser/edit.php?action=info'>Edit Personal Info</a>&nbsp;&nbsp;<a href='edit.php?action=picture'>Change Display Picture</a></b></td><td align='right' width='0'><div class='smalltext' style='position: relative;'><a href='home.php?user=$username'>My Page</a> - <a href='signout.php'>sign out</a></div></td></tr></table><table class='main' cellSpacing='0' cellPadding='4' width='100%' border='0'><tr><td class='mainleft' vAlign='top' width='200'><!--Side Pannel--><table class='left' cellSpacing='0' cellPadding='4' width='100%' border='1'><tr><th align='left' vAlign='top' class='left'><strong>$username</strong></th></tr><tr><td class='left' vAlign='top'><span class='smalltext' id='ProfileModule1_links'></span><span id='ProfileModule1_lblImage'><br /><center><img src='image.php?user=$lcuser' width='170' border='0' alt='$name' /></center></span><span id='ProfileModule1_lblStatement'></span><span id='ProfileModule1_lblBasic'><br /><span id='profName'><b>Name:</b> </span><span id='profName1'>$name</span><br /><span id='profBirthday'><b>Birthday:</b> </span><span id='profBirthday1'>$bday</span><br /><span id='profGender'><b>Gender:</b> </span><span id='profGender1'>$gender</span></span><span id='ProfileModule1_lblInterests'><br /><br /><span id='profInterests'><b>Interests:</b> </span><span id='profInterests1'>$interests</span><br /><span id='profExpertise'><b>Expertise:</b> </span><span id='profExpertise1'>$expertise</span></span><span id='ProfileModule1_lblContact'><br /><br /><span id='profEmail'><b>Email:</b> </span><span id='profEmail1'><a href='mailto:$email'>email me</a></span><br />$sideinfo</span><br><span id='ProfileModule1_lblBr'><br></span><span class='smalltext' id='profMember'><b>Joined:</b></span>$joined</td></tr></table><br><table border='1' cellspacing='0' cellpadding='4' width='100%' class='left'><tr><th align='left' valign='top' class='left'><strong>Friends</strong></th></tr><tr><td valign='top' class='left'>$friends</td></tr></table><br /><table border='1' cellspacing='0' cellpadding='4' width='100%' class='left'><tr><th align='left' valign='top' class='left'><strong>About Me </strong></th></tr><tr><td valign='top' class='left'>$about</td></tr></table><br /><span style='display:none'><table><tr><th><b>Get Involved!</b></th></tr><tr><td><p><a>Suggest a link</a></p><p><a>Recommend to friend</a></p><p><a>Create a site</a></p></td></tr></table></span></td><td class='maincenter' vAlign='top'>$posts<br><hr size='1' noshade='noshade' />$next</td></tr></table><span id='lblReadOnly' style='display: none'>False</span></span><table border='0' cellspab cing='0' cellpadding='4' width='725' class='footer'><tr><td align='center' valign='top'><a href='http://odysseusblog.sourceforge.net/'>Odysseus Blog Created by Justin Williams</a></td></tr></table></center></body></html>";
	}
	echo $body;
}
?>
Return current item: Odysseus Blog