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 / cpwd.php,v < prev    next >
Text File  |  2003-10-20  |  8KB  |  442 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.29;    author bule;    state Exp;
  26. branches;
  27. next    1.3;
  28.  
  29. 1.3
  30. date    2003.09.04.07.26.59;    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:    cpwd.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 
  73. //               client page is allow an administrator to change 
  74. //               his/her password. 
  75. // 
  76. // Copyright (c) 2003 John L. Whiteman
  77. //
  78. // Permission is herby granted, free of charge, to any person obtaining a 
  79. // copy of this software, data, and associated documentation files 
  80. // (the "Software"), to deal in the Software without restriction, 
  81. // including without limitation the rights to use, copy, modify, merge, 
  82. // publish, distribute, sublicense, and/or sell copies of Software, and to
  83. // permit persons to whom the Software is furnished to do so, subject to 
  84. // the following conditions:
  85. //
  86. // The above copyright notice and this permission notice shall be 
  87. // included in all copies or substantial portions of the Software.
  88. //
  89. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  90. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  91. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  92. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  93. // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  94. // TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  95. //////////////////////////////////////////////////////////////////////////////
  96. //////////////////////////////////////////////////////////////////////////////
  97.  
  98. $web = new Web();
  99.  
  100. if (!$_SESSION['ADMIN']) {
  101.  
  102.     $web->redirect("login.php");
  103.  
  104.     exit;
  105. }
  106.  
  107. $indonesia = new Indonesia();
  108.  
  109. $status = $indonesia->get_dictionary_status();
  110.  
  111. if ($status["status"] == 1 || $status["status"] == 2) {
  112.  
  113.     $web->redirect("admin.php");
  114.  
  115.     exit;
  116. }
  117.  
  118. if ($_SESSION['NODUP_CHANGE_PASSWORD']) {
  119.  
  120.     unset($_SESSION['NODUP_CHANGE_PASSWORD']);
  121.  
  122.     $web->redirect("admin.php");
  123.  
  124.     exit;
  125. }
  126. ?>
  127. <html>
  128. <head>
  129. <title>Bahasa Indonesia Dictionary: Change Password</title>
  130.  
  131. <link href="bahasa.css" rel="stylesheet" type="text/css">
  132.  
  133. <script type="text/javascript" src="bahasa.js"></script>
  134.  
  135. <script language="Javascript" type="text/javascript">
  136. <!--
  137. //////////////////////////////////////////////////////////////////////////////
  138. function verify() {
  139.  
  140.     var name = document.change_password.name.value;
  141.  
  142.     name = trim(name);
  143.  
  144.     if (is_white_space(name)) {
  145.  
  146.         alert("You must enter your name.");
  147.  
  148.         document.change_password.name.focus();
  149.  
  150.         return(false);
  151.     } 
  152.  
  153.     var old_password = document.change_password.old_password.value;
  154.  
  155.     if (is_white_space(old_password)) {
  156.  
  157.         alert("You must enter your old password.");
  158.  
  159.         document.change_password.old_password.focus();
  160.  
  161.         return(false);
  162.     } 
  163.  
  164.     var new_password = document.change_password.new_password.value;
  165.  
  166.     if (is_white_space(new_password)) {
  167.  
  168.         alert("You must enter a new password.");
  169.  
  170.         document.change_password.new_password.focus();
  171.  
  172.         return(false);
  173.     } 
  174.  
  175.     if ((new_password.length < 5) || (new_password.length > 50)) {
  176.  
  177.         alert(
  178.         "The new password value must 5-50 characters in length!");
  179.  
  180.         document.change_password.new_password.focus();
  181.  
  182.         return(false);
  183.     }
  184.  
  185.     var confirm_new_password = 
  186.     document.change_password.confirm_new_password.value;
  187.  
  188.     if (is_white_space(confirm_new_password)) {
  189.  
  190.         alert(
  191.         "You must enter your new password again for confirmation.");
  192.  
  193.         document.change_password.confirm_new_password.focus();
  194.  
  195.         return(false);
  196.     } 
  197.  
  198.     if (new_password != confirm_new_password) {
  199.  
  200.         alert(
  201.         "Your confirmation password does not match your " + 
  202.         "new password."); 
  203.  
  204.         document.change_password.confirm_new_password.focus();
  205.  
  206.         return(false);
  207.     }
  208.  
  209.     return(true);
  210. }
  211. //////////////////////////////////////////////////////////////////////////////
  212. // -->
  213. </script>
  214. </head>
  215. <html>
  216. <body>
  217. <?
  218. $web->show_logo("Change Password");
  219. ?>
  220. <a href="admin.php">Administration</a>
  221.  
  222. <?
  223. if (
  224. isset($_POST['name']) &&
  225. isset($_POST['old_password']) && 
  226. isset($_POST['new_password']) &&
  227. isset($_POST['confirm_new_password'])) {
  228.  
  229.     if ($_SESSION['ADMIN'] != $_POST['name']) {
  230.  
  231.         print 
  232.         "<br><hr><b>You are not allowed to change password!" .
  233.         "</b><hr><br>\n";
  234.  
  235.     } else {
  236.  
  237.         $errstr = 
  238.         $indonesia->change_password(
  239.         $_POST['name'], $_POST['old_password'], $_POST['new_password'],
  240.         $_POST['confirm_new_password']); 
  241.  
  242.         if ($errstr != "") {
  243.  
  244.             print "<br><hr><b>${errstr}</b><hr><br>\n";
  245.  
  246.         } else {
  247.  
  248.             print 
  249.             "<br><hr><b>Your password has " .
  250.             "been changed!</b><hr><br>\n"; 
  251.  
  252.             $_SESSION['NODUP_CHANGE_PASSWORD'] = 1;
  253.         }
  254.     }
  255. } else {
  256.  
  257.     show_change_password_form();
  258. }
  259. ?>
  260. </body>
  261. </html>
  262.  
  263. <?
  264. function show_change_password_form() {
  265.  
  266.     print <<<EOFSCPF
  267. <form name="change_password" method="post" onSubmit='return verify()'>
  268. <table cellpadding="3" cellspacing="3" border="0">
  269. <tr>
  270. <td>Name:</td>
  271. <td>
  272. <input type="text" name="name">
  273. </td>
  274. </tr>
  275. <tr>
  276. <td>Old Password:</td>
  277. <td>
  278. <input type="password" name="old_password">
  279. </td>
  280. </tr><tr>
  281. <td>New Password (5-50 characters):</td>
  282. <td>
  283. <input type="password" name="new_password" maxlength="50">
  284. </td>
  285. </tr><tr>
  286. <td>Type New Password Again:</td>
  287. <td>
  288. <input type="password" name="confirm_new_password" maxlength="50">
  289. </td>
  290. </tr><tr>
  291. <td colspan="2" align="right">
  292. <input type="submit" value="Change Password!">
  293. </td>
  294. </tr>
  295. </table>
  296. </form>
  297. <script language="Javascript" type="text/javascript">
  298. document.change_password.name.focus();
  299. </script>
  300.  
  301.  
  302.  
  303. EOFSCPF;
  304.  
  305.     return;
  306. }
  307. ?>
  308. @
  309.  
  310.  
  311. 1.6
  312. log
  313. @*** empty log message ***
  314. @
  315. text
  316. @d12 1
  317. a12 1
  318. // Modified:     October 17, 2003
  319. d71 2
  320. @
  321.  
  322.  
  323. 1.5
  324. log
  325. @*** empty log message ***
  326. @
  327. text
  328. @d12 1
  329. a12 1
  330. // Modified:     October 05, 2003
  331. a38 1
  332.  
  333. d70 3
  334. a72 3
  335. <title>
  336. Bahasa Indonesia Dictionary: Change Password 
  337. </title>
  338. d75 2
  339. a76 26
  340.  
  341. function is_white_space(stoken) {
  342.  
  343.     if (stoken == null) return(true);
  344.     
  345.     if (stoken == '') return(true);
  346.  
  347.     if (stoken == "") return(true);
  348.  
  349.     return(false);
  350. }
  351.  
  352. function trim(stoken) {
  353.  
  354.     if (is_white_space(stoken)) {
  355.  
  356.         return(stoken);
  357.     }
  358.  
  359.     stoken = stoken.replace(/^\s*/, "");
  360.  
  361.     stoken = stoken.replace(/\s*&/, "");
  362.  
  363.     return(stoken);
  364. }
  365.  
  366. d150 2
  367. a151 1
  368.  
  369. @
  370.  
  371.  
  372. 1.4
  373. log
  374. @*** empty log message ***
  375. @
  376. text
  377. @d12 1
  378. a12 1
  379. // Modified:     September 30, 2003
  380. d180 3
  381. a182 1
  382. <h2>Bahasa Indonesia Dictionary: Change Password</h2>
  383. @
  384.  
  385.  
  386. 1.3
  387. log
  388. @*** empty log message ***
  389. @
  390. text
  391. @d12 1
  392. a12 1
  393. // Modified:     September 03, 2003
  394. d42 1
  395. a42 1
  396. if (!session_is_registered("ADMIN")) {
  397. d60 1
  398. a60 1
  399. if (session_is_registered("NODUP_CHANGE_PASSWORD")) {
  400. d62 1
  401. a62 1
  402.     session_unregister("NODUP_CHANGE_PASSWORD");
  403. d213 1
  404. a213 3
  405.             $NODUP_CHANGE_PASSWORD = 1;
  406.  
  407.             session_register("NODUP_CHANGE_PASSWORD");
  408. @
  409.  
  410.  
  411. 1.2
  412. log
  413. @*** empty log message ***
  414. @
  415. text
  416. @d12 1
  417. a12 1
  418. // Modified:     August 18, 2003
  419. d210 2
  420. a211 1
  421.             "<br><hr><b>Your password has changed!</b><hr><br>\n"; 
  422. @
  423.  
  424.  
  425. 1.1
  426. log
  427. @Initial revision
  428. @
  429. text
  430. @d5 34
  431. a269 1
  432.  
  433. @
  434.  
  435.  
  436. 1.1.1.1
  437. log
  438. @Bahasa Indonesia Dictionary
  439. @
  440. text
  441. @@
  442.