home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / oss / cvs-2004 / bahasa / web / editor.php,v < prev    next >
Text File  |  2003-10-20  |  11KB  |  503 lines

  1. head    1.8;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @# @;
  6.  
  7.  
  8. 1.8
  9. date    2003.10.20.00.21.45;    author bule;    state Exp;
  10. branches;
  11. next    1.7;
  12.  
  13. 1.7
  14. date    2003.10.18.00.33.41;    author bule;    state Exp;
  15. branches;
  16. next    1.6;
  17.  
  18. 1.6
  19. date    2003.10.06.00.39.26;    author bule;    state Exp;
  20. branches;
  21. next    1.5;
  22.  
  23. 1.5
  24. date    2003.10.01.06.51.29;    author bule;    state Exp;
  25. branches;
  26. next    1.4;
  27.  
  28. 1.4
  29. date    2003.09.04.07.26.59;    author bule;    state Exp;
  30. branches;
  31. next    1.3;
  32.  
  33. 1.3
  34. date    2003.09.03.07.11.10;    author bule;    state Exp;
  35. branches;
  36. next    1.2;
  37.  
  38. 1.2
  39. date    2003.09.02.07.07.24;    author bule;    state Exp;
  40. branches;
  41. next    1.1;
  42.  
  43. 1.1
  44. date    2003.08.31.18.48.47;    author bule;    state Exp;
  45. branches;
  46. next    ;
  47.  
  48.  
  49. desc
  50. @@
  51.  
  52.  
  53. 1.8
  54. log
  55. @*** empty log message ***
  56. @
  57. text
  58. @<?
  59. session_start();
  60. require_once("../php/Indonesia.php");
  61. require_once("../php/Web.php");
  62. //////////////////////////////////////////////////////////////////////////////
  63. //////////////////////////////////////////////////////////////////////////////
  64. // Project Name: Bahasa Indonesia Dictionary
  65. // Directory:    bahasa/web
  66. // File Name:    edit.php
  67. // Author(s):    John L. Whiteman
  68. // Created:      August 31, 2003  
  69. // Modified:     October 19, 2003
  70. // Description:  The purpose of this restricted access PHP web 
  71. //               client page is to act like a front end to 
  72. //               the delete.php, update.php, and insert.php pages.
  73. //               It allows an an administrator to type 
  74. //               in a word then if the word exists ask them if they 
  75. //               want to delete or update the word.  If the word 
  76. //               does not exist then it asks them if they want to
  77. //               add the word.  Redirection is made to the applicable
  78. //               PHP page. 
  79. // 
  80. // Copyright (c) 2003 John L. Whiteman
  81. //
  82. // Permission is herby granted, free of charge, to any person obtaining a 
  83. // copy of this software, data, and associated documentation files 
  84. // (the "Software"), to deal in the Software without restriction, 
  85. // including without limitation the rights to use, copy, modify, merge, 
  86. // publish, distribute, sublicense, and/or sell copies of Software, and to
  87. // permit persons to whom the Software is furnished to do so, subject to 
  88. // the following conditions:
  89. //
  90. // The above copyright notice and this permission notice shall be 
  91. // included in all copies or substantial portions of the Software.
  92. //
  93. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  94. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  95. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  96. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  97. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  98. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  99. //////////////////////////////////////////////////////////////////////////////
  100. //////////////////////////////////////////////////////////////////////////////
  101.  
  102. $web = new Web();
  103.  
  104. if (!$_SESSION['ADMIN']) {
  105.  
  106.     $web->redirect("login.php");
  107.  
  108.     exit;
  109. }
  110.  
  111. $indonesia = new Indonesia();
  112.  
  113. $status = $indonesia->get_dictionary_status();
  114.  
  115. if ($status["status"] == 1 || $status["status"] == 2) {
  116.  
  117.     $web->redirect("admin.php");
  118.  
  119.     exit;
  120. }
  121.  
  122. ?>
  123. <html>
  124. <head>
  125. <title>Bahasa Indonesia Dictionary: Search Word(s)</title>
  126.  
  127. <link href="bahasa.css" rel="stylesheet" type="text/css">
  128.  
  129. <script type="text/javascript" src="bahasa.js"></script>
  130.  
  131. <script language="Javascript" type="text/javascript"> 
  132. <!--
  133. //////////////////////////////////////////////////////////////////////////////
  134. function verify_search() {
  135.  
  136.     stoken = document.search.stoken.value;
  137.  
  138.     stoken = trim(stoken);
  139.  
  140.     if (is_white_space(stoken)) {
  141.  
  142.         alert("You need to specify a search word value!");
  143.  
  144.         document.search.stoken.focus();
  145.  
  146.         return(false);
  147.     }    
  148.  
  149.     if (stoken.length > 255) {
  150.  
  151.         alert(
  152.         "You need to specify a search word 1 to 255 characters " + 
  153.         "in length!");  
  154.  
  155.         document.search.stoken.focus();
  156.  
  157.         return(false);
  158.     }
  159.  
  160.     return(true);
  161. }
  162. //////////////////////////////////////////////////////////////////////////////
  163. // -->
  164. </script>
  165. </head>
  166. <body>
  167. <?
  168. $web->show_logo("Search Word(s)");
  169. ?>
  170. <a href="admin.php">Administration</a>
  171.  
  172. <?
  173.  
  174. show_search_form($web, $indonesia);
  175.  
  176. if (isset($_POST['stoken'])) {
  177.  
  178.     search_all($web, $indonesia, $_POST['stoken']);
  179.  
  180. ?>
  181.  
  182. </body>
  183. </html>
  184.  
  185. <?
  186. ///////////////////////////////////////////////////////////////////////////////
  187. function search_all($web, $indonesia, $stoken) {
  188.  
  189.     $results = array();
  190.  
  191.     $stoken = $web->strip($stoken);
  192.  
  193.     if ($stoken == "") {
  194.  
  195.         print 
  196.         "<br><hr><b>You must specify a search value!" .
  197.         "</b><hr><br>\n" .
  198.         "<script language=\"Javascript\" type=\"text/javascript\">\n" . 
  199.         "document.search.stoken.focus();\n" .
  200.         "</script>\n"; 
  201.  
  202.         return;
  203.     }
  204.  
  205.     $errstr = $indonesia->search_all($results, $stoken);
  206.  
  207.     if ($errstr != "") {
  208.  
  209.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  210.  
  211.         return;
  212.     } 
  213.  
  214.     $total_results = count($results);
  215.  
  216.     print 
  217.     "<hr><b>Found ${total_results} " . 
  218.     "match(es) for search entry: '${stoken}'</b><hr>\n" .
  219.     "<form method=\"post\" action=\"insert.php\">\n ".
  220.     "<input type=\"submit\" " .
  221.     "value=\"Insert as New English Entry!\">\n" .
  222.     "<input type=\"hidden\" name=\"insert_new_entry\" " .
  223.     "value=\"${stoken}\">\n" .
  224.     "<input type=\"hidden\" name=\"language\" " .
  225.     "value=\"English\">\n" . 
  226.     "</form>\n" .
  227.     "<form method=\"post\" action=\"insert.php\">\n ".
  228.     "<input type=\"submit\" " .
  229.     "value=\"Insert as New Indonesian Entry!\">\n" .
  230.     "<input type=\"hidden\" name=\"insert_new_entry\" " .
  231.     "value=\"${stoken}\">\n" .
  232.     "<input type=\"hidden\" name=\"language\" " .
  233.     "value=\"Indonesian\">\n" . 
  234.     "</form>\n";
  235.  
  236.     if ($total_results == 0) {
  237.  
  238.         return;
  239.     }
  240.  
  241.     print 
  242.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\">\n";
  243.  
  244.     for($i = 0; $i < $total_results; $i++) {
  245.  
  246.         if ($i == 0) {
  247.  
  248.             print
  249.             "<tr>\n" .
  250.             "<th>PKEY</th>\n" .
  251.             "<th>Language</th>\n" .
  252.             "<th>English</th>\n" .
  253.             "<th>Indonesian</th>\n" .
  254.             "<th>Part of Speech</th>\n" .
  255.             "<th>Pronunciation</th>\n" .
  256.             "<th>IPA</th>\n" .
  257.             "<th>Comments</th>\n" .
  258.             "<th>Created</th>\n" .
  259.             "<th>Modified</th>\n" .
  260.             "<th>Action</th>\n" .
  261.             "</tr>\n";    
  262.         }
  263.  
  264.         $pkey = $web->tohtml($results[$i]["pkey"]);
  265.         $language = $web->tohtml($results[$i]["language"]);
  266.         $english = $web->tohtml($results[$i]["english"]);
  267.         $indonesian = $web->tohtml($results[$i]["indonesian"]);
  268.         $pos = $web->tohtml($results[$i]["pos"]);
  269.         $pronunciation = $web->tohtml($results[$i]["pronunciation"]);
  270.         $ipa = $web->tohtml($results[$i]["ipa"]);
  271.         $comments = $web->tohtml($results[$i]["comments"]);
  272.         $created = $web->tohtml($results[$i]["created"]);
  273.         $modified = $web->tohtml($results[$i]["modified"]);
  274.  
  275.         print 
  276.         "<tr>\n" .
  277.         "<td>${pkey} </td>\n" .
  278.         "<td>${language} </td>\n" .
  279.         "<td>${english} </td>\n" .
  280.         "<td>${indonesian} </td>\n" .
  281.         "<td>${pos} </td>\n" .
  282.         "<td>${pronunciation} </td>\n" .
  283.         "<td>${ipa} </td>\n" .
  284.         "<td>${comments} </td>\n" .
  285.         "<td>${created} </td>\n" .
  286.         "<td>${modified} </td>\n" .
  287.         "<td wrap>\n" .
  288.         "<form name=\"delete_entry\" method=\"post\" " .
  289.         "action=\"delete.php\">\n" .
  290.         "<input type=\"submit\" value=\"Delete!  \">\n" .
  291.         "<input type=\"hidden\" name=\"pkey\" " .
  292.         "value=\"${pkey}\">\n" .
  293.         "<input type=\"hidden\" name=\"editor\" " .
  294.         "value=\"1\">\n" .
  295.         "</form>\n" .
  296.         "<form name=\"update_entry\" method=\"post\" " .
  297.         "action=\"update.php\">\n" .
  298.         "<input type=\"submit\" value=\"Update!\">\n" .
  299.         "<input type=\"hidden\" name=\"pkey\" " .
  300.         "value=\"${pkey}\">\n" .
  301.         "<input type=\"hidden\" name=\"editor\" " .
  302.         "value=\"1\">\n" .
  303.         "</form>\n" .
  304.         "</td>\n" .
  305.         "</tr>\n";
  306.     } 
  307.     
  308.     print "</table>\n";
  309.  
  310.     return;
  311. }
  312. ///////////////////////////////////////////////////////////////////////////////
  313. function show_search_form($web, $indonesia) {
  314.  
  315.     print <<<EOFSSF
  316. <form name="search" method="post" onSubmit='return verify_search()'>
  317. <table cellpadding="3" cellspacing="3" border="0">
  318. <tr>
  319. <td>Enter search entry:</td>
  320. <td>
  321. <input type="text" name="stoken" maxlength="255" size="30">
  322. </td>
  323. </tr><tr>
  324. <td colspan="2" align="right">
  325. <input type="submit" value="Search Dictionary!">
  326. </td>
  327. </tr>
  328. </table>
  329. </form>
  330. <script language="Javascript" type="text/javascript"> 
  331. document.search.stoken.focus();
  332. </script>
  333. EOFSSF;
  334.  
  335.     return;
  336. }
  337. ///////////////////////////////////////////////////////////////////////////////
  338. ///////////////////////////////////////////////////////////////////////////////
  339. ?>
  340. @
  341.  
  342.  
  343. 1.7
  344. log
  345. @*** empty log message ***
  346. @
  347. text
  348. @d12 1
  349. a12 1
  350. // Modified:     October 17, 2003
  351. d69 2
  352. @
  353.  
  354.  
  355. 1.6
  356. log
  357. @*** empty log message ***
  358. @
  359. text
  360. @d12 1
  361. a12 1
  362. // Modified:     October 05, 2003
  363. d70 2
  364. d73 1
  365. a73 25
  366. //////////////////////////////////////////////////////////////////////////////
  367. function is_white_space(stoken) {
  368.  
  369.     if (stoken == null) return(true);
  370.  
  371.     if (stoken == '') return(true);
  372.  
  373.     if (stoken == "") return(true);
  374.  
  375.     return(false);
  376. }
  377. //////////////////////////////////////////////////////////////////////////////
  378. function trim(stoken) {
  379.  
  380.     if (is_white_space(stoken)) {
  381.  
  382.         return(stoken);
  383.     }
  384.  
  385.     stoken = stoken.replace(/^\s*/, "");
  386.  
  387.     stoken = stoken.replace(/\s*$/, "");
  388.  
  389.     return(stoken);
  390. }
  391. d104 1
  392. a104 1
  393. //////////////////////////////////////////////////////////////////////////////
  394. @
  395.  
  396.  
  397. 1.5
  398. log
  399. @*** empty log message ***
  400. @
  401. text
  402. @d12 1
  403. a12 1
  404. // Modified:     September 30, 2003
  405. d130 3
  406. a132 2
  407. <h2>Bahasa Indonesia Dictionary: Search Word(s)</h2>
  408.  
  409. @
  410.  
  411.  
  412. 1.4
  413. log
  414. @*** empty log message ***
  415. @
  416. text
  417. @d12 1
  418. a12 1
  419. // Modified:     September 03, 2003
  420. d47 1
  421. a47 1
  422. if (!session_is_registered("ADMIN")) {
  423. @
  424.  
  425.  
  426. 1.3
  427. log
  428. @*** empty log message ***
  429. @
  430. text
  431. @d12 1
  432. a12 1
  433. // Modified:     September 02, 2003
  434. a53 9
  435. if (session_is_registered("NODUP_UPDATE_ENTRY")) {
  436.  
  437.     session_unregister("NODUP_UPDATE_ENTRY");
  438.  
  439.     $web->redirect("admin.php");
  440.  
  441.     exit;    
  442. }
  443.  
  444. d180 2
  445. a181 1
  446.     "<hr><b>Found 0 matches for search entry: '${stoken}'</b><hr>\n" .
  447. @
  448.  
  449.  
  450. 1.2
  451. log
  452. @*** empty log message ***
  453. @
  454. text
  455. @d12 1
  456. a12 1
  457. // Modified:     September 01, 2003
  458. d77 1
  459. a77 1
  460. <title>Bahasa Indonesia Dictionary: Dictionary Editor</title>
  461. d139 1
  462. a139 1
  463. <h2>Bahasa Indonesia Dictionary: Dictionary Editor</h2>
  464. d189 1
  465. a189 1
  466.     "<hr><b>Found 0 matches for: '${stoken}'</b><hr>\n" .
  467. d192 1
  468. a192 1
  469.     "value=\"Insert as new English entry!\">\n" .
  470. d200 1
  471. a200 1
  472.     "value=\"Insert as new Indonesian entry!\">\n" .
  473. d231 1
  474. d258 18
  475. d290 1
  476. a290 1
  477. <td>Enter search word(s):</td>
  478. @
  479.  
  480.  
  481. 1.1
  482. log
  483. @*** empty log message ***
  484. @
  485. text
  486. @d12 1
  487. a12 1
  488. // Modified:     August 31, 2003
  489. d77 1
  490. a77 1
  491. <title>Bahasa Indonesia Dictionary: Editor</title>
  492. d105 31
  493. d139 1
  494. a139 1
  495. <h2>Bahasa Indonesia Dictionary: Editor</h2>
  496. a142 1
  497. <h3>This page is under construction!</h3>
  498. d144 8
  499. d158 133
  500. @
  501.  
  502.