Subversion-Projekte lars-tiefland.ci

Revision

Revision 2011 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 2011 Revision 2117
Zeile 1... Zeile 1...
1
<?php
1
<?php
Zeile 2... Zeile 2...
2
 
2
 
Zeile 3... Zeile 3...
3
// $Id: weban_helper.php 2011 2017-02-04 23:30:38Z lars $
3
// $Id: weban_helper.php 2117 2017-11-11 20:56:38Z lars $
4
 
-
 
5
if (!defined("CONTINUE_ON_ERROR"))
4
 
6
{
5
if (!defined("CONTINUE_ON_ERROR")) {
7
	define("CONTINUE_ON_ERROR", false);
6
    define("CONTINUE_ON_ERROR", false);
8
}
-
 
9
if (!defined("CRON"))
7
}
10
{
-
 
11
	if (php_sapi_name() == "cli")
8
if (!defined("CRON")) {
12
	{
-
 
13
		define("CRON", true);
9
    if (php_sapi_name() == "cli") {
14
	}
-
 
15
	else
10
        define("CRON", true);
16
	{
11
    } else {
17
		define("CRON", false);
12
        define("CRON", false);
18
	}
13
    }
19
}
14
}
20
 
-
 
21
if (!defined("EOL"))
15
 
22
{
-
 
23
	if (php_sapi_name() == "cli")
16
if (!defined("EOL")) {
24
	{
-
 
25
		define("EOL", "\n");
17
    if (php_sapi_name() == "cli") {
26
	}
-
 
27
	else
18
        define("EOL", "\n");
28
	{
19
    } else {
29
		define("EOL", "<br>");
20
        define("EOL", "<br>");
30
	}
21
    }
31
}
22
}
32
$GLOBALS['ci'] = &get_instance();
23
$GLOBALS['ci'] = &get_instance();
33
$GLOBALS['order_db'] = $GLOBALS['ci']->load->database('order_db', TRUE);
24
$GLOBALS['order_db'] = $GLOBALS['ci']->load->database('order_db', true);
34
$GLOBALS['db_red'] = $GLOBALS['ci']->load->database('db_red', TRUE);
25
$GLOBALS['db_red'] = $GLOBALS['ci']->load->database('db_red', true);
35
$GLOBALS['ci']->load->model('artikel_model', 'artikel');
26
$GLOBALS['ci']->load->model('artikel_model', 'artikel');
36
$domain = "faltradxxs.de";
27
$domain = "faltradxxs.de";
37
$GLOBALS["Eigenschaften"] = getVersandEigenschaften($domain);
28
$GLOBALS["Eigenschaften"] = getVersandEigenschaften($domain);
Zeile 38... Zeile 29...
38
$GLOBALS["web_rechte"] = getWebRechte($domain);
29
$GLOBALS["web_rechte"] = getWebRechte($domain);
39
isWeban();
30
isWeban();
40
 
31
 
41
$GLOBALS["zahlsysteme"] = array(
32
$GLOBALS["zahlsysteme"] = array(
42
	"kreditkarte",
33
    "kreditkarte",
43
	"paypal",
34
    "paypal",
44
	"sofortueberweisung",
35
    "sofortueberweisung",
45
	"frei",
36
    "frei",
46
	"finanzierung",
37
    "finanzierung",
47
	"billsafe",
38
    "billsafe",
48
	"billsafe_hire",
39
    "billsafe_hire",
49
	"amazon",
40
    "amazon",
50
	"PayPalExpress",
41
    "PayPalExpress",
51
	"Ratenzahlung",
42
    "Ratenzahlung",
Zeile 52... Zeile 43...
52
	"PayPalPlus",
43
    "PayPalPlus",
53
	"paymill",
44
    "paymill",
54
	);
45
    );
55
 
46
 
56
//Excellence Käuferschutz
47
//Excellence Käuferschutz
57
$GLOBALS["tsItems"] = array(
48
$GLOBALS["tsItems"] = array(
58
	"TS080501_500_30_EUR" => array(
49
    "TS080501_500_30_EUR" => array(
59
		"max" => 500,
50
        "max" => 500,
60
		"preis" => 0.82353,
51
        "preis" => 0.82353,
61
		),
52
        ),
62
	"TS080501_1500_30_EUR" => array(
53
    "TS080501_1500_30_EUR" => array(
63
		"max" => 1500,
54
        "max" => 1500,
64
		"preis" => 2.47059,
55
        "preis" => 2.47059,
65
		),
56
        ),
66
	"TS080501_2500_30_EUR" => array(
57
    "TS080501_2500_30_EUR" => array(
67
		"max" => 2500,
58
        "max" => 2500,
68
		"preis" => 4.11765,
59
        "preis" => 4.11765,
69
		),
60
        ),
70
	"TS080501_5000_30_EUR" => array(
61
    "TS080501_5000_30_EUR" => array(
71
		"max" => 5000,
62
        "max" => 5000,
72
		"preis" => 8.23530,
63
        "preis" => 8.23530,
73
		),
64
        ),
74
	"TS080501_1000_30_EUR" => array(
65
    "TS080501_1000_30_EUR" => array(
75
		"max" => 1000,
66
        "max" => 1000,
76
		"preis" => 16.47060,
67
        "preis" => 16.47060,
77
		),
68
        ),
78
	"TS080501_20000_30_EUR" => array(
69
    "TS080501_20000_30_EUR" => array(
Zeile 79... Zeile 70...
79
		"max" => 20000,
70
        "max" => 20000,
80
		"preis" => 31.94120,
71
        "preis" => 31.94120,
81
		),
72
        ),
82
	);
73
    );
83
 
74
 
84
$GLOBALS["tsMethods"] = array(
75
$GLOBALS["tsMethods"] = array(
85
	"paypal" => "PAYPAL",
76
    "paypal" => "PAYPAL",
86
	"PayPalPlus" => "PAYPAL",
77
    "PayPalPlus" => "PAYPAL",
87
	"billsafe" => "INVOICE",
78
    "billsafe" => "INVOICE",
88
	"nachnahme" => "CASH_ON_DELIVERY",
79
    "nachnahme" => "CASH_ON_DELIVERY",
89
	"kreditkarte" => "CREDIT_CARD",
80
    "kreditkarte" => "CREDIT_CARD",
Zeile 90... Zeile 81...
90
	"selbstabholung" => "CASH_ON_PICKUP",
81
    "selbstabholung" => "CASH_ON_PICKUP",
91
	"sofortueberweisung" => "DIECT_E_BANKING",
82
    "sofortueberweisung" => "DIECT_E_BANKING",
92
	"vorkasse" => "PREPAYMENT",
83
    "vorkasse" => "PREPAYMENT",
93
	);
84
    );
Zeile 94... Zeile 85...
94
//Excellence Käuferschutz - ENDE
85
//Excellence Käuferschutz - ENDE
95
 
86
 
96
/**
87
/**
97
 * @author Lars Tiefland
88
 * @author Lars Tiefland
98
 * @copyright 2016
89
 * @copyright 2016
99
 */
90
 */
100
 
91
 
101
function getVersandLaender()
-
 
102
{
92
function getVersandLaender()
103
	// ME: Länder raus, und die bit-Schiebeoperation ungestört durchzählen lasssen
93
{
104
	// LT: für Smarty umgebaut
-
 
105
	$forbiddenLands = array();
94
    // ME: Länder raus, und die bit-Schiebeoperation ungestört durchzählen lasssen
106
	if (table_exists("bestelladresse", $GLOBALS["INI"]["dbConnect"]["order_db"]) &&
95
    // LT: für Smarty umgebaut
107
		$GLOBALS["INI"]["modules"]["adresssystem"] == "neu")
96
    $forbiddenLands = array();
108
	{
97
    if (table_exists("bestelladresse", $GLOBALS["INI"]["dbConnect"]["order_db"]) &&
109
		$old = false;
98
        $GLOBALS["INI"]["modules"]["adresssystem"] == "neu") {
110
		if (table_exists("shippinggroups"))
-
 
111
		{
99
        $old = false;
112
			$cTable = "countries";
100
        if (table_exists("shippinggroups")) {
113
			$cField = "`name-ger";
101
            $cTable = "countries";
114
			$coTable = "cotinents";
102
            $cField = "`name-ger";
115
			$coField = "name_de";
103
            $coTable = "cotinents";
116
			if (table_exists("countries"))
104
            $coField = "name_de";
117
			{
105
            if (table_exists("countries")) {
118
				$cField = "country";
106
                $cField = "country";
119
				$cTable = $GLOBALS["INI"]["dbConnect"]["database"].".".$cTable;
107
                $cTable = $GLOBALS["INI"]["dbConnect"]["database"] . "." . $cTable;
120
				$coTable = "";
108
                $coTable = "";
121
				$coField = "continent";
109
                $coField = "continent";
122
			}
110
            }
123
			$sql = "SELECT
111
            $sql = "SELECT
124
                        c.id,
112
                        c.id,
125
                        c.shipping,
113
                        c.shipping,
126
                        ".$coField." AS continent,
114
                        " . $coField . " AS continent,
127
                        c.".$cField." AS country 
115
                        c." . $cField . " AS country 
128
                    FROM
116
                    FROM
129
                        ".$cTable." c
117
                        " . $cTable . " c
130
                    JOIN
-
 
131
                        ".$GLOBALS["INI"]["dbConnect"]["database"].
118
                    JOIN
132
				".shippinggroups sg
119
                        " . $GLOBALS["INI"]["dbConnect"]["database"] .
133
                    ON
120
                ".shippinggroups sg
134
                        sg.id = c.shipping
121
                    ON
135
                ";
122
                        sg.id = c.shipping
136
			if ($coTable)
123
                ";
137
			{
124
            if ($coTable) {
138
				$sql .= "
-
 
139
                        JOIN
125
                $sql .= "
140
                            ".$coTable."
-
 
141
                        ON
126
                        JOIN
142
                            co.id=c.continent
127
                            " . $coTable . "
143
                    ";
128
                        ON
144
			}
129
                            co.id=c.continent
145
		}
130
                    ";
146
		else
131
            }
147
		{
132
        } else {
148
			$old = true;
133
            $old = true;
149
			$sql = "SELECT
134
            $sql = "SELECT
150
					id,
135
					id,
151
					weban_lcode,
136
					weban_lcode,
152
					`name-ger` AS country
137
					`name-ger` AS country
153
				FROM
138
				FROM
154
					content_management.countries
-
 
155
				WHERE
139
					content_management.countries
156
					weban_lcode!=''
140
				WHERE
157
			";
-
 
158
		}
141
					weban_lcode!=''
159
		$res = $GLOBALS["db_red"]->query($sql);
-
 
160
		while ($row = $res->unbuffered_row('array'))
142
			";
161
		{
143
        }
162
			$land_name = $row["country"];
144
        $res = $GLOBALS["db_red"]->query($sql);
163
			if (!in_array($land_name, $forbiddenLands))
145
        while ($row = $res->unbuffered_row('array')) {
164
			{
-
 
165
				if ($old === true)
146
            $land_name = $row["country"];
166
				{
147
            if (!in_array($land_name, $forbiddenLands)) {
167
					$land = $row["weban_lcode"];
148
                if ($old === true) {
168
					$gewicht = 0;
149
                    $land = $row["weban_lcode"];
169
					$preis = 0;
150
                    $gewicht = 0;
170
					if (isset($_SESSION['SHOP']['SUMME']) && $_SESSION['SHOP']['SUMME'])
151
                    $preis = 0;
171
					{
152
                    if (isset($_SESSION['SHOP']['SUMME']) && $_SESSION['SHOP']['SUMME']) {
172
						$preis = $_SESSION['SHOP']['SUMME'];
153
                        $preis = $_SESSION['SHOP']['SUMME'];
173
					}
154
                    }
174
					// gibt es für dieses Land Versandoptionen?
155
                    // gibt es für dieses Land Versandoptionen?
175
					$sql = "SELECT 
156
                    $sql = "SELECT 
176
                                ID 
157
                                ID 
177
                            FROM
158
                            FROM
178
                                artikel 
159
                                artikel 
Zeile 179... Zeile 160...
179
                            WHERE 
160
                            WHERE 
180
                                Lieferstatus & ".$land." = ".$land." 
-
 
181
                            AND
161
                                Lieferstatus & " . $land . " = " . $land . " 
182
                                Father=-3 
162
                            AND
183
                            AND 
163
                                Father=-3 
184
                                status = ".$GLOBALS['INI']['shops_ID']."
164
                            AND 
185
                        ";
165
                                status = " . $GLOBALS['INI']['shops_ID'] . "
186
 
166
                        ";
187
					if (isset($_SESSION['SHOP']['BASKET']) && count($_SESSION["SHOP"]["BASKET"]))
167
 
188
					{
168
                    if (isset($_SESSION['SHOP']['BASKET']) && count($_SESSION["SHOP"]["BASKET"])) {
189
						$sql .= "
169
                        $sql .= "
190
                                AND
170
                                AND
191
                                (
171
                                (
192
                                    (".$gewicht.
172
                                    (" . $gewicht .
193
							" between preis_neu1 and preis_neu2)
173
                            " between preis_neu1 and preis_neu2)
194
                                )
174
                                )
195
                                AND
175
                                AND
196
                                (
176
                                (
197
                                    (".$preis.
-
 
198
							" BETWEEN preis_neu3 AND preis_neu4)
177
                                    (" . $preis .
199
                                    OR
-
 
200
                                    (preis_neu3=preis_neu4)
178
                            " BETWEEN preis_neu3 AND preis_neu4)
201
                                )                            
-
 
202
                            ";
179
                                    OR
203
					}
-
 
204
					if (isset($_SESSION['SHOP']['BASKET']) && count($_SESSION["SHOP"]["BASKET"]))
180
                                    (preis_neu3=preis_neu4)
205
					{
-
 
206
						foreach ($GLOBALS["Eigenschaften"] as $nr)
181
                                )                            
207
						{
182
                            ";
208
							if (Eigenschaft($nr) == true)
183
                    }
209
							{
184
                    if (isset($_SESSION['SHOP']['BASKET']) && count($_SESSION["SHOP"]["BASKET"])) {
210
								$sql .= " AND Eigenschaft_$nr = 1 ";
185
                        foreach ($GLOBALS["Eigenschaften"] as $nr) {
211
							}
186
                            if (Eigenschaft($nr) == true) {
212
							else
187
                                $sql .= " AND Eigenschaft_$nr = 1 ";
213
							{
188
                            } else {
214
								$sql .= "
189
                                $sql .= "
215
                                        AND
190
                                        AND
216
                                        (
191
                                        (
217
                                            (Eigenschaft_$nr = 0)
192
                                            (Eigenschaft_$nr = 0)
218
                                            OR
193
                                            OR
219
                                            (Eigenschaft_$nr IS NULL)
194
                                            (Eigenschaft_$nr IS NULL)
220
                                        )
195
                                        )
221
                                    ";
-
 
222
							}
196
                                    ";
223
						}
197
                            }
224
					}
-
 
225
 
198
                        }
226
 
199
                    }
227
					$q = $GLOBALS['ci']->db->query($sql);
-
 
228
					if ($q)
200
 
229
					{
201
 
230
						$n = $q->row_array();
202
                    $q = $GLOBALS['ci']->db->query($sql);
231
						if ($n)
203
                    if ($q) {
232
						{
204
                        $n = $q->row_array();
233
							if ($GLOBALS["INI"]["charset"] == "utf-8" && $GLOBALS["INI"]["dbConnect"]["db_is_utf8"] !=
-
 
234
								1)
205
                        if ($n) {
235
							{
-
 
236
								$land_name = utf8_encode($land_name);
206
                            if ($GLOBALS["INI"]["charset"] == "utf-8" && $GLOBALS["INI"]["dbConnect"]["db_is_utf8"] !=
237
							}
207
                                1) {
238
							$laender[$row["id"]] = $land_name;
208
                                $land_name = utf8_encode($land_name);
239
						}
209
                            }
240
					}
210
                            $laender[$row["id"]] = $land_name;
241
				}
211
                        }
242
				else
212
                    }
243
				{
213
                } else {
244
					$continent = $row["continent"];
214
                    $continent = $row["continent"];
245
					$sql = "SELECT 
215
                    $sql = "SELECT 
246
                                ID 
216
                                ID 
247
                            FROM
217
                            FROM
Zeile 248... Zeile 218...
248
                                artikel 
218
                                artikel 
249
                            WHERE 
-
 
250
                                kennung =  ".$row["shipping"]."
219
                            WHERE 
251
                            AND
220
                                kennung =  " . $row["shipping"] . "
252
                                Father=-3 
221
                            AND
253
                            AND 
222
                                Father=-3 
254
                                status = ".$GLOBALS['INI']['shops_ID']."
223
                            AND 
255
                        ";
224
                                status = " . $GLOBALS['INI']['shops_ID'] . "
256
 
225
                        ";
257
					if (count($_SESSION["SHOP"]["BASKET"]))
226
 
258
					{
227
                    if (count($_SESSION["SHOP"]["BASKET"])) {
259
						$sql .= "
228
                        $sql .= "
260
                                AND
229
                                AND
261
                                (
230
                                (
262
                                    (".$gewicht.
231
                                    (" . $gewicht .
263
							" between preis_neu1 and preis_neu2)
232
                            " between preis_neu1 and preis_neu2)
264
                                )
233
                                )
265
                                AND
234
                                AND
266
                                (
-
 
267
                                    (".$preis.
235
                                (
268
							" BETWEEN preis_neu3 AND preis_neu4)
-
 
269
                                    OR
236
                                    (" . $preis .
270
                                    (preis_neu3=preis_neu4)
-
 
271
                                )                            
237
                            " BETWEEN preis_neu3 AND preis_neu4)
272
                            ";
-
 
273
					}
238
                                    OR
274
					if (count($_SESSION["SHOP"]["BASKET"]))
-
 
275
					{
239
                                    (preis_neu3=preis_neu4)
276
						foreach ($GLOBALS["Eigenschaften"] as $nr)
240
                                )                            
277
						{
241
                            ";
278
							if (Eigenschaft($nr) == true)
242
                    }
279
							{
243
                    if (count($_SESSION["SHOP"]["BASKET"])) {
280
								$sql .= " AND Eigenschaft_$nr = 1 ";
244
                        foreach ($GLOBALS["Eigenschaften"] as $nr) {
281
							}
245
                            if (Eigenschaft($nr) == true) {
282
							else
246
                                $sql .= " AND Eigenschaft_$nr = 1 ";
283
							{
247
                            } else {
284
								$sql .= "
248
                                $sql .= "
285
                                        AND
249
                                        AND
286
                                        (
250
                                        (
287
                                            (Eigenschaft_$nr = 0)
251
                                            (Eigenschaft_$nr = 0)
288
                                            OR
252
                                            OR
289
                                            (Eigenschaft_$nr IS NULL)
253
                                            (Eigenschaft_$nr IS NULL)
290
                                        )
-
 
291
                                    ";
254
                                        )
292
							}
255
                                    ";
293
						}
-
 
294
					}
256
                            }
295
 
257
                        }
296
 
-
 
297
					$q = mysql_query($sql);
258
                    }
298
					if ($q)
259
 
299
					{
260
 
300
						$n = mysql_num_rows($q);
261
                    $q = mysql_query($sql);
301
						if ($n)
262
                    if ($q) {
302
						{
263
                        $n = mysql_num_rows($q);
303
							if ($GLOBALS["INI"]["charset"] == "utf-8" && $GLOBALS["INI"]["dbConnect"]["order_db_is_utf8"] !=
264
                        if ($n) {
304
								1)
265
                            if ($GLOBALS["INI"]["charset"] == "utf-8" && $GLOBALS["INI"]["dbConnect"]["order_db_is_utf8"] !=
305
							{
266
                                1) {
306
								$land_name = utf8_encode($land_name);
-
 
307
								$continent = utf8_encode($continent);
267
                                $land_name = utf8_encode($land_name);
308
							}
-
 
309
							$laender[$continent][$row["id"]] = $land_name;
268
                                $continent = utf8_encode($continent);
310
						}
-
 
311
					}
269
                            }
312
				}
270
                            $laender[$continent][$row["id"]] = $land_name;
313
			}
271
                        }
314
		}
272
                    }
315
	}
273
                }
316
	else
274
            }
317
	{
-
 
318
		for ($i = 0; $i < 64; $i++)
275
        }
319
		{
276
    } else {
320
 
-
 
321
			$land = 1 << $i;
277
        for ($i = 0; $i < 64; $i++) {
322
 
278
 
Zeile 323... Zeile 279...
323
			$land_name = getCountryById($land);
279
            $land = 1 << $i;
324
 
280
 
325
			if ($land_name)
281
            $land_name = getCountryById($land);
326
			{
282
 
327
 
283
            if ($land_name) {
328
				if (!in_array($land_name, $forbiddenLands))
284
 
329
				{
285
                if (!in_array($land_name, $forbiddenLands)) {
330
					$gewicht = getBasketGewicht();
286
                    $gewicht = getBasketGewicht();
331
					$preis = getBasketSumme();
287
                    $preis = getBasketSumme();
332
 
288
 
333
					// gibt es für dieses Land Versandoptionen?
289
                    // gibt es für dieses Land Versandoptionen?
334
					$sql = "SELECT 
290
                    $sql = "SELECT 
Zeile 335... Zeile 291...
335
                                ID 
291
                                ID 
336
                            FROM
-
 
337
                                artikel 
292
                            FROM
338
                            WHERE 
293
                                artikel 
339
                                Lieferstatus & ".$land." = ".$land." 
294
                            WHERE 
340
                            AND
295
                                Lieferstatus & " . $land . " = " . $land . " 
341
                                Father=-3 
296
                            AND
342
                            AND 
297
                                Father=-3 
343
                                status = ".$GLOBALS['INI']['shops_ID']."
298
                            AND 
344
                        ";
299
                                status = " . $GLOBALS['INI']['shops_ID'] . "
345
 
300
                        ";
346
					if (count($_SESSION["SHOP"]["BASKET"]))
301
 
347
					{
302
                    if (count($_SESSION["SHOP"]["BASKET"])) {
348
						$sql .= "
303
                        $sql .= "
349
                                AND
304
                                AND
350
                                (
305
                                (
351
                                    (".$gewicht.
306
                                    (" . $gewicht .
352
							" between preis_neu1 and preis_neu2)
307
                            " between preis_neu1 and preis_neu2)
353
                                )
-
 
354
                                AND
308
                                )
355
                                (
-
 
356
                                    (".$preis.
309
                                AND
357
							" BETWEEN preis_neu3 AND preis_neu4)
-
 
358
                                    OR
310
                                (
359
                                    (preis_neu3=preis_neu4)
-
 
360
                                )                            
311
                                    (" . $preis .
361
                            ";
-
 
362
					}
312
                            " BETWEEN preis_neu3 AND preis_neu4)
363
					if (count($_SESSION["SHOP"]["BASKET"]))
313
                                    OR
364
					{
314
                                    (preis_neu3=preis_neu4)
365
						foreach ($GLOBALS["Eigenschaften"] as $nr)
315
                                )                            
366
						{
316
                            ";
367
							if (Eigenschaft($nr) == true)
317
                    }
368
							{
318
                    if (count($_SESSION["SHOP"]["BASKET"])) {
369
								$sql .= " AND Eigenschaft_$nr = 1 ";
319
                        foreach ($GLOBALS["Eigenschaften"] as $nr) {
370
							}
320
                            if (Eigenschaft($nr) == true) {
371
							else
321
                                $sql .= " AND Eigenschaft_$nr = 1 ";
372
							{
322
                            } else {
373
								$sql .= "
323
                                $sql .= "
374
                                        AND
324
                                        AND
375
                                        (
325
                                        (
376
                                            (Eigenschaft_$nr = 0)
326
                                            (Eigenschaft_$nr = 0)
377
                                            OR
-
 
378
                                            (Eigenschaft_$nr IS NULL)
327
                                            OR
379
                                        )
328
                                            (Eigenschaft_$nr IS NULL)
380
                                    ";
-
 
381
							}
329
                                        )
382
						}
330
                                    ";
383
					}
331
                            }
384
 
332
                        }
385
 
333
                    }
386
					$q = mysql_query($sql);
-
 
387
					if ($q)
334
 
388
					{
335
 
389
						$n = mysql_num_rows($q);
336
                    $q = mysql_query($sql);
390
						if ($n)
337
                    if ($q) {
391
						{
338
                        $n = mysql_num_rows($q);
392
							$shopsNoEncode = array(
339
                        if ($n) {
393
								"ababum.de",
340
                            $shopsNoEncode = array(
394
								"etoh24.de",
341
                                "ababum.de",
395
								);
342
                                "etoh24.de",
396
							if ($GLOBALS["INI"]["charset"] == "utf-8" && !in_array(__SHOP__, $shopsNoEncode))
343
                                );
397
							{
-
 
398
								$land_name = utf8_encode($land_name);
344
                            if ($GLOBALS["INI"]["charset"] == "utf-8" && !in_array(__SHOP__, $shopsNoEncode)) {
399
							}
-
 
400
							$laender[$land] = ($land_name);
345
                                $land_name = utf8_encode($land_name);
401
						}
-
 
402
					}
346
                            }
403
				}
347
                            $laender[$land] = ($land_name);
Zeile 404... Zeile 348...
404
			}
348
                        }
405
		}
349
                    }
Zeile 406... Zeile 350...
406
	}
350
                }
407
	if (is_array($laender))
351
            }
408
	{
352
        }
409
		$laender = array_unique($laender);
353
    }
410
	}
-
 
411
	else
354
    if (is_array($laender)) {
412
	{
355
        $laender = array_unique($laender);
413
		$laender = array();
356
    } else {
414
	}
-
 
415
 
357
        $laender = array();
416
	return $laender;
-
 
417
}
358
    }
418
 
-
 
419
 
359
 
420
function table_exists($table, $db = null, $c = null)
360
    return $laender;
421
{
361
}
422
	$ini = $GLOBALS['INI'];
-
 
423
	if ($db)
362
 
424
	{
363
 
425
		$db = trim($db, '.');
-
 
426
	}
364
function table_exists($table, $db = null, $c = null)
427
	if (!$c)
-
 
428
	{
365
{
429
		$conn = $GLOBALS['order_db'];
-
 
430
	}
366
    $ini = $GLOBALS['INI'];
431
	else
367
    if ($db) {
432
	{
368
        $db = trim($db, '.');
433
		$conn = $c;
369
    }
434
	}
370
    if (!$c) {
435
	if (!$db || $db == $ini["dbConnect"]["database"])
371
        $conn = $GLOBALS['order_db'];
436
	{
372
    } else {
437
		$db = $ini["dbConnect"]["database"];
373
        $conn = $c;
438
		if (!$c)
374
    }
439
		{
375
    if (!$db || $db == $ini["dbConnect"]["database"]) {
440
			$conn = $GLOBALS['ci']->db;
376
        $db = $ini["dbConnect"]["database"];
441
		}
377
        if (!$c) {
442
		else
378
            $conn = $GLOBALS['ci']->db;
443
		{
379
        } else {
444
			$conn = $c;
-
 
445
		}
380
            $conn = $c;
446
	}
381
        }
447
	$sql = "SELECT
382
    }
448
            engine
383
    $sql = "SELECT
Zeile 449... Zeile 384...
449
        FROM
384
            engine
450
            information_schema.TABLES
385
        FROM
451
        WHERE
386
            information_schema.TABLES
452
            table_name='".$table."'
387
        WHERE
453
        AND
-
 
454
            table_schema='".$db."'
388
            table_name='" . $table . "'
455
    ";
389
        AND
456
	$res = $conn->query($sql);
390
            table_schema='" . $db . "'
457
	if ($res->num_rows())
-
 
458
	{
391
    ";
459
		return true;
-
 
460
	}
392
    $res = $conn->query($sql);
461
	return false;
-
 
462
}
393
    if ($res->num_rows()) {
463
 
394
        return true;
464
function column_exists($table, $column, $db = null, $c = null)
395
    }
465
{
-
 
466
	$ini = $GLOBALS['INI'];
396
    return false;
467
	if ($db)
397
}
468
	{
-
 
469
		$db = trim($db, '.');
398
 
470
	}
-
 
471
	if (!$c)
399
function column_exists($table, $column, $db = null, $c = null)
472
	{
-
 
473
		$conn = $GLOBALS['order_db'];
400
{
474
	}
401
    $ini = $GLOBALS['INI'];
475
	else
402
    if ($db) {
476
	{
403
        $db = trim($db, '.');
477
		$conn = $c;
404
    }
478
	}
405
    if (!$c) {
479
	if (!$db || $db == $ini["dbConnect"]["database"])
-
 
480
	{
406
        $conn = $GLOBALS['order_db'];
481
		$db = $ini["dbConnect"]["database"];
407
    } else {
482
		if (!$c)
408
        $conn = $c;
483
		{
409
    }
484
			$conn = $GLOBALS['ci']->db;
410
    if (!$db || $db == $ini["dbConnect"]["database"]) {
485
		}
411
        $db = $ini["dbConnect"]["database"];
486
		else
412
        if (!$c) {
487
		{
413
            $conn = $GLOBALS['ci']->db;
488
			$conn = $c;
414
        } else {
489
		}
415
            $conn = $c;
490
	}
416
        }
Zeile 491... Zeile 417...
491
 
417
    }
492
	$t_exists = table_exists($table, $db, $conn);
418
 
493
	if ($t_exists)
-
 
494
	{
419
    $t_exists = table_exists($table, $db, $conn);
495
		$sql = "SELECT
420
    if ($t_exists) {
496
                    data_type
421
        $sql = "SELECT
497
                FROM
422
                    data_type
498
                    information_schema.COLUMNS
423
                FROM
499
                WHERE
424
                    information_schema.COLUMNS
Zeile 500... Zeile 425...
500
                    column_name='".$column."'
425
                WHERE
501
                AND
426
                    column_name='" . $column . "'
502
                    table_name='".$table."'
427
                AND
Zeile 525... Zeile 450...
525
 * @param mixed $c
450
 * @param mixed $c
526
 * @return
451
 * @return
527
 */
452
 */
528
function getColumnInfo($table, $column, $db = null, $c = null)
453
function getColumnInfo($table, $column, $db = null, $c = null)
529
{
454
{
530
	global $remoteServer_dbh, $localhost_dbh;
455
    global $remoteServer_dbh, $localhost_dbh;
531
	if (!is_array($_SESSION["INI"]))
456
    if (!is_array($_SESSION["INI"])) {
532
	{
-
 
533
		$ini = $GLOBALS["INI"];
457
        $ini = $GLOBALS["INI"];
534
	}
-
 
535
	else
458
    } else {
536
	{
-
 
537
		$ini = $_SESSION["INI"];
459
        $ini = $_SESSION["INI"];
538
	}
460
    }
539
	if ($db)
461
    if ($db) {
540
	{
-
 
541
		$db = trim($db, '.');
462
        $db = trim($db, '.');
542
	}
463
    }
543
	if (!$c)
464
    if (!$c) {
544
	{
-
 
545
		if (__USE_MDB2__ === true)
465
        if (__USE_MDB2__ === true) {
546
		{
-
 
547
			$conn = $GLOBALS["order_db"];
466
            $conn = $GLOBALS["order_db"];
548
		}
-
 
549
		elseif (is_resource($GLOBALS["order_dbh"]))
467
        } elseif (is_resource($GLOBALS["order_dbh"])) {
550
		{
-
 
551
			$conn = $GLOBALS["order_dbh"];
468
            $conn = $GLOBALS["order_dbh"];
552
		}
-
 
553
		elseif (is_resource($remoteServer_dbh))
469
        } elseif (is_resource($remoteServer_dbh)) {
554
		{
-
 
555
			$conn = $remoteServer_dbh;
470
            $conn = $remoteServer_dbh;
556
		}
471
        }
557
	}
-
 
558
	else
472
    } else {
559
	{
-
 
560
		$conn = $c;
473
        $conn = $c;
561
	}
474
    }
562
	if (!$db || $db == $ini["dbConnect"]["database"])
475
    if (!$db || $db == $ini["dbConnect"]["database"]) {
563
	{
-
 
564
		$db = $ini["dbConnect"]["database"];
476
        $db = $ini["dbConnect"]["database"];
565
		if (!$c)
477
        if (!$c) {
566
		{
-
 
567
			if (__USE_MDB2__ === true)
478
            if (__USE_MDB2__ === true) {
568
			{
-
 
569
				$conn = $GLOBALS["db"];
479
                $conn = $GLOBALS["db"];
570
			}
-
 
571
			elseif (is_resource($GLOBALS["dbh"]))
480
            } elseif (is_resource($GLOBALS["dbh"])) {
572
			{
-
 
573
				$conn = $GLOBALS["dbh"];
481
                $conn = $GLOBALS["dbh"];
574
			}
-
 
575
			elseif (is_resource($localhost_dbh))
482
            } elseif (is_resource($localhost_dbh)) {
576
			{
-
 
577
				$conn = $localhost_dbh;
483
                $conn = $localhost_dbh;
578
			}
484
            }
579
		}
-
 
580
		else
485
        } else {
581
		{
-
 
582
			$conn = $c;
486
            $conn = $c;
583
		}
487
        }
584
	}
488
    }
585
 
489
 
586
 
490
 
587
	if (column_exists($table, $column, $db, $conn))
491
    if (column_exists($table, $column, $db, $conn)) {
588
	{
-
 
589
		//Hole Informationen zur Spalte
492
        //Hole Informationen zur Spalte
590
		$sql = "SELECT
493
        $sql = "SELECT
591
                    *
494
                    *
592
                FROM
495
                FROM
593
                    information_schema.COLUMNS
496
                    information_schema.COLUMNS
594
                WHERE
497
                WHERE
595
                    column_name='".$column."'
498
                    column_name='" . $column . "'
596
                AND
499
                AND
597
                    table_name='".$table."'
500
                    table_name='" . $table . "'
598
                AND
501
                AND
599
                    table_schema='".$db."'
502
                    table_schema='" . $db . "'
600
            ";
503
            ";
Zeile 601... Zeile 504...
601
 
504
 
602
		if (__USE_MDB2__ === true)
-
 
603
		{
505
        if (__USE_MDB2__ === true) {
604
			$res = $conn->query($sql);
506
            $res = $conn->query($sql);
605
			if ($res->numRows())
-
 
606
			{
507
            if ($res->numRows()) {
607
				$row = $res->fetchRow();
508
                $row = $res->fetchRow();
608
			}
-
 
609
		}
509
            }
610
		else
-
 
611
		{
510
        } else {
612
			$res = mysql_query($sql, $conn);
511
            $res = mysql_query($sql, $conn);
613
			if (mysql_num_rows($res))
-
 
614
			{
512
            if (mysql_num_rows($res)) {
615
				$row = mysql_fetch_assoc($res);
513
                $row = mysql_fetch_assoc($res);
616
			}
514
            }
617
		}
515
        }
618
		$t = getTableInfo($table, $db, $conn);
516
        $t = getTableInfo($table, $db, $conn);
619
		$row["engine"] = $t["ENGINE"];
517
        $row["engine"] = $t["ENGINE"];
620
		if ($row["engine"] == "InnoDB")
-
 
621
		{
518
        if ($row["engine"] == "InnoDB") {
622
			//Hole Informationen zu einem definierten Fremdschl?ssel
519
            //Hole Informationen zu einem definierten Fremdschl?ssel
623
			$sql = "SELECT
520
            $sql = "SELECT
624
                        REFERENCED_TABLE_SCHEMA,
521
                        REFERENCED_TABLE_SCHEMA,
625
                        REFERENCED_TABLE_NAME,
522
                        REFERENCED_TABLE_NAME,
626
                        REFERENCED_COLUMN_NAME,
523
                        REFERENCED_COLUMN_NAME,
627
                        CONSTRAINT_NAME
524
                        CONSTRAINT_NAME
628
                    FROM
525
                    FROM
629
                        information_schema.KEY_COLUMN_USAGE
526
                        information_schema.KEY_COLUMN_USAGE
630
                    WHERE
527
                    WHERE
631
                        column_name='".$column."'
528
                        column_name='" . $column . "'
632
                    AND
529
                    AND
633
                        table_name='".$table."'
530
                        table_name='" . $table . "'
634
                    AND
531
                    AND
635
                        table_schema='".$db."'
532
                        table_schema='" . $db . "'
636
                ";
533
                ";
637
			if (__USE_MDB2__ === true)
-
 
638
			{
534
            if (__USE_MDB2__ === true) {
639
				$res = $conn->query($sql);
535
                $res = $conn->query($sql);
640
				if ($res->numRows())
-
 
641
				{
536
                if ($res->numRows()) {
642
					$row_k = $res->fetchRow();
537
                    $row_k = $res->fetchRow();
643
				}
-
 
644
			}
538
                }
645
			else
-
 
646
			{
539
            } else {
647
				$res = mysql_query($sql, $conn);
540
                $res = mysql_query($sql, $conn);
648
				if (mysql_num_rows($res))
-
 
649
				{
541
                if (mysql_num_rows($res)) {
650
					$row_k = mysql_fetch_assoc($res);
542
                    $row_k = mysql_fetch_assoc($res);
651
				}
543
                }
652
			}
544
            }
653
			if (is_array($row_k))
-
 
654
			{
545
            if (is_array($row_k)) {
655
				$row = array_merge($row, $row_k);
546
                $row = array_merge($row, $row_k);
656
			}
547
            }
657
		}
548
        }
658
	}
549
    }
Zeile 659... Zeile 550...
659
	return $row;
550
    return $row;
Zeile 660... Zeile 551...
660
 
551
 
661
}
552
}
Zeile 670... Zeile 561...
670
 * @param mixed $c
561
 * @param mixed $c
671
 * @return
562
 * @return
672
 */
563
 */
673
function getTableInfo($table, $db = null, $c = null)
564
function getTableInfo($table, $db = null, $c = null)
674
{
565
{
675
	global $remoteServer_dbh, $localhost_dbh;
566
    global $remoteServer_dbh, $localhost_dbh;
676
	if (!is_array($_SESSION["INI"]))
567
    if (!is_array($_SESSION["INI"])) {
677
	{
-
 
678
		$ini = $GLOBALS["INI"];
568
        $ini = $GLOBALS["INI"];
679
	}
-
 
680
	else
569
    } else {
681
	{
-
 
682
		$ini = $_SESSION["INI"];
570
        $ini = $_SESSION["INI"];
683
	}
571
    }
684
	if ($db)
572
    if ($db) {
685
	{
-
 
686
		$db = trim($db, '.');
573
        $db = trim($db, '.');
687
	}
574
    }
688
	if (!$c)
575
    if (!$c) {
689
	{
-
 
690
		if (__USE_MDB2__ === true)
576
        if (__USE_MDB2__ === true) {
691
		{
-
 
692
			$conn = $GLOBALS["order_db"];
577
            $conn = $GLOBALS["order_db"];
693
		}
-
 
694
		elseif (is_resource($GLOBALS["order_dbh"]))
578
        } elseif (is_resource($GLOBALS["order_dbh"])) {
695
		{
-
 
696
			$conn = $GLOBALS["order_dbh"];
579
            $conn = $GLOBALS["order_dbh"];
697
		}
-
 
698
		elseif (is_resource($remoteServer_dbh))
580
        } elseif (is_resource($remoteServer_dbh)) {
699
		{
-
 
700
			$conn = $remoteServer_dbh;
581
            $conn = $remoteServer_dbh;
701
		}
582
        }
702
	}
-
 
703
	else
583
    } else {
704
	{
-
 
705
		$conn = $c;
584
        $conn = $c;
706
	}
585
    }
707
	if (!$db || $db == $ini["dbConnect"]["database"])
586
    if (!$db || $db == $ini["dbConnect"]["database"]) {
708
	{
-
 
709
		$db = $ini["dbConnect"]["database"];
587
        $db = $ini["dbConnect"]["database"];
710
		if (!$c)
588
        if (!$c) {
711
		{
-
 
712
			if (__USE_MDB2__ === true)
589
            if (__USE_MDB2__ === true) {
713
			{
-
 
714
				$conn = $GLOBALS["db"];
590
                $conn = $GLOBALS["db"];
715
			}
-
 
716
			elseif (is_resource($GLOBALS["dbh"]))
591
            } elseif (is_resource($GLOBALS["dbh"])) {
717
			{
-
 
718
				$conn = $GLOBALS["dbh"];
592
                $conn = $GLOBALS["dbh"];
719
			}
-
 
720
			elseif (is_resource($localhost_dbh))
593
            } elseif (is_resource($localhost_dbh)) {
721
			{
-
 
722
				$conn = $localhost_dbh;
594
                $conn = $localhost_dbh;
723
			}
595
            }
724
		}
-
 
725
		else
596
        } else {
726
		{
-
 
727
			$conn = $c;
597
            $conn = $c;
728
		}
598
        }
729
	}
599
    }
730
 
600
 
731
	if (table_exists($table, $db, $conn))
601
    if (table_exists($table, $db, $conn)) {
732
	{
-
 
733
		//Hole Informationen zur Tabelle
602
        //Hole Informationen zur Tabelle
734
		$sql = "SELECT
603
        $sql = "SELECT
735
                    *
604
                    *
736
                FROM
605
                FROM
737
                    information_schema.TABLES
606
                    information_schema.TABLES
738
                WHERE
607
                WHERE
739
                    table_name='".$table."'
608
                    table_name='" . $table . "'
740
                AND
609
                AND
741
                    table_schema='".$db."'
610
                    table_schema='" . $db . "'
742
            ";
611
            ";
Zeile 743... Zeile 612...
743
 
612
 
744
		if (__USE_MDB2__ === true)
-
 
745
		{
613
        if (__USE_MDB2__ === true) {
746
			$res = $conn->query($sql);
614
            $res = $conn->query($sql);
747
			if ($res->numRows())
-
 
748
			{
615
            if ($res->numRows()) {
749
				$row = $res->fetchRow();
616
                $row = $res->fetchRow();
750
			}
-
 
751
		}
617
            }
752
		else
-
 
753
		{
618
        } else {
754
			$res = mysql_query($sql, $conn);
619
            $res = mysql_query($sql, $conn);
755
			if (mysql_num_rows($res))
-
 
756
			{
620
            if (mysql_num_rows($res)) {
757
				$row = mysql_fetch_assoc($res);
621
                $row = mysql_fetch_assoc($res);
758
			}
622
            }
759
		}
623
        }
760
	}
624
    }
761
	return $row;
625
    return $row;
Zeile 762... Zeile 626...
762
}
626
}
763
 
627
 
764
/**
628
/**
Zeile 784... Zeile 648...
784
 * @param array $config
648
 * @param array $config
785
 * @return void
649
 * @return void
786
 */
650
 */
787
function createDBField($name, $table, $conn, $config)
651
function createDBField($name, $table, $conn, $config)
788
{
652
{
789
	$typ = $config["type"];
653
    $typ = $config["type"];
790
	if ($config["length"])
654
    if ($config["length"]) {
791
	{
-
 
792
		$typ .= "(".$config["length"].")";
655
        $typ .= "(" . $config["length"] . ")";
793
	}
656
    }
794
	if ($config["extra"])
657
    if ($config["extra"]) {
795
	{
-
 
796
		$typ .= " ".$config["extra"];
658
        $typ .= " " . $config["extra"];
797
	}
659
    }
798
	if ($config["nullable"] == 1)
660
    if ($config["nullable"] == 1) {
799
	{
-
 
800
		$typ .= " NULL DEFAULT NULL";
661
        $typ .= " NULL DEFAULT NULL";
801
	}
-
 
802
	else
662
    } else {
803
	{
-
 
804
		$default = '';
663
        $default = '';
805
		if ($config["default"])
664
        if ($config["default"]) {
806
		{
-
 
807
			$default = $config["default"];
665
            $default = $config["default"];
808
		}
666
        }
809
		$typ .= " NOT NULL DEFAULT '".$default."'";
667
        $typ .= " NOT NULL DEFAULT '" . $default . "'";
810
	}
668
    }
811
	if ($config["after"])
669
    if ($config["after"]) {
812
	{
-
 
813
		$typ .= " AFTER ".$config["after"];
670
        $typ .= " AFTER " . $config["after"];
814
	}
671
    }
815
	if ($config["index"])
672
    if ($config["index"]) {
816
	{
-
 
817
		$typ .= ", ADD ".$config["index"]."(".$name.")";
673
        $typ .= ", ADD " . $config["index"] . "(" . $name . ")";
818
	}
674
    }
819
	$sql = "
675
    $sql = "
820
            ALTER TABLE
676
            ALTER TABLE
821
                ".$table."
677
                " . $table . "
822
            ADD
678
            ADD
823
                ".$name." ".$typ."
679
                " . $name . " " . $typ . "
824
        ";
680
        ";
825
	$conn->exec($sql);
681
    $conn->exec($sql);
826
}
682
}
827
function Eigenschaft($NR)
683
function Eigenschaft($NR)
828
{
684
{
829
	if (is_array($_SESSION['SHOP']['BASKET']) && count($_SESSION['SHOP']['BASKET']) >
685
    if (is_array($_SESSION['SHOP']['BASKET']) && count($_SESSION['SHOP']['BASKET']) >
830
		0)
686
        0) {
831
	{
-
 
832
		foreach ($_SESSION['SHOP']['BASKET'] as $v)
687
        foreach ($_SESSION['SHOP']['BASKET'] as $v) {
833
		{
-
 
834
			$test = explode("_", $v["ID"]);
688
            $test = explode("_", $v["ID"]);
835
			if (count($test) == 1)
689
            if (count($test) == 1) {
836
			{
-
 
837
				$idArray[] = $v["ID"];
690
                $idArray[] = $v["ID"];
838
			}
691
            }
839
		}
692
        }
840
		$query = "
693
        $query = "
841
                SELECT distinct
694
                SELECT distinct
842
                    Eigenschaft_$NR
695
                    Eigenschaft_$NR
843
                FROM
696
                FROM
844
                    artikel
697
                    artikel
845
                WHERE
698
                WHERE
846
                    (ID =".implode(" or ID =", $idArray).")
699
                    (ID =" . implode(" or ID =", $idArray) . ")
847
                AND
700
                AND
848
                    Language = '".$GLOBALS["INI"]['language']."'
701
                    Language = '" . $GLOBALS["INI"]['language'] . "'
849
                AND
702
                AND
850
                    Eigenschaft_$NR=1
703
                    Eigenschaft_$NR=1
851
            ";
704
            ";
Zeile 852... Zeile 705...
852
 
705
 
853
		$result = $GLOBALS['ci']->db->query($query);
706
        $result = $GLOBALS['ci']->db->query($query);
854
		if ($result->num_rows() > 0)
-
 
855
		{
707
        if ($result->num_rows() > 0) {
856
			return true;
-
 
857
		}
708
            return true;
858
		else
-
 
859
		{
709
        } else {
860
			return false;
710
            return false;
861
		}
-
 
862
	}
711
        }
863
	else
-
 
864
	{
712
    } else {
865
		return false;
713
        return false;
866
	}
714
    }
Zeile 867... Zeile 715...
867
}
715
}
868
 
716
 
869
/**
717
/**
Zeile 878... Zeile 726...
878
 * @return array
726
 * @return array
879
 */
727
 */
880
function getVersandEigenschaften($domain = __SITE__)
728
function getVersandEigenschaften($domain = __SITE__)
881
{
729
{
Zeile 882... Zeile 730...
882
 
730
 
883
	$sql = "SELECT
731
    $sql = "SELECT
884
                id
732
                id
885
            FROM
733
            FROM
886
                properties
734
                properties
887
            WHERE
735
            WHERE
888
                interner_Name LIKE 'Eigenschaft%'
736
                interner_Name LIKE 'Eigenschaft%'
889
            AND
737
            AND
890
                tools=1
738
                tools=1
Zeile 891... Zeile 739...
891
        ";
739
        ";
892
 
740
 
893
	$res = $GLOBALS["db_red"]->query($sql);
741
    $res = $GLOBALS["db_red"]->query($sql);
894
	$rows = $res->result_array();
-
 
895
	foreach ($rows as $row)
742
    $rows = $res->result_array();
896
	{
743
    foreach ($rows as $row) {
897
		$sql2 = "SELECT
744
        $sql2 = "SELECT
898
                    wp.*,
745
                    wp.*,
899
                    p.interner_name
746
                    p.interner_name
900
                FROM
747
                FROM
Zeile 906... Zeile 753...
906
                JOIN
753
                JOIN
907
                    properties AS p
754
                    properties AS p
908
                ON
755
                ON
909
                    p.id=wp.properties
756
                    p.id=wp.properties
910
                WHERE
757
                WHERE
911
                    domain='".$domain."'
758
                    domain='" . $domain . "'
912
                AND
759
                AND
913
                    properties=".$row["id"]."
760
                    properties=" . $row["id"] . "
914
                AND
761
                AND
915
                    wp.Bezeichnung LIKE '%;logistik';
762
                    wp.Bezeichnung LIKE '%;logistik';
916
            ";
763
            ";
917
		$res2 = $GLOBALS["db_red"]->query($sql2);
764
        $res2 = $GLOBALS["db_red"]->query($sql2);
918
		$row2 = $res2->row_array();
765
        $row2 = $res2->row_array();
919
		if (is_array($row2))
766
        if (is_array($row2)) {
920
		{
-
 
921
			list($name, $nr) = explode("_", $row2["interner_name"]);
767
            list($name, $nr) = explode("_", $row2["interner_name"]);
922
			$eigenschaften[] = $nr;
768
            $eigenschaften[] = $nr;
923
		}
769
        }
924
	}
770
    }
925
	return $eigenschaften;
771
    return $eigenschaften;
926
}
772
}
Zeile 927... Zeile 773...
927
 
773
 
928
function getWebRechte($site = __SITE__)
774
function getWebRechte($site = __SITE__)
929
{
775
{
930
	$web_rechte = array();
776
    $web_rechte = array();
931
	$query = "SELECT
777
    $query = "SELECT
932
                m.interner_name m_name,
778
                m.interner_name m_name,
933
                t.button_name t_name,
779
                t.button_name t_name,
934
                p.interner_name p_name,
780
                p.interner_name p_name,
935
                wp.Bezeichnung wp_name
781
                wp.Bezeichnung wp_name
Zeile 950... Zeile 796...
950
            AND
796
            AND
951
                t.modules = m.ID
797
                t.modules = m.ID
952
            ORDER BY
798
            ORDER BY
953
                p.Rang
799
                p.Rang
954
        ";
800
        ";
955
	$res = $GLOBALS["db_red"]->query($query);
801
    $res = $GLOBALS["db_red"]->query($query);
956
	while ($zeile = $res->unbuffered_row('array'))
802
    while ($zeile = $res->unbuffered_row('array')) {
957
	{
-
 
958
		if (!$zeile["wp_name"])
803
        if (!$zeile["wp_name"]) {
959
		{
-
 
960
			$zeile["wp_name"] = "";
804
            $zeile["wp_name"] = "";
961
		}
805
        }
962
		$zeile["wp_name"] = explode("|", $zeile["wp_name"]);
806
        $zeile["wp_name"] = explode("|", $zeile["wp_name"]);
963
 
807
 
964
		if (count($zeile["wp_name"]) == 1)
808
        if (count($zeile["wp_name"]) == 1) {
965
		{
-
 
966
			$zeile["wp_name"] = $zeile["wp_name"][0];
809
            $zeile["wp_name"] = $zeile["wp_name"][0];
967
		}
810
        }
968
 
811
 
969
		$web_rechte[$zeile["m_name"]][$zeile["t_name"]][$zeile["p_name"]] = $zeile["wp_name"];
812
        $web_rechte[$zeile["m_name"]][$zeile["t_name"]][$zeile["p_name"]] = $zeile["wp_name"];
970
	}
813
    }
971
 
814
 
972
	foreach (array_keys($web_rechte) as $a)
815
    foreach (array_keys($web_rechte) as $a) {
973
	{
-
 
974
		foreach (array_keys($web_rechte[$a]) as $b)
816
        foreach (array_keys($web_rechte[$a]) as $b) {
975
		{
-
 
976
			foreach (array_keys($web_rechte[$a][$b]) as $c)
817
            foreach (array_keys($web_rechte[$a][$b]) as $c) {
977
			{
-
 
978
				if (is_array($web_rechte[$a][$b][$c]))
818
                if (is_array($web_rechte[$a][$b][$c])) {
979
				{
-
 
980
					$web_rechte[$a][$b][$c] = $web_rechte[$a][$b][$c][array_search($GLOBALS["INI"]["language"],
819
                    $web_rechte[$a][$b][$c] = $web_rechte[$a][$b][$c][array_search($GLOBALS["INI"]["language"],
981
						array_keys($web_rechte["online_shop"]["language"]))];
820
                        array_keys($web_rechte["online_shop"]["language"]))];
982
					if ($web_rechte[$a][$b][$c] == "./.")
821
                    if ($web_rechte[$a][$b][$c] == "./.") {
983
					{
-
 
984
						unset($web_rechte[$a][$b][$c]);
822
                        unset($web_rechte[$a][$b][$c]);
985
					}
823
                    }
986
				}
824
                }
987
			}
825
            }
988
		}
826
        }
989
	}
827
    }
990
	unset($query);
828
    unset($query);
991
	unset($result);
829
    unset($result);
992
	unset($zeile);
830
    unset($zeile);
993
	return $web_rechte;
831
    return $web_rechte;
994
}
832
}
Zeile 995... Zeile 833...
995
 
833
 
996
function getZahlarten()
834
function getZahlarten()
997
{
835
{
998
	$zahlarten[] = "- Bezahlarten -";
836
    $zahlarten[] = "- Bezahlarten -";
999
	$sql = "
837
    $sql = "
1000
		SELECT
838
		SELECT
1001
			z.*
839
			z.*
1002
		FROM
840
		FROM
1003
			zahlungsarten z
841
			zahlungsarten z
Zeile 1006... Zeile 844...
1006
		ON
844
		ON
1007
			a.short_line_1=z.interner_name
845
			a.short_line_1=z.interner_name
1008
		ORDER BY
846
		ORDER BY
1009
			name
847
			name
1010
	";
848
	";
1011
	$res = $GLOBALS['ci']->db->query($sql);
849
    $res = $GLOBALS['ci']->db->query($sql);
1012
	while ($row = $res->unbuffered_row('array'))
850
    while ($row = $res->unbuffered_row('array')) {
1013
	{
-
 
1014
		$ini_name = $row["interner_name"];
851
        $ini_name = $row["interner_name"];
1015
		if ($row["interner_name"] == "sofortueberweisung")
852
        if ($row["interner_name"] == "sofortueberweisung") {
1016
		{
-
 
1017
			$ini_name = "ueberweisung";
853
            $ini_name = "ueberweisung";
1018
		}
854
        }
1019
		if (isset($GLOBALS['INI'][$ini_name]) && $GLOBALS["INI"][$ini_name]["aktiv"] ==
855
        if (isset($GLOBALS['INI'][$ini_name]) && $GLOBALS["INI"][$ini_name]["aktiv"] ==
1020
			1 && ((isset($_SESSION['zahlarten'][$ini_name]) && $_SESSION["zahlarten"][$ini_name]
856
            1 && ((isset($_SESSION['zahlarten'][$ini_name]) && $_SESSION["zahlarten"][$ini_name]
1021
			!== false) || !isset($_SESSION['zahlarten'][$ini_name])) || !in_array($row["interner_name"],
857
            !== false) || !isset($_SESSION['zahlarten'][$ini_name])) || !in_array($row["interner_name"],
1022
			$GLOBALS["zahlsysteme"]))
858
            $GLOBALS["zahlsysteme"])) {
1023
		{
-
 
1024
			$zahlarten[$row['interner_name']] = $row['name'];
859
            $zahlarten[$row['interner_name']] = $row['name'];
1025
		}
860
        }
1026
	}
861
    }
1027
	return $zahlarten;
862
    return $zahlarten;
1028
}
863
}
Zeile 1029... Zeile 864...
1029
 
864
 
1030
function getWebanLCode($land)
865
function getWebanLCode($land)
1031
{
866
{
1032
	$sql = "SELECT
867
    $sql = "SELECT
1033
                weban_lcode
868
                weban_lcode
1034
            FROM
869
            FROM
1035
                countries
870
                countries
1036
            WHERE
871
            WHERE
1037
                `name-ger` = '".$land."'
872
                `name-ger` = '" . $land . "'
1038
            OR
873
            OR
1039
                `name-en` = '".$land."'
874
                `name-en` = '" . $land . "'
1040
            OR
875
            OR
1041
                `iso-2` = '".$land."'
876
                `iso-2` = '" . $land . "'
1042
            OR
877
            OR
1043
                `iso-3` = '".$land."'
878
                `iso-3` = '" . $land . "'
1044
            OR
879
            OR
1045
                `id` = '".$land."'
880
                `id` = '" . $land . "'
1046
        ";
881
        ";
1047
	$res = $GLOBALS["db_red"]->query($sql);
882
    $res = $GLOBALS["db_red"]->query($sql);
1048
	$row = $res->row_array();
883
    $row = $res->row_array();
1049
	$id = $row['weban_lcode'];
884
    $id = $row['weban_lcode'];
1050
	return $id;
885
    return $id;
Zeile 1051... Zeile 886...
1051
}
886
}
1052
 
887
 
1053
function get_versandkosten($land = null, $mode = '')
888
function get_versandkosten($land = null, $mode = '')
1054
{
-
 
1055
	if (is_null($land))
889
{
1056
	{
890
    if (is_null($land)) {
1057
		$land = 47;
891
        $land = 47;
1058
	}
892
    }
1059
	$lCode = getWebanLCode($land);
893
    $lCode = getWebanLCode($land);
1060
	$gewicht = get_gewicht();
894
    $gewicht = get_gewicht();
1061
	$preis = $_SESSION['SHOP']['SUMME'];
895
    $preis = $_SESSION['SHOP']['SUMME'];
1062
	$shopID = $GLOBALS["INI"]['shops_ID'];
896
    $shopID = $GLOBALS["INI"]['shops_ID'];
1063
	if (isset($_SESSION["KundengruppeShopID"]) && $_SESSION["KundengruppeShopID"] !=
-
 
1064
		"")
897
    if (isset($_SESSION["KundengruppeShopID"]) && $_SESSION["KundengruppeShopID"] !=
1065
	{
898
        "") {
1066
		$shopID = $_SESSION["KundengruppeShopID"];
899
        $shopID = $_SESSION["KundengruppeShopID"];
1067
	}
900
    }
1068
	$sql_Z_extra = "";
901
    $sql_Z_extra = "";
1069
	if (column_exists("zahlungsarten", "express", $GLOBALS["INI"]["dbConnect"]["database"],
-
 
1070
		$GLOBALS['ci']->db))
902
    if (column_exists("zahlungsarten", "express", $GLOBALS["INI"]["dbConnect"]["database"],
1071
	{
903
        $GLOBALS['ci']->db)) {
Zeile 1072... Zeile 904...
1072
		$sql_Z_extra = "express,";
904
        $sql_Z_extra = "express,";
1073
	}
905
    }
1074
 
906
 
1075
	$sql = "
907
    $sql = "
1076
		SELECT
908
		SELECT
1077
			a.ID,
909
			a.ID,
Zeile 1091... Zeile 923...
1091
			Eigenschaft_1,
923
			Eigenschaft_1,
1092
			Eigenschaft_2,
924
			Eigenschaft_2,
1093
			Eigenschaft_3,
925
			Eigenschaft_3,
1094
			Eigenschaft_4,
926
			Eigenschaft_4,
1095
			Eigenschaft_5,
927
			Eigenschaft_5,
1096
			".$sql_Z_extra."
928
			" . $sql_Z_extra . "
1097
			z.name AS z_name
929
			z.name AS z_name
1098
		FROM
930
		FROM
1099
			artikel a
931
			artikel a
1100
		JOIN
932
		JOIN
1101
			zahlungsarten z
933
			zahlungsarten z
1102
		ON
934
		ON
1103
			z.interner_name=a.short_line_1
935
			z.interner_name=a.short_line_1
1104
		WHERE
936
		WHERE
1105
			father=-3
937
			father=-3
1106
		AND
938
		AND
1107
			language='".$GLOBALS['INI']['language']."'
939
			language='" . $GLOBALS['INI']['language'] . "'
1108
		AND
940
		AND
1109
			lieferstatus & ".$lCode."=".$lCode."
941
			lieferstatus & " . $lCode . "=" . $lCode . "
1110
		AND
942
		AND
1111
		(
943
		(
1112
			(".$gewicht." between preis_neu1 and preis_neu2)
944
			(" . $gewicht . " between preis_neu1 and preis_neu2)
1113
		)
945
		)
1114
		AND
946
		AND
1115
		(
947
		(
1116
			(".$preis." BETWEEN preis_neu3 AND preis_neu4)
948
			(" . $preis . " BETWEEN preis_neu3 AND preis_neu4)
1117
			OR
949
			OR
1118
			(preis_neu3=preis_neu4)
950
			(preis_neu3=preis_neu4)
1119
		)
951
		)
1120
	";
952
	";
1121
	if ($mode != 'Versanduebersicht')
953
    if ($mode != 'Versanduebersicht') {
1122
	{
-
 
1123
		foreach ($GLOBALS["Eigenschaften"] as $nr)
954
        foreach ($GLOBALS["Eigenschaften"] as $nr) {
1124
		{
-
 
1125
			if (Eigenschaft($nr) == true)
955
            if (Eigenschaft($nr) == true) {
1126
			{
-
 
1127
				$sql .= "
956
                $sql .= "
1128
					AND
957
					AND
1129
						Eigenschaft_$nr = 1
958
						Eigenschaft_$nr = 1
1130
				";
959
				";
1131
			}
-
 
1132
			else
960
            } else {
1133
			{
-
 
1134
				$sql .= "
961
                $sql .= "
1135
					AND
962
					AND
1136
					(
963
					(
1137
						(Eigenschaft_$nr = 0)
964
						(Eigenschaft_$nr = 0)
1138
						OR
965
						OR
1139
						(Eigenschaft_$nr IS NULL)
966
						(Eigenschaft_$nr IS NULL)
1140
					)
967
					)
1141
				";
968
				";
1142
			}
969
            }
1143
		}
970
        }
1144
	}
971
    }
1145
	$sql .= "
972
    $sql .= "
1146
		ORDER BY
973
		ORDER BY
1147
			short_line_1,
974
			short_line_1,
1148
			rang
975
			rang
1149
	";
976
	";
1150
	$res = $GLOBALS['ci']->db->query($sql);
977
    $res = $GLOBALS['ci']->db->query($sql);
1151
	$items = $res->result_array();
978
    $items = $res->result_array();
1152
	return $items;
979
    return $items;
1153
}
980
}
Zeile 1154... Zeile 981...
1154
 
981
 
1155
/**
982
/**
1156
 * getIsoCode()
983
 * getIsoCode()
Zeile 1162... Zeile 989...
1162
 *
989
 *
1163
 * @return string
990
 * @return string
1164
 */
991
 */
1165
function getIsoCode($Land = 'Deutschland', $len = 2)
992
function getIsoCode($Land = 'Deutschland', $len = 2)
1166
{
993
{
1167
	$iso = "DE";
994
    $iso = "DE";
1168
	$sql = "SELECT
995
    $sql = "SELECT
1169
                `iso-".$len."` as iso_code
996
                `iso-" . $len . "` as iso_code
1170
            FROM
997
            FROM
1171
                countries
998
                countries
1172
            WHERE
999
            WHERE
1173
                `name-ger` ='".$Land."'
1000
                `name-ger` ='" . $Land . "'
1174
            OR
1001
            OR
1175
                `name-en` = '".$Land."'
1002
                `name-en` = '" . $Land . "'
1176
            OR
1003
            OR
1177
                `id` = '".$Land."'
1004
                `id` = '" . $Land . "'
1178
        ";
1005
        ";
1179
	$res = $GLOBALS["db_red"]->query($sql);
1006
    $res = $GLOBALS["db_red"]->query($sql);
1180
	$row = $res->row_array();
1007
    $row = $res->row_array();
1181
	$iso = $row["iso_code"];
1008
    $iso = $row["iso_code"];
1182
	return $iso;
1009
    return $iso;
1183
}
1010
}
Zeile 1184... Zeile 1011...
1184
 
1011
 
1185
if (isset($GLOBALS['INI']['steuern']['use_countries_tax']))
-
 
1186
{
1012
if (isset($GLOBALS['INI']['steuern']['use_countries_tax'])) {
1187
	$GLOBALS['steuern'] = getSteuerinfo();
1013
    $GLOBALS['steuern'] = getSteuerinfo();
Zeile 1188... Zeile 1014...
1188
}
1014
}
1189
 
1015
 
1190
/**
1016
/**
1191
 * Liefert zu den angegebenen LänderIds aus der Ini-Variable steuern->use_countries-tax die verfügbaren Steuersätze
1017
 * Liefert zu den angegebenen LänderIds aus der Ini-Variable steuern->use_countries-tax die verfügbaren Steuersätze
1192
 *      *
1018
 *      *
1193
 * @return array $steuern mit den Steuerinfos ermittelt
1019
 * @return array $steuern mit den Steuerinfos ermittelt
1194
 *
1020
 *
1195
 */
1021
 */
1196
function getSteuerinfo()
1022
function getSteuerinfo()
1197
{
1023
{
1198
	$steuern = array();
1024
    $steuern = array();
1199
	//default LandID für Deutschland
1025
    //default LandID für Deutschland
1200
	$landID = 47;
1026
    $landID = 47;
1201
	//Wenn das Flag gesetzt ist, dann nimm diesen wert, damit auch "ausländische Shops" den richtigen MwSt angezeigt bekommen
-
 
1202
	if (isset($GLOBALS["INI"]["steuern"]["default_countryID"]))
1027
    //Wenn das Flag gesetzt ist, dann nimm diesen wert, damit auch "ausländische Shops" den richtigen MwSt angezeigt bekommen
1203
	{
1028
    if (isset($GLOBALS["INI"]["steuern"]["default_countryID"])) {
Zeile 1204... Zeile 1029...
1204
		$landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
1029
        $landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
1205
	}
1030
    }
Zeile 1206... Zeile 1031...
1206
 
1031
 
1207
	$countryIDs = (isset($GLOBALS['INI']['steuern']['use_countries_tax'])) ? $GLOBALS['INI']['steuern']['use_countries_tax'] :
1032
    $countryIDs = (isset($GLOBALS['INI']['steuern']['use_countries_tax'])) ? $GLOBALS['INI']['steuern']['use_countries_tax'] :
1208
		$landID;
1033
        $landID;
1209
 
1034
 
1210
	$sql = "SELECT
1035
    $sql = "SELECT
1211
			*
1036
			*
1212
		FROM
1037
		FROM
1213
			countries_tax
1038
			countries_tax
1214
		WHERE
1039
		WHERE
1215
			countries_id IN (".$countryIDs.")
-
 
1216
	";
1040
			countries_id IN (" . $countryIDs . ")
1217
	$res = $GLOBALS["db_red"]->query($sql);
1041
	";
1218
	while ($r = $res->unbuffered_row('array'))
1042
    $res = $GLOBALS["db_red"]->query($sql);
1219
	{
1043
    while ($r = $res->unbuffered_row('array')) {
Zeile 1220... Zeile 1044...
1220
		$steuern[$r['countries_id']][$r['taxes_id']] = $r['tax_percent'];
1044
        $steuern[$r['countries_id']][$r['taxes_id']] = $r['tax_percent'];
1221
	}
1045
    }
1222
	return $steuern;
1046
    return $steuern;
1223
}
1047
}
1224
 
-
 
1225
function get_gewicht()
1048
 
1226
{
1049
function get_gewicht()
1227
	$gewicht = 0;
1050
{
1228
	foreach ($_SESSION['SHOP']['BASKET'] AS $bItem)
1051
    $gewicht = 0;
1229
	{
1052
    foreach ($_SESSION['SHOP']['BASKET'] as $bItem) {
Zeile 1230... Zeile 1053...
1230
		$artikel = $GLOBALS['ci']->artikel->get_artikel($bItem['ID'], true);
1053
        $artikel = $GLOBALS['ci']->artikel->get_artikel($bItem['ID'], true);
1231
		$gewicht += $artikel['gewicht'];
1054
        $gewicht += $artikel['gewicht'];
1232
	}
1055
    }
Zeile 1245... Zeile 1068...
1245
 *
1068
 *
1246
 */
1069
 */
Zeile 1247... Zeile 1070...
1247
 
1070
 
1248
function isWeban()
1071
function isWeban()
1249
{
1072
{
1250
	$webanIP = "89.245.130.99";
1073
    $webanIP = "89.245.130.99";
1251
	if (!defined("IS_WEBAN"))
-
 
1252
	{
1074
    if (!defined("IS_WEBAN")) {
1253
		if ((isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] == $webanIP) || (isset
1075
        if ((isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] == $webanIP) || (isset
1254
			($_SERVER["PHP_AUTH_USER"]) && $_SERVER["PHP_AUTH_USER"] == "admin") || (isset($_SERVER["REMOTE_ADDR"]) &&
1076
            ($_SERVER["PHP_AUTH_USER"]) && $_SERVER["PHP_AUTH_USER"] == "admin") || (isset($_SERVER["REMOTE_ADDR"]) &&
1255
			preg_match("/192\.168\.0/", $_SERVER["REMOTE_ADDR"])) || CRON === true)
-
 
1256
		{
1077
            preg_match("/192\.168\.0/", $_SERVER["REMOTE_ADDR"])) || CRON === true) {
1257
			define("IS_WEBAN", true);
-
 
1258
		}
1078
            define("IS_WEBAN", true);
1259
		else
-
 
1260
		{
1079
        } else {
1261
			define("IS_WEBAN", false);
1080
            define("IS_WEBAN", false);
1262
		}
1081
        }
1263
	}
1082
    }
1264
}
1083
}
1265
function admin_debug($var, $die = false)
1084
function admin_debug($var, $die = false)
1266
{
1085
{
1267
	if (IS_WEBAN === true)
-
 
1268
	{
1086
    if (IS_WEBAN === true) {
1269
		echo EOL."Admin-Debug:".EOL;
1087
        echo EOL . "Admin-Debug:" . EOL;
1270
		var_dump($var);
1088
        var_dump($var);
1271
		if ($die === true)
-
 
1272
		{
1089
        if ($die === true) {
1273
			die();
1090
            die();
1274
		}
-
 
1275
	}
1091
        }
1276
	else
-
 
1277
	{
1092
    } else {
1278
		//mail( "ltiefland@gmail.com", "Fehler auf " . __SHOP__, var_export( $var, true ) );
1093
        //mail( "ltiefland@gmail.com", "Fehler auf " . __SHOP__, var_export( $var, true ) );
1279
	}
1094
    }
Zeile 1280... Zeile 1095...
1280
}
1095
}
1281
 
1096
 
1282
function getBasketGewicht()
1097
function getBasketGewicht()
1283
{
1098
{
-
 
1099
    $gewicht = 0;
-
 
1100
    foreach ($_SESSION["SHOP"]["BASKET"] as $bItem) {
-
 
1101
        $gewicht += $bItem["gewicht"];
-
 
1102
    }
-
 
1103
    return $gewicht;
-
 
1104
}
1284
	$gewicht = 0;
1105
 
1285
	foreach ($_SESSION["SHOP"]["BASKET"] as $bItem)
1106
function getDokDomain()
-
 
1107
{
-
 
1108
    global $webs, $site_full, $site;
-
 
1109
    $prot = "http";
-
 
1110
    if ( $webs["use_ssl"] == 1 )
-
 
1111
    {
-
 
1112
        $prot = "https";
-
 
1113
    }
-
 
1114
    $dokDomain = $prot . "://www." . $site_full;
-
 
1115
    if ( $site == $site_full && $webs["dok_domain"] )
1286
	{
1116
    {
1287
		$gewicht += $bItem["gewicht"];
1117
        $dokDomain = $prot . "://" . $webs["dok_domain"];
1288
	}
1118
    }
1289
	return $gewicht;
-
 
1290
}
1119
    return $dokDomain;