album.php 9.4 KB

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