<?

function rating($rate,&$topic) { ?>
<noindex>
<div class="descr"><?=MSG_t_currating;?>: <? if ($topic['trating']) echo $topic['trating'];
else { ?><?=MSG_none;?></div><? }
if (!$rate && $GLOBALS['inuserid']>3) { ?>
<form class="descr" action="index.php" method=POST><?=MSG_t_rate;?>: <select name=tr_value>
<option value=1>1
<option value=2>2
<option value=3>3
<option value=4>4
<option value=5>5
<option value=6>6
<option value=7>7
</select> &nbsp; <input type=submit value="<?=MSG_t_dorate;?>">
<input type=hidden name=a value=do_rate>
<input type=hidden name=t value=<?=$topic['t_id'];?>>
</form></div>
<? } ?></noindex>
<? }

function quick_login_form() { ?>
<tr class="basictable"><td><?=MSG_input_login;?>:</td>
<td><input type=text name=inusername size=32 maxlength=32> &nbsp; <a href="index.php?m=profile&a=rules"><?=MSG_register;?></a></td></tr>
<tr class="basictable"><td><?=MSG_input_password;?>:</td>
<td><input type=password name=inpassword size=32 maxlength=32> &nbsp; <a href="index.php?m=profile&a=password"><?=MSG_forgot_password;?>?</a></td></tr>
<? }

function main_time_diff($time,$queries,$time2) { ?>
<br><br><noindex>
<div class="maintext" style="text-align: center"><?=MSG_forum_exectime;?>: <?=$time;?>. <?=MSG_forum_numqueries;?>: <?=$queries;?>, <?=MSG_forum_querytime;?> <?=$time2;?>
<? if ($GLOBALS['inuserlevel']>=1000) { ?><br><a href="admin/index.php"><?=MSG_admincenter;?></a><? } ?>
</div></noindex>
<? }

function show_allowed($inforum,$inuserlevel) { ?>
<br><br><div class="descr">
<?=MSG_p_html;?> <? if ($inuserlevel<$inforum['f_lhtml']) { ?><?=MSG_forbidden;?><? }
else { ?><?=MSG_allowed;?><? } ?><br>
<?=MSG_p_bcode;?> <a href="index.php?m=misc&a=show_bcode">BoardCode</a> <? if (!$inforum['f_bcode']) { ?><?=MSG_forbidden;?><? }
else { ?><?=MSG_allowed;?><? }
?><br>
<?=MSG_usage;?> <a href="index.php?m=misc&a=show_smiles"><?=MSG_p_smiles;?></a> <? if (!$inforum['f_smiles']) { ?><?=MSG_forbidden;?><? }
else { ?><?=MSG_allowed;?><? } ?><br>
<?=MSG_automatic;?> <a href="index.php?m=misc&a=detrans"><?=MSG_p_detrans;?></a>
<? if ($GLOBALS['inuser']['u_detrans']) { ?><?=MSG_enabled;?><? }
else { ?><?=MSG_disabled;?><? } ?></div>
<? }

function confirm($newmodule,$newaction,$params,$text,$backlink) { ?>
<table class="innertable" width=100% cellspacing=1><tr><td class="tablehead" colspan=2>
<?=$text;?></td></tr>
<tr class="basictable"><td width=50% align=right><form action="index.php" method=POST><input type=hidden name=m value="<?=$newmodule;?>">
<input type=hidden name=a value="<?=$newaction;?>">
<? foreach ($params as $curname=>$curvalue) { ?><input type=hidden name=<?=$curname;?> value="<?=$curvalue;?>"><? } ?>
<input type=submit value="Да">&nbsp;</form></td><td>
<form action="<?=$backlink;?>" method=GET>&nbsp;<input type=submit value="Нет"></td></tr></table>
<? }

function timelimiter($time,$name) { ?>
<select name="<?=$name;?>"><?=set_select("<option value=\"\">".MSG_all_time."<option value=1>".MSG_last_day.
"<option value=2>".MSG_last_2days."<option value=7>".MSG_last_week."<option value=30>".MSG_last_month.
"<option value=365>".MSG_last_year,$time);?></select>
<? }

function calendar_out($vardate,$monthselect,$days_in_month,$mindate,$first_day,$reflink) {
  $day = date("j",$vardate);
  $month=date("n",$vardate);
  $year=date("Y",$vardate);
  $prev_date=mktime(0,0,0,$month-1,$day,$year);
  $next_date=mktime(0,0,0,$month+1,$day,$year);
  $test_date2=mktime(0,0,0,$month+1,1,$year);
  $test_date=mktime(0,0,0,$month,1,$year);
?>
<script><!--
function jump() {
  document.location.href='<?=$reflink;?>vd='+vd[vd.selectedIndex].value;
}
-->
</script>
<table width=210 border=0 cellspacing=0 cellpadding=0 class="innertable" align=center>
<tr><td class="tablehead" width=15%><?
if ($mindate>$test_date) { ?>&nbsp;<? }
else { ?><a class="inverse" href="<?=$reflink;?>vd=<?=($test_date-24*60*60);?>">&lt;&lt;&lt</a><? } ?>
<td class="tablehead"><select name="vd" onChange="jump();"><?=set_select($monthselect,$vardate);?></select></td>
<td class="tablehead" width=15%><?
if ($GLOBALS['curtime']<$test_date2) { ?>&nbsp;<? }
else { ?><a class="inverse" href="<?=$reflink;?>vd=<?=$test_date2;?>">&gt;&gt;&gt</a><? } ?>
</td></tr><tr><td colspan=3><table width=100% border=0 cellspacing=1><tr class="basictable">
<? for ($i=1; $i<$first_day; $i++) { ?><td>&nbsp;</td><? }
for ($i=1; $i<=$days_in_month; $i++) {
  if ($i!=$day && $GLOBALS['curtime']>$test_date+($i-1)*24*60*60) {
if (($first_day+$i) % 7 >= 5) { ?><td><a class="calendar_hday" href="<?=$reflink;?>&vd=<?=($test_date+($i-1)*24*60*60);?>"><?=$i;?></a><? }
else { ?><td><a class="calendar" href="<?=$reflink;?>&vd=<?=($test_date+($i-1)*24*60*60);?>"><?=$i;?></a><? }
}
  elseif ($i==$day) { ?><td><b><?=$i;?></b></td><? }
  else { ?><td><?=$i;?></td><? }
  if (($i+$first_day) % 7 ==1) { ?></tr><tr class="basictable"><? }
}
for ($i=($first_day+$days_in_month-1) % 7; $i<7 && $i>1; $i++) { ?><td>&nbsp;</td><? }
?></tr></table></td></tr></table><br>
<? }

function forum_rules($ref,$rules) { ?>
<table class="innertable" width=100% cellspacing=1><tr>
<td class="tablehead"><?
if ($GLOBALS['forum']) { ?>
<?=MSG_f_rules;?> "<?=$GLOBALS['inforum']['f_title'];?>"
<? } else { ?>
<?=MSG_forum_rules;?>
<? }?></td></tr>
<tr><td class="basictable"><br><?=nl2br($rules);?><br><br></td></tr>
<tr><td class="tablehead"><a href="<?=$ref;?>"><?=MSG_prevpage;?></a>
</td></tr></table>
<? }

function fast_switch_form($flist,$button) {
  if (!$button) { ?>
<script><!--
function JumpTo() {
var URL = document.jumpmenu.f.options[document.jumpmenu.f.selectedIndex].value;
top.location.href = "index.php?f="+URL;
}
--></script>
<? } ?>
<form action="index.php" method=GET name=jumpmenu>
<table width=100% border=0><tr><td align=right class="descr"><?=MSG_f_goto;?>: <?
   if ($button) { ?>
<select name=f><?=$flist;?></select>
<input type=submit value="<?=MSG_f_go;?>">
<? }
else { ?>
<select name=f onChange="JumpTo()"><?=$flist;?></select>
<? } ?>
</td></tr></table></form>
<? }

function common_post(&$pdata,$msg) {
if ($GLOBALS['opt_impersonation'] && $GLOBALS['inuserlevel']>=1000) { ?>
<tr class="basictable"><td><?=MSG_p_fromname;?>:</td>
<td><input type=text name=inname value="<?=htmlspecialchars($GLOBALS['inuser']['u__name']);?>">
</td></tr>
<? } ?>
<tr class="basictable"><td>
<?=$msg;?>:
<? show_allowed($GLOBALS['inforum'],$GLOBALS['inuserlevel']);?>
<? if ($GLOBALS['inuser']['u_extform']) { ?><br>
<?=list_smiles("AddText",4);?>
<? } ?>
</td><td>
<script language="Javascript" src="langs/<?=$GLOBALS['inuser']['ln_file'];?>/post.js"></script>
<script language="Javascript" src="styles/<?=$GLOBALS['inuser']['st_file'];?>/post.js"></script>
<? if ($GLOBALS['inuser']['u_extform']) { ?>
<script language="JavaScript">insertcodes();</script>
<? }
if ($GLOBALS['inuser']['u_extform']) { ?>
<textarea name=p_text rows=15 cols=70 onselect="javascript:storeCaret(this);" onclick="javascript:storeCaret(this);" onkeyup="javascript:storeCaret(this);" onchange="javascript:storeCaret(this);"><? }
else { ?><textarea name=p_text rows=15 cols=70><? } ?><?=textarea($pdata['p_text']);?></textarea>
</td></tr>
<? }

function show_vote_resbegin(&$tdata) { ?>
<table class="innertable" cellspacing=1 width=100% cellpadding=3><tr>
<td class="tablehead" colspan=2><?=$tdata['pl_title'];?></td></tr>
<? }

function show_vote_resentry($text,$count,$total) { ?>
<tr class="basictable"><td><?=$text;?></td>
<td><?=$count;?></td></tr>
<? }

function show_vote_resend($total) { ?>
<tr><td class="tablehead" colspan=2><?=MSG_vote_total;?>: <?=$total;?>
</td></tr></table><br>
<? }

function show_vote_begin(&$tdata) { ?>
<form action="index.php" method=POST>
<table class="innertable" cellspacing=1 width=100% cellpadding=3><tr>
<td class="tablehead" colspan=2><?=$tdata['pl_title'];?></td></tr>
<? }

function show_vote_entry($text,$id) { ?>
<tr class="basictable"><td><?=$text;?></td>
<td align=center width=12><input type=radio name=pv_id value="<?=$id;?>">
</td></tr>
<? }

function show_vote_end() { ?>
<tr><td class="tablehead" colspan=2><input type=hidden name=m value=stdforum><input type=hidden name=t value=<?=$GLOBALS['topic'];?>>
<input type=hidden name=a value=do_vote><input type=submit value="Голосовать!">
</td></tr></table></form>
<? }

function main_rating_start($title) { ?>
<br><table width=100% class="innertable" cellspacing=1 cellpadding=0>
<tr><td class="tablehead"><?=$title;?></td></tr>
<? }

function main_rating_entry(&$udata) { ?>
<tr><td class="basictable"><?=user_out($udata['u__name'],$udata['u_id']);?></td></tr>
<? }

function main_rating_end() { ?>
</table>
<? }

function allowed_actions() { 
if ($GLOBALS['inuser']['u_extform']) { ?>
<br><table width=100% class="innertable" cellspacing=0 cellpadding=0><tr class="basictable">
<td width=50% class="descr"><? if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lpost']) { ?><?=MSG_cant;?> <?=MSG_allow_post;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_post;?><? } ?><br><?
if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_ltopic']) { ?><?=MSG_cant;?> <?=MSG_allow_topic;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_topic;?><? } ?><br><?
if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lvote']) { ?><?=MSG_cant;?> <?=MSG_allow_vote;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_vote;?><? } ?><br><?
if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lpoll']) { ?><?=MSG_cant;?> <?=MSG_allow_poll;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_poll;?><? } ?></td><td class="descr"><?
if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_ledit']) { ?><?=MSG_cant;?> <?=MSG_allow_edit;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_edit;?><? } ?><br><?
if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lattach']) { ?><?=MSG_cant;?> <?=MSG_allow_attach;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_attach;?><? } ?><br><?
if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lmoderate']) { ?><?=MSG_cant;?> <?=MSG_allow_moderate;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_moderate;?><? } ?><br><?
if ($GLOBALS['inuserlevel']<$GLOBALS['inforum']['f_lip']) { ?><?=MSG_cant;?> <?=MSG_allow_ip;?><? }
else { ?><?=MSG_can;?> <?=MSG_allow_ip;?><? } ?>
</td></tr></table>
<? }
}
