Gossamer Forum
Home : Products : DBMan : Customization :

Problem with autodelete & cookie mod

Quote Reply
Problem with autodelete & cookie mod
I got relational mod installed and then try to add autodelte mod and cookie mod without success. The problems are as follows:

Autodelete mod (Automatically removes entries older than a predetermined date):
I added the fields in cfg file

'DateAdded' => [ 6, 'date', 20, 255, 1, &get_date(), ''],
'Removeby' => [7, 'date', 4, 5, 1, '', '']

I added a sentence in sub html_record_form
<INPUT TYPE="TEXT" NAME="Removeby" SIZE="20" VALUE="$rec{'Removeby'}" MAXLENGTH="255">
When I try to add an item to my item db, I get error message saying either not correct date format or length no matter what I input such as 02/07, 02-07 or number of days. Since the max length in the Removeby field is 5, I could not figure out what format of date should I put in that field. (I run it on windows 98)

Cookie mod (by Eli Finkelman) problem:

When I load the login page, I get a runtime error (This error doesnot appear in NS. ):
Line: 72
Error: 'document.form1' is not a object.

If I ignor this error message and continue login and choose cookie to remember my login info, it doesn't work the next time I login in.

Thanks in advance.

Long

Quote Reply
Re: Problem with autodelete & cookie mod In reply to
With the auto-deletion mod, the following:

Code:

'Removeby' => [7, 'date', 4, 5, 1, '', '']


Should be an numer field, like the following:

Code:

Removeby => [7, 'numer', 4, 5, 1, '', '']


BTW: You do not need single quotes for Field Names that have only one word in them.

About the Cookie Mod...I will have to defer this to the author of the Mod or other DBMAN users who have successfully installed it...I don't use it.

Regards,

Eliot Lee
Quote Reply
Re: Problem with autodelete & cookie mod In reply to
Thanks, Eliot
Should user input a DATE by which the ad expires or a NUMBER indicating the number of days after which the ad expires?

Long
Long


Quote Reply
Re: Problem with autodelete & cookie mod In reply to
Actually the field should be a numer field (I have edited my previous post)....

And what you should do is use a drop-down menu, with the following steps:

1) Add the following codes in your %db_select_field hash:

Code:

Removeby => '1,7,14,30,60,90,120,150,180,210,240,270,300,330,360',


2) Then add the following codes in your sub html_record_form in the html.pl file:

Code:

Remove Record: |; print &db_select_field("Removeby",$rec{'Removeby'}); print qq|


OR you can use the build_fancy_select_field for the Removeby field, by adding the following codes in your html.pl file:

Code:

sub build_fancy_select_field {
# --------------------------------------------------------
#
# To call this subroutine from html_record_form, use the following syntax:
#
# print &build_fancy_select_field("FieldName",$rec{'FieldName'});
#
# Be sure to express the field name *exactly* as it is defined in your .cfg file.
#

my $field = $_[0];
my $compare = $_[1];
my %selector = (
'Removeby' => [
['---','Choose one of the following:'],
['1','Today'],
['7','One Week'],
['14','Two Weeks'],
['30','One Month'],
['60','Two Months'],
['90','Three Months'],
['120','Four Months'],
['150','Five Months'],
['180','Six Months'],
['210','Seven Months'],
['240','Eight Months'],
['270','Nine Months'],
['300','Eleven Months'],
['365','Year'],
],
);
$output = qq|<SELECT NAME="$field">\n|;
$i = 0;
while ( $selector{$field}[$i][0] ) {
$selector{$field}[$i][0] eq $compare ?
($output .= qq|<OPTION VALUE="$selector{$field}[$i][0]" SELECTED>$selector{$field}[$i][1]\n|) :
($output .= qq|<OPTION VALUE="$selector{$field}[$i][0]">$selector{$field}[$i][1]\n|);
++$i;
}
if ($i) { $output .= "</SELECT>"; }
else { $output = "Incorrect field definition"; }
return $output;

}


Then replace the codes in Step 2 I gave with the following codes:

Code:

Remove Record: |; print &build_fancy_field("Removeby",$rec{'Removeby'}); print qq|


Regards,

Eliot Lee
Quote Reply
Re: Problem with autodelete & cookie mod In reply to
This is what extacly I expected. it works great.

There is a typing error in the sub name of the statement below, it should be &build_fancy_select_field. You may want to change it in case somebody else need it.

Remove Record: |; print &build_fancy_mult_field("Removeby",$rec{'Removeby'}); print qq|

Thanks a lot

Long



Quote Reply
Re: Problem with autodelete & cookie mod In reply to
Good...and you're welcome...

I have edited my previous post.

Regards,

Eliot Lee
Quote Reply
Problem with autodelete & cookie solved In reply to
I am sorry I commented the <form ......> statement within the print qq| tag hoping to keeping the original code in place when installing the cookie mod. How stupid I was. So the cookie mod is working now. Eliot solved my another problem with delete mod.

Quote Reply
Re: Problem with autodelete & cookie solved In reply to
So, both of your problems are solved, right???

Good.

Regards,

Eliot Lee
Quote Reply
Re: Problem with autodelete & cookie mod In reply to
In Reply To:
When I try to add an item to my item db, I get error message saying either not correct date format or length no matter what I input such as 02/07, 02-07 or number of days.
What autodelete mod are you using? What is the definition of the RemoveBy field in your .cfg file?

As for the cookie mod, you didn't set it up as the mod directs. Try doing it exactly as the mod instructs. Once it works, you can try to change it.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Problem with autodelete & cookie mod In reply to
Looks to me like this problem is solved. Tongue

Regards,

Eliot Lee
Quote Reply
Re: Problem with autodelete & cookie mod In reply to
Well excuse the heck out of me.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Problem with autodelete & cookie mod In reply to
Thanks Eliot and JPD for replies. I got another stupid question: How the expiration is implemented. As stated in the instruction, it's not really automatic, so on my side, how the records can be deleted "automatically". ( I am using the autodelete mod from http://webmagic.hypermart.net/dbman/).

Long

Quote Reply
Re: Problem with autodelete & cookie mod In reply to
If you included:

&auto_delete; #### added for autodelete mod

In your auth.pl file within sub auth_check_password

Then it should check for files to delete when users login.

Hope this helps, I can't find the post where I put all the steps for setting up the autodelete with my classifieds.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Problem with autodelete & cookie mod In reply to
Yes, I followed all the instructions during installation. Yesterday, I added some records and set the exprie day to 1 day. Today when I logged on, those records are still there.

I just found actually the autodelete feature is deleting my user db, not my item db which has a field specifying the expiring date. Every time a user login, the user's record in the user db is deleted automatically.

I appreciate any clues.

Thanks

Long

Quote Reply
Re: Problem with autodelete & cookie solved In reply to
Hi, Elot

I realized that my autodeletion mod just deletes my user db instead of item db. I use Relational mod and autodelete mod (automatically removes entries older than a predetermined date). Maybe the mod I used is designed for non relational db.

I noticed that JPD has an Autodelete for multiple databases mod. I tried to install it, I could not find the place in db.cgi sub validate_record where a line is supposed to be added there. Since you have give me some codes for this mod and I'd prefer to specify number of days to determin how long a record should exist instead of using a date, I guess you may have the autodelet mod to be used with relational mod. Thanks for your help

Long

Quote Reply
Re: Problem with autodelete & cookie solved In reply to
I know that the autodelete mod was written before there was any discussion of relational databases. It very well could be that it will need to be rewritten.

In Reply To:
I noticed that JPD has an Autodelete for multiple databases mod.
Where? I have never written an autodelete mod to my knowledge. Can you give me the url of this mod?


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Problem with autodelete & cookie solved In reply to
Thanks for your reply.
I am sorry I am not sure if this is yours, but found lots of your mods there.
http://webmagic.hypermart.net/dbman/autodelm.txt

Do you think this autodelete mod for multiple db will work with relational mod?

Long


Quote Reply
Re: Problem with autodelete & cookie solved In reply to
That's Lois's script. I haven't looked closely at it, but she's probably using it on her database which is relational.

I'll let her answer any other questions you have, though, since she has experience with it.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Problem with autodelete & cookie solved In reply to
Long:

I received your email and will respond here for others who may be following the thread.

Correct me if I'm wrong, but you chose to use this version:
Automatically removes entries older than a predetermined date.

Using in your cfg file:

'DateAdded' => [ 6, 'date', 20, 255, 1, &get_date(), ''],
'Removeby' => [7, 'date', 4, 5, 1, '', '']

If so, your original fields were setup correctly. The removeby field would contain the date you want the record deleted.
If you want to use: Automatically removes entries older then $remove # days old, then you could change the field to a number.

So the first question is which variation of the mod are you using?

I have this running with my classifieds and have it setup to autodelete records in 6 category databases.
It was very easy to do this using the user friendly mod, and placing the arrays within my format.pl file.

I have mine setup to remove the ad a day after the ad expires.
So the coding within http://webmagic.hypermart.net/dbman/autodelm.txt takes all that into consideration.

I'm sure you would only need to modify the first two lines in the other version to

my $remove = 30; # Number of days old.
my $date_field = 3; # Position of date field.

with:

foreach $db (@autodelete) {
my ($removeby_field,$dateadded_field,$db_file_name) = split /\|/, $db;

and then use the following codes from autodelm.txt

#### setups for autodelete mod ####
####@autodelete[#]= 'remove_by field number|date_added field number|database name';
####@autodelete[#]= 'remove_by field number|expires field number|database name'; ### using expired field

You would setup one line for each of the databases that you want to use this in.
And then check that you are making all the changes stated with the mod.
Also be sure to change the code to match your field names.

Please also note that the example presented is for use with a classifieds system in which "Expires" is calculated to be AdDate * duration.

If this doesn't help, maybe if you explain exactly what you are wanting to do it would help.
Exactly which variation of the autodelete are you wanting to use?
How do you want to date to be determined, etc.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Problem with autodelete & cookie solved In reply to
Hi, Lois

Thank you very much for your reply. First let me make my case clear. I installed DBman with relational mod and currently I only have two db: user and item, and will add more item dbs. The potential use of dbman on my site would be managing classfied ads. I hope it will do this:
Ask user to input how many days he would like his ad to exist. I think inputing the length of time is more reasonable than inputing a future date. So the field for this would be "numer". I have tried the "Automatically removes entries older than a predetermined date" mod, as I said it only delete records in the user db.

I also read the autodelete mod for multiple dbs, and found it needs to insert a line into sub validate_records in the db.cgi script. However I didnot find the place in that sub where the line is supposed to be inserted. Another place I don't quite understand is to insert some array statements into format.pl. Like this:
@autodelete[0] = '5|6|this.db';
@autodelete[1] = '8|3|that.db';
@autodelete[2] = '10|0|theother.db';

Where extactly I should put these lines? are they a subroutine?

So, first I would like you to point out to me which variation I should use to fit my need. Second, if you would suggest the mod for multiple dbs, I would appreciate it very much if you could answer my question regarding this mod.

Best,

Long








Quote Reply
Re: Problem with autodelete & cookie solved In reply to
Yes it will manage classified ads just fine, as I'm using this for Oregon Classifieds at: http://www.lanecountyauction.com/classads.htm

If you are not using the user friendly mod then you can add the array codes to your .cfg files.

The line you were referring to in the db.cgi file that you were unable to find noted that it was for use with the validate record mod. If you are not using this then it wouldn't be necessary.

It's really difficult to help you without knowing what you field names are, and what html.pl version you are using. But from the notes you should just be able to rename the fields I have used to match yours.

How are you calculating the expire date? Are you using the examples provided in autodelm.txt

These codes:

@autodelete[0] = '5|6|this.db';
@autodelete[1] = '8|3|that.db';
@autodelete[2] = '10|0|theother.db';

tell the script which fields to look in for each database to perform the delete funtions.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Problem with autodelete & cookie solved In reply to
Hi, LoisC, Thanks for reply.
I visited your site, that is what extactly I want to do especially the field "ad duration".

I figured out the problem. there are two varible names from the two mods do not match, $removeby_field and $removeby. When I made them consistent, it works fine. Without you, I could not have fixed this bug. Thank you very much.

Long


Quote Reply
Re: Problem with autodelete & cookie solved In reply to
So glad I could help. I wasn't sure if I was just confusing you more Smile

I'm glad I keep good notes or I wouldn't remember myself how I did something after awhile. The FAQ is just my way of keeping notes of all the great pieces of code provided in the forum.

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/