| 2 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
use App\Http\Controllers\BasketController;
|
|
|
4 |
use App\Http\Controllers\BuyController;
|
|
|
5 |
use App\Http\Controllers\ShippingController;
|
|
|
6 |
use App\Http\Controllers\UserController;
|
|
|
7 |
use Illuminate\Support\Facades\DB;
|
|
|
8 |
use Illuminate\Support\Facades\Schema;
|
|
|
9 |
use PHPHtmlParser\Dom;
|
|
|
10 |
use App\Models\Action;
|
|
|
11 |
use App\Models\Item;
|
|
|
12 |
use App\Models\Directory;
|
|
|
13 |
use Illuminate\Support\Facades\Route;
|
|
|
14 |
use PHPHtmlParser\Exceptions\ChildNotFoundException;
|
|
|
15 |
use PHPHtmlParser\Exceptions\CircularException;
|
|
|
16 |
use PHPHtmlParser\Exceptions\CurlException;
|
|
|
17 |
use PHPHtmlParser\Exceptions\NotLoadedException;
|
|
|
18 |
use PHPHtmlParser\Exceptions\StrictException;
|
|
|
19 |
|
|
|
20 |
/*
|
|
|
21 |
|--------------------------------------------------------------------------
|
|
|
22 |
| Web Routes
|
|
|
23 |
|--------------------------------------------------------------------------
|
|
|
24 |
|
|
|
|
25 |
| Here is where you can register web routes for your application. These
|
|
|
26 |
| routes are loaded by the RouteServiceProvider within a group which
|
|
|
27 |
| contains the "web" middleware group. Now create something great!
|
|
|
28 |
|
|
|
|
29 |
*/
|
|
|
30 |
|
|
|
31 |
$GLOBALS["INI"] = getConfig();
|
|
|
32 |
$GLOBALS["zahlsysteme"] = [
|
|
|
33 |
"kreditkarte",
|
|
|
34 |
"paypal",
|
|
|
35 |
"sofortueberweisung",
|
|
|
36 |
"frei",
|
|
|
37 |
"finanzierung",
|
|
|
38 |
"billsafe",
|
|
|
39 |
"billsafe_hire",
|
|
|
40 |
"amazon",
|
|
|
41 |
"PayPalExpress",
|
|
|
42 |
"Ratenzahlung",
|
|
|
43 |
"PayPalPlus",
|
|
|
44 |
"paymill",
|
|
|
45 |
"klarna",
|
|
|
46 |
"paydirekt",
|
|
|
47 |
"payever",
|
|
|
48 |
"billie",
|
|
|
49 |
"easycredit",
|
|
|
50 |
"crefopay",
|
|
|
51 |
"crefopayKK",
|
|
|
52 |
"PayPalCheckout",
|
|
|
53 |
];
|
|
|
54 |
|
|
|
55 |
if ( php_sapi_name() == "cli" )
|
|
|
56 |
{
|
|
|
57 |
return;
|
|
|
58 |
}
|
|
|
59 |
session_start();
|
|
|
60 |
if ( isset( $_GET["killSession"] ) )
|
|
|
61 |
{
|
|
|
62 |
unset( $_SESSION );
|
|
|
63 |
$_SESSION["SHOP"]["BASKET"] = new BasketController();
|
|
|
64 |
}
|
|
|
65 |
$GLOBALS["steuern"] = array();
|
|
|
66 |
//default LandID für Deutschland
|
|
|
67 |
$landID = 47;
|
|
|
68 |
//Wenn das Flag gesetzt ist, dann nimm diesen wert, damit auch "ausländische Shops" den richtigen MwSt angezeigt bekommen
|
|
|
69 |
if ( isset( $GLOBALS["INI"]["steuern"]["default_countryID"] ) )
|
|
|
70 |
{
|
|
|
71 |
$landID = $GLOBALS["INI"]["steuern"]["default_countryID"];
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
$countryIDs = ( isset( $GLOBALS['INI']['steuern']['use_countries_tax'] ) ) ? $GLOBALS['INI']['steuern']['use_countries_tax'] : $landID;
|
|
|
75 |
|
|
|
76 |
$sql = "SELECT
|
|
|
77 |
*
|
|
|
78 |
FROM
|
|
|
79 |
countries_tax
|
|
|
80 |
WHERE
|
|
|
81 |
country_id IN (" . $countryIDs . ")
|
|
|
82 |
";
|
|
|
83 |
$rows = DB::connection( "cms" )->select( $sql );
|
|
|
84 |
foreach ( $rows as $r )
|
|
|
85 |
{
|
|
|
86 |
$GLOBALS["steuern"][$r->country_id][$r->taxes_id] = $r->tax_percent;
|
|
|
87 |
$GLOBALS["steuern"][$r->country_id][null] = $GLOBALS["steuern"][$r->country_id][0];
|
|
|
88 |
}
|
|
|
89 |
if ( !isset( $_SESSION["SHOP"]["BASKET"] ) )
|
|
|
90 |
{
|
|
|
91 |
$_SESSION["SHOP"]["BASKET"] = new BasketController();
|
|
|
92 |
}
|
|
|
93 |
elseif ( is_array( $_SESSION["SHOP"]["BASKET"] ) )
|
|
|
94 |
{
|
|
|
95 |
$items = $_SESSION["SHOP"]["BASKET"];
|
|
|
96 |
unset( $_SESSION["SHOP"]["BASKET"] );
|
|
|
97 |
$_SESSION["SHOP"]["BASKET"] = new BasketController();
|
|
|
98 |
$_SESSION["SHOP"]["BASKET"]->items = $items;
|
|
|
99 |
}
|
|
|
100 |
$sql = "
|
|
|
101 |
SELECT
|
|
|
102 |
*
|
|
|
103 |
FROM
|
|
|
104 |
i18n_de
|
|
|
105 |
";
|
|
|
106 |
if ( Schema::hasTable( 'i18n_de' ) )
|
|
|
107 |
{
|
|
|
108 |
$langstrings = DB::select( $sql );
|
|
|
109 |
}
|
|
|
110 |
else
|
|
|
111 |
{
|
|
|
112 |
$langstrings = DB::connection( "old" )->select( $sql );
|
|
|
113 |
}
|
|
|
114 |
foreach ( $langstrings as $langstring )
|
|
|
115 |
{
|
|
|
116 |
$GLOBALS["langstrings"][$langstring->page_id][$langstring->id] = $langstring->string;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
function parseCMSPage( $url ): array
|
|
|
120 |
{
|
|
|
121 |
$menu = "";
|
|
|
122 |
$content = "";
|
|
|
123 |
$dom = new Dom;
|
|
|
124 |
try
|
|
|
125 |
{
|
|
|
126 |
$dom->loadFromUrl( $url );
|
|
|
127 |
$menu = $dom->getElementById( 'menu' )->innerHtml;
|
|
|
128 |
$menu = str_replace( "/typo3", "/cms", $menu );
|
|
|
129 |
$content = $dom->getElementById( 'content' )->innerHtml;
|
|
|
130 |
$content = str_replace( "fileadmin/", $GLOBALS["INI"]["typo3"]["url"] . "/typo3/fileadmin/", $content );
|
|
|
131 |
$content = str_replace( "ce-textpic", "", $content );
|
|
|
132 |
}
|
|
|
133 |
catch ( ChildNotFoundException|CircularException|CurlException|StrictException|NotLoadedException $e )
|
|
|
134 |
{
|
|
|
135 |
}
|
|
|
136 |
return array( "menu" => $menu, "content" => $content, );
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
function getConfig()
|
|
|
140 |
{
|
|
|
141 |
define( '__SITE__', env( 'site' ) );
|
|
|
142 |
define( '__SHOP__', env( 'shop' ) );
|
|
|
143 |
define( "__CFG_PATH__", "/etc/shop_configs/" . __SITE__ . "/" . __SHOP__ );
|
|
|
144 |
|
|
|
145 |
$cfg_file = __CFG_PATH__ . "/config.de.xml";
|
|
|
146 |
if ( !file_exists( $cfg_file ) )
|
|
|
147 |
{
|
|
|
148 |
trigger_error( "Konnte keine Konfigurationsdatei für das Shopsystem " . __SITE__ . " -> " . __SHOP__ . " finden (" . ( $cfg_file ) . ")!", E_USER_ERROR );
|
|
|
149 |
}
|
|
|
150 |
$xml = simplexml_load_file( $cfg_file, "SimpleXMLElement", LIBXML_NOCDATA );
|
|
|
151 |
$ini = json_decode( json_encode( $xml ), true );
|
|
|
152 |
foreach ( $ini as $key => $wert )
|
|
|
153 |
{
|
|
|
154 |
if ( $wert == array() )
|
|
|
155 |
{
|
|
|
156 |
$ini[$key] = "";
|
|
|
157 |
}
|
|
|
158 |
elseif ( is_array( $wert ) )
|
|
|
159 |
{
|
|
|
160 |
foreach ( $wert as $key2 => $wert2 )
|
|
|
161 |
{
|
|
|
162 |
if ( $wert2 == array() )
|
|
|
163 |
{
|
|
|
164 |
$ini[$key][$key2] = "";
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
$v_file = __CFG_PATH__ . "/versand.xml";
|
|
|
171 |
if ( file_exists( $v_file ) )
|
|
|
172 |
{
|
|
|
173 |
$xml = simplexml_load_file( $v_file, "SimpleXMLElement", LIBXML_NOCDATA );
|
|
|
174 |
$ini["shipping"] = json_decode( json_encode( $xml ), true );
|
|
|
175 |
foreach ( $ini["shipping"] as $key => $wert )
|
|
|
176 |
{
|
|
|
177 |
if ( $wert == array() )
|
|
|
178 |
{
|
|
|
179 |
$ini["shipping"][$key] = "";
|
|
|
180 |
}
|
|
|
181 |
elseif ( is_array( $wert ) )
|
|
|
182 |
{
|
|
|
183 |
foreach ( $wert as $key2 => $wert2 )
|
|
|
184 |
{
|
|
|
185 |
if ( $wert2 == array() )
|
|
|
186 |
{
|
|
|
187 |
$ini["shipping"][$key][$key2] = "";
|
|
|
188 |
}
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
return $ini;
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
$nav = new Directory();
|
|
|
197 |
$menu = $nav->nav_menu();
|
|
|
198 |
$sc = parseCMSPage( $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" );
|
|
|
199 |
$data = [
|
|
|
200 |
"nav" => $menu,
|
|
|
201 |
"serviceCenterMenu" => $sc["menu"],
|
|
|
202 |
"langstrings" => $GLOBALS["langstrings"],
|
|
|
203 |
"ini" => $GLOBALS["INI"],
|
|
|
204 |
];
|
|
|
205 |
\View::share( $data );
|
|
|
206 |
|
|
|
207 |
/* Mobile Weiche */
|
|
|
208 |
if ( isset( $_SERVER["HTTP_USER_AGENT"] ) )
|
|
|
209 |
{
|
|
|
210 |
if ( !isset( $_SESSION['isMobile'] ) || $_SESSION['isMobile'] === false || !isset( $GLOBALS['isMobile'] ) || $GLOBALS['isMobile'] === false )
|
|
|
211 |
{
|
|
|
212 |
|
|
|
213 |
$_SESSION['isMobile'] = false;
|
|
|
214 |
$GLOBALS['isMobile'] = false;
|
|
|
215 |
|
|
|
216 |
$pattern = "/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|iPad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i";
|
|
|
217 |
if ( preg_match( $pattern, $_SERVER["HTTP_USER_AGENT"] ) )
|
|
|
218 |
{
|
|
|
219 |
|
|
|
220 |
$_SESSION['isMobile'] = true;
|
|
|
221 |
$GLOBALS['isMobile'] = true;
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
}
|
|
|
225 |
}
|
|
|
226 |
Route::get( "/addItemToBasket", function ()
|
|
|
227 |
{
|
|
|
228 |
$_SESSION["SHOP"]["BASKET"]->addItem();
|
|
|
229 |
return view( 'header_wk' );
|
|
|
230 |
} );
|
|
|
231 |
Route::get( "/editItem/{id}/{menge}", function ()
|
|
|
232 |
{
|
|
|
233 |
$_SESSION["SHOP"]["BASKET"]->editItem();
|
|
|
234 |
return redirect( "/basket.html" );
|
|
|
235 |
} )->where( [ "id" => "[0-9a-f]{40}", "menge" => "[0-9]+" ] );
|
|
|
236 |
Route::get( "/delItem/{id}", function ()
|
|
|
237 |
{
|
|
|
238 |
$_SESSION["SHOP"]["BASKET"]->delItem();
|
|
|
239 |
return redirect( "/basket.html" );
|
|
|
240 |
} )->where( "id", "[0-9a-f]{40}" );
|
|
|
241 |
Route::post( "/login", [ UserController::class, "login" ] );
|
|
|
242 |
Route::post( "/logout", [ UserController::class, "logout" ] );
|
|
|
243 |
Route::post( "/send_pw", [ UserController::class, "forgot_pw" ] );
|
|
|
244 |
Route::get( "/favoriten", function ()
|
|
|
245 |
{
|
|
|
246 |
return view( 'login_center' );
|
|
|
247 |
} );
|
|
|
248 |
Route::get( "/forgot_pw", function ()
|
|
|
249 |
{
|
|
|
250 |
return view( 'login_center' );
|
|
|
251 |
} );
|
|
|
252 |
Route::get( "/login", function ()
|
|
|
253 |
{
|
|
|
254 |
return view( 'login_center' );
|
|
|
255 |
} );
|
|
|
256 |
Route::get( "/register", function ()
|
|
|
257 |
{
|
|
|
258 |
return view( 'login_center' );
|
|
|
259 |
} );
|
|
|
260 |
Route::get( "/update_versand", [ ShippingController::class, "updateShipping" ] );
|
|
|
261 |
Route::get( "/checkLand.php", function ()
|
|
|
262 |
{
|
|
|
263 |
$_SESSION['SHOP']["BASKET"]->getShippingCountries();
|
|
|
264 |
$valid = 1;
|
|
|
265 |
if ( !in_array( $_GET["land"], array_keys( $_SESSION["SHOP"]["BASKET"]->shippingCountries ) ) )
|
|
|
266 |
{
|
|
|
267 |
$valid = 0;
|
|
|
268 |
}
|
|
|
269 |
echo $valid;
|
|
|
270 |
return $valid;
|
|
|
271 |
} );
|
|
|
272 |
Route::get( '/setSessionVars', function ()
|
|
|
273 |
{
|
|
|
274 |
foreach ( $_GET as $key => $value )
|
|
|
275 |
{
|
|
|
276 |
if ( $value == "false" )
|
|
|
277 |
{
|
|
|
278 |
unset( $_SESSION[$key] );
|
|
|
279 |
}
|
|
|
280 |
else
|
|
|
281 |
{
|
|
|
282 |
$_SESSION[$key] = $value;
|
|
|
283 |
}
|
|
|
284 |
}
|
|
|
285 |
} );
|
|
|
286 |
Route::post( "/setSessionVars", function ()
|
|
|
287 |
{
|
|
|
288 |
foreach ( $_POST as $key => $value )
|
|
|
289 |
{
|
|
|
290 |
if ( $value == "false" )
|
|
|
291 |
{
|
|
|
292 |
unset( $_SESSION[$key] );
|
|
|
293 |
}
|
|
|
294 |
else
|
|
|
295 |
{
|
|
|
296 |
$_SESSION[$key] = $value;
|
|
|
297 |
}
|
|
|
298 |
}
|
|
|
299 |
} );
|
|
|
300 |
Route::post( "/updateSession", function ()
|
|
|
301 |
{
|
|
|
302 |
} );
|
|
|
303 |
Route::get( "/cms/{slug}", function ( $slug )
|
|
|
304 |
{
|
|
|
305 |
$url = $GLOBALS["INI"]["typo3"]["url"] . "/typo3/" . $slug;
|
|
|
306 |
$arr = parseCMSPage( $url );
|
|
|
307 |
$content = $arr["content"];
|
|
|
308 |
return view( 'service_center_content', [
|
|
|
309 |
"serviceContent" => $content,
|
|
|
310 |
] );
|
|
|
311 |
} );
|
|
|
312 |
Route::get( "/bestellen_seite_{step}.html", function ( $step )
|
|
|
313 |
{
|
|
|
314 |
return view( 'buy_' . $step, [
|
|
|
315 |
"pagetype" => "Bestellvorgang1",
|
|
|
316 |
"Laender" => getRechnungsLaender(),
|
|
|
317 |
"defaultLandID" => 47,
|
|
|
318 |
] );
|
|
|
319 |
} )->where( 'step', '[1-4][ab]{0,1}' );
|
|
|
320 |
Route::post( "/bestellen_seite_{step}.html", [ BuyController::class, 'step1' ] )->where( 'step', '[1-4][ab]{0,1}' );
|
|
|
321 |
Route::get( "basket.html", function ()
|
|
|
322 |
{
|
|
|
323 |
|
|
|
324 |
return view( 'basket' );
|
|
|
325 |
} );
|
|
|
326 |
Route::get( "/directory/{id}", function ( $id )
|
|
|
327 |
{
|
|
|
328 |
list( $dirId, $dirName ) = explode( "-", $id, 2 );
|
|
|
329 |
$dirs = Directory::with( 'medium.medium' )->where( "directory_id", $dirId )->whereIn( 'status', [
|
|
|
330 |
0,
|
|
|
331 |
99
|
|
|
332 |
] )->orderBy( 'kennung' )->orderBy( 'name' )->get();
|
|
|
333 |
$items = Item::with( 'price', 'medium.medium', 'manufacturer' )->where( "directory_id", $dirId )->where( 'status', '=', 0 )->get();
|
|
|
334 |
$subdir = Directory::with( 'medium.medium', 'template.template' )->find( $dirId );
|
|
|
335 |
$subdir["subdirs"] = $dirs;
|
|
|
336 |
$subdir["items"] = $items;
|
|
|
337 |
$template = 'subdir';
|
|
|
338 |
$artstaemmeItems = array();
|
|
|
339 |
if ( is_countable( $subdir->template ) && isset( $subdir->template[0] ) )
|
|
|
340 |
{
|
|
|
341 |
$template = substr( $subdir->template[0]->template->template_value, strpos( $subdir->template[0]->template->template_value, "=" ) + 1 );
|
|
|
342 |
foreach ( $dirs as $dir )
|
|
|
343 |
{
|
|
|
344 |
if ( $dir->articlemaster == 1 )
|
|
|
345 |
{
|
|
|
346 |
$artstaemmeItems[$dir->id] = $dir;
|
|
|
347 |
$artstaemmeItems[$dir->id]["items"] = Item::with( 'medium.medium', 'price', 'manufacturer' )->where( 'directory_id', '=', $dir->id )->where( 'status', '=', 0 )->get();
|
|
|
348 |
}
|
|
|
349 |
}
|
|
|
350 |
}
|
|
|
351 |
return view( $template, [
|
|
|
352 |
"subdir" => $subdir,
|
|
|
353 |
"artstaemmeItems" => $artstaemmeItems,
|
|
|
354 |
] );
|
|
|
355 |
} );
|
|
|
356 |
Route::get( "{item:slug}.html", function ( Item $item )
|
|
|
357 |
{
|
|
|
358 |
$item->load( 'price', 'medium.medium', 'manufacturer' );
|
|
|
359 |
return view( 'item', [
|
|
|
360 |
"item" => $item,
|
|
|
361 |
] );
|
|
|
362 |
} );
|
|
|
363 |
Route::get( '/', function ()
|
|
|
364 |
{
|
|
|
365 |
$date = date( "Y-m-d" );
|
|
|
366 |
$aktion = Action::with( 'medium.medium' )->where( 'valid_from', '<=', $date )->where( 'valid_to', '>=', $date )->get();
|
|
|
367 |
return view( 'startpage', [
|
|
|
368 |
"pagetype" => "Startseite",
|
|
|
369 |
"aktion" => $aktion,
|
|
|
370 |
] );
|
|
|
371 |
} );
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
function getRechnungsLaender(): array
|
|
|
375 |
{
|
|
|
376 |
$arr = array();
|
|
|
377 |
$laender = DB::connection( 'cms' )->select( 'SELECT id,name_de FROM countries WHERE rank > 0 ORDER BY rank' );
|
|
|
378 |
foreach ( $laender as $land )
|
|
|
379 |
{
|
|
|
380 |
$arr[$land->id] = $land->name_de;
|
|
|
381 |
}
|
|
|
382 |
return $arr;
|
|
|
383 |
}
|
|
|
384 |
|
|
|
385 |
require_once __DIR__.'/admin.php';
|