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 / request.php,v < prev    next >
Text File  |  2003-10-26  |  12KB  |  662 lines

  1. head    1.10;
  2. access;
  3. symbols
  4.     Initial:1.1.1.1 bule:1.1.1;
  5. locks; strict;
  6. comment    @# @;
  7.  
  8.  
  9. 1.10
  10. date    2003.10.26.01.53.10;    author bule;    state Exp;
  11. branches;
  12. next    1.9;
  13.  
  14. 1.9
  15. date    2003.10.20.00.21.46;    author bule;    state Exp;
  16. branches;
  17. next    1.8;
  18.  
  19. 1.8
  20. date    2003.10.18.00.33.42;    author bule;    state Exp;
  21. branches;
  22. next    1.7;
  23.  
  24. 1.7
  25. date    2003.10.17.00.39.36;    author bule;    state Exp;
  26. branches;
  27. next    1.6;
  28.  
  29. 1.6
  30. date    2003.10.06.00.39.27;    author bule;    state Exp;
  31. branches;
  32. next    1.5;
  33.  
  34. 1.5
  35. date    2003.10.01.06.51.29;    author bule;    state Exp;
  36. branches;
  37. next    1.4;
  38.  
  39. 1.4
  40. date    2003.09.11.05.28.22;    author bule;    state Exp;
  41. branches;
  42. next    1.3;
  43.  
  44. 1.3
  45. date    2003.09.04.07.27.00;    author bule;    state Exp;
  46. branches;
  47. next    1.2;
  48.  
  49. 1.2
  50. date    2003.08.19.19.24.21;    author bule;    state Exp;
  51. branches;
  52. next    1.1;
  53.  
  54. 1.1
  55. date    2003.08.12.19.18.23;    author bule;    state Exp;
  56. branches
  57.     1.1.1.1;
  58. next    ;
  59.  
  60. 1.1.1.1
  61. date    2003.08.12.19.18.23;    author bule;    state Exp;
  62. branches;
  63. next    ;
  64.  
  65.  
  66. desc
  67. @@
  68.  
  69.  
  70. 1.10
  71. log
  72. @*** empty log message ***
  73. @
  74. text
  75. @<?
  76. session_start();
  77. require_once("../php/Indonesia.php");
  78. require_once("../php/Web.php");
  79. //////////////////////////////////////////////////////////////////////////////
  80. //////////////////////////////////////////////////////////////////////////////
  81. // Project Name: Bahasa Indonesia Dictionary
  82. // Directory:    bahasa/web
  83. // File Name:    request.php
  84. // Author(s):    John L. Whiteman
  85. // Created:      June 23, 2003  
  86. // Modified:     October 20, 2003
  87. // Description:  The purpose of this unrestricted access PHP web 
  88. //               client page is to allow the client to request a 
  89. //               new entry be placed in the dictionary. 
  90. // 
  91. // Copyright (c) 2003 John L. Whiteman
  92. //
  93. // Permission is herby granted, free of charge, to any person obtaining a 
  94. // copy of this software, data, and associated documentation files 
  95. // (the "Software"), to deal in the Software without restriction, 
  96. // including without limitation the rights to use, copy, modify, merge, 
  97. // publish, distribute, sublicense, and/or sell copies of Software, and to
  98. // permit persons to whom the Software is furnished to do so, subject to 
  99. // the following conditions:
  100. //
  101. // The above copyright notice and this permission notice shall be 
  102. // included in all copies or substantial portions of the Software.
  103. //
  104. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  105. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  106. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  107. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  108. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  109. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  110. //////////////////////////////////////////////////////////////////////////////
  111. //////////////////////////////////////////////////////////////////////////////
  112. $web = new Web();
  113.  
  114. $indonesia = new Indonesia();
  115.  
  116. $status = $indonesia->get_dictionary_status();
  117.  
  118. if (
  119. ($status["status"] == 1) ||
  120. ($status["status"] == 2) || 
  121. ($status["status"] == 3)) {
  122.  
  123.     $web->redirect("offline.php");
  124.  
  125.     exit;
  126. }
  127.  
  128. ?>
  129. <html>
  130. <head>
  131. <title>Bahasa Indonesia Dictionary: Request a New Word</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() {
  141.  
  142.     english = document.request.english.value;
  143.  
  144.     english = trim(english);
  145.  
  146.     if (english.length > 255) {
  147.  
  148.         alert(
  149.         "The English value must be 255 characters or less!");
  150.  
  151.         document.request.english.focus();
  152.  
  153.         return(false);
  154.     }
  155.  
  156.     indonesian = document.request.indonesian.value;
  157.  
  158.     indonesian = trim(indonesian);
  159.  
  160.     if (indonesian.length > 255) {
  161.  
  162.         alert(
  163.         "The Indonesian value must be 255 characters or less!");
  164.  
  165.         document.request.indonesian.focus();
  166.  
  167.         return(false);
  168.     }
  169.  
  170.     if ((english == "") && (indonesian =="")) {
  171.  
  172.         alert(
  173.         "You must specify at least an English or Indonesian " + 
  174.         "value!");
  175.  
  176.         document.request.english.focus();
  177.  
  178.         return(false);
  179.     } 
  180.  
  181.     return(true);
  182. }
  183. //////////////////////////////////////////////////////////////////////////////
  184. // -->
  185. </script>
  186. </head>
  187. <body>
  188. <?
  189. $web->show_logo("Request a New Word");
  190. ?>
  191.  
  192. <a class="menu" href="search.php">Search Dictionary</a>
  193.  | 
  194. <a class="menu" href="reference.php">Reference</a>
  195.  | 
  196. <a class="menu" href="email.php">Send Us E-mail</a>
  197.  | 
  198. <a class="menu" href="admin.php">Administration</a>
  199. <hr>
  200. <b>
  201. If you didn't find a word or phrase that you were looking for in the 
  202. dictionary,<br>
  203. then use this form to submit a request for it to be added.
  204.   Terima Kasih!
  205. </b>
  206. <hr>
  207. <?
  208. if (
  209. ($_SESSION['NODUP_REQUESTS']) &&
  210. (isset($_POST['id'])) &&
  211. ($_SESSION['NODUP_REQUESTS'] == $_POST['id'])) {
  212.  
  213.     //Do nothing...prevents refresh duplication of last action
  214.  
  215. } else if (
  216. (isset($_POST['english'])) &&
  217. (isset($_POST['indonesian'])) &&
  218. (isset($_POST['spelling_flag'])) &&
  219. (isset($_POST['id'])) &&
  220. (isset($_POST['part_of_speech'])) && 
  221. (isset($_POST['comments']))) {
  222.  
  223.     if ($_SESSION['NODUP_REQUESTS']) {
  224.  
  225.         unset($_SESSION['NODUP_REQUESTS']);
  226.     }
  227.  
  228.     $errstr = 
  229.     $indonesia->insert_request(
  230.     $_POST['english'], $_POST['indonesian'], 
  231.     $_POST['spelling_flag'], $_POST['part_of_speech'],
  232.     $_POST['comments']);
  233.  
  234.     if ($errstr != "") {
  235.  
  236.         print "<hr><b>${errstr}</b><hr><br>\n";
  237.  
  238.  
  239.     } else {
  240.  
  241.         print 
  242.         "<hr><b>Your request has been submitted!" .
  243.         "</b><hr>"; 
  244.  
  245.         $_SESSION['NODUP_REQUESTS'] = $_POST['id'];
  246.     }
  247. }
  248.  
  249. show_request_form($web, $indonesia);
  250.  
  251. $web->show_footer();
  252. ?>
  253. </body>
  254. </html>
  255. <?
  256. //////////////////////////////////////////////////////////////////////////////
  257. function show_request_form($web, $indonesia) {
  258.  
  259.     $pos = array();
  260.  
  261.     $id = uniqid(rand(), true);
  262.  
  263.     $pos_select =
  264.     "<select name=\"part_of_speech\">\n";
  265.  
  266.     $errstr = $indonesia->get_parts_of_speech($pos);
  267.  
  268.     $pos_help =
  269.     "<table cellpadding=\"3\" cellspacing=\"3\" border=\"1\">\n" .
  270.     "<tr>\n" .
  271.     "<th>Part of Speech</th>\n" .
  272.     "<th>Description</th>\n" .
  273.     "</tr>\n";
  274.  
  275.     $total_pos = count($pos);
  276.  
  277.     for($i = 0; $i < $total_pos; $i++) {
  278.  
  279.         $part_of_speech = 
  280.         $web->tohtml($pos[$i]["part_of_speech"]);
  281.  
  282.         $description = 
  283.         $web->tohtml($pos[$i]["description"]);
  284.  
  285.         $pkey = 
  286.         $web->tohtml($pos[$i]["pkey"]);
  287.  
  288.         if ($part_of_speech != "unknown") {
  289.  
  290.             $pos_select .=
  291.             "<option value=\"${pkey}\">${part_of_speech}\n";
  292.  
  293.         } else {
  294.  
  295.             $pos_select .=
  296.             "<option value=\"${pkey}\" selected>" .
  297.             "${part_of_speech}\n";
  298.         }
  299.  
  300.         $pos_help .= 
  301.         "<tr>\n" .
  302.         "<td>${part_of_speech}:</td>\n" .
  303.         "<td>${description}</td>\n" .
  304.         "</tr>\n"; 
  305.     }
  306.  
  307.     $pos_select .= "</select>\n"; 
  308.  
  309.     $pos_help .= "</table>\n";
  310.  
  311.     print <<<EOFSSF
  312. <form name="request" method="post" onSubmit='return verify()'>
  313. <table cellpadding="3" cellspacing="3" border="0">
  314.  
  315. <tr>
  316. <td>English (1 to 255 characters):</td>
  317. </tr><tr>
  318. <td>
  319. <input type="text" name="english"
  320. maxlength="255" size="50">
  321. </td>
  322.  
  323. </tr><tr>
  324. <td><hr></td>
  325.  
  326. </tr><tr>
  327. <td>Indonesian (1 to 255 characters):</td>
  328. </tr><tr>
  329. <td>
  330. <input type="text" name="indonesian"
  331. maxlength="255" size="50">
  332. </td>
  333.  
  334. </tr><tr>
  335. <td><hr></td>
  336.  
  337. </tr><tr>
  338. <td>Spelling Convention:</td>
  339. </tr><tr>
  340. <td>
  341. <input type="radio" name="spelling_flag" value="1">Before 1972
  342.   
  343. <input type="radio" name="spelling_flag" value="0" checked>Modern
  344. </td>
  345.  
  346. </tr><tr>
  347. <td><hr></td>
  348.  
  349. </tr><tr>
  350. <td>Part of Speech: <a href="request.php#pos">Help</a></td>
  351. </tr><tr>
  352. <td>
  353. $pos_select
  354. </td>
  355.  
  356. </tr><tr>
  357. <td><hr></td>
  358.  
  359. </tr><tr>
  360. <td>Comments:</td>
  361. </tr><tr>
  362. <td>
  363. <textarea name="comments" wrap="soft" rows="5" cols="55"></textarea>
  364. </td>
  365.  
  366. </tr><tr>
  367. <td><hr></td>
  368.  
  369. </tr><tr>
  370. <td align="right">
  371. <input type="reset" value="Clear Form">
  372.   
  373. <input type="submit" value="Send Request!"> 
  374. </td>
  375.  
  376. </tr>
  377. </table>
  378. <input type="hidden" name="id" value="${id}">
  379. </form>
  380.  
  381. <script language="Javascript" type="text/javascript">
  382. document.request.english.focus();
  383. </script>
  384.  
  385. <hr>
  386. <a name="pos"><h3>Parts of Speech Definitions</h3>
  387. <hr>
  388. $pos_help
  389. <hr>
  390. EOFSSF;
  391.  
  392.     return;
  393. }
  394. //////////////////////////////////////////////////////////////////////////////
  395. //////////////////////////////////////////////////////////////////////////////
  396. ?>
  397. @
  398.  
  399.  
  400. 1.9
  401. log
  402. @*** empty log message ***
  403. @
  404. text
  405. @d12 1
  406. a12 1
  407. // Modified:     October 19, 2003
  408. d118 1
  409. a118 1
  410. <a href="search.php">Search Dictionary</a>
  411. d120 1
  412. a120 1
  413. <a href="reference.php">Reference</a>
  414. d122 1
  415. a122 1
  416. <a href="email.php">Send Us E-mail</a>
  417. d124 1
  418. a124 1
  419. <a href="admin.php">Administration</a>
  420. @
  421.  
  422.  
  423. 1.8
  424. log
  425. @*** empty log message ***
  426. @
  427. text
  428. @d12 1
  429. a12 1
  430. // Modified:     October 17, 2003
  431. d58 2
  432. @
  433.  
  434.  
  435. 1.7
  436. log
  437. @*** empty log message ***
  438. @
  439. text
  440. @d12 1
  441. a12 1
  442. // Modified:     October 15, 2003
  443. d57 1
  444. a57 6
  445. <title>
  446. Bahasa Indonesia Dictionary: Request a New Word 
  447. </title>
  448. <script language="Javascript" type="text/javascript">
  449. //////////////////////////////////////////////////////////////////////////////
  450. function is_email(token) {
  451. d59 1
  452. a59 1
  453.     var regexp = /^\w+([\.-]?\w+)*@@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
  454. d61 2
  455. a62 29
  456.     if (regexp.test(token)) return(true);
  457.  
  458.     return(false);
  459. }
  460. //////////////////////////////////////////////////////////////////////////////
  461. function is_white_space(stoken) {
  462.  
  463.     if (stoken == null) return(true);
  464.  
  465.     if (stoken == '') return(true);
  466.  
  467.     if (stoken == "") return(true);
  468.  
  469.     return(false);
  470. }
  471. //////////////////////////////////////////////////////////////////////////////
  472. function trim(stoken) {
  473.  
  474.     if (is_white_space(stoken)) {
  475.  
  476.         return(stoken);
  477.     }
  478.  
  479.     stoken = stoken.replace(/^\s*/, "");
  480.  
  481.     stoken = stoken.replace(/\s*$/, "");
  482.  
  483.     return(stoken);
  484. }
  485. d108 1
  486. @
  487.  
  488.  
  489. 1.6
  490. log
  491. @*** empty log message ***
  492. @
  493. text
  494. @d12 1
  495. a12 1
  496. // Modified:     October 05, 2003
  497. d206 1
  498. @
  499.  
  500.  
  501. 1.5
  502. log
  503. @*** empty log message ***
  504. @
  505. text
  506. @d12 1
  507. a12 1
  508. // Modified:     September 30, 2003
  509. d143 3
  510. a145 2
  511.  
  512. <h2>Bahasa Indonesia Dictionary: Request a New Word</h2>
  513. @
  514.  
  515.  
  516. 1.4
  517. log
  518. @*** empty log message ***
  519. @
  520. text
  521. @d12 1
  522. a12 1
  523. // Modified:     September 05, 2003
  524. d163 1
  525. a163 1
  526. (session_is_registered("NODUP_REQUESTS")) &&
  527. d177 1
  528. a177 1
  529.     if (session_is_registered("NODUP_REQUESTS")) {
  530. d179 1
  531. a179 1
  532.         session_unregister("NODUP_REQUESTS");
  533. d199 1
  534. a199 3
  535.         $NODUP_REQUESTS = $_POST['id'];
  536.  
  537.         session_register("NODUP_REQUESTS");
  538. @
  539.  
  540.  
  541. 1.3
  542. log
  543. @*** empty log message ***
  544. @
  545. text
  546. @d12 1
  547. a12 1
  548. // Modified:     September 03, 2003
  549. d58 1
  550. a58 1
  551. Bahasa Indonesia Dictionary: Request a New Entry 
  552. d126 11
  553. d144 1
  554. a144 1
  555. <h2>Bahasa Indonesia Dictionary: Request a New Entry</h2>
  556. d147 14
  557. a160 1
  558.  
  559. @
  560.  
  561.  
  562. 1.2
  563. log
  564. @*** empty log message ***
  565. @
  566. text
  567. @d12 1
  568. a12 1
  569. // Modified:     August 19, 2003
  570. a39 7
  571. if (session_is_registered("NODUP_REQUEST_ENTRY")) {
  572.  
  573.     session_unregister("NODUP_REQUEST_ENTRY");
  574.  
  575.     $web->redirect("search.php");
  576. }
  577.  
  578. d135 1
  579. a135 1
  580. <a href="search.php">Search</a>
  581. d139 7
  582. d149 2
  583. a150 1
  584. (isset($_POST['pos'])) && 
  585. d153 5
  586. d161 1
  587. a161 1
  588.     $_POST['spelling_flag'], $_POST['pos'],
  589. d166 1
  590. a166 1
  591.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  592. d172 2
  593. a173 2
  594.         "<br><hr><b>Your entry has been submitted " .
  595.         "and will be reviewed!</b><hr><br>"; 
  596. d175 1
  597. a175 1
  598.         $NODUP_REQUEST_ENTRY = 1;
  599. d177 1
  600. a177 1
  601.         session_register("NODUP_REQUEST_ENTRY");
  602. d179 1
  603. d181 1
  604. a181 1
  605. } else {
  606. a182 2
  607.     show_request_form($web, $indonesia);
  608. }
  609. d192 2
  610. d195 1
  611. a195 1
  612.     "<select name=\"pos\">\n";
  613. d206 14
  614. a219 1
  615.     foreach($pos as $p) {
  616. d221 2
  617. a222 1
  618.         $part_of_speech = $web->tohtml($p->part_of_speech);
  619. d224 1
  620. a224 1
  621.         $description = $web->tohtml($p->description);
  622. d226 4
  623. a229 2
  624.         $pos_select .=
  625.         "<option value=\"$p->pkey\">${part_of_speech}\n";
  626. d247 1
  627. a247 1
  628. <td>English (255 characters maximum):</td>
  629. d250 2
  630. a251 1
  631. <textarea name="english" wrap="soft" rows="2" cols="55"></textarea>
  632. d258 1
  633. a258 1
  634. <td>Indonesian (255 characters maximum):</td>
  635. d261 2
  636. a262 1
  637. <textarea name="indonesian" wrap="soft" rows="2" cols="55"></textarea>
  638. d309 1
  639. @
  640.  
  641.  
  642. 1.1
  643. log
  644. @Initial revision
  645. @
  646. text
  647. @d5 33
  648. a37 1
  649.  
  650. a301 2
  651.  
  652.  
  653. @
  654.  
  655.  
  656. 1.1.1.1
  657. log
  658. @Bahasa Indonesia Dictionary
  659. @
  660. text
  661. @@
  662.