Subversion-Projekte lars-tiefland.laravel_shop

Revision

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