Blame | Letzte Änderung | Log anzeigen | RSS feed
<?function getZipFileList( $zipfile, $filter = "", $returnString = false){$cmd = "unzip -l $zipfile $filter";echo $cmd."\n";exec($cmd, $returnValue);if ($returnString){return implode($returnValue,"\n");}else{$returnValue = array_slice ($returnValue, 3, -2);foreach($returnValue as $lineNr => $lineValue){$buffer = preg_split("/\s+/", trim($lineValue));$returnValue[$lineNr] = array(length => $buffer[0],date => $buffer[1],time => $buffer[2],name => $buffer[3]);}return $returnValue;}}/* ########################################################################################################### */function getZipFileExtractedTo( $zipfile, $filename, $targetPath){$filename = str_replace(" ", "\ ", $filename);$filename = str_replace("(", "\(", $filename);$filename = str_replace(")", "\)", $filename);$cmd="unzip -joC $zipfile $filename -d $targetPath";echo $cmd."\n";preg_match("/inflating:.*\/(.*?)$/",exec($cmd),$matches);echo "-> ".$matches[1]."\n";return $matches[1];}/* ########################################################################################################### */function getZipFileContent( $zipfile, $filename){$cmd="unzip -p $zipfile $filename";echo $cmd."\n";exec($cmd, $returnValue);return implode($returnValue,"\n");}/* ########################################################################################################### */function parseProdanetData($xml){global $zipfile;preg_match("/<ProductRecord ProdanetEAN=\"(.*?)\">.*?(<Features>(.*?)<\/Features>)/",$xml,$matches);array_shift ($matches);//Header verarbeitenpreg_match("/<VersionNumber>(.*?)<\/VersionNumber>.*?<RevisionNumber>(.*?)<\/RevisionNumber>.*?<Timestamp>(.*?)<\/Timestamp>.*?<Country>(.*?)<\/Country>.*?<Sender>(.*?)<\/Sender>.*?<Receiver>(.*?)<\/Receiver>/",$xml,$header);array_shift ($header);//Data verarbeitenpreg_match("/<Brand>(.*?)<\/Brand>.*?<ProductName1>(.*?)<\/ProductName1>.*?<ProductName2>(.*?)<\/ProductName2>.*?<ProductColor>(.*?)<\/ProductColor>.*?<ProductGroupName>(.*?)<\/ProductGroupName>/",$xml,$data);array_shift ($data);//Features verarbeitenreturnarray("Header" => array("VersionNumber" => $header[0],"RevisionNumber" => $header[1],"Timestamp" => $header[2],"Country" => $header[3],"Sender" => $header[4],"Receiver" => $header[5]),"ProductMasterRecordData" => array("ProdanetEAN" => $matches[0],"Brand" => $data[0],"ProductName1" => $data[1],"ProductName2" => $data[2],"ProductColor" => $data[3],"ProductGroupName" => $data[4],"ProductImage" => getZipFileExtractedTo($zipfile,"*".$matches[0].".j*","/web/apache/pq-media.de/images/Bild_1/original")),"ProductFeatureRecord" => $matches[1]);}/* ########################################################################################################### *//* ########################################################################################################### *//* ########################################################################################################### */$zipfile = $_SERVER[argv][1] ;mysql_connect("127.0.0.1:3306","content_managem","k-dp-u");mysql_query ("use pq_media_de") or die (mysql_errno().": ".mysql_error());foreach(getZipFileList($zipfile, "*.xml", false) as $productFile){$data=parseProdanetData(getZipFileContent($zipfile, $productFile[name]));$query="insert intoartikel(Father,Language,kennung,hersteller,kurzbezeichnung,langbezeichnung ,bild_1_url,beschreibung,erstellt_am,erstellt_von,prodanetVersionNumber,prodanetRevisionNumber,prodanetTimestamp)values(1,'".addslashes($data[Header][Country])."','".addslashes($data[ProductMasterRecordData][ProdanetEAN])."','".addslashes($data[ProductMasterRecordData][Brand])."','".addslashes($data[ProductMasterRecordData][ProductName1])."','".addslashes($data[ProductMasterRecordData][ProductName2])."','".addslashes($data[ProductMasterRecordData][ProductImage])."','".addslashes($data[ProductFeatureRecord])."',NOW(),'ProdaNet-Import','".addslashes($data[Header][VersionNumber])."','".addslashes($data[Header][RevisionNumber])."','".addslashes($data[Header][Timestamp])."')";print_r($query);mysql_query ($query) or die (mysql_errno().": ".mysql_error()."\n\n".$query);}function imageConvert($path="/web/apache/pq-media.de/images/Bild_1"){$original=$path."/original";$handle=opendir($original);while ($image = readdir ($handle)){if (is_file ($original."/".$image)){$image = str_replace(" ", "\ ", $image);$image = str_replace("(", "\(", $image);$image = str_replace(")", "\)", $image);$cmd = array("convert -scale 180x180 $original/$image $path/180x180/$image","convert -scale 120x120 $original/$image $path/120x120/$image","convert -scale 80x120 $original/$image $path/80x120/$image","convert -scale 30x30 $original/$image $path/30x30/$image","rm $original/$image");foreach($cmd as $exec){echo $exec."\n";exec($exec);}}}closedir($handle);}imageConvert();?>