Subversion-Projekte lars-tiefland.laravel_shop

Revision

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