setting.php 13 KB

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