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 / delete.php,v < prev    next >
Text File  |  2003-10-20  |  26KB  |  1,290 lines

  1. head    1.9;
  2. access;
  3. symbols
  4.     Initial:1.1.1.1 bule:1.1.1;
  5. locks; strict;
  6. comment    @# @;
  7.  
  8.  
  9. 1.9
  10. date    2003.10.20.00.21.45;    author bule;    state Exp;
  11. branches;
  12. next    1.8;
  13.  
  14. 1.8
  15. date    2003.10.18.00.33.41;    author bule;    state Exp;
  16. branches;
  17. next    1.7;
  18.  
  19. 1.7
  20. date    2003.10.06.00.39.26;    author bule;    state Exp;
  21. branches;
  22. next    1.6;
  23.  
  24. 1.6
  25. date    2003.10.01.06.51.29;    author bule;    state Exp;
  26. branches;
  27. next    1.5;
  28.  
  29. 1.5
  30. date    2003.09.04.07.26.59;    author bule;    state Exp;
  31. branches;
  32. next    1.4;
  33.  
  34. 1.4
  35. date    2003.09.03.07.11.10;    author bule;    state Exp;
  36. branches;
  37. next    1.3;
  38.  
  39. 1.3
  40. date    2003.09.02.07.07.24;    author bule;    state Exp;
  41. branches;
  42. next    1.2;
  43.  
  44. 1.2
  45. date    2003.08.19.06.42.07;    author bule;    state Exp;
  46. branches;
  47. next    1.1;
  48.  
  49. 1.1
  50. date    2003.08.12.19.18.23;    author bule;    state Exp;
  51. branches
  52.     1.1.1.1;
  53. next    ;
  54.  
  55. 1.1.1.1
  56. date    2003.08.12.19.18.23;    author bule;    state Exp;
  57. branches;
  58. next    ;
  59.  
  60.  
  61. desc
  62. @@
  63.  
  64.  
  65. 1.9
  66. log
  67. @*** empty log message ***
  68. @
  69. text
  70. @<?
  71. session_start();
  72. require_once("../php/Indonesia.php");
  73. require_once("../php/Web.php");
  74. //////////////////////////////////////////////////////////////////////////////
  75. //////////////////////////////////////////////////////////////////////////////
  76. // Project Name: Bahasa Indonesia Dictionary
  77. // Directory:    bahasa/web
  78. // File Name:    delete.php
  79. // Author(s):    John L. Whiteman
  80. // Created:      June 23, 2003  
  81. // Modified:     October 19, 2003
  82. // Description:  The purpose of this restricted access PHP web 
  83. //               client page is to allow deletion of an entry 
  84. //               in the dictionary table of the database. 
  85. // 
  86. // Copyright (c) 2003 John L. Whiteman
  87. //
  88. // Permission is herby granted, free of charge, to any person obtaining a 
  89. // copy of this software, data, and associated documentation files 
  90. // (the "Software"), to deal in the Software without restriction, 
  91. // including without limitation the rights to use, copy, modify, merge, 
  92. // publish, distribute, sublicense, and/or sell copies of Software, and to
  93. // permit persons to whom the Software is furnished to do so, subject to 
  94. // the following conditions:
  95. //
  96. // The above copyright notice and this permission notice shall be 
  97. // included in all copies or substantial portions of the Software.
  98. //
  99. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  100. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  101. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  102. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  103. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  104. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  105. //////////////////////////////////////////////////////////////////////////////
  106. //////////////////////////////////////////////////////////////////////////////
  107.  
  108. $web = new Web();
  109.  
  110. if (!$_SESSION['ADMIN']) {
  111.  
  112.     $web->redirect("login.php");
  113.  
  114.     exit;
  115. }
  116.  
  117. $indonesia = new Indonesia();
  118.  
  119. $status = $indonesia->get_dictionary_status();
  120.  
  121. if ($status["status"] == 1 || $status["status"] == 2) {
  122.  
  123.     $web->redirect("admin.php");
  124.  
  125.     exit;
  126. }
  127.  
  128. ?>
  129. <html>
  130. <head>
  131. <title>Bahasa Indonesia Dictionary: Delete Word(s)</title>
  132.  
  133. <link href="bahasa.css" rel="stylesheet" type="text/css">
  134.  
  135. <script type="text/javascript" src="bahasa.js"></script>
  136.  
  137. <script language="Javascript" type="text/javascript"> 
  138. <!--
  139. //////////////////////////////////////////////////////////////////////////////
  140. function verify_delete_all() {
  141.  
  142.     password = document.delete_all.password.value;
  143.  
  144.     if (is_white_space(password)) {
  145.  
  146.         alert("You must enter a password value!");
  147.  
  148.         document.delete_all.password.focus();
  149.  
  150.         return(false);
  151.     }
  152.  
  153.     return(true);
  154. }
  155. //////////////////////////////////////////////////////////////////////////////
  156. function verify_delete_selected() {
  157.  
  158.     password = document.delete_entries.password.value;
  159.  
  160.     if (is_white_space(password)) {
  161.  
  162.         alert("You must enter a password value!");
  163.  
  164.         document.delete_entries.password.focus();
  165.  
  166.         return(false);
  167.     }
  168.  
  169.     return(true);
  170. }
  171. //////////////////////////////////////////////////////////////////////////////
  172. function verify_search() {
  173.  
  174.     stoken = document.search.stoken.value;
  175.  
  176.     stoken = trim(stoken);
  177.  
  178.     if (is_white_space(stoken)) {
  179.  
  180.         alert("You need to specify a search word value!");
  181.  
  182.         document.search.stoken.focus();
  183.  
  184.         return(false);
  185.         }
  186.  
  187.     if (stoken.length > 255) {
  188.  
  189.         alert(
  190.         "You need to specify a search word 1 to 255 characters " +
  191.         "in length!");
  192.  
  193.         document.search.stoken.focus();
  194.  
  195.         return(false);
  196.     }
  197.  
  198.     return(true);
  199. }
  200. //////////////////////////////////////////////////////////////////////////////
  201. // -->
  202. </script>
  203. </head>
  204. <body>
  205. <?
  206. $web->show_logo("Delete Word(s)");
  207. ?>
  208.  
  209. <a href="admin.php">Administration</a>
  210. <br><br>
  211. <?
  212.  
  213. show_search_form($web, $indonesia);
  214.  
  215. if (isset($_POST['editor'])) {
  216.  
  217.     print 
  218.     "<form name=\"editor\" method=\"post\" action=\"editor.php\">\n" .
  219.     "<input type=\"submit\" value=\"Go Back to Search Dictionary!\">\n" .
  220.     "</form>\n"; 
  221. }
  222.  
  223. if (
  224. ($_SESSION['NODUP_DELETES']) &&
  225. (isset($_POST['id'])) &&
  226. (isset($_POST['delete_all'])) &&
  227. ($_SESSION['NODUP_DELETES'] == $_POST['id'])) {
  228.  
  229.         //Do nothing...prevents refresh duplication of last action
  230.  
  231. } else if (
  232. ($_SESSION['NODUP_DELETES']) &&
  233. (isset($_POST['id'])) &&
  234. (isset($_POST['delete_selected'])) &&
  235. ($_SESSION['NODUP_DELETES'] == $_POST['id'])) {
  236.  
  237.         //Do nothing...prevents refresh duplication of last action
  238.  
  239. } else if (
  240. (isset($_POST['editor'])) &&
  241. (isset($_POST['pkey']))) {
  242.  
  243.     search_pkey($web, $indonesia, $_POST['pkey']);
  244.  
  245. } else if (
  246. (isset($_POST['delete_selected'])) &&
  247. (isset($_POST['id'])) &&
  248. (isset($_POST['stokenx'])) &&
  249. (isset($_POST['password']))) {
  250.  
  251.     if (
  252.     (!$_SESSION['NODUP_DELETES'] ||
  253.     (($_SESSION['NODUP_DELETES']) &&
  254.     ($_SESSION['NODUP_DELETES'] != $_POST['id'])))) {
  255.  
  256.         if ($_SESSION['NODUP_DELETES']) {
  257.  
  258.             unset($_SESSION['NODUP_DELETES']);
  259.         }
  260.  
  261.         $errstr =
  262.         $indonesia->login($_SESSION['ADMIN'], $_POST['password']);
  263.     
  264.         if ($errstr != "") {
  265.  
  266.             print "<br><hr><b>Permission denied!</b><hr>\n";
  267.  
  268.         } else {
  269.  
  270.             $deleted_count = 0;
  271.  
  272.             $error_flag = 0;
  273.  
  274.             foreach($_POST as $name => $value) {
  275.  
  276.                 $name = $web->strip($name);
  277.  
  278.                 $value = $web->strip($value);
  279.  
  280.                 if ($value == "delete_entry") {
  281.  
  282.                     $errstr = 
  283.                     $indonesia->delete_entry($name);
  284.  
  285.                     if ($errstr != "") {
  286.             
  287.                         print 
  288.                         "<br><hr><b>" .
  289.                         "${errstr}</b><hr>\n";
  290.                         
  291.                         $error_flag = 1;
  292.  
  293.                         break;
  294.                     }
  295.  
  296.                     $deleted_count++;
  297.  
  298.                     if ($deleted_count == 1) {
  299.  
  300.                         $_SESSION['NODUP_DELETES'] =
  301.                             $_POST['id'];    
  302.                     } 
  303.                 }
  304.             }
  305.  
  306.             if ($error_flag == 0) {
  307.  
  308.                 if ($deleted_count == 0) {
  309.  
  310.                     print
  311.                     "<br><hr><b>" .
  312.                     "You need to select at least " .
  313.                     "one entry to delete!</b><hr><br>\n";
  314.  
  315.                     search_all(
  316.                     $web, $indonesia, $_POST['stokenx']);
  317.  
  318.                 } else if ($deleted_count == 1) {
  319.  
  320.                     print
  321.                     "<br><hr><b>" .
  322.                     "Successfully deleted " .
  323.                     "${deleted_count} " .
  324.                     "entry!</b><hr><br>\n";
  325.  
  326.                 } else {
  327.  
  328.                     print
  329.                     "<br><hr><b>" .
  330.                     "Successfully deleted " .
  331.                     "${deleted_count} " .
  332.                     "entries!</b><hr><br>\n";
  333.                 } 
  334.             }
  335.         }
  336.     }
  337.  
  338. } else if (
  339. (isset($_POST['delete_all'])) &&
  340. (isset($_POST['id'])) &&
  341. (isset($_POST['password']))) {
  342.  
  343.     if (
  344.     (!$_SESSION['NODUP_DELETES'] ||
  345.     (($_SESSION['NODUP_DELETES']) &&
  346.     ($_SESSION['NODUP_DELETES'] != $_POST['id'])))) {
  347.  
  348.         if ($_SESSION['NODUP_DELETES']) {
  349.  
  350.             unset($_SESSION['NODUP_DELETES']);
  351.         }
  352.  
  353.         $errstr =
  354.         $indonesia->login($_SESSION['ADMIN'], $_POST['password']);
  355.     
  356.         if ($errstr != "") {
  357.  
  358.             print "<br><hr><b>Permission denied!</b><hr>\n";
  359.  
  360.         } else {
  361.  
  362.             $deleted_count = 0;
  363.  
  364.             $error_flag = 0;
  365.  
  366.             foreach($_POST as $name => $value) {
  367.  
  368.                 $name = $web->strip($name);
  369.  
  370.                 $value = $web->strip($value);
  371.  
  372.                 if ($value == "delete_entry") {
  373.  
  374.                     $errstr = 
  375.                     $indonesia->delete_entry($name);
  376.  
  377.                     if ($errstr != "") {
  378.             
  379.                         print 
  380.                         "<br><hr><b>" .
  381.                         "${errstr}</b><hr>\n";
  382.                         
  383.                         $error_flag = 1;
  384.  
  385.                         break;
  386.                     }
  387.  
  388.                     $deleted_count++;
  389.  
  390.                     if ($deleted_count == 1) {
  391.  
  392.                         $_SESSION['NODUP_DELETES'] =
  393.                             $_POST['id'];
  394.                     } 
  395.                 }
  396.             }
  397.  
  398.             if ($error_flag == 0) {
  399.  
  400.                 if ($deleted_count == 1) {
  401.  
  402.                     print
  403.                     "<br><hr><b>" .
  404.                     "Successfully deleted " .
  405.                     "${deleted_count} " .
  406.                     "entry!</b><hr><br>\n";
  407.  
  408.                 } else {
  409.  
  410.                     print
  411.                     "<br><hr><b>" .
  412.                     "Successfully deleted " .
  413.                     "${deleted_count} " .
  414.                     "entries!</b><hr><br>\n";
  415.                 } 
  416.             }
  417.         }
  418.     }
  419.  
  420. } else if (isset($_POST['stoken'])) {
  421.  
  422.     search_all($web, $indonesia, $_POST['stoken']);
  423. }
  424. ?>
  425. </body>
  426. </html>
  427.  
  428. <?
  429. ///////////////////////////////////////////////////////////////////////////////
  430. function search_all($web, $indonesia, $stoken) {
  431.  
  432.     $results = array();
  433.  
  434.     $id = uniqid(rand(), true);
  435.  
  436.     $stoken = $web->strip($stoken);
  437.  
  438.     if ($stoken == "") {
  439.  
  440.         print
  441.         "<hr><b>You must specify a search value!" .
  442.         "</b><hr><br>\n" .
  443.         "<script language=\"Javascript\" type=\"text/javascript\">\n" .
  444.         "document.search.stoken.focus();\n" .
  445.         "</script>\n";
  446.  
  447.         return;
  448.     }  
  449.  
  450.     $errstr = $indonesia->search_all($results, $stoken);
  451.  
  452.     if ($errstr != "") {
  453.  
  454.         print "<hr><b>${errstr}</b><hr><br>\n";
  455.  
  456.         return;
  457.     }
  458.  
  459.     $total_results = count($results);
  460.  
  461.     print 
  462.     "<hr><b>Found ${total_results} match(es) for search entry: " .
  463.     "'${stoken}'</b>" .
  464.     "<hr>\n";
  465.  
  466.     if ($total_results == 0) {
  467.  
  468.         return;
  469.     }
  470.  
  471.     $results_str = "";
  472.  
  473.     $pkeys = "";
  474.  
  475.     $results_str .=
  476.     "<form name=\"delete_entries\" method=\"post\" " .
  477.     "onSubmit='return verify_delete_selected()'>\n" .
  478.     "<input type=\"hidden\" name=\"id\" value=\"${id}\">\n" . 
  479.     "<input type=\"hidden\" name=\"delete_selected\" value=\"1\">\n" .
  480.     "<input type=\"hidden\" name=\"stokenx\" value=\"${stoken}\">\n" .
  481.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\">\n";
  482.  
  483.     for($i = 0; $i < $total_results; $i++) {
  484.  
  485.         if ($i == 0) {
  486.  
  487.             $results_str .=    
  488.             "<tr>\n" .
  489.             "<th>PKEY</th>\n" .
  490.             "<th>Language</th>\n" .
  491.             "<th>English</th>\n" .
  492.             "<th>Indonesian</th>\n" .
  493.             "<th>Part of Speech</th>\n" .
  494.             "<th>Pronunciation</th>\n" .
  495.             "<th>IPA</th>\n" .
  496.             "<th>Comments</th>\n" .
  497.             "<th>Created</th>\n" .
  498.             "<th>Modified</th>\n" .
  499.             "<th>\n" .
  500.             "<input type=\"submit\" " .
  501.             "value=\"Delete Selected Entries!\" " .
  502.             "onClick='return verify_delete_selected()'>" .
  503.             "<br>\n" .
  504.             "Password:<br>\n" .
  505.             "<input type=\"password\" " .
  506.             "name=\"password\">\n" .
  507.             "</th>\n" .
  508.             "</tr>\n";
  509.                 }
  510.  
  511.         $pkey = $web->tohtml($results[$i]["pkey"]);
  512.         $language = $web->tohtml($results[$i]["language"]);
  513.         $english = $web->tohtml($results[$i]["english"]);
  514.         $indonesian = $web->tohtml($results[$i]["indonesian"]);
  515.         $pos = $web->tohtml($results[$i]["pos"]);
  516.         $pronunciation = $web->tohtml($results[$i]["pronunciation"]);
  517.         $ipa = $web->tohtml($results[$i]["ipa"]);
  518.         $comments = $web->tohtml($results[$i]["comments"]);
  519.         $created = $web->tohtml($results[$i]["created"]);
  520.         $modified = $web->tohtml($results[$i]["modified"]);
  521.  
  522.         $pkeys .= 
  523.         "<input type=\"hidden\" name=\"${pkey}\" " .
  524.         "value=\"delete_entry\">\n";
  525.  
  526.         $results_str .=
  527.         "<tr>\n" .
  528.         "<td>${pkey} </td>\n" .
  529.         "<td>${language} </td>\n" .
  530.         "<td>${english} </td>\n" .
  531.         "<td>${indonesian} </td>\n" .
  532.         "<td>${pos} </td>\n" .
  533.         "<td>${pronunciation} </td>\n" .
  534.         "<td>${ipa} </td>\n" .
  535.         "<td>${comments} </td>\n" .
  536.         "<td>${created} </td>\n" .
  537.         "<td>${modified} </td>\n" .
  538.         "<td>Delete:  \n" .
  539.         "<input type=\"checkbox\" name=\"${pkey}\" " .
  540.         "value=\"delete_entry\"></td>\n" .
  541.         "</tr>\n";
  542.         }
  543.  
  544.     $results_str .= "</table></form>\n";
  545.  
  546.     if ($total_results > 1) {
  547.  
  548.         print
  549.         "<form name=\"delete_all\" method=\"post\" " .
  550.         "onSubmit='return verify_delete_all()'>\n" .
  551.         "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\">\n" .
  552.         "<tr>\n" .
  553.         "<td>Password:</td>\n" .
  554.         "<td><input type=\"password\" name=\"password\"></td>\n" .
  555.         "<td>\n " .
  556.         "<input type=\"submit\" value=\"Delete All Entries!\">\n" .
  557.         "</td></tr></table>\n" .
  558.         "<input type=\"hidden\" name=\"delete_all\" value=\"1\">\n" .
  559.         "<input type=\"hidden\" name=\"id\" value=\"${id}\">\n" .
  560.         "${pkeys}" .
  561.         "</form><hr>\n";
  562.     }
  563.  
  564.     print $results_str;
  565.  
  566.     return;
  567. }
  568. ///////////////////////////////////////////////////////////////////////////////
  569. function search_pkey($web, $indonesia, $spkey) {
  570.  
  571.     $results = array();
  572.  
  573.     $id = uniqid(rand(), true);
  574.  
  575.     $spkey = $web->strip($spkey);
  576.  
  577.     if ($spkey == "") {
  578.  
  579.         print
  580.         "<hr><b>No primary key specified!" .
  581.         "</b><hr><br>\n" .
  582.         "<script language=\"Javascript\" type=\"text/javascript\">\n" .
  583.         "document.search.stoken.focus();\n" .
  584.         "</script>\n";
  585.  
  586.         return;
  587.     }  
  588.  
  589.     $errstr = $indonesia->search_pkey($results, $spkey);
  590.  
  591.     if ($errstr != "") {
  592.  
  593.         print "<hr><b>${errstr}</b><hr><br>\n";
  594.  
  595.         return;
  596.     }
  597.  
  598.     $total_results = count($results);
  599.  
  600.     print 
  601.     "<hr><b>Found ${total_results} match(es) for " .
  602.     "primary key: '${spkey}'</b>" .
  603.     "<hr>\n";
  604.  
  605.     if ($total_results == 0) {
  606.  
  607.         return;
  608.     }
  609.  
  610.     $results_str = "";
  611.  
  612.     $pkeys = "";
  613.  
  614.     $results_str .=
  615.     "<form name=\"delete_entries\" method=\"post\" " .
  616.     "onSubmit='return verify_delete_selected()'>\n" .
  617.     "<input type=\"hidden\" name=\"id\" value=\"${id}\">\n" . 
  618.     "<input type=\"hidden\" name=\"delete_selected\" value=\"1\">\n" .
  619.     "<input type=\"hidden\" name=\"editor\" value=\"1\">\n" .
  620.     "<input type=\"hidden\" name=\"stokenx\" value=\"1\">\n" .
  621.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\">\n";
  622.  
  623.     for($i = 0; $i < $total_results; $i++) {
  624.  
  625.         if ($i == 0) {
  626.  
  627.             $results_str .=    
  628.             "<tr>\n" .
  629.             "<th>PKEY</th>\n" .
  630.             "<th>English</th>\n" .
  631.             "<th>Indonesian</th>\n" .
  632.             "<th>Part of Speech</th>\n" .
  633.             "<th>Pronunciation</th>\n" .
  634.             "<th>IPA</th>\n" .
  635.             "<th>Comments</th>\n" .
  636.             "<th>Created</th>\n" .
  637.             "<th>Modified</th>\n" .
  638.             "<th>\n" .
  639.             "<input type=\"submit\" " .
  640.             "value=\"Delete Selected Entries!\" " .
  641.             "onClick='return verify_delete_selected()'>" .
  642.             "<br>\n" .
  643.             "Password:<br>\n" .
  644.             "<input type=\"password\" " .
  645.             "name=\"password\">\n" .
  646.             "</th>\n" .
  647.             "</tr>\n";
  648.                 }
  649.  
  650.         $pkey = $web->tohtml($results[$i]["pkey"]);
  651.         $english = $web->tohtml($results[$i]["english"]);
  652.         $indonesian = $web->tohtml($results[$i]["indonesian"]);
  653.         $pos = $web->tohtml($results[$i]["pos"]);
  654.         $pronunciation = $web->tohtml($results[$i]["pronunciation"]);
  655.         $ipa = $web->tohtml($results[$i]["ipa"]);
  656.         $comments = $web->tohtml($results[$i]["comments"]);
  657.         $created = $web->tohtml($results[$i]["created"]);
  658.         $modified = $web->tohtml($results[$i]["modified"]);
  659.  
  660.         $pkeys .= 
  661.         "<input type=\"hidden\" name=\"${pkey}\" " .
  662.         "value=\"delete_entry\">\n";
  663.  
  664.         $results_str .=
  665.         "<tr>\n" .
  666.         "<td>${pkey} </td>\n" .
  667.         "<td>${english} </td>\n" .
  668.         "<td>${indonesian} </td>\n" .
  669.         "<td>${pos} </td>\n" .
  670.         "<td>${pronunciation} </td>\n" .
  671.         "<td>${ipa} </td>\n" .
  672.         "<td>${comments} </td>\n" .
  673.         "<td>${created} </td>\n" .
  674.         "<td>${modified} </td>\n" .
  675.         "<td>Delete:  \n" .
  676.         "<input type=\"checkbox\" name=\"${pkey}\" " .
  677.         "value=\"delete_entry\" checked></td>\n" .
  678.         "</tr>\n";
  679.         }
  680.  
  681.     $results_str .= 
  682.     "</table></form>\n " .
  683.     "<script language=\"Javascript\" type=\"text/javascript\">\n" .
  684.     "document.delete_entries.password.focus();\"\n" .
  685.     "</script>\n";
  686.  
  687.     print $results_str;
  688.  
  689.     return;
  690. }
  691. ///////////////////////////////////////////////////////////////////////////////
  692. function show_search_form($web, $indonesia) {
  693.  
  694.     print <<<EOFSSF
  695. <form name="search" method="post" onSubmit='return verify_search()'>
  696. <table cellpadding="3" cellspacing="3" border="0">
  697. <tr>
  698. <td>Enter search entry to delete:</td> 
  699. <td>
  700. <input type="text" name="stoken" maxlength="255" size="30">
  701. </td>
  702. </tr><tr>
  703. <td colspan="2" align="right">
  704. <input type="submit" value="Search Dictionary!">
  705. </td>
  706. </tr>
  707. </table>
  708. </form>
  709. <script language="Javascript" type="text/javascript">
  710. document.search.stoken.focus(); 
  711. </script>
  712. EOFSSF;
  713.     return;
  714. }
  715. ///////////////////////////////////////////////////////////////////////////////
  716. ///////////////////////////////////////////////////////////////////////////////
  717. ?>
  718. @
  719.  
  720.  
  721. 1.8
  722. log
  723. @*** empty log message ***
  724. @
  725. text
  726. @d12 1
  727. a12 1
  728. // Modified:     October 17, 2003
  729. d63 2
  730. @
  731.  
  732.  
  733. 1.7
  734. log
  735. @*** empty log message ***
  736. @
  737. text
  738. @d12 1
  739. a12 1
  740. // Modified:     October 05, 2003
  741. d64 2
  742. d67 2
  743. a68 27
  744.  
  745. ///////////////////////////////////////////////////////////////////////////////
  746. function is_white_space(stoken) {
  747.  
  748.     if (stoken == null) return(true);
  749.  
  750.     if (stoken == '') return(true);
  751.  
  752.     if (stoken == "") return(true);
  753.  
  754.     return(false);
  755. }
  756. ///////////////////////////////////////////////////////////////////////////////
  757. function trim(stoken) {
  758.  
  759.     if (is_white_space(stoken)) {
  760.  
  761.         return(stoken);
  762.     }
  763.  
  764.     stoken = stoken.replace(/^\s*/, "");
  765.  
  766.     stoken = stoken.replace(/\s*$/, "");
  767.  
  768.     return(stoken);
  769. }
  770. ///////////////////////////////////////////////////////////////////////////////
  771. d84 1
  772. a84 1
  773. ///////////////////////////////////////////////////////////////////////////////
  774. d129 2
  775. a130 2
  776. ///////////////////////////////////////////////////////////////////////////////
  777. ///////////////////////////////////////////////////////////////////////////////
  778. @
  779.  
  780.  
  781. 1.6
  782. log
  783. @*** empty log message ***
  784. @
  785. text
  786. @d12 1
  787. a12 1
  788. // Modified:     September 30, 2003
  789. d157 3
  790. a159 1
  791. <h2>Bahasa Indonesia Dictionary: Delete Word(s)</h2>
  792. @
  793.  
  794.  
  795. 1.5
  796. log
  797. @*** empty log message ***
  798. @
  799. text
  800. @d12 1
  801. a12 1
  802. // Modified:     September 03, 2003
  803. d41 1
  804. a41 1
  805. if (!session_is_registered("ADMIN")) {
  806. d174 1
  807. a174 1
  808. (session_is_registered("NODUP_DELETES")) &&
  809. d182 1
  810. a182 1
  811. (session_is_registered("NODUP_DELETES")) &&
  812. d202 2
  813. a203 2
  814.     (!session_is_registered("NODUP_DELETES") ||
  815.     ((session_is_registered("NODUP_DELETES")) &&
  816. d206 1
  817. a206 1
  818.         if (session_is_registered("NODUP_DELETES")) {
  819. d208 1
  820. a208 1
  821.             session_unregister("NODUP_DELETES");
  822. d250 2
  823. a251 5
  824.                         $NODUP_DELETES = 
  825.                         $_POST['id'];
  826.  
  827.                         session_register(
  828.                         "NODUP_DELETES");
  829. d294 2
  830. a295 2
  831.     (!session_is_registered("NODUP_DELETES") ||
  832.     ((session_is_registered("NODUP_DELETES")) &&
  833. d298 1
  834. a298 1
  835.         if (session_is_registered("NODUP_DELETES")) {
  836. d300 1
  837. a300 1
  838.             session_unregister("NODUP_DELETES");
  839. d342 2
  840. a343 5
  841.                         $NODUP_DELETES = 
  842.                         $_POST['id'];
  843.  
  844.                         session_register(
  845.                         "NODUP_DELETES");
  846. @
  847.  
  848.  
  849. 1.4
  850. log
  851. @*** empty log message ***
  852. @
  853. text
  854. @d12 1
  855. a12 1
  856. // Modified:     September 02, 2003
  857. d206 5
  858. d301 5
  859. d502 17
  860. a518 14
  861.     print
  862.     "<form name=\"delete_all\" method=\"post\" " .
  863.     "onSubmit='return verify_delete_all()'>\n" .
  864.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\">\n" .
  865.     "<tr>\n" .
  866.     "<td>Password:</td>\n" .
  867.     "<td><input type=\"password\" name=\"password\"></td>\n" .
  868.     "<td>\n " .
  869.     "<input type=\"submit\" value=\"Delete All Entries!\">\n" .
  870.     "</td></tr></table>\n" .
  871.     "<input type=\"hidden\" name=\"delete_all\" value=\"1\">\n" .
  872.     "<input type=\"hidden\" name=\"id\" value=\"${id}\">\n" .
  873.     "${pkeys}" .
  874.     "</form><hr>\n";
  875. @
  876.  
  877.  
  878. 1.3
  879. log
  880. @*** empty log message ***
  881. @
  882. text
  883. @d12 1
  884. a12 1
  885. // Modified:     September 01, 2003
  886. d62 1
  887. a62 1
  888. <title>Bahasa Indonesia Dictionary: Delete Entry</title>
  889. d165 8
  890. d190 6
  891. d408 2
  892. a409 1
  893.     "<hr><b>Found ${total_results} match(es) for: '${stoken}'</b>" .
  894. d512 123
  895. d637 1
  896. a637 1
  897. print <<<EOFSSF
  898. d641 1
  899. a641 1
  900. <td>Enter search word(s) to delete:</td> 
  901. @
  902.  
  903.  
  904. 1.2
  905. log
  906. @*** empty log message ***
  907. @
  908. text
  909. @d12 1
  910. a12 1
  911. // Modified:     August 18, 2003
  912. a47 9
  913. if (session_is_registered("NODUP_DELETE_ENTRY")) {
  914.  
  915.     session_unregister("NODUP_DELETE_ENTRY");
  916.  
  917.     $web->redirect("admin.php");
  918.  
  919.     exit;    
  920. }
  921.  
  922. d66 1
  923. d77 1
  924. a77 1
  925.  
  926. d91 6
  927. d98 6
  928. a103 1
  929. function verify() {
  930. d105 4
  931. a108 1
  932.     var stoken = document.deletee.stoken.value;
  933. d110 1
  934. a110 1
  935.     stoken = trim(stoken);
  936. d112 1
  937. a112 1
  938.     if (is_white_space(stoken)) {
  939. d114 1
  940. a114 1
  941.         alert("You must enter a search value.");
  942. d116 1
  943. a116 1
  944.         document.deletee.stoken.focus();
  945. d123 2
  946. d126 1
  947. a126 1
  948. function verify_delete() {
  949. d128 1
  950. a128 1
  951.     var password = document.verify.password.value;
  952. d130 10
  953. a139 1
  954.     if (is_white_space(password)) {
  955. d141 3
  956. a143 1
  957.         alert("You must enter your password.");
  958. d145 1
  959. a145 1
  960.         document.verify.password.focus();
  961. d152 2
  962. d157 1
  963. a157 1
  964. <h2>Bahasa Indonesia Dictionary: Delete Entry</h2>
  965. d163 2
  966. d166 46
  967. a211 2
  968. (isset($_POST['pkey'])) &&
  969. (isset($_POST['delete_flag']))) { 
  970. d213 2
  971. a214 3
  972.     $errstr =
  973.     $indonesia->login(
  974.     $_SESSION['ADMIN'], $_POST['password']);
  975. d216 14
  976. a229 1
  977.     if ($errstr != "") {
  978. d231 2
  979. a232 1
  980.         print "<b>Permission denied!</b>\n";
  981. d234 5
  982. a238 1
  983.     } else {
  984. d240 1
  985. a240 2
  986.         $errstr = 
  987.         $indonesia->delete_entry($_POST['pkey']);
  988. d242 1
  989. a242 1
  990.         if ($errstr != "") {
  991. d244 4
  992. a247 1
  993.             print "<br><hr><b>${errstr}</b><hr><br>\n";
  994. d249 2
  995. a250 1
  996.         } else {
  997. d252 7
  998. a258 1
  999.             print "<br><hr><b>Delete successful!</b><hr><br>\n";
  1000. d260 1
  1001. a260 1
  1002.             $NODUP_DELETE_ENTRY = 1;
  1003. d262 8
  1004. a269 2
  1005.             session_register("NODUP_DELETE_ENTRY");
  1006.         } 
  1007. d273 13
  1008. a285 7
  1009. (isset($_POST['pkey'])) &&
  1010. (isset($_POST['entry'])) && 
  1011. (isset($_POST['language']))) {     
  1012.  
  1013.     show_verify_form(
  1014.     $web, $indonesia,
  1015.     $_POST['pkey'], $_POST['entry'], $_POST['language']);
  1016. d287 1
  1017. a287 4
  1018. } else if (
  1019. (isset($_POST['stoken'])) &&
  1020. (isset($_POST['method'])) &&
  1021. (isset($_POST['language']))) { 
  1022. d289 1
  1023. a289 1
  1024.     show_search_form();
  1025. d291 1
  1026. a291 3
  1027.     search(
  1028.     $web, $indonesia, 
  1029.     $_POST['stoken'], $_POST['method'], $_POST['language']);
  1030. d293 1
  1031. a293 1
  1032. } else {
  1033. d295 1
  1034. a295 5
  1035.     show_search_form();
  1036. }
  1037. ?>
  1038. </body>
  1039. </html>
  1040. d297 1
  1041. a297 5
  1042. <?
  1043. ///////////////////////////////////////////////////////////////////////////////
  1044. //
  1045. ///////////////////////////////////////////////////////////////////////////////
  1046. function search($web, $indonesia, $stoken, $method, $language) {
  1047. d299 1
  1048. a299 1
  1049.     $stoken = trim($stoken);
  1050. d301 1
  1051. a301 1
  1052.     if ($stoken == "") {
  1053. d303 2
  1054. a304 1
  1055.         print "You must enter a search value.";
  1056. d306 7
  1057. a312 2
  1058.         return;
  1059.     }
  1060. d314 2
  1061. a315 1
  1062.     $method = trim($method);
  1063. d317 1
  1064. a317 1
  1065.     if ($method == "") {
  1066. d319 1
  1067. a319 1
  1068.         print "You must choose a search method.";
  1069. d321 2
  1070. a322 2
  1071.         return;
  1072.     }
  1073. d324 5
  1074. a328 1
  1075.     $language = trim($language);
  1076. d330 1
  1077. a330 1
  1078.     if ($method == "exact") {
  1079. d332 7
  1080. a338 1
  1081.         search_exact($web, $indonesia, $stoken, $language);
  1082. d340 1
  1083. a340 1
  1084.     } else if ($method == "fuzzy") {
  1085. d342 8
  1086. a349 1
  1087.         print "This feature has not been implemented yet.";
  1088. d352 3
  1089. a354 1
  1090.     return;
  1091. d356 5
  1092. d362 1
  1093. a362 3
  1094. //
  1095. ///////////////////////////////////////////////////////////////////////////////
  1096. function search_exact($web, $indonesia, $stoken, $language) {
  1097. d366 3
  1098. a368 1
  1099.     $language = strtolower($language);
  1100. d370 8
  1101. a377 2
  1102.     $sql = 
  1103.     "SELECT * FROM dictionary WHERE ${language}=\"$stoken\"";
  1104. d379 4
  1105. a382 1
  1106.     $errstr = $indonesia->search($sql, $results);
  1107. d386 1
  1108. a386 1
  1109.         print "$errstr";
  1110. d391 1
  1111. a391 1
  1112.     $matches = count($results);
  1113. d393 3
  1114. a395 1
  1115.     if (!$matches) {
  1116. d397 1
  1117. a397 1
  1118.         print "<h3>Found ${matches} matches!</h3>"; 
  1119. d402 3
  1120. a404 3
  1121.     print 
  1122.     "<h3>Found ${matches} exact " .
  1123.     "matches for ${language} word(s) ${stoken}!</h3>\n"; 
  1124. d406 7
  1125. a412 4
  1126.     print 
  1127.     "<hr>" .
  1128.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\" " .
  1129.     "width=\"50%\">\n";
  1130. d414 1
  1131. a414 1
  1132.     for($i = 0; $i < $matches; $i++) {
  1133. d418 1
  1134. a418 1
  1135.             print
  1136. d421 1
  1137. d425 3
  1138. d430 9
  1139. a438 5
  1140.             "<th>Spelling Flag</th>\n" .
  1141.             "<th>Pronunciation</th>\n" .
  1142.             "<th>IPA Pronunciation</th>\n" .
  1143.             "<th>Comments</th>\n" .
  1144.             "<th>Action</th>\n" .
  1145. d440 1
  1146. a440 1
  1147.         }
  1148. d442 14
  1149. a455 10
  1150.         $pkey = $web->tohtml($results[$i]->pkey);
  1151.         $eng = $web->tohtml($results[$i]->english);
  1152.         $indo = $web->tohtml($results[$i]->indonesian);
  1153.         $pos = $web->tohtml($results[$i]->part_of_speech);
  1154.         $created = $web->tohtml($results[$i]->created);
  1155.         $modified = $web->tohtml($results[$i]->modified);
  1156.         $spelling_flag = $web->tohtml($results[$i]->spelling_flag);
  1157.         $p = $web->tohtml($results[$i]->pronunciation);
  1158.         $pipa = $web->tohtml($results[$i]->pronunciation_ipa);
  1159.         $comments = $web->tohtml($results[$i]->comments);
  1160. d457 1
  1161. a457 1
  1162.         print 
  1163. d460 3
  1164. a462 2
  1165.         "<td>${eng} </td>\n" .
  1166.         "<td>${indo} </td>\n" .
  1167. d464 3
  1168. d469 3
  1169. a471 14
  1170.         "<td>${spelling_flag} </td>\n" .
  1171.         "<td>${p} </td>\n" .
  1172.         "<td>${pipa} </td>\n" .
  1173.         "<td>${comments} </td>\n" .
  1174.         "<td>\n" .
  1175.         "<form name=\"delete.php\" method=\"post\">\n" .
  1176.         "<input type=\"submit\" value=\"Delete!\">\n" .
  1177.         "<input type=\"hidden\" name=\"pkey\" " .
  1178.         "value=\"${pkey}\"> " .
  1179.         "<input type=\"hidden\" name=\"entry\" " .
  1180.         "value=\"${stoken}\"> " .
  1181.         "<input type=\"hidden\" name=\"language\" " .
  1182.         "value=\"${language}\"> " .
  1183.         "</form></td>\n" .    
  1184. d473 1
  1185. a473 1
  1186.     }
  1187. d475 1
  1188. a475 1
  1189.     print "</table><hr>\n";
  1190. d477 14
  1191. a490 6
  1192.     return;
  1193. ///////////////////////////////////////////////////////////////////////////////
  1194. //
  1195. ///////////////////////////////////////////////////////////////////////////////
  1196. function show_verify_form($web, $indonesia, $pkey, $entry, $language) {
  1197. d492 1
  1198. a492 26
  1199.     $language = ucfirst($language);
  1200.  
  1201.     print <<<EOFSCF
  1202. <b>WARNING:</b><br>
  1203. The following ${language} dictionary entry will be permanently removed:<br>
  1204. Primary Key = ${pkey} <br>
  1205. Entry = ${entry}<br>
  1206. <form method="post" name="verify"
  1207. onSubmit="return verify_delete()"> 
  1208. <table cellpadding="3" cellspacing="3" border="0">
  1209. <tr>
  1210. <td>
  1211. <input type="submit" value="Delete Entry"> 
  1212. </td>
  1213. <td>
  1214. Password:
  1215. </td>
  1216. <td>
  1217. <input type="password" name="password">
  1218. </td>
  1219. </tr>
  1220. </table>
  1221. <input type="hidden" name="delete_flag" value="1">
  1222. <input type="hidden" name="pkey" value="${pkey}">
  1223. </form>
  1224. EOFSCF;
  1225. d497 1
  1226. a497 3
  1227. //
  1228. ///////////////////////////////////////////////////////////////////////////////
  1229. function show_search_form() {
  1230. d499 2
  1231. a500 2
  1232.     print <<<EOFSSF
  1233. <form name="deletee" method="post"  onsubmit='return verify()'>
  1234. d503 1
  1235. a503 17
  1236. <td colspan="2">Enter Search Word(s) to DELETE:
  1237. </td>
  1238. </tr><tr>
  1239. <td colspan="2">
  1240. <textarea name="stoken" rows="5" cols="50" wrap="soft"></textarea>
  1241. </td>
  1242. </tr><tr>
  1243. <td>
  1244. <input type="radio" name="method" value="exact" checked>
  1245. </td>
  1246. <td>
  1247. Search dictionary for exact matches only
  1248. </td>
  1249. </tr><tr>
  1250. <td>
  1251. <input type="radio" name="method" value="fuzzy">
  1252. </td>
  1253. d505 1
  1254. a505 1
  1255. Search dictionary for exact and/or close matches 
  1256. d508 2
  1257. a509 6
  1258. <td colspan="2"></td>
  1259. </tr><tr>
  1260. <td align="right" colspan="2">
  1261. <input type="submit" name="language" value="English"> 
  1262.    
  1263. <input type="submit" name="language" value="Indonesian">
  1264. d515 2
  1265. a516 2
  1266. document.deletee.stoken.focus();
  1267. </script> 
  1268. a517 1
  1269.  
  1270. d520 2
  1271. @
  1272.  
  1273.  
  1274. 1.1
  1275. log
  1276. @Initial revision
  1277. @
  1278. text
  1279. @d5 33
  1280. @
  1281.  
  1282.  
  1283. 1.1.1.1
  1284. log
  1285. @Bahasa Indonesia Dictionary
  1286. @
  1287. text
  1288. @@
  1289.