Subversion-Projekte lars-tiefland.laravel_shop

Revision

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