Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 176 | Revision 180 | 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
{
177 lars 18
    define('__SITE__', env('site'));
19
    define('__SHOP__', env('shop'));
20
    define("__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__);
176 lars 21
 
177 lars 22
    $cfg_file = __CFG_PATH__ . "/config.de.xml";
23
    if (!file_exists($cfg_file)) {
24
        trigger_error("Konnte keine Konfigurationsdatei für das Shopsystem " . __SITE__ . " -> " . __SHOP__ . " finden (" . ($cfg_file) . ")!", E_USER_ERROR);
25
    }
26
    $xml = simplexml_load_file($cfg_file, "SimpleXMLElement", LIBXML_NOCDATA);
27
    $ini = json_decode(json_encode($xml), true);
28
    foreach ($ini as $key => $wert) {
29
        if ($wert == array()) {
30
            $ini[$key] = "";
31
        } elseif (is_array($wert)) {
32
            foreach ($wert as $key2 => $wert2) {
33
                if ($wert2 == array()) {
34
                    $ini[$key][$key2] = "";
176 lars 35
                }
36
            }
37
        }
177 lars 38
    }
176 lars 39
 
177 lars 40
    $v_file = __CFG_PATH__ . "/versand.xml";
41
    if (file_exists($v_file)) {
42
        $xml = simplexml_load_file($v_file, "SimpleXMLElement", LIBXML_NOCDATA);
43
        $ini["shipping"] = json_decode(json_encode($xml), true);
44
        foreach ($ini["shipping"] as $key => $wert) {
45
            if ($wert == array()) {
46
                $ini["shipping"][$key] = "";
47
            } elseif (is_array($wert)) {
48
                foreach ($wert as $key2 => $wert2) {
49
                    if ($wert2 == array()) {
50
                        $ini["shipping"][$key][$key2] = "";
176 lars 51
                    }
52
                }
53
            }
54
        }
177 lars 55
    }
56
    return $ini;
176 lars 57
}
177 lars 58
 
88 lars 59
session_start();
176 lars 60
$GLOBALS["INI"] = getConfig();
61
$nav = new \App\Models\Directory();
62
$GLOBALS["menu"] = $nav->nav_menu();
91 lars 63
/* Mobile Weiche */
64
if (isset($_SERVER["HTTP_USER_AGENT"])) {
65
    if (!isset($_SESSION['isMobile']) || $_SESSION['isMobile'] == false || !isset($GLOBALS['isMobile']) || $GLOBALS['isMobile'] == false) {
88 lars 66
 
67
        $_SESSION['isMobile'] = false;
68
        $GLOBALS['isMobile'] = false;
69
 
91 lars 70
        if (preg_match("/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
88 lars 71
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
72
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
91 lars 73
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER["HTTP_USER_AGENT"])) {
88 lars 74
 
75
            $_SESSION['isMobile'] = true;
76
            $GLOBALS['isMobile'] = true;
77
        }
78
 
79
    }
91 lars 80
}
68 lars 81
Route::get("/directory/{id}", function ($id) {
82
    $dirs = \App\Models\Directory::where("directory_id", $id)->get();
174 lars 83
    $items = \App\Models\Item::where("directory_id", $id)->join('prices', 'items.id', '=', 'prices.item_id')->get();
176 lars 84
    return view('subdir', ["subdir" => array("items" => $items, "subdirs" => $dirs), "menu" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
67 lars 85
});
168 lars 86
Route::get("{id}.html", function ($id) {
174 lars 87
    global $menu, $ini;
74 lars 88
    $item = \App\Models\Item::find($id);
176 lars 89
    return view('item', ["item" => $item, "menu" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
74 lars 90
});
2 lars 91
Route::get('/', function () {
175 lars 92
    global $menu;
16 lars 93
    $aktion = \App\Models\Action::all();
176 lars 94
    return view('startpage', ["aktion" => $aktion, "menu" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
2 lars 95
});