Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1699 | Revision 1703 | 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;
375 lars 9
    use Illuminate\Support\Facades\DB;
673 lars 10
    use Illuminate\Support\Facades\Schema;
365 lars 11
    use PHPHtmlParser\Dom;
333 lars 12
    use App\Models\Action;
13
    use App\Models\Item;
14
    use App\Models\Directory;
15
    use Illuminate\Support\Facades\Route;
366 lars 16
    use PHPHtmlParser\Exceptions\ChildNotFoundException;
17
    use PHPHtmlParser\Exceptions\CircularException;
18
    use PHPHtmlParser\Exceptions\CurlException;
375 lars 19
    use PHPHtmlParser\Exceptions\NotLoadedException;
366 lars 20
    use PHPHtmlParser\Exceptions\StrictException;
2 lars 21
 
333 lars 22
    /*
23
    |--------------------------------------------------------------------------
24
    | Web Routes
25
    |--------------------------------------------------------------------------
26
    |
27
    | Here is where you can register web routes for your application. These
28
    | routes are loaded by the RouteServiceProvider within a group which
29
    | contains the "web" middleware group. Now create something great!
30
    |
31
     */
2 lars 32
 
848 lars 33
    $GLOBALS["INI"] = getConfig();
850 lars 34
    $GLOBALS["zahlsysteme"] = [
832 lars 35
        "kreditkarte",
36
        "paypal",
37
        "sofortueberweisung",
38
        "frei",
39
        "finanzierung",
40
        "billsafe",
41
        "billsafe_hire",
42
        "amazon",
43
        "PayPalExpress",
44
        "Ratenzahlung",
45
        "PayPalPlus",
46
        "paymill",
47
        "klarna",
48
        "paydirekt",
49
        "payever",
50
        "billie",
51
        "easycredit",
52
        "crefopay",
53
        "crefopayKK",
54
        "PayPalCheckout",
850 lars 55
    ];
832 lars 56
 
624 lars 57
    if ( php_sapi_name() == "cli" )
582 lars 58
    {
59
        return;
60
    }
704 lars 61
    session_start();
847 lars 62
    if ( isset( $_GET["killSession"] ) )
63
    {
64
        unset( $_SESSION );
65
        $_SESSION["SHOP"]["BASKET"] = new BasketController();
66
    }
710 lars 67
    $GLOBALS["steuern"] = array();
68
    //default LandID für Deutschland
69
    $landID = 47;
70
    //Wenn das Flag gesetzt ist, dann nimm diesen wert, damit auch "ausländische Shops" den richtigen MwSt angezeigt bekommen
71
    if ( isset( $GLOBALS["INI"]["steuern"]["default_countryID"] ) )
72
    {
73
        $landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
74
    }
75
 
76
    $countryIDs = ( isset( $GLOBALS['INI']['steuern']['use_countries_tax'] ) ) ? $GLOBALS['INI']['steuern']['use_countries_tax'] : $landID;
77
 
723 lars 78
    $sql = "SELECT
79
            *
80
        FROM
1619 lars 81
            content_management.countries_tax
723 lars 82
        WHERE
83
            country_id IN (" . $countryIDs . ")
84
    ";
85
    $rows = DB::connection( "cms" )->select( $sql );
710 lars 86
    foreach ( $rows as $r )
87
    {
711 lars 88
        $GLOBALS["steuern"][$r->country_id][$r->taxes_id] = $r->tax_percent;
89
        $GLOBALS["steuern"][$r->country_id][null] = $GLOBALS["steuern"][$r->country_id][0];
710 lars 90
    }
697 lars 91
    if ( !isset( $_SESSION["SHOP"]["BASKET"] ) )
92
    {
730 lars 93
        $_SESSION["SHOP"]["BASKET"] = new BasketController();
697 lars 94
    }
700 lars 95
    elseif ( is_array( $_SESSION["SHOP"]["BASKET"] ) )
697 lars 96
    {
97
        $items = $_SESSION["SHOP"]["BASKET"];
98
        unset( $_SESSION["SHOP"]["BASKET"] );
730 lars 99
        $_SESSION["SHOP"]["BASKET"] = new BasketController();
699 lars 100
        $_SESSION["SHOP"]["BASKET"]->items = $items;
697 lars 101
    }
340 lars 102
    $sql = "
103
        SELECT
104
            *
105
        FROM
106
            i18n_de
107
    ";
405 lars 108
    if ( Schema::hasTable( 'i18n_de' ) )
109
    {
110
        $langstrings = DB::select( $sql );
111
    }
112
    else
113
    {
114
        $langstrings = DB::connection( "old" )->select( $sql );
115
    }
340 lars 116
    foreach ( $langstrings as $langstring )
117
    {
355 lars 118
        $GLOBALS["langstrings"][$langstring->page_id][$langstring->id] = $langstring->string;
340 lars 119
    }
355 lars 120
 
1586 lars 121
    if ( !isset( $_SESSION["navigation"]["position"] ) )
122
    {
123
        $_SESSION["navigation"]["position"] = null;
124
    }
1693 lars 125
    $nav = new DirectoryController();
848 lars 126
    $menu = $nav->nav_menu();
1582 lars 127
    $shopPosition = $nav->shopPosition();
368 lars 128
    $sc = parseCMSPage( $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" );
852 lars 129
    $data = [
130
        "nav"               => $menu,
131
        "serviceCenterMenu" => $sc["menu"],
1582 lars 132
        "shopPosition"      => $shopPosition,
852 lars 133
        "langstrings"       => $GLOBALS["langstrings"],
134
        "ini"               => $GLOBALS["INI"],
135
    ];
136
    \View::share( $data );
848 lars 137
 
333 lars 138
    /* Mobile Weiche */
355 lars 139
    if ( isset( $_SERVER["HTTP_USER_AGENT"] ) )
333 lars 140
    {
375 lars 141
        if ( !isset( $_SESSION['isMobile'] ) || $_SESSION['isMobile'] === false || !isset( $GLOBALS['isMobile'] ) || $GLOBALS['isMobile'] === false )
333 lars 142
        {
88 lars 143
 
355 lars 144
            $_SESSION['isMobile'] = false;
145
            $GLOBALS['isMobile'] = false;
88 lars 146
 
853 lars 147
            $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";
148
            if ( preg_match( $pattern, $_SERVER["HTTP_USER_AGENT"] ) )
333 lars 149
            {
88 lars 150
 
355 lars 151
                $_SESSION['isMobile'] = true;
152
                $GLOBALS['isMobile'] = true;
333 lars 153
            }
154
 
88 lars 155
        }
156
    }
1674 lars 157
    Route::get( "/preisagentur/{filename}", [ PriceAgencyController::class, "download" ] );
405 lars 158
    Route::get( "/addItemToBasket", function ()
385 lars 159
    {
697 lars 160
        $_SESSION["SHOP"]["BASKET"]->addItem();
848 lars 161
        return view( 'header_wk' );
405 lars 162
    } );
745 lars 163
    Route::get( "/editItem/{id}/{menge}", function ()
164
    {
165
        $_SESSION["SHOP"]["BASKET"]->editItem();
765 lars 166
        return redirect( "/basket.html" );
745 lars 167
    } )->where( [ "id" => "[0-9a-f]{40}", "menge" => "[0-9]+" ] );
168
    Route::get( "/delItem/{id}", function ()
169
    {
170
        $_SESSION["SHOP"]["BASKET"]->delItem();
765 lars 171
        return redirect( "/basket.html" );
745 lars 172
    } )->where( "id", "[0-9a-f]{40}" );
766 lars 173
    Route::post( "/login", [ UserController::class, "login" ] );
809 lars 174
    Route::post( "/logout", [ UserController::class, "logout" ] );
814 lars 175
    Route::post( "/send_pw", [ UserController::class, "forgot_pw" ] );
777 lars 176
    Route::get( "/favoriten", function ()
177
    {
848 lars 178
        return view( 'login_center' );
777 lars 179
    } );
776 lars 180
    Route::get( "/forgot_pw", function ()
181
    {
848 lars 182
        return view( 'login_center' );
776 lars 183
    } );
765 lars 184
    Route::get( "/login", function ()
762 lars 185
    {
848 lars 186
        return view( 'login_center' );
765 lars 187
    } );
775 lars 188
    Route::get( "/register", function ()
189
    {
848 lars 190
        return view( 'login_center' );
775 lars 191
    } );
890 lars 192
    Route::get( "/update_versand", [ ShippingController::class, "updateShipping" ] );
891 lars 193
    Route::get( "/checkLand.php", function ()
890 lars 194
    {
195
        $_SESSION['SHOP']["BASKET"]->getShippingCountries();
196
        $valid = 1;
893 lars 197
        if ( !in_array( $_GET["land"], array_keys( $_SESSION["SHOP"]["BASKET"]->shippingCountries ) ) )
890 lars 198
        {
199
            $valid = 0;
200
        }
899 lars 201
        echo $valid;
890 lars 202
        return $valid;
203
    } );
658 lars 204
    Route::get( '/setSessionVars', function ()
205
    {
206
        foreach ( $_GET as $key => $value )
207
        {
208
            if ( $value == "false" )
209
            {
210
                unset( $_SESSION[$key] );
211
            }
212
            else
213
            {
214
                $_SESSION[$key] = $value;
215
            }
216
        }
217
    } );
765 lars 218
    Route::post( "/setSessionVars", function ()
219
    {
762 lars 220
        foreach ( $_POST as $key => $value )
221
        {
222
            if ( $value == "false" )
223
            {
224
                unset( $_SESSION[$key] );
225
            }
226
            else
227
            {
228
                $_SESSION[$key] = $value;
229
            }
230
        }
765 lars 231
    } );
232
    Route::post( "/updateSession", function ()
756 lars 233
    {
234
    } );
355 lars 235
    Route::get( "/cms/{slug}", function ( $slug )
236
    {
359 lars 237
        $url = $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" . $slug;
365 lars 238
        $arr = parseCMSPage( $url );
355 lars 239
        $content = $arr["content"];
361 lars 240
        return view( 'service_center_content', [
848 lars 241
            "serviceContent" => $content,
355 lars 242
        ] );
243
    } );
925 lars 244
    Route::get( "/bestellen_seite_{step}.html", function ( $step )
376 lars 245
    {
925 lars 246
        return view( 'buy_' . $step, [
924 lars 247
            "pagetype"      => "Bestellvorgang1",
848 lars 248
            "Laender"       => getRechnungsLaender(),
249
            "defaultLandID" => 47,
376 lars 250
        ] );
925 lars 251
    } )->where( 'step', '[1-4][ab]{0,1}' );
252
    Route::post( "/bestellen_seite_{step}.html", [ BuyController::class, 'step1' ] )->where( 'step', '[1-4][ab]{0,1}' );
349 lars 253
    Route::get( "basket.html", function ()
254
    {
678 lars 255
 
848 lars 256
        return view( 'basket' );
349 lars 257
    } );
1564 lars 258
    Route::get( "{item:slug}.html", function ( Item $item )
333 lars 259
    {
1564 lars 260
        //$item->load( 'price', 'medium.medium', 'manufacturer' );
261
        return view( 'item', [
262
            "item" => $item,
263
        ] );
264
    } );
1692 lars 265
    Route::get( "/directory/{id}-{name}", [ DirectoryController::class, "index" ] )->whereNumber( 'id' );
333 lars 266
    Route::get( '/', function ()
267
    {
405 lars 268
        $date = date( "Y-m-d" );
269
        $aktion = Action::with( 'medium.medium' )->where( 'valid_from', '<=', $date )->where( 'valid_to', '>=', $date )->get();
333 lars 270
        return view( 'startpage', [
848 lars 271
            "pagetype" => "Startseite",
272
            "aktion"   => $aktion,
333 lars 273
        ] );
274
    } );
685 lars 275
 
276
 
703 lars 277
    function getRechnungsLaender(): array
685 lars 278
    {
687 lars 279
        $arr = array();
1619 lars 280
        $laender = DB::connection( 'cms' )->select( 'SELECT id,name_de FROM content_management.countries WHERE `rank` > 0 ORDER BY `rank`' );
687 lars 281
        foreach ( $laender as $land )
282
        {
283
            $arr[$land->id] = $land->name_de;
284
        }
285
        return $arr;
730 lars 286
    }
964 lars 287
 
1144 lars 288
    //require_once __DIR__.'/admin.php';