Brauche hilfe mit php [DANKE]

J

John_M

Registriert
Thread Starter
Dabei seit
18.05.2018
Beiträge
4
Reaktionspunkte
0
Hallo brauche Hilfe wegen http://www.wildwestonline.eu/ ( Nur eine Deutsche Fan Site von Spiel WWO )

Index.php macht das nicht was er soll ;)

Bei http://www.wildwestonline.eu/index.php?kategorie=waffen

komme ich wieder auf index.php und nicht auf Seite waffen.html

Die Seite waffen.html ist auch auf ftp

http://www.wildwestonline.eu/game/waffen.html

Ich brauche aber die waffen.html in Mitte der Seite wo News.html ist

So http://www.wildwestonline.eu/index.php?kategorie=News

und nicht:

http://www.wildwestonline.eu/News.html





Im index.php ist:


<?
if ($kategorie): echo($kategorie) ;
else: echo("Saloon der deutschsprachiger Community");
endif; ?>
]
</center>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#C0C0C0">
<?
include("Menu.html");
?>
</td>
<td valign="top" bgcolor="#808080">&nbsp;</td>
<td valign="top" bgcolor="#C0C0C0">
<?
if ($kategorie): include ($kategorie . ".html") ;
else: include ("News.html");
endif; ?>
</td>
<td valign="top" bgcolor="#808080">&nbsp;</td>
<td valign="top" bgcolor="#C0C0C0">
<?
include("Right.html");
?>

ich "denke" das liegt am: if ($kategorie): include ($kategorie . ".html") ;


Danke für jeder HILFE.
 
versuchs mal mit $_GET['kategorie'] statt $kategorie.
 
Wow Danke

Geht ! Danke Danke!
 
Nur FYI:

include ($_GET['kategorie'] . ".html") ;

Ganz schlechte Idee! Brandgefaehrlich! Der Inhalt von $_GET['kategorie'] kann ja alles moegliche sein, also z.b. auch sowas wie "/etc/passwd%00". Wenn das bei dir jetzt nicht direkt funktioniert, dann weil PHP das mit deiner Config / deiner Version nicht mehr ausfuehrt - trotzdem ist das ein echter Security Bug.

Wer weiterlesen moechte: https://www.owasp.org/index.php/Testing_for_Local_File_Inclusion
 
  • Gefällt mir
Reaktionen: medeman
OK (In kurz)

Ich habe vor 15-18 Jahre Web aufgebaut wie

http://web.archive.org/web/20111219122047/http://www.vietcong-game.net:80/
http://web.archive.org/web/20011202224333/http://www.operationflashpoint.cz:80/

Später hatte mir Kumpel das index.php umgebaut von


<?
if ($kategorie): echo($kategorie) ;
else: echo("Saloon der deutschsprachiger Community");
endif; ?>
]
</center>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#C0C0C0">
<?
include("Menu.html");
?>
</td>
<td valign="top" bgcolor="#808080">&nbsp;</td>
<td valign="top" bgcolor="#C0C0C0">
<?
if ($kategorie): include ($kategorie . ".html") ;
else: include ("News.html");
endif; ?>
</td>
<td valign="top" bgcolor="#808080">&nbsp;</td>
<td valign="top" bgcolor="#C0C0C0">
<?
include("Right.html");
?>


auf:



<?
include("Menu.html");
?>
</td>
<td valign="top" bgcolor="#808080">&nbsp;</td>
<td valign="top" bgcolor="#CDDBD1">
<?
/* Old bad navigation with lack of security
if ($kategorie): include ($kategorie . ".html") ;
else: include("News.html");
endif; */

/* Navigation by Trouby */
if (isset($_GET["kategorie"])) { // look if there's a navigation request
$page = $_GET["kategorie"]; // make an alias
$error = '<script>alert("Logged asshole! ;)");</script>'; // define an error message for 'crackers'
// Look if the protocol breaker '://' is in the navigation request (can be http:// ftp:// or anything..)
if (ereg('://',$page) || ereg('www',$page))
die($error);
// If the navigation request contains more the 20 characters, it could be a crack attempt
if (strlen($page) > 20)
die($error);
// Look if the file exists, if not, include the default page
if (!file_exists($page.'.html') || empty($page))
include ("eod.html");
// everything was OK, include the navigation
@include($page.'.html'); // the '@' means that there will no error output if it failes to include
}
else
include ("News.html");
?>
</td>
<td valign="top" bgcolor="#808080">&nbsp;</td>
<td valign="top" bgcolor="#CDDBD1">
<?
include("Right.html");
?>

aber das geht auch nicht mehr.

Wer kann bitte helfen.
 
Der sicherste und einfachste Weg ist wohl, wenn du ein Array bereitstellst mit allen möglichen Seiten.
Wenn dein _GET im Array ist = OK, wenn nicht = ungültig

PHP:
<?php
    $pages = array(
        'News'
        ,'Waffen'
        ,'....'
    );
?>

dann:

<?php
if(!empty($_GET['kategorie'] && in_array($_GET['kategorie'], $pages) && file_exists($_GET['kategorie'].'.html')) {
    include($_GET['kategorie'].'.html');
} else {
    //Fehlermeldung oder Standardseite
}
?>

Das ganze cracker-zeugs kannst du dann weglassen

aber oglimmer hat Recht, eine Variable aus der URL mehr oder weniger direkt zu übernehmen ist keine so gute Idee :)

In deinem zweiten Code ist das Hauptproblem wohl, dass die Funktion ereg() nicht mehr funktioniert in aktuellen PHP-Versionen.
 
In den letzten 15 Jahren hat sich einiges getan. Heute würde man nicht mehr Inhalt ("Saloon der deutschsprachiger Community"), Routing ($page = $_GET["kategorie"]) und Design (<td valign="top" bgcolor="#CDDBD1">) in einer HTML-Datei zusammenwerfen. Und man würde auch keinen JS-Code in PHP Strings stecken ($error = '<script>alert("Logged asshole!");</script>').

Also wenn Du ein bisschen Zeit hast, dann lohnt es sich, ein Framework zu erlernen und die Seite darin komplett neu zu schreiben. Klar ist das viel Aufwand, aber Du lernst dabei auch sehr viel und bekommst Sicherheitsfeatures und langfristig eine bessere Wartbarkeit der Seite dazu.
 
  • Gefällt mir
Reaktionen: dg2rbf
Danke an Alle. Ja ich probier was ich kann. Naja vor 18 Jahre wahr ich 25 Jahre Alt jetzt naja hehe...
 
Zurück
Oben Unten