Gossamer Forum
Home : Products : Links 2.0 : Customization :

Site of the day MOD Posted here!

(Page 2 of 3)
> > > >
Quote Reply
Re: Site of the day MOD Posted here! In reply to
enhost I had the same problem, but cured it by replacing the path to the complete path to links.cfg, i.e. /home/ID/public_html/pat/to/links/admin/links.cfg.

Try this and it should work.

Jerry
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Hi,

IS there anyway we can incorporate the <%rate_img%> tag so it will show the image of the stars along with the random link?

Thanks...

------------------
BeatBox Entertainment
beat-box.com
Ron Newbigging

Quote Reply
Re: Site of the day MOD Posted here! In reply to
Copy the relevant code from site_html_link to site_html_site_of_day. Make appropriate changes to your template file. It should work...
Quote Reply
Re: Site of the day MOD Posted here! In reply to
I tried changing the path in the file to the full path to my links.cfg file.. however it still produces the same message any ideas?

------------------
Extreme Network Hosting
http://www.enhost.com
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Eliot,
Could you give an example what HTML code should be put in between here ? (sorry, I don't even know much about HTML!)

sub site_html_site_of_the_day {
# --------------------------------------------------------
# This routine determines how the sotd page will look like.
#
my %rec = @_;
$output = qq~
PUT YOUR HTML HERE!
(you can use $rec{ ***** })
~;
return $output;
}
Quote Reply
Re: Site of the day MOD Posted here! In reply to
instead of

Code:
# Pull out the total number of links.
open (COUNT, "<$db_hits_path/index.count") or &error ("unable to open index count file: $db_hits_path/index.count. Reason: $!");
$count = int <COUNT>;
close COUNT;
# Get the random line from the url lookup database.
srand;
$find = 0; $rand = int (rand ($count + 0.5)); ($rand == $count) and ($rand--);
open (URL, "<$db_url_name") or &error ("unable to open url database: $db_url_name. Reason: $!");
while (<URL> ) {
$find++ == $rand or next;
/(.+)$delim/o or next;
$id = $1;
last;
}
close URL;
$id or &error ("Can't find random line: $rand.");
if ($id =~ /^\d+$/) {
my (%rec) = &get_record ($id);
($rec{$db_key} eq $id) ?
&build_page :
&error ("Random ID $id is not a valid ID.");
} else {
&error ("Can't find random Links ID: $id.");
}

i think you should use this.. it only opens the databases once.. yours does it three times plus it scans them twice.. this way it just gets the link directly once..

Code:
open DB, "<$db_file_name";
@links = <DB>;
close DB;

%rec = &array_to_hash (0, &split_decode ($links[int rand $#links]));
&build_page;

beleive me.. it does go faster.. it gets rid of excess code..

jerry
Quote Reply
Re: Site of the day MOD Posted here! In reply to
ok.. i have a question for everyone.. has anyone ever gotten this script to work?? cause i just read through the code and all it is going to do is return a blank template with no link information on it..

ok.. here is a rewrite.. it will work with templates and non templates..

sotd.cgi
Code:
#!/usr/local/bin/perl

$txtfile = '/path/to/sotd.txt';

# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
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/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
# ========================================================

eval { &main; }; # Trap any fatal errors so the program hopefully
if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.
exit; # There are only two exit calls in the script, here and in in &cgierr.

sub main {
# --------------------------------------------------------
open (DB, "<$db_file_name") or &cgierr ("Can't Open DB: $db_file_name");
my @links = <DB>;
close DB;
my %rec = &array_to_hash (0, &split_decode ($links[int rand $#links]));
open (SOTD, ">$txtfile") or &cgierr ("Can't Open FILE: $txtfile. Reason: $!");
print SOTD &site_html_sotd (%rec);
close SOTD;

$ENV{'REQUEST_METHOD'} and print "Content-type: text/plain\n\n";
print "ID: $rec{$db_key} Title: $rec{'Title'}\n";
}

site_html.pl
Code:
sub site_html_sotd {
# --------------------------------------------------------
# This routine determines how the sotd link will look like.
#
my %rec = @_;
my ($output);
$output = qq~
<a href="$rec{'URL'}">$rec{'Title'}</a><br>
~;
return $output;
}

site_html_templates.pl
Code:
sub site_html_sotd {
# --------------------------------------------------------
# This routine determines how the sotd link will look like.
#
my %rec = @_;

# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

return &load_template ('sotd.html', {
%rec,
%globals
});
}

sotd.html
Code:
<a href="<%URL%>"><%Title%></a><br>

then you can run this via cron..

read www.gossamer-threads.com/scripts/resources/Detailed/244.html for help

and then using SSI.. you can attach it to a page..

Code:
<!--#include virtual="sotd.txt"-->

jerry


[This message has been edited by widgetz (edited January 17, 2000).]
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Yea...I got the original codes to work just fine!

Decent edits of the codes, Jerry.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Site of the day MOD Posted here! In reply to
I got it to work as well, with a few mods tho.
I will try with the new code tho.

Now, the question is, is there anyway to have the script not call the same link again till it has gone through them all, or something similar?


Derek
http://www.djmixes.com


[This message has been edited by Predator (edited January 10, 2000).]
Quote Reply
Re: Site of the day MOD Posted here! In reply to
For your latter mod, I would add a new field wasSOTD to your DB, have SOTD check wasSOTD, and either throw it out and choose again if yes or use it and mark it yes if no. Shouldn't be too difficult a mod... but it would substantially increase the processing time for SOTD if, say, you only had a couple valid links left in a large DB (remember, it would loop until it randomly got a valid link). A better approach would be to load in the valid links from the beginning...

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)


[This message has been edited by oldmoney (edited January 10, 2000).]
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Stupid Question Time

This crontab...is it to be done manually everynight by me or is it automatic?

Cause I might not be near my comp every night!

But if it is manually it would be nice for site of the month.....

Gian
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Crontab is a server package that AUTOMATES execution of scripts in your server.

Look at the FAQ in the Resource Center!

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Site of the day MOD Posted here! In reply to
it's only easy to do those kind of database things to MySQL databases.. Smile

you can can change a field like what oldmoney said and then you make a query like

Code:
while (1) {
SELECT * FROM Links WHERE wasSOTD = 'No'
if ($hits > 0) {
$rand = int rand $hits;
SELECT * FROM Links WHERE wasSOTD = 'No' LIMIT 1, $rand
# You get the link here..
last;
}
else {
UPDATE Links TO wasSOTD = 'Yes'
}
}

or something like that.. since it loops around til it gets a link, if you don't have any links it will create an infinite loop.. but that can be fixed easily..

jerry
Quote Reply
Re: Site of the day MOD Posted here! In reply to
I have successfully got Widgetz sotd.cgi working from the browser window and it produces a sotd.txt. However, although it runs it produces a 500 server error page.

Is there anyway to prevent this ?
Quote Reply
Re: Site of the day MOD Posted here! In reply to
There are some print codes you can add in. I would recommend running this script via crontab, which you won't see the error message. It is basically a cosmetic error via the web browser.

Add the following codes:

Code:
print "Content-type: text/html\n\n";
print "Site of Day Completed.";

AFTER the following codes:

Code:
&error ("Can't find random Links ID: $id.");
}

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Site of the day MOD Posted here! In reply to
doug.. i added two lines of code.. one line to determine if you are using the web browser or telnet and the other just prints the ID and Title.. that way when used on the web browser it won't give the 500 and on telnet it won't print Content-type: text/plain

jerry
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Thanks Eliot, I used the print codes you suggested and this worked. At the present time I prefer to manually update my site but may use crontab in the future.

Thanks Widgetz for a useful script, despite the two lines of code my browser still came back with a 500 error ? why
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Crontab or Windows Scheduler is A LOT easier than having to manually execute this script everyday. If you forget to execute it, then users will be confused, if you are truly using this has a site of the day script.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




Quote Reply
Re: Site of the day MOD Posted here! In reply to
Hi!

Is there a way that i can only build detailed pages when a site has been chosen as site of the day?

Instead of having a whole directrory full of detailed views?!!


Thanks

Gian
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Use Widgetz' detailed.cgi which builds detailed pages on the fly, as opposed to static HTML.

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)
Quote Reply
Re: Site of the day MOD Posted here! In reply to
Cool Thanks!!!

Gian
Quote Reply
Re: Site of the day MOD Posted here! In reply to
 
Quote:
For your latter mod, I would add a new field wasSOTD to your DB, have SOTD check wasSOTD, and either throw it out and choose again if yes or use it and mark it yes if no. Shouldn't be too difficult a mod... but it would substantially increase the processing time for SOTD if, say, you only had a couple valid links left in a large DB (remember, it would loop until it randomly got a valid link). A better approach would be to load in the valid links from the beginning...
Quote:
it's only easy to do those kind of database things to MySQL databases..
you can can change a field like what oldmoney said and then you make a query like


code:
--------------------------------------------------------------------------------

while (1) { SELECT * FROM Links WHERE wasSOTD = 'No' if ($hits > 0) { $rand = int rand $hits; SELECT * FROM Links WHERE wasSOTD = 'No' LIMIT 1, $rand # You get the link here.. last; } else { UPDATE Links TO wasSOTD = 'Yes' }}

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

or something like that.. since it loops around til it gets a link, if you don't have any links it will create an infinite loop.. but that can be fixed easily..

Did anyone actually get around to this in perl??!!

It would be a great help!

Thanks

Gian
Quote Reply
Re: Site of the day MOD Posted here! In reply to
The codes that Widgetz provided ARE Perl codes, yet they work with MYSQL tables.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. :)
----------------------








Quote Reply
Re: Site of the day MOD Posted here! In reply to
So how i can i encorporate this into Link 2



[This message has been edited by Gian (edited January 30, 2000).]
Quote Reply
Re: Site of the day MOD Posted here! In reply to
I would like to incorporate the build_linked_title into my sotd template, so the site of the day will have the category listed on it. I'm unsure how to start this. I'm using widgetz' mod above. Any suggestions?

------------------
Marie Altobelli
Dragonsblood Ink. Librarian
http://dbink.hostingcheck.com
> > > >