Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 341 | Revision 343 | 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
    }
30
    \View::assign( 'langstrings', $GLOBALS[ "langstrings" ] );
333 lars 31
    function getConfig()
32
    {
33
        define( '__SITE__', env( 'site' ) );
34
        define( '__SHOP__', env( 'shop' ) );
35
        define( "__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__ );
176 lars 36
 
333 lars 37
        $cfg_file = __CFG_PATH__ . "/config.de.xml";
38
        if ( !file_exists( $cfg_file ) )
39
        {
40
            trigger_error( "Konnte keine Konfigurationsdatei für das Shopsystem " . __SITE__ . " -> " . __SHOP__ . " finden (" . ( $cfg_file ) . ")!", E_USER_ERROR );
41
        }
42
        $xml = simplexml_load_file( $cfg_file, "SimpleXMLElement", LIBXML_NOCDATA );
43
        $ini = json_decode( json_encode( $xml ), true );
44
        foreach ( $ini as $key => $wert )
45
        {
46
            if ( $wert == array() )
47
            {
48
                $ini[ $key ] = "";
49
            }
50
            elseif ( is_array( $wert ) )
51
            {
52
                foreach ( $wert as $key2 => $wert2 )
53
                {
54
                    if ( $wert2 == array() )
55
                    {
56
                        $ini[ $key ][ $key2 ] = "";
57
                    }
176 lars 58
                }
59
            }
60
        }
61
 
333 lars 62
        $v_file = __CFG_PATH__ . "/versand.xml";
63
        if ( file_exists( $v_file ) )
64
        {
65
            $xml = simplexml_load_file( $v_file, "SimpleXMLElement", LIBXML_NOCDATA );
66
            $ini[ "shipping" ] = json_decode( json_encode( $xml ), true );
67
            foreach ( $ini[ "shipping" ] as $key => $wert )
68
            {
69
                if ( $wert == array() )
70
                {
71
                    $ini[ "shipping" ][ $key ] = "";
72
                }
73
                elseif ( is_array( $wert ) )
74
                {
75
                    foreach ( $wert as $key2 => $wert2 )
76
                    {
77
                        if ( $wert2 == array() )
78
                        {
79
                            $ini[ "shipping" ][ $key ][ $key2 ] = "";
80
                        }
176 lars 81
                    }
82
                }
83
            }
84
        }
333 lars 85
        return $ini;
177 lars 86
    }
87
 
333 lars 88
    session_start();
89
    $GLOBALS[ "INI" ] = getConfig();
90
    $GLOBALS[ "menu" ] = array();
91
    $nav = new Directory();
92
    $GLOBALS[ "menu" ] = $nav->nav_menu();
93
    /* Mobile Weiche */
94
    if ( isset( $_SERVER[ "HTTP_USER_AGENT" ] ) )
95
    {
96
        if ( !isset( $_SESSION[ 'isMobile' ] ) || $_SESSION[ 'isMobile' ] == false || !isset( $GLOBALS[ 'isMobile' ] ) || $GLOBALS[ 'isMobile' ] == false )
97
        {
88 lars 98
 
333 lars 99
            $_SESSION[ 'isMobile' ] = false;
100
            $GLOBALS[ 'isMobile' ] = false;
88 lars 101
 
333 lars 102
            if (
103
                preg_match( "/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
88 lars 104
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
105
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
333 lars 106
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER[ "HTTP_USER_AGENT" ] )
107
            )
108
            {
88 lars 109
 
333 lars 110
                $_SESSION[ 'isMobile' ] = true;
111
                $GLOBALS[ 'isMobile' ] = true;
112
            }
113
 
88 lars 114
        }
115
    }
333 lars 116
    Route::get( "/directory/{id}", function ( $id )
117
    {
118
        list( $dirId, $dirName ) = explode( "-", $id, 2 );
119
        $dirs = Directory::with( 'medium.medium' )->where( "directory_id", $dirId )->whereIn( 'status', [
120
            0,
121
            2,
122
            99
123
        ] )->get();
124
        $items = Item::with( 'price' )->with( 'medium.medium' )->where( "directory_id", $dirId )->whereIn( 'status', [
125
            0,
126
            2
127
        ] )->get();
128
        $subdir = Directory::with( 'medium.medium' )->find( $dirId );
129
        $subdir[ "subdirs" ] = $dirs;
130
        $subdir[ "items" ] = $items;
131
        return view( 'subdir', [
132
            "subdir" => $subdir,
133
            "nav"    => $GLOBALS[ "menu" ],
134
            "ini"    => $GLOBALS[ "INI" ]
135
        ] );
136
    } );
137
    Route::get( "{item:slug}.html", function ( Item $item )
138
    {
139
        $item->load( 'price', 'medium.medium' );
140
        return view( 'item', [
141
            "item" => $item,
142
            "nav"  => $GLOBALS[ "menu" ],
143
            "ini"  => $GLOBALS[ "INI" ]
144
        ] );
145
    } );
146
    Route::get( '/', function ()
147
    {
148
        $aktion = Action::with( 'medium.medium' )->get();
149
        return view( 'startpage', [
150
            "pagetype" => "Startseite",
151
            "aktion"   => $aktion,
152
            "nav"      => $GLOBALS[ "menu" ],
153
            "ini"      => $GLOBALS[ "INI" ]
154
        ] );
155
    } );