<?
session_start();

$document = array();
$script = "";
$init = "";

require "../lib/getnpost.php";
require "../lib/config.php";
require "../lib/dbconnect.php";
require "../lib/auth.php";
require "../lib/common.php";

require "community_common.php";

function mkCommunityBox($bdid, $maxlength=34) {
	$result = mysql_query("select msid, mssubject, msdepth
from messages
where bdid = '$bdid'
order by msseq desc
limit 5");

	$communitybox = "";

	for ($i = 0; $i < 5; $i++) {
		if ($i > 0) {
			$communitybox .= <<<EOS
<tr> 
<td height="1" colspan="2"  background="/images/dot_01.gif"></td>
</tr>

EOS;
		}

		list($msi, $mssbj, $msdp) = mysql_fetch_row($result);

		if ($msi) {
			$mssbj = getShortString($mssbj, $maxlength);

			if ($msdp) $mssbj = "[re] " . $mssbj;

			$communitybox .= <<<EOS
<tr> 
<td width="4%" style="padding: 5px;"><img src="/images/ball_black.gif" width="3" height="11"></td>
<td width="96%" style="padding: 5px;"><a href="read.php?bdid=$bdid&msid=$msi">$mssbj</a></td>
</tr>

EOS;
		} else {
			$communitybox .= <<<EOS
<tr> 
<td width="4%" style="padding: 5px;">&nbsp;</td>
<td width="96%" style="padding: 5px;">&nbsp;</td>
</tr>

EOS;
		}
	}

	return $communitybox;
}

function mkCommunity(&$document, &$script, &$init) {
	// °øÁö»çÇ×: bdid 13
	// ÀÚÀ¯°Ô½ÃÆÇ: bdid 1
	// ÇÐ½ÀÁ¤º¸: bdid 7
	// Á¦Ç°È°¿ëÆÁ ¹× »ç¿ë±â: bdid 8
	// ³ìÀ½¸¶¹ý»ç: bdid 5
	// ¾îÈÖ¸¶¹ý»ç: bdid 2
	// PDA ¾îÈÖ¸¶¹ý»ç: bdid 10
	// L/C¸¶¹ý»ç: bdid 3
	// ¾ÈÀüÄ«µå¸¶¹ý»ç: bdid 6
	// ¾Ï±â¸¶¹ý»ç: bdid 4

	$noticebox = mkCommunityBox(13, 34, "C");
	$freebdbox = mkCommunityBox(1, 34);
	$stinfobox = mkCommunityBox(7, 34);
	$tipusebox = mkCommunityBox(8, 34);
	$rwuserbox = mkCommunityBox(5, 38);
	$vwuserbox = mkCommunityBox(2, 38);
	$pwuserbox = mkCommunityBox(10, 38);
	$lwuserbox = mkCommunityBox(3, 38);
	$bwuserbox = mkCommunityBox(6, 38);
	$mwuserbox = mkCommunityBox(4, 38);

	$document['main'] .= <<<EOS
            <table width="710" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td><img src="images/mainbox_up.gif" width="710" height="13"></td>
              </tr>
              <tr> 
                <td align="center" background="/community/images/mainbox_md.gif"> 
                  <table width="690" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="345" align="center" valign="top"> 
                        <!--- °øÁö»çÇ× --->
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td height="22" align="right" valign="top"><a href="/community/list.php?bdid=13"><img src="images/main_title01.gif" width="313" height="16" border="0"></a></td>
                          </tr>
                        </table>
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td><img src="images/greenbox_up.gif" width="313" height="8"></td>
                          </tr>
                          <tr> 
                            <td align="center" background="/community/images/greenbox_md.gif">
<table width="270" border="0" cellspacing="0" cellpadding="0">
$noticebox
</table>
                            </td>
                          </tr>
                          <tr> 
                            <td><img src="images/greenbox_dn.gif" width="313" height="12"></td>
                          </tr>
                        </table>
                      </td>
                      <td width="345" align="center" valign="top"> 
                        <!--- ÀÚÀ¯°Ô½ÃÆÇ --->
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td height="22" align="right" valign="top"><a href="/community/list.php?bdid=1"><img src="images/main_title02.gif" width="313" height="16" border="0"></a></td>
                          </tr>
                        </table>
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td><img src="images/greenbox_up.gif" width="313" height="8"></td>
                          </tr>
                          <tr> 
                            <td align="center" background="/community/images/greenbox_md.gif"> 
<table width="270" border="0" cellspacing="0" cellpadding="0">
$freebdbox
</table>
                            </td>
                          </tr>
                          <tr> 
                            <td><img src="images/greenbox_dn.gif" width="313" height="12"></td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <br>
                  <table width="690" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="345" align="center" valign="top"> 
                        <!--- ÇÐ½ÀÁ¤º¸ --->
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td height="22" align="right" valign="top"><a href="/community/list.php?bdid=7"><img src="images/main_title03.gif" width="313" height="16" border="0"></a></td>
                          </tr>
                        </table>
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td><img src="images/greenbox_up.gif" width="313" height="8"></td>
                          </tr>
                          <tr> 
                            <td align="center" background="/community/images/greenbox_md.gif"> 
<table width="270" border="0" cellspacing="0" cellpadding="0">
$stinfobox
</table>
                            </td>
                          </tr>
                          <tr> 
                            <td><img src="images/greenbox_dn.gif" width="313" height="12"></td>
                          </tr>
                        </table>
                      </td>
                      <td width="345" align="center" valign="top"> 
                        <!--- Á¦Ç° È°¿ëÆÁ ¹× »ç¿ë±â --->
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td height="22" align="right" valign="top"><a href="/community/list.php?bdid=8"><img src="images/main_title04.gif" width="305" height="17" border="0"></a></td>
                          </tr>
                        </table>
                        <table width="313" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td><img src="images/greenbox_up.gif" width="313" height="8"></td>
                          </tr>
                          <tr> 
                            <td align="center" background="/community/images/greenbox_md.gif"> 
<table width="270" border="0" cellspacing="0" cellpadding="0">
$tipusebox
</table>
                            </td>
                          </tr>
                          <tr> 
                            <td><img src="images/greenbox_dn.gif" width="313" height="12"></td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table> </td>
              </tr>
              <tr> 
                <td><img src="images/mainbox_dn.gif" width="710" height="13"></td>
              </tr>
            </table>
            <br>
            <table width="710" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="355" align="center" valign="top"> 
                  <!--- ³ìÀ½¸¶¹ý»ç --->
                  <table width="340" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="294" height="25" style="padding-left:20px"><img src="images/main_title05.gif" width="156" height="13"></td>
                      <td width="46"><a href="/community/list.php?bdid=5"><img src="images/title_more.gif" width="41" height="11" border="0"></a></td>
                    </tr>
                    <tr> 
                      <td height="6" colspan="2"  background="/community/images/title_pat.gif"></td>
                    </tr>
                    <tr> 
                      <td height="10" colspan="2"></td>
                    </tr>
                  </table>
<table width="300" border="0" cellspacing="0" cellpadding="0">
$rwuserbox
</table>
                </td>
                <td width="355" align="center" valign="top"> 
                  <!--- ¾îÈÖ¸¶¹ý»ç --->
                  <table width="340" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="294" height="25" style="padding-left:20px"><img src="images/main_title06.gif" width="181" height="13"></td>
                      <td width="46"><a href="/community/list.php?bdid=2"><img src="images/title_more.gif" width="41" height="11" border="0"></a></td>
                    </tr>
                    <tr> 
                      <td height="6" colspan="2"  background="/community/images/title_pat.gif"></td>
                    </tr>
                    <tr> 
                      <td height="10" colspan="2"></td>
                    </tr>
                  </table>
<table width="300" border="0" cellspacing="0" cellpadding="0">
$vwuserbox
</table>
                </td>
              </tr>
            </table>
            <br>
            <table width="710" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="355" align="center" valign="top"> 
                  <!--- PDA¾îÈÖ¸¶¹ý»ç --->
                  <table width="340" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="294" height="25" style="padding-left:20px"><img src="images/main_title07.gif" width="251" height="13"></td>
                      <td width="46"><a href="/community/list.php?bdid=10"><img src="images/title_more.gif" width="41" height="11" border="0"></a></td>
                    </tr>
                    <tr> 
                      <td height="6" colspan="2"  background="/community/images/title_pat.gif"></td>
                    </tr>
                    <tr> 
                      <td height="10" colspan="2"></td>
                    </tr>
                  </table>
<table width="300" border="0" cellspacing="0" cellpadding="0">
$pwuserbox
</table>
                </td>
                <td width="355" align="center" valign="top"> 
                  <!--- L/C¸¶¹ý»ç --->
                  <table width="340" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="294" height="25" style="padding-left:20px"><img src="images/main_title08.gif" width="246" height="13"></td>
                      <td width="46"><a href="/community/list.php?bdid=3"><img src="images/title_more.gif" width="41" height="11" border="0"></a></td>
                    </tr>
                    <tr> 
                      <td height="6" colspan="2"  background="/community/images/title_pat.gif"></td>
                    </tr>
                    <tr> 
                      <td height="10" colspan="2"></td>
                    </tr>
                  </table>
<table width="300" border="0" cellspacing="0" cellpadding="0">
$lwuserbox
</table>
                </td>
              </tr>
            </table>
            <br>
            <table width="710" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="355" align="center" valign="top"> 
                  <!--- ¾ÈÀüÄ«µå¸¶¹ý»ç --->
                  <table width="340" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="294" height="25" style="padding-left:20px"><img src="images/main_title09.gif" width="207" height="13"></td>
                      <td width="46"><a href="/community/list.php?bdid=6"><img src="images/title_more.gif" width="41" height="11" border="0"></a></td>
                    </tr>
                    <tr> 
                      <td height="6" colspan="2"  background="/community/images/title_pat.gif"></td>
                    </tr>
                    <tr> 
                      <td height="10" colspan="2"></td>
                    </tr>
                  </table>
<table width="300" border="0" cellspacing="0" cellpadding="0">
$bwuserbox
</table>
                </td>
                <td width="355" align="center" valign="top"> 
                  <!--- ¾Ï±â¸¶¹ý»ç --->
                  <table width="340" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="294" height="25" style="padding-left:20px"><img src="images/main_title10.gif" width="184" height="13"></td>
                      <td width="46"><a href="/community/list.php?bdid=4"><img src="images/title_more.gif" width="41" height="11" border="0"></a></td>
                    </tr>
                    <tr> 
                      <td height="6" colspan="2"  background="/community/images/title_pat.gif"></td>
                    </tr>
                    <tr> 
                      <td height="10" colspan="2"></td>
                    </tr>
                  </table>
<table width="300" border="0" cellspacing="0" cellpadding="0">
$mwuserbox
</table>
                </td>
              </tr>
            </table>
            <br>

EOS;
}

## Start

mkCommunity($document, $script, $init);

$document['mainalign'] = "right";	// overload community_common.php

$document['subtitlename'] = "";

$document['subtitle'] = <<<EOS
<img src="/community/images/subtitle_00.gif" />
EOS;

require "community_template.php";
?>
