Subversion-Projekte lars-tiefland.laravel_shop

Revision

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

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