From 347037024ebd07e88368b9d6d37312795c8fbc43 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 13 May 2013 16:37:00 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.services.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 3b34aa0db..19cc00ef0 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -527,6 +527,25 @@ class wsServices extends cubeFlashGateway { $this->outputXML = false; } + public function wescoRef() { + $cache = ROOT . '/cache/wesco/' . $this->args['ref']; + if (file_exists($cache)) { + header('Location: ' . file_get_contents($cache)); + exit; + } + $url = 'http://www.wesco-eshop.fr/catalogsearch/result/?q=' . $this->args['ref']; + $doc = new DOMDocument(); + $doc->loadHTML(file_get_contents($url)); + $x = simplexml_import_dom($doc); + $xpath = $x->xpath('//a[@class="product-image"]'); + if (count($xpath) > 0) { + $r = $xpath[0]['href']; + file_put_contents($cache, $r); + header('Location: ' . $r); + exit; + } + header('Location: http://www.wesco-eshop.fr'); + } } ?> \ No newline at end of file -- 2.39.5