Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php//$Id: gen_csv.php 3361 2011-02-24 15:34:41Z tiefland $/*** @author Lars Tiefland <tiefland@weban.de>* @copyright 2008 Webagentur Niewerth* @package Content-management* @version $Rev: 3361 $* @license propietary* @filesource**//*** erstellt eine XML-Datei und übertägt sie an den Remote-Server; dieser erstellt dann die gewünschten CSV-Dateien* Im Anschluß wird die XML-Datei wieder gelöscht* @author Lars Tiefland <tiefland@weban.de>* @copyright 2008 Webagentur Niewerth* @package Content-management*/require_once "../Online-Shop/connect2.php";require_once "Config.php";if ( count( $_GET ) == 1 ){$Agentur_ID = $_GET["agentur"];$sql = "SELECTshops_ID,name,config,uses_dump,csv_url,plesk,user,serverFROMPreisagentur p,shops sWHEREs.ID=p.shops_idANDp.ID=" . $Agentur_ID;$res = mysql_query( $sql );if ( $res ){$row = mysql_fetch_assoc( $res );$shop = $row["name"];$extra = ( $row["plesk"] ) ? "httpdocs" : $shop;$user = ( $row["user"] ) ? $row["user"] : "www-data";$server = ( $row["server"] ) ? $row["server"] : $shop;$xml_file = $site . "_" . $shop . ".xml";$cfg = new Config();if ( file_exists( $xml_file ) ){$xml = $cfg->parseConfig( $xml_file, "xml" );$csv_arr = $xml->toArray();if ( isset( $csv_arr["root"]["CSV_files"]["CSV"]["shop"] ) ){$csv = $csv_arr["root"]["CSV_files"]["CSV"];unset( $csv_arr["root"]["CSV_files"]["CSV"] );$csv_arr["root"]["CSV_files"]["CSV"][0] = $csv;unset( $csv );$i = 1;}else{$i = count( $csv_arr["root"]["CSV_files"]["CSV"] );}}else{$i = 0;}$csv_files = array();if ( is_array( $csv_arr["root"]["CSV_files"]["CSV"] ) ){foreach ( $csv_arr["root"]["CSV_files"]["CSV"] as $csv_file ){$csv_files[] = $csv_file["agentur"];}}if ( !in_array( $Agentur_ID, $csv_files ) ){$out_file = str_replace( "http://www.", "/var/www/", $row["csv_url"] );$csv_arr["root"]["CSV_files"]["CSV"][$i]["shop"] = $shop;$csv_arr["root"]["CSV_files"]["CSV"][$i]["agentur"] = $Agentur_ID;$csv_arr["root"]["CSV_files"]["CSV"][$i]["uses_dump"] = $row["uses_dump"];$csv_arr["root"]["CSV_files"]["CSV"][$i]["config"] = $row["config"];$csv_arr["root"]["CSV_files"]["CSV"][$i]["out_file"] =basename( $out_file );$csv_arr["root"]["CSV_files"]["CSV"][$i]["out_dir"] =dirname( $out_file );$cfg2 = new Config();$cfg2->parseConfig( $csv_arr["root"]["CSV_files"],"phparray" );$cfg2->writeConfig( $xml_file, "xml", array( "name" =>"CSV_files" ) );$cmd = "scp $xml_file $user@" . $server . ":$extra/control/$xml_file";exec( $cmd, $out, $err );}header( "Location: ../shop-statistik.php" );}else{echo mysql_error() . "<br>$sql<br>";}}else{echo "Falsche Anzahl Parameter";}?>