Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 349 | Revision 356 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 349 Revision 355
Zeile 23... Zeile 23...
23
            i18n_de
23
            i18n_de
24
    ";
24
    ";
25
    $langstrings = DB::select( $sql );
25
    $langstrings = DB::select( $sql );
26
    foreach ( $langstrings as $langstring )
26
    foreach ( $langstrings as $langstring )
27
    {
27
    {
28
        $GLOBALS[ "langstrings" ][ $langstring->page_id ][ $langstring->id ] = $langstring->string;
28
        $GLOBALS["langstrings"][$langstring->page_id][$langstring->id] = $langstring->string;
29
    }
29
    }
-
 
30
    function getCMSPage( $url )
-
 
31
    {
-
 
32
        $ch = curl_init( $url );
-
 
33
        curl_setopt_array( $ch, array(
-
 
34
            CURLOPT_RETURNTRANSFER => true,
-
 
35
        );
-
 
36
        $erg = curl_exec( $ch );
-
 
37
        $code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
-
 
38
        return $erg;
-
 
39
    }
-
 
40
 
-
 
41
    function parseCMSPage( $content )
-
 
42
    {
-
 
43
        $doc = new DomDocument;
-
 
44
        $doc->validateOnParse = true;
-
 
45
        $doc->loadHtml( $erg );
-
 
46
        $menu = $doc->getElementById( "menu" )->nodeValue;
-
 
47
        $content = $doc->getElementById( "content" )->nodeValue;
-
 
48
        return array( "menu" => $menu, "content" => $content, );
-
 
49
    }
-
 
50
 
30
    function getConfig()
51
    function getConfig()
31
    {
52
    {
32
        define( '__SITE__', env( 'site' ) );
53
        define( '__SITE__', env( 'site' ) );
33
        define( '__SHOP__', env( 'shop' ) );
54
        define( '__SHOP__', env( 'shop' ) );
34
        define( "__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__ );
55
        define( "__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__ );
Zeile 42... Zeile 63...
42
        $ini = json_decode( json_encode( $xml ), true );
63
        $ini = json_decode( json_encode( $xml ), true );
43
        foreach ( $ini as $key => $wert )
64
        foreach ( $ini as $key => $wert )
44
        {
65
        {
45
            if ( $wert == array() )
66
            if ( $wert == array() )
46
            {
67
            {
47
                $ini[ $key ] = "";
68
                $ini[$key] = "";
48
            }
69
            }
49
            elseif ( is_array( $wert ) )
70
            elseif ( is_array( $wert ) )
50
            {
71
            {
51
                foreach ( $wert as $key2 => $wert2 )
72
                foreach ( $wert as $key2 => $wert2 )
52
                {
73
                {
53
                    if ( $wert2 == array() )
74
                    if ( $wert2 == array() )
54
                    {
75
                    {
55
                        $ini[ $key ][ $key2 ] = "";
76
                        $ini[$key][$key2] = "";
56
                    }
77
                    }
57
                }
78
                }
58
            }
79
            }
59
        }
80
        }
Zeile 60... Zeile 81...
60
 
81
 
61
        $v_file = __CFG_PATH__ . "/versand.xml";
82
        $v_file = __CFG_PATH__ . "/versand.xml";
62
        if ( file_exists( $v_file ) )
83
        if ( file_exists( $v_file ) )
63
        {
84
        {
64
            $xml = simplexml_load_file( $v_file, "SimpleXMLElement", LIBXML_NOCDATA );
85
            $xml = simplexml_load_file( $v_file, "SimpleXMLElement", LIBXML_NOCDATA );
65
            $ini[ "shipping" ] = json_decode( json_encode( $xml ), true );
86
            $ini["shipping"] = json_decode( json_encode( $xml ), true );
66
            foreach ( $ini[ "shipping" ] as $key => $wert )
87
            foreach ( $ini["shipping"] as $key => $wert )
67
            {
88
            {
68
                if ( $wert == array() )
89
                if ( $wert == array() )
69
                {
90
                {
70
                    $ini[ "shipping" ][ $key ] = "";
91
                    $ini["shipping"][$key] = "";
71
                }
92
                }
72
                elseif ( is_array( $wert ) )
93
                elseif ( is_array( $wert ) )
73
                {
94
                {
74
                    foreach ( $wert as $key2 => $wert2 )
95
                    foreach ( $wert as $key2 => $wert2 )
75
                    {
96
                    {
76
                        if ( $wert2 == array() )
97
                        if ( $wert2 == array() )
77
                        {
98
                        {
78
                            $ini[ "shipping" ][ $key ][ $key2 ] = "";
99
                            $ini["shipping"][$key][$key2] = "";
79
                        }
100
                        }
80
                    }
101
                    }
81
                }
102
                }
82
            }
103
            }
83
        }
104
        }
84
        return $ini;
105
        return $ini;
Zeile 85... Zeile 106...
85
    }
106
    }
86
 
107
 
87
    session_start();
108
    session_start();
88
    $GLOBALS[ "INI" ] = getConfig();
109
    $GLOBALS["INI"] = getConfig();
89
    $GLOBALS[ "menu" ] = array();
110
    $GLOBALS["menu"] = array();
90
    $nav = new Directory();
111
    $nav = new Directory();
91
    $GLOBALS[ "menu" ] = $nav->nav_menu();
112
    $GLOBALS["menu"] = $nav->nav_menu();
92
    /* Mobile Weiche */
113
    /* Mobile Weiche */
93
    if ( isset( $_SERVER[ "HTTP_USER_AGENT" ] ) )
114
    if ( isset( $_SERVER["HTTP_USER_AGENT"] ) )
94
    {
115
    {
Zeile 95... Zeile 116...
95
        if ( !isset( $_SESSION[ 'isMobile' ] ) || $_SESSION[ 'isMobile' ] == false || !isset( $GLOBALS[ 'isMobile' ] ) || $GLOBALS[ 'isMobile' ] == false )
116
        if ( !isset( $_SESSION['isMobile'] ) || $_SESSION['isMobile'] == false || !isset( $GLOBALS['isMobile'] ) || $GLOBALS['isMobile'] == false )
96
        {
117
        {
Zeile 97... Zeile 118...
97
 
118
 
98
            $_SESSION[ 'isMobile' ] = false;
119
            $_SESSION['isMobile'] = false;
99
            $GLOBALS[ 'isMobile' ] = false;
120
            $GLOBALS['isMobile'] = false;
100
 
121
 
101
            if (
122
            if (
102
                preg_match( "/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
123
                preg_match( "/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine
103
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
124
        |htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|
Zeile 104... Zeile 125...
104
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
125
        panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus
105
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER[ "HTTP_USER_AGENT" ] )
126
        |up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i", $_SERVER["HTTP_USER_AGENT"] )
106
            )
127
            )
Zeile 107... Zeile 128...
107
            {
128
            {
108
 
129
 
-
 
130
                $_SESSION['isMobile'] = true;
-
 
131
                $GLOBALS['isMobile'] = true;
-
 
132
            }
-
 
133
 
-
 
134
        }
-
 
135
    }
-
 
136
    Route::get( "/cms/{slug}", function ( $slug )
-
 
137
    {
-
 
138
        $url = $GLOBALS["INI"]["typo3"]["url"] . "/" . $slug;
-
 
139
        $res = getCMSPage( $url );
-
 
140
        $arr = parseCMSPage( $res );
-
 
141
        $content = $arr["content"];
-
 
142
        return view( 'subdir', [
109
                $_SESSION[ 'isMobile' ] = true;
143
            "content"      => $content,
110
                $GLOBALS[ 'isMobile' ] = true;
144
            "nav"         => $GLOBALS["menu"],
111
            }
145
            "ini"         => $GLOBALS["INI"],
112
 
146
            "langstrings" => $GLOBALS["langstrings"],
113
        }
147
        ] );
114
    }
148
    } );
115
    Route::get( "basket.html", function ()
149
    Route::get( "basket.html", function ()
116
    {
150
    {
117
        return view( 'basket', [
151
        return view( 'basket', [
118
            "nav"  => $GLOBALS[ "menu" ],
152
            "nav"         => $GLOBALS["menu"],
119
            "ini"  => $GLOBALS[ "INI" ],
153
            "ini"         => $GLOBALS["INI"],
Zeile 131... Zeile 165...
131
        $items = Item::with( 'price' )->with( 'medium.medium' )->where( "directory_id", $dirId )->whereIn( 'status', [
165
        $items = Item::with( 'price' )->with( 'medium.medium' )->where( "directory_id", $dirId )->whereIn( 'status', [
132
            0,
166
            0,
133
            2
167
            2
134
        ] )->get();
168
        ] )->get();
135
        $subdir = Directory::with( 'medium.medium' )->find( $dirId );
169
        $subdir = Directory::with( 'medium.medium' )->find( $dirId );
136
        $subdir[ "subdirs" ] = $dirs;
170
        $subdir["subdirs"] = $dirs;
137
        $subdir[ "items" ] = $items;
171
        $subdir["items"] = $items;
138
        return view( 'subdir', [
172
        return view( 'subdir', [
139
            "subdir" => $subdir,
173
            "subdir"      => $subdir,
140
            "nav"    => $GLOBALS[ "menu" ],
174
            "nav"         => $GLOBALS["menu"],
141
            "ini"    => $GLOBALS[ "INI" ],
175
            "ini"         => $GLOBALS["INI"],
142
            "langstrings" => $GLOBALS[ "langstrings" ],
176
            "langstrings" => $GLOBALS["langstrings"],
143
        ] );
177
        ] );
144
    } );
178
    } );
145
    Route::get( "{item:slug}.html", function ( Item $item )
179
    Route::get( "{item:slug}.html", function ( Item $item )
146
    {
180
    {
147
        $item->load( 'price', 'medium.medium' );
181
        $item->load( 'price', 'medium.medium' );
148
        return view( 'item', [
182
        return view( 'item', [
149
            "item" => $item,
183
            "item"        => $item,
150
            "nav"  => $GLOBALS[ "menu" ],
184
            "nav"         => $GLOBALS["menu"],
151
            "ini"  => $GLOBALS[ "INI" ],
185
            "ini"         => $GLOBALS["INI"],
152
            "langstrings" => $GLOBALS[ "langstrings" ],
186
            "langstrings" => $GLOBALS["langstrings"],
153
        ] );
187
        ] );
154
    } );
188
    } );
155
    Route::get( '/', function ()
189
    Route::get( '/', function ()
156
    {
190
    {
157
        $aktion = Action::with( 'medium.medium' )->get();
191
        $aktion = Action::with( 'medium.medium' )->get();
158
        return view( 'startpage', [
192
        return view( 'startpage', [
159
            "pagetype"    => "Startseite",
193
            "pagetype"    => "Startseite",
160
            "aktion"      => $aktion,
194
            "aktion"      => $aktion,
161
            "nav"         => $GLOBALS[ "menu" ],
195
            "nav"         => $GLOBALS["menu"],
162
            "ini"         => $GLOBALS[ "INI" ],
196
            "ini"         => $GLOBALS["INI"],
163
            "langstrings" => $GLOBALS[ "langstrings" ],
197
            "langstrings" => $GLOBALS["langstrings"],
164
        ] );
198
        ] );
165
    } );
199
    } );