<?php require_once 'nsoconfig.php';?>
<?php include_once '_cake_top.php';?>
    <?php include_once '_cake_header.php';?>
    <div id="main-content">
        <?php include_once'_cake_searchbar.php'?>
        <div class="pml">
            <div class="pmlt1"><img src="images/ic_p.gif">下载中心</div>
            <div class="h10"></div>
            <div class="pmlt3">
                <div class="pjtt"></div>
                <div class="pjltc lhei">
                    <h3>下载中心(请点击名称下载)</h3>
                    <p>&nbsp;</p>
                    <p><span class="STYLE3">*以下软件资源来自互联网，仅供学习，勿做其它用途；</span></p>
                    <p class="STYLE3">*以下软件解释权为：<strong>【<span class="STYLE6">泽瑞所有</span></strong>】</p>
                    <table width="100%" cellspacing="0" cellpadding="0" align="center" class="under" id="blin2">
                        <tbody>
                        <?php $categories = getCategoriesByParent(6); $i=1; foreach ($categories as $cat): ?>
                            <tr bgcolor="#DDEDF6">
                                <td height="30" bgcolor="#EDF2F8" colspan="4"><span class="STYLE4">【<?php echo $i?>】<?php echo $cat['name']?></span></td>
                            </tr>
                            <tr>
                                <td width="258"><span class="STYLE5">名称 </span></td>
                                <td width="255"><span class="STYLE5">说明 </span></td>
								<td width="68"><span class="STYLE5">软件大小 </span></td>
                                <td width="72"><span class="STYLE5">上传日期</span></td>
                            </tr>
                            <?php 
							$posts = getPostsByCategory($cat['id']);
							if ($posts): foreach ($posts as $post):
								$file = getFileWithFullPathByPost($post['post_id'], 'rar');
								$fileValue = str_replace(NSO_UPLOAD_DIR_NAME . '/', '', $file);
								$sql = "SELECT size FROM files WHERE path = '{$fileValue}'";
								$row = $nsodb->get_row($sql, ARRAY_A);
								$fileSize = $row['size'];
							?>
                            <tr>
                                <td bgcolor="#f4f4f4"><a class="STYLE5" href="<?php echo $file?>"><?php echo $post['title'];?></a></td>
                                <td bgcolor="#f4f4f4"><span class="STYLE5"><?php echo $post['subtitle']?></span></td>
                                <td><span class="STYLE5"><?php echo round($fileSize/1024, 2)?>MB</span></td>
                                <td bgcolor="#f4f4f4"><span class="STYLE5"><?php echo date('m月d日', strtotime($post['date']))?></span></td>
                            </tr>
                            <?php endforeach; endif;?>
                        <?php $i++; endforeach;?>
                        </tbody>
                    </table>
                    <p class="STYLE1">&nbsp;</p>
                    <p class="STYLE1">&nbsp;</p>
                </div>
            </div>
            <div class="h15"></div>
        </div>
        <?php include_once '_cake_service_siderbar.php';?>
    </div>
    <?php include_once '_cake_footer.php';?>