<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.10 www.bcoos.net 2006/09 GPL 
//v1.9 www.bcoos.net 2006-08 GPL
//v1.8 www.exoops.info 2006/08 GPL
// $Id: commentform.inc.php,v 1.7 2003/03/19 06:58:09 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include_once(XOOPS_ROOT_PATH."/class/xoopslists.php");
include_once(XOOPS_ROOT_PATH.'/class/xoopsform/formdhtmltextarea.php');
if ( !isset($submit_page) ) {
	$submit_page = _PHP_SELF;
}
echo "<table><tr><td><form action='postcomment.php' method='post' id='commentform' onsubmit='return xoopsValidate(\"subject\", \"message\", \"comment_submit\");'><br /><br /><b>". _YOURNAME .":</b>&nbsp;";
if ($xoopsUser) {
	echo "<a href='".XOOPS_URL."/userinfo.php?id_user=".$xoopsUser->getVar("id_user")."'>".$xoopsUser->getVar("uname")."</a>&nbsp;[&nbsp;<a href='".XOOPS_URL."/user.php?op=logout'>"._LOGOUT."</a>&nbsp;]";
} else {
	echo "<input type='text' class='text' id='anonuser' name='anonuser' size='20' maxlength='60' value='" . $_POST['anonuser'] . "' />";
}
echo "<br /><br /><b>". _SUBJECT ."</b><br />";
if ( !preg_match("/^re:/i", $subject) && $pid != 0) {
	$subject = "Re: ".substr($subject, 0, 56);
}
echo "<input type='text' class='text' id='subject' name='subject' size='50' maxlength='60' value='$subject' /><br /><br /><b>". _MESSAGEICON ."</b><table><tr align='left'><td>";
$lists    = new XoopsLists;
$filelist = $lists->getSubjectsList();
$count = 1;
while ( list ($key, $file) = each ($filelist) ) {
	$checked = "";
	if ( isset($icon) && $file == $icon ) {
		$checked = " checked='checked'";
	}
	echo "<input type='radio' class='radio' value='$file' name='icon'$checked />&nbsp;";
	echo "<img src='".XOOPS_URL."/images/subject/".$file."' border='0' alt='' />&nbsp;";
	if ( $count == 8 ) {
		echo "<br />";
		$count = 0;
	}
	$count++;
}
echo "</td></tr></table><br /><b>". _COMMENT ."</b><br /><br />";
$desc = new XoopsFormDhtmlTextArea("", "message", $message, 10, 50);
echo $desc->render();
echo "<br /><br />";
if ( $xoopsUser && !empty($bcoosConfig['allow_html']) ) {
	echo _ALLOWEDHTML."<br />";
	echo get_allowed_html();
	if ($allow_html == '0' || $_POST['allow_html'] == '0') {
		$option0 = " selected";
		} elseif ($allow_html == '2' || $_POST['allow_html'] == '2') {
			$option2 = " selected";
			} else {
				$option1 = " selected";
			}
	echo "<br /><br />
	<select class='select' name='allow_html'>
	<option value='0'$option0>"._HTMLOFF."</option>
	<option value='1'$option1>"._HTMLAUTOWRAP."</option>
	<option value='2'$option2>"._HTMLNOAUTOWRAP."</option>
	</select><br />";
	} else {
		echo "<input type='hidden' name='allow_html' value='0'>";
	}
echo "<input type='checkbox' class='checkbox' name='allow_smileys' value='1'";
if ( (!isset($allow_smileys) && !isPost()) || $allow_smileys == '1' || $_POST['allow_smileys'] == '1' ) {
	echo " checked='checked'";
}
echo " /> "._ENABLESMILEY."<br />";
// Enable bbcode?
echo "<input type='checkbox' class='checkbox' name='allow_bbcode' value='1'";
if ( (!isset($allow_bbcode) && !isPost()) || $allow_bbcode == '1' || $_POST['allow_bbcode'] == '1' ) {
	echo " checked='checked'";
}
echo " />&nbsp;"._ENABLEBBCODE."<br />";
if ( $xoopsUser && $bcoosConfig['anonpost'] ) {
	echo "<input type='checkbox' class='checkbox' name='noname'";
	if ( !empty($noname) ) {
		echo " checked='checked'";
	}
	echo " />"._POSTANON."<br />";
}
if ( !$xoopsUser && $bcoosConfig['anonpost'] && $bcoosConfig['captcha_comments'] && function_exists('imagecreate')) {
	include_once(XOOPS_ROOT_PATH."/class/rc4.crypt.php");
	$checksum   = "verified";
	$pass       = strtoupper(makepass());
	$rc4        = new rc4_crypt();
	$rc4->key($pass);
	$rc4->crypt($checksum);
	$im         = imagecreatefrompng('../../images/verify.png');
	$text_color = imagecolorallocate($im, 50, 50, 50);
	imagestring($im, 5, 2, 2, $pass, $text_color);
	imagepng($im, "../../cache/verify.png");
	imagedestroy($im);
	
	?>
	<br />
	<input type="hidden" name="verify_crc" value="<?php echo base64_encode($checksum);?>" />
	<table><tr><td>
	<input type='text' class='text' id='verify_text' name='verify_text' size='12' maxlength='12' value='' />
	</td><td>
	<?php echo _US_ENTERVERIF;?>
	</td></tr></table>
	&nbsp;<img src="../../cache/verify.png?<?php echo time();?>" /><br />
	<?php
	if (@file_exists("../../cache/verify.png")) {
		$img_verify = 1;
	}
	
}
?>
<br />
<input type="hidden" name="pid" value="<?php echo intval($pid);?>" />
<input type="hidden" name="comment_id" value="<?php echo intval($comment_id);?>" />
<input type="hidden" name="item_id" value="<?php echo intval($item_id);?>" />
<input type="hidden" name="order" value="<?php echo intval($order);?>" />
<select class="select" name="op">
<option value="preview" selected="selected"><?php echo _PREVIEW;?></option>
<option value="post"><?php echo _POSTCOMMENT;?></option>
</select>
<input type="submit" class="button" value="<?php echo _GO;?>" name="comment_submit" id="comment_submit" />
</form>
</td></tr></table>
<?php
unset($submit_page);
?>
