Gossamer Forum
Home : Products : DBMan : Customization :

User Post Control

Quote Reply
User Post Control
Is there any way that Admin can control users how many posts they can submit.

For Ex.

Add "number of records allowed" field on member create page.
If the number field is empty, the user can have unlimited records.
But if the number is 5, the user can have only 5 records at the same time.
Then, the user's records reach 5, it redirects to the "record limit full page" when the user clicks ADD link.

I add ":$in{'limit'}" in db.cgi
print PASS "$in{'new_username'}:$encrypted:$in{'per_view'}:$in{'per_add'}:$in{'per_del'}:$in{'per_mod'}:$in{'per_admin'}:$in{'limit'}\n";

Then, it creates default.pass
username:password:1:1:1:1:0:5

But I do not know how to get the data from default.pass.
putting "$limit" does not work.

Please guide me to the correct direction.

Thank you.

Last edited by:

haruchan: Mar 20, 2006, 1:47 PM
Quote Reply
Re: [haruchan] User Post Control In reply to
You have to look at the part of the script that opens & reads the db.pass file (it's auth.pl). Check out the modification called "adding permissions" or "addtional permissions" it is located here (check it out and see if you adapt it to your needs):
http://www.jpdeni.com/dbman/Mods/AddPermission.txt

There are several MOD's that have already been written to do what you want...

http://www.jpdeni.com/dbman/Mods/limitrecords.html

JPDeni wrote some at the above link.

Also check out the "unofficial faq" maintained by LoisC at the link below for some more ideas and mods:

http://redundantcartridge.com/dbman/

Last edited by:

Watts: Mar 20, 2006, 3:57 PM
Quote Reply
Re: [Watts] User Post Control In reply to
Thank you for the reply.

I have some questions. (May be misunderstood)
In this way, I can give a specific number of allow posts.

1. How about unlimited posts? Do I put "0" instead of "5", etc.

My pass for admin
admin:password:1:1:1:1:1

2. Do I have to change the second number or automatically unlimited for admin?


3. Also, I would like to know if there is control to expire user after specific days.

Last edited by:

haruchan: Mar 20, 2006, 5:09 PM
Quote Reply
Re: [haruchan] User Post Control In reply to
With your first two questions, the number of posts allowed can easily be altered through the admin display. You can make it any number you want. It'll take a three-digit number, so you can set it to 999. If someone who you want to have unlimited posts should happen to add 999 posts, you can go back in to the admin display and make it 999 again. Or you can make the input field in the admin display another character longer so that someone could add 9999.

It wouldn't be difficult to change it so that admins had unlimited posts. It just didn't occur to me at the time I wrote the mod.

Quote:

I would like to know if there is control to expire user after specific days.

I don't think such a modification exists, but you might try looking at Lois's database to see for sure.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] User Post Control In reply to
With the AutoDelete Mod there is an option #4:

Autodelete those users with the "Guest" status.

Perhaps this can be adapted to work for what you need.

--------------------

AUTODELETE RECORDS

Autodelete those users with the "Guest" status.

This mod will allow you to autodelete records in your database. The script doesn't exactly delete records automatically, but if you put a line in the auth.pl file, sub auth_check_password, it will delete them whenever someone logs into the database.

The mod originated by SwanSong is setup to be used as follows:

1. Only delete a user's database record who has expired after a set amount of days, (30 days), BUT ONLY if the member_option (data field #2) equals "Guest".

2. If the the member_option field = "Guest" and their account has past the expiration days, then also delete there password line from the password file.

3. I have a creation_date field (data field #5) of when a user's account has been created. I am using the US date formation so this field contains a date that is formated like this: mm-dd-yyyy.

--------------------------------
DB.CFG - HTML.PL

Add the appropriate fields in both your .cfg file and within your sub html_record_form.

Example fields being used:

member_option => [2,'alpha',0,9,1,'',''],
creation_date => [5,'date',4,5,1,&get_date,''],

# RemoveAd => [26, 'numer', 4, 5, 1, '', ''],
# DateAdded => [1, 'date', 4, 5, 1, &get_date, ''],

--------------------------------
AUTH.PL

In sub auth_check_password {

After code:

open(AUTH, ">$auth_dir/$db_uid") or &cgierr("unable to open auth file: $auth_dir/$uid. Reason: $!\n");
print AUTH "$uid: $ENV{'REMOTE_HOST'}\n";
close AUTH;

add code:

&auto_delete; #### added for autodelete mod

------------------------------------
DB.CGI:

In sub main {

Add: elsif ($in{'auto_delete'}) { if ($per_admin) { &auto_delete; } else { &html_unauth; } } ### autodelete

Add the following new sub:

sub auto_delete {
# ------------------------------------------
# Automatically removes entries older then $remove # days old.
#
my $remove = 30; # Number of days old.
my $date_field = 5; # Position of date field.

my $today = &date_to_unix(&get_date);
my $removeby = $today - ($remove * 86400);
my (@lines, @values);

open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;

open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }

foreach $line (@lines) {
if ($line =~ /^#/) { next; }
if ($line =~ /^\s*$/) { next; }
chomp $line;
@values = &split_decode ($line);

if (($removeby > &date_to_unix($values[$date_field])) && ($values[2] eq 'Guest')) {
&auth_logging("System Auto-Deleted Expired Guest: $values[3],$values[2]");
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) }
@passlines = <PASS>;
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 $passline (@passlines) {
($passline =~ /^$values[$auth_user_field]:/) ?
($found = 1) :
print PASS $passline;
}
close PASS;
}
else {
print DB $line, "\n";
}
}
close DB;
}

Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/
Quote Reply
Re: User Post Control In reply to
JPDeni,

Thank you for the answer. So, I can add only number, but not unlimited function.
I saw some php can do, putting "0" is unlimited, but I guess it is not for CGI.

LoisC,

Thank you for the reply. In this case, $remove can be specified in db.cgi.
>sub auto_delete {
># ------------------------------------------
># Automatically removes entries older then $remove # days old.
>#
>my $remove = 30; # Number of days old.


Like I wrote before, I added ":$in{'remove'}" in db.cgi
print PASS "$in{'new_username'}:$encrypted:$in{'per_view'}:$in{'per_add'}:$in{'per_del'}:$in{'per_mod'}:$in{'per_admin'}:$in{'remove'}\n";

Is that possible to read the data from default.pass?
I tried my $remove = $in('remove'); but it did not work.
Quote Reply
Re: [haruchan] User Post Control In reply to
Quote:
I saw some php can do, putting "0" is unlimited, but I guess it is not for CGI.


It isn't a difference between CGI and php. It's just the way that DBMan is written. "0" means that the person doesn't have permission to add records. I suppose I could write something to make it so "U" could make it unlimited, but it seems like an awful lot of work when it's doable the way it is.

I want to be clear that it won't work just to add the numbers. You have to add all of the code in the modification file.

Quote:

Is that possible to read the data from default.pass?


Yes. There are examples of reading the data from the .pass file in the limit records modification file.

Just to be sure you understand the file I'm talking about -- http://jpdeni.com/...ds/limitrecords6.txt .


Edited to add:
Now that I look closely at the mod, I see that admin records aren't counted at all. You could also create a new permission, like Watts suggested earlier, for those who are not admins, but are allowed to add unlimited records.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: Mar 22, 2006, 1:58 PM