Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1704 | Revision 1706 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1657 lars 1
<?php
2
 
1703 lars 3
    use PHPHtmlParser\Dom;
4
    use PHPHtmlParser\Exceptions\ChildNotFoundException;
5
    use PHPHtmlParser\Exceptions\CircularException;
6
    use PHPHtmlParser\Exceptions\CurlException;
7
    use PHPHtmlParser\Exceptions\NotLoadedException;
8
    use PHPHtmlParser\Exceptions\StrictException;
1705 lars 9
    use Illuminate\Support\Facades\DB;
10
    use Illuminate\Support\Facades\Schema;
1703 lars 11
 
1704 lars 12
    $GLOBALS["zahlsysteme"] = [
13
        "kreditkarte",
14
        "paypal",
15
        "sofortueberweisung",
16
        "frei",
17
        "finanzierung",
18
        "billsafe",
19
        "billsafe_hire",
20
        "amazon",
21
        "PayPalExpress",
22
        "Ratenzahlung",
23
        "PayPalPlus",
24
        "paymill",
25
        "klarna",
26
        "paydirekt",
27
        "payever",
28
        "billie",
29
        "easycredit",
30
        "crefopay",
31
        "crefopayKK",
32
        "PayPalCheckout",
33
    ];
34
 
1699 lars 35
    function getConfig()
36
    {
1701 lars 37
        if ( !defined( "__SITE__" ) )
38
        {
39
            define( '__SITE__', env( 'site' ) );
40
        }
41
        if ( !defined( "__SHOP__" ) )
42
        {
43
            define( '__SHOP__', env( 'shop' ) );
44
        }
45
        if ( !defined( "__CFG_PATH__" ) )
46
        {
47
            define( "__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__ );
48
        }
1699 lars 49
        $cfg_file = __CFG_PATH__ . "/config.de.xml";
50
        if ( !file_exists( $cfg_file ) )
1657 lars 51
        {
1699 lars 52
            trigger_error( "Konnte keine Konfigurationsdatei für das Shopsystem " . __SITE__ . " -> " . __SHOP__ . " finden (" . ( $cfg_file ) . ")!", E_USER_ERROR );
1657 lars 53
        }
1699 lars 54
        $xml = simplexml_load_file( $cfg_file, "SimpleXMLElement", LIBXML_NOCDATA );
55
        $ini = json_decode( json_encode( $xml ), true );
56
        foreach ( $ini as $key => $wert )
1657 lars 57
        {
1699 lars 58
            if ( $wert == array() )
1659 lars 59
            {
1699 lars 60
                $ini[$key] = "";
1659 lars 61
            }
1699 lars 62
            elseif ( is_array( $wert ) )
1659 lars 63
            {
1699 lars 64
                foreach ( $wert as $key2 => $wert2 )
65
                {
66
                    if ( $wert2 == array() )
67
                    {
68
                        $ini[$key][$key2] = "";
69
                    }
70
                }
1659 lars 71
            }
1657 lars 72
        }
1699 lars 73
 
74
        $v_file = __CFG_PATH__ . "/versand.xml";
75
        if ( file_exists( $v_file ) )
76
        {
77
            $xml = simplexml_load_file( $v_file, "SimpleXMLElement", LIBXML_NOCDATA );
78
            $ini["shipping"] = json_decode( json_encode( $xml ), true );
79
            foreach ( $ini["shipping"] as $key => $wert )
80
            {
81
                if ( $wert == array() )
82
                {
83
                    $ini["shipping"][$key] = "";
84
                }
85
                elseif ( is_array( $wert ) )
86
                {
87
                    foreach ( $wert as $key2 => $wert2 )
88
                    {
89
                        if ( $wert2 == array() )
90
                        {
91
                            $ini["shipping"][$key][$key2] = "";
92
                        }
93
                    }
94
                }
95
            }
96
        }
97
        return $ini;
1657 lars 98
    }
1702 lars 99
 
100
    /**
101
     * Load Content form Typo3
102
     *
103
     * @param $url
104
     * @return array
105
     */
106
    function parseCMSPage( $url ): array
107
    {
108
        $menu = "";
109
        $content = "";
110
        $dom = new Dom;
111
        try
112
        {
113
            $dom->loadFromUrl( $url );
114
            $menu = $dom->getElementById( 'menu' )->innerHtml;
115
            $menu = str_replace( "/typo3", "/cms", $menu );
116
            $content = $dom->getElementById( 'content' )->innerHtml;
117
            $content = str_replace( "fileadmin/", $GLOBALS["INI"]["typo3"]["url"] . "/typo3/fileadmin/", $content );
118
            $content = str_replace( "ce-textpic", "", $content );
119
        }
120
        catch ( ChildNotFoundException|CircularException|CurlException|StrictException|NotLoadedException $e )
121
        {
122
        }
123
        return array( "menu" => $menu, "content" => $content, );
124
    }
125
 
1704 lars 126
    if ( isset( $_GET["killSession"] ) )
127
    {
128
        unset( $_SESSION );
129
        $_SESSION["SHOP"]["BASKET"] = new BasketController();
130
    }
131
    $GLOBALS["steuern"] = array();
132
    //default LandID für Deutschland
133
    $landID = 47;
134
    //Wenn das Flag gesetzt ist, dann nimm diesen wert, damit auch "ausländische Shops" den richtigen MwSt angezeigt bekommen
135
    if ( isset( $GLOBALS["INI"]["steuern"]["default_countryID"] ) )
136
    {
137
        $landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
138
    }
139
 
140
    $countryIDs = ( isset( $GLOBALS['INI']['steuern']['use_countries_tax'] ) ) ? $GLOBALS['INI']['steuern']['use_countries_tax'] : $landID;
141
 
142
    $sql = "SELECT
143
            *
144
        FROM
145
            content_management.countries_tax
146
        WHERE
147
            country_id IN (" . $countryIDs . ")
148
    ";
149
    $rows = DB::connection( "cms" )->select( $sql );
150
    foreach ( $rows as $r )
151
    {
152
        $GLOBALS["steuern"][$r->country_id][$r->taxes_id] = $r->tax_percent;
153
        $GLOBALS["steuern"][$r->country_id][null] = $GLOBALS["steuern"][$r->country_id][0];
154
    }
155
 
156
    $sql = "
157
        SELECT
158
            *
159
        FROM
160
            i18n_de
161
    ";
162
    if ( Schema::hasTable( 'i18n_de' ) )
163
    {
164
        $langstrings = DB::select( $sql );
165
    }
166
    else
167
    {
168
        $langstrings = DB::connection( "old" )->select( $sql );
169
    }
170
    foreach ( $langstrings as $langstring )
171
    {
172
        $GLOBALS["langstrings"][$langstring->page_id][$langstring->id] = $langstring->string;
173
    }
174
 
175
    function getRechnungsLaender(): array
176
    {
177
        $arr = array();
178
        $laender = DB::connection( 'cms' )->select( 'SELECT id,name_de FROM content_management.countries WHERE `rank` > 0 ORDER BY `rank`' );
179
        foreach ( $laender as $land )
180
        {
181
            $arr[$land->id] = $land->name_de;
182
        }
183
        return $arr;
184
    }