File: changepw.pl

package info (click to toggle)
dcmtk 3.6.0-12
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 32,976 kB
  • sloc: cpp: 193,852; ansic: 46,292; sh: 4,020; makefile: 3,969; perl: 3,278; lex: 94
file content (133 lines) | stat: -rw-r--r-- 4,806 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/perl
#
#  Copyright (C) 1996-2010, OFFIS e.V.
#  All rights reserved.  See COPYRIGHT file for details.
#
#  This software and supporting documentation were developed by
#
#    OFFIS e.V.
#    R&D Division Health
#    Escherweg 2
#    D-26121 Oldenburg, Germany
#
#  for CEN/TC251/WG4 as a contribution to the Computer Assisted Radiology
#  (CAR) 1996 DICOM Demonstration.
#
#
# Module: dcmwlm (WWW Component)
#
# Author: Marco Eichelberg
#
# Purpose:
#   This perl script allows to change the password for a storage area.
#
# Last Update:      $Author: joergr $
# Update Date:      $Date: 2010-10-14 13:02:01 $
# CVS/RCS Revision: $Revision: 1.2 $
# Status:           $State: Exp $
#
# CVS/RCS Log
#   $Log: changepw.pl,v $
#   Revision 1.2  2010-10-14 13:02:01  joergr
#   Updated copyright header. Added reference to COPYRIGHT file.
#
#   Revision 1.1  2002/12/03 12:16:03  wilkens
#   Added files und functionality from the dcmtk/wlisctn folder to dcmtk/dcmwlm
#   so that dcmwlm can now completely replace wlistctn in the public domain part
#   of dcmtk. Pertaining to this replacement requirement, another optional return
#   key attribute was integrated into the wlm utilities.
#
#
#

require 'prefs.ph';
require 'layout.ph';
require 'password.ph';
require 'lock.ph';
require 'urldecod.ph';
require 'write.ph';
require 'checkvr.ph';

$path_info=$ENV{'PATH_INFO'};
&get_request;

$aetitle = '';
$passwd = '';
if ($path_info ne '')
{
  ($dummy, $aetitle, $passwd, $rest) = split(/\//, $path_info);
}

if (($passwd eq '') || (! &checkurlcode($passwd, $aetitle)))
{
  # Password is incorrect.
  &page_title("Password invalid");
  printf("<A HREF=\"%s\">Click here</A> to return to main menu.\n", $prefs{'main.pl'});
  &page_footer;
} else {
  # Password is correct.
  &set_readlock("$prefs{'data_path'}/$aetitle");

  if (-f "$prefs{'data_path'}/$aetitle/$prefs{'publicfile'}")
  {
    &page_title("Public Storage Area");
    printf("It is not possible to change the password for a public storage area.<p>");
    printf("<A HREF=\"%s/%s/%s\">Click here</A> to return to main menu.\n",
      $prefs{'main.pl'}, $aetitle, $passwd);
    &page_footer;
  } else {
    if ($request ne '')
    {
      # We have received a filled-in form.
      # We save/update it and return a URL to the updated form.
      if ($rqpairs{'action'} eq 'Submit')
      {
        if (&testpasswd($passwd, $rqpairs{'oldpasswd'}, $aetitle))
        {
          if ((length($rqpairs{'newpasswd1'})<6)||($rqpairs{'newpasswd1'} ne $rqpairs{'newpasswd2'}))
          {
            # new PW incorrect
            &page_title("New password invalid");
            printf("You have not entered the same password twice, or the password was shorter than six letters.<br>\n");
            printf("The password has not been changed.<p>\n");
            printf("<A HREF=\"%s/%s/%s\">Click here</A> to retry or return to <A HREF=\"%s/%s/%s\">Main Menu</A>\n",
              $prefs{'changepw.pl'}, $aetitle, $passwd,
              $prefs{'main.pl'}, $aetitle, $passwd);
            &page_footer;
          } else {
            &set_writelock("$prefs{'data_path'}/$aetitle");
            &writepasswd($rqpairs{'newpasswd1'}, $aetitle);
            $passwd = &makepasswd($rqpairs{'newpasswd1'}, $aetitle);
            printf("Location: %s/%s/%s\n\n", $prefs{'main.pl'}, $aetitle, $passwd);
          }
        } else {
          # PW incorrect
          &page_title("Old Password invalid");
          printf("The password has not been changed.<p>\n");
          printf("<A HREF=\"%s%s\">Click here</A> to retry or return to <A HREF=\"%s%s\">Main Menu</A>\n",
            $prefs{'changepw.pl'}, $path_info, $prefs{'main.pl'}, $path_info);
          &page_footer;
        }
      } else {
        printf("Location: %s%s\n\n", $prefs{'main.pl'}, $path_info);
      }
    } else {
      # we are requested to display a form
      &page_title("Change Password");
      printf("<FORM METHOD=get ACTION=\"%s/%s/%s\">\n",$prefs{'changepw.pl'}, $aetitle, $passwd);
      printf("<INPUT TYPE=HIDDEN name=\"request\" value=\"                                                            \">\n");
      printf("Please enter the <b>old</b> password for storage area '%s':\n",$aetitle);
      printf("<CENTER><INPUT TYPE=PASSWORD name=\"oldpasswd\" size=20 value=\"\"><p>\n");
      printf("</CENTER>\n");
      printf("Please enter the <b>new</b> password <b>twice</b>:\n");
      printf("<CENTER><INPUT TYPE=PASSWORD name=\"newpasswd1\" size=20 value=\"\"><p>\n");
      printf("<INPUT TYPE=PASSWORD name=\"newpasswd2\" size=20 value=\"\"><p>\n");
      printf("<INPUT TYPE=SUBMIT name=\"action\" value=\"Submit\">\n");
      printf("<INPUT TYPE=SUBMIT name=\"action\" value=\"Cancel\"></CENTER>\n");
      &page_footer;
    }
  }
  &release_lock;
}