Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 180 | Revision 214 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */

function getConfig()
{
    define('__SITE__', env('site'));
    define('__SHOP__', env('shop'));
    define("__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__);

    $cfg_file = __CFG_PATH__ . "/config.de.xml";
    if (!file_exists($cfg_file)) {
        trigger_error("Konnte keine Konfigurationsdatei für das Shopsystem " . __SITE__ . " -> " . __SHOP__ . " finden (" . ($cfg_file) . ")!", E_USER_ERROR);
    }
    $xml = simplexml_load_file($cfg_file, "SimpleXMLElement", LIBXML_NOCDATA);
    $ini = json_decode(json_encode($xml), true);
    foreach ($ini as $key => $wert) {
        if ($wert == array()) {
            $ini[$key] = "";
        } elseif (is_array($wert)) {
            foreach ($wert as $key2 => $wert2) {
                if ($wert2 == array()) {
                    $ini[$key][$key2] = "";
                }
            }
        }
    }

    $v_file = __CFG_PATH__ . "/versand.xml";
    if (file_exists($v_file)) {
        $xml = simplexml_load_file($v_file, "SimpleXMLElement", LIBXML_NOCDATA);
        $ini["shipping"] = json_decode(json_encode($xml), true);
        foreach ($ini["shipping"] as $key => $wert) {
            if ($wert == array()) {
                $ini["shipping"][$key] = "";
            } elseif (is_array($wert)) {
                foreach ($wert as $key2 => $wert2) {
                    if ($wert2 == array()) {
                        $ini["shipping"][$key][$key2] = "";
                    }
                }
            }
        }
    }
    return $ini;
}

session_start();
$GLOBALS["INI"] = getConfig();
$GLOBALS["menu"] = array();
$nav = new \App\Models\Directory();
$GLOBALS["menu"] = $nav->nav_menu();
/* Mobile Weiche */
if (isset($_SERVER["HTTP_USER_AGENT"])) {
    if (!isset($_SESSION['isMobile']) || $_SESSION['isMobile'] == false || !isset($GLOBALS['isMobile']) || $GLOBALS['isMobile'] == false) {

        $_SESSION['isMobile'] = false;
        $GLOBALS['isMobile'] = false;

        if (preg_match("/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER["HTTP_USER_AGENT"])) {

            $_SESSION['isMobile'] = true;
            $GLOBALS['isMobile'] = true;
        }

    }
}
Route::get("/directory/{id}", function ($id) {
    $dirs = \App\Models\Directory::where("directory_id", $id)->whereIn('status',[0,2,99])->get();
    $items = \App\Models\Item::where("directory_id", $id)->join('prices', 'items.id', '=', 'prices.item_id')->get();
    return view('subdir', ["subdir" => array("items" => $items, "subdirs" => $dirs), "nav" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
});
Route::get("{id}.html", function ($id) {
    global $menu, $ini;
    $item = \App\Models\Item::find($id);
    return view('item', ["item" => $item, "nav" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
});
Route::get('/', function () {
    global $menu;
    $aktion = \App\Models\Action::all();
    return view('startpage', ["aktion" => $aktion, "nav" => $GLOBALS["menu"], "ini" => $GLOBALS["INI"]]);
});