access forbidden, als gevolg van routerscript?

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Tortuga web

tortuga web

06/10/2015 18:48:26
Quote Anchor link
Hallo,
Ik heb een website met een routingsysteem gemaakt en daar het fotoalbumscript van Arjan Kapteijn in geplakt.
(Bedankt Arjan en aanvullers) Dit gaat allemaal goed, behalve wanneer via een link naar een specifiek album wil, krijg ik steeds de Access Forbidden melding. Ik test dit allemaal in een locale omgeving met wampserver.
Ik vermoed dat het probleem zit in het routescript:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?php
    class Router {
        static $routes = array();
        public static function add($link, $url, $method = null) {
            self::$routes[] = [
                'link'  =>  $link,
                'url'   =>  $url,
                'method'    =>  $method
            ];
        }

        public static function getArray() {
            return self::$routes;
        }

        public static function name($input) {
            foreach (self::$routes as $r) {
                if($input == $r['method'] || $input == $r['url'] || $input == $r['link'])  {
                    echo $r['link'];
                    break;
                }
            }
        }
    }

    include_once('routes.php');
    $configs = array(
        'home'      =>      'index.php',
        'pages'     =>      'pages',
        'handler'   =>      'error.php',
    );

    $requestURI = explode('/', $_SERVER['REQUEST_URI']);
    $scriptName = explode('/', $_SERVER['SCRIPT_NAME']);
    for ($i= 0; $i < sizeof($scriptName); $i++) {
        if ($requestURI[$i] == $scriptName[$i]) {
            unset($requestURI[$i]);
        }
    }

    $command = array_values($requestURI);
    var_dump ($command);
    $arg0=null; $arg1=null; $arg2 = null;
    if(isset($command[0])) {
        $arg0=$command[0];
    }

    if(isset($command[1])) {
        $arg1='/'.$command[1].'/';
    }

    if(isset($command[2])) {
        $arg2=$command[2];
    }

    $url = $arg0.$arg1.$arg2;
    if($url == '') {
        include_once($configs['pages'].'/'.$configs['home']);
        return;
    }

    $routes = Router::getArray();
    foreach ($routes as $route) {
        if($url == $route['link']) {
            include_once($configs['pages'].'/'.$route['url']);
            return;
        }
    }

    include_once('handler/'.$configs['handler']);
?>

Met dit in de .htaccess:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
<IfModule mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE On
    Options FollowSymLinks
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ([^/]+)/?$ index.php?id=$1 [NC,L]
    RewriteRule ^url\/(.*)\/?$ /index.php?id=Routing&rest=$1 [NC,L]
</IfModule>


Het stukje script waar de link staat om naar een album te gaan:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?php
if(!$mappen = glob($startmap.'/'.$map.'/*', GLOB_ONLYDIR)) {
    $mappen = array();
}

foreach($mappen as $album) {
    if(basename($album) != 'thumbs') {
        echo '<a href="'.$base_url.basename($album).'">'.ucfirst(basename($album)).'</a><br>'.PHP_EOL;
    }
}

?>

De link klopt voor wat er in de adresregel verschijnt, alleen krijg ik dus een forbidden.
Gewijzigd op 06/10/2015 18:49:51 door Tortuga web
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.