2017-07-20 1 views
-4

Ich kämpfe seit langem mit Problemen. Ich habe gerade php mvc-Anwendung vom lokalen Server auf Webhosting (http://www.fandasoft.cz) kopiert, aber wenn ich zum Beispiel versuchen, das Formular zu senden, oder fügen Sie einfach Schrägstrich und alles wie fandasoft.cz/home Ich habe 404 Datei nicht gefunden - und nicht einmal meine eigene 404 Seite. In Fehlerprotokoll ist nur Fehler 'Primäres Skript unbekannt \ n'. Der ganze Code ist auf github (Entschuldigung, es ist tschechisch). Was vermisse ich? Vielen Dank.Webhosting Datei nicht gefunden

.htaccess 
# aktivace prepisovaciho mechanizmu pro URL 
RewriteEngine On 

# zakaz zobrazovani obsahu adresaru 
# 403 pro adresare ktere neobsahuji index soubor 
Options -Indexes 
#Options +FollowSymlinks 

# zakladni adresa pro prepisovani. Je potreba pokud aplikaci mame v podadresari. 
#<If "%{HTTP_HOST} == ^\d+\.'"> 

#ErrorDocument 404 app/ 
# Prepisovaci podminky 
# viz: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond 
# nebudeme prepisovat URL pro existujici adresare 
RewriteCond %{REQUEST_FILENAME} !-d 
# ani pro existujci soubory 
RewriteCond %{REQUEST_FILENAME} !-f 
# ani pro symbolicke odkazy 
RewriteCond %{REQUEST_FILENAME} !-l 
# prepis vsechna splnujici podminky na tvar index.php s parametrem url 
# vice zde: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule 
#RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 

RewriteRule ^(.+)$ index.php/$1 [QSA,L] 
#!\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ 

index.php 
<?php 
use app\Bootstrap; 
require('app/config.php'); 
require_once('app/error_handler.php'); 
//nastav autoloading 
spl_autoload_extensions('.php'); 
spl_autoload_register(); 
session_start(); 
require_once 'vendor/autoload.php'; 
$app = new Bootstrap(); 
?> 

bootstrap.php 
<?php 

namespace app; 

use Lcobucci\JWT\Signer\Hmac\Sha256; 
use Lcobucci\JWT\ValidationData; 
use Lcobucci\JWT\Parser; 
use app\modely\pobocka; 

class Bootstrap { 

    private $kontroler; 
    private $akce; 
    private $parametry = array(); 

    public function __construct() { 
     $this->parsujUrl(); 
     $this->routuj(); 
    } 

    private function routuj() { 

     if ($this->kontroler) { 
      $trida = "app\\kontrolery\\" . $this->kontroler; 
      $soubor = "app/kontrolery/" . $this->kontroler . ".php"; 

      if (is_readable($soubor)) { 
       $handler = new $trida(); 

       if ($this->akce && method_exists($handler, $this->akce)) { 
        $handler->{$this->akce}($this->parametry); 
        return true; 
       } elseif (!$this->akce) { 
        var_dump($this->kontroler); 
        $handler->index(); 
        var_dump('OK'); 
        return true; 
       } else { 
        $handler = new kontrolery\Error(); 
        $handler->error404(); 
        return true; 
       } 
      } else { 
       $handler = new kontrolery\Error(); 
       $handler->error404(); 
       return true; 
      } 
     } else { 
      $handler = new kontrolery\Home(); 
     } 
     $handler->index(); 
    } 

    private function parsujUrl() { 
     $url = $_SERVER['REQUEST_URI']; 
     $url = filter_var($url, FILTER_SANITIZE_URL); 
     if (ENVIRONMENT === 'DEV') { 
      $pos = strpos($url, ROOT_DIR); 
     } else { 
      $pos = true; 
//   $url = rtrim($url,"/"); 
     } 
     if ($pos == false) { 
      $url = substr_replace($url, '', $pos, strlen(ROOT_DIR)); 
     } 

     $url = 'pobocka/nastav/'; 
     $parsovanaUrl = parse_url($url); 
     var_dump($parsovanaUrl); 
     $path = array_filter(explode('/', !empty($parsovanaUrl['path']) ? $parsovanaUrl['path'] : null)); 

     if (empty($path[0])) { 
      $this->kontroler = null; 
     } else if (count($path) > 2) { 
      $this->kontroler = 'Error'; 
     } else { 
      $this->kontroler = $path[0]; 
     } 

     var_dump($this->kontroler); 

     $this->akce = !empty($path[1]) ? $path[1] : null; 

     if (!empty($parsovanaUrl['query'])) { 
      preg_match_all('([\w]+=[\w\d]+)', $parsovanaUrl['query'], $par); 
      foreach ($par[0] as $p) { 
       $this->parametry[explode('=', $p)[0]] = explode('=', $p)[1]; 
      } 

     } 

     // POST jako parametry pro jednoduchou praci s formulari 
     foreach ($_POST as $k => $v) { 
      $this->parametry[$k] = $v; 
     } 


     $token = !empty($_COOKIE[COOKIE_POBOCKA]) ? $_COOKIE[COOKIE_POBOCKA] : null; 
     $signer = new Sha256(); 

     $data = new ValidationData(); // It will use the current time to validate (iat, nbf and exp) 
     $data->setIssuer(WEB_URL); 
     $data->setAudience(WEB_URL); 

     try { 
      $token = (new Parser())->parse($token); 
      if (!$token->verify($signer, SIGN_JWT) || !$token->validate($data)) { 
       $this->presmeruj(); 
      } else { 
       $pobocka = json_decode($token->getClaim("pobocka")); 
       $_SESSION[SESSION_POBOCKA] = new Pobocka($pobocka->id, $pobocka->id_pobocka, $pobocka->nazev, $pobocka->heslo, $pobocka->mesto); 
      } 
     } catch (\Exception $exception) { 
      $this->presmeruj(); 
     } 

    } 

    private function presmeruj() { 
     if ($this->kontroler == "zaznam" && $this->akce == "vratInfoZbozi") { 

     } elseif ($this->kontroler != "pobocka" && $this->kontroler != "home") { 
      $this->kontroler = 'home'; 
      $this->akce = ''; 
      $this->parametry = ''; 
      unset($_SESSION['uzivatel']); 
      unset($_SESSION[SESSION_POBOCKA]); 
     } 
    } 

} 
+0

Bitte fügen Sie den entsprechenden Code * hier * – Kai

+0

https://serverfault.com/questions/517190/nginx-1-fastcgi-sent-in--derder-primary-script-unknown bei Rate, das ist ein Server-Konfigurationsproblem nicht dein Code. –

+0

Eliminiere alle Variablen: Versuche ein einfaches Hallo-Welt-Programm zu machen und stelle sicher, dass es funktioniert. Dann kannst du die großen Sachen angehen. –

Antwort

0

Das einzige, was ich war von

in .htaccess
#RewriteRule ^(.+)$ index.php/$1 [QSA,L] 

zu

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 

jetzt gut es funktioniert hatte zu ändern.