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 / admins.php,v < prev    next >
Text File  |  2003-10-20  |  13KB  |  668 lines

  1. head    1.7;
  2. access;
  3. symbols
  4.     Initial:1.1.1.1 bule:1.1.1;
  5. locks; strict;
  6. comment    @# @;
  7.  
  8.  
  9. 1.7
  10. date    2003.10.20.00.21.45;    author bule;    state Exp;
  11. branches;
  12. next    1.6;
  13.  
  14. 1.6
  15. date    2003.10.18.00.33.41;    author bule;    state Exp;
  16. branches;
  17. next    1.5;
  18.  
  19. 1.5
  20. date    2003.10.06.00.39.26;    author bule;    state Exp;
  21. branches;
  22. next    1.4;
  23.  
  24. 1.4
  25. date    2003.10.01.06.51.28;    author bule;    state Exp;
  26. branches;
  27. next    1.3;
  28.  
  29. 1.3
  30. date    2003.09.11.05.28.22;    author bule;    state Exp;
  31. branches;
  32. next    1.2;
  33.  
  34. 1.2
  35. date    2003.08.19.06.42.07;    author bule;    state Exp;
  36. branches;
  37. next    1.1;
  38.  
  39. 1.1
  40. date    2003.08.12.19.18.23;    author bule;    state Exp;
  41. branches
  42.     1.1.1.1;
  43. next    ;
  44.  
  45. 1.1.1.1
  46. date    2003.08.12.19.18.23;    author bule;    state Exp;
  47. branches;
  48. next    ;
  49.  
  50.  
  51. desc
  52. @@
  53.  
  54.  
  55. 1.7
  56. log
  57. @*** empty log message ***
  58. @
  59. text
  60. @<?
  61. session_start();
  62. require_once("../php/Indonesia.php");
  63. require_once("../php/Web.php");
  64. //////////////////////////////////////////////////////////////////////////////
  65. //////////////////////////////////////////////////////////////////////////////
  66. // Project Name: Bahasa Indonesia Dictionary
  67. // Directory:    bahasa/web
  68. // File Name:    admins.php
  69. // Author(s):    John L. Whiteman
  70. // Created:      June 23, 2003  
  71. // Modified:     October 19, 2003
  72. // Description:  The purpose of this restricted access PHP web client 
  73. //               page is to allow creation and deletion of administrators. 
  74. // 
  75. // Copyright (c) 2003 John L. Whiteman
  76. //
  77. // Permission is herby granted, free of charge, to any person obtaining a 
  78. // copy of this software, data, and associated documentation files 
  79. // (the "Software"), to deal in the Software without restriction, 
  80. // including without limitation the rights to use, copy, modify, merge, 
  81. // publish, distribute, sublicense, and/or sell copies of Software, and to
  82. // permit persons to whom the Software is furnished to do so, subject to 
  83. // the following conditions:
  84. //
  85. // The above copyright notice and this permission notice shall be 
  86. // included in all copies or substantial portions of the Software.
  87. //
  88. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  89. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  90. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  91. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  92. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  93. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  94. //////////////////////////////////////////////////////////////////////////////
  95. //////////////////////////////////////////////////////////////////////////////
  96. $web = new Web();
  97.  
  98. if (!$_SESSION['ADMIN']) {
  99.  
  100.     $web->redirect("login.php");
  101.  
  102.     exit;
  103. }
  104.  
  105. $indonesia = new Indonesia();
  106.  
  107. $status = $indonesia->get_dictionary_status();
  108.  
  109. if ($status["status"] == 1 || $status["status"] == 2) {
  110.  
  111.     $web->redirect("admin.php");
  112.  
  113.     exit;
  114. }
  115.  
  116. if ($_SESSION['NODUP_ADMINS']) {
  117.  
  118.     unset($_SESSION['NODUPS_ADMINS']);
  119.  
  120.     $web->redirect("admin.php");
  121.  
  122.     exit;
  123. }
  124. ?>
  125. <html>
  126. <head>
  127. <title>Bahasa Indonesia Dictionary: Administrators</title>
  128.  
  129. <link href="bahasa.css" rel="stylesheet" type="text/css">
  130.  
  131. <script type="text/javascript" src="bahasa.js"></script>
  132.  
  133. <script language="Javascript" type="text/javascript">
  134. <!--
  135. //////////////////////////////////////////////////////////////////////////////
  136. function verify() {
  137.  
  138.     name = document.administrators.name.value;
  139.  
  140.     name = trim(name);
  141.  
  142.     if (is_white_space(name)) {
  143.  
  144.         alert(
  145.         "You must enter your administrator name!");
  146.  
  147.         document.administrators.name.focus();
  148.  
  149.         return(false);
  150.     }
  151.  
  152.     password = document.administrators.password.value;
  153.  
  154.     if (is_white_space(password)) {
  155.  
  156.         alert(
  157.         "You must enter your administrator password!");
  158.  
  159.         document.administrators.password.focus();
  160.  
  161.         return(false);
  162.     }
  163.  
  164.     return(true);
  165. }
  166. //////////////////////////////////////////////////////////////////////////////
  167. function verify_delete() {
  168.  
  169.     delete_name = document.administrators.delete_name.value;
  170.  
  171.     delete_name = trim(delete_name);
  172.  
  173.     if (is_white_space(delete_name)) {
  174.  
  175.         alert(
  176.         "You must enter administrator's name!");
  177.  
  178.         document.administrators.delete_name.focus();
  179.  
  180.         return(false);
  181.     }
  182.  
  183.     name = document.administrators.name.value;
  184.  
  185.     name = trim(name);
  186.  
  187.     if (is_white_space(name)) {
  188.  
  189.         alert(
  190.         "You must enter your administrator name!");
  191.  
  192.         document.administrators.name.focus();
  193.  
  194.         return(false);
  195.     }
  196.  
  197.     password = document.administrators.password.value;
  198.  
  199.     if (is_white_space(password)) {
  200.  
  201.         alert(
  202.         "You must enter your administrator password!");
  203.  
  204.         document.administrators.password.focus();
  205.  
  206.         return(false);
  207.     }
  208.  
  209.     return(true);
  210. }
  211. //////////////////////////////////////////////////////////////////////////////
  212. function verify_insert() {
  213.  
  214.     insert_name = document.administrators.insert_name.value;
  215.  
  216.     insert_name = trim(insert_name);
  217.  
  218.     if (is_white_space(insert_name)) {
  219.  
  220.         alert(
  221.         "You must enter a new administrator name!");
  222.  
  223.         document.administrators.insert_name.focus();
  224.  
  225.         return(false);
  226.     }
  227.  
  228.     if ((insert_name.length < 5) || (insert_name.length > 50)) {
  229.  
  230.         alert(
  231.         "Please keep the new administrator's name between " + 
  232.         "5 to 50 characters in length."); 
  233.  
  234.         document.administrators.insert_name.focus();
  235.  
  236.         return(false);
  237.     } 
  238.  
  239.     insert_password = document.administrators.insert_password.value;
  240.  
  241.     if (is_white_space(insert_password)) {
  242.  
  243.         alert(
  244.         "You must enter the new administrator's password!");
  245.  
  246.         document.administrators.insert_password.focus();
  247.  
  248.         return(false);
  249.     }
  250.  
  251.     if ((insert_password.length < 5) || (insert_password.length > 50)) {
  252.  
  253.         alert(
  254.         "Please keep the new administrator's password between " + 
  255.         "5 to 50 characters in length."); 
  256.  
  257.         document.administrators.insert_password.focus();
  258.  
  259.         return(false);
  260.     } 
  261.  
  262.     name = document.administrators.name.value;
  263.  
  264.     name = trim(name);
  265.  
  266.     if (is_white_space(name)) {
  267.  
  268.         alert(
  269.         "You must enter your administrator name!");
  270.  
  271.         document.administrators.name.focus();
  272.  
  273.         return(false);
  274.     }
  275.  
  276.     password = document.administrators.password.value;
  277.  
  278.     if (is_white_space(password)) {
  279.  
  280.         alert(
  281.         "You must enter your administrator password!");
  282.  
  283.         document.administrators.password.focus();
  284.  
  285.         return(false);
  286.     }
  287.  
  288.     return(true);
  289. }
  290. //////////////////////////////////////////////////////////////////////////////
  291. // -->
  292. </script>
  293. </head>
  294. <html>
  295. <body>
  296. <?
  297. $web->show_logo("Administrators");
  298. ?>
  299. <a href="admin.php">Administration</a>
  300.  
  301. <?
  302. if (
  303. (isset($_POST['name'])) &&
  304. (isset($_POST['password'])) &&
  305. (isset($_POST['delete_name']))) {
  306.  
  307.     $errstr = 
  308.     $indonesia->delete_administrator(
  309.     $_POST['delete_name'], 
  310.     $_POST['name'], $_POST['password']);
  311.  
  312.     if ($errstr != "") {
  313.  
  314.         print "<hr><b>${errstr}</b><hr>\n";
  315.  
  316.     } else {
  317.  
  318.         print 
  319.         "<br><hr><b>\n" .
  320.         "Successfully deleted administrator!" . 
  321.         "</b><hr><br>\n"; 
  322.  
  323.         $_SESSION['NODUP_ADMINS'] = 1;
  324.     }
  325.  
  326. } else if (
  327. (isset($_POST['name'])) &&
  328. (isset($_POST['password'])) &&
  329. (isset($_POST['insert_name'])) &&
  330. (isset($_POST['insert_password']))) {
  331.  
  332.     $errstr = 
  333.     $indonesia->insert_administrator(
  334.     $_POST['insert_name'], $_POST['insert_password'],
  335.     $_POST['name'], $_POST['password']);
  336.  
  337.     if ($errstr != "") {
  338.  
  339.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  340.  
  341.     } else {
  342.  
  343.         print 
  344.         "<br><hr><b>\n" .
  345.         "Successfully added new administrator!" . 
  346.         "</b><hr><br>\n"; 
  347.  
  348.         $_SESSION['NODUP_ADMINS'] = 1;
  349.     }
  350.  
  351. } else if (
  352. (isset($_POST['name'])) &&
  353. (isset($_POST['password'])) &&
  354. (isset($_POST['insert_administrator']))) {
  355.  
  356.     $errstr = 
  357.     $indonesia->login_db_user($_POST['name'], $_POST['password']);
  358.  
  359.     if ($errstr != "") {
  360.  
  361.         print "<hr><b>${errstr}</b><hr>\n";
  362.  
  363.     } else {
  364.  
  365.         show_insert_administrator_form();
  366.     }
  367.  
  368. } else if (
  369. (isset($_POST['name'])) &&
  370. (isset($_POST['password'])) &&
  371. (isset($_POST['delete_administrator']))) {
  372.  
  373.     $errstr = 
  374.     $indonesia->login_db_user($_POST['name'], $_POST['password']);
  375.  
  376.     if ($errstr != "") {
  377.  
  378.         print "<hr><b>${errstr}</b><hr>\n";
  379.  
  380.     } else {
  381.  
  382.         show_delete_administrator_form();
  383.     }
  384. } else {
  385.  
  386.     show_admin_options_form($web, $indonesia);
  387. }
  388. ?>
  389. </body>
  390. </html>
  391.  
  392. <?
  393. //////////////////////////////////////////////////////////////////////////////
  394. function show_admin_options_form($web, $indonesia) {
  395.  
  396.     $administrators = array();
  397.  
  398.     $errstr = $indonesia->get_administrators($administrators); 
  399.  
  400.     if ($errstr != "") {
  401.  
  402.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  403.  
  404.         return;
  405.     }
  406.  
  407.     $delete_administrator_html = "";
  408.  
  409.     if (count($administrators) > -1) {
  410.  
  411.         $delete_administrator_html .= 
  412.         "</tr><tr>\n" .
  413.         "<td>\n" .
  414.         "<input type=\"submit\" name=\"delete_administrator\" " .
  415.         "value=\"Delete an Existing Administrator!\">\n" .
  416.         "</td>\n"; 
  417.     }
  418.  
  419.     print <<<EOFSAOF
  420. <form name="administrators" method="post" onSubmit='return verify()'> 
  421. <table cellpadding="3" cellspacing="3" border="1">
  422. <tr>
  423. <td align="right">
  424. Name:  
  425. <input type="text" name="name" maxlength="255" size="50">
  426.    
  427. Password:  
  428. <input type="password" name="password" maxlength="255" size="50">
  429. </td>
  430. </tr><tr>
  431. <td>
  432. <input type="submit" name="insert_administrator" 
  433. value="Add a New Administrator!">
  434. </td>
  435. $delete_administrator_html
  436. </tr>
  437. </table>
  438. </form>
  439. <script language="Javascript" type="text/javascript">
  440. document.administrators.name.focus();
  441. </script>
  442. EOFSAOF;
  443.  
  444.     return;
  445. }
  446. //////////////////////////////////////////////////////////////////////////////
  447. function show_delete_administrator_form() {
  448.  
  449.     print <<<EOFDAF
  450. <form name="administrators" method="post" onSubmit='return verify_delete()'>
  451. <table cellpadding="3" cellspacing="3" border="0">
  452. <tr>
  453. <td>Enter Administrator's Name:</td>
  454. <td><input type="text" maxlength="50" name="delete_name"></td>
  455. </tr><tr>
  456. <td>Name:</td>
  457. <td><input type="text" name="name"></td>
  458. </tr></tr>
  459. <td>Password:</td>
  460. <td><input type="password" name="password"></td>
  461. </tr><tr>
  462. <td colspan="2" align="right">
  463. <input type="reset" value="Clear Form!">
  464. <input type="submit" value="Delete Administrator!">
  465. </td>
  466. </tr>
  467. </table>
  468. </form>
  469. <script language="Javascript" type="text/javascript">
  470. document.administrators.delete_name.focus();
  471. </script>
  472. EOFDAF;
  473.  
  474.     return;
  475. }
  476. //////////////////////////////////////////////////////////////////////////////
  477. function show_insert_administrator_form() {
  478.  
  479.     print <<<EOFIAF
  480. <form name="administrators" method="post" onSubmit='return verify_insert()'>
  481. <table cellpadding="3" cellspacing="3" border="0"> 
  482. <tr>
  483. <td>New Administrator's Name (5-50 characters):</td>
  484. <td><input type="text" maxlength="50" name="insert_name"></td>
  485. </tr><tr>
  486. <td>New Administrator's Password (5-50 characters):</td>
  487. <td><input type="password" maxlength="50" name="insert_password"></td>
  488. </tr><tr>
  489. <td>Name:</td>
  490. <td><input type="text" name="name"></td>
  491. </tr></tr>
  492. <td>Password:</td>
  493. <td><input type="password" name="password"></td>
  494. </tr><tr>
  495. <td colspan="2" align="right">
  496. <input type="reset" value="Clear Form!">
  497. <input type="submit" value="Insert New Administrator!">
  498. </td>
  499. </tr>
  500. </table>
  501. </form>
  502. <script language="Javascript" type="text/javascript">
  503. document.administrators.insert_name.focus();
  504. </script>
  505. EOFIAF;
  506.  
  507.     return;
  508. }
  509. //////////////////////////////////////////////////////////////////////////////
  510. //////////////////////////////////////////////////////////////////////////////
  511. ?>
  512. @
  513.  
  514.  
  515. 1.6
  516. log
  517. @*** empty log message ***
  518. @
  519. text
  520. @d12 1
  521. a12 1
  522. // Modified:     October 17, 2003
  523. d69 2
  524. @
  525.  
  526.  
  527. 1.5
  528. log
  529. @*** empty log message ***
  530. @
  531. text
  532. @d12 1
  533. a12 1
  534. // Modified:     October 05, 2003
  535. d68 3
  536. a70 3
  537. <title>
  538. Bahasa Indonesia Dictionary: Administrators 
  539. </title>
  540. d73 1
  541. a73 25
  542. //////////////////////////////////////////////////////////////////////////////
  543. function is_white_space(stoken) {
  544.  
  545.     if (stoken == null) return(true);
  546.     
  547.     if (stoken == '') return(true);
  548.  
  549.     if (stoken == "") return(true);
  550.  
  551.     return(false);
  552. }
  553. //////////////////////////////////////////////////////////////////////////////
  554. function trim(stoken) {
  555.  
  556.     if (is_white_space(stoken)) {
  557.  
  558.         return(stoken);
  559.     }
  560.  
  561.     stoken = stoken.replace(/^\s*/, "");
  562.  
  563.     stoken = stoken.replace(/\s*&/, "");
  564.  
  565.     return(stoken);
  566. }
  567. d230 1
  568. a230 1
  569. //////////////////////////////////////////////////////////////////////////////
  570. @
  571.  
  572.  
  573. 1.4
  574. log
  575. @*** empty log message ***
  576. @
  577. text
  578. @d12 1
  579. a12 1
  580. // Modified:     September 30, 2003
  581. d259 3
  582. a261 1
  583. <h2>Bahasa Indonesia Dictionary: Administrators</h2>
  584. @
  585.  
  586.  
  587. 1.3
  588. log
  589. @*** empty log message ***
  590. @
  591. text
  592. @d12 1
  593. a12 1
  594. // Modified:     September 05, 2003
  595. d39 1
  596. a39 1
  597. if (!session_is_registered("ADMIN")) {
  598. d57 1
  599. a57 1
  600. if (session_is_registered("NODUP_ADMINS")) {
  601. d59 1
  602. a59 1
  603.     session_unregister("NODUP_ADMINS");
  604. d284 1
  605. a284 3
  606.         $NODUP_ADMINS = 1;
  607.  
  608.         session_register("NODUP_ADMINS");
  609. d309 1
  610. a309 3
  611.         $NODUP_ADMINS = 1;
  612.  
  613.         session_register("NODUP_ADMINS");
  614. @
  615.  
  616.  
  617. 1.2
  618. log
  619. @*** empty log message ***
  620. @
  621. text
  622. @d12 1
  623. a12 1
  624. // Modified:     August 18, 2003
  625. d275 1
  626. a275 1
  627.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  628. d326 1
  629. a326 1
  630.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  631. d343 1
  632. a343 1
  633.         print "<br><hr><b>${errstr}</b><hr><br>\n";
  634. d386 1
  635. a386 1
  636. <table cellpadding="3" cellspacing="3" border="0">
  637. d390 1
  638. a390 1
  639. <input type="text" name="name">
  640. d393 1
  641. a393 1
  642. <input type="password" name="password">
  643. a400 2
  644. </tr><tr>
  645. <td> </td>
  646. @
  647.  
  648.  
  649. 1.1
  650. log
  651. @Initial revision
  652. @
  653. text
  654. @d5 32
  655. a36 1
  656.  
  657. a478 1
  658.  
  659. @
  660.  
  661.  
  662. 1.1.1.1
  663. log
  664. @Bahasa Indonesia Dictionary
  665. @
  666. text
  667. @@
  668.