album.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <?php
  2. require 'checklogin.inc';
  3. require '../config.php';
  4. require "../public/_pdo.php";
  5. require "./public.inc";
  6. $type["pali"] = 1;
  7. $type["wbw"] = 2;
  8. $type["translate"] = 3;
  9. $type["note"] = 4;
  10. $type["dighest"] = 5;
  11. $type["templet"] = 6;
  12. $type["heading"] = 7;
  13. $iType["1"] = "pali";
  14. $iType["2"] = "wbw";
  15. $iType["3"] = "translate";
  16. $iType["4"] = "note";
  17. $iType["5"] = "dighest";
  18. $iType["6"] = "templet";
  19. $iType["7"] = "heading";
  20. $_lang["1"] = "pali";
  21. $_lang["2"] = "en";
  22. $_lang["3"] = "sc";
  23. $_lang["4"] = "tc";
  24. $_slang["pali"] = "1";
  25. $_slang["en"] = "2";
  26. $_slang["sc"] = "3";
  27. $_slang["tc"] = "4";
  28. $album_power["15"] = "超级管理员";
  29. $album_power["1"] = "管理员";
  30. $album_power["2"] = "编辑";
  31. if (isset($_GET["op"])) {
  32. $op = $_GET["op"];
  33. }
  34. if (isset($_GET["book"])) {
  35. $book = $_GET["book"];
  36. }
  37. if (isset($_GET["type"])) {
  38. $album_type = $_GET["type"];
  39. }
  40. switch ($op) {
  41. case "show_info":
  42. $db_file = _FILE_DB_RESRES_INDEX_;
  43. PDO_Connect("$db_file");
  44. $album_id = $_GET["album_id"];
  45. $query = "select * from 'album' where id='{$album_id}'";
  46. $Fetch = PDO_FetchAll($query);
  47. if (count($Fetch) > 0) {
  48. $sFileName = $Fetch[0]["file"];
  49. $book = $Fetch[0]["book"];
  50. $type = $Fetch[0]["type"];
  51. $thisFileName = basename(__FILE__);
  52. ?>
  53. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  54. <html>
  55. <head>
  56. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  57. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  58. <link type="text/css" rel="stylesheet" href="css/style.css"/>
  59. <link type="text/css" rel="stylesheet" href="css/color_day.css" id="colorchange" />
  60. <link type="text/css" rel="stylesheet" href="css/style_mobile.css" media="screen and (max-width:800px)">
  61. </head>
  62. <body class="indexbody">
  63. <br/><br/>
  64. <div class='fun_block' >
  65. <h2><?php echo $Fetch[0]["title"]; ?></h2>
  66. <form action=\"{$thisFileName}\" method=\"get\">
  67. <input type='hidden' name='op' value='update' />
  68. <input type='hidden' name='album_id' value='<?php echo $album_id; ?>'/>
  69. <table>
  70. <tr>
  71. <td>Type</td><td><?php echo $iType["{$type}"]; ?></td>
  72. </tr>
  73. <tr>
  74. <td>Title</td><td><input type='input' name='title' value='<?php echo $Fetch[0]["title"]; ?>'/></td>
  75. </tr>
  76. <tr>
  77. <td>Book</td><td><?php echo $book; ?></td>
  78. </tr>
  79. <tr>
  80. <td>Author</td><td><input type='input' name='title' value='<?php echo $Fetch[0]["author"]; ?>'/></td>
  81. </tr>
  82. <tr>
  83. <td>Edition</td><td><input type='input' name='title' value='<?php echo $Fetch[0]["edition"]; ?>'/></td>
  84. </tr>
  85. <tr>
  86. <td>Create</td><td><?php echo date("Y-m-d h:i:sa", $Fetch[0]["create_time"]); ?></td>
  87. </tr>
  88. <tr>
  89. <td>Uptate</td><td><?php echo date("Y-m-d h:i:sa", $Fetch[0]["update_time"]); ?></td>
  90. </tr>
  91. <tr>
  92. <td>Cover</td><td><input type="file" name="cover" id="file" /></td>
  93. </tr>
  94. <tr>
  95. <td>Language</td>
  96. <td>
  97. <select name="lang" >
  98. <option value="en">English</option>
  99. <option value="sc">简体中文</option>
  100. <option value="tc">正体中文</option>
  101. </select>
  102. </td>
  103. </tr>
  104. <tr>
  105. <td><input type="submit" value='Update'></td><td></td>
  106. </tr>
  107. </table>
  108. </form>
  109. </div>
  110. <div class='fun_block' >
  111. <h2>授权</h2>
  112. <?php
  113. /*权限管理*/
  114. $query = "select * from 'album' where id='{$_GET["album_id"]}'";
  115. $album_info = PDO_FetchAll($query);
  116. if (count($album_info) > 0) {
  117. $query = "select * from 'album_power' where album_id='{$album_info[0]["id"]}'";
  118. $Fetch = PDO_FetchAll($query);
  119. ?>
  120. <form>
  121. <table>
  122. <tr>
  123. <th>序号</th><th>用户</th><th>密码</th><th>权限</th><th></th><th></th>
  124. </tr>
  125. <?php
  126. $sn = 1;
  127. foreach ($Fetch as $oneline) {
  128. echo "<tr>
  129. <td>{$sn}</td>
  130. <td>{$oneline["user_id"]}</td>
  131. <td><input type='input' value='{$oneline["password"]}' /></td>
  132. <td>
  133. <select>";
  134. foreach ($album_power as $x => $value) {
  135. if ($oneline["power"] == $x) {
  136. $select = "selected";
  137. } else {
  138. $select = "";
  139. }
  140. echo "<option value='{$x}' {$select}>{$value}</option>\r\n";
  141. }
  142. echo "</select>
  143. </td>
  144. <td><button>修改</button></td>
  145. <td><button>删除</button></td>
  146. </tr>";
  147. $sn++;
  148. }
  149. echo "</table>";
  150. echo "<input type='submit' value='update'/>";
  151. echo "</form>";
  152. }
  153. ?>
  154. </div>
  155. <div class='fun_block' >
  156. <h2>章节</h2>
  157. <div>
  158. <?php
  159. PDO_Connect("$sFileName");
  160. $table = "p{$book}_{$iType["{$type}"]}_info";
  161. $query = "SELECT level,title,paragraph FROM '{$table}' WHERE album_id=$album_id and level>0 and level<9";
  162. //查询章节标题文内容
  163. $FetchText = PDO_FetchAll($query);
  164. $iFetchText = count($FetchText);
  165. if ($iFetchText > 0) {
  166. echo "<ul>";
  167. for ($i = 0; $i < $iFetchText; $i++) {
  168. $read_link = ""; //"../reader/?book={$book}&album={$album_id}&paragraph={$FetchText[$i]["paragraph"]}";
  169. echo "<li class='palicannon_nav_level_{$FetchText[$i]["level"]}'><a href='{$read_link}' target='_blank'>{$FetchText[$i]["title"]}</a></li>";
  170. }
  171. echo "</ul>";
  172. }
  173. ?>
  174. </div>
  175. </div>
  176. </body>
  177. </html>
  178. <?php
  179. }
  180. break;
  181. case "update":
  182. break;
  183. case "new_form":
  184. ?>
  185. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  186. <html>
  187. <head>
  188. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  189. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  190. <link type="text/css" rel="stylesheet" href="css/style.css"/>
  191. <link type="text/css" rel="stylesheet" href="css/color_day.css" id="colorchange" />
  192. <link type="text/css" rel="stylesheet" href="css/style_mobile.css" media="screen and (max-width:800px)">
  193. </head>
  194. <body class="indexbody">
  195. <br/><br/>
  196. <div class='fun_block' >
  197. <h2><?php echo $Fetch[0]["title"]; ?></h2>
  198. <form action=\"{$thisFileName}\" method=\"get\">
  199. <input type='hidden' name='op' value='new' />
  200. <input type='hidden' name='album_id' value='<?php echo $album_id; ?>'/>
  201. <table>
  202. <tr>
  203. <td>Type</td><td><?php echo $iType["{$type}"]; ?></td>
  204. </tr>
  205. <tr>
  206. <td>Title</td><td><input type='input' name='title' value='<?php echo $Fetch[0]["title"]; ?>'/></td>
  207. </tr>
  208. <tr>
  209. <td>Book</td><td><?php echo $book; ?></td>
  210. </tr>
  211. <tr>
  212. <td>Author</td><td><input type='input' name='title' value='<?php echo $Fetch[0]["author"]; ?>'/></td>
  213. </tr>
  214. <tr>
  215. <td>Edition</td><td><input type='input' name='title' value='<?php echo $Fetch[0]["edition"]; ?>'/></td>
  216. </tr>
  217. <tr>
  218. <td>Create</td><td><?php echo date("Y-m-d h:i:sa", time()); ?></td>
  219. </tr>
  220. <tr>
  221. <td>Uptate</td><td><?php echo date("Y-m-d h:i:sa", time()); ?></td>
  222. </tr>
  223. <tr>
  224. <td>Cover</td><td><input type="file" name="cover" id="file" /></td>
  225. </tr>
  226. <tr>
  227. <td>Language</td>
  228. <td>
  229. <select name="lang" >
  230. <option value="en">English</option>
  231. <option value="sc">简体中文</option>
  232. <option value="tc">正体中文</option>
  233. </select>
  234. </td>
  235. </tr>
  236. <tr>
  237. <td><input type="submit" value='Create'></td><td></td>
  238. </tr>
  239. </table>
  240. </form>
  241. </div>
  242. </body>
  243. </html>
  244. <?php
  245. break;
  246. case "new":
  247. $db_file = _FILE_DB_RESRES_INDEX_;
  248. PDO_Connect("$db_file");
  249. $album_guid = $_GET["album_guid"];
  250. $album_type = $_GET["album_type"];
  251. $book = $_GET["book"];
  252. $lang = $_GET["lang"];
  253. $tag = $_GET["tag"];
  254. $summary = $_GET["summary"];
  255. $author = $_GET["author"];
  256. $edition = $_GET["edition"];
  257. $title = $_GET["title"];
  258. $dbFileName = _DIR_PALICANON_ . "/" . $album_type . "/p" . $book . "_" . $album_type . ".db3";
  259. $PDO->beginTransaction();
  260. $query = "INSERT INTO album (id,
  261. book,
  262. guid,
  263. title,
  264. file,
  265. cover,
  266. language,
  267. author,
  268. tag,
  269. summary,
  270. create_time,
  271. update_time,
  272. version,
  273. edition,
  274. type,
  275. owner) VALUES
  276. (NULL,
  277. '{$book}',
  278. '{$album_guid}',
  279. '{$title}',
  280. '{$dbFileName}',
  281. '',
  282. '{$_slang[$lang]}',
  283. '{$author}',
  284. '{$tag}',
  285. '{$summary}',
  286. " . time() . ",
  287. " . time() . ",
  288. '1',
  289. '{$edition}',
  290. '{$type[$album_type]}',
  291. '{$UID}')";
  292. $stmt = @PDO_Execute($query);
  293. $PDO->commit();
  294. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  295. $error = PDO_ErrorInfo();
  296. echo "error - $error[2]";
  297. } else {
  298. //获取刚刚插入的索引号
  299. $album_index = $PDO->lastInsertId();
  300. echo $album_index;
  301. }
  302. break;
  303. case "get":
  304. $db_file = _FILE_DB_RESRES_INDEX_;
  305. PDO_Connect("$db_file");
  306. $query = "select * from 'album' where book='{$book}' and type='{$type[$album_type]}' and owner='{$UID}'";
  307. $Fetch = PDO_FetchAll($query);
  308. echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
  309. break;
  310. case "get_album":
  311. if (isset($_GET["album_id"])) {
  312. $album_id = $_GET["album_id"];
  313. }
  314. if (isset($_GET["book"])) {
  315. $book = $_GET["book"];
  316. }
  317. if (isset($_GET["type"])) {
  318. $album_type = $_GET["type"];
  319. }
  320. $db_file = _FILE_DB_RESRES_INDEX_;
  321. PDO_Connect("$db_file");
  322. $query = "select * from 'album' where id='{$album_id}'";
  323. $Fetch = PDO_FetchAll($query);
  324. $result = array();
  325. if (count($Fetch) > 0) { //找到专辑
  326. $result = array_merge($result, $Fetch);
  327. }
  328. //找本人相关专辑
  329. $query = "select * from 'album' where id!='{$album_id}' and book='{$book}' and type='{$type[$album_type]}' and owner='{$UID}'";
  330. $Fetch = PDO_FetchAll($query);
  331. $result = array_merge($result, $Fetch);
  332. echo json_encode($result, JSON_UNESCAPED_UNICODE);
  333. break;
  334. }
  335. ?>