$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