Add php fungtion (icecat)

I stumbled upon this php fungtion and wounderd if it would work for csc.



the problem is that it uses EAN and in csc EAN and manufactor is importet as a fungtion.





can any one give me som hints on how to integrate this?


<br />
function getICEcatProductSpecs($ean, $drawdescription = 0, $drawpicture = 0)<br />
{  <br />
    // Username and password for usage with ICEcat <br />
    $username = "Your ICEcat username goes here";<br />
    $password = "Your ICEcat password goes here";<br />
<br />
    // Return 0 and exit function if no EAN available<br />
    if($ean == null)<br />
    {<br />
	    return 0;<br />
    }<br />
<br />
    // Get the product specifications in XML format<br />
    $context = stream_context_create(array(<br />
	    'http' => array(<br />
		    'header'  => "Authorization: Basic " . base64_encode($username.":".$password)<br />
	    )<br />
    ));<br />
    $data = file_get_contents('http://data.icecat.biz/xml_s3/xml_server3.cgi?ean_upc='.$ean.';lang=nl;output=productxml', false, $context);<br />
    $xml = new SimpleXMLElement($data);<br />
	<br />
    // Create arrays of item elements from the XML feed<br />
    $productPicture = $xml->xpath("//Product");<br />
    $productDescription = $xml->xpath("//ProductDescription");<br />
    $categories = $xml->xpath("//CategoryFeatureGroup");<br />
    $spec_items = $xml->xpath("//ProductFeature");<br />
	<br />
    //Draw product specifications table if any specs available for the product<br />
    if($spec_items != null)<br />
    {<br />
	    $categoryList = array();<br />
	    foreach($categories as $categoryitem) {<br />
		    $catId = intval($categoryitem->attributes());<br />
		    $titleXML = new SimpleXMLElement($categoryitem->asXML());<br />
		    $title = $titleXML->xpath("//Name");<br />
		    $catName = $title[0]->attributes();<br />
		    //echo $catId . $catName['Value']. "<br />";<br />
		    $categoryList[$catId] = $catName['Value'];<br />
	    }<br />
		<br />
	    $specs =  "<table class='productspecs'>";<br />
	    $i = 0;<br />
		<br />
	    $drawnCategories = array();<br />
		<br />
	    foreach($spec_items as $item) {<br />
		    $specValue = $item->attributes();<br />
		    $titleXML = new SimpleXMLElement($item->asXML());<br />
		    $title = $titleXML->xpath("//Name");<br />
		    $specName = $title[0]->attributes();<br />
		    $specCategoryId = intval($specValue['CategoryFeatureGroup_ID']);<br />
			<br />
		    if($specName['Value'] != "Source data-sheet")<br />
		    {<br />
			    $class = $i%2==0?"odd":"even";<br />
			    $specs .= "<tr class='".$class."'><br />
					    <td><br />
						    <table>";<br />
			    if(!in_array($specCategoryId, $drawnCategories))<br />
			    {<br />
				    $specs .= " <tr class='speccategory'><br />
								    <th><h3>".$categoryList[$specCategoryId]."</h3></th><br />
							    </tr>";<br />
				    $drawnCategories[$i] = $specCategoryId;<br />
			    }<br />
			    $specs .= "	 <tr><br />
								    <th>".utf8_decode($specName['Value']).":</th><br />
							    </tr><br />
							    <tr><br />
								    <td>";   <br />
										    if($specValue['Presentation_Value'] == "Y")<br />
										    {<br />
											    $specs .= "Ja <img src='".SCRIPT_ROOT."images/check_green.png' alt='Ja' />";<br />
										    }<br />
										    else if($specValue['Presentation_Value'] == "N")<br />
										    {<br />
											    $specs .= "Nee <img src='".SCRIPT_ROOT."images/check_red.png' alt='Nee' />";<br />
										    }<br />
										    else<br />
										    {<br />
											    $specs .= str_replace('\n', '<br />', utf8_decode($specValue['Presentation_Value']));<br />
										    }<br />
						    $specs .= "</td><br />
							    </tr><br />
						    </table><br />
					    </td><br />
				    </tr>";<br />
		    }<br />
		    $i++;<br />
	    }<br />
	    $specs .= "</table>";<br />
		<br />
	    //Draw product description and link to manufacturer if available<br />
	    if( $drawdescription != 0)<br />
	    {<br />
		    foreach($productDescription as $item) {<br />
			    $productValues = $item->attributes();<br />
			    if($productValues['URL'] != null)<br />
			    {<br />
				    $specs .= "<p id='manufacturerlink'><a href='".$productValues['URL']."'>Productinformation from manufacturer</a></p>";<br />
			    }<br />
			    if($productValues['LongDesc'] != null)<br />
			    {<br />
				    $description = utf8_decode(str_replace('\n', '', $productValues['LongDesc']));<br />
				    $description = str_replace('<b>', '<strong>', $description);<br />
				    $description = str_replace('<B>', '<strong>', $description);<br />
				    $description = str_replace('</b>', '</strong>', $description);<br />
				    $specs .= "<p id='manudescription'>".$description."</p>";<br />
			    }<br />
}<br />
	    }<br />
<br />
	    //Draw product picture if available<br />
	    if( $drawdescription != 0)<br />
	    {<br />
		    foreach($productPicture as $item) {<br />
			    $productValues = $item->attributes();<br />
			    if($productValues['HighPic'] != null)<br />
			    {<br />
				    $specs .= "<div id='manuprodpic'><img src='".$productValues['HighPic']."' alt='' /></div>";<br />
			    }<br />
		    }<br />
	    }<br />
	    return $specs;<br />
    }<br />
    else<br />
    {<br />
	    return 0;<br />
    }<br />
}<br />

and here is the text that comes with the code.



i am not shure if you could make this so it is a update product tool or if it shuld be an on the run script.



[color=#333333]Use this PHP function to draw a nice table with product specifications gathered from an XML feed from ICEcat ([url=“http://www.icecat.biz/”]http://www.icecat.biz/[/url]). It requires that you feed the function with an EAN product number and that you have registered with ICEcat. Set your username and password accordingly in the variables. You can choose to draw the product description and picture by setting $drawdescription and $drawpicture to 1.[/color]

[color=#333333]The output is fully valid XHTML 1.0 Strict and is easily stylable using CSS.[/color]