<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
include_once("../../mainfile.php");
if($bcoosConfig['startpage'] == "xtremguestbook") {
	$xoopsOption['show_rblock'] =1;
	include_once(XOOPS_ROOT_PATH."/header.php");
	make_cblock();
	echo "<br />";
	} else {
		$xoopsOption['show_rblock'] =0;
		include_once(XOOPS_ROOT_PATH."/header.php");
	}
//include config file
include_once("cache/config.php");
?>
<script type="text/javascript">
function xoopsValidateXtrem(subjectId, textareaId, nameId, submitId) {
	var maxchars = 65535;
	var subjectDom = xoopsGetElementById(subjectId);
	var textareaDom = xoopsGetElementById(textareaId);
	var submitDom = xoopsGetElementById(submitId);
	var nameDom = xoopsGetElementById(nameId);
	if (textareaDom.value == "" || subjectDom.value == "" || nameDom.value == "") {
		alert("<?php echo _XTG_NOTFULL;?>");
		return false;
	}
	if (maxchars != 0) {
		if (textareaDom.value.length > maxchars) {
			alert("<?php echo _MESSAGETOOLONG;?>\n\n<?php echo _ALLOWEDCHAR;?>" + maxchars + "\n<?php echo _CURRCHAR;?>" + textareaDom.value.length + "");
			textareaDom.focus();
			return false;
		} else {
			submitDom.disabled = true;
			return true;
		}
	} else {
		submitDom.disabled = true;
		return true;
	}
}
</script>
<?php
//assign variable of xoopsuser to form
if ($_POST["message"]!="") $message=$myts->makeTboxData4PreviewInForm($_POST["message"]);
else $message="";
if ($_POST["title"]!="") $title_v=$myts->makeTareaData4PreviewInForm($_POST["title"]);
else $title_v="";
if ($_POST["email"]!="") $email_v=$myts->makeTareaData4Edit($_POST["email"]);
else $email_v = !empty($xoopsUser) ? $xoopsUser->getVar("email", "E") : "";
if ($_POST["username"]!="") $name_v=$myts->makeTareaData4Edit($_POST["username"]);
else $name_v = !empty($xoopsUser) ? $xoopsUser->getVar("uname", "E") : "";
$url_v = !empty($xoopsUser) ? $xoopsUser->getVar("url", "E") : "";
//show preview mode
if ($_GET["preview"] == 1) {
	OpenTable();
	echo "<table width='98%' align='center' border='0'><tr><td>";
	openThread($width="100%");
	//sanitize text before show
	$previewmessage = $myts->sanitizeForPreview($_POST["message"], $allowhtml, $allowsmileys, $allowbbcode);
	$previewtitle   = $myts->sanitizeForPreview($_POST["title"], 0, 0, 0);
	if ( $xoopsUser ) {
		$poster = new XoopsUser($xoopsUser->uid());
		if ( !$poster->isActive() ) {
			$poster = 0;
			}
		} else {
			$poster = 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();
		$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"] != "" ) {
			$email_image = "<a href='mailto:".$email_v."'><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, $previewtitle, $previewmessage, $post_date, $ip_image, $reply_image, $edit_image, $delete_image, $name_v, $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($url_v) $www_image = "<a href='".$url_v."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."www.gif' alt='"._VISITWEBSITE."' /></a>";
			else $www_image='';
			if($email_v) $email_image = "<a href='mailto:".$email_v."'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."email.gif' alt='".sprintf(_SENDEMAILTO,$name_v)."' /></a>";
			else $email_image='';
			showThread($color_num, $subject_image, $previewtitle, $previewmessage, $post_date, $ip_image, $reply_image, $edit_image, $delete_image, $name_v,"", "", "", "", "", "", "", "", "", $email_image, $www_image, "", "", "", "");
			}
		closeThread();
		echo "</td></tr></table>";
		CloseTable();
		}
OpenTable();
if ($xoopsUser) {
	$disabled="disabled='disabled'";
	}
echo "
<form name='guestbook' action='post.php' onsubmit='return xoopsValidateXtrem(\"title\", \"message\", \"username\", \"submitbutton\");' method='post'>
<table width='98%' border='0'>
<tr><td colspan='2'>
<b>"._XTG_SIGNGUESTBOOK." ( <a href='index.php'>"._XTG_BACKGUESTBOOK."</a> )</b><br /><br />
"._XTG_DESC."<br /><hr /><br />
</td></tr>
<tr><td>
"._XTG_NAME."*
</td><td>
<input name='username' type='text' ".$disabled." value='".$name_v."' class=text />
</td></tr>
<tr><td>
"._EMAIL."
</td><td>
<input name='email' type='text' value='".$email_v."' size=50 class=text />
</td></tr>
<tr><td>
"._XTG_URL."
</td><td>
<input name='url' type='text' ".$disabled." value='".$url_v."' size=50 class=text />
	</td></tr>
<tr><td>
"._XTG_TITLE."*
</td><td>
<input name='title' id='title' type='text' value='".$title_v."' size=50 class=text />
</td></tr>
<tr><td>
"._XTG_MESSAGE."*
</td><td>";
include_once(XOOPS_ROOT_PATH."/include/xoopscodes.php");
if ($allowbbcode==1) xoopsCodeTarea("message");
else echo "<textarea id='message' name='message' wrap='virtual' cols='50' rows='10'></textarea><br />";
if ($allowsmileys==1) xoopsSmilies("message");
echo "</td></tr>
<tr><td>
&nbsp;
</td><td>
<input name='previewbutton' id='previewbutton' type='submit' onclick='document.forms.guestbook.action=\"sign.php?preview=1\";' value='"._XTG_PREVIEW."' class='button' >
<input name='submitbutton' id='submitbutton' type='submit' value='"._XTG_SEND."' class='button' >
</td></tr>
</table>
</form>";
CloseTable();
include_once(XOOPS_ROOT_PATH."/footer.php");
?>
