Gossamer Forum
Home : Products : Links 2.0 : Customization :

Search Engine Friendly Links II - Link Title instead of ID

(Page 1 of 2)
> >
Quote Reply
Search Engine Friendly Links II - Link Title instead of ID
Hello!

I`m searching for a mod to change:

Code:
http://downloads.supernature-forum.de/cgi-bin/detail.cgi?ID=4245

to

http://downloads.supernature-forum.de/Grafik/Cover Druckstudio.html

Does already a solution exist for this problem?

I would be glad if you could help me Smile


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Is there a reason you have not upgraded to 3.2.0, because it’s a part of the upgrade version?


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Search Engine Friendly Links II - Link Title instead of ID In reply to
Hi,

Sanrda, This is Links 2 (flatfile), not Links SQL/Gossamer Links <G>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
 
Ok - it seems, that no "ready to use" mod does exist for my request.

So let me tell you about the idea behind and what I tried out in the meantime.


I decided to use the lastlink.html for testing.
------------------------------------------------------------
1. Attempt:

I added &<%Titel%> behind ...ID=<%ID%>.
Code:
<b><a href="<%db_cgi_url%>/detail.cgi?ID=<%ID%>&<%Titel%>" class="titel"><%Titel%></a></b><br>

But - of course - the results did not satisfy me.

Then I spent a lot of time searching a script which replaces spaces in <%Titel%> with characters like + or -.

I found such a script : http://forum.de.selfhtml.org/archiv/2004/12/t96253/

To try out this script, I added a new field in links.def:
Code:
echteURL => [27, 'alpha', 40, 200, 0, '', ''],

$db_echteURL = 27;


In nph-build.cgi I wrote the following code into the sub build_update_newpop sub:
(... instead of writing a completely new sub Wink )

Code:
####################### Begin of : Einschub $Echte URL #########################
# Quelle: http://forum.de.selfhtml.org/archiv/2004/12/t96253/

my($esc) = $values[$db_title];
$esc =~ s/^\s+|\s+$//gs;
$esc =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$esc =~ s/ /\+/g;
$esc =~ s/%20/\+/g;
$values[$db_echteURL] = $esc ;

####################### End of : Einschub $Echte URL #########################

In lastlink.html I changed :
&<%Titel%> to &<%echteURL %>

The results:
Code:
BMP zu AVI
http://.../cgi-bin/detail.cgi?ID=694&BMP+zu+AVI

Speziell für SoKo
http://.../cgi-bin/detail.cgi?ID=4343&Speziell+f%FCr+SoKo


I need a code sniplet to change:
spaces to -
ä to ae , Ä to Ae , ö to oe , Ö to Oe , ü to ue , Ü to Ue
, to .
/ to -


I think you still know what the results in <%echteURL%> should look like:
Speziell für SoKo => Speziell-fuer-Soko

Can anyone help me please - because I`m not a perl expert ?

Thank You Smile


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Quote:
I need a code sniplet to change:
spaces to -
ä to ae , Ä to Ae , ö to oe , Ö to Oe , ü to ue , Ü to Ue
, to .
/ to -


This will probably work for ya...

http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=288273#288273


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Search Engine Friendly Links II - Link Title instead of ID In reply to
Hello Leonard,
thank you for posting the link to your mod. Smile
I will try your mod the next days and will let you know about the results.

(Sorry for my bad english - I come from germany and my schooldays were about 20 years ago)

In the meantime I found another interesting link that helped me.

I changed the code posted above into:

Code:

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

my($esc) = $values[$db_title];
my $htm = ".html";

# 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;


# Quelle: 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/ /\-/g;
$esc =~ s/%20/\-/g;

$esc = $esc .$htm;

$values[$db_echteURL] = $esc;



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

Maybe I forgot some special characters that had to be transformed in the example above.

But as far as I tested it seems to work.

For your information:
In <%Titel%> the names of software titles are stored - such as:
- NIS @Guard AddOns
- Capturize / Capturize Pro
- BMP&GIF zu AVI ( Win98/Win 2000)

This is the reason why the content of <%Titel%> must be changed before it can be used in an url.

I will tell you later about about the next steps, progress and -surely- about the next problems.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Remember the aim was to create a real url in <%echteURL%> first.

I changed the code to:

Code:
####################### Einschub $ Echte URL #########################

my($esc) = $values[$db_title];
my $htm = ".html";

# 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/ /\-/g;
$esc =~ s/%20/\-/g;

$esc = $esc .$htm; # ads ".html" at the end of $esc

# $values[$db_echteURL] = $esc;
# Detailed.html shows : http://.../cgi-bin/detail.cgi?ID=4343&Speziell-fuer-SoKo.html
# <%echteURL%> = Speziell-fuer-SoKo.html

# <%ID%> hinzufügen - Now let`s add the $db_key
$esc = "-" .$esc;
$esc = "-" .$values[$db_key] .$esc;


# Kategorie hinzufügen - Now let`s add the category:
my($esd) = $values[$db_category];
$esd =~ s/\//-/g;
$esd = "$build_root_url/" . &urlencode($esd) . "/";
$esd = $esd .$esc;
$values[$db_echteURL] = $esd;
# Detailed.html shows : http://.../cgi-bin/detail.cgi?ID=4343&http://.../links/Grafik-Bildbearbeitung/4343-Speziell-fuer-SoKo.html
# <%echteURL%> = http://.../links/Grafik-Bildbearbeitung/-4343-Speziell-fuer-SoKo.html

####################### Einschub $ Echte URL #########################
Code:

With this result the next steps can be done.

I will tell you later my ideas -
at the moment I`m in a hurry.

Sorry for that.Angelic


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
I found one solution that I would like to introduce to you.

Version :
Gossamer Links V 2.01 - German translation by Nicky

I call this solution :

Real URL - No. I
Instead of dynamic HTML Pages (generated by detail.cgi) only -
static HTML Pages will be generated by nph-build.cgi too.


What must be done?

1. Add a new system field in links.def

2. ## Einschub $ Echte URL ## must be changed

3. Change or add an entry in links.cfg

4. Change or add an entry in nph-build.cgi

5. Change an entry in detail.cgi

Whether you have to change an entry or to add an entry depends on version and/or modification in use.



Optional steps:


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

This depends on whether you want to call the static html pages directly or whether you want to keep old links valid (for search engines)


b. Changes in aendern.cgi (Updates)

c. Changes in eintrag.cgi (New entries)


The optional changes in b. and c. are only necessary if you want to create <%echteURL%>
in eintrag.cgi or aendern.cgi too.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Real URL - No. I --- 1. Add a new system field in links.def

For example:

Code:

echteURL => [27, 'alpha', 40, 200, 0, '', ''],

.
. and:
.

Code:

$db_echteURL = 27;

Don`t forget that this must be an optional system field !


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Real URL - No. I --- 2. ## Einschub $ Echte URL ## must be changed

Code:

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

my($esc) = $rec{'Titel'};
## 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;

$esc =~ s/%26/\-und-/g; # change & character
$esc =~ s/ /\-/g;
$esc =~ s/%20/\-/g; #
$esc =~ s/\(/\-/g; # (
$esc =~ s/\)/\-/g; # )
$esc =~ s/!/\-/g; # !

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

## <%ID%> hinzufügen - Now let`s add the $db_key
$esd = $rec{'ID'} ."-" .$esd;

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

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

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

It is still possible that remaining special characters in $esc must be removed!

This code must be added into the sub build_detailed_view in nph-build.cgi.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Real URL - No. I --- 3. Change or add an entry in links.cfg

Find these lines in your links.cfg :

Code:

# Soll die Detailierte Ansicht für jeden Link erstellt werden ? (1 = ja, 0 = nein).
$build_detailed = 0;
$build_detail_path = "$build_root_path/Detailiert";
$build_detail_url = "$build_root_url/Detailiert";

and change the value of $build_detailed from 0 to 1 .

If these lines don`t exist you must add them above :

Code:
# Use templates?
$build_use_templates =
...


Now sub build_detailed_view in nph-build.cgi
does create static HTML Pages in the folder :

http://.../links/Detailiert/


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Real URL - No. I --- 4. Change or add an entry in nph-build.cgi


Find sub build_detailed_view in nph-build.cgi :

Code:

sub build_detailed_view {
# --------------------------------------------------------

# Für $echteURL muss "Einschub Echte URl" umgeschrieben werden
my (@values, $id, %rec, $count, $days_old, $Titel, $echteURL);


if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";
open (DB, "<$db_file_name") or &cgierr("Kann die Datei bzw. Verzeichnis nicht öffnen: $db_file_name. Grund: $!");
LINE: while (<DB>) {
/^#/ and next LINE;
/^\s*$/ and next LINE;
chomp;
@values = &split_decode ($_);
$days_old = &days_old($rec{'Datum'});
$id = $values[$db_key_pos];
#$echteURL = $values[$db_echteURL];
%rec = &array_to_hash (0, @values);
$title_linked = &build_linked_title ("$rec{'Kategorie'}/$rec{'Titel'}");
$category_clean = &build_clean ("$rec{'Kategorie'}");
$thiscat = ("$rec{'Kategorie'}");


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

my($esc) = $rec{'Titel'}; ## $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;

$esc =~ s/%26/\-und-/g; # change & character
$esc =~ s/ /\-/g;
$esc =~ s/%20/\-/g; #
$esc =~ s/\(/\-/g; # (
$esc =~ s/\)/\-/g; # )
$esc =~ s/!/\-/g; # !
# $esc =~ s/[/\-/g; # [
# $esc =~ s/]/\-/g; # ]
# $esc =~ s/%ae/\-/g; # Copyright character
# $esc =~ s/+/\-/g; # +
# $esc =~ s/,/\-/g; # ,
# $esc =~ s/>/\-/g; # >
# $esc =~ s/</\-/g; # <
# $esc =~ s/%/\-/g; # %
# $esc =~ s/ /\-/g; #

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

## <%ID%> hinzufügen - Now let`s add the $db_key
$esd = $rec{'ID'} ."-" .$esd; ## $db_key

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

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

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






open (DETAIL, ">$build_detail_path/$echteURL$build_extension") or &cgierr ("Kann die Detailierten Seiten nicht erstellen: $build_detail_path/$chteURL$build_extension. Grund: $!");

print DETAIL &site_html_detailed (%rec);
close DETAIL;
$use_html ?
print qq~<a href="$build_detail_url/$echteURL$build_extension" target="_blank">$echteURL</a> ~ :
print qq~$echteURL ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}

and insert ## Einschub $ Echte URL ## as shown above.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Real URL - No. I --- 5. Change an entry in detail.cgi



Open detail.cgi and find sub main :

Code:

sub main {
# --------------------------------------------------------
%in = &parse_form();

my (%rec) = &get_record ($in{'ID'});

unless ($in{'ID'}) {
&html_print_headers;
print &site_html_detailed_error ("Kein Link angegeben."); #future versions will load a form instead of an error
}

#### Redirection : Leitet altes URL Format auf neues HTML Format um:
elsif ($rec{$db_key} eq $in{'ID'}) {

my ($esd) = "http://.../links/Detailiert/" .$rec{'echteURL'} .".html";
print "Location: $esd\n\n";

}
# Original Code / Old code:
# elsif ($rec{$db_key} eq $in{'ID'}) {
# $title_unlinked = &build_unlinked_title ("$rec{'Kategorie'}/$rec{'Titel'}");
# $title_linked = &build_linked_title ("$rec{'Kategorie'}/$rec{'Titel'}");
# $thiscat = $rec{'Kategorie'};
# &html_print_headers;
# print &site_html_detailed (%rec);
# }
else {
&html_print_headers;
print &site_html_detailed_error ("Link $in{'ID'} nicht gefunden.");
}
}


Change the code as shown above.

The result is that old search engine entries are still valid and you dont even have to change entries in your html templates.

All entries like : http://.../cgi-bin/detail.cgi?ID=4964
will be redirected to their static html pages.


Andreas

Dr.Windows








Last edited by:

SevenSpirits: May 7, 2007, 10:02 AM
Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
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
Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
That`s all I did - I tried it and I found no bugs.

I hope it will function for you too.



Unfortunately I had not the the time to try Leonard`s mod in Post #5.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Testing...
I replied to this post previously, but the reply is not here. Checking to see if this one will be...


Leonard
aka PerlFlunkie
Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
I must say sorry to all those who tested the script - there is an error in the script changes.

SevenSpirits wrote:


What must be done?

1. Add a new system field in links.def
That`s right

2. ## Einschub $ Echte URL ## must be changed
Attention : New script

3. Change or add an entry in links.cfg
That`s right

4. Change or add an entry in nph-build.cgi
Attention : New script

5. Change an entry in detail.cgi
That`s right


Andreas

Dr.Windows








Last edited by:

SevenSpirits: May 11, 2007, 12:16 PM
Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
2. ## Einschub $ Echte URL ## must be changed


Code:

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

my($esc) = $values[$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;



$esc =~ s/%26/\-und-/g; # change & character

$esc =~ s/ /\-/g;

$esc =~ s/%20/\-/g; #

$esc =~ s/\(/\-/g; # (

$esc =~ s/\)/\-/g; # )

$esc =~ s/!/\-/g; # !



## Kategorie hinzuf?gen - Now let`s add the category:

my($esd) = $values[$db_category] ."-";

$esd =~ s/\//-/g;


## <%ID%> hinzuf?gen - Now let`s add the $db_key

$esd = $values[$db_key] ."-" .$esd;


$esd = $esd .$esc;

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


$values[$db_echteURL] = $esd;

$echteURL = $esd;
## <%echteURL%> = 3043-grafik-bildbearbeitung-speziell-fuer-soko

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


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
4. Change or add an entry in nph-build.cgi
Attention : New script


Two changes must be done :

Open nph-build.cgi and find sub build_update_newpop.

In sub build_update_newpop find :

Code:

print DBTMP &join_encode (&array_to_hash(0, @values));
}
close DB;
close DBTMP;

if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tKann nicht umbennen! Seltsam: $!\n";
open (DBTMP, ">$db_links_name") or &cgierr ("Kann die Datei bzw. Verzeichnis nicht öffnen: $db_links_name. Grund: $!");
open (DB, "$db_links_name.bak") or &cgierr ("Kann die Datei bzw. Verzeichnis nicht öffnen: $db_links_name.bak. Grund: $!");
while (<DB>) { print DBTMP; }
close DB;
close DBTMP;
}
}
else {
&cgierr ("Kann keine HTML Dateien erstellen! Tragen Sie mindestens ein Link in Ihre Datenbank ein, danach probieren Sie es nochmal!");
}


foreach (keys %hits) {
next unless /^\d+$/;
unlink ("$db_hits_path/$_") or &cgierr ("Kann die Datei nicht löschen: '$db_hits_path/$_'. Grund: $!");
}
}

Insert Einschub $ Echte Url (previous post) before the line : print DBTMP &join_encode (&array_to_hash(0, @values));



Find : sub build_detailed_view and change the code as posted below:

Code:

sub build_detailed_view {
# --------------------------------------------------------

my (@values, $id, %rec, $count, $days_old);


if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";
open (DB, "<$db_file_name") or &cgierr("Kann die Datei bzw. Verzeichnis nicht öffnen: $db_file_name. Grund: $!");
LINE: while (<DB>) {
/^#/ and next LINE;
/^\s*$/ and next LINE;
chomp;
@values = &split_decode ($_);
$days_old = &days_old($rec{'Datum'});
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);

$echteURL = $rec{'echteURL'};

$title_linked = &build_linked_title ("$rec{'Kategorie'}/$rec{'Titel'}");
$category_clean = &build_clean ("$rec{'Kategorie'}");
$thiscat = ("$rec{'Kategorie'}");
open (DETAIL, ">$build_detail_path/$id$build_extension") or &cgierr ("Kann die Detailierten Seiten nicht erstellen: $build_detail_path/$id$build_extension. Grund: $!");

print DETAIL &site_html_detailed (%rec);
close DETAIL;
$use_html ?
print qq~<a href="$build_detail_url/$echteURL$build_extension" target="_blank">$echteURL</a> ~ :
print qq~$echteURL ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}

Now I hope it works fine.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
SevenSpirits,

Thanks for posting your mod, I will test it out soon. Can you translate the German parts?

What I had posted before was a question to you: Were/are you familiar with the German Links sites, and do you know what has happened to them?

This one is still active:
http://www.simball.de/links_mods/index.shtml

This one is on the way out...
http://www.nicky.net/

But these others are dead...
http://www.imagefolio.de/links_mods/
http://www.links2x.de/.../downloads.php?cat=2
http://www.motorrad-link.de/LinksMod/

And this one, I'm not sure if had mods before, can't find any now...
http://www.dieblen.de/links/


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: May 11, 2007, 5:57 PM
Quote Reply
Re: [PerlFlunkie] Search Engine Friendly Links II - Link Title instead of ID In reply to
Hi Leonard,

i will translate the German parts the next days.
I think you mean the error messages. (?)

Downloads for german and english versions are still available at http://www.nicky.net/ .

I`m not familar with the other german link sites.
I`m responsible for the content and the mods on this links site : http://downloads.supernature-forum.de/links/

Feel free to try out the functions there - including adding new Entries and Updates.
(You can`t do anything wrong there - but please use Leonard as user name )

Don`t worry - the mod I posted is not built in there.
It`s because this is the official site -
the mod is implemented in our (restricted) TestArea (so I can try out each modification before)


But there ist still one line to change in: nph-build.cgi --> sub build_detailed_view :

Instead :
Code:
open (DETAIL, ">$build_detail_path/$id$build_extension") or &cgierr ("Kann die Detailierten Seiten nicht erstellen: $build_detail_path/$echteURL$build_extension. Grund: $!");

use :
Code:
open (DETAIL, ">$build_detail_path/$echteURL$build_extension") or &cgierr ("Kann die Detailierten Seiten nicht erstellen: $build_detail_path/$echteURL$build_extension. Grund: $!");

Let me know if you need any further informations.

I hope you are using Internet Explorer - it seems that the new style of this forum ist not optimized for other browsers ...

.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
I tried to translate some parts :

Post #8 of 21:

Einschub $ Echte URL = Insertion $ Real URL

Post #9 of 21:

echteURL = realURL

Post #10 of 21:

$rec{'Titel'} = $db_title

Sonderzeichen maskieren = to mask special characters

## <%echteURL%> = 3043-grafik-bildbearbeitung-speziell-fuer-soko
3043 = <%ID%>
grafik -= name of a category
bildbearbeitung -= name of one subcategory of graphics
speziell-fuer-soko - fantasy name of an entry in database

Post #11 of 21:

# Soll die Detailierte Ansicht für jeden Link erstellt werden ? (1 = ja, 0 = nein). =
# Should we build a detailed view for each link? (1 = yes, 0 = no). =

Post #13 of 21

Kein Link angegeben = you did not specify a link

Leitet altes URL Format auf neues HTML Format um = does redirect from old url format to new html format

nicht gefunden = not found

Post #14 of 21 Optional

Du hast keine URL eingetragen = you did not enter an url

Fehler. Kann die Datei bzw. Verzeichnis nicht öffnen = Error. Cannot open file or folder
Grund = reason

Diese URL wurde in der Datenbank nicht gefunden = This url wasn`t found in database

Dein Antrag auf die Linkänderung wurde bereits abgeschickt =
Your link modification request was already sent

----

Automatische Eintragung akzeptiert dieses System nicht =
this system doesn`t accept automatic entries

Post #19 of 21

Kann nicht umbennen! Seltsam = Can`t rename ... curious

Kann keine HTML Dateien erstellen! Tragen Sie mindestens ein Link in Ihre Datenbank ein- danach probierren Sie es noch mal!
Can`t create html files! Enter at the minimum one link into your database - and then try once again!

Kann die Datei nicht löschen = Can`t delete the file

.


Andreas

Dr.Windows








Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
One thing you can do to simplify your mod is to make common code snippets into a subroutine.
Change:

$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; #

into:

$esc = &cleanup;

Then make new sub, in db_utils.pl:

sub cleanup
#-----------------------------------------
# get rid of extra characters
my ($input) = shift;
$input =~ s/%26/\-und-/g; # ersetzt das & Zeichen
$input =~ s/ /\-/g;
$input =~ s/%20/\-/g;
$input =~ s/%20/\-/g; #
$input =~ s/%28/\-/g; # (
$input =~ s/%29/\-/g; # )
$input =~ s/%21/\-/g; # !
$input =~ s/%5b/\-/g; # [
$input =~ s/%5d/\-/g; # ]
$input =~ s/%ae/\-/g; # Copyright character
$input =~ s/%2b/\-/g; # +
$input =~ s/%2c/\-/g; # ,
$input =~ s/%3e/\-/g; # >
$input =~ s/%25/\-/g; # %
$input =~ s/%09/\-/g; #
return $input;
}


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: May 14, 2007, 2:51 PM
Quote Reply
Re: [PerlFlunkie] Search Engine Friendly Links II - Link Title instead of ID In reply to
Yes - a subroutine would be a smart solution- thank you for the code Smile

But first I must change the code snipplets (get rid of extra characters )
because they dont`t work as I expected.

Although i have the solution I did not have the time to do so.

But I will post the solution soon.

It`s because I wanted to know first whether this mod does function for other Versions of Links too.

Here`s a screenshot of detailed.html (TestArea) :

http://.../links/Detailiert/4359-internetprogramme-diverse-andreas-test.html

.


Andreas

Dr.Windows








Last edited by:

SevenSpirits: May 14, 2007, 3:28 PM
Quote Reply
Re: [SevenSpirits] Search Engine Friendly Links II - Link Title instead of ID In reply to
Hm ... it seems that something went wrong while editing my previous post ...

(After : It`s because I wanted to know first whether this mod does function for other Versions of Links too. )

If the mod works fine I will post the solution in a new thread.
So that no one has to read dozends of posts before he gets the final solution.


Andreas

Dr.Windows








> >