#!/usr/bin/perl # DCLinks 2000 Version 1.1 # June 06 2000 # # Revision History # DCLinks 2000 1.1 - 06/06/2000 # - added new filelock # - added dropdown menu # # DCLinks 2000 1.0 Release on 06 Jan 2000 # - Major upgrade # DCLinks 1998 Release on 16 November 1997 # # DCLinks 2000 Version 1.000 # dclinks.setup # Jan 20 2000 # # ########## YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT ############### # Copyright ©1997-2000 DCScripts All Rights Reserved # As part of the installation process, you will be asked # to accept the terms of this Agreement. This Agreement is # a legal contract, which specifies the terms of the license # and warranty limitation between you and DCScripts and DCLinks. # You should carefully read the following terms and conditions before # installing or using this software. Unless you have a different license # agreement obtained from DCScripts, installation or use of this software # indicates your acceptance of the license and warranty limitation terms # contained in this Agreement. If you do not agree to the terms of this # Agreement, promptly delete and destroy all copies of the Software. # # Versions of the Software # -------------------------------------------------------------------------- # You may install as many copies of DCLinks Script for free # on personal and non-profit sites. Otherwise, a single license # of DCLinks is $35 (USD). # # License to Redistribute # -------------------------------------------------------------------------- # Distributing the software and/or documentation with other products # (commercial or otherwise) or by other than electronic means without # DCScripts's prior written permission is forbidden. # # All rights to the DCLinks software and documentation not expressly # granted under this Agreement are reserved to DCScripts. # # Disclaimer of Warranty # THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND # WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER # WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE # AND SOFTWARE ENVIRONMENTS INTO WHICH DCLINKS MAY BE USED, NO WARRANTY OF # FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE # ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF DCSCRIPTS WILL BE # LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE. # IN NO CASE SHALL DCSCRIPTS BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR # CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS # OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE # BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT, # NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF # DCSCRIPTS IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL # DCSCRIPT'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID # BY LICENSEE TO DCSCRIPTS. # ########################################################################### use Encode; $cgidir = "."; # NO NEED TO EDIT BELOW THIS LINE IF YOU ARE USING # THE DEFAULT SETUP require "$cgidir/dclinks.setup"; require "$cgidir/cgi-lib.pl"; require "$cgidir/dclinkslib.pl"; # OK Let's read in formdata ReadParse(); $r_in = \%in; # Cookie name $in{'cookie_name'} = "DCProtectSessionID"; # OK, before we do anything, let's check the user's session ID # If it exists then read in user data $r_in->{'userdata'} = get_session(); $j = -1; foreach (@link_fields) { $j++; $field_id{$_} = $j; } # Create files if not found check_datafile($datafile,[]); check_datafile($counter,[]); if ($in{'action'} eq 'set_sort_index') { set_sort_index($in{'field'}); exit; } elsif ($in{'action'} eq 'redirect') { update_view( $in{"id"} ); print "Location: $in{'URL'}\n\n"; exit; } # Send HTTP header to the server print_header(); # Format Comment input so that it will fit nicely in the database $in{'Description'} = form_to_text($in{'Description'}); # Depending on Form input: # 1) Display add to links form # 2) Add Link information to the database # 3) Display Links #$header = $title; $cat1 = $in{'category'}; $cat1 =~ s/\s/+/g; $menu = qq~ Página Principal | Añadir Enlace | Buscar Enlace ~; if ($r_in->{'userdata'}->{'Group'} eq 'admin') { $menu .= qq~ | Administración Directorio | Salir ~; } #ATENCIÓN AHORA SÓLO SE PERMITE AÑADIR ENLACES DESDE EL PANEL DE ADMINISTRACION DE LA SECCION DIRECTORIO $r_data = readdata($datafile); #if ($in{'action'} eq "add_form") { # print_header_end(); # $sub_header = "Por favor, rellene el siguiente formulario para añadir su página."; # add_form(); #} if ($in{'action'} eq "add_search") { print_header_end(); add_search(); } elsif ($in{'action'} eq "search_links") { print_header_end(); search_links(); } #elsif ($in{'action'} eq "add_links") { # if (incomplete_form()) { # print_header_end(); # $sub_header = "ERROR! Formulario incompleto."; # add_form(); # } # elsif (duplicate_url()) { # print_header_end(); # $sub_header = "ERROR! URL ya registrada en el directorio !!."; # add_form(); # } # else { # print_header_end(); # add_links(); # $sub_header = "Su enlace ha sido añadido a nuestra base de datos."; # $html_output = qq~ #

# Gracias por tu tiempo.
# El Colegio de Veterinarios se reserva el derecho de modificar los datos de esta referencia.
# Ir al menú principal

~; # } #} elsif ($in{'action'} eq "view_category") { $sub_header = "Enlaces en $in{'category'}"; print_header_end(); view_category(); } elsif ($in{'action'} eq 'update_rating') { update_rating($in{"id"},$in{'score'}); } elsif ($in{'action'} eq 'rate') { rating_form($in{"id"}); } else { print_header_end(); display_main(); } display_output(); exit; #======================================================================# # function display_main # displays the main categories #======================================================================# sub display_main { # Sort data according to category foreach (@{$r_data}) { my @data = split /\|/; $category_num{$data[$cat_id]}++; } $html_output = qq~ ~; toggle('reset'); my $num_cat = @Category_list; for ($j=0;$j<$num_cat/2;$j++) { toggle(); my $cat = $Category_list[2*$j]; $cat1 = $cat; $cat =~ tr/ /+/; if ($category_num{"$cat1"} eq "" ) { $category_num{"$cat1"} = "0"; } $html_output .= qq~ ~; $cat = $Category_list[2*$j+1]; $cat1 = $cat; $cat =~ tr/ /+/; if ($category_num{"$cat1"} eq "" ) { $category_num{"$cat1"} = "0"; } if ($Category_desc{$cat1}) { $html_output .= qq~ ~; } else { $html_output .= qq~ ~; } $html_output .= ""; } $html_output .= "
Directorio
$cat1 ($category_num{"$cat1"})
$Category_desc{$cat1}
$cat1 ($category_num{"$cat1"})
$Category_desc{$cat1}
 
"; } #======================================================================# # function view_category # displays links in one categorie #======================================================================# sub view_category { $category = $in{"category"}; $category =~ tr/+/ /; my $r_links = []; # Ok, first pull off all the links in this category foreach $record (@{$r_data}) { chomp($record); my @row = split (/\|/,$record); if ($row[$cat_id] eq $category) { push(@{$r_links},$record); } } my $sort_by_field = get_cookie($sort_by_field_cookie); if ($sort_by_field > 0) { $r_links = sort_topics($r_links,$sort_by_field); } my $num_links = @{$r_links}; # stuff for next and previous pages my $num_next = int(($num_links - 1)/$max_links) + 1; my $start = $in{'mm'} + 1; my $stop = $in{'mm'} + $max_links; $stop = $num_links if ($stop > $num_links); # Construct links to additional topics $stop--; $start--; my @temp_out; for ($j=1;$j<=$num_next;$j++) { my $marker = ($j-1)*$max_links; my $j_start = ($j-1)*$max_links + 1; my $j_stop = $j*$max_links; $j_stop=$num_links if ($j_stop > $num_links); if ($marker == $start) { push(@temp_out,$j); } else { my $cat = $category; $cat =~ s/ /+/g; push(@temp_out, "$j" ); } } my $pages = join(" \| ",@temp_out); if ($num_next > 1) { $html_output = qq~
~; } $html_output = qq~
Listado ordenado por $sorted_by_trans{$sort_by_field}
Ordenar por : Nombre | Novedades | Más vistos | País
~; foreach (@$r_links[$start..$stop]) { toggle(); my @link = split /\|/; my ($ltime,$ldate) = split (/\s/,$link[$field_id{"Date"}]); $ltime = time_format($ltime); $ldate = date_format($ldate); my $score = rating( $link[$field_id{"Rating"}] ); unless ($score eq "NA") { $score = sprintf("%.1f",$score); } my $votes = votes( $link[$field_id{"Rating"}] ); $link[$field_id{"Homepage"}] =~ s/http:\/\///g; $html_output .= qq~
$link[$field_id{"ID"}]~; if ($r_in->{'userdata'}->{'Group'} eq 'admin') { $html_output .= qq~ D
E
~; } $html_output .= qq~
$link[$field_id{"Name"}]
http://$link[$field_id{"Homepage"}]

$link[$field_id{"Description"}]
$link[$field_id{"EMail"}]

$ldate $ltime $link[$field_id{"Views"}] Vistas $votes Votos Puntuación: $score Califica este web
 
~; } $html_output .= qq~ ~; if ($num_next > 1) { $html_output .= qq~ ~; } $html_output .= qq~
~; } #======================================================================# # addd_links # #======================================================================# #sub add_links { # my $r_data = readdata($datafile); # my $id = get_number(); # my ($ltime,$ldate) = get_date(); # $ldate = $ltime. " " . $ldate; # $in{'ID'} = $id; ## $in{'Date'} = $ldate; # $in{'Views'} = 0; # foreach $field (@link_fields){ #$in{$field} =~ s/\|/\s/g; # push(@fields,$in{$field}); # } # my $newline = join("\|",@fields); # $newline .= "\n"; # unshift(@{$r_data},$newline); # writedata("$datafile",$r_data); #} #======================================================================# # duplicate_url # #======================================================================# #sub duplicate_url { # foreach (@{$r_data}) { # if ($_ =~ /$in{'Homepage'}/) { # return 1; # } # } # return 0; #} #======================================================================# # incomplete_form # #======================================================================# sub incomplete_form { print "\n"; foreach $field (@link_fields) { if ($in{$field} eq "" || $in{$field} eq " ") { unless ($field eq "ID" or $field eq "Views" or $field eq "Rating" or $field eq "Date") { push(@ERROR,$field); return 1; } } } return 0; } #======================================================================# # add_form # #======================================================================# #sub add_form { # $html_output = qq~ #
# # # # # ~; # foreach (@link_fields) { # $html_output .= table_row($_,$field_input_type{$_}); # } # $html_output .= qq~ # # # #
Envíe su página
# borrar
#
# ~; #} #======================================================================# # get_number # # get next counter number for a new link # #======================================================================# sub get_number { my $num; open(F,"$counter") or my_die ("Can't read from $counter",$!); flock(F,2); $num = ; flock(F,8); close(F); if ($num eq "" or $num < 1) { $num = 1; } else { $num++; } open(F,">$counter") or my_die ("Can't write to $counter",$!); flock(F,2); print F $num; flock(F,8); close(F); $num; } #======================================================================# # search_links # #======================================================================# sub search_links { my $r_links = []; my $search_string = "$in{'Name'} $in{'Category'} $in{'Description'} $in{'Country'}"; $search_string =~ s/\s+//g; # Ok, first pull off all the links in this category foreach $record (@{$r_data}) { chomp($record); my @row = split (/\|/,$record); $res = 1; foreach $field (@search_fields) { $res =0 if $in{$field} && $row[$field_pos{$field}] !~ /$in{$field}/i; } push(@{$r_links},$record) if $res; } my $sort_by_field = get_cookie($sort_by_field_cookie); if ($sort_by_field > 0) { $r_links = sort_topics($r_links,$sort_by_field); } my $num_links = @{$r_links}; # stuff for next and previous pages my $num_next = int(($num_links - 1)/$max_links) + 1; my $start = $in{'mm'} + 1; my $stop = $in{'mm'} + $max_links; $stop = $num_links if ($stop > $num_links); # Construct links to additional topics $stop--; $start--; my @temp_out; for ($j=1;$j<=$num_next;$j++) { my $marker = ($j-1)*$max_links; my $j_start = ($j-1)*$max_links + 1; my $j_stop = $j*$max_links; $j_stop=$num_links if ($j_stop > $num_links); if ($marker == $start) { push(@temp_out,$j); } else { my $cat = $category; $cat =~ s/ /+/g; push(@temp_out, "$j" ); } } my $pages = join(" \| ",@temp_out); $html_output = qq~
Enlaces encontrados: $num_links
Listado ordenado por $sorted_by_trans{$sort_by_field}
Ordenar por : Nombre | Novedades | Más vistos | País

~; foreach (@$r_links[$start..$stop]) { toggle(); my @link = split /\|/; my ($ltime,$ldate) = split (/\s/,$link[$field_id{"Date"}]); $ltime = time_format($ltime); $ldate = date_format($ldate); my $score = rating( $link[$field_id{"Rating"}] ); unless ($score eq "NA") { $score = sprintf("%.1f",$score); } my $votes = votes( $link[$field_id{"Rating"}] ); $link[$field_id{"Homepage"}] =~ s/http:\/\///g; $html_output .= qq~
$link[$field_id{"ID"}]~; if ($r_in->{'userdata'}->{'Group'} eq 'admin') { $html_output .= qq~ B
M
~; } $html_output .= qq~
$link[$field_id{"Name"}]
http://$link[$field_id{"Homepage"}]
$link[$field_id{"Country"}]
$link[$field_id{"Description"}]
$link[$field_id{"EMail"}]
$ldate $ltime $link[$field_id{"Views"}] Vistas $votes Votos Puntuación: $score Califica este web
 
~; } $html_output .= qq~
~; } #======================================================================# # add_search # #======================================================================# sub add_search { $html_output = qq~
  ~; foreach (@search_fields) { $html_output .= table_row_search($_,$field_input_type{$_}); } $html_output .= qq~
Buscar enlace
Por favor, utilice uno o varios de los siguientes criterios
~; } 1;