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 < prev    next >
PHP Script  |  2003-08-12  |  3KB  |  166 lines

  1. <?
  2. session_start();
  3. require_once("../php/Indonesia.php");
  4. require_once("../php/Web.php");
  5.  
  6. $web = new Web(); 
  7.  
  8. if (!session_is_registered("ADMIN")) {
  9.  
  10.     $web->redirect("login.php");
  11.  
  12.     exit;
  13. }
  14.  
  15. if (session_is_registered("NODUP_DELETE_REQUEST")) {
  16.  
  17.     session_unregister("NODUP_DELETE_REQUEST");
  18.  
  19.     $web->redirect("admin.php");    
  20.  
  21.     exit;
  22.  
  23. $indonesia = new Indonesia();
  24.  
  25. $status = $indonesia->get_dictionary_status();
  26.  
  27. if ($status["status"] == 1 || $status["status"] == 2) {
  28.  
  29.     $web->redirect("admin.php");
  30. }
  31.  
  32. ?>
  33. <html>
  34. <head>
  35. <title>
  36. Bahasa Indonesia Dictionary: Request Entries
  37. </title>
  38. </head>
  39. <body>
  40. <h2>Bahasa Indonesia Dictionary: Request Entries</h2>
  41. <a href="admin.php">Administration</a>
  42. <?
  43. if (isset($_POST['delete_entry'])) {
  44.  
  45.     $errstr = 
  46.     $indonesia->delete_request($_POST['delete_entry']);
  47.  
  48.     if ($errstr != "") {
  49.  
  50.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  51.  
  52.     } else {
  53.  
  54.         print "<br><hr><b>Successful deletion!</b><hr><br>\n";
  55.  
  56.         $NODUP_DELETE_REQUEST = 1;
  57.  
  58.         session_register("NODUP_DELETE_REQUEST");
  59.     }
  60.  
  61. } else {
  62.  
  63.     show_requests($web, $indonesia);
  64. }
  65. ?>
  66. </body>
  67. </html>
  68. <?
  69. //////////////////////////////////////////////////////////////////////////////
  70. function show_requests($web, $indonesia) {
  71.  
  72.     $requests = array();
  73.  
  74.     $errstr = $indonesia->get_requests($requests);
  75.  
  76.     if ($errstr != "") {
  77.  
  78.         print "<hr><br><b>${errstr}</b><hr><br>\n";
  79.  
  80.     } else {
  81.  
  82.         $total_requests = count($requests);
  83.  
  84.         print "<h3>Found ${total_requests} requests</h3>\n";
  85.  
  86.         if ($total_requests == 0) {
  87.  
  88.             return;
  89.         }
  90.  
  91.         print 
  92.         "<table cellpadding=\"3\" cellspacing=\"3\" " .
  93.         "border=\"1\" width=\"50%\">\n"; 
  94.  
  95.         for($i = 0; $i < $total_requests; $i++) {
  96.  
  97.             if ($i == 0) {
  98.  
  99.                 print 
  100.                 "<tr>\n" .
  101.                 "<th>PKEY</th>\n" .
  102.                 "<th>English</th>\n" .
  103.                 "<th>Indonesian</th>\n" .
  104.                 "<th>POS</th>\n" .
  105.                 "<th>Spelling Flag</th>\n" .
  106.                 "<th>Comments</th>\n" .
  107.                 "<th>Created</th>\n" .
  108.                 "<th>Insert</th>\n" .
  109.                 "<th>Delete</th>\n" .
  110.                 "</tr>\n";
  111.             }
  112.  
  113.             $pkey = 
  114.             $web->tohtml($requests[$i]->pkey);
  115.  
  116.             $english = 
  117.             $web->tohtml($requests[$i]->english);
  118.  
  119.             $indonesian = 
  120.             $web->tohtml($requests[$i]->indonesian);
  121.  
  122.             $pos = 
  123.             $web->tohtml($requests[$i]->part_of_speech);
  124.  
  125.             $spl = 
  126.             $web->tohtml($requests[$i]->spelling_flag);
  127.  
  128.             $comments = 
  129.             $web->tohtml($requests[$i]->comments);
  130.  
  131.             $created = 
  132.             $web->tohtml($requests[$i]->created);
  133.  
  134.             print 
  135.             "<tr>\n" .
  136.             "<td>${pkey} </td>\n" .
  137.             "<td>${english} </td>\n" .
  138.             "<td>${indonesian} </td>\n" .
  139.             "<td>${pos} </td>\n" .
  140.             "<td>${spl} </td>\n" .
  141.             "<td>${comments} </td>\n" .
  142.             "<td>${created} </td>\n" .
  143.             "<td>\n" .
  144.             "<form name=\"insert\" action=\"insert.php\" " . 
  145.             "method=\"post\">\n" .
  146.             "<input type=\"submit\" value=\"Insert!\">\n" .
  147.             "<input type=\"hidden\" " .
  148.             "name=\"insert_request_entry\" " .
  149.             "value=\"${pkey}\"></form>\n" .
  150.             "</td>\n" .
  151.             "<td>\n" .
  152.             "<form name=\"delete\" method=\"post\">\n" .
  153.             "<input type=\"submit\" value=\"Delete!\">\n" .
  154.             "<input type=\"hidden\" name=\"delete_entry\" " .
  155.             "value=\"${pkey}\"></form>\n" .
  156.             "</tr>\n";
  157.         }
  158.  
  159.         print "</table>\n";
  160.     }
  161.  
  162.     return;
  163. }
  164. ?>
  165.