#!/usr/bin/perl ######################################################################################### # In der ersten Zeile dieses Skriptes (#!/usr/bin/perl) muss der Pfad zur Perl-Version # # auf Ihrem WebServer angegeben sein. Weitere Details ersehen Sie in der # # Installationsanleitung. # ######################################################################################### # The preceding line must contain the path to the Perl installation on your web server. # # For further details see the installation manual. # ######################################################################################### # ContRay - Professional Website Engine - Release 3 Enterprise Edition # # Copyright © 2001-2008 ContRay [wwww.contray.de] # # ContRay is a registered trademark (No. 305 41 569) in Germany. All rights # # on the software are reserved by Kai Lange, Von-Anckeln-Str. 8, D-21029 Hamburg. # # The global marketing of ContRay be subject to Andreas Schwope, # # ContRay - Marketing und Vertrieb, Am Thie 13, D-31087 Landwehr. # # All rights reserved. # ######################################################################################### # # # Lesen Sie diese Bedingungen vor dem Einsatz der Software! Sollten Ihnen eine # # abweichende Lizenzvereinbarung beim Kauf von ContRay zugrunde gelegen haben, # # haben ggf. die dortigen Garantiebestimmungen Gültigkeit. # # # # Eine erweiterte Lizenzbestimmung steht Ihnen auf der ContRay Website zur Verfügung # # und ist der Software beigefügt. # # # # Unrechtmäßige Benutzer von ContRay, die ContRay ohne den Erwerb einer gültigen # # Lizenz benutzen, unterliegen dem deutschen und internationalen Recht und werden # # aufgrund von Lizenzbetrug von uns verfolgt und angeklagt. Der Gerichtsstand # # ist Hamburg, Deutschland. # # # # Mit dem Kauf, der Installation, dem Download oder anderer Art und Weise des # # in Besitzbringens dieser Software und dem betrachten, kopieren, verändern oder # # sonstiger Behandlung dieser Software, dem Sourcecode oder Teilen des # # Sourcecodes (inklusive diesen Bedingungen) erklären Sie sich mit diesen # # Bedingungen einverstanden. Sofern Sie damit nicht einverstanden sind, löschen # # Sie die Software unwiderruflich von Ihrem Computer und vernichten Sie ggf. # # vorhandene Kopien der Software. # # # # Die Copyright-Inhaber und/oder die Verkäufer dieser Software übernehmen unter # # keinen Umständen eine Haftung für die fehlerfreie Funktion dieser Software. # # ContRay ist eine Script-Software mit voller Sourcecode-Verfügbarkeit. Eine # # korrekte Funktionsweise kann aufgrund der nicht vorhanden automatischen # # Installationsmöglichkeit durch eine Setuproutine nicht zugesichert werden. # # Auf Wunsch installiert der Verkäufer gegen Berechnung die Software. # # Sofern die Software von anderen, als von den Verkäufern selbst installiert # # wird, gilt die Software als Verkauft unter Ausschluss jeglicher Gewährleistung. # # Da der Verkäufer keinerlei Einfluss auf die korrekte Intallation und # # Konfiguration der Software nehmen kann, trägt der Käufer alle Risiken des # # Betriebes der Software. Wie bei anderer Software dieser Art kann der Einsatz # # der Software einen vollständigen Ausfall der Systeme, auf denen die Software # # betrieben wird und der im Netzwerk verbundenen System zur Folge haben. Ebenso # # ist ein vollständiger Verlust aller Daten in der betriebenen Serverumgebung # # möglich. Dieses Risiko gehen Sie mit der Installation dieser Software ein. # # EINE HAFTUNG HIERFÜR IST AUSDRÜCKLICH AUSGESCHLOSSEN. # ######################################################################################### # # # Please read these terms before using the software! If you bought ContRay with a # # different license arrangement the guarantee agreement stated there might be the # # valid one. # # # # An extended license arrangement can be found on the ContRay web site and is added to # # the software. # # # # Users who install and use ContRay without a valid license are subject to German and # # international law and will be prosecuted. Venue is Hamburg, Germany. # # # # You agree to these terms by buying, installing, downloading or receiving the software # # in a different way, by viewing, copying, changing or using the software, the source # # code or part of the source code (including these terms). If you do not agree to these # # terms you must delete the software irrevocably from your computer and you must delete # # each copy of the software you have. # # # # The owners of the Copyright and/or the vendors of the software cannot be held liable # # for the error-free working of the software. ContRay is a script software with an # # open source code. An error-free working cannot be guaranteed due to the fact that # # there is no automatic installation routine. # # If the licensee wishes the vendor will install the software for a charge. # # If the software is not installed by the vendor it is sold without any warranty. # # Since the vendor cannot influence installation and configuration the licensee assumes # # all risks of running the software. As with all software of this kind running the # # software can cause a complete breakdown of the systems that run the software and a # # complete breakdown of the systems that are in the same network. It is also possible # # that all data on the server is lost. By installing the software the licensee assumes # # this risk. # # NEITHER THE PRODUCER OF THE SOFTWARE NOR THE VENDOR IS LIABLE FOR THESE DAMAGES. # ######################################################################################### use CGI qw(:standard); use CGI::Carp 'fatalsToBrowser'; ######################################################################################### # Geben Sie denn vollen Pfad zur variables.cfg an: # # Enter the full path to the variables.cfg: # # z.B. /home/yourdomain/cgi-bin/contray/variables.cfg # ######################################################################################### require("variables.cfg"); ######################################################################################### # NEHMEN SIE KEINE ÄNDERUNGEN UNTERHALB DIESER POSITION VOR! # # ===================================================================================== # # DO NOT MODIFY BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING. # ######################################################################################### require($contraypath."language.".$languageFile); require($contraypath."admin/session-lib.pl"); my $title = $LangSitemap; sub fprint; # what links should we create my $static = ( param('link') eq 'static' ) ? 1 : 0; my %pathtbl = parse_pathtbl(); # Set path to $temppath (for preview mode) $temppath = param("DATA"); if ($temppath ne "" && !$static) { $livepath = $temppath; } $temppath = '' if $static; # read data from index.dat and id.group.dat &read_data(); # show header &show_header($title, $MENU); &show_template(); &show_footer(); &ExitProc; ############################################################################ ### Name: read_data ############################################################################ sub read_data { if (open(FILE, $livepath."index.dat")) { while() { $_ =~ s/\n//g; ($fID,$fGROUP,$fTYPE,$fTITLE,$fTEMPLATE,$fSORT,$fINFO,$fCOUNT) = split(/:/,$_); $fTEMPLATE =~ s/ //g; if (($fID eq $ID) and ($GROUP eq $fGROUP)) { $TEMPLATE = $fTEMPLATE; $TITLE = $fTITLE; $SORT = $fSORT; $INFO = $fINFO; if($SORT eq "") { $SORT = "FALSE"; } } if (($fID eq "000") and ($fTYPE ne "H")) { push (@MainMenu,"$fTITLE:$fID:$fGROUP:$fTYPE:$fTEMPLATE:$fSORT:$fINFO:$fCOUNT"); } if(($fID eq "000") and ($fGROUP eq "001")) { if( $static ){ $MENU = '' . $fTITLE . ' Powered by ContRay Content Management System'; } else { $MENU = '' . $fTITLE . ' Powered by ContRay Content Management System'; } } } close(FILE); } } ############################################################################ ### Name: numericbyte ############################################################################ sub numericbyte { ($ID1,$ID2,$ID3,$ID4,$ID5,$ID6,$ID7,$ID8) = split(/:/, $a); ($IX1,$IX2,$IX3,$IX4,$IX5,$IX6,$IX7,$IX8) = split(/:/, $b); $ID1 <=> $IX1; } ############################################################################ ### Name: show_template ############################################################################ sub show_template { $VARLOOP = ""; $CopyCheck = "FALSE"; if (open(FILE, $templatepath."sitemap.html")) { while() { if($_ =~ /<%SITEMAP%>/) { $_ =~ s/<%SITEMAP%>//g; &PrintLoop; } else { $_ =~ s/<%TITLE%>/$LangSitemap/g; $_ =~ s/<%contrayurl%>/$webcgi/g; $_ =~ s/<%root%>/$webwww/g; $_ =~ s/<%gfxurl%>/$webgfx/g; $_ =~ s/<%media%>/$webmedia/g; $_ =~ s/<%NAVIGATION%>/$MENU/g; $_ =~ s/<%DATAPATH%>/$temppath/g; if($_ =~ /<%COPYRIGHT%>/) { $Copyright = $LangCopyright; $Copyright.= "\n"; if ($languageFile eq "de") { $Copyright.= "\n"; if($temppath ne "") { $Copyright.= " - $LangPreview - \n"; } $_ =~ s/<%COPYRIGHT%>/$Copyright/g; } fprint $_; } } close(FILE); } else { fprint "No template : $TEMPLATE for $TITLE\n"; } } ############################################################################ ### Name: PrintMainMenu ############################################################################ sub PrintMainMenu{ ($sTITLE,$sID,$sGROUP,$sTYPE,$sTEMPLATE,$sSORT,$sINFO,$sCOUNT) = split(/:/,@MainMenu[0]); if ($sCOUNT ne "") { @temparray = (); foreach $NAME (@MainMenu) { ($P1,$P2,$P3,$P4,$P5,$P6,$P7,$P8) = split(/:/, $NAME); push(@temparray, "$P8:$P1:$P2:$P3:$P4:$P5:$P6:$P7"); } @temparray2 = sort numericbyte @temparray; @MainMenu = (); foreach $NAME (@temparray2) { ($P1,$P2,$P3,$P4,$P5,$P6,$P7,$P8) = split(/:/, $NAME); push(@MainMenu, "$P2:$P3:$P4:$P5:$P6:$P7:$P8"); } } for ($c = 0 ; $c < @MainMenu ; $c ++) { $temp = $_; ($sTITLE,$sID,$sGROUP,$sTYPE,$sTEMPLATE,$sSORT,$sINFO,$sCOUNT) = split(/:/,@MainMenu[$c]); if (($sTYPE eq "L") and (substr($sINFO,0,5) eq "/$sTITLE/g; $temp =~ s/<%ID%>/$sID/g; $temp =~ s/<%GROUP%>/$sGROUP/g; if($sTYPE eq "U") { $T = "ID=$sID&GROUP=$sGROUP"; $OpenB = " ){ s/\s+$//; my ( $group, $num, $type, $title, $template, $sort, $info, $sidx ) = split /:/; # skip hidden entries next if $type eq 'H'; $template =~ s/§/:/g; my $pointer = $tree; for( my $i = 0; $i < length($group); $i += 3 ){ my $triple = substr $group, $i, 3; $pointer->{ $triple } ||= { order => [] }; $pointer = $pointer->{ $triple }; } $pointer->{ $num } ||= {}; $pointer->{ $num }->{type} = $type; $pointer->{ $num }->{title} = $title; $pointer->{ $num }->{group} = $group; $pointer->{ $num }->{num} = $num; $pointer->{ $num }->{tmpl} = $template; $pointer->{ $num }->{sort} = $sort; $pointer->{ $num }->{info} = $info; $pointer->{ $num }->{sidx} = $sidx; if( $info =~ /^/ ){ $pointer->{ $num }->{group} = $group . $num; $pointer->{ $num }->{num} = $1; } push @{ $pointer->{order} }, $num; } close DATA; } #use Data::Dumper; #die Data::Dumper::Dumper( $tree ); # skip root $tree = $tree->{'000'}; # sort subentries @{ $tree->{order} } = sort { $tree->{$a}{sidx} <=> $tree->{$b}{sidx} } @{ $tree->{order} }; foreach my $key ( @{ $tree->{order} } ) { print_tree( $tree->{$key} ); } } sub print_tree { my $tree = shift || return; print '
'; if( $tree->{order} ) { printf '', $webgfx, 'folder.gif'; fprint sprintf ' %s', $webcgi, $tree->{group}, $tree->{num}, $temppath || '', $tree->{title}; print '
'; # sort subentries @{ $tree->{order} } = sort { $tree->{$a}{sidx} <=> $tree->{$b}{sidx} } @{ $tree->{order} }; foreach my $key ( @{ $tree->{order} } ) { print_tree( $tree->{$key} ); } } else { if( $tree->{type} eq 'U' ){ printf '', $webgfx, 'url.gif'; fprint sprintf ' %s
', $tree->{tmpl}, $tree->{sort} eq 'TRUE' ? ' target="_blank"' : '', $tree->{title}; } else { printf '
', $webgfx, 'html.gif'; fprint sprintf ' %s
', $webcgi, $tree->{group}, $tree->{num}, $temppath || '', $tree->{title}; } } print '
'; } ############################################################################ ### Name: show_header ############################################################################ sub show_header { $l_TITLE = $_[0]; $l_MENU = $_[1]; fprint header( -charset => $LangInputCharset ); if (open(FILE, $templatepath."header.html")) { while() { if($_ =~ /<\/title>/i) { $_ =~ s/<\/title>/<\/title>\n /ig; } $_ =~ s/<%TITLE%>/$l_TITLE/g; $_ =~ s/<%NAVIGATION%>/$l_MENU/g; $_ =~ s/<%root%>/$webwww/g; $_ =~ s/<%gfxurl%>/$webgfx/g; $_ =~ s/<%contrayurl%>/$webcgi/g; $_ =~ s/<%DATAPATH%>/$temppath/g; $_ =~ s/<%meta[123]%>//g; $_ =~ s/<%contrayhead[123]%>//g; if($_ =~ /<%MAINMENU%>/) { &PrintMainMenu; } else { $_ =~ s/<%ID%>/$ID/g; $_ =~ s/<%GROUP%>/$GROUP/g; } fprint "$_"; } close(FILE); } } ############################################################################ ### Name: show_footer ############################################################################ sub show_footer { if (open(FILE, $templatepath."footer.html")) { while() { $_ =~ s/<%root%>/$webwww/g; $_ =~ s/<%gfxurl%>/$webgfx/g; $_ =~ s/<%contrayurl%>/$webcgi/g; if($_ =~ /<%COPYRIGHT%>/) { $Copyright = $LangCopyright; $Copyright.= "\n"; if ($languageFile eq "de") { $Copyright.= "\n"; if($temppath ne "") { $Copyright.= " - $LangPreview - \n"; } $_ =~ s/<%COPYRIGHT%>/$Copyright/g; } fprint "$_"; } close(FILE); } } #------------------------------------------------------------------------------------------------------ sub fprint { foreach my $str ( @_ ){ print $static ? convert_links( $str ) : $str; } } sub parse_pathtbl { my %tbl = (); open( PTBL, '<'.$datapath.'path.tbl' ) || return; local $/ = "\037"; while( defined( my $record = ) ){ my ( $key, $val ) = split /\036/, $record; $val =~ s/\037$//; $tbl{$key} = $val; } close PTBL; return wantarray ? %tbl : \%tbl; } sub convert_links { my $data = shift; while( $data =~ m/=("[^"]*contray\.cgi(\?[^"]*)?"|'[^']*contray\.cgi(\?[^']*)?'|\S*contray\.cgi(\?\S*)?)/ ){ my $u = $1; my $p = quotemeta $u; my $q = substr( $u, 0, 1 ); $q = ( $q eq '"' ) ? $q : ( ( $q eq "'" ) ? $q : '"' ); # determine id & group my ($id) = $u =~ /[?&;]ID=(\d+)/i; my ($group) = $u =~ /[?&;]GROUP=(\d+)/i; $id = length($id) ? $id : '000'; $group = length($group) ? $group : '001'; # finally replace "contray.cgi?foobarbaz" with a static url... $data =~ s/=$p/'=' . $q . $pathtbl{$id.$group} . $q/e; } # convert links to dynamic components $data =~ s/sitemap\.cgi(\?)?/'sitemap.cgi?link=static' . ( $1 ? '&' : '' )/eg; $data =~ s/search\.cgi(\?)?/'search.cgi?link=static' . ( $1 ? '&' : '' )/eg; $data =~ s/contact\.cgi(\?)?/'contact.cgi?link=static' . ( $1 ? '&' : '' )/eg; # We need seriously changes in the nearer future... we should think about a framework for adding thoose scripts as plugins. $data =~ s/(]+ACTION=[^>]*sitemap\.cgi[^>]*>)/$1/ig; $data =~ s/(]+ACTION=[^>]*search\.cgi[^>]*>)/$1/ig; $data =~ s/(]+ACTION=[^>]*contact\.cgi[^>]*>)/$1/ig; $data }