setting.php 14 KB

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