(UnRegistered) DLSuperC Insert and Delete Side-By-Side Report 6/23/2001 12:03:49 PM Panel 1 -- New Source Matches + Inserts Panel 2 -- New Source Matches + Deletes New File = c:\windows\desktop\dbd2.cgi.new 6/22/2001 12:32:00 AM New File = c:\windows\desktop\dbd2.cgi.new 6/22/2001 12:32:00 AM Old File = c:\windows\desktop\database_doctor.cgi.original 11/13/2000 2:50:00 AM Old File = c:\windows\desktop\database_doctor.cgi.original 11/13/2000 2:50:00 AM Ref# ID ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 Ref# ID ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 1 #!/usr/bin/perl 1 #!/usr/bin/perl 2 $| = 1; 2 $| = 1; 3 3 4 I - # last revised: # May 2001 for www.ghtRx.com # Roger Davies # www.ssdirect.com # 4 D - ############################################################## 5 I - # based on: # Database_Doctor.cgi 2.0 # Mike Carville # www.web-bazaar.com/cgi/ 5 D - # 6 I - $database = "_database/ghtrx.dat"; 6 D - # Database_Doctor.cgi 2.0 7 I - $users = "_database/ghtuser.dat"; 7 D - # Mike Carville 8 I - $debug=0; # 0=no,1=yes print messages 8 D - # www.web-bazaar.com/cgi/ 9 I - $htmlform = "display_add.dat"; 9 D - # carville@web-bazaar.com 10 I - $check_items = "N"; # Y=unique first field 10 D - # 11 I - @table_fields = ("YYMD","Name","City","State","Email","Website","Condition","Pro 11 D - # This script is made available free of charge. 12 12 D - # Please leave my name in the header section. 13 13 D - # You may not sell this script for any reason. 14 14 D - # While not required, please leave the banner in the footer 15 15 D - # in the manager script to help fund further development. 16 16 D - # 17 17 D - # If you are really thrilled with this script, why not help 18 18 D - # us both out and buy a reference book from our scripts page. 19 19 D - # We get a commission, you get knowledge, and Amazon stockholders 20 20 D - # breathe easier for another day. <:-) 21 21 D - # 22 22 D - # The Database Doctor 23 23 D - # ------------------- 24 24 D - # The Database Doctor is a tool designed to help manage 25 25 D - # Pipe Delimited Databases.(|) The script is designed to 26 26 D - # add to, edit and delete, sort and prepare printouts of 27 27 D - # databases. Many scripts, especially web stores utilize 28 28 D - # these types of data files. 29 29 D - # 30 30 D - # The script is password protected, and has a user addition 31 31 D - # form. 32 32 D - # 33 33 D - # Earlier versions of this script supported multiple users. 34 34 D - # Nobody seemed to care, and it messed up a lot of people. 35 35 D - # Out like the cat. In with the new. 36 36 D - # 37 37 D - # Even though this was written to manage a webstore database, 38 38 D - # everybody seemed to want a front end to this. Display.cgi 39 39 D - # was written to address this. The Database Doctor will still 40 40 D - # work wonderfully to create and maintain databases for an 41 41 D - # inventory file. With display.cgi now it becomes flexible 42 42 D - # and can easily handle address books, directories or whatever 43 43 D - # you can imagine. And imagination is the key. 44 44 D - # 45 45 D - # 46 46 D - # A key feature of the script is that it will edit any 47 47 D - # number of fields in a database. 48 48 D - # 49 49 D - # -the database you make will have as many fields 50 50 D - # as set in the @table_names array below. 51 51 D - # 52 52 D - # -if you subsequently add a field to the middle you 53 53 D - # will need to adjust your database 54 54 D - # 55 55 D - # -The Titles for the fields need to match the names 56 56 D - # on the input form, and are contained within the @table_names array . 57 57 D - # 58 58 D - # -The input form for new items is an html form module located in html.dat. 59 59 D - # 60 60 D - # -The Form can be whatever you like...you can have drop down 61 61 D - # and so forth to speed up entry. 62 62 D - # 63 63 D - # -The absolute key though is that the name of the fields in the form 64 64 D - # must match the headings for the fields in the @tables_names array below. This 65 65 D - # the script knows where the data is coming in from, and where to put it. 66 66 D - # If you are missing data from an entry form you are having a matching problem 67 67 D - # 68 68 D - # -Don't add an opening or closing form tag to html.dat...as that is in 69 69 D - # the script itself. 70 70 D - # 71 71 D - # PATH to PERL 72 72 D - # ------------ 73 73 D - # 74 74 D - # The first line of every cgi script contains the path to the perl interpreter o 75 75 D - # /usr/bin/perl is standard on most, some others use /usr/local/bin/perl 76 76 D - # If you don't know where it is, ask your host, or if you have telnet, login and 77 77 D - # 78 78 D - # FILES 79 79 D - # ----- 80 80 D - # 81 81 D - # Make ABSOLUTELY sure to transfer the files in ASCII and not BINARY. BINARY bre 82 82 D - # 83 83 D - # In the main CGI Directory place database_doctor.cgi(755) 84 84 D - # 85 85 D - # Contents (permissions in ())... html.dat(666) 86 86 D - # 87 87 D - # DATABASE (name whatever you like)(666) 88 88 D - # 89 89 D - # Place login_setup.cgi and users.dat wherever you want. 90 90 D - # Login Setup will create the encrypted password. 91 91 D - # There is a path to adjust the users.dat location on 92 92 D - # the first line of login_setup.cgi 93 93 D - # 94 94 D - # There are two logon pages included as well. Remember to changes the 95 95 D - # paths to the scripts, and to leave the form input names alone. 96 96 D - # One accesses the Database Doctor, the other will add users to users.dat. 97 97 D - # 98 98 D - # One Other Option... 99 99 D - # By setting the $check_items variable to Y the script will verify that the 100 100 D - # first field in the entry you are adding is unique from all the others. 101 101 D - # Most web store scripts require a unique item id. 102 102 D - # 103 103 D - # ALWAYS BACK UP YOUR DATA MANUALLY!!!! 104 104 D - # 105 105 D - # 106 106 D - # We of course are not responsible if this script blows 107 107 D - # up your computer. We can, however, sell you a new one. 108 108 D - # At the point of this writing my computer has failed to blow up. 109 109 D - # 110 110 D - # My personal friend and mentor Steven May contributed to this 111 111 D - # script with the form parsing routine, and inspired the logic 112 112 D - # behind parts of the search routine. You can see Steven's 113 113 D - # work at http://www.blackwater-pacific.com/ 114 114 D - # 115 115 D - # And lastly, thanks to Joe DePasquale for the search routine I 116 116 D - # borrowed from the linkmatic script before modifying. 117 117 D - # 118 118 D - # 119 119 D - # 120 120 D - # Improvements in version 2.0 121 121 D - # 122 122 D - # -changed path structure to make installation easier 123 123 D - # 124 124 D - # -added the ability to use get as well as post in the display script 125 125 D - # 126 126 D - # -added a routine that limits the number of results from a search, and provides 127 127 D - # 128 128 D - # SET THESE FILE PATHS...you can add paths if you like,but having 129 129 D - # paths caused lots of people not to be able to set it up right...so 130 130 D - # I gave up and took em out! 131 131 132 I - # Main 132 D - $database = "fsfprs.dat"; #just the name of the file 133 133 DM- 134 134 D - $users = "users.dat"; 135 135 D - 136 136 D - #change to Y if you would like the first field compared 137 137 D - #to the other first fields in the database during preview 138 138 D - #to insure a unique ID if you need that for a webstore 139 139 D - 140 140 D - $check_items = "N"; 141 141 D - 142 142 D - @table_fields = ("First-Name","Last-Name","Business-Name","State","Email","Web-S 143 143 D - 144 144 D - 145 145 D - 146 146 D - 147 147 D - ################################################################################ 148 148 D - #####Thats that. You change below here and you mess with the guts...feel free bu 149 149 D - 150 print "Content-type: text/html\n\n"; 150 print "Content-type: text/html\n\n"; 151 print qq~ 151 print qq~ 152 152 153 153 154 I - Global Health Trax -- Testimonal Database 154 D - Database Doctor 2.0 155 155 156 156 157 I -

157 D - 158 D -

159 ~; 159 ~; 160 160 161 161 D - ############################################################## 162 # Parse from the web form 162 # Parse from the web form 163 163 D - ############################################################## 164 read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 164 read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 165 @cgiPairs = split(/&/,$buffer); 165 @cgiPairs = split(/&/,$buffer); 166 I - foreach $cgiPair (@cgiPairs){ 166 D - foreach $cgiPair (@cgiPairs) 167 167 D - { 168 ($name,$value) = split(/=/,$cgiPair); 168 ($name,$value) = split(/=/,$cgiPair); 169 $value =~ s/\+/ /g; 169 $value =~ s/\+/ /g; 170 $value =~ s/%(..)/pack("c",hex($1))/ge; 170 $value =~ s/%(..)/pack("c",hex($1))/ge; 171 $form{$name} .= "\0" if (defined($form{$name})); 171 $form{$name} .= "\0" if (defined($form{$name})); 172 $form{$name} .= "$value"; 172 $form{$name} .= "$value"; 173 I - if ($debug) {print "
0 form{$name}=$value";} 173 174 } 174 } 175 175 176 176 D - 177 177 D - 178 178 D - ############################################################## 179 # Validate User 179 # Validate User 180 I - $passwd="N"; #default access level is N=None 180 D - ############################################################## 181 181 D - 182 open (PEOPLE, "$users"); 182 open (PEOPLE, "$users"); 183 I - while (){ 183 D - 184 184 D - while () 185 185 D - { 186 $row=$_; 186 $row=$_; 187 @user = split(/ /,$row); 187 @user = split(/ /,$row); 188 I - if ($form{'user'} eq $user[0]){ 188 D - 189 189 D - if ($form{'user'} eq $user[0]) 190 190 D - { 191 $password = crypt($form{'password'}, "MM"); 191 $password = crypt($form{'password'}, "MM"); 192 I - if ($password eq "$user[1]" ) {$passwd="Y";} 192 D - 193 193 D - if ($password eq "$user[1]" ) 194 194 D - {$passwd="Y";} 195 } 195 } 196 } 196 } 197 close (PEOPLE); 197 close (PEOPLE); 198 198 199 199 D - 200 200 D - ############################################################## 201 # Set Hidden Tags for Re-entry 201 # Set Hidden Tags for Re-entry 202 I - print qq~ 202 D - ############################################################## 203 I - 203 D - print qq~\n~; 204 I - 204 D - print qq~\n~; 205 I - ~; 205 206 206 207 207 D - 208 208 D - 209 209 D - ############################################################## 210 # Display the Addition Form if necessary 210 # Display the Addition Form if necessary 211 211 D - ############################################################## 212 $form {'startup'} and &display; 212 $form {'startup'} and &display; 213 213 214 214 D - 215 215 D - ############################################################## 216 # User Passes Check 216 # User Passes Check 217 I - if ($passwd ne "Y"){ #user 217 D - ############################################################## 218 I - print "Incorrect logon. Use your
back b 218 D - if ($passwd eq "Y") 219 IM- print"\n"; 219 D - { 220 IM- } 220 D - 221 I - else { 221 D - 222 I - # Preview Form 222 D - 223 I - $hitCount=0; 223 D - ############################################################## 224 I - if ($form {'preview'}){ 224 D - # Preview the Addition 225 I - if ($check_items eq "Y"){&check_items;} 225 D - ############################################################## 226 226 D - 227 227 D - if ($form {'preview'}) 228 228 D - { 229 229 D - 230 230 D - if ($check_items eq "Y") 231 231 D - {&check_items;} 232 232 D - 233 print "
PreviewPreview
$table_fields\n"; 240 print "
$table_fields\n"; 241 print "