get_res_index.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <?php
  2. /*
  3. 获取资源列表
  4. */
  5. require_once "../path.php";
  6. require_once "../public/_pdo.php";
  7. if(isset($_COOKIE["language"])){
  8. $lang=$_COOKIE["language"];
  9. }
  10. else{
  11. $lang="en";
  12. }
  13. require_once "language/db_{$lang}.php";
  14. if(isset($_GET["book"])){
  15. $book=$_GET["book"];
  16. }
  17. else{
  18. echo "no book id";
  19. exit;
  20. }
  21. if(substr($book,0,1)=='p'){
  22. $book=substr($book,1);
  23. }
  24. if(isset($_GET["album"])){
  25. $album = $_GET["album"];
  26. }
  27. else{
  28. $album = -1;
  29. }
  30. if(isset($_GET["paragraph"])){
  31. $paragraph = $_GET["paragraph"];
  32. }
  33. else{
  34. $paragraph = -1;
  35. }
  36. function format_file_size($size){
  37. if($size<102){
  38. $str_size=$size."B";
  39. }
  40. else if($size<(1024*102)){
  41. $str_size=sprintf("%.1f KB",$size/1024);
  42. }
  43. else{
  44. $str_size=sprintf("%.1f MB",$size/(1024*1024));
  45. }
  46. return($str_size);
  47. }
  48. PDO_Connect("sqlite:"._FILE_DB_RES_INDEX_);
  49. //资源名称
  50. $res_title="";
  51. if($album==-1){
  52. //查书
  53. if($paragraph==-1){
  54. //查整本书
  55. $query = "select * from 'book' where book_id='$book' ";
  56. $Fetch = PDO_FetchAll($query);
  57. $iFetch=count($Fetch);
  58. if($iFetch>0){
  59. echo "<div id='album_info_head'>";
  60. $res_title=$Fetch[0]["title"];
  61. echo "<h2>$res_title</h2>";
  62. echo "<div class='album_info'>";
  63. echo "<div class='cover'></div>";
  64. echo "<div class='infomation'>";
  65. //标题
  66. echo "<div class='title'>《".$res_title."》</div>";
  67. echo "<div class='type'>".$Fetch[0]["c1"]." ".$Fetch[0]["c2"]."</div>";
  68. echo "</div>";
  69. echo "</div>";
  70. //相关专辑
  71. $query = "select album.id,album.title, author.name from album LEFT JOIN author ON album.author = author.id where album.book='$book' ";
  72. $Fetch_ather = PDO_FetchAll($query);
  73. $iFetchAther=count($Fetch_ather);
  74. if($iFetchAther>0){
  75. echo "<ul class='search_list'>";
  76. echo "<li class='title'>相关专辑</li>";
  77. foreach($Fetch_ather as $one_album){
  78. $read_link="reader.php?book=$book&album=".$one_album["id"]."&paragraph=$paragraph";
  79. $info_link="index_render_res_list($book,".$one_album["id"].",-1)";
  80. echo "<li onclick='$info_link' >";
  81. echo "<span>{$one_album["title"]}</span>";
  82. echo "<div><span class='author_name'>".$one_album["name"]."</span><span class='ui-icon-carat-r ui-icon' style='display:inline-block;'></span></span>";
  83. echo "</li>";
  84. }
  85. echo "</ul>";
  86. }
  87. //相关专辑结束
  88. echo "</div>";
  89. //目录
  90. $db_file = _FILE_DB_PALITEXT_;
  91. PDO_Connect("sqlite:$db_file");
  92. $query = "select * from 'pali_text' where book = '{$book}' and ( level>'0' and level<8 ) ";
  93. $Fetch_Toc = PDO_FetchAll($query);
  94. $iFetchToc=count($Fetch_Toc);
  95. if($iFetchToc>0){
  96. $aLevel=array();
  97. foreach($Fetch_Toc as $one_title){
  98. $level=$one_title["level"];
  99. if(isset($aLevel["{$level}"])){
  100. $aLevel["{$level}"]++;
  101. }
  102. else{
  103. $aLevel["{$level}"]=1;
  104. }
  105. }
  106. ksort($aLevel);
  107. //找出不是一个的最大层级
  108. foreach($aLevel as $x=>$x_value){
  109. $maxLevel=$x;
  110. if($x_value>1){
  111. break;
  112. }
  113. }
  114. echo "<ul class='search_list'>";
  115. echo "<li class='title'>章节</li>";
  116. foreach($Fetch_Toc as $one_title){
  117. $level=$one_title["level"];
  118. if($maxLevel==$level){
  119. $toc_paragraph=$one_title["paragraph"];
  120. $toc_title=$one_title["text"];
  121. $info_link="index_render_res_list($book,-1,$toc_paragraph)";
  122. echo "<li onclick='$info_link' >";
  123. echo "<span>{$toc_title}</span>";
  124. echo "<div><span class='author_name'>2</span><span class='ui-icon-carat-r ui-icon' style='display:inline-block;'></span></span>";
  125. echo "</li>";
  126. }
  127. }
  128. echo "</ul>";
  129. }
  130. //目录结束
  131. }
  132. }
  133. else{
  134. //查书中的一个段
  135. $db_file = _FILE_DB_PALITEXT_;
  136. PDO_Connect("sqlite:$db_file");
  137. $query = "select text from 'pali_text' where book= '{$book}' and paragraph= '{$paragraph}' ";
  138. $res_title = PDO_FetchOne($query);
  139. echo "<div id='album_info_head'>";
  140. echo "<h2>$res_title</h2>";
  141. echo "<div class='album_info'>";
  142. echo "<div class='cover'></div>";
  143. echo "<div class='infomation'>";
  144. //书名
  145. echo "<div class='title'>《{$book_name[$book][0]}》</div>";
  146. echo "<div class='type'>{$book_name[$book][1]}</div>";
  147. echo "</div>";
  148. echo "</div>";
  149. PDO_Connect("sqlite:"._FILE_DB_RES_INDEX_);
  150. $query = "select resindex.id,resindex.title,resindex.type,resindex.album,author.name from 'index' as resindex LEFT JOIN author ON resindex.author = author.id where resindex.book='$book' and resindex.paragraph=$paragraph and resindex.type<>7 group by resindex.album";
  151. $Fetch = PDO_FetchAll($query);
  152. $iFetch=count($Fetch);
  153. if($iFetch>0){
  154. $res_title=$Fetch[0]["title"];
  155. //可用资源
  156. echo "<ul class='search_list'>";
  157. echo "<li class='title'>可用资源</li>";
  158. foreach($Fetch as $one_album){
  159. $album_type=$one_album["type"];
  160. $read_link="../pcdl/reader.php?book=$book&album=".$one_album["album"]."&paragraph=$paragraph";
  161. $info_link="index_render_res_list($book,".$one_album["album"].",$paragraph)";
  162. echo "<li onclick='$info_link' >";
  163. echo "<span><span class='media_type'>{$media_type_short[$album_type]}</span>{$one_album["title"]}</span>";
  164. echo "<div><span class='author_name'>{$one_album["name"]}</span><span class='ui-icon-carat-r ui-icon' style='display:inline-block;'></span></span>";
  165. echo "</li>";
  166. }
  167. echo "</ul>";
  168. }
  169. //查共享文档
  170. PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
  171. $query = "select * from fileindex where book='$book' and paragraph=$paragraph and status>0 and share>0 order by create_time";
  172. $Fetch = PDO_FetchAll($query);
  173. $iFetch=count($Fetch);
  174. if($iFetch>0){
  175. echo "<ul class='search_list'>";
  176. echo "<li class='title'>共享文档</li>";
  177. foreach($Fetch as $one_file){
  178. //$read_link="reader.php?book=$book&album=".$one_para["album"]."&paragraph=$paragraph";
  179. $edit_link="../app/project.php?op=open&doc_id={$one_file["doc_id"]}";
  180. echo "<li class='noline'><a href='$edit_link' target='_blank'>".$one_file["title"]."</a>-".$one_file["user_id"]."</li>";
  181. }
  182. echo "</ul>";
  183. }
  184. //目录
  185. $db_file =_FILE_DB_PALITEXT_;
  186. PDO_Connect("sqlite:$db_file");
  187. $query = "select * from 'pali_text' where book = '{$book}' and level>'0' and level<8 and paragraph>=$paragraph ";
  188. $Fetch_Toc = PDO_FetchAll($query);
  189. $iFetchToc=count($Fetch_Toc);
  190. if($iFetchToc>1){
  191. if($Fetch_Toc[1]["level"]>$Fetch_Toc[0]["level"]){
  192. echo "<ul class='search_list'>";
  193. echo "<li class='title'>章节</li>";
  194. for($iToc=1;$iToc<$iFetchToc;$iToc++){
  195. if($Fetch_Toc[$iToc]["level"]<=$Fetch_Toc[0]["level"]){
  196. break;
  197. }
  198. $level=$Fetch_Toc[$iToc]["level"];
  199. $toc_paragraph=$Fetch_Toc[$iToc]["paragraph"];
  200. $toc_title=$Fetch_Toc[$iToc]["text"];
  201. $info_link="index_render_res_list($book,-1,$toc_paragraph)";
  202. echo "<li onclick='$info_link' >";
  203. echo "<span>{$toc_title}</span>";
  204. echo "<div><span class='author_name'>2</span><span class='ui-icon-carat-r ui-icon' style='display:inline-block;'></span></span>";
  205. echo "</li>";
  206. }
  207. echo "</ul>";
  208. }
  209. }
  210. //目录结束
  211. }
  212. }
  213. else{
  214. //查专辑
  215. if($paragraph==-1){
  216. //查整张专辑
  217. $query = "select album.id,album.title,album.file,album.guid,album.type, author.name from album LEFT JOIN author ON album.author = author.id where album.id='$album' ";
  218. //$query = "select * from 'album' where id='$album'";
  219. $Fetch = PDO_FetchAll($query);
  220. $iFetch=count($Fetch);
  221. if($iFetch>0){
  222. echo "<div id='album_info_head'>";
  223. //标题
  224. $res_title=$Fetch[0]["title"];
  225. $album_file_name=$Fetch[0]["file"];
  226. $album_guid=$Fetch[0]["guid"];
  227. $album_type=$Fetch[0]["type"];
  228. echo "<h2>$res_title</h2>";
  229. echo "<div class='album_info'>";
  230. echo "<div class='cover'></div>";
  231. echo "<div class='infomation'>";
  232. //标题
  233. echo "<div class='title'>".$res_title."</div>";
  234. //echo "<div class='type'>".$Fetch[0]["c1"]." ".$Fetch[0]["c2"]."</div>";
  235. echo "<div class='author'>".$Fetch[0]["name"]."</div>";
  236. echo "<div class='media'><span class='media_type'>".$media_type[$Fetch[0]["type"]]."</span></div>";
  237. echo "</div>";
  238. echo "</div>";
  239. $read_link="reader.php?book=$book&album=$album&paragraph=$paragraph";
  240. echo "<ul class='search_list'>";
  241. echo "<li class='title'>阅读</li>";
  242. echo "<li><a class='online_read' style='color: white;' href='$read_link' target='_blank'>在线阅读</a></li>";
  243. echo "</ul>";
  244. //下载
  245. echo "<ul class='search_list'>";
  246. $query = "select album_ebook.file_name, album_ebook.file_size, file_format.format from album_ebook LEFT JOIN file_format ON album_ebook.file_format=file_format.id where album='$album'";
  247. $Fetch_ebook = PDO_FetchAll($query);
  248. if(count($Fetch_ebook)>0){
  249. echo "<li class='title'>下载</li>";
  250. foreach($Fetch_ebook as $one_ebook){
  251. $ebook_download_link="<a href='".$one_ebook["file_name"]."' target='_blank'>下载</a>";
  252. echo "<li><span class='file_format'>".$one_ebook["format"]."</span>".format_file_size($one_ebook["file_size"])."$ebook_download_link</li>";
  253. }
  254. }
  255. echo "</ul>";
  256. //相关专辑
  257. echo "<ul class='search_list'>";
  258. $query = "select album.id,album.title,album.file,album.guid,album.type, author.name from album LEFT JOIN author ON album.author = author.id where album.book='$book' and album.id != $album ";
  259. //$query = "select * from 'album' where book='$book' and id != $album";
  260. $Fetch_ather = PDO_FetchAll($query);
  261. $iFetchAther=count($Fetch_ather);
  262. if($iFetchAther>0){
  263. echo "<li class='title'>相关专辑</li>";
  264. foreach($Fetch_ather as $one_album){
  265. $read_link="reader.php?book=$book&album=".$one_album["id"]."&paragraph=$paragraph";
  266. echo "<li ><span class='media_type'>{$media_type[$one_album["type"]]}</span><a href='$read_link' target='_blank'>{$one_album["title"]}</a>{$one_album["name"]}</li>";
  267. }
  268. }
  269. echo "</ul>";
  270. //相关专辑结束
  271. echo "</div>";
  272. //目录
  273. switch($album_type){
  274. case 1:
  275. case 2:
  276. case 6:
  277. $db_file = _FILE_DB_PALITEXT_;
  278. PDO_Connect("sqlite:$db_file");
  279. $query = "select * from 'pali_text' where book = '{$book}' and level>'0' and level<8 ";
  280. break;
  281. case 3:
  282. $db_file = '../'.$album_file_name;
  283. echo "db album:{$db_file}";
  284. PDO_Connect("sqlite:$db_file");
  285. $query = "select * from 'album' where guid='$album_guid'";
  286. $Fetch_album = PDO_FetchAll($query);
  287. $this_album_id=$Fetch_album[0]["id"];
  288. $query = "select * from 'data' where level>'0' and level<8 and album=$this_album_id ";
  289. break;
  290. }
  291. $Fetch_Toc = PDO_FetchAll($query);
  292. $iFetchToc=count($Fetch_Toc);
  293. if($iFetchToc>0){
  294. $aLevel=array();
  295. foreach($Fetch_Toc as $one_title){
  296. $level=$one_title["level"];
  297. if(isset($aLevel["{$level}"])){
  298. $aLevel["{$level}"]++;
  299. }
  300. else{
  301. $aLevel["{$level}"]=1;
  302. }
  303. }
  304. ksort($aLevel);
  305. //找出不是一个的最大层级
  306. foreach($aLevel as $x=>$x_value){
  307. $maxLevel=$x;
  308. if($x_value>1){
  309. break;
  310. }
  311. }
  312. echo "<ul class='search_list'>";
  313. echo "<li class='title'>章节</li>";
  314. foreach($Fetch_Toc as $one_title){
  315. $level=$one_title["level"];
  316. if($maxLevel==$level){
  317. $toc_paragraph=$one_title["paragraph"];
  318. $toc_title=$one_title["text"];
  319. $info_link="index_render_res_list($book,$album,$toc_paragraph)";
  320. echo "<li onclick='$info_link' >";
  321. echo "<span>{$toc_title}</span>";
  322. echo "<div><span class='author_name'>2</span><span class='ui-icon-carat-r ui-icon' style='display:inline-block;'></span></span>";
  323. echo "</li>";
  324. }
  325. }
  326. echo "</ul>";
  327. }
  328. //目录结束
  329. }
  330. }
  331. else{
  332. //查专辑中的一个段
  333. $query = "select * from 'index' where album='$album' and paragraph=$paragraph";
  334. $Fetch = PDO_FetchAll($query);
  335. $iFetch=count($Fetch);
  336. if($iFetch>0){
  337. //标题
  338. $res_title=$Fetch[0]["title"];
  339. echo "<h2>$res_title</h2>";
  340. echo "<div class='album_info'>";
  341. echo "<div class='cover'></div>";
  342. echo "<div class='infomation'>";
  343. //出自专辑 标题
  344. $query = "select album.id,album.title,album.type,album.file,album.guid, author.name from album LEFT JOIN author ON album.author = author.id where album.id='$album' ";
  345. $FetchAlbum = PDO_FetchAll($query);
  346. if(count($FetchAlbum)>0){
  347. $album_type=$FetchAlbum[0]["type"];
  348. $album_file_name=$FetchAlbum[0]["file"];
  349. $album_guid=$FetchAlbum[0]["guid"];
  350. //专辑标题
  351. $info_link="index_render_res_list($book,$album,-1)";
  352. echo "<div onclick='$info_link' class='title'>".$FetchAlbum[0]["title"]."</div>";
  353. }
  354. echo "<div class='author'>".$FetchAlbum[0]["name"]."</div>";
  355. echo "<div class='author'><span class='media_type'>".$media_type[$FetchAlbum[0]["type"]]."</span></div>";
  356. echo "</div>";
  357. echo "</div>";
  358. //在线阅读
  359. $read_link="reader.php?book=$book&album=$album&paragraph=$paragraph";
  360. echo "<ul class='search_list'>";
  361. echo "<li class='title'>阅读</li>";
  362. echo "<li><a class='online_read' style='color: white;' href='$read_link' target='_blank'>在线阅读</a></li>";
  363. echo "</ul>";
  364. //相关段落
  365. //$query = "select album.id,album.title,album.file,album.guid,album.type, author.name from album LEFT JOIN author ON album.author = author.id where album.book='$book' and album.id != $album ";
  366. $query = "select idx.id , idx.title , idx.album , idx.type , author.name FROM 'index' as idx LEFT JOIN author ON idx.author = author.id WHERE idx.book='$book' and idx.paragraph=$paragraph and idx.album!=$album and idx.type!=7";
  367. $Fetch_ather = PDO_FetchAll($query);
  368. $iFetchAther=count($Fetch_ather);
  369. if($iFetchAther>0){
  370. echo "<ul class='search_list'>";
  371. echo "<li class='title'>相关资源</li>";
  372. foreach($Fetch_ather as $one_album){
  373. $read_link="reader.php?book=$book&album=".$one_album["album"]."&paragraph=$paragraph";
  374. echo "<li class='noline'>";
  375. echo "<span><span class='media_type'>{$media_type[$one_album["type"]]}</span>";
  376. echo "<a href='$read_link' target='_blank'>{$one_album["title"]}</a></span><span>{$one_album["name"]}</span></li>";
  377. }
  378. echo "</ul>";
  379. }
  380. //目录
  381. switch($album_type){
  382. case 1:
  383. case 2:
  384. case 6:
  385. $db_file =_FILE_DB_PALITEXT_;
  386. PDO_Connect("sqlite:$db_file");
  387. $query = "select * from 'pali_text' where book = '{$book}' and level>'0' and level<8 and paragraph>=$paragraph ";
  388. break;
  389. case 3:
  390. $db_file = "../{$album_file_name}";
  391. PDO_Connect("sqlite:$db_file");
  392. $query = "select * from 'album' where guid='$album_guid'";
  393. $Fetch_album = PDO_FetchAll($query);
  394. $this_album_id=$Fetch_album[0]["id"];
  395. $query = "select * from 'data' where level>'0' and level<8 and paragraph>=$paragraph and album=$this_album_id ";
  396. break;
  397. }
  398. $Fetch_Toc = PDO_FetchAll($query);
  399. $iFetchToc=count($Fetch_Toc);
  400. if($iFetchToc>1){
  401. if($Fetch_Toc[1]["level"]>$Fetch_Toc[0]["level"]){
  402. echo "<ul class='search_list'>";
  403. echo "<li class='title'>章节</li>";
  404. for($iToc=1;$iToc<$iFetchToc;$iToc++){
  405. if($Fetch_Toc[$iToc]["level"]<=$Fetch_Toc[0]["level"]){
  406. break;
  407. }
  408. $level=$Fetch_Toc[$iToc]["level"];
  409. $toc_paragraph=$Fetch_Toc[$iToc]["paragraph"];
  410. $toc_title=$Fetch_Toc[$iToc]["text"];
  411. $info_link="index_render_res_list($book,$album,$toc_paragraph)";
  412. echo "<li onclick='$info_link' >";
  413. echo "<span>{$toc_title}</span>";
  414. echo "<div><span class='author_name'>2</span><span class='ui-icon-carat-r ui-icon' style='display:inline-block;'></span></span>";
  415. echo "</li>";
  416. }
  417. echo "</ul>";
  418. }
  419. }
  420. //目录结束
  421. }
  422. }
  423. }
  424. ?>