<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
define('IN_IORANGE', true);
include('include/init.php');

$count = $db->getValue('SELECT COUNT(*) FROM '.Book::table().' WHERE status = 1 AND view = 1');
$pageObj = new iPage();
$pageObj->setPageSize(10);
$pageObj->setTotalRecord($count);

$sql = 'SELECT `bookid`,typeid,size,`bookname`,lastchapterid,bookinfo,`author` FROM `'.Book::table().'`
		WHERE `status` = 1 AND `view` = 1
		ORDER BY `updatedate` DESC LIMIT '.$pageObj->getOffset().','.$pageObj->getPageSize();
$books = $db->setQueryString($sql)->find();
if (!empty($books))
{
    foreach ($books as &$book)
    {
        $book['bookinfo'] = preg_replace('/\s/i', '', preg_replace('/\n/i', '', preg_replace('/　/i', '', $book['bookinfo'])));
        if (mb_strlen($book['bookinfo'], 'utf-8') > 30)
        {
            $book['bookinfo'] = iSubstr($book['bookinfo'], 0, 32, '...');
        }
    }
}

include_once tpl("over");