Subversion-Projekte lars-tiefland.laravel_shop

Revision

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