<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.1 www.bcoos.net 2006-08 GPL
include_once("../../mainfile.php");
$bcoosConfig['title'] .= " - "._XTG_MODULE_NAME;
if ($bcoosConfig['startpage'] == "xtremguestbook"){
	$xoopsOption['show_rblock'] =1;
	include_once(XOOPS_ROOT_PATH."/header.php");
	make_cblock();
	echo "<br />";
	} else {
		$xoopsOption['show_rblock'] =1;
		include_once(XOOPS_ROOT_PATH."/header.php");
	}
include_once(XOOPS_ROOT_PATH."/class/xoopspagenav.php");
OpenTable();
//include config file
include_once("cache/config.php");
//count number of messages
$sqlquery=$db->query("SELECT count(*) as nbmsg from ".$db->prefix("xtremguestbook")." where moderate=0");
$sqlfetch=$db->fetchArray($sqlquery);
$nbmessage=$sqlfetch["nbmsg"];
//Admin or not
if ($xoopsUser) $adminview=$xoopsUser->isAdmin($xoopsModule->mid()) ;
else $adminview=0;
$pagenav=new XoopsPageNav($nbmessage, $nbmsgbypage, $limite, "limite", "");
echo "<table width='98%' align='center' border='0'><tr><td>";


echo "<div align='left'>"._XTG_MODULE_NAME."</div><br /><br />";

// disclaimer
if ($showdisclaimer) {
$disclaimer = join('', file("./cache/disclaimer.txt"));
$myts->setType('admin');
echo "<center>".$myts->makeTareaData4Show($disclaimer, 1, 1, 1)."</center><BR /><BR />";
}
echo "<BR /><BR />";
printf(_XTG_THEREIS,"<b><font class='fg2'>".$nbmessage."</font></b>");
echo "<br /><a href='sign.php'>"._XTG_SIGNGUESTBOOK."</a><br /><br />";
echo "</td></tr></table>";
CloseTable();
echo "<br />";
OpenTable();
//show render nav
echo '<div align="center">'.$pagenav->renderNav(3, 3).'</div>';
echo "<table width='98%' align='center' border='0'><tr><td>";
openThread($width="100%");
if (!isset($limite)) $limite=0;
//Select messages
$sqlquery=$db->query("SELECT user_id,uname,url,email,title,message,note,post_time,poster_ip,xtremguestbook_id from ".$db->prefix("xtremguestbook")." where moderate=0 order by post_time desc limit ".intval($limite).",".$nbmsgbypage);
$nbmessage-=$limite;
while ($sqlfetch=$db->fetchArray($sqlquery)) {
	//alternate color
	if($color_num==1) $color_num=2;
	else $color_num=1;
	$edit_image = "";
	$reply_image = "";
	$delete_image = "";
	$ip_image = "";
	$post_date = formatTimestamp($sqlfetch["post_time"],"m");
	if ( $sqlfetch["user_id"] != 0 ) {
		$poster = new XoopsUser($sqlfetch["user_id"]);
		if ( !$poster->isActive() ) {
			$poster = 0;
			}
		} else {
			$poster = 0;
		}
// if this topic is not locked, show reply/edit link and Show ip button for admin only
if ( $adminview ) {
	$delete_image = "<a href='admin/index.php?op=Messagedel&idmsg=".$sqlfetch["xtremguestbook_id"]."&uid=".$sqlfetch["user_id"]."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."delete.gif' alt='"._XTG_DELETEPOST."' /></a>";
	$ip_image     = "<a href='".XOOPS_URL."/modules/system/admin.php?fct=filter&op=add&add_ip=".$sqlfetch["poster_ip"]."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."ip.gif' alt='".$sqlfetch["poster_ip"]."' border='0' /></a>";
	$edit_image   = "<a href='admin/index.php?op=Messageedit&idmsg=".$sqlfetch["xtremguestbook_id"]."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."edit.gif' border='0' /></a>";
	}
// Number of message
$sqlfetch["title"]=$nbmessage.") ".$sqlfetch["title"];
$nbmessage--;
$message=$myts->sanitizeForDisplay($sqlfetch["message"], $allowhtml, $allowsmileys, $allowbbcode);
$note=$myts->sanitizeForDisplay($sqlfetch["note"], $allowhtml, $allowsmileys, $allowbbcode);
if ( $note != "" ) $message.="<br /><hr /><i>"._XTG_NOTE." ".$note."</i>";
$title=$myts->sanitizeForDisplay($sqlfetch["title"], 0, 0, 0);
if ( $poster ) {
	$reg_date = _JOINED;
	$reg_date .= formatTimestamp($poster->user_regdate(),"s");
	$posts = _POSTS;
	$posts .= $poster->posts();
	$user_from = _FROM;
	$user_from = $poster->user_from();
	$user_from .=":&nbsp;";
	$rank = $poster->rank();
	if ( $rank['image'] != "" ) {
		$rank['image'] = "<img src='".XOOPS_URL."/images/ranks/".$rank['image']."' alt='' />";
		}
	$avatar_image = "<img src='".XOOPS_URL."/images/avatar/".$poster->user_avatar()."' alt='' />";
	if ( $poster->isOnline() ) {
			$online_image = "<span style='color:#ee0000;font-weight:bold;'>"._ONLINE."</span>";
		} else {
			$online_image = "";
		}
	$profile_image = "<a href='".XOOPS_URL."/userinfo.php?uid=".$poster->uid()."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."profile.gif' alt='"._PROFILE."' /></a>";
	if ( $xoopsUser ) {
			$pm_image =  "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/pmlite.php?send2=1&amp;to_userid=".$poster->uid()."','pmlite',360,300);\"><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."pm.gif' alt='".sprintf(_SENDPMTO,$poster->uname())."' /></a>";
		} else {
			$pm_image = "";
		}
	if ( $sqlfetch["email"] != "" ) {
		if ($xoopsUser && $xoopsUser->user_viewemail(1)) {
			$email_image = "<a href='mailto:".$sqlfetch["email"]."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."email.gif' alt='".sprintf(_SENDEMAILTO,$poster->uname())."' /></a>";
				}
		} else {
			$email_image = "";
		}
	$posterurl = $poster->url();
	if ( $poster->url() != "" ) {
		$www_image = "<a href='$posterurl'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."www.gif' alt='"._VISITWEBSITE."' /></a>";
		} else {
			$www_image = "";
		}
	if ( $poster->user_icq() != "" ) {
		$icq_image = "<a href='http://wwp.icq.com/scripts/search.dll?to=".$poster->user_icq()."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."icq_add.gif' alt='"._ADDTOLIST."' /></a>";
		} else {
			$icq_image = "";
		}
	if ( $poster->user_aim() != "" ) {
		$aim_image = "<a href='aim:goim?screenname=".$poster->user_aim()."&message=Hi+".$poster->user_aim()."+Are+you+there?'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."aim.gif' alt='aim' /></a>";
		} else {
			$aim_image = "";
		}
	if ( $poster->user_yim() != "" ) {
		$yim_image = "<a href='http://edit.yahoo.com/config/send_webmesg?.target=".$poster->user_yim()."&.src=pg'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."yim.gif' alt='yim' /></a>";
		} else {
			$yim_image = "";
		}
	if ( $poster->user_msnm() != '' ) {
			$msnm_image = "<a href='".XOOPS_URL."/userinfo.php?uid=".$poster->uid()."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."msnm.gif' alt='msnm' /></a>";
		} else {
			$msnm_image = "";
		}
//show message
showThread($color_num, $subject_image, $title, $message, $post_date, $ip_image, $reply_image, $edit_image, $delete_image, $sqlfetch["uname"], $rank['title'], $rank['image'], $avatar_image, $reg_date, $posts, $user_from, $online_image, $profile_image, $pm_image, $email_image, $www_image, $icq_image, $aim_image, $yim_image, $msnm_image);
} else {
	if ($sqlfetch["url"]) $www_image = "<a href='".$sqlfetch["url"]."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."www.gif' alt='"._VISITWEBSITE."' /></a>";
	else $www_image='';
if ($xoopsUser) {
	if ($sqlfetch["email"]) $email_image = "<a href='mailto:".$sqlfetch["email"]."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."email.gif' alt='".sprintf(_SENDEMAILTO,$sqlfetch["uname"])."' /></a>";
	else $email_image='';
}	
	showThread($color_num, $subject_image, $title, $message, $post_date, $ip_image, $reply_image, $edit_image, $delete_image, $sqlfetch["uname"],"", "", "", "", "", "", "", "", "", $email_image, $www_image, "", "", "", "");
}
$nbmsgaffich++;
}
closeThread();
echo "</td></tr></table>";
// Show navigation bar
echo '<div align="center">'.$pagenav->renderNav(3, 3).'</div>';
CloseTable();
echo "<br />";
include_once(XOOPS_ROOT_PATH."/footer.php");
?>
