#!/usr/bin/perl
use lib '../cgi-bin';
use strict vars;
use English;
use Time::Local;
use File::Basename;
require 'urlencoding.pm';
require 'toolbox.pm';
require 'db_wrapper.pm';
#---------------------------------------------------------------------------------------------------------
#--
#-- A n z e i g e m o d u l
#--
#--
#-- Mit diesem Script werden WML-Verweise aus einer Datenquelle sortiert ausgegeben.
#-- Die Ausgabe kann WML oder HTML sein.
#--
#--
#-- sm.cgi
#--
#-- 03.05.2000 SK Logging eingebaut
#-- 11.04.2000 SK Überschriften verbessert
#-- 21.03.2000 SK Profile in den Security-Bereich verschoben
#-- 11.03.2000 SK Unterkategorien eingebaut
#-- 06.02.2000 SK Suche nach Sprache des WAP-Angebots eingebaut, EMail-Dienst
#-- 24.01.2000 SK An Pflege-CGIs angepasst verbessert
#-- 10.01.2000 SK HTML-Ausgabe verbessert
#-- 09.01.2000 SK Rohgerüst erstellt
#--
#---------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------
# Allgemeine Variablen
#---------------------------------------------------------------------------------------------------------
my $zeile = "";
my $scripting = "WML";
my $br = "";
my $htmlbr = "";
my $grth = "";
my $i = 0;
my $count = 0;
my $maxcount = 10;
my $anz_kat = 63;
my $ausgabe = "";
my $ausgabecount = 0;
my $sprache = 0; # 0=Deutsch, 1=Englisch
my $sprachetyp = "de";
my $angebotssprache = "";
my $suchtyp = "";
my $sorttyp = "";
my $anzeigetyp = "";
my $aufruf = "";
my $suchbegriff = "";
my $sterne = "****";
my $kn = ""; # Kategorienummer
my $kn_suche = "";
my $kat_name = "";
my $vonpos = 0;
#---------------------------------------------------------------------------------------------------------
# Dateipfade und Basisverzeichnisse
#---------------------------------------------------------------------------------------------------------
if ($scripting eq "WML") {$i=3;} else {$i=7;} # /wap/ bzw. /cgi-bin/
my $CGIPATH = dirname($PROGRAM_NAME,"");
my $ROOTPATH = substr($CGIPATH,0,length($CGIPATH)-$i);
my $StatistikDatei = $ROOTPATH."security/statistik.txt";
my $DBDatei = $ROOTPATH."security/urls.csv"; # bzw. mySQL-DB
#---------------------------------------------------------------------------------------------------------
my %CGI_Input = ();
#---------------------------------------------------------------------------------------------------------
# DB-Felder
#---------------------------------------------------------------------------------------------------------
my $urlid = "";
my $userid = "";
my $html = "";
my $wml = "";
my $sprachecontent = "";
my $schluesselworte = "";
my $kategorie = "";
my $top10 = "";
my $bemerkung = "";
my $titel = "";
my $klickrate = "";
my $erstellungsdatum = "";
my $aenderungsdatum = "";
my $zweck = "";
my $land = "";
my $beschreibung = "";
my $device = "";
my $qs_flag = "";
my $zielgruppe = "";
#---------------------------------------------------------------------------------------------------------
# eindimensionale Arrays
#---------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------
# mehrdimensionale Arrays
#---------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------
# Ausgabetexte
#---------------------------------------------------------------------------------------------------------
my @c_title1 = ("WubscH","WubscH");
my @c_title2 = ("Suchmodul WAP-Angebote","Search module WAP-Sites"); # HTML-Fenstertitel
my @c_title3 = ("Dienste","Services");
my @c_title4 = ("Hilfe","Help");
my @c_title5 = ("Fehler","Error");
my @c_title6 = ("Kategorien","Categories");
my @c_title7 = ("EMail senden","Send an EMail");
my @s_title1 = ("Sprache","Language");
my @s_title2 = ("Ausgabe","Output");
my @s_title3 = ("Sortierung","Sorting");
my @s_title4 = ("Angebotssprache","Item language");
my @i_title1 = ("Suchbegriff","Search item");
my @i_title2 = ("Ergebnisse","Results");
my @i_title3 = ("Anzeigen","Show");
my @i_title4 = ("Senden","Send");
my @fehler_text1 = ("Unbekannte Spracheinstellung","Language unknown");
my @fehler_text2 = ("Öffnen der Datenbank ist fehlgeschlagen","Cannot open database");
my @fehler_text3 = ("Unbekannter Suchtyp","Unknown search type");
my @fehler_text4 = ("Unbekannter Anzeigetyp","Unknown output type");
my @fehler_text5 = ("Kann Statistikfile nicht finden","Statistikfile not found");
my @fehler_text6 = ("Unbekanntes Scripting","Scripting unknown");
my @fehler_text7 = ("Unbekanntes WAP-Angebotssprache","Unknown language for WAP-Sites");
my @text2 = ("Suchbegriff","Searchitem");
my @text3 = ("nicht gefunden bei Selektion","not found for selection");
my @text4 = ("Bitte Option Nummernauswahl waehlen","Please choose Use Number option");
my @text5 = ("Suchbegriff Auflistung","Search-text listing");
my @text6 = ("Anzahl Ergebnisse","Number of results");
my @text7 = ("Sprache Suchmodul","Language of searchmodule");
my @text8 = ("Ausgabeformat","Output format");
my @text9 = ("Auflistung nach","Listing");
my @text10 = ("Sprache WAP-Angebot","Language of WAP-Site");
my @text11 = ("für Sprache","for language");
my @text12 = ("An","To");
my @text13 = ("Von","From");
my @text14 = ("Betreff","Subject");
my @text15 = ("Nachricht","Message");
my @href1 = ("Waehlen","Dial");
my @href2 = ("--> Suchen","--> Search");
my @href3 = ("Dienste","Services");
my @href4 = ("Hilfe","Help");
my @href5 = ("--> Weitere Treffer","--> More hits");
my @href6 = ("Kategorien","Categories");
my @href7 = ("Konfiguration","Configuration");
my @href8 = ("Eurotaschenrechner","Euro-Calculator");
my @option11 = ("Deutsch","German");
my @option12 = ("Englisch","English");
my @option21 = ("Link auf ","Link to ");
my @option22 = ("-Angebot","-Site");
my @option23 = ("mit Datum","with date");
my @option24 = ("mit Klickrate","with clickrate");
my @option24 = ("Link auf Beschreibung","Link to description");
my @option31 = ("Datum","Date");
my @option32 = ("TOP10","TOP10");
my @option33 = ("A-Z","A-Z");
my @option34 = ("Kategorie","Categorie");
my @option35 = ("Schluesselwort","Keyword");
my @option36 = ("Klickrate","Clickrate");
my @option38 = ("Index","Index");
my @option39 = ("Kategorien","Categories");
my @option41 = ("Jede","Every");
my @option42 = ("Deutsch","German");
my @option43 = ("Englisch","English");
my @label1 = ("Zurück","Back");
#---------------------------------------------------------------------------------------------------------
# Hashes
#---------------------------------------------------------------------------------------------------------
my %selected_anzeigetyp;
my %selected_suchtyp;
my %selected_sprache;
my %selected_angebotssprache;
my %sorthash;
my %anzeigemodul = ("WML"=>"sm2.cgi","HTML"=>"sm.cgi");
##########################################################################################################
if ($scripting eq "HTML") {
&httpHeader();
} else {
&wtpHeader();
}
# open (TEST, "> /tmp/suchen.txt") || die;
%CGI_Input = &ParseInput();
&Input_aufbereiten(\%CGI_Input); # Adresse wird übergeben
# Spracheinstellung vornehmen
if (($CGI_Input{SP} eq "de") || ($CGI_Input{SP} eq "")) { # default
$sprache = 0;
$sprachetyp = "de";
} elsif ($CGI_Input{SP} eq "en") {
$sprache = 1;
$sprachetyp = "en";
} else {
if ($scripting eq "HTML") {
HTML_Fehlermeldung("$c_title5[0]", "$fehler_text1[0]"); # deutsche Meldung
} else {
WML_Fehlermeldung("$c_title5[0]", "$fehler_text1[0]"); # deutsche Meldung
}
exit 0; # habe fertig!
}
if ($scripting eq "HTML") { # Formularauswahl
$selected_sprache{$sprachetyp} = "selected";
} else {
$selected_sprache{$sprachetyp} = "";
}
# Scripting überprüfen
if (($scripting ne $CGI_Input{SC}) && ($CGI_Input{SC} ne "")) {
if ($scripting eq "HTML") {
HTML_Fehlermeldung("$c_title5[0]", "$fehler_text6[$sprache]");
} else {
WML_Fehlermeldung("$c_title5[0]", "$fehler_text6[$sprache]");
}
exit 0; # habe fertig!
}
# Scriptspezifika definieren
if ($scripting eq "HTML") {
$br = " ";
print "";
print " ";
}
# Anzeige Ergebnis
if ($count eq 0) { # keine Treffer
print "$text2[$sprache] \"$suchbegriff\" $text3[$sprache] $suchtyp $text11[$sprache] $angebotssprache\n";
} else { # mind. ein Treffer
# Sortierung über hash, Problem bei gleichen Schlüsselwerten ???
# foreach $i (sort { $sorthash{$b} cmp $sorthash{$a} } keys %sorthash) {
$ausgabecount = 0;
if ($suchtyp eq "Datum") { # neuestes Datum zuerst
foreach $i (sort { $b cmp $a } keys %sorthash) {
if ($ausgabecount == $vonpos) { # erstes weglassen
print $sorthash{$i};
} else {
if (($vonpos < $ausgabecount) && ($ausgabecount < $vonpos+$maxcount)) {
print $br.$sorthash{$i};
}
}
$ausgabecount++;
}
} else { # normale Sortierung über Schlüssel
foreach $i (sort { uc($a) cmp uc($b) } keys %sorthash) { # Groß/Kleinschreibung ignorieren
if ($ausgabecount == $vonpos) { # erstes weglassen
print $sorthash{$i};
} else {
if (($vonpos < $ausgabecount) && ($ausgabecount < $vonpos+$maxcount)) {
print $br.$sorthash{$i};
}
}
$ausgabecount++;
}
}
if ($vonpos+$maxcount < $count) { # zu viele Treffer
$vonpos = $vonpos+$maxcount; # weiterschalten
if ($scripting eq "HTML") {
print "
";
$htmlbr = "
";
$grth = ">";
} else {
$br = "
";
$htmlbr = "";
$grth = "/>";
}
# Sprache WAP-Angebots
if (($CGI_Input{AS} eq "") ||
($CGI_Input{AS} eq "*") ||
($CGI_Input{AS} eq "de") ||
($CGI_Input{AS} eq "en")) {
if ($CGI_Input{AS} eq "") {
$angebotssprache = "*"; # default
} else {
$angebotssprache = $CGI_Input{AS};
}
if ($scripting eq "HTML") {
$selected_angebotssprache{$angebotssprache} = "selected"; # Formularauswahl
} else {
$selected_angebotssprache{$angebotssprache} = "";
}
} else {
if ($scripting eq "HTML") {
HTML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text7[$sprache]");
} else {
WML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text7[$sprache]");
}
exit 0; # habe fertig!
}
# Einstellung des Suchtyps
if (($CGI_Input{ST} eq "") ||
($CGI_Input{ST} eq "Datum") ||
($CGI_Input{ST} eq "TOP10") ||
($CGI_Input{ST} eq "A-Z") ||
($CGI_Input{ST} eq "Index") ||
# ($CGI_Input{ST} eq "Klickrate") ||
($CGI_Input{ST} eq "sw")) {
if ($CGI_Input{ST} eq "") {
$suchtyp = "Index"; # default
} else {
$suchtyp = $CGI_Input{ST};
}
if ($scripting eq "HTML") {
$selected_suchtyp{$suchtyp} = "selected"; # Formularauswahl
} else {
$selected_suchtyp{$suchtyp} = "";
}
} else {
if ($scripting eq "HTML") {
HTML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text3[$sprache]");
} else {
WML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text3[$sprache]");
}
exit 0; # habe fertig!
}
# Einstellung des Suchbegriffs
$suchbegriff = $CGI_Input{SB};
# Einstellung der Kategorie-Nummer
$kn = $CGI_Input{KN};
if ($kn eq "") {
$kn = "0000";
}
$kat_name = db_wrapper::get_kat_info($kn,1);
# Einstellung der Ausgabeposition
if ($CGI_Input{AB} eq "") {
$vonpos = 0;
} else {
$vonpos = $CGI_Input{AB};
}
# Einstellung des Ausgabeformates
if (($CGI_Input{AT} eq "") ||
($CGI_Input{AT} eq "st") ||
# ($CGI_Input{AT} eq "Klickrate") ||
($CGI_Input{AT} eq "be") ||
($CGI_Input{AT} eq "da") ) {
if ($CGI_Input{AT} eq "") {
$anzeigetyp = "st"; # default
} else {
$anzeigetyp = $CGI_Input{AT};
}
if ($scripting eq "HTML") {
$selected_anzeigetyp{$anzeigetyp} = "selected"; # Formularauswahl
} else {
$selected_anzeigetyp{$anzeigetyp} = "";
}
} else {
if ($scripting eq "HTML") {
HTML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text4[$sprache]");
} else {
WML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text4[$sprache]");
}
exit 0; # habe fertig!
}
# Umkopieren von Parametern
if ($CGI_Input{ER} ne "") {
$maxcount = $CGI_Input{ER};
}
# Logging
if ($suchbegriff ne "") {
toolbox::Logging("I",basename($PROGRAM_NAME,""),"main","SB=$suchbegriff,ER=$maxcount,SP=$sprachetyp,KN=$kn,ST=$suchtyp,AT=$anzeigetyp,AS=$angebotssprache");
}
# Statistik öffnen
if (!open (STATISTIKFILE, "< $StatistikDatei")) {
if ($scripting eq "HTML") {
HTML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text5[$sprache]:".$StatistikDatei);
} else {
WML_Fehlermeldung("$c_title5[$sprache]", "$fehler_text5[$sprache]:".$StatistikDatei);
}
exit 0; # habe fertig!
}
$zeile =
\n"; } # Suchbegriff Auflistung print "$text5[$sprache]\n"; if ($scripting eq "HTML") { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; # print "\n"; print "\n"; # Anzahl Ergebnisse print "$htmlbr$text6[$sprache]\n"; if ($scripting eq "HTML") { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; # Sprache Suchmodul print "$htmlbr$text7[$sprache]\n"; print "\n"; # Ausgabeformat print "$htmlbr$text8[$sprache]\n"; print "\n"; # Submit if ($scripting eq "HTML") { print "$br\n"; } else { } if ($scripting eq "HTML") { print "\n"; } if ($scripting eq "HTML") { print ""; print "(C) 2002, WubscH\n"; } print "
\n"; if ($scripting eq "WML") { print "\n"; print "$meldung\n"; print "
\n"; print "