URL'lerin size parametresini p isim ama files.class.php aslında $_GET['page'] test içinde. Yani URL'ler page parametre olarak kullanmak ya da kodunu değiştirmek için değiştirmek ya:
// in files.class.php instead of if(!isset($_GET['page']))
if(!isset($_GET['p'])){
// your code here...
} else {
// ...
}
Lütfen orijinal kodu, $_GET['page'] var hiç yok gibi, her zaman indeks sayfasını gösterir.
Bana garip görünüyor başka bir şey takip ediyor (ama belki de bunu kurmak sadece nasıl olduğunu):
if(file_exists($_GET['page'].'.txt')){
// and lets include that then:
ob_start();
include("contents/". $_GET['page'] . '.php');
$content = ob_get_contents();
ob_end_clean();
}
Önce metin dosyası olup olmadığını kontrol örn. about.txt var, ancak daha sonra bir PHP file contents/about.php içerir. Bu amaçlanmaktadır? Metin dosyası varsa PHP her zaman var mı?
UPDATE:
Also make sure that you properly check the value that you get from $_GET['page'] or however you call it in the end.
E.g. this call http://designed.sytes.net/index.php?page=../index seems to kill your server (sorry it was unintentionally :( )
UPDATE 2:
In order to provide "some" security you could check whether $_GET['page'] is one of predefined values instead of checking whether a file with this name exists. E.g:
$valid_pages = array('home', 'about', 'services', 'contact');
if(isset($_GET['page']) && in_array($_GET['page'], $valid_pages) {
// include page here
}
else {
// redirect to home page
}
İşte $_GET['page'] ../index gibi göreceli patika şeklinde değil emin kılar. O bu değerlerden biri değilse $valid_pages Eğer ana sayfaya yönlendirme.