Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 214 | Revision 217 | 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();
180 lars 61
$GLOBALS["menu"] = array();
176 lars 62
$nav = new \App\Models\Directory();
63
$GLOBALS["menu"] = $nav->nav_menu();
91 lars 64
/* Mobile Weiche */
65
if (isset($_SERVER["HTTP_USER_AGENT"])) {
66
    if (!isset($_SESSION['isMobile']) || $_SESSION['isMobile'] == false || !isset($GLOBALS['isMobile']) || $GLOBALS['isMobile'] == false) {
88 lars 67
 
68
        $_SESSION['isMobile'] = false;
69
        $GLOBALS['isMobile'] = false;
70
 
91 lars 71
        if (preg_match("/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
88 lars 72
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
73
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
91 lars 74
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER["HTTP_USER_AGENT"])) {
88 lars 75
 
76
            $_SESSION['isMobile'] = true;
77
            $GLOBALS['isMobile'] = true;
78
        }
79
 
80
    }
91 lars 81
}
68 lars 82
Route::get("/directory/{id}", function ($id) {
214 lars 83
    $dirs = \App\Models\Directory::where("directory_id", $id)->whereIn('status', [0, 2, 99])->get();
84
    $items = \App\Models\Item::where("directory_id", $id)->whereIn('status', [0, 2])->join('prices', 'items.id', '=', 'prices.item_id')->get();
186 lars 85
    return view('subdir', ["subdir" => array("items" => $items, "subdirs" => $dirs), "nav" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
67 lars 86
});
168 lars 87
Route::get("{id}.html", function ($id) {
174 lars 88
    global $menu, $ini;
74 lars 89
    $item = \App\Models\Item::find($id);
186 lars 90
    return view('item', ["item" => $item, "nav" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
74 lars 91
});
2 lars 92
Route::get('/', function () {
175 lars 93
    global $menu;
16 lars 94
    $aktion = \App\Models\Action::all();
215 lars 95
    return view('startpage', ["pagetype" => "Startseite","aktion" => $aktion, "nav" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
2 lars 96
});