Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 232 | Revision 307 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

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