【Lbook】读书角入口 | 书籍资源 整合
本贴目的在于可以通过搜索快速找到《读书角》的位置,方便查阅书籍。
【Lbook读书角 | 点此进入】点击上面链接快速访问。
关于Lbook资源的说明
2023年12月27日,limitless将所有pdf文件整合在此处,所有资源原始页面将无法获取资源,不做另行通知。
如遇资源无法访问请访问本页查看资源是否存在。
看书时提示“服务器错误:404 找不到资源”,pdf展示页白屏解决办法
limitless已经将所有上架的pdf资源整合到读书角内,原有资源访问方式立刻作废不可用。不进行另行通告。
请从读书角访问。
若页面提示无法找到资源,请从读书角进入,使用ctrl+F搜索是否存在资源。
一些资源可能为其他资源的二级资源,需要点击进入才可访问,例如《超新星纪元》在《刘慈欣作品集》内,直接搜索是搜不到的。
Lbook后端程序代码开源
Lbook实际上是使用了一种基于php共享文件夹资源的方案。不一定是共享电子书,也可以共享任何文件或资源,使用户自由获取所需。
该基于php共享资源的原理是,直接将资源按照文件夹目录树组织,然后为每个文件夹提供一个index.php用来供外部用户访问。仅需将需要共享的资源(例如pdf,ebup,txt,zip等文件)按照顺序放在文件夹内,并为所有目录配备index.php(包括根目录)即可让用户通过浏览器网页的形式,像是浏览自己计算机上的文件一样,访问服务器上的资源。该index.php代码将于后文提供。
用户实际上获取的是文件的获取链接,至于是获取这个文件,还是直接在线预览(比如pdf之类的是可以直接在线预览的,此时就如同一个电子书网站一样),实际上是用户的浏览器决定的。好在,现在大部分浏览器都支持在线预览。
使用该代码,可以作为最简单的替代ftp服务器的方法,作为电子书网站时,并不会获得一个多么强大的电子书页面应用,但是它绝对足够简单,所以特别适合个人使用或者小组织临时部署的一些资源共享网站。
文件结构类似于:
Lbook/ # 根目录
├── index.php # 用户通过访问这个页面,获取下面的几个子文件夹
├── Chapter1/ # 子文件夹1
│ ├── index.php # 用户进入后,通过这个页面继续获取具体的书籍或次级文件夹
│ ├── page01.pdf # 电子书等资源
│ ├── page02.pdf
│ └── ...
├── Chapter2/
│ ├── index.php # 每个需要用户访问的位置,都需要相同的`index.php`
│ ├── section01.epub
│ ├── section02.epub
│ └── ...
└── Chapter3/
├── index.php
├── document01.txt
├── document02.txt
└── ...
为了部署一个类似于Lbook一样的最简单资源站,你需要准备:
- 需要一台服务器。cpu与内存不需要特别大,但是带宽需要按照所需选择。如果是内网部署可以忽略。
- 足够大的磁盘。
- 一个服务器后端,例如Windows的
iss,Linux的nginx等,用来提供http协议服务器。 - 开放需要开放的端口。
- 将
http页面根目录设置为资源目录根目录。 - 给所有需要分享的目录下都放置一个
index.html,代码如下。
index.php代码。注意,一般来说这个文件必须叫这个名字。全部设置好之后应该就能玩了!注意,这个代码契合了limitless的主题,你可以按需更改里面的内容
<!-- https://limitless.net.cn/?p=1630 -->
<!-- 页面开源授权:GPL v3 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lbook - 读书角</title>
<link rel="shortcut icon" href="favicon.ico">
<style>
body {
background-color: #efefef;
margin: 0;
padding: 20px;
}
h1,
h2 {
color: #1e1e1e;
}
table {
width: 90%;
margin: auto;
align: center;
}
th,
td {
padding: 12px 15px;
text-align: left;
border: 1px solid #ccc;
border-radius: 10px;
}
th {
background-color: #ccc;
}
tr {
color: #1e1e1e;
background-color: #efefef;
transition: 0.5s all;
}
tr:hover {
background-color: #ccc;
}
a {
color: #1e1e1e;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.container13009 {
max-width: 1024px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border: 1px solid #1e1e1e;
border-radius: 10px;
box-shadow: 0 0px 4px rgb(18 18 18 / 15%);
}
.card-link {
display: inline-block;
text-align: center;
border-radius: 10px;
border: 1px solid #ccc;
background-color: #efefef;
color: #1e1e1e;
padding: 5px;
padding-left: 20px;
padding-right: 20px;
text-decoration: none !important;
transition: background-color 0.3s;
margin: 10px;
}
.card-link:hover {
background-color: #1e1e1e;
color: #efefef;
}
</style>
</head>
<body>
<div class="container13009">
<?php
$num = 0; //用来记录目录下的文件个数
$dirname = './'; //要遍历的目录名字
$dir_handle = opendir($dirname);
function formatSizeUnits($bytes)
{
if ($bytes >= 1099511627776) {
$bytes = number_format($bytes / 1099511627776, 3) . ' TB';
} elseif ($bytes >= 1073741824) {
$bytes = number_format($bytes / 1073741824, 3) . ' GB';
} elseif ($bytes >= 1048576) {
$bytes = number_format($bytes / 1048576, 3) . ' MB';
} elseif ($bytes >= 1024) {
$bytes = number_format($bytes / 1024, 3) . ' KB';
} else {
$bytes = $bytes . ' B';
}
return $bytes;
}
echo '<table>';
echo '<caption><h2>Lbook | 读书角 | 休闲阅读目录</h2></caption>';
echo '<th>序号</th><th>名称</th><th style="width: 100px;">存储空间</th><th>类型</th></tr>';
while ($file = readdir($dir_handle)) {
if ($file != "." && $file != ".." && $file != "index.php" && $file != "favicon.ico") {
$dirFile = $dirname . "/" . $file;
$num = $num + 1;
echo '<td>' . $num . '</td>';//序号
echo '<td><a href="' . $file . '" target="_self" >' . $file . '</a></td>'; //名称 链接
echo '<td style="width: 100px;">' . formatSizeUnits(filesize($dirFile)) . '</td>';//大小
echo '<td>' . filetype($dirFile) . '</td>';//类型
echo '</tr>';
}
}
echo '</table>';
closedir($dir_handle);
echo '<hr><h2>关于Lbook资源的说明</h2><p>2023年12月27日,limitless将所有pdf文件整合在此处,所有资源原始页面将无法获取资源,不做另行通知。<br>如遇资源无法访问请访问本页查看资源是否存在.</p><hr>';
echo '<div style="margin: 0 auto; width: fit-content;"><a class="card-link" href="/" target="_self" >返回 limitless 主页</a> <a class="card-link" href="/?p=1630" target="_self" >关于读书角 Lbook</a><a class="card-link" href="javascript:history.back(-1)">返回上一页</a></div>';
?>
<div style="text-align: center;"> <a href="/" style="color:#000000;text-decoration: none !important" target="_self" rel="nofollow">limitless</a> © Copyright 2021~2025 All right reserved</div>
</div>
</body>
代码授权许可:GPLv3
2023年11月26日
2025年2月4日开源最新版代码
