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 / requests.php,v < prev    next >
Text File  |  2003-10-20  |  15KB  |  795 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.46;    author bule;    state Exp;
  11. branches;
  12. next    1.8;
  13.  
  14. 1.8
  15. date    2003.10.18.00.33.42;    author bule;    state Exp;
  16. branches;
  17. next    1.7;
  18.  
  19. 1.7
  20. date    2003.10.06.00.39.27;    author bule;    state Exp;
  21. branches;
  22. next    1.6;
  23.  
  24. 1.6
  25. date    2003.10.04.18.22.57;    author bule;    state Exp;
  26. branches;
  27. next    1.5;
  28.  
  29. 1.5
  30. date    2003.10.01.06.51.30;    author bule;    state Exp;
  31. branches;
  32. next    1.4;
  33.  
  34. 1.4
  35. date    2003.09.04.07.27.00;    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.19.24.21;    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:    requests.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 an administrator to handle new 
  84. //               dictionary requests submitted by a client. 
  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. $web = new Web(); 
  108.  
  109. if (!$_SESSION['ADMIN']) {
  110.  
  111.     $web->redirect("login.php");
  112.  
  113.     exit;
  114. }
  115.  
  116. $indonesia = new Indonesia();
  117.  
  118. $status = $indonesia->get_dictionary_status();
  119.  
  120. if ($status["status"] == 1 || $status["status"] == 2) {
  121.  
  122.     $web->redirect("admin.php");
  123.  
  124.     exit;
  125. }
  126.  
  127. if (
  128. (isset($_POST['requested_entries'])) &&
  129. (isset($_POST['id']))) {
  130.  
  131.     foreach($_POST as $name => $value) {
  132.  
  133.         if ($value == "Insert!") {
  134.  
  135.             $pkey = $name;
  136.  
  137.             $web->redirect(
  138.             "insert.php?insert_requested_entry=${pkey}");
  139.  
  140.             exit;
  141.         }
  142.         }
  143. }
  144. ?>
  145. <html>
  146. <head>
  147. <title>Bahasa Indonesia Dictionary: Requested Entries</title>
  148.  
  149. <link href="bahasa.css" rel="stylesheet" type="text/css">
  150.  
  151. <script type="text/javascript" src="bahasa.js"></script>
  152.  
  153. <script language="Javascript" type="text/javascript">
  154. <!--
  155.  
  156. var no_send_flag = 0;
  157.  
  158. //////////////////////////////////////////////////////////////////////////////
  159. function verify() {
  160.  
  161.     if (no_send_flag) {
  162.  
  163.         no_send_flag = 0;
  164.  
  165.         return(false);
  166.     }
  167.  
  168.     return(true);
  169. }
  170. //////////////////////////////////////////////////////////////////////////////
  171. function verify_delete_all() {
  172.  
  173.     password = document.delete_all.password.value;
  174.  
  175.     if (is_white_space(password)) {
  176.  
  177.         alert(
  178.         "You must enter a password value!");
  179.  
  180.         document.delete_all.password.focus();
  181.  
  182.         return(false);
  183.     }
  184.  
  185.     return(true);
  186. }
  187. //////////////////////////////////////////////////////////////////////////////
  188. function verify_delete_selected() {
  189.  
  190.     password = document.requested_entries.password.value;
  191.  
  192.     if (is_white_space(password)) {
  193.  
  194.         alert(
  195.         "You must enter a password value!");
  196.  
  197.         document.requested_entries.password.focus();
  198.  
  199.         no_send_flag = 1;
  200.  
  201.         return(false);
  202.     }
  203.  
  204.     return(true);
  205. }
  206. //////////////////////////////////////////////////////////////////////////////
  207. // -->
  208. </script>
  209. </head>
  210. <body>
  211. <?
  212. $web->show_logo("Requested Entries");
  213. ?>
  214. <a href="admin.php">Administration</a>
  215. <?
  216. if (
  217. ($_SESSION['NODUP_REQUESTS']) &&
  218. (isset($_POST['id'])) &&
  219. (isset($_POST['requested_entries'])) &&
  220. ($_SESSION['NODUP_REQUESTS'] == $_POST['id'])) {
  221.  
  222.     //Do nothing...prevents refresh duplication of last action 
  223.  
  224. } else if ( 
  225. (isset($_POST['requested_entries'])) &&
  226. (isset($_POST['id'])) &&
  227. (isset($_POST['password']))) {
  228.  
  229.     if ($_SESSION['NODUP_REQUESTS']) {
  230.  
  231.         unset($_SESSION['NODUP_REQUESTS']);
  232.     }
  233.  
  234.     $errstr = 
  235.     $indonesia->login($_SESSION['ADMIN'], $_POST['password']);
  236.  
  237.     if ($errstr != "") {
  238.  
  239.         print "<br><hr><b>Permission denied!</b><hr>\n";
  240.  
  241.     } else {
  242.  
  243.         $delete_count = 0;
  244.  
  245.         $error_flag = 0;
  246.  
  247.         $selected = 0;
  248.  
  249.         foreach($_POST as $name => $pkey) {
  250.  
  251.             if (
  252.             ($name != "id") && ($name != "requested_entries") && 
  253.             ($name != "password")) {
  254.  
  255.                 $pkey = trim($pkey); 
  256.  
  257.                 $pkey = $web->tohtml($pkey);
  258.  
  259.                 $selected++;
  260.  
  261.                 $errstr =
  262.                 $indonesia->delete_request($pkey);
  263.  
  264.                 if ($errstr != "") {
  265.  
  266.                     print "<br><hr><b>${errstr}</b><hr>\n";
  267.  
  268.                     $error_flag = 1;
  269.  
  270.                     break;
  271.  
  272.                 } else {
  273.  
  274.                     $delete_count++;
  275.                 }
  276.             }
  277.         }
  278.  
  279.         if (!$selected) {
  280.  
  281.             print 
  282.             "<hr><b>You must select at least one " .
  283.             "requested entries to delete!</b><hr>\n";
  284.  
  285.         } else {
  286.  
  287.             $_SESSION['NODUP_REQUESTS'] = $_POST['id'];
  288.  
  289.             if (!$error_flag) {
  290.  
  291.                 if ($delete_count > 1) {
  292.  
  293.                     print 
  294.                     "<hr><b>Successfully deleted " .
  295.                     "${delete_count} " .
  296.                     "requested entries!</b><hr>\n"; 
  297.  
  298.                 } else if ($delete_count == 1) {
  299.  
  300.                     print 
  301.                     "<hr><b>Successfully deleted " .
  302.                     "${delete_count} " .
  303.                     "requested entry!</b><hr>\n"; 
  304.  
  305.                 } else {
  306.  
  307.                     print 
  308.                     "<hr><b>No requested " .
  309.                     "entries deleted!" .
  310.                     "</b><hr>\n"; 
  311.                 }
  312.             }
  313.         }
  314.     }
  315.  
  316. } else if (
  317. (isset($_POST['delete_all'])) &&
  318. (isset($_POST['id'])) &&
  319. (isset($_POST['password']))) { 
  320.  
  321.     if (
  322.     (!$_SESSION['NODUP_REQUESTS']) || 
  323.     (($_SESSION['NODUP_REQUESTS']) && 
  324.     ($_SESSION['NODUP_REQUESTS'] != $_POST['id']))) {
  325.  
  326.         if ($_SESSION['NODUP_REQUESTS']) {
  327.  
  328.             unset($_SESSION['NODUP_REQUESTS']);
  329.         }
  330.  
  331.         $errstr = 
  332.         $indonesia->login($_SESSION['ADMIN'], $_POST['password']);
  333.  
  334.         if ($errstr != "") {
  335.  
  336.             print "<br><hr><b>Permission denied!</b><hr>\n";
  337.  
  338.         } else {
  339.  
  340.             $errstr = $indonesia->delete_requests();
  341.  
  342.             if ($errstr != "") {
  343.  
  344.                 print "<hr><b>${errstr}</b><hr>\n";
  345.  
  346.             } else {
  347.  
  348.                 print 
  349.                 "<hr><b>All requested entries " .
  350.                 "successfully " .
  351.                 "deleted!</b><hr>\n";
  352.  
  353.                 $_SESSION['NODUP_REQUESTS'] = $_POST['id'];
  354.             }
  355.         }
  356.     }
  357. }
  358.  
  359. show_requests($web, $indonesia);
  360.  
  361. ?>
  362. </body>
  363. </html>
  364. <?
  365. //////////////////////////////////////////////////////////////////////////////
  366. function show_requests($web, $indonesia) {
  367.  
  368.     $requests = array();
  369.  
  370.     $id = uniqid(rand(), true);
  371.  
  372.     $errstr = $indonesia->get_requests($requests);
  373.  
  374.     if ($errstr != "") {
  375.  
  376.         print "<hr><br><b>${errstr}</b><hr><br>\n";
  377.  
  378.     } else {
  379.  
  380.         $total_requests = count($requests);
  381.  
  382.         print 
  383.         "<hr><b>Found ${total_requests} requested " .
  384.         "entries!</b><hr><br>\n";
  385.  
  386.         if ($total_requests == 0) {
  387.  
  388.             return;
  389.         }
  390.  
  391.         if ($total_requests > 1) {
  392.  
  393.             print
  394.             "<form name=\"delete_all\" method=\"post\" " .
  395.             "onSubmit='return verify_delete_all()'>\n" .
  396.             "<table cellpadding=\"3\" cellspacing=\"3\" " .
  397.             "border=\"0\">\n" .
  398.             "<tr>\n" .
  399.             "<td>Password:</td>\n" .
  400.             "<td><input type=\"password\" " .
  401.             "name=\"password\"></td>\n" .
  402.             "<td>\n " .
  403.             "<input type=\"submit\" " .
  404.             "value=\"Delete All Entries!\">\n" .
  405.             "</td></tr></table>\n" .
  406.             "<input type=\"hidden\" name=\"delete_all\" " .
  407.             "value=\"1\">\n" .
  408.             "<input type=\"hidden\" name=\"id\" " .
  409.             "value=\"${id}\">\n" .
  410.             "</form><hr>\n";
  411.         }
  412.  
  413.         print
  414.         "<form name=\"requested_entries\" method=\"post\" " .
  415.         "onSubmit='return verify()'>\n" .
  416.         "<table cellpadding=\"3\" cellspacing=\"3\" " .
  417.         "border=\"1\">\n";
  418.  
  419.         for($i = 0; $i < $total_requests; $i++) {
  420.  
  421.             if ($i == 0) {
  422.  
  423.                 print 
  424.                 "<tr>\n" .
  425.                 "<th>PKEY</th>\n" .
  426.                 "<th>English</th>\n" .
  427.                 "<th>Indonesian</th>\n" .
  428.                 "<th>Part of Speech</th>\n" .
  429.                 "<th>Spelling</th>\n" .
  430.                 "<th>Comments</th>\n" .
  431.                 "<th>Created</th>\n" .
  432.                 "<th>Insert</th>\n" .
  433.                 "<th>\n" .
  434.                 "<input type=\"submit\" " .
  435.                 "value=\"Delete Selected Entries!\" " .
  436.                 "onClick='return verify_delete_selected()'>" .
  437.                 "<br>\n" .
  438.                 "Password:<br>\n" .
  439.                 "<input type=\"password\" " .
  440.                 "name=\"password\">\n" .
  441.                 "</th>\n" .
  442.                 "</tr>\n";
  443.             }
  444.  
  445.             $pkey = 
  446.             $web->tohtml($requests[$i]["pkey"]);
  447.  
  448.             $english = 
  449.             $web->tohtml($requests[$i]["english"]);
  450.  
  451.             $indonesian = 
  452.             $web->tohtml($requests[$i]["indonesian"]);
  453.  
  454.             $pos = 
  455.             $web->tohtml($requests[$i]["pos"]);
  456.  
  457.             $spl = 
  458.             $web->tohtml($requests[$i]["spelling"]);
  459.  
  460.             $comments = 
  461.             $web->tohtml($requests[$i]["comments"]);
  462.  
  463.             $created = 
  464.             $web->tohtml($requests[$i]["created"]);
  465.  
  466.             print 
  467.             "<tr>\n" .
  468.             "<td>${pkey} </td>\n" .
  469.             "<td>${english} </td>\n" .
  470.             "<td>${indonesian} </td>\n" .
  471.             "<td>${pos} </td>\n" .
  472.             "<td>${spl} </td>\n" .
  473.             "<td>${comments} </td>\n" .
  474.             "<td>${created} </td>\n" .
  475.             "<td>\n" .
  476.             "<input type=\"submit\" value=\"Insert!\" " .
  477.             "name=\"${pkey}\">\n" .
  478.             "</td>\n" .
  479.             "<td>Delete:  \n" .
  480.             "<input type=\"checkbox\" name=\"${pkey}\" " .
  481.             "value=\"${pkey}\"></td>\n" .
  482.             "</tr>\n";
  483.         }
  484.  
  485.         print
  486.         "</table>\n" .
  487.         "<input type=\"hidden\" name=\"id\" value=\"${id}\">\n" .
  488.         "<input type=\"hidden\" name=\"requested_entries\" " .
  489.         "value=\"1\">\n" .
  490.         "</form>\n";
  491.     }
  492.  
  493.     return;
  494. }
  495. ?>
  496.  
  497. @
  498.  
  499.  
  500. 1.8
  501. log
  502. @*** empty log message ***
  503. @
  504. text
  505. @d12 1
  506. a12 1
  507. // Modified:     October 17, 2003
  508. d79 2
  509. @
  510.  
  511.  
  512. 1.7
  513. log
  514. @*** empty log message ***
  515. @
  516. text
  517. @d12 1
  518. a12 1
  519. // Modified:     October 05, 2003
  520. d78 3
  521. a80 3
  522. <title>
  523. Bahasa Indonesia Dictionary: Requested Entries
  524. </title>
  525. d83 1
  526. d87 1
  527. a87 26
  528. ///////////////////////////////////////////////////////////////////////////////
  529. function is_white_space(stoken) {
  530.  
  531.     if (stoken == null) return(true);
  532.  
  533.     if (stoken == '') return(true);
  534.  
  535.     if (stoken == "") return(true);
  536.  
  537.     return(false);
  538. }
  539. ///////////////////////////////////////////////////////////////////////////////
  540. function trim(stoken) {
  541.  
  542.     if (is_white_space(stoken)) {
  543.  
  544.         return(stoken);
  545.     }
  546.  
  547.     stoken = stoken.replace(/^\s*/, "");
  548.  
  549.     stoken = stoken.replace(/\s*$/, "");
  550.  
  551.     return(stoken);
  552. }
  553. ///////////////////////////////////////////////////////////////////////////////
  554. d99 1
  555. a99 1
  556. ///////////////////////////////////////////////////////////////////////////////
  557. d116 1
  558. a116 1
  559. ///////////////////////////////////////////////////////////////////////////////
  560. d135 2
  561. a136 2
  562. ///////////////////////////////////////////////////////////////////////////////
  563. ///////////////////////////////////////////////////////////////////////////////
  564. @
  565.  
  566.  
  567. 1.6
  568. log
  569. @*** empty log message ***
  570. @
  571. text
  572. @d12 1
  573. a12 1
  574. // Modified:     October 04, 2003
  575. d164 3
  576. a166 1
  577. <h2>Bahasa Indonesia Dictionary: Requested Entries</h2>
  578. @
  579.  
  580.  
  581. 1.5
  582. log
  583. @*** empty log message ***
  584. @
  585. text
  586. @d12 1
  587. a12 1
  588. // Modified:     September 30, 2003
  589. d275 1
  590. a275 1
  591.     ($_SESSION['NODUP_REQUESTS'] != $_POST['id'])))) {
  592. @
  593.  
  594.  
  595. 1.4
  596. log
  597. @*** empty log message ***
  598. @
  599. text
  600. @d12 1
  601. a12 1
  602. // Modified:     September 03, 2003
  603. d40 1
  604. a40 1
  605. if (!session_is_registered("ADMIN")) {
  606. d168 1
  607. a168 1
  608. (session_is_registered("NODUP_REQUESTS")) &&
  609. d180 1
  610. a180 1
  611.     if (session_is_registered("NODUP_REQUESTS")) {
  612. d182 1
  613. a182 1
  614.         session_unregister("NODUP_REQUESTS");
  615. d238 1
  616. a238 3
  617.             $NODUP_REQUESTS = $_POST['id'];
  618.  
  619.             session_register("NODUP_REQUESTS");
  620. d273 2
  621. a274 2
  622.     (!session_is_registered("NODUP_REQUESTS") || 
  623.     ((session_is_registered("NODUP_REQUESTS")) && 
  624. d277 1
  625. a277 1
  626.         if (session_is_registered("NODUP_REQUESTS")) {
  627. d279 1
  628. a279 1
  629.             session_unregister("NODUP_REQUESTS");
  630. d304 1
  631. a304 3
  632.                 $NODUP_REQUESTS = $_POST['id'];
  633.  
  634.                 session_register("NODUP_REQUESTS");
  635. @
  636.  
  637.  
  638. 1.3
  639. log
  640. @*** empty log message ***
  641. @
  642. text
  643. @d12 1
  644. a12 1
  645. // Modified:     September 01, 2003
  646. d47 1
  647. a47 1
  648. if (session_is_registered("NODUP_DELETE_REQUEST")) {
  649. d49 1
  650. a49 1
  651.     session_unregister("NODUP_DELETE_REQUEST");
  652. d51 3
  653. a53 1
  654.     $web->redirect("admin.php");    
  655. d56 5
  656. a60 1
  657. d62 3
  658. a64 1
  659. $indonesia = new Indonesia();
  660. d66 1
  661. a66 1
  662. $status = $indonesia->get_dictionary_status();
  663. d68 2
  664. a69 1
  665. if ($status["status"] == 1 || $status["status"] == 2) {
  666. d71 3
  667. a73 1
  668.     $web->redirect("admin.php");
  669. a74 1
  670.  
  671. d79 1
  672. a79 1
  673. Bahasa Indonesia Dictionary: Request Entries
  674. d81 81
  675. d164 1
  676. a164 1
  677. <h2>Bahasa Indonesia Dictionary: Request Entries</h2>
  678. d167 17
  679. a183 1
  680. if (isset($_POST['delete_entry'])) {
  681. d186 1
  682. a186 1
  683.     $indonesia->delete_request($_POST['delete_entry']);
  684. d190 1
  685. a190 1
  686.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  687. d194 3
  688. a196 1
  689.         print "<br><hr><b>Successful deletion!</b><hr><br>\n";
  690. d198 1
  691. a198 1
  692.         $NODUP_DELETE_REQUEST = 1;
  693. d200 67
  694. a266 1
  695.         session_register("NODUP_DELETE_REQUEST");
  696. d269 9
  697. a277 1
  698. } else {
  699. d279 33
  700. a311 1
  701.     show_requests($web, $indonesia);
  702. d313 3
  703. d325 2
  704. d338 1
  705. a338 1
  706.         "<br><hr><b>Found ${total_requests} requested " .
  707. d346 25
  708. a370 1
  709.         print 
  710. d372 1
  711. a372 1
  712.         "border=\"1\" width=\"50%\">\n"; 
  713. d383 2
  714. a384 2
  715.                 "<th>POS</th>\n" .
  716.                 "<th>Spelling Flag</th>\n" .
  717. d388 9
  718. a396 1
  719.                 "<th>Delete</th>\n" .
  720. d401 1
  721. a401 1
  722.             $web->tohtml($requests[$i]->pkey);
  723. d404 1
  724. a404 1
  725.             $web->tohtml($requests[$i]->english);
  726. d407 1
  727. a407 1
  728.             $web->tohtml($requests[$i]->indonesian);
  729. d410 1
  730. a410 1
  731.             $web->tohtml($requests[$i]->part_of_speech);
  732. d413 1
  733. a413 1
  734.             $web->tohtml($requests[$i]->spelling_flag);
  735. d416 1
  736. a416 1
  737.             $web->tohtml($requests[$i]->comments);
  738. d419 1
  739. a419 1
  740.             $web->tohtml($requests[$i]->created);
  741. d431 2
  742. a432 6
  743.             "<form name=\"insert\" action=\"insert.php\" " . 
  744.             "method=\"post\">\n" .
  745.             "<input type=\"submit\" value=\"Insert!\">\n" .
  746.             "<input type=\"hidden\" " .
  747.             "name=\"insert_request_entry\" " .
  748.             "value=\"${pkey}\"></form>\n" .
  749. d434 3
  750. a436 5
  751.             "<td>\n" .
  752.             "<form name=\"delete\" method=\"post\">\n" .
  753.             "<input type=\"submit\" value=\"Delete!\">\n" .
  754.             "<input type=\"hidden\" name=\"delete_entry\" " .
  755.             "value=\"${pkey}\"></form>\n" .
  756. d440 6
  757. a445 1
  758.         print "</table>\n";
  759. d451 1
  760. @
  761.  
  762.  
  763. 1.2
  764. log
  765. @*** empty log message ***
  766. @
  767. text
  768. @d12 1
  769. a12 1
  770. // Modified:     August 19, 2003
  771. d117 3
  772. a119 1
  773.         print "<h3>Found ${total_requests} requests</h3>\n";
  774. @
  775.  
  776.  
  777. 1.1
  778. log
  779. @Initial revision
  780. @
  781. text
  782. @d5 33
  783. a37 1
  784.  
  785. @
  786.  
  787.  
  788. 1.1.1.1
  789. log
  790. @Bahasa Indonesia Dictionary
  791. @
  792. text
  793. @@
  794.