Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Automatically Validate + Build when user adds a link

Quote Reply
Automatically Validate + Build when user adds a link
I would like to set my site so that liks are automatically validated + Built when user adds a link, without the need for the administrtor intervention. In other words, I'd like to change the code (or settings) so that when a user adds a link, the database and webpages automatically and immediately update themselves. Can you point me to how to do this?

Thanks,

Assaf
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
Heres to put links in your database automatically http://www.gossamer-threads.com/...um3/HTML/002456.html

And uh, to make it build i'm guessing you can do this...

In add.cgi at the top where you see this
require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/nph-build.cgi";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
Put the bolded line that you see in yours

Then below, where you see this

# Send the admin an email message notifying of new addition.
&send_email;

Add this under it,
Code:
# Now we're building the database again
# This may be a long wait for the user and
# recommended for a very large database

&build_backup;
&build_url_index;
&build_detailed_view;
&build_category_information;
&build_stats;
&build_home_page;
&build_category_pages;
This looks ok, but don't know if it'll work. Oh, this could be unsafe, and i would recommend some filtering of words or something, because people could overload your links database and when you go on, you'll have to delete maybe 10000 bad or offensive, or invalid links.

Lavon
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
Thanks.
Just adding require "$db_lib_path/nph-build.cgi"; to the code as suggested casues a 500 Internal Server error. Is nph-build.cgi not set up as a library?

The validate part seems to wrok o.k.

Thanks,

Assaf
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
Of course you realize that over time your database will be devalued as unrelated sites add themselves. Sites including pornographic sites. Check out how the majour search engines are cluttered with child porn sites. No editorial control as Links is designed, and your links database will be populated with gods know what. And you (and your web host) can be held accountable for sites you list.

Plus, rebuilding the database every time someone adds their site will seriously overtax your servers cpu. If you got 100s or more links (and you will quickly when [not if] spammers discover your site), your server will rightfully shut you down ASAP.

Food for thought... Dan Smile
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
Hear, Hear!..Dan!

I agree with Dan. There are alternatives, such as using Cron jobs, to re-build the Index automatically. I empathesize with your need, assaf, to automatically rebuild the index after each addition in order to keep the database even more "dynamic." But as Dan mentioned, your Index will soon be filled with unwanted resources and you will spend more time deleting resources out of your links.db than taking the time to validate and re-build your database.

Smile

Just wanted to add my two cents.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited October 05, 1999).]
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
I would agree with Dan and Eliot, except that the particular site I am working on is an intranet site, closed to a limited number of professional people.

In our case, it is quite a burdon to have to approve evry new link.

Assaf
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
requiring nph-build.cgi will automatically build all of the pages.. it will also most likely return with a 500..

instead.. you would have to take all the subs out and put them into their own .pl file.. perhaps build.pl

and then require that from both nph-build.cgi and add.cgi..

then you would do the same thing except you would have to build_stats first..

jerry
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
OK.. none of you probably got that..

but if you wanted to build pages automatically.. and you had a big db.. it would take the user like 5 minutes to submit one link Wink

there is always the option of using CGI for everything. .i am doing this so i can save diskspace Wink

jerry
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
It works!

As widgetz suggested, I copied all the functions to a separate library and called it build.pl. I added it to the require list (instead of nph-build.cgi), and added the code that Bmxer suggested.
It took one more modification: the build finction output diagnostics to STDOUT that I needed to get rid of to get a valid html code. So I redirected the output to /dev/null. The resulting additional code block is:
# Now we're building the database again
# This may be a long wait for the user and
# recommended for a very large database&build_backup;


open (SAVED, ">&STDOUT") or &cgierr("error in process_form. unable to save STDOUT. Reason: $!");
open (STDOUT, ">/dev/null") or &cgierr("error in process_form. unable to redirect STDOUT to /dev/null. Reason: $!");

&build_url_index;
&build_detailed_view;
&build_category_information;
&build_stats;
&build_home_page;
&build_category_pages;

open (STDOUT, ">&SAVED")or &cgierr("error in process_form. unable to restore STDOUT. Reason: $!");

Thanks for all the help,

Assaf

P.S.

It works great. Our db is small with only 75 links, and I don't expect it to get larger than 200 any time in the near future, so the build is practically instanteous (sp?)

Assaf
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
interesting..

i knew that this was easy to do.. but never knew it was that easy to do Wink

i guess auto build is pretty much over with then eh?

except this doesn't do exactly what people wanted.. i remembered something like.. rebuild only pages that need to be rebuilt.. that doesn't take much.. the pages that have to be rebuilt are

home.. new.. the category (using build_single_category).. and the stats i guess..

not much to it..

jerry
Quote Reply
Re: Automatically Validate + Build when user adds a link In reply to
To cut down on mine, I have a category building cgi only, of course with stats, and homepage. I guess links could check the db_modified of a links thing, or the date of a link, see if it matches that day, and if it does, it'll just build the categories that those links are in. Of course if one is built earlier, and another link is submitted later, it'll rebuild the first one again.