#!/usr/bin/perl -w
#############################################################
# SHOP-Server Hauptdatei Version 3.1
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Autor: Helmut Walter
# E-Mail: webmaster@inspire-net.de
# Webseite: http://www.inspire-world.de
#############################################################
#Fehlerausgabe an Browser
use CGI::Carp qw(fatalsToBrowser);
no warnings;
# Dateiflock
use Fcntl qw(:DEFAULT :flock);
use CGI qw(:standard);
use strict;
use vars qw($dbh %tpl %setupvar %extraconf $object @names %FORM %ENV @confdata $menuespacer $templateset $shopurl $templatepfad $shopartikelmenu $templatecssurl $fbjs $usertemplatekopf $usertemplatefoot $shopuserheader $shopuserfooter
$betreiberbannercodeoben $betreiberbannercodeunten $betreiberbutton $shopsearchcookie $shoplogincookie $loidc $kcloginid $kcshopid $kcloginname $gast_or_login $shopidcookie $cookicartdaten $warenkorbsumme $warenkorbdaten
$newkorbstatus $kundencenterlink $shoptopmenue $bottomlinks $subaufrufparameter $progname $userloginprogname $picviewerprog $fehlermeldung $fehler_gefunden $errormeldung);
#use CGI;
use DBI;
my $object = new CGI;
@names = $object->param();
%FORM = map {$_ => $object->param($_)} $object->param();
$| = 1;
# Benoetigte Dateien einbinden
require "../../setup/setup.pl";
require "../../setup/tpl_lang.pl";
require "../../setup/extraconfig.pl";
require "../../routinen/module/scriptlibrary.pl";
require "../../routinen/module/datenbank.pl";
require "../../routinen/module/shoplibrary.pl";
# Name des Programms
$progname = "index.$setupvar{'installendung'}";
# Name des Login Programms
$userloginprogname = "login.$setupvar{'installendung'}";
# Name des Shop Programms
$picviewerprog = "picviewer.$setupvar{'installendung'}";
# DB Verbindung herstellen
&verbinden;
#####################################################################
# Config Daten holen
my @bn = split('/',$ENV{'SCRIPT_FILENAME'});
if ($bn[-2] =~ /^(s\d{6})$/) {
my $shid = $bn[-2];
$shid =~ s/[^0-9]//;
$shid =~ s/^(0{1,})//;
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#confid, shopid, shopnr, tplset, tplwidth, menuwidth, shoptitel, hplinktitel, hpurl, target, werbefrei, ab, bis, sperre, wegen, openclose, grund, menuart, mwstcalc, geld, ps_user, ps_admin, ps_artikel, max_topan, scaleprev, prevw, prevh, scalebig, bigw, bigh , sortfeld, sortorder
@confdata = get_configdata($bn[-2], $shid);
} else {
print "Content-type: text/html\n\n";
print qq~
Keine Daten für Shop gefunden
~;
exit;
}
# Geschlossen wegen Wartung - - - - - - - - - - - - - - - - - - - - #
if (-e "$setupvar{'cgipfad'}/setup/globalclose.txt") {
print "Content-type: text/html\n\n";
print qq~
Shop wurde wegen Wartungsarbeiten kurzzeitig geschlossen.
~;
exit;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#####################################################################
$menuespacer = $confdata[5];
$templateset = "$setupvar{'htmlverz'}/templates/$confdata[3]";
$shopurl = "$setupvar{'cgiverzeichnis'}/shops/$confdata[2]/$progname";
$templatepfad = "$setupvar{'htmlpfad'}/templates/$confdata[3]";
$shopartikelmenu = &artikelmenue;
#####################################################################
# Shoptemplatecss - - - - - - - - - - - - - - - - - - - - - - - - - #
if (!-e "$setupvar{'htmlpfad'}/usercss/$confdata[2].css") {
$templatecssurl = "$setupvar{'htmlverz'}/templatecss/$confdata[3].css";
} else {
$templatecssurl = "$setupvar{'htmlverz'}/usercss/$confdata[2].css";
}
$fbjs = qq~
~;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# User Header/Footer - - - - - - - - - - - - - - - - - - - - - - - #
$usertemplatekopf = $confdata[2] . "_kopf";
if (-e "$setupvar{'htmlpfad'}/usertemplates/$usertemplatekopf.html") {
$shopuserheader = get_usertemplate("$setupvar{'htmlpfad'}/usertemplates/$usertemplatekopf.html");
} else {
$shopuserheader = '';
}
$usertemplatefoot = $confdata[2] . "_fuss";
if (-e "$setupvar{'htmlpfad'}/usertemplates/$usertemplatefoot.html") {
$shopuserfooter = get_usertemplate("$setupvar{'htmlpfad'}/usertemplates/$usertemplatefoot.html");
} else {
$shopuserfooter = '';
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#####################################################################
# Werbefrei? und Betreiberbutton
my $test_datum = &aktuelles_datum();
# falls abgelaufen - Werbefrei auf 0
if ($confdata[10] == 1 && $confdata[12] < $test_datum) {
run_remove_werbefrei($confdata[1]);
}
# oder ...
if ($confdata[10] == 1 && $confdata[12] > $test_datum) {
$betreiberbannercodeoben = '';
$betreiberbannercodeunten = '';
} else {
if ($extraconf{'werbungtopbott'} == 1) {
$betreiberbannercodeoben = &get_bookwerbung("$setupvar{'cgipfad'}/setup/betreiberwerbung.dat");
$betreiberbannercodeunten = '';
} elsif ($extraconf{'werbungtopbott'} == 2) {
$betreiberbannercodeoben = '';
$betreiberbannercodeunten = &get_bookwerbung("$setupvar{'cgipfad'}/setup/betreiberwerbung.dat");
}
}
$betreiberbutton = get_booklogo("$setupvar{'cgipfad'}/setup/betreiberlogo.dat");
#####################################################################
# Shop offen - geschlossen? - - - - - - - - - - - - - - - - - - - - #
if ($confdata[15] == 1) { &shopfehler($confdata[16], 'Shop geschlossen', '1'); exit; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Shop gesperrt? - - - - - - - - - - - - - - - - - - - - - - - - - #
if ($confdata[13] == 1) { &shopfehler($confdata[14], 'Hinweis', '0'); exit; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#####################################################################
# Name fuer Suchcookie
$shopsearchcookie = "SEARCH-$confdata[2]";
# Ist Kunde eingeloggt?
$shoplogincookie = "LOGIN-$confdata[2]";
$loidc = cookie("$shoplogincookie");
($kcloginid,$kcshopid,$kcloginname) = split(/\|/, $loidc);
if ($kcloginname eq '') {
$gast_or_login = qq~Willkommen Gast, bitte anmelden oder registrieren~;
} elsif ($loidc ne '') {
$gast_or_login = qq~Willkommen $kcloginname abmelden~;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#####################################################################
# Shopcookie wird zur Warenkorbidentifikation benoetigt
$shopidcookie = "WK-$confdata[2]";
$cookicartdaten = cookie("$shopidcookie");
if ($cookicartdaten eq '') {
my $ende_cookdate = datumsroutine("EI","0","7200");
my $randomid = pw_gen("25", "3", "0");
print "Set-Cookie: $shopidcookie=$randomid; expires=$ende_cookdate\n";
# Warenkorb
my $korb_sek = datumsroutine("HI");
run_dbquery("DELETE FROM ".$setupvar{'prefix'}."artanzlog WHERE ($korb_sek - artkorb_sek) > 7200 AND shopid = '$confdata[1]'");
run_dbquery("INSERT INTO ".$setupvar{'prefix'}."warenkorbinfo (wkid, shopnr, randomid, geld, wktime, mwst, vsart, versandkosten, auslandversand, nnzuschlag, gesamt, mwstgesamt, zusatzvsk) VALUES ('', '$confdata[2]', '$randomid', '0.00', '$korb_sek', '0.00', '', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00')");
# Statistik updaten ###########################################
# stid, shopid, startdatum, kundenzahl, wkanzahl, letzterwk, bestellungen, gesamtwert, artikelanzahl, verkaufteartikel, logins, letzter_login
my $wks_sek = datumsroutine("HI");
run_dbquery("UPDATE ".$setupvar{'prefix'}."shopstatistik SET wkanzahl = wkanzahl + 1, letzterwk = '$wks_sek' WHERE shopid = '$confdata[1]'");
###############################################################
$warenkorbsumme = "$confdata[19] 0.00";
} elsif ($cookicartdaten ne '') {
$warenkorbdaten = get_korbsumme($cookicartdaten, $confdata[2]);
$warenkorbsumme = "$confdata[19] $warenkorbdaten";
}
if ($FORM{'incart'} eq 'ok') {
$newkorbstatus = "
Artikel wurde Warenkorb hinzugefügt";
}
if ($FORM{'nocart'} eq 'dup') {
$newkorbstatus = "
Artikel befindet sich schon im Warenkorb";
}
if ($loidc ne '') {
$kundencenterlink = "Kundencenter | ";
} else {
$kundencenterlink = '';
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
#####################################################################
# Topmenue fuer Warenkorb, Hilfe, AGB, etc. - - - - - - - - - - - - #
$shoptopmenue = qq~$kundencenterlinkIhr Warenkorb [$warenkorbsumme] | Impressum | Kontakt | AGB | Weitere Infos$newkorbstatus~;
# Fusszeile des Shops
$bottomlinks = qq~$confdata[7]~;
#####################################################################
# Shophauptmenue holen
# $shopartikelmenu = &artikelmenue;
#####################################################################
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Aufrufparameter der Haupt und Modulroutinen
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
$subaufrufparameter = $FORM{'aktion'};
$subaufrufparameter =~ s/[^0-9a-zA-Z_]//g;
if ($subaufrufparameter eq ""){ &shopstart; }
require "$setupvar{'cgipfad'}/routinen/module/shoproutinenaufrufe.pl";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Shopstartseite
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub shopstart {
my ($startseitentitel, $startseitencontent, $startseitentopangebote);
headall($confdata[6], '','');
($startseitentitel, $startseitencontent, $startseitentopangebote) = get_startseitendaten($confdata[1], $confdata[23]);
my %tplstart =(
startseitentitel => $startseitentitel,
startseitencontent => $startseitencontent,
startseitentopangebote => $startseitentopangebote,
);
print shptplparser("$templatepfad/shopstartseite.html",\%tplstart);
&footall();
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# etwaige Fehlermeldungen ausgeben
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub shopfehler {
my ($fehlertext, $fehlertitel, $jsback) = @_;
my ($jsbacklink, $titelcontent, $ausgabecontent);
headall("$confdata[6]: $fehlertitel", '','');
if ($jsback) {
$jsbacklink = "
";
} else {
$jsbacklink = '';
}
$titelcontent = "$fehlertitel";
$ausgabecontent = $fehlertext . $jsbacklink;
my %tplfehler =(
titelcontent => $titelcontent,
ausgabecontent => $ausgabecontent);
print shptplparser("$templatepfad/textausgaben.html",\%tplfehler);
&footall();
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Globalen Header ausgeben
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub headall {
my ($sektionstitel,$meta,$jscode) = @_;
# Headerblock ##########################################
&Headerout;
my %tplhead =(
shoptitle => $sektionstitel,
templatecssurl => $templatecssurl,
meta => "$meta\n$confdata[36]",
jscript => $jscode,
fbjs => $fbjs,
shopuserheader => $shopuserheader,
betreiberbannercodeoben => $betreiberbannercodeoben,
gast_or_login => $gast_or_login,
shoptopmenue => $shoptopmenue,
templateset => $templateset,
shopartikelmenu => $shopartikelmenu,
menuespacer => $menuespacer,
shopausgabebreite => $confdata[4]
);
print shptplparser("$templatepfad/globalshopheader.html",\%tplhead);
# Headerblock ##########################################
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Globalen Footer ausgeben
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
sub footall {
my %tplfoot =(
bottomlinks => $bottomlinks,
betreiberbutton => $betreiberbutton,
betreiberbannercodeunten => $betreiberbannercodeunten,
shopuserfooter => $shopuserfooter,
templateset => $templateset
);
print shptplparser("$templatepfad/globalshopfooter.html",\%tplfoot);
# Headerblock ##########################################
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
$dbh->disconnect;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #