Thread Script hängt sich auf: Warum nur? (20 answers)
Opened by pktm at 2003-09-26 01:41

pktm
 2003-09-28 00:51
#4729 #4729
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Ich glaub mich hackts.
Das Scipt läuft ja jetzt.
Aber wenn ich in eine Datei, die angezeigt werden soll noch eine einzige Zeile mehr einfüge hängt es wieder.
Gibt es irgendwie eine Beschränkung von Textfile-Größen oder wie?
Kann doch irgendwie nicht sein!?
Kann das mal wer bei sich ausprobieren?
Im folgenden alle Daten die ihr braucht:

Das Script
more (11.9kb):

Code: (dl )
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!c:/usr/bin/perl -w
# ---------------------------------------------------
# MODULE
# ---------------------------------------------------
use strict;
use warnings;
use diagnostics;
use CGI qw/:standard/;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
$CGI::POST_MAX=1024 * 100;  # max 100K posts
$CGI::DISABLE_UPLOADS = 1;  # no uploads
use Data::Dumper;
use vars;
# ---------------------------------------------------
# KONSTANTEN
# ---------------------------------------------------
use constant UNIX => 0; # Unix y/n
# ---------------------------------------------------
# VARIABLEN
# ---------------------------------------------------
$| = 1;
my $cgi         = CGI->new();
my $query       = $cgi->Vars; #extract parameters
my $index_file  = 'c:/apache/cgi-bin/cms/1_3/txt/index.txt'; # nr. | key | pfad
my $index       = 'c:/apache/cgi-bin/cms/1_3/html/index.html';
# ---- TEMPLATE
my %subs = ();                                                                  # global hash for &substitute substitute_key => value
# ---- SETTINGS
$subs{relative_url} = $cgi->url(-relative=>1);
$subs{full_url}     = $cgi->url(-full=>1);
$subs{self}         = $cgi->url(-relative=>1) . '?action=';
$subs{domain}       = '127.0.0.1';
# ---- SENDMAIL-SETTINGS
my $mailto = 'trash@mail.net';
my $kontakt_subject = 'Feedback von Webseite';
my $Sendmail_Prog = "/usr/sbin/sendmail";
# -- folowing variable: format of the outgoing Message
my $mailtext = qq~
Von: $query->{name}
Email: $query->{email}
Firma (optional): $query->{firma}
Text:
$query->{text}
~;
# ---- LAST SETTINGS
my $kontakt_submit = qq~
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="DE"><head><title>Intergastro Service - Kontakt</title>
<meta http-equiv="refresh" content="5; URL=$subs{full_url}">
<link rel="stylesheet" type="text/css" href="http://$subs{domain}/css/cms.css" />
</head><body bgcolor="white" encoding>
<p>& </p>
<p>& </p>
<p>& </p>
<p align="center">Ihre Nachricht wurde verschickt. Vielen Dank für Ihr Interesse.<br />
<a href="$subs{full_url}">Sollten Sie nicht automatisch weiter geleitet werden bitte hier klicken.</a></p>
</td>
</tr>
</table>
</body>
</html>
   ~;
# ---------------------------------------------------
# LOGIK
# ---------------------------------------------------
print $cgi->header(-charset=>'UTF-8',
                  -expires=>'+1s',
                  -type=>'text/html',
                  );
warningsToBrowser(1);
if($query->{action}){
   if( $query->{action} eq "kontakt" ){
       if( $query->{submit} ){
           if( $query->{name} eq "" || $query->{email} eq "" || $query->{text} eq "" || $query->{email} !~ /^[\w\d][\w\d\.\-]*\@([\w\d\-]+\.)+[a-zA-Z]{2,4}$/ ){
               $subs{error} .= qq~<p class="error">Bitte &uuml;berpr&uuml;fen Sie ihre Eingabe!</p>~;
               my @keys = qw(name email firma text);
               foreach( @keys ) {
                   $_ = "" if !defined;
                   $subs{$_} = $query->{$_};
               }
               zeigeSeite('kontakt');
           }else{ # Kontakt erfolgreich
               open(MAIL,"|$Sendmail_Prog -t") || print qq~<p class="error">Mailprogramm konnte nicht gestartet werden</p>~;
               print MAIL "To: $mailto\n";
               print MAIL "Subject: $kontakt_subject\n\n";
               print MAIL "$mailtext\n";
               close(MAIL) || print qq~<p class="error">Fehler beim Mailversenden!</p>~;
               print $kontakt_submit;
           }
       }else{ #erstaufruf
           zeigeSeite('kontakt');
       }
   }else{
       zeigeSeite($query->{action});
   }
}else{
   zeigeSeite('index');
}
exit( 0 );
# ---------------------------------------------------
# SUBS
# ---------------------------------------------------
sub zeigeSeite{
   my $key = $_[0];  #Schlüsselwort für Aufzurufende Seite in /txt/index.txt
   my $pfad = 0;
   my @index = extractFile( $index_file );
# print;
   foreach (@index){
       chomp $_;
       if($_ =~ m/$key\.igs/ig){
           $pfad = (split /\t/,$_)[2];
           last;
       }
   }
   if($pfad eq 0){ print errorSeite( $query->{action}, "zeigeSeite: $!" ); exit( 1 ); } # -> Fehlerseite?
   my @inhalt = extractFile( $pfad );
   foreach (@inhalt){
       chomp $_;
   }
# ---------------------------------------------------
# DYN. INHALT

   $subs{titel}        = (split/\|/, $inhalt[0])[2];
   $subs{keywords}     = (split/\|/, $inhalt[1])[2];
   $subs{desc}         = (split/\|/, $inhalt[2])[2];
   $subs{page_topic}   = (split/\|/, $inhalt[3])[2];
   my $page            = (split/\|/, $inhalt[4])[2];

   $subs{inhalt} = join"",substitute( extractFile( $page ) );                  # CONTENT auselesen & serialisieren
   
#    $subs{inhalt} =~ s/\n/ /g;

   print substitute( extractFile( $index ) );                                  # SUBSTITUTION IN INDEX.HTML
   
# print;

} #ZeigeSeite
# --------------------------------------------------------
sub extractFile{
# ---- usage
# my @extractedFile = extractFile( "FileName" ); # dieing if file doesn't exists
   my $file = $_[0];
   open(DAT, "$file") || die "$! ($file)";
   my @inhalt = <DAT>;
   close(DAT);
   return @inhalt;
} #extractFile
# --------------------------------------------------------
sub substitute{
# ---- usage
# my @substitutedFile = substitute( @contentToSubstitute ); # substitute-keywords must be added to %subs (global %hash)
   my @err = ();                                                               # array für fehler
   my @file = @_;
   foreach my $eintrag( @file ){
       if( $eintrag =~ /\%\%(.*)\%\%/ ){
           my $keyword = $1;
           unless( exists $subs{$keyword} ){ push @err, "Wert nicht gesetzt: $keyword\n"; $subs{$keyword} = ""; }
           unless( $eintrag =~ s/\Q$&\E/$subs{$keyword}/g ){ print STDERR "Fehler beim ersetzen!\n"; }
           print STDERR "ersetzte: $& mit $eintrag\n";
       }
   }
   print STDERR @err;
   return @file;
} #substitute
# --------------------------------------------------------
sub errorSeite {
   my ($action, $fehler) = @_;
   $cgi->delete_all();
   my $msg = qq~
<html>
<head>
<meta http-equiv="refresh" content="5; URL=$subs{full_url}">
</head>
<body>
<p align="center">& </p><br /><p>Ein Fehler ist aufgetreten. Sie werden automatisch zur Startseite umgeleitet.</p>
<a href="$subs{full_url}" align="center">Sollten Sie nicht automatisch umgeleitet werden klicken Sie bitte hier!</a>
<p>& </p>
<p>& </p>
<p>& </p>
<p align="left">Hinweise für den Webmaster: <br />
Aktion: $action<br />
Fehler: $fehler</p>
</body>
</html>
   ~;
   return ($msg);
} #errorSeite



index.txt (Werte durch Tabulator getrennt)
Code: (dl )
1
2
3
0	index	c:/apache/cgi-bin/cms/1_3/txt/index.igs
1 kontakt c:/apache/cgi-bin/cms/1_3/txt/kontakt.igs
2 cms c:/apache/cgi-bin/cms/1_3/txt/cms.igs


index.igs (Wieso .igs? seht euch mal oben den Link zur ersten Version an ;) )
Code: (dl )
1
2
3
4
5
0|titel|Diese Seite gliedert sich in folgende Bereiche:
1|meta_keywords|GCP
2|meta_description|http://www.example.de - Ihr Serviceunternehmen für Gastronomie! #ändern
3|meta_page-topic|GCP - Wir stellen uns vor!
4|page|c:/apache/cgi-bin/cms/1_3/txt/indextxt.igs


indextxt.igs
Code: (dl )
1
2
3
4
5
6
[html]<!-- inhalt -->
Dieses ist der Inhalt!<br />
Dieses ist der self-Pfad: %%self%%<br />
full_url: %%full_url%%<br />
relative_url: %%relative_url%%<br />
<!-- /inhalt -->[/html]


cms.igs
Code: (dl )
1
2
3
4
5
0|titel|Content Management System (CMS)
1|meta_keywords|CMS Content Management System
2|meta_description|http://example.com - Webdesign & Programmierung
3|meta_page-topic|Produkt Content Management System (CMS)
4|page|c:/apache/cgi-bin/cms/1_3/txt/cmstxt.igs


cmstxt.igs
Code: (dl )
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
[html]<!-- inhalt -->

<br />

<ul type="square">
 <li><a href="%%self%%cms#desc">Beschreibung</a></li>
 <li><a href="%%self%%cms#desc">Funktionsumfang</a></li>
 <li>Systemanforderungen
</ul>

<a name="desc">& </a>
<h2>Beschreibung</h2>

<p>Beim CMS v.1.3 handelt es sich um ein echtzeit - Content management System.
Es wurde speziell f&uuml;r Benutzer entwickelt, welche nicht im Besitz einer MySQL Datenbank

sind. Das CMS v.1.3 besticht durch die Einfachheit der Navigation sowie einer schnellen

Datenverwertung ( Traffic ). Eine Besonderheit des CMS v.1.3 ist das Kontakt-Formular. Es

ist auf Sicherheit ausgelegt, somit ist es Angreifern unm&ouml;glich Ihr Sendmail-Programm

(Programm zum Versenden von Emails) zu nutzen.
Für den Benutzer ist das CMS v.1.3 besonders vorteilhaft. Durch sein stets gleiches

Erscheinungsbild ist der Einfr&auml;gungseffekt besonders hoch.
Bei der Navigation wurde bewusst auf unnötige verzierung verzichtet um eine m&ouml;glichst

einfach Handhabung zu erreichen. Die Inhalte k&ouml;nnen jegliche Art von Webseite sein, die

der User mit Hilfe der beiliegenden Anleitung ohne weiteres mit eigenen Programmen (z.B.

Macromedia Dreamweaver) erstellen und einfügen kann.</p>


<h2>Funktionsumfang</h2>

<ul>
 <li>Content Management System</li>
   <ul>
<li>Einf&uuml;gen eigener Inhalte per Copy & Paste</li>
<li>Einheitliches Design durch Template-Funktion</li>

   </ul>
 <li>Kontakt-Formular</li>
   <ul>
<li>Direktes Versenden von Nachrichten mittels Formular</li>
<li>Empfang der Nachrichten auf Ihrer persönlichen Email-Adresse</li>
<li>Eingabedaten:</li>
 <ul>
<li>Name</li>
<li>Email-Adresse</li>
<li>Firma</li>
<li>Nachricht</li>
 </ul>
   </ul>
</ul>

<!-- /inhalt -->[/html]


Das Template
more (6.5kb):

Code: (dl )
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="DE"><head><title>%%titel%%</title>
<base href="%%full_url%%" />
<meta name="description" content="%%desc%%" />
<meta name="audience" content="Kids, Jugendliche, Studenten, Erwachsene, all, alle" />
<meta name="art" content="Informationsseite" />
<meta name="page-topic" content="%%page_topic%%" />
<meta name="content_language" content="DE" />
<meta name="robots" content="follow" />
<meta name="keywords" content="%%keywords%%" />
<meta name="revisit-after" content="30 days" />
<link rel="stylesheet" type="text/css" href="http://127.0.0.1/css/cms.css" />
</head><body bgcolor="white">

<!-- /html_start -->

<!-- hauptinhalt -->
<table border="0" bordercolor="red" cellpadding="2" cellspacing="0" align="center" width="800">
<tr>
<td colspan="2" align="center" id="briefkopf">
<!-- Briefkopf -->
<img src="http://127.0.0.1/grafiken/cms/cms_logo2.gif" border="0" />
<!-- /Briefkopf -->
</td>
</tr>
<tr>
<td colspan="2" align="center" ID="addy">
<!-- Adresse -->
Name <img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
Straße <img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
PLZ Ort <img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
mail@web.net
<!-- Adresse -->
</td>
<tr>
<tr>
<td id="nav" valign="top">

<!-- navigattion -->
<table border="0" cellspacing="0" cellpadding="1"><tr><td><!-- dummy-table -->
<table border="0" bordercolor="blue" cellpadding="2" cellspacing="1" width="200" >
<tr>
<td class="nav"><img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
& <a href="%%full_url%%?action=index">home</a></td>
</tr>
<td class="nav"><img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
& <a href="%%full_url%%?action=cms">Content Management System</a></td>
</tr>
<tr>
<td><p/>&nbsp;</td>
</tr>
<tr>
<td class="nav"><img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
& <a href="%%full_url%%?action=kontakt">Kontakt</a></td>
</tr>
</table>
</td></tr></table><!-- /dummy-table -->
<!-- /navigattion -->

<td class="inhalt" valign="top" width="100%">

<!-- inhalt -->
<table border="0" bordercolor="green" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td colspan="2" id="lauftext" align="right">%%titel%%& & & & & </td>
</tr>
<tr>
<td id="text" valign="top">
<!-- inhalt -->
<table><tr><td><!-- dummy-table -->
%%inhalt%%
</td></tr></table><!-- /dummy-table -->
<!-- /inhalt -->
</td>

</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" align="center" class="navtab">
<a href="%%full_url%%?action=index" border="0">home</a>
<img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
<a href="%%full_url%%?action=cms">Content Management System</a>
<img src="http://127.0.0.1/grafiken/greysmallbullet.gif" width="5" height="5" border="0" alt="*"/>
<a href="%%full_url%%?action=kontakt">Kontakt</a>
</td>
</tr>
</table>
<!-- /hauptinhalt -->
</body></html>



So, das wärs.
Damit und mit dem Ordnersystem wie aus dem Script erkennbar (kann man ganz einfach wieder löschen) müsste es gehen.
Wenn ich jetzt an die cmstxt.igs noch eine einzige Zeile anhänge bleibt das Script wieder hängen.
Ich verstehe das irgendwie nicht.
mfg pktm
PS: Öhm, wie soll ich sagen, bitte noch keine Kommentare zu den Inhalten, bin ja gerade erst am erstellen...\n\n

<!--EDIT|pktm|1064696258-->^
Last edited: 2012-10-13 13:23:41 +0200 (CEST)
http://www.intergastro-service.de (mein erstes CMS :) )

View full thread Script hängt sich auf: Warum nur?