Home : Products : Links 2.0 : Customization :

Products: Links 2.0: Customization: Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID: Edit Log

Here is the list of edits for this post
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID
Real URL - No. I --- Optional steps :


a. Changes in link.html, lastlink.html and rate_top.html

Change the code as shown below:

Code:
<!-- <b><a href="<%db_cgi_url%>/detail.cgi?ID=<%ID%> class="titel"><%Titel%></a></b><br> -->

<b><a href="http://.../links/Detailiert/<%echteURL%>.html" class="titel"><%Titel%></a></b><br>




b. Changes in aendern.cgi (Updates):

Change the code as shown below:

Code:

sub process_form {
# --------------------------------------------------------
my ($key, $status, @values, $found, $esc, $esd, $del);
local (%original);

!$in{'Current URL'} and &site_html_modify_failure ("Du hast keine URL eingetragen !") and return;


open (DB, "<$db_file_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_file_name. Grund: $!");
$found = 0;
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);

# I`m using <%ID%> for update verification
if ($data[$db_key] eq $in{'Current URL'}) {

$in{$db_key} = $data[0];
$found = 1;
%original = &array_to_hash (0, @data);
last LINE;
}
}
close DB;
!$found and &site_html_modify_failure ("Diese URL wurde in der Datenbank nicht gefunden.") and return;


foreach $key (keys %add_system_fields) {
$in{$key} = $original{$key};
}


$in{$db_cols[$db_dateadded]} = $original{'Anmeldedatum'};
$in{$db_cols[$db_modified]} = &get_date;


####################### Einschub $ Echte URL #########################
##### Variante 1 : Detailed ####

$esc = $in{$db_cols[$db_title]};

## http://www.wer-weiss-was.de/theme34/article944865.html
$esc =~ s/ä/ae/g;
$esc =~ s/Ä/Ae/g;
$esc =~ s/ö/oe/g;
$esc =~ s/Ö/Oe/g;
$esc =~ s/ü/ue/g;
$esc =~ s/Ü/Ue/g;
$esc =~ s/ß/ss/g;

## http://de.selfhtml.org/perl/sprache/zeichenketten.htm#beispiel2 : Sonderzeichen maskieren
$esc =~ s/\@/-at-/g;
$esc =~ s/\//-/g;

## http://forum.de.selfhtml.org/archiv/2004/12/t96253/
$esc =~ s/^\s-|\s-$//gs;
# $esc =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$esc =~ s/([^a-zA-Z0-9_\-.()[]%ae!+,>%O9)/uc sprintf("%%%02x",ord($1))/eg;


## Remove some special characters :
$esc =~ s/\%26/\-und-/g; # ersetzt das & Zeichen
$esc =~ s/ /\-/g;
$esc =~ s/%20/\-/g;
$esc =~ s/%20/\-/g; #
$esc =~ s/%28/\-/g; # (
$esc =~ s/%29/\-/g; # )
$esc =~ s/%21/\-/g; # !
$esc =~ s/%5b/\-/g; # [
$esc =~ s/%5d/\-/g; # ]
$esc =~ s/%ae/\-/g; # Copyright character
$esc =~ s/%2b/\-/g; # +
$esc =~ s/%2c/\-/g; # ,
$esc =~ s/%3e/\-/g; # >
$esc =~ s/%25/\-/g; # %
$esc =~ s/%09/\-/g; #

## Kategorie hinzufügen - Now let`s add the category:
$esd = $in{$db_cols[$db_category]} ."-";
$esd =~ s/\//-/g;

$esd = $in{$db_cols[$db_key]} ."-" .$esd;

$esd = $esd .$esc;
$esd =~ tr/[A-Z]/[a-z]/; #change all letters to lowercase

$in{$db_cols[$db_echteURL]} = $esd;
## <%echteURL%> = 3043-grafik-bildbearbeitung-speziell-fuer-soko


## Delete the old entry or redirect to the new entry:




## The following lines are not necessary :
if($in{$db_cols[$db_isnew]} eq "Ja") {
$in{$db_cols[$db_isnew]} = "";
$in{$db_cols[$db_isnewupdate]} = "";
$in{$db_cols[$db_dateadded]} = $in{$db_cols[$db_modified]};
}


####################### Einschub $ Echte URL #########################


&check_exclude($in{'Kategorie'});
$status = &validate_record(%in);
if ($status eq "ok") {

open (MOD, "<$db_modified_name") or &cgierr ("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_modified_name. Grund: $!");
while (<MOD>) {
chomp;
@values = split /\|/;
if ($values[0] eq $in{$db_key}) {
close MOD;
&site_html_modify_failure("Dein Antrag auf die Linkänderung wurde bereits abgeschickt.");
return;
}
}
close MOD;


open (MOD, ">>$db_modified_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_modified_name. Grund: $!");
flock(MOD, $LOCK_EX) unless (!$db_use_flock);
print MOD &join_encode(%in);
close MOD;


&send_email;

&site_html_modify_success;
}
else {

&site_html_modify_failure($status);
}
}





c. Changes in eintrag.cgi (New entries)


Change the code as shown below:

Code:

sub process_form {
# --------------------------------------------------------
my ($key, $status, $line, $output);

# Check the referer.
if (@db_referers and $ENV{'HTTP_REFERER'}) {
$found = 0;
foreach (@db_referers) {
$ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last;
}
if (!$found) {
&site_html_add_failure ("Automatische Eintragung akzeptiert dieses System nicht.");
return;
}
}


foreach $key (keys %add_system_fields) {
$in{$key} = $add_system_fields{$key};
}


$in{$db_cols[$db_dateadded]} = $in{$db_cols[$db_modified]} = &get_date;





open (ID, "<$db_links_id_file_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_links_id_file_name. Grund: $!");
$in{$db_key} = <ID> + 1;
close ID;


####################### Einschub $ Echte URL #########################
##### Variante 1 : Detailed ####

my($esc) = $in{$db_cols[$db_title]};

## http://www.wer-weiss-was.de/theme34/article944865.html
$esc =~ s/ä/ae/g;
$esc =~ s/Ä/Ae/g;
$esc =~ s/ö/oe/g;
$esc =~ s/Ö/Oe/g;
$esc =~ s/ü/ue/g;
$esc =~ s/Ü/Ue/g;
$esc =~ s/ß/ss/g;

## http://de.selfhtml.org/perl/sprache/zeichenketten.htm#beispiel2 : Sonderzeichen maskieren
$esc =~ s/\@/-at-/g;
$esc =~ s/\//-/g;


## http://forum.de.selfhtml.org/archiv/2004/12/t96253/
$esc =~ s/^\s-|\s-$//gs;
# $esc =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$esc =~ s/([^a-zA-Z0-9_\-.()[]%ae!+,>%O9)/uc sprintf("%%%02x",ord($1))/eg;

## Remove some special characters :
$esc =~ s/%26/\-und-/g; # ersetzt das & Zeichen
$esc =~ s/ /\-/g;
$esc =~ s/%20/\-/g;
$esc =~ s/%20/\-/g; #
$esc =~ s/%28/\-/g; # (
$esc =~ s/%29/\-/g; # )
$esc =~ s/%21/\-/g; # !
$esc =~ s/%5b/\-/g; # [
$esc =~ s/%5d/\-/g; # ]
$esc =~ s/%ae/\-/g; # Copyright character
$esc =~ s/%2b/\-/g; # +
$esc =~ s/%2c/\-/g; # ,
$esc =~ s/%3e/\-/g; # >
$esc =~ s/%25/\-/g; # %
$esc =~ s/%09/\-/g; #

## Kategorie hinzufügen - Now let`s add the category:
my($esd) = $in{$db_cols[$db_category]} ."-";
$esd =~ s/\//-/g;

$esd = $in{$db_key} ."-" .$esd;

$esd = $esd .$esc;
$esd =~ tr/[A-Z]/[a-z]/; #change all letters to lowercase


$rec{'echteURL'} = $esd;
$echteURL = $esd;
$in{$db_cols[$db_echteURL]} = $esd;
## <%echteURL%> = 3043-grafik-bildbearbeitung-speziell-fuer-soko

####################### Einschub $ Echte URL #########################



&check_exclude($in{'Kategorie'});
$status = &validate_record(%in);
if ($status eq "ok") {


open (ID, ">$db_links_id_file_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_links_id_file_name. Grund: $!");
flock(ID, 2) unless (!$db_use_flock);
print ID $in{$db_key};
close ID;


open (VAL, ">>$db_valid_name") or &cgierr("Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen: $db_valid_name. Grund: $!");
flock(VAL, 2) unless (!$db_use_flock);
print VAL &join_encode(%in);
close VAL;


&send_email;

&site_html_add_success;
}
else {
&site_html_add_failure($status);
}
}


Andreas

Dr.Windows








Last edited by:

SevenSpirits: May 7, 2007, 10:55 AM

Edit Log: