Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 175 | Revision 177 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
 
3
use Illuminate\Support\Facades\Route;
4
 
5
/*
6
|--------------------------------------------------------------------------
7
| Web Routes
8
|--------------------------------------------------------------------------
9
|
10
| Here is where you can register web routes for your application. These
11
| routes are loaded by the RouteServiceProvider within a group which
12
| contains the "web" middleware group. Now create something great!
13
|
88 lars 14
 */
2 lars 15
 
176 lars 16
function getConfig()
17
{
18
	define('__SITE__', env('site'));
19
	define('__SHOP__', env('shop'));
20
        define( "__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__ );
21
 
22
        $cfg_file = __CFG_PATH__ . "/config.de.xml";
23
        if ( !file_exists( $cfg_file ) )
24
        {
25
            trigger_error( "Konnte keine Konfigurationsdatei für das Shopsystem " . __SITE__ . " -> " . __SHOP__ . " finden (" . ( $cfg_file ) . ")!", E_USER_ERROR );
26
        }
27
        $xml = simplexml_load_file( $cfg_file, "SimpleXMLElement", LIBXML_NOCDATA );
28
        $ini = json_decode( json_encode( $xml ), true );
29
        foreach ( $ini as $key => $wert )
30
        {
31
            if ( $wert == array() )
32
            {
33
                $ini[ $key ] = "";
34
            }
35
            elseif ( is_array( $wert ) )
36
            {
37
                foreach ( $wert as $key2 => $wert2 )
38
                {
39
                    if ( $wert2 == array() )
40
                    {
41
                        $ini[ $key ][ $key2 ] = "";
42
                    }
43
                }
44
            }
45
        }
46
 
47
        $v_file = __CFG_PATH__ . "/versand.xml";
48
        if ( file_exists( $v_file ) )
49
        {
50
            $xml = simplexml_load_file( $v_file, "SimpleXMLElement", LIBXML_NOCDATA );
51
            $ini["shipping"] = json_decode( json_encode( $xml ), true );
52
            foreach ( $ini["shipping"] as $key => $wert )
53
            {
54
                if ( $wert == array() )
55
                {
56
                    $ini["shipping"][ $key ] = "";
57
                }
58
                elseif ( is_array( $wert ) )
59
                {
60
                    foreach ( $wert as $key2 => $wert2 )
61
                    {
62
                        if ( $wert2 == array() )
63
                        {
64
                            $ini["shipping"][ $key ][ $key2 ] = "";
65
                        }
66
                    }
67
                }
68
            }
69
        }
70
        return $ini;
71
}
88 lars 72
session_start();
176 lars 73
$GLOBALS["INI"] = getConfig();
74
$nav = new \App\Models\Directory();
75
$GLOBALS["menu"] = $nav->nav_menu();
91 lars 76
/* Mobile Weiche */
77
if (isset($_SERVER["HTTP_USER_AGENT"])) {
78
    if (!isset($_SESSION['isMobile']) || $_SESSION['isMobile'] == false || !isset($GLOBALS['isMobile']) || $GLOBALS['isMobile'] == false) {
88 lars 79
 
80
        $_SESSION['isMobile'] = false;
81
        $GLOBALS['isMobile'] = false;
82
 
91 lars 83
        if (preg_match("/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
88 lars 84
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
85
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
91 lars 86
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER["HTTP_USER_AGENT"])) {
88 lars 87
 
88
            $_SESSION['isMobile'] = true;
89
            $GLOBALS['isMobile'] = true;
90
        }
91
 
92
    }
91 lars 93
}
68 lars 94
Route::get("/directory/{id}", function ($id) {
95
    $dirs = \App\Models\Directory::where("directory_id", $id)->get();
174 lars 96
    $items = \App\Models\Item::where("directory_id", $id)->join('prices', 'items.id', '=', 'prices.item_id')->get();
176 lars 97
    return view('subdir', ["subdir" => array("items" => $items, "subdirs" => $dirs), "menu" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
67 lars 98
});
168 lars 99
Route::get("{id}.html", function ($id) {
174 lars 100
    global $menu, $ini;
74 lars 101
    $item = \App\Models\Item::find($id);
176 lars 102
    return view('item', ["item" => $item, "menu" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
74 lars 103
});
2 lars 104
Route::get('/', function () {
175 lars 105
    global $menu;
16 lars 106
    $aktion = \App\Models\Action::all();
176 lars 107
    return view('startpage', ["aktion" => $aktion, "menu" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
2 lars 108
});