Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 345 | Revision 355 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
 
333 lars 3
    use App\Models\Action;
4
    use App\Models\Item;
5
    use App\Models\Directory;
6
    use Illuminate\Support\Facades\Route;
2 lars 7
 
333 lars 8
    /*
9
    |--------------------------------------------------------------------------
10
    | Web Routes
11
    |--------------------------------------------------------------------------
12
    |
13
    | Here is where you can register web routes for your application. These
14
    | routes are loaded by the RouteServiceProvider within a group which
15
    | contains the "web" middleware group. Now create something great!
16
    |
17
     */
2 lars 18
 
340 lars 19
    $sql = "
20
        SELECT
21
            *
22
        FROM
23
            i18n_de
24
    ";
25
    $langstrings = DB::select( $sql );
26
    foreach ( $langstrings as $langstring )
27
    {
342 lars 28
        $GLOBALS[ "langstrings" ][ $langstring->page_id ][ $langstring->id ] = $langstring->string;
340 lars 29
    }
333 lars 30
    function getConfig()
31
    {
32
        define( '__SITE__', env( 'site' ) );
33
        define( '__SHOP__', env( 'shop' ) );
34
        define( "__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__ );
176 lars 35
 
333 lars 36
        $cfg_file = __CFG_PATH__ . "/config.de.xml";
37
        if ( !file_exists( $cfg_file ) )
38
        {
39
            trigger_error( "Konnte keine Konfigurationsdatei für das Shopsystem " . __SITE__ . " -> " . __SHOP__ . " finden (" . ( $cfg_file ) . ")!", E_USER_ERROR );
40
        }
41
        $xml = simplexml_load_file( $cfg_file, "SimpleXMLElement", LIBXML_NOCDATA );
42
        $ini = json_decode( json_encode( $xml ), true );
43
        foreach ( $ini as $key => $wert )
44
        {
45
            if ( $wert == array() )
46
            {
47
                $ini[ $key ] = "";
48
            }
49
            elseif ( is_array( $wert ) )
50
            {
51
                foreach ( $wert as $key2 => $wert2 )
52
                {
53
                    if ( $wert2 == array() )
54
                    {
55
                        $ini[ $key ][ $key2 ] = "";
56
                    }
176 lars 57
                }
58
            }
59
        }
60
 
333 lars 61
        $v_file = __CFG_PATH__ . "/versand.xml";
62
        if ( file_exists( $v_file ) )
63
        {
64
            $xml = simplexml_load_file( $v_file, "SimpleXMLElement", LIBXML_NOCDATA );
65
            $ini[ "shipping" ] = json_decode( json_encode( $xml ), true );
66
            foreach ( $ini[ "shipping" ] as $key => $wert )
67
            {
68
                if ( $wert == array() )
69
                {
70
                    $ini[ "shipping" ][ $key ] = "";
71
                }
72
                elseif ( is_array( $wert ) )
73
                {
74
                    foreach ( $wert as $key2 => $wert2 )
75
                    {
76
                        if ( $wert2 == array() )
77
                        {
78
                            $ini[ "shipping" ][ $key ][ $key2 ] = "";
79
                        }
176 lars 80
                    }
81
                }
82
            }
83
        }
333 lars 84
        return $ini;
177 lars 85
    }
86
 
333 lars 87
    session_start();
88
    $GLOBALS[ "INI" ] = getConfig();
89
    $GLOBALS[ "menu" ] = array();
90
    $nav = new Directory();
91
    $GLOBALS[ "menu" ] = $nav->nav_menu();
92
    /* Mobile Weiche */
93
    if ( isset( $_SERVER[ "HTTP_USER_AGENT" ] ) )
94
    {
95
        if ( !isset( $_SESSION[ 'isMobile' ] ) || $_SESSION[ 'isMobile' ] == false || !isset( $GLOBALS[ 'isMobile' ] ) || $GLOBALS[ 'isMobile' ] == false )
96
        {
88 lars 97
 
333 lars 98
            $_SESSION[ 'isMobile' ] = false;
99
            $GLOBALS[ 'isMobile' ] = false;
88 lars 100
 
333 lars 101
            if (
102
                preg_match( "/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
88 lars 103
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
104
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
333 lars 105
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER[ "HTTP_USER_AGENT" ] )
106
            )
107
            {
88 lars 108
 
333 lars 109
                $_SESSION[ 'isMobile' ] = true;
110
                $GLOBALS[ 'isMobile' ] = true;
111
            }
112
 
88 lars 113
        }
114
    }
349 lars 115
    Route::get( "basket.html", function ()
116
    {
117
        return view( 'basket', [
118
            "nav"  => $GLOBALS[ "menu" ],
119
            "ini"  => $GLOBALS[ "INI" ],
120
            "langstrings" => $GLOBALS[ "langstrings" ],
121
        ] );
122
    } );
333 lars 123
    Route::get( "/directory/{id}", function ( $id )
124
    {
125
        list( $dirId, $dirName ) = explode( "-", $id, 2 );
126
        $dirs = Directory::with( 'medium.medium' )->where( "directory_id", $dirId )->whereIn( 'status', [
127
            0,
128
            2,
129
            99
130
        ] )->get();
131
        $items = Item::with( 'price' )->with( 'medium.medium' )->where( "directory_id", $dirId )->whereIn( 'status', [
132
            0,
133
            2
134
        ] )->get();
135
        $subdir = Directory::with( 'medium.medium' )->find( $dirId );
136
        $subdir[ "subdirs" ] = $dirs;
137
        $subdir[ "items" ] = $items;
138
        return view( 'subdir', [
139
            "subdir" => $subdir,
140
            "nav"    => $GLOBALS[ "menu" ],
344 lars 141
            "ini"    => $GLOBALS[ "INI" ],
343 lars 142
            "langstrings" => $GLOBALS[ "langstrings" ],
333 lars 143
        ] );
144
    } );
145
    Route::get( "{item:slug}.html", function ( Item $item )
146
    {
147
        $item->load( 'price', 'medium.medium' );
148
        return view( 'item', [
149
            "item" => $item,
150
            "nav"  => $GLOBALS[ "menu" ],
345 lars 151
            "ini"  => $GLOBALS[ "INI" ],
343 lars 152
            "langstrings" => $GLOBALS[ "langstrings" ],
333 lars 153
        ] );
154
    } );
155
    Route::get( '/', function ()
156
    {
157
        $aktion = Action::with( 'medium.medium' )->get();
158
        return view( 'startpage', [
343 lars 159
            "pagetype"    => "Startseite",
160
            "aktion"      => $aktion,
161
            "nav"         => $GLOBALS[ "menu" ],
162
            "ini"         => $GLOBALS[ "INI" ],
163
            "langstrings" => $GLOBALS[ "langstrings" ],
333 lars 164
        ] );
165
    } );