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

// 性能不行
$sql = 'SELECT b.*,t.typename FROM '.Book::table().' AS b INNER JOIN `'.Types::table().'` AS t ON t.typeid = b.typeid ORDER BY RAND() LIMIT 1';
$book = $db->setQueryString($sql)->find(true);

$chapters = Chapter::single()->getChapterList($book['bookid']);
if (!empty($chapters))
{
    $firstChapter = $chapters[0];
}

include_once tpl('rbook');