setting.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <?php
  2. require 'checklogin.inc';
  3. require '../public/config.php';
  4. require "../public/_pdo.php";
  5. if(isset($_GET["language"])){$currLanguage=$_GET["language"];}
  6. else{$currLanguage="en";}
  7. if(isset($_GET["device"])){$currDevice=$_GET["device"];}
  8. else{$currDevice="computer";}
  9. $menu_active["general"] = "";
  10. $menu_active["local"] = "";
  11. $menu_active["studio"] = "";
  12. $menu_active["liberay"] = "";
  13. $menu_active["dictionary"] = "";
  14. $menu_active["userdict"] = "";
  15. $menu_active["term"] = "";
  16. $menu_active["message"] = "";
  17. $menu_active["album"] = "";
  18. $menu_active["account"] = "";
  19. if(isset($_GET["item"])){
  20. $currSettingItem=$_GET["item"];
  21. $menu_active[$currSettingItem] = " class='act'";
  22. }
  23. else{
  24. $currSettingItem="home";
  25. }
  26. $album_power["15"]="超级管理员";
  27. $album_power["1"]="管理员";
  28. $album_power["2"]="编辑";
  29. ?>
  30. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  31. <html>
  32. <head>
  33. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  34. <link type="text/css" rel="stylesheet" href="css/main.css"/>
  35. <link type="text/css" rel="stylesheet" href="css/setting.css"/>
  36. <title>PCD Studio</title>
  37. <script src="../public/js/jquery.min.js"></script>
  38. <script type="text/javascript">
  39. $(document).ready(function(){
  40. $(".flip").click(function(){
  41. $(this).next().slideToggle("slow");
  42. });
  43. });
  44. </script>
  45. </head>
  46. <body class="mainbody" id="mbody">
  47. <div class="main">
  48. <!-- content begin-->
  49. <div id="leftmenuinner">
  50. <div class="toolgroup1">
  51. </div>
  52. <div >
  53. <h1>Setting</h1>
  54. </div>
  55. <div class='toc' id='leftmenuinnerinner'>
  56. <ul class="setting_item">
  57. <li <?php echo $menu_active["general"];?>><a href="setting.php?item=general">General</a></li>
  58. <li <?php echo $menu_active["local"];?>><a href="setting.php?item=local">Local</a></li>
  59. <li <?php echo $menu_active["studio"];?>><a href="setting.php?item=studio">Studio</a></li>
  60. <li <?php echo $menu_active["liberay"];?>><a href="setting.php?item=liberay">Liberay</a></li>
  61. <li <?php echo $menu_active["dictionary"];?>><a href="setting.php?item=dictionary">Dictionary</a></li>
  62. <li <?php echo $menu_active["userdict"];?>><a href="setting.php?item=userdict">User Dictionary</a></li>
  63. <li <?php echo $menu_active["term"];?>><a href="setting.php?item=term">Term</a></li>
  64. <li <?php echo $menu_active["message"];?>><a href="setting.php?item=message">Message</a></li>
  65. <li <?php echo $menu_active["album"];?>><a href="setting.php?item=album">Album</a></li>
  66. <li <?php echo $menu_active["account"];?>><a href="setting.php?item=account">Accont</a></li>
  67. <li><a href="../admin/setting.php?item=account">Web Admin</a></li>
  68. </ul>
  69. </div>
  70. </div>
  71. <div id="setting_main_view" class="mainview">
  72. <div class="tool_bar">
  73. <div >
  74. <?php
  75. switch($currSettingItem){
  76. case "account":
  77. break;
  78. case "album":
  79. if(isset($_GET["id"])){
  80. echo "<a href='setting.php?item=album'>返回</a>";
  81. }
  82. break;
  83. }
  84. ?>
  85. </div>
  86. <div>
  87. <span>Language</span>
  88. <select id="id_language" name="menu" >
  89. <option value="en" >English</option>
  90. <option value="si" >සින‍්හල</option>
  91. <option value="zh-cn" >简体中文</option>
  92. <option value="zh-tw" >正體中文</option>
  93. </select>
  94. </div>
  95. </div>
  96. <?php
  97. switch($currSettingItem){
  98. case "dictionary":
  99. PDO_Connect("sqlite:../".FILE_DB_REF);
  100. $query = "select * from info where 1";
  101. $all = PDO_FetchAll($query);
  102. echo "<h2>参考字典 Refrence Dictionary</h2>";
  103. echo "<table>";
  104. echo "<th>选择</th><th>名称</th><th>语言</th><th>简介</th><th>下载</th><th></th>";
  105. foreach($all as $dict){
  106. echo "<tr>";
  107. echo "<td><input type='checkbox' checked /></td><td>{$dict["shortname"]}</td><td>{$dict["language"]}</td><td>{$dict["name"]}</td><td><button>下载</button></td><td><a>管理</a></td>";
  108. echo "</tr>";
  109. }
  110. echo "</table>";
  111. echo "<h2>系统字典System Dictionary</h2>";
  112. break;
  113. case "local":
  114. //语言文件
  115. if(isset($_GET["lang"])){
  116. $_local=json_decode(file_get_contents("../public/lang/{$_GET["lang"]}.json"));
  117. }
  118. else{
  119. $_local=json_decode(file_get_contents("../public/lang/default.json"));
  120. }
  121. echo $_local->gui->pcd_studio;
  122. echo "<button>保存</button>";
  123. foreach($_local as $x=>$value){
  124. echo "<div>";
  125. $counter=count($value);
  126. echo "<div class='flip'>{$x}({$counter})</div>";
  127. echo "<div class='panel' style='display:none;'>";
  128. if(is_object($value)){
  129. $counter=1;
  130. echo "<table>";
  131. foreach($value as $row=>$row_value){
  132. echo "<tr>";
  133. echo "<td>$counter</td>";
  134. echo "<td>{$row}</td>";
  135. echo "<td><input type='input' value='{$row_value}' /></td>";
  136. echo "</tr>";
  137. $counter++;
  138. }
  139. echo "</table>";
  140. echo "<button>增加</button>";
  141. }
  142. else if(is_array($value)){
  143. $counter=1;
  144. echo "<table>";
  145. foreach($value as $row){
  146. if(is_object($row)){
  147. echo "<tr>";
  148. echo "<td>$counter</td>";
  149. echo "<td style=\"text-align:right;\">{$row->id}</td>";
  150. echo "<td><input type='input' value='{$row->value}' /></td>";
  151. echo "</tr>";
  152. }
  153. else{
  154. echo "unkow<br>";
  155. }
  156. $counter++;
  157. }
  158. echo "</table>";
  159. echo "<button>增加</button>";
  160. }
  161. else{
  162. echo "unkow type";
  163. }
  164. echo "</div>";
  165. echo "</div>";
  166. }
  167. break;
  168. case "userdict"://用户字典管理
  169. if(isset($_GET["page"])){
  170. $iCurrPage=$_GET["page"];
  171. }
  172. else{
  173. $iCurrPage=0;
  174. }
  175. $iOnePage=300;
  176. $db_file = $_file_db_wbw;
  177. PDO_Connect("sqlite:$db_file");
  178. $query = "select count(word_index) as co from user_index where user_id={$UID}";
  179. $allWord = PDO_FetchOne($query);
  180. $iCountWords=$allWord;
  181. if($iCountWords==0){
  182. echo "<div id='setting_user_dict_count'>您的用户字典中没有单词。</div>";
  183. }
  184. else{
  185. echo "<div>search:<input type='input' /></div>";
  186. $iPages=ceil($iCountWords/$iOnePage);
  187. if($iCurrPage>$iPages){
  188. $iCurrPage=$iPages;
  189. }
  190. $begin=$iCurrPage*$iOnePage;
  191. $query = "select word_index from user_index where user_id={$UID} order by id DESC limit {$begin},{$iOnePage} ";
  192. $allWord = PDO_FetchAll($query);
  193. $strQuery="('";
  194. foreach($allWord as $one){
  195. $strQuery .= $one["word_index"]."','";
  196. }
  197. $strQuery = substr($strQuery,0,strlen($strQuery)-2);
  198. $strQuery .= ")";
  199. $query = "select * from dict where id in {$strQuery} order by time DESC";
  200. $allWords = PDO_FetchAll($query);
  201. ?>
  202. <div id="setting_user_dict_nav" style="backgroud-color:gray">
  203. <?php
  204. if($iCurrPage==0){
  205. echo "第一页 | ";
  206. echo "上一页";
  207. }
  208. else{
  209. echo "<a href=\"setting.php?item=userdict&page=0\">第一页</a>";
  210. $prevPage=$iCurrPage-1;
  211. echo "<a href=\"setting.php?item=userdict&page={$prevPage}\">上一页</a>";
  212. }
  213. echo "第<input type=\"input\" value=\"".($iCurrPage+1)."\" size=\"4\" />页";
  214. echo "共{$iPages}页";
  215. if($iCurrPage<$iPages-1){
  216. echo "<a href=\"setting.php?item=userdict&page=".($iCurrPage+1)."\">下一页</a>";
  217. echo "<a href=\"setting.php?item=userdict&page=".($iPages-1)."\">最后一页</a>";
  218. }
  219. else{
  220. echo "下一页 | 最后一页";
  221. }
  222. echo "<span id='setting_user_dict_count'>总计{$iCountWords}</span>";
  223. ?>
  224. Type=
  225. <select>
  226. <option>n.</option>
  227. <option>adj.</option>
  228. </select>
  229. <button>导入</button><button>导出</button><button>新建</button>
  230. </div>
  231. <table>
  232. <tr>
  233. <th><input type="checkbox" /></th><th>拼写</th><th>类型</th><th>语法</th><th>意思</th><th>语基</th><th>状态</th><th>引用</th><th></th>
  234. </tr>
  235. <?php
  236. foreach($allWords as $word){
  237. echo "<tr>";
  238. echo "<td><input type=\"checkbox\" /></td>";
  239. echo "<td>{$word["pali"]}</td>";
  240. echo "<td>{$word["type"]}</td>";
  241. echo "<td>{$word["gramma"]}</td>";
  242. echo "<td>{$word["mean"]}</td>";
  243. echo "<td>{$word["parent"]}</td>";
  244. if($word["creator"]==$UID){
  245. echo "<td>原创</td>";
  246. }
  247. else{
  248. echo "<td>引用</td>";
  249. }
  250. echo "<td>{$word["ref_counter"]}</td>";
  251. echo "<td>...</td>";
  252. echo "</tr>";
  253. }
  254. ?>
  255. </table>
  256. <?php
  257. }
  258. break;
  259. case "term":
  260. if(isset($_GET["page"])){
  261. $iCurrPage=$_GET["page"];
  262. }
  263. else{
  264. $iCurrPage=0;
  265. }
  266. $iOnePage=300;
  267. $dictFileName=$dir_dict_term."dhammaterm.db";
  268. PDO_Connect("sqlite:$dictFileName");
  269. $query = "select count(*) as co from term where owner= ".$PDO->quote($USER_NAME);
  270. echo $query;
  271. $allWord = PDO_FetchOne($query);
  272. $iCountWords=$allWord;
  273. if($iCountWords==0){
  274. echo "<div id='setting_user_dict_count'>您的术语字典中没有单词。</div>";
  275. }
  276. else{
  277. echo "<div id='setting_user_dict_count'>您的术语字典中已经有{$iCountWords}个单词。</div>";
  278. $iPages=ceil($iCountWords/$iOnePage);
  279. if($iCurrPage>$iPages){
  280. $iCurrPage=$iPages;
  281. }
  282. $begin=$iCurrPage*$iOnePage;
  283. $query = "select * from term where owner= ".$PDO->quote($USER_NAME);
  284. $allWords = PDO_FetchAll($query);
  285. ?>
  286. <div id="setting_user_dict_nav">
  287. <?php
  288. if($iCurrPage==0){
  289. echo "第一页 | ";
  290. echo "上一页";
  291. }
  292. else{
  293. echo "<a href=\"setting.php?item=term&page=0\">第一页</a>";
  294. $prevPage=$iCurrPage-1;
  295. echo "<a href=\"setting.php?item=term&page={$prevPage}\">上一页</a>";
  296. }
  297. echo "第<input type=\"input\" value=\"".($iCurrPage+1)."\" size=\"4\" />页";
  298. echo "共{$iPages}页";
  299. if($iCurrPage<$iPages-1){
  300. echo "<a href=\"setting.php?item=term&page=".($iCurrPage+1)."\">下一页</a>";
  301. echo "<a href=\"setting.php?item=term&page=".($iPages-1)."\">最后一页</a>";
  302. }
  303. else{
  304. echo "下一页 | 最后一页";
  305. }
  306. ?>
  307. </div>
  308. <table>
  309. <tr>
  310. <th>序号</th><th>拼写</th><th>意思</th><th>第二个意思</th><th>注解</th><th>引用</th>
  311. </tr>
  312. <?php
  313. foreach($allWords as $word){
  314. echo "<tr>";
  315. echo "<td>{$word["id"]}</td>";
  316. echo "<td>{$word["word"]}</td>";
  317. echo "<td>{$word["meaning"]}</td>";
  318. echo "<td>{$word["other_meaning"]}</td>";
  319. echo "<td><textarea>{$word["note"]}</textarea></td>";
  320. echo "<td></td>";
  321. echo "</tr>";
  322. }
  323. ?>
  324. </table>
  325. <?php
  326. }
  327. break;
  328. case "account":
  329. echo "<h2>Accont</h2>";
  330. echo "User Name:$username<br />";
  331. echo "Nick Name:$nickname<br />";
  332. echo "User ID:$userid<br />";
  333. echo "Email:$email<br />";
  334. echo "<a href='login.php?op=logout'>Logout</a>";
  335. break;
  336. case "album":
  337. $db_file = $dir_palicanon.'res.db3';
  338. PDO_Connect("sqlite:$db_file");
  339. if(isset($_GET["id"])){
  340. if(isset($_GET["power"])){
  341. /*权限管理*/
  342. $query = "select * from 'album' where id='{$_GET["id"]}'";
  343. $album_info = PDO_FetchAll($query);
  344. if(count($album_info)>0){
  345. $query = "select * from 'album_power' where album_id='{$album_info[0]["id"]}'";
  346. $Fetch = PDO_FetchAll($query);
  347. echo "<h2>专辑权限管理</h2>";
  348. echo "<div>{$album_info[0]["title"]}-{$album_info[0]["author"]}</div>";
  349. echo "<form>";
  350. ?>
  351. <table>
  352. <tr>
  353. <th>序号</th><th>用户</th><th>密码</th><th>权限</th><th></th><th></th>
  354. </tr>
  355. <?php
  356. $sn=1;
  357. foreach($Fetch as $oneline){
  358. echo "<tr>
  359. <td>{$sn}</td>
  360. <td>{$oneline["user_id"]}</td>
  361. <td><input type='input' value='{$oneline["password"]}' /></td>
  362. <td>
  363. <select>";
  364. foreach($album_power as $x=>$value){
  365. if($oneline["power"]==$x){
  366. $select="selected";
  367. }
  368. else{
  369. $select="";
  370. }
  371. echo "<option value='{$x}' {$select}>{$value}</option>\r\n";
  372. }
  373. echo "</select>
  374. </td>
  375. <td><button>修改</button></td>
  376. <td><button>删除</button></td>
  377. </tr>";
  378. $sn++;
  379. }
  380. echo "<input type='submit' />";
  381. echo "</form>";
  382. }
  383. }
  384. else{
  385. $query = "select * from 'album' where id='{$_GET["id"]}'";
  386. $Fetch = PDO_FetchAll($query);
  387. if(count($Fetch)>0){
  388. echo "<h2>{$Fetch[0]["title"]}</h2>";
  389. echo "<form>";
  390. foreach($Fetch[0] as $x=>$value){
  391. echo "<div><span>{$x}</span><span><input type='input' value='{$value}' /></span></div>";
  392. }
  393. echo "<input type='submit' />";
  394. echo "</form>";
  395. }
  396. }
  397. }
  398. else{
  399. echo "<h2>My Album</h2>";
  400. $query = "select * from 'album' where owner='{$UID}'";
  401. $Fetch = PDO_FetchAll($query);
  402. ?>
  403. <table>
  404. <tr>
  405. <th>Book</th><th>Title</th><th>Author</th><th>语言</th><th>媒体</th><th></th><th></th>
  406. </tr>
  407. <?php
  408. foreach($Fetch as $album){
  409. echo "<tr><td>{$album["book"]}</td>
  410. <td>{$album["title"]}</td>
  411. <td>{$album["author"]}</td>
  412. <td>{$album["language"]}</td>
  413. <td>{$album["type"]}</td>
  414. <td><a href=\"album.php?op=show_info&album_id={$album["id"]}\" target='_blank'>详情</a></td>
  415. <td><a href=\"album.php?op=export&album_id={$album["id"]}\" target='_blank'>导出</a></td>
  416. </tr>";
  417. }
  418. echo "</table>";
  419. }
  420. break;
  421. }
  422. ?>
  423. </div>
  424. </div>
  425. </body>
  426. </html>