Gossamer Forum
Home : Products : Links 2.0 : Customization :

Preventing Duplicate ID's

Quote Reply
Preventing Duplicate ID's
Can anyone come up with a mod that would warn the admin when he tries to add a link whose ID already exists? For example, "Warning! This ID already exists. Are you sure you want to overwrite it?"

See this thread for more details about this problem: http://www.gossamer-threads.com/...m11/HTML/000826.html

Thank you.
Quote Reply
Re: Preventing Duplicate ID's In reply to
you can just take it out all together and do something like add.cgi

it get's the current number in linksid.txt and you will never have a problem Smile

jerry
Quote Reply
Re: Preventing Duplicate ID's In reply to
You mean take out the ID field in the admin panel?
Quote Reply
Re: Preventing Duplicate ID's In reply to
sort of Smile

i don't think you can take it out though..

it prints it based on the links.def..

you can say

if ($field ne "ID") {

Smile
Quote Reply
Re: Preventing Duplicate ID's In reply to
You're losing me. Smile

If you have the time, would you mind giving me detailed instructions? Thanks.
Quote Reply
Re: Preventing Duplicate ID's In reply to
umm.. have you tried altering the link id Smile

it doesn't write over it or whatever.. it finds the next availible number and writes on that Smile
Quote Reply
Re: Preventing Duplicate ID's In reply to
This is the problem:

Quote:
It seems that if one user starts to add a link while you are adding a link at the same time, you may both end up with the same ID number. If you don't watch out for this, you will have two links pointing to the same place from the directory.

Or see this thread:

http://www.gossamer-threads.com/...m11/HTML/000826.html
Quote Reply
Re: Preventing Duplicate ID's In reply to
nah.. Smile it's called filelocking

if they submit it at the same exact time.. (that is SO hard to do) i beleive the server will give you a busy message..

you know.. Server Too Busy..

like microsoft.com's ftp site Smile

jerry
Quote Reply
Re: Preventing Duplicate ID's In reply to
Hi,

--------- quote -------------------------
if they submit it at the same exact time.. (that is SO hard to do) i beleive the server will give you a busy message..
--------- End ---------------------------

i have the same problem on my dedicated unix server. The server supports file locking and is configured to handle our scripts. On the project where we use Links 2.0 we have about 1600 Visitors a day, and we also do a lot of recherching and submit many new links every day via the admin area ourself.

It is especially a problem, if someone installs the external rating on his page and realizes, that he rates for other peoples link.

This should be fixed by alex i belive.

We test 2 times a day, with a perl script via cron job for double idīs. If there is one, we get a warning email. But this is not a real solution.

Karl
Quote Reply
Re: Preventing Duplicate ID's In reply to
if i knew what the problem was.. i would make a mod.. but i have never heard or seen it happen to anyone..

but i am sure it's a small modify of db.pl.. in sub add_record

jerry
Quote Reply
Re: Preventing Duplicate ID's In reply to
I think the real solution would be to not assign an ID number until after the user submitted link has been validated by the admin.

That way only the admin script would be handing out ID numbers and could control which ones get used.

Of course you may run into the same problem if you have multiple administrators, but would be much less likely.

Dan O.
Quote Reply
Re: Preventing Duplicate ID's In reply to
Not all servers support file locking, and file locking is only advisory with flock anyway. Another program, or even process, can read right through it.

All of my problems have been traced to file locking (well, 90% of them at least).

I'm on Solaris 2.7, and I've resorted to lock-file usage and making sure each program checks first -- if it's able to create the lock-file, then it knows for sure it has the lock on the file. The bigger flat-file databases get, and the more active your sites get, the more important it is to make sure only one read/write or read-then-write process can access the database at the same time.
Quote Reply
Re: Preventing Duplicate ID's In reply to
i had this problem afew times myself. i wish there is a real solution but the way i do it:
i setup links2 to send me an e-mail everytime
someone submit a link and if i get an e-mail while adding links myself, i double check the id# to see if it's assigned before i validate it and if it does exsit then just change the id# (links2 only) the program will tell you it validated the old id# but actually it validate it the new one. just search for the old id# and the new id# and we will see i'm right. i hope this helps
Quote Reply
Re: Preventing Duplicate ID's In reply to
Actually, Links2 DOES have built in protection. (well, my copy (which is unchanged) does anyway. (-: )

Lets say I just added a link with an ID of 212. Then I use the back button and add a new link, but forget to change the ID. Links will automatically make it 213.

This is pretty good protection against idiocity. It's not perfect, but has saved me many times over. (-: It won't protect you against users adding at the same time, but it'll help yourself.

Owen
Quote Reply
Re: Preventing Duplicate ID's In reply to
Owen,

Yes, if you go back and resubmit the link, it will add it with a new ID number. But, if you reload the add success page, it doesn't and, in fact, will give you an ID number like 123|123. That will break your database real fast.

I like the idea of not having an ID number assigned until the administrator validates the link. That would seem to be the best way of handling this problem. I'll look into that for a possible mod as soon as I get the time.
Quote Reply
Re: Preventing Duplicate ID's In reply to
To PugDog
I have been concerned about this problem as my server (Unix Apache) does not support flock due to the cgi-bin being on another server and flock doesnt operate across network file systems.
I have been looking at using a lock file but but I need to learn more perl & Unix before I attempt it, any posting of pointers to using lock files with links2 appreciated, thanks.
chmod