##################################################################### # Limit the number of records a user can add # Multiple records per user # Limit total number of records # # by JPDeni # Created 12-July-2000 ##################################################################### # # This mod will allow you to either have the same limit per user or # a different limit. If you want to change the number of records a # user can add, go to the "Admin" link and enter the new number in # the "Add" field. # In default.cfg, you must have a field for the userid. Be sure to # set the $auth_user_field variable to the number of the userid field. # If you are going to allow users to sign up for accounts online, # change the @auth_signup_permissions to indicate the default number # of records a user can add: #--------------------------- # Permissions a new signup should get. @auth_signup_permissions = (1,5,1,1,0); #--------------------------- # The above would allow new users to add 5 records. # Also, you should be sure to set $auth_modify_own = 1; # in your .cfg file. ###### # In db.cgi, sub add_record, after ###### &auth_logging("added record: $in{$db_key}") if ($auth_logging); ###### # add ###### unless ($per_admin) { open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!"); if ($db_use_flock) { flock(PASS, 1); } @lines = ; close PASS; open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!"); if ($db_use_flock) { flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!"); } foreach $line (@lines) { if ($line =~ /^$db_userid:/) { chomp $line; @passdata = split ':',$line; --$passdata[3]; $per_add = $passdata[3]; $pass_line = join ':',@passdata; print PASS "$pass_line\n"; } else { print PASS $line; } } close PASS; } ###### # In sub delete_records, change ###### if ($in{$key} eq "delete") { $delete_list{$key} = 1; $rec_to_delete = 1; } ###### # to ###### if ($in{$key} eq "delete") { $delete_list{$key} = 1; $rec_to_delete = 1; unless ($per_admin) { ++$user_count; } } ###### # Also in sub delete_records, after ###### &auth_logging("deleted records: $succstr") if ($auth_logging); ###### # add ###### open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!"); if ($db_use_flock) { flock(PASS, 1); } @lines = ; close PASS; open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!"); if ($db_use_flock) { flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!"); } foreach $line (@lines) { if ($line =~ /^$db_userid:/) { chomp $line; @passdata = split ':',$line; $passdata[3] += $user_count; $per_add = $passdata[3]; $pass_line = join ':',@passdata; print PASS "$pass_line\n"; } else { print PASS $line; } } close PASS; ###### # In sub admin_display, change ###### if ($in{'inquire'} and ($in{'username'} eq $data[0])) { $user_list .= qq~\n~; $perm = qq| View Add Delete Modify Admin |; $password = $data[1]; } else { $user_list .= qq~\n~; } } $user_list .= ""; # Build the permissions list if we haven't inquired in someone. if (!$perm) { $perm = qq| View Add Delete Modify Admin |; } &html_admin_display ($message, $user_list, $password, $perm); } ###### # to ###### if ($in{'inquire'} and ($in{'username'} eq $data[0])) { $user_list .= qq~\n~; $perm = qq| View Add Delete Modify Admin |; $password = $data[1]; } else { $user_list .= qq~\n~; } } $user_list .= ""; # Build the permissions list if we haven't inquired in someone. if (!$perm) { $perm = qq| View Add Delete Modify Admin |; } &html_admin_display ($message, $user_list, $password, $perm); }