Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1704 | Revision 1706 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
 
730 lars 3
    use App\Http\Controllers\BasketController;
4
    use App\Http\Controllers\BuyController;
1692 lars 5
    use App\Http\Controllers\DirectoryController;
1669 lars 6
    use App\Http\Controllers\PriceAgencyController;
875 lars 7
    use App\Http\Controllers\ShippingController;
765 lars 8
    use App\Http\Controllers\UserController;
333 lars 9
    use App\Models\Action;
10
    use App\Models\Item;
11
    use Illuminate\Support\Facades\Route;
2 lars 12
 
333 lars 13
    /*
14
    |--------------------------------------------------------------------------
15
    | Web Routes
16
    |--------------------------------------------------------------------------
17
    |
18
    | Here is where you can register web routes for your application. These
19
    | routes are loaded by the RouteServiceProvider within a group which
20
    | contains the "web" middleware group. Now create something great!
21
    |
22
     */
2 lars 23
 
848 lars 24
    $GLOBALS["INI"] = getConfig();
832 lars 25
 
624 lars 26
    if ( php_sapi_name() == "cli" )
582 lars 27
    {
28
        return;
29
    }
704 lars 30
    session_start();
697 lars 31
    if ( !isset( $_SESSION["SHOP"]["BASKET"] ) )
32
    {
730 lars 33
        $_SESSION["SHOP"]["BASKET"] = new BasketController();
697 lars 34
    }
355 lars 35
 
1586 lars 36
    if ( !isset( $_SESSION["navigation"]["position"] ) )
37
    {
38
        $_SESSION["navigation"]["position"] = null;
39
    }
1693 lars 40
    $nav = new DirectoryController();
848 lars 41
    $menu = $nav->nav_menu();
1582 lars 42
    $shopPosition = $nav->shopPosition();
368 lars 43
    $sc = parseCMSPage( $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" );
852 lars 44
    $data = [
45
        "nav"               => $menu,
46
        "serviceCenterMenu" => $sc["menu"],
1582 lars 47
        "shopPosition"      => $shopPosition,
852 lars 48
        "langstrings"       => $GLOBALS["langstrings"],
49
        "ini"               => $GLOBALS["INI"],
50
    ];
51
    \View::share( $data );
848 lars 52
 
333 lars 53
    /* Mobile Weiche */
355 lars 54
    if ( isset( $_SERVER["HTTP_USER_AGENT"] ) )
333 lars 55
    {
375 lars 56
        if ( !isset( $_SESSION['isMobile'] ) || $_SESSION['isMobile'] === false || !isset( $GLOBALS['isMobile'] ) || $GLOBALS['isMobile'] === false )
333 lars 57
        {
88 lars 58
 
355 lars 59
            $_SESSION['isMobile'] = false;
60
            $GLOBALS['isMobile'] = false;
88 lars 61
 
853 lars 62
            $pattern = "/(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";
63
            if ( preg_match( $pattern, $_SERVER["HTTP_USER_AGENT"] ) )
333 lars 64
            {
88 lars 65
 
355 lars 66
                $_SESSION['isMobile'] = true;
67
                $GLOBALS['isMobile'] = true;
333 lars 68
            }
69
 
88 lars 70
        }
71
    }
1674 lars 72
    Route::get( "/preisagentur/{filename}", [ PriceAgencyController::class, "download" ] );
405 lars 73
    Route::get( "/addItemToBasket", function ()
385 lars 74
    {
697 lars 75
        $_SESSION["SHOP"]["BASKET"]->addItem();
848 lars 76
        return view( 'header_wk' );
405 lars 77
    } );
745 lars 78
    Route::get( "/editItem/{id}/{menge}", function ()
79
    {
80
        $_SESSION["SHOP"]["BASKET"]->editItem();
765 lars 81
        return redirect( "/basket.html" );
745 lars 82
    } )->where( [ "id" => "[0-9a-f]{40}", "menge" => "[0-9]+" ] );
83
    Route::get( "/delItem/{id}", function ()
84
    {
85
        $_SESSION["SHOP"]["BASKET"]->delItem();
765 lars 86
        return redirect( "/basket.html" );
745 lars 87
    } )->where( "id", "[0-9a-f]{40}" );
766 lars 88
    Route::post( "/login", [ UserController::class, "login" ] );
809 lars 89
    Route::post( "/logout", [ UserController::class, "logout" ] );
814 lars 90
    Route::post( "/send_pw", [ UserController::class, "forgot_pw" ] );
1704 lars 91
    Route::get( "/favoriten", 'login_center' );
92
    Route::view( "/forgot_pw", 'login_center' );
93
    Route::view( "/login", 'login_center' );
94
    Route::view( "/register", 'login_center' );
890 lars 95
    Route::get( "/update_versand", [ ShippingController::class, "updateShipping" ] );
891 lars 96
    Route::get( "/checkLand.php", function ()
890 lars 97
    {
98
        $_SESSION['SHOP']["BASKET"]->getShippingCountries();
99
        $valid = 1;
893 lars 100
        if ( !in_array( $_GET["land"], array_keys( $_SESSION["SHOP"]["BASKET"]->shippingCountries ) ) )
890 lars 101
        {
102
            $valid = 0;
103
        }
899 lars 104
        echo $valid;
890 lars 105
        return $valid;
106
    } );
658 lars 107
    Route::get( '/setSessionVars', function ()
108
    {
109
        foreach ( $_GET as $key => $value )
110
        {
111
            if ( $value == "false" )
112
            {
113
                unset( $_SESSION[$key] );
114
            }
115
            else
116
            {
117
                $_SESSION[$key] = $value;
118
            }
119
        }
120
    } );
765 lars 121
    Route::post( "/setSessionVars", function ()
122
    {
762 lars 123
        foreach ( $_POST as $key => $value )
124
        {
125
            if ( $value == "false" )
126
            {
127
                unset( $_SESSION[$key] );
128
            }
129
            else
130
            {
131
                $_SESSION[$key] = $value;
132
            }
133
        }
765 lars 134
    } );
135
    Route::post( "/updateSession", function ()
756 lars 136
    {
137
    } );
355 lars 138
    Route::get( "/cms/{slug}", function ( $slug )
139
    {
359 lars 140
        $url = $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" . $slug;
365 lars 141
        $arr = parseCMSPage( $url );
355 lars 142
        $content = $arr["content"];
361 lars 143
        return view( 'service_center_content', [
848 lars 144
            "serviceContent" => $content,
355 lars 145
        ] );
146
    } );
925 lars 147
    Route::get( "/bestellen_seite_{step}.html", function ( $step )
376 lars 148
    {
925 lars 149
        return view( 'buy_' . $step, [
924 lars 150
            "pagetype"      => "Bestellvorgang1",
848 lars 151
            "Laender"       => getRechnungsLaender(),
152
            "defaultLandID" => 47,
376 lars 153
        ] );
925 lars 154
    } )->where( 'step', '[1-4][ab]{0,1}' );
155
    Route::post( "/bestellen_seite_{step}.html", [ BuyController::class, 'step1' ] )->where( 'step', '[1-4][ab]{0,1}' );
1704 lars 156
    Route::view( "basket.html",'basket' );
1564 lars 157
    Route::get( "{item:slug}.html", function ( Item $item )
333 lars 158
    {
1564 lars 159
        return view( 'item', [
160
            "item" => $item,
161
        ] );
162
    } );
1692 lars 163
    Route::get( "/directory/{id}-{name}", [ DirectoryController::class, "index" ] )->whereNumber( 'id' );
333 lars 164
    Route::get( '/', function ()
165
    {
405 lars 166
        $date = date( "Y-m-d" );
167
        $aktion = Action::with( 'medium.medium' )->where( 'valid_from', '<=', $date )->where( 'valid_to', '>=', $date )->get();
333 lars 168
        return view( 'startpage', [
848 lars 169
            "pagetype" => "Startseite",
170
            "aktion"   => $aktion,
333 lars 171
        ] );
172
    } );