2016-06-06 22 views
0

Das Projekt, das ich schrieb funktioniert auf meinem Computer (mit XAMPP) und auf meinem Linux Server (mit Apache2), beide von ihnen verwenden .PHP verlor Variablen auf enthalten

Mein Freund wird es auf seinem vorhandenen 1&1 Host hosten und auch verwenden. Und das ist der einzige Host, wo es nicht funktioniert.

Die Website funktioniert so: index.php wird die Datei php enthalten. Aber nach include sind alle Variablen und Konstanten verloren. Und das ist ein großes Problem.

Auf der pageTools.php sollte es viele Funktionen wie head() geben. Also, wenn ich eine Seite öffnen, es zeigt:

Fatal error: Uncaught Error: Call to undefined function head() in /homepages/35/d31536471/htdocs/SoWiHome/katalog/artikel.php:101 Stack trace: #0 {main} thrown in /homepages/35/d31536471/htdocs/SoWiHome/katalog/artikel.php on line 101

index.php

<?php 
define("BASE",__DIR__); 
define("BASEURL", "http://".$_SERVER["SERVER_NAME"]."/".basename(__DIR__)); 
define("URL", BASEURL); 
require BASE."/CONFIG.php"; 
require BASE."/pageTools.php"; 

ini_set("log_errors", 1); 
ini_set("register_globals", 1); //Don't work. 
ini_set("error_log", __DIR__."/log.txt"); 

session_start(); 

$openURL = $_SERVER["REQUEST_URI"]; 
if (strpos($openURL, "?")) 
    $openURL = strtok($openURL, "?"); 
$aOpen = explode("/", $openURL); 
$baseUrl = BASEURL; 

$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die("Fehler bei der Datenbankverbindung!"); 
$db->query("SET CHARACTER SET 'utf8'"); 

global $openURL, $baseUrl, $db; //Also don't work... 

if ($openURL == "" or $openURL == "/") { 
    include "home.php"; 
    exit; 
} 
elseif (end($aOpen) == "admin") { 
    include BASE."/admin.php"; 
    die; 
} 
elseif (file_exists(BASE."/".strtolower($aOpen[2]).'.php')) { 
    include BASE."/".strtolower($aOpen[2]).'.php'; 
} 
else { 
    echo "<!--TRY: ".json_encode($aOpen)."-->"; 
    include "error404.php"; 
} 

.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /katalog 
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
</IfModule> 

Antwort

1

Ihr Problem ist wahrscheinlich, dass register_globals nicht mehr in PHP7 unterstützt.

Von PHP.net:

This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

Perhaps the most controversial change in PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP » 4.2.0. Reliance on this directive was quite common and many people didn't even know it existed and assumed it's just how PHP works. This page will explain how one can write insecure code with this directive but keep in mind that the directive itself isn't insecure but rather it's the misuse of it.

Weitere Informationen über register_globals auf die PHP.net - Manual page