]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 13 May 2013 16:37:00 +0000 (16:37 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 13 May 2013 16:37:00 +0000 (16:37 +0000)
inc/ws/Controlleur/class.ws.services.php

index 3b34aa0db65c3479303b5ab15dfc39339b80f503..19cc00ef0f7ef1ec6d19d54a92a9f172b9f33540 100644 (file)
@@ -527,6 +527,25 @@ class wsServices extends cubeFlashGateway {
                $this->outputXML = false;\r
        }\r
 \r
+       public function wescoRef() {\r
+               $cache = ROOT . '/cache/wesco/' . $this->args['ref'];\r
+               if (file_exists($cache)) {\r
+                       header('Location: ' . file_get_contents($cache));\r
+                       exit;\r
+               }\r
+               $url = 'http://www.wesco-eshop.fr/catalogsearch/result/?q=' . $this->args['ref'];\r
+               $doc = new DOMDocument();\r
+               $doc->loadHTML(file_get_contents($url));\r
+               $x = simplexml_import_dom($doc);\r
+               $xpath = $x->xpath('//a[@class="product-image"]');\r
+               if (count($xpath) > 0) {\r
+                       $r = $xpath[0]['href'];\r
+                       file_put_contents($cache, $r);\r
+                       header('Location: ' . $r);\r
+                       exit;\r
+               }\r
+               header('Location: http://www.wesco-eshop.fr');\r
+       }\r
 }\r
 \r
 ?>
\ No newline at end of file