Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1710 | 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;
1715 lars 6
    use App\Http\Controllers\ManufacturerController;
1669 lars 7
    use App\Http\Controllers\PriceAgencyController;
875 lars 8
    use App\Http\Controllers\ShippingController;
765 lars 9
    use App\Http\Controllers\UserController;
333 lars 10
    use App\Models\Action;
11
    use App\Models\Item;
12
    use Illuminate\Support\Facades\Route;
1706 lars 13
    use Illuminate\Support\Facades\DB;
1708 lars 14
    use Illuminate\Support\Facades\Schema;
2 lars 15
 
333 lars 16
    /*
17
    |--------------------------------------------------------------------------
18
    | Web Routes
19
    |--------------------------------------------------------------------------
20
    |
21
    | Here is where you can register web routes for your application. These
22
    | routes are loaded by the RouteServiceProvider within a group which
23
    | contains the "web" middleware group. Now create something great!
24
    |
25
     */
2 lars 26
 
848 lars 27
    $GLOBALS["INI"] = getConfig();
832 lars 28
 
624 lars 29
    if ( php_sapi_name() == "cli" )
582 lars 30
    {
31
        return;
32
    }
704 lars 33
    session_start();
1709 lars 34
    $GLOBALS["steuern"] = array();
35
    //default LandID für Deutschland
36
    $landID = 47;
37
    //Wenn das Flag gesetzt ist, dann nimm diesen wert, damit auch "ausländische Shops" den richtigen MwSt angezeigt bekommen
38
    if ( isset( $GLOBALS["INI"]["steuern"]["default_countryID"] ) )
39
    {
40
        $landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
41
    }
42
 
43
    $countryIDs = ( isset( $GLOBALS['INI']['steuern']['use_countries_tax'] ) ) ? $GLOBALS['INI']['steuern']['use_countries_tax'] : $landID;
697 lars 44
    if ( !isset( $_SESSION["SHOP"]["BASKET"] ) )
45
    {
730 lars 46
        $_SESSION["SHOP"]["BASKET"] = new BasketController();
697 lars 47
    }
355 lars 48
 
1586 lars 49
    if ( !isset( $_SESSION["navigation"]["position"] ) )
50
    {
51
        $_SESSION["navigation"]["position"] = null;
52
    }
1708 lars 53
    $sql = "SELECT
54
            *
55
        FROM
56
            content_management.countries_tax
57
        WHERE
58
            country_id IN (" . $countryIDs . ")
59
    ";
60
    $rows = DB::connection( "cms" )->select( $sql );
61
    foreach ( $rows as $r )
62
    {
63
        $GLOBALS["steuern"][$r->country_id][$r->taxes_id] = $r->tax_percent;
64
        $GLOBALS["steuern"][$r->country_id][null] = $GLOBALS["steuern"][$r->country_id][0];
65
    }
66
 
67
    $sql = "
68
        SELECT
69
            *
70
        FROM
71
            i18n_de
72
    ";
73
    if ( Schema::hasTable( 'i18n_de' ) )
74
    {
75
        $langstrings = DB::select( $sql );
76
    }
77
    else
78
    {
79
        $langstrings = DB::connection( "old" )->select( $sql );
80
    }
81
    foreach ( $langstrings as $langstring )
82
    {
83
        $GLOBALS["langstrings"][$langstring->page_id][$langstring->id] = $langstring->string;
84
    }
1693 lars 85
    $nav = new DirectoryController();
848 lars 86
    $menu = $nav->nav_menu();
1582 lars 87
    $shopPosition = $nav->shopPosition();
368 lars 88
    $sc = parseCMSPage( $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" );
852 lars 89
    $data = [
90
        "nav"               => $menu,
91
        "serviceCenterMenu" => $sc["menu"],
1582 lars 92
        "shopPosition"      => $shopPosition,
852 lars 93
        "langstrings"       => $GLOBALS["langstrings"],
94
        "ini"               => $GLOBALS["INI"],
95
    ];
96
    \View::share( $data );
848 lars 97
 
333 lars 98
    /* Mobile Weiche */
355 lars 99
    if ( isset( $_SERVER["HTTP_USER_AGENT"] ) )
333 lars 100
    {
375 lars 101
        if ( !isset( $_SESSION['isMobile'] ) || $_SESSION['isMobile'] === false || !isset( $GLOBALS['isMobile'] ) || $GLOBALS['isMobile'] === false )
333 lars 102
        {
88 lars 103
 
355 lars 104
            $_SESSION['isMobile'] = false;
105
            $GLOBALS['isMobile'] = false;
88 lars 106
 
853 lars 107
            $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";
108
            if ( preg_match( $pattern, $_SERVER["HTTP_USER_AGENT"] ) )
333 lars 109
            {
88 lars 110
 
355 lars 111
                $_SESSION['isMobile'] = true;
112
                $GLOBALS['isMobile'] = true;
333 lars 113
            }
114
 
88 lars 115
        }
116
    }
1674 lars 117
    Route::get( "/preisagentur/{filename}", [ PriceAgencyController::class, "download" ] );
405 lars 118
    Route::get( "/addItemToBasket", function ()
385 lars 119
    {
697 lars 120
        $_SESSION["SHOP"]["BASKET"]->addItem();
848 lars 121
        return view( 'header_wk' );
405 lars 122
    } );
745 lars 123
    Route::get( "/editItem/{id}/{menge}", function ()
124
    {
125
        $_SESSION["SHOP"]["BASKET"]->editItem();
765 lars 126
        return redirect( "/basket.html" );
745 lars 127
    } )->where( [ "id" => "[0-9a-f]{40}", "menge" => "[0-9]+" ] );
128
    Route::get( "/delItem/{id}", function ()
129
    {
130
        $_SESSION["SHOP"]["BASKET"]->delItem();
765 lars 131
        return redirect( "/basket.html" );
745 lars 132
    } )->where( "id", "[0-9a-f]{40}" );
766 lars 133
    Route::post( "/login", [ UserController::class, "login" ] );
809 lars 134
    Route::post( "/logout", [ UserController::class, "logout" ] );
814 lars 135
    Route::post( "/send_pw", [ UserController::class, "forgot_pw" ] );
1710 lars 136
    Route::view( "/favoriten", 'login_center' );
1704 lars 137
    Route::view( "/forgot_pw", 'login_center' );
138
    Route::view( "/login", 'login_center' );
139
    Route::view( "/register", 'login_center' );
890 lars 140
    Route::get( "/update_versand", [ ShippingController::class, "updateShipping" ] );
891 lars 141
    Route::get( "/checkLand.php", function ()
890 lars 142
    {
143
        $_SESSION['SHOP']["BASKET"]->getShippingCountries();
144
        $valid = 1;
893 lars 145
        if ( !in_array( $_GET["land"], array_keys( $_SESSION["SHOP"]["BASKET"]->shippingCountries ) ) )
890 lars 146
        {
147
            $valid = 0;
148
        }
899 lars 149
        echo $valid;
890 lars 150
        return $valid;
151
    } );
658 lars 152
    Route::get( '/setSessionVars', function ()
153
    {
154
        foreach ( $_GET as $key => $value )
155
        {
156
            if ( $value == "false" )
157
            {
158
                unset( $_SESSION[$key] );
159
            }
160
            else
161
            {
162
                $_SESSION[$key] = $value;
163
            }
164
        }
165
    } );
765 lars 166
    Route::post( "/setSessionVars", function ()
167
    {
762 lars 168
        foreach ( $_POST as $key => $value )
169
        {
170
            if ( $value == "false" )
171
            {
172
                unset( $_SESSION[$key] );
173
            }
174
            else
175
            {
176
                $_SESSION[$key] = $value;
177
            }
178
        }
765 lars 179
    } );
180
    Route::post( "/updateSession", function ()
756 lars 181
    {
182
    } );
355 lars 183
    Route::get( "/cms/{slug}", function ( $slug )
184
    {
359 lars 185
        $url = $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" . $slug;
365 lars 186
        $arr = parseCMSPage( $url );
355 lars 187
        $content = $arr["content"];
361 lars 188
        return view( 'service_center_content', [
848 lars 189
            "serviceContent" => $content,
355 lars 190
        ] );
191
    } );
925 lars 192
    Route::get( "/bestellen_seite_{step}.html", function ( $step )
376 lars 193
    {
925 lars 194
        return view( 'buy_' . $step, [
924 lars 195
            "pagetype"      => "Bestellvorgang1",
848 lars 196
            "Laender"       => getRechnungsLaender(),
197
            "defaultLandID" => 47,
376 lars 198
        ] );
925 lars 199
    } )->where( 'step', '[1-4][ab]{0,1}' );
200
    Route::post( "/bestellen_seite_{step}.html", [ BuyController::class, 'step1' ] )->where( 'step', '[1-4][ab]{0,1}' );
1704 lars 201
    Route::view( "basket.html",'basket' );
1564 lars 202
    Route::get( "{item:slug}.html", function ( Item $item )
333 lars 203
    {
1564 lars 204
        return view( 'item', [
205
            "item" => $item,
206
        ] );
207
    } );
1692 lars 208
    Route::get( "/directory/{id}-{name}", [ DirectoryController::class, "index" ] )->whereNumber( 'id' );
1715 lars 209
    Route::get( "/manufacturers/", [ ManufacturerController::class, "index" ] );
210
    Route::get( "/manufacturers/{manufacturer:slug}.html", [ ManufacturerController::class, "show" ] );
333 lars 211
    Route::get( '/', function ()
212
    {
405 lars 213
        $date = date( "Y-m-d" );
214
        $aktion = Action::with( 'medium.medium' )->where( 'valid_from', '<=', $date )->where( 'valid_to', '>=', $date )->get();
333 lars 215
        return view( 'startpage', [
848 lars 216
            "pagetype" => "Startseite",
217
            "aktion"   => $aktion,
333 lars 218
        ] );
219
    } );
1706 lars 220
 
221
    function getRechnungsLaender(): array
222
    {
223
        $arr = array();
224
        $laender = DB::connection( 'cms' )->select( 'SELECT id,name_de FROM content_management.countries WHERE `rank` > 0 ORDER BY `rank`' );
225
        foreach ( $laender as $land )
226
        {
227
            $arr[$land->id] = $land->name_de;
228
        }
229
        return $arr;
1715 lars 230
    }