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 / dictionary.php,v < prev    next >
Text File  |  2003-10-20  |  11KB  |  630 lines

  1. head    1.6;
  2. access;
  3. symbols
  4.     Initial:1.1.1.1 bule:1.1.1;
  5. locks; strict;
  6. comment    @# @;
  7.  
  8.  
  9. 1.6
  10. date    2003.10.20.00.21.45;    author bule;    state Exp;
  11. branches;
  12. next    1.5;
  13.  
  14. 1.5
  15. date    2003.10.18.00.33.41;    author bule;    state Exp;
  16. branches;
  17. next    1.4;
  18.  
  19. 1.4
  20. date    2003.10.06.00.39.26;    author bule;    state Exp;
  21. branches;
  22. next    1.3;
  23.  
  24. 1.3
  25. date    2003.10.01.06.51.29;    author bule;    state Exp;
  26. branches;
  27. next    1.2;
  28.  
  29. 1.2
  30. date    2003.08.19.06.42.07;    author bule;    state Exp;
  31. branches;
  32. next    1.1;
  33.  
  34. 1.1
  35. date    2003.08.12.19.18.23;    author bule;    state Exp;
  36. branches
  37.     1.1.1.1;
  38. next    ;
  39.  
  40. 1.1.1.1
  41. date    2003.08.12.19.18.23;    author bule;    state Exp;
  42. branches;
  43. next    ;
  44.  
  45.  
  46. desc
  47. @@
  48.  
  49.  
  50. 1.6
  51. log
  52. @*** empty log message ***
  53. @
  54. text
  55. @<?
  56. session_start();
  57. require_once("../php/Indonesia.php");
  58. require_once("../php/Web.php");
  59. //////////////////////////////////////////////////////////////////////////////
  60. //////////////////////////////////////////////////////////////////////////////
  61. // Project Name: Bahasa Indonesia Dictionary
  62. // Directory:    bahasa/web
  63. // File Name:    dictionary.php
  64. // Author(s):    John L. Whiteman
  65. // Created:      June 23, 2003  
  66. // Modified:     October 19, 2003
  67. // Description:  The purpose of this restricted access PHP web 
  68. //               client page is provide major table operations 
  69. //               against the dictionary database, like create,
  70. //               recreate, and delete table operations. 
  71. // 
  72. // Copyright (c) 2003 John L. Whiteman
  73. //
  74. // Permission is herby granted, free of charge, to any person obtaining a 
  75. // copy of this software, data, and associated documentation files 
  76. // (the "Software"), to deal in the Software without restriction, 
  77. // including without limitation the rights to use, copy, modify, merge, 
  78. // publish, distribute, sublicense, and/or sell copies of Software, and to
  79. // permit persons to whom the Software is furnished to do so, subject to 
  80. // the following conditions:
  81. //
  82. // The above copyright notice and this permission notice shall be 
  83. // included in all copies or substantial portions of the Software.
  84. //
  85. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  86. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  87. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  88. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  89. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  90. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  91. //////////////////////////////////////////////////////////////////////////////
  92. //////////////////////////////////////////////////////////////////////////////
  93. $web = new Web();
  94.  
  95. if (
  96. (!$_SESSION['ADMIN']) &&
  97. (!$_SESSION['DB_ADMIN'])) { 
  98.  
  99.     $web->redirect("login.php");
  100.  
  101.     exit;
  102. }
  103.  
  104. if ($_SESSION['NODUP_DICTIONARY']) {
  105.  
  106.     unset($_SESSION['NODUP_DICTIONARY']);
  107.  
  108.     $web->redirect("admin.php");
  109.  
  110.     exit;
  111. }
  112.  
  113. if (
  114. (!isset($_POST['create'])) && 
  115. (!isset($_POST['destroy'])) && 
  116. (!isset($_POST['recreate'])) && 
  117. (!isset($_POST['password']))) {
  118.  
  119.     $web->redirect("admin.php");
  120.  
  121.     exit;
  122.  
  123. $indonesia = new Indonesia();
  124.  
  125. $status = $indonesia->get_dictionary_status();
  126.  
  127. if ($status["status"] == 1) {
  128.  
  129.     $web->redirect("admin.php");
  130.  
  131.     exit;
  132. }
  133.  
  134. $is_initialized = 0;
  135.  
  136. if (
  137. $status["status"] == 0 || 
  138. $status["status"] == 3 || 
  139. $status["status"] == 4) {
  140.  
  141.     $is_initialized = 1;
  142. }
  143.  
  144. $title = "Create Dictionary";
  145.  
  146. //Can't destroy because never created 
  147. if (isset($_POST['destroy'])) {
  148.     
  149.     if (!$is_initialized) {
  150.  
  151.         $web->redirect("admin.php");
  152.  
  153.         exit;
  154.     }
  155.  
  156.     $title = "Destroy Dictionary";
  157.  
  158. //Can't recreate because never created 
  159. if (isset($_POST['recreate'])) {
  160.     
  161.     if (!$is_initialized) {
  162.  
  163.         $web->redirect("admin.php");
  164.  
  165.         exit;
  166.     }
  167.  
  168.     $title = "Recreate Dictionary";
  169. ?>
  170. <html>
  171. <head>
  172. <title>Bahasa Indonesia Dictionary: <? echo ${title};?></title>
  173.  
  174. <link href="bahasa.css" rel="stylesheet" type="text/css">
  175.  
  176. <script type="text/javascript" src="bahasa.js"></script>
  177.  
  178. <script language="Javascript" type="text/javascript">
  179. <!--
  180. //////////////////////////////////////////////////////////////////////////////
  181. function verify() {
  182.  
  183.     var name = document.dictionary.name.value;
  184.  
  185.     name = trim(name);
  186.  
  187.     if (is_white_space(name)) {
  188.  
  189.         alert("You must enter your name.");
  190.  
  191.         document.dictionary.name.focus();
  192.  
  193.         return(false);
  194.     }
  195.  
  196.     var password = document.dictionary.password.value;
  197.  
  198.     if (is_white_space(password)) {
  199.  
  200.         alert("You must enter your password.");
  201.  
  202.         document.dictionary.password.focus();
  203.  
  204.         return(false);
  205.     }
  206.  
  207.     return(true);
  208. }
  209. //////////////////////////////////////////////////////////////////////////////
  210. // -->
  211. </script>
  212.  
  213. </head>
  214. <body>
  215. <?
  216. $web->show_logo("$title");
  217. ?>
  218.  
  219. <a href="admin.php">Administration</a>
  220. <br><br>
  221.  
  222. <?
  223.  
  224.     if (!isset($_POST['password'])) {
  225.  
  226.         if (isset($_POST['destroy'])) {
  227.  
  228.             show_destroy($indonesia);
  229.  
  230.         } else if (isset($_POST['recreate'])) {
  231.  
  232.             show_recreate($indonesia);
  233.  
  234.         } else if (isset($_POST['create'])) {
  235.  
  236.             show_create($indonesia);
  237.  
  238.         //Should never reach here, but just in case
  239.         } else {
  240.  
  241.             print 
  242.             "This option is not supported.<br>\n" .
  243.             "Please go to " .
  244.             "<a href=\"admin.php\">Administration</a>" .
  245.             " to see what is available.";
  246.         }
  247.  
  248.     } else if ((isset($_POST['name'])) && (isset($_POST['password']))) {  
  249.  
  250.         if (isset($_POST['destroy'])) {
  251.  
  252.             $errstr =
  253.             $indonesia->login_db_user(
  254.             $_POST['name'], $_POST['password']);
  255.  
  256.             if ($errstr != "") {
  257.  
  258.                 show_destroy($indonesia);
  259.  
  260.                 print "<br><hr><b>${errstr}</b><hr><br>\n"; 
  261.  
  262.             } else {
  263.  
  264.                 $errstr = 
  265.                 $indonesia->destroy_dictionary();
  266.  
  267.                 if ($errstr != "") {
  268.  
  269.                     print 
  270.                     "<br><b>ERROR:</b><br>\n" .
  271.                     "${errstr}<br>";
  272.  
  273.                 } else {
  274.  
  275.                     print 
  276.                     "<br><b>SUCCESS:</b><br>\n" .
  277.                     "Dictionary tables and data " .
  278.                     "destroyed!<br>" .
  279.                     "Please log back in as " .
  280.                     "database administrator.";
  281.  
  282.                     $_SESSION['NODUP_DICTIONARY'] = 1;
  283.  
  284.                     unset($_SESSION['ADMIN']);
  285.                 }
  286.             }
  287.  
  288.         } else if (isset($_POST['recreate'])) {
  289.  
  290.             $errstr =
  291.             $indonesia->login_db_user(
  292.             $_POST['name'], $_POST['password']);
  293.  
  294.             if ($errstr != "") {
  295.  
  296.                 show_recreate($indonesia);
  297.  
  298.                 print "<br><hr><b>${errstr}</b><hr><br>\n"; 
  299.  
  300.             } else {
  301.  
  302.                 $errstr = 
  303.                 $indonesia->create_dictionary();
  304.  
  305.                 if ($errstr != "") {
  306.  
  307.                     print 
  308.                     "<br><b>ERROR:</b><br>\n" .
  309.                     "${errstr}<br>";
  310.  
  311.                 } else {
  312.  
  313.                     print 
  314.                     "<br><b>SUCCESS:</b><br>\n" .
  315.                     "Dictionary tables and data " .
  316.                     "recreated!<br>";
  317.  
  318.                     $_SESSION['NODUP_DICTIONARY'] = 1;
  319.                 }
  320.             }
  321.  
  322.  
  323.         } else if (isset($_POST['create'])) {
  324.  
  325.             $errstr =
  326.             $indonesia->login_db_user(
  327.             $_POST['name'], $_POST['password']);
  328.  
  329.             if ($errstr != "") {
  330.  
  331.                 show_create($indonesia);
  332.  
  333.                 print "<br><hr><b>${errstr}</b><hr><br>\n"; 
  334.  
  335.             } else {
  336.  
  337.                 $errstr = 
  338.                 $indonesia->create_dictionary();
  339.  
  340.                 if ($errstr != "") {
  341.  
  342.                     print 
  343.                     "<br><b>ERROR:</b><br>\n" .
  344.                     "${errstr}<br>";
  345.  
  346.                 } else {
  347.  
  348.                     print 
  349.                     "<br><b>SUCCESS:</b><br>\n" .
  350.                     "Dictionary tables and data " .
  351.                     "created!<br>" .
  352.                     "Please log back in as an " .
  353.                     "administrator.";
  354.  
  355.                     $_SESSION['NODUP_DICTIONARY'] = 1;
  356.  
  357.                     unset($_SESSION['DB_ADMIN']);
  358.                 }
  359.             }
  360.  
  361.         //Should never reach here, but just in case
  362.         } else {
  363.  
  364.             print 
  365.             "This option is not supported.<br>\n" .
  366.             "Please go to " .
  367.             "<a href=\"admin.php\">Administration</a>" .
  368.             " to see what is available.";
  369.         }
  370.     }
  371. ?>
  372.  
  373. </body>
  374. </html>
  375.  
  376. <?
  377. function show_create($indonesia) {
  378.  
  379.     print <<<EOFSC
  380. <b>WARNING:</b><br>
  381. This operation will create the default tables and data
  382. in the dictionary database.<br>
  383. It assumes that you already created a database and 
  384. configured the Dictionary.pm class module properly.<br>
  385. See project documentation for more details if you are not sure.
  386. <form name="dictionary" method="post" onsubmit="return verify()">
  387. <table cellpadding="3" cellspacing="3" border="0">
  388. <tr>
  389. <td>
  390. <input type="submit" value="Create Dictionary"> 
  391. </td>
  392. <td>
  393. Name:
  394. </td>
  395. <td>
  396. <input type="text" name="name"> 
  397. </td>
  398. <td>
  399. Password:
  400. </td>
  401. <td>
  402. <input type="password" name="password">
  403. </td>
  404. </tr>
  405. </table> 
  406. <input type="hidden" name="create" value="1">
  407. <input type="hidden" name="create_flag" value="1">
  408. </form>
  409. EOFSC;
  410.  
  411.     return;
  412. }
  413.  
  414. function show_destroy($indonesia) {
  415.  
  416.     print <<<EOFSD
  417. <b>WARNING:</b><br>
  418. All tables and data in the dictionary database will be  
  419. permanently destroyed.<br>
  420. If new data has been inserted into the dictionary since 
  421. it was last created,<br>then you should  
  422. <a href="backup.php">backup</a>
  423. the dictionary before proceeding with this operation.
  424. <form name="dictionary" method="post" onsubmit="return verify()">
  425. <table cellpadding="3" cellspacing="3" border="0">
  426. <tr>
  427. <td>Name:</td>
  428. <td>
  429. <input type="text" name="name">
  430. </td>
  431. <td>
  432. Password:
  433. </td>
  434. <td>
  435. <input type="password" name="password">
  436. </td>
  437. </tr><tr>
  438. <td colspan="4" align="right">
  439. <input type="submit" value="Destroy Dictionary!">
  440. </td>
  441. </tr>
  442. </table> 
  443. <input type="hidden" name="destroy" value="1">
  444. </form>
  445. <script language="Javascript" type="text/javascript">
  446. document.dictionary.name.focus();
  447. </script>
  448. EOFSD;
  449.  
  450.     return;
  451. }
  452.  
  453. function show_recreate($indonesia) {
  454.  
  455.     print <<<EOFSR
  456. <b>WARNING:</b><br>
  457. All tables and data in the dictionary database will be  
  458. permanently destroyed.<br>
  459. If new data has been inserted into the dictionary since 
  460. it was last created,<br>then you should  
  461. <a href="backup.php">backup</a>
  462. the dictionary before proceeding with this operation.
  463. <form name="dictionary" method="post" onsubmit="return verify()">
  464. <table cellpadding="3" cellspacing="3" border="0">
  465. <tr>
  466. <td>
  467. Name:
  468. </td>
  469. <td>
  470. <input type="text" name="name">
  471. </td>
  472. <td>
  473. Password:
  474. </td>
  475. <td>
  476. <input type="password" name="password">
  477. </td>
  478. </tr><tr>
  479. <td colspan="4" align="right">
  480. <input type="submit" value="Recreate Dictionary!">
  481. </td>
  482. </tr>
  483. </table> 
  484. <input type="hidden" name="recreate" value="1">
  485. </form>
  486. <script language="Javascript" type="text/javascript">
  487. document.dictionary.name.focus();
  488. </script>
  489. EOFSR;
  490.  
  491.     return;
  492. }
  493. ?>
  494. @
  495.  
  496.  
  497. 1.5
  498. log
  499. @*** empty log message ***
  500. @
  501. text
  502. @d12 1
  503. a12 1
  504. // Modified:     October 17, 2003
  505. d122 2
  506. @
  507.  
  508.  
  509. 1.4
  510. log
  511. @*** empty log message ***
  512. @
  513. text
  514. @d12 1
  515. a12 1
  516. // Modified:     October 05, 2003
  517. d121 3
  518. a123 3
  519. <title>
  520. Bahasa Indonesia Dictionary: <? echo ${title};?> 
  521. </title>
  522. d126 2
  523. a127 26
  524.  
  525. function is_white_space(stoken) {
  526.  
  527.     if (stoken == null) return(true);
  528.  
  529.     if (stoken == '') return(true);
  530.  
  531.     if (stoken == "") return(true); 
  532.  
  533.     return(false);
  534. }
  535.  
  536. function trim(stoken) {
  537.  
  538.     if (is_white_space(stoken)) {
  539.  
  540.         return(stoken) 
  541.     }
  542.  
  543.     stoken = stoken.replace(/^\s*/, "");
  544.  
  545.     stoken = stoken.replace(/\s*&/, ""); 
  546.     
  547.     return(token);
  548. }
  549.  
  550. d156 2
  551. @
  552.  
  553.  
  554. 1.3
  555. log
  556. @*** empty log message ***
  557. @
  558. text
  559. @d12 1
  560. a12 1
  561. // Modified:     September 30, 2003
  562. d184 3
  563. a186 1
  564. <h2>Bahasa Indonesia Dictionary: <? echo ${title};?></h2>
  565. @
  566.  
  567.  
  568. 1.2
  569. log
  570. @*** empty log message ***
  571. @
  572. text
  573. @d12 1
  574. a12 1
  575. // Modified:     August 18, 2003
  576. d42 2
  577. a43 2
  578. (!session_is_registered("ADMIN")) &&
  579. (!session_is_registered("DB_ADMIN"))) { 
  580. d50 1
  581. a50 1
  582. if (session_is_registered("NODUP_DICTIONARY")) {
  583. d52 1
  584. a52 1
  585.     session_unregister("NODUP_DICTIONARY");
  586. d249 1
  587. a249 1
  588.                     $NODUP_DICTIONARY = 1;
  589. d251 1
  590. a251 3
  591.                     session_register("NODUP_DICTIONARY");
  592.  
  593.                     session_unregister("ADMIN");
  594. d285 1
  595. a285 3
  596.                     $NODUP_DICTIONARY = 1;
  597.  
  598.                     session_register("NODUP_DICTIONARY");
  599. d322 1
  600. a322 3
  601.                     $NODUP_DICTIONARY = 1;
  602.  
  603.                     session_register("NODUP_DICTIONARY");
  604. d324 1
  605. a324 1
  606.                     session_unregister("DB_ADMIN");
  607. @
  608.  
  609.  
  610. 1.1
  611. log
  612. @Initial revision
  613. @
  614. text
  615. @d5 34
  616. a38 1
  617.  
  618. @
  619.  
  620.  
  621. 1.1.1.1
  622. log
  623. @Bahasa Indonesia Dictionary
  624. @
  625. text
  626. @@
  627.