if (!isset($_SERVER['PHP_AUTH_USER'])) { Header("WWW-Authenticate: Basic realm=\"Configurations-Editor\""); Header("HTTP/1.0 401 Unauthorized"); echo "Sie müssen sich autentifizieren\n"; exit; } else { $login=($_GET["login"])?$_GET["login"]:$_POST["login"]; if (file_exists ("conf$login.php")) { require "conf$login.php"; } else { require "conf.php"; } if ($_SERVER['PHP_AUTH_USER']<>$ERPftpuser || $_SERVER['PHP_AUTH_PW']<>$ERPftppwd) { Header("WWW-Authenticate: Basic realm=\"My Realm\""); Header("HTTP/1.0 401 Unauthorized"); echo "Sie müssen sich autentifizieren\n"; exit; } require_once "DB.php"; function pg($sel) { global $dbP; echo "\tStandard VK\n"; $sql="select id,pricegroup from pricegroup"; if (!$dbP) return; $pgs=$dbP->getall($sql); if ($pgs) foreach ($pgs as $row) { echo "\t".$row[1]."\n"; } } /** * TODO: short description. * * @param string $sel * * @return TODO */ function charset($sel) { $chars = array('','latin9','utf-8'); foreach ($chars as $c) { echo "\t$c\n"; } } function shoplang($sel,$default) { global $dbM; if (!$dbM) return; $sql="SELECT L.*, C.configuration_value FROM languages L LEFT JOIN configuration C "; $sql.="ON L.code = C.configuration_value"; $rs=$dbM->getAll($sql,DB_FETCHMODE_ASSOC); if (!$rs) { echo "\t\tkeine Sprachen\n"; } else { echo "\t\tnicht verwenden\n"; foreach ($rs as $row) { if ($default["id"]<>$row["languages_id"]) { echo "\t\t"; echo ($row["code"]==$row["configuration_value"])?"!":" "; echo $row["name"]."\n"; } } } } function erplang($sel) { global $dbP; if (!$dbP) return; $sql="select * from language"; $rs=$dbP->getAll($sql,DB_FETCHMODE_ASSOC); if (!$rs) { echo "\t\tkeine Sprachen\n"; } else { //echo "\t\tStandard\n"; foreach ($rs as $row) { echo "\t\t".$row["description"]."\n"; } } } function getERPlangs() { global $dbP; if (!$dbP) return; $sql="select * from language"; $rs=$dbP->getAll($sql,DB_FETCHMODE_ASSOC); return $rs; } function getShopDefault() { global $dbM; if (!$dbM) return; $sql="select * from languages L left join configuration C on L.code=C.configuration_value "; $sql.="where configuration_key = 'DEFAULT_LANGUAGE'"; $rs=$dbM->getAll($sql,DB_FETCHMODE_ASSOC); if ($rs) { return array("id"=>$rs[0]["languages_id"],"name"=>$rs[0]["name"]); } else { return 0; } } function getBugru() { global $dbP; if (!$dbP) return; $sql ="select BG.id as bugru,(T.rate * 100) as rate,TK.startdate from buchungsgruppen BG "; $sql.="left join chart C on BG.income_accno_id_0=C.id left join taxkeys TK "; $sql.="on TK.chart_id=C.id left join tax T on T.id=TK.tax_id where "; $sql.="TK.startdate <= now() order by BG.id, TK.startdate"; $rs=$dbP->getAll($sql,DB_FETCHMODE_ASSOC); if ($rs) foreach ($rs as $row) { $bugru[$row["bugru"]]=$row["rate"]; } return $bugru; } if ($_POST["ok"]=="sichern") { $ok=true; $dsnP = array( 'phptype' => 'pgsql', 'username' => $_POST["ERPuser"], 'password' => $_POST["ERPpass"], 'hostspec' => $_POST["ERPhost"], 'database' => $_POST["ERPdbname"], 'port' => $_POST["ERPport"] ); $dbP=@DB::connect($dsnP); if (DB::isError($dbP)||!$dbP) { $ok=false; echo "Keine Verbindung zur ERP"; echo $dbP->userinfo; $dbP=false; } else { $bugru=getBugru(); $sql="SELECT id,description,buchungsgruppen_id FROM parts where partnumber = '%s'"; $rs=$dbP->getall(sprintf($sql,$_POST["div16NR"])); $_POST["div16ID"]=$rs[0][0]; $div16txt=addslashes($rs[0][1]); $_POST["div16TAX"]=$bugru[$rs[0][2]]; $rs=$dbP->getall(sprintf($sql,$_POST["div07NR"])); $_POST["div07ID"]=$rs[0][0]; $_POST["div07TAX"]=$bugru[$rs[0][2]]; $div07txt=addslashes($rs[0][1]); $rs=$dbP->getall(sprintf($sql,$_POST["versandNR"])); $_POST["versandID"]=$rs[0][0]; $_POST["versandTAX"]=$bugru[$rs[0][2]]; $versandtxt=addslashes($rs[0][1]); $rs=$dbP->getall(sprintf($sql,$_POST["nachnNR"])); $_POST["nachnID"]=$rs[0][0]; $_POST["nachnTAX"]=$bugru[$rs[0][2]]; $nachntxt=addslashes($rs[0][1]); $rs=$dbP->getall(sprintf($sql,$_POST["minderNR"])); $_POST["minderID"]=$rs[0][0]; $_POST["minderTAX"]=$bugru[$rs[0][2]]; $mindertxt=addslashes($rs[0][1]); $rs=$dbP->getall(sprintf($sql,$_POST["paypalNR"])); $_POST["paypalID"]=$rs[0][0]; $_POST["paypalTAX"]=$bugru[$rs[0][2]]; $paypaltxt=addslashes($rs[0][1]); $rs=$dbP->getall("select id from employee where login = '".$_POST["ERPusrN"]."'"); $_POST["ERPusrID"]=$rs[0][0]; } $dsnM = array( 'phptype' => 'mysql', 'username' => $_POST["SHOPuser"], 'password' => $_POST["SHOPpass"], 'hostspec' => $_POST["SHOPhost"], 'database' => $_POST["SHOPdbname"], 'port' => $_POST["SHOPport"] ); $dbM=@DB::connect($dsnM); if (DB::isError($dbM)||!$dbM) { //$ok=false; echo "Keine Verbindung zum Shop"; echo $dbM->userinfo; $dbM=false; }; if ($ok) { $ShopDefaultLang=getShopDefault(); $f=fopen("conf$login.php","w"); $v="2.0"; $d=date("Y/m/d H:i:s"); fputs($f,"\n// Verbindung zur ERP-db\n"); fputs($f,"\$ERPuser=\"".$_POST["ERPuser"]."\";\n"); fputs($f,"\$ERPpass=\"".$_POST["ERPpass"]."\";\n"); fputs($f,"\$ERPhost=\"".$_POST["ERPhost"]."\";\n"); fputs($f,"\$ERPport=\"".$_POST["ERPport"]."\";\n"); fputs($f,"\$ERPdbname=\"".$_POST["ERPdbname"]."\";\n"); fputs($f,"\$ERPusr[\"Name\"]=\"".$_POST["ERPusrN"]."\";\n"); fputs($f,"\$ERPusr[\"ID\"]=\"".$_POST["ERPusrID"]."\";\n"); fputs($f,"\$ERPdir=\"".$_POST["ERPdir"]."\";\n"); fputs($f,"\$ERPimgdir=\"".$_POST["ERPimgdir"]."\";\n"); fputs($f,"\$maxSize=\"".$_POST["maxSize"]."\";\n"); fputs($f,"\$ERPftphost=\"".$_POST["ERPftphost"]."\";\n"); fputs($f,"\$ERPftpuser=\"".$_POST["ERPftpuser"]."\";\n"); fputs($f,"\$ERPftppwd=\"".$_POST["ERPftppwd"]."\";\n"); fputs($f,"//Verbindung zur osCommerce-db\n"); fputs($f,"\$SHOPuser=\"".$_POST["SHOPuser"]."\";\n"); fputs($f,"\$SHOPpass=\"".$_POST["SHOPpass"]."\";\n"); fputs($f,"\$SHOPhost=\"".$_POST["SHOPhost"]."\";\n"); fputs($f,"\$SHOPport=\"".$_POST["SHOPport"]."\";\n"); fputs($f,"\$SHOPdbname=\"".$_POST["SHOPdbname"]."\";\n"); fputs($f,"\$SHOPdns=\"mysql://\$SHOPuser:\$SHOPpass@\$SHOPhost/\$SHOPdbname\";\n"); fputs($f,"\$SHOPdir=\"".$_POST["SHOPdir"]."\";\n"); fputs($f,"\$SHOPchar=\"".$_POST["SHOPchar"]."\";\n"); fputs($f,"\$SHOPimgdir=\"".$_POST["SHOPimgdir"]."\";\n"); fputs($f,"\$SHOPftphost=\"".$_POST["SHOPftphost"]."\";\n"); fputs($f,"\$SHOPftpuser=\"".$_POST["SHOPftpuser"]."\";\n"); fputs($f,"\$SHOPftppwd=\"".$_POST["SHOPftppwd"]."\";\n"); fputs($f,"\$div16[\"ID\"]=\"".$_POST["div16ID"]."\";\n"); fputs($f,"\$div07[\"ID\"]=\"".$_POST["div07ID"]."\";\n"); fputs($f,"\$versand[\"ID\"]=\"".$_POST["versandID"]."\";\n"); fputs($f,"\$nachn[\"ID\"]=\"".$_POST["nachnID"]."\";\n"); fputs($f,"\$minder[\"ID\"]=\"".$_POST["minderID"]."\";\n"); fputs($f,"\$paypal[\"ID\"]=\"".$_POST["paypalID"]."\";\n"); fputs($f,"\$div16[\"NR\"]=\"".$_POST["div16NR"]."\";\n"); fputs($f,"\$div07[\"NR\"]=\"".$_POST["div07NR"]."\";\n"); fputs($f,"\$versand[\"NR\"]=\"".$_POST["versandNR"]."\";\n"); fputs($f,"\$nachn[\"NR\"]=\"".$_POST["nachnNR"]."\";\n"); fputs($f,"\$minder[\"NR\"]=\"".$_POST["minderNR"]."\";\n"); fputs($f,"\$paypal[\"NR\"]=\"".$_POST["paypalNR"]."\";\n"); fputs($f,"\$div16[\"TAX\"]=\"".$_POST["div16TAX"]."\";\n"); fputs($f,"\$div07[\"TAX\"]=\"".$_POST["div07TAX"]."\";\n"); fputs($f,"\$versand[\"TAX\"]=\"".$_POST["versandTAX"]."\";\n"); fputs($f,"\$nachn[\"TAX\"]=\"".$_POST["nachnTAX"]."\";\n"); fputs($f,"\$minder[\"TAX\"]=\"".$_POST["minderTAX"]."\";\n"); fputs($f,"\$paypal[\"TAX\"]=\"".$_POST["paypalTAX"]."\";\n"); fputs($f,"\$div16[\"TXT\"]=\"".$div16txt."\";\n"); fputs($f,"\$div07[\"TXT\"]=\"".$div07txt."\";\n"); fputs($f,"\$versand[\"TXT\"]=\"".$versandtxt."\";\n"); fputs($f,"\$nachn[\"TXT\"]=\"".$nachntxt."\";\n"); fputs($f,"\$minder[\"TXT\"]=\"".$mindertxt."\";\n"); fputs($f,"\$paypal[\"TXT\"]=\"".$paypaltxt."\";\n"); fputs($f,"\$bgcol[1]=\"#ddddff\";\n"); fputs($f,"\$bgcol[2]=\"#ddffdd\";\n"); fputs($f,"\$preA=\"".$_POST["preA"]."\";\n"); fputs($f,"\$preK=\"".$_POST["preK"]."\";\n"); fputs($f,"\$auftrnr=\"".$_POST["auftrnr"]."\";\n"); fputs($f,"\$debug=".$_POST["debug"].";\n"); fputs($f,"\$kdnum=\"".$_POST["kdnum"]."\";\n"); fputs($f,"\$stdprice=\"".$_POST["stdprice"]."\";\n"); fputs($f,"\$altprice=\"".$_POST["altprice"]."\";\n"); fputs($f,"\$KDGrp=\"".$_POST["KDGrp"]."\";\n"); fputs($f,"\$nopic=\"".$_POST["nopic"]."\";\n"); fputs($f,"\$showErr=\"true\";\n"); $Language=array(); $DefaultLangOk=false; if ($_POST["ERPlang"]) foreach ($_POST["ERPlang"] as $key=>$val) { if ($_POST["SHOPlang"][$key]==$ShopDefaultLang["id"]) $DefaultLangOk=true; if ($_POST["SHOPlang"][$key]) fputs($f,"\$Language[$key]=array(\"ERP\"=>$val,\"SHOP\"=>".$_POST["SHOPlang"][$key].");\n"); } if (!$DefaultLangOk) { fputs($f,"\$SHOPdbname=\"\";\n"); echo "Es wurde keine ERP-Sprache der Shopdefaultsprache zugewiesen."; echo "Verbindung zum Shop abgebrochen"; } fputs($f,"\$SHOPdefaultlang=\"".$ShopDefaultLang["id"]."\";\n"); fputs($f,"\$SpracheAlle=\"".$_POST["SpracheAlle"]."\";\n"); fputs($f,"?>"); fclose($f); echo "'conf.php' geschrieben!"; if (file_exists ("conf$login.php")) { require "conf$login.php"; } else { require "conf.php"; } $sql="select count(*) from customers_number"; $rc=@$dbM->query($sql); if ($rc->code==-18) { $sql="CREATE TABLE customers_number ( cid int(6) NOT NULL auto_increment, customers_id int(3) NOT NULL default '0', "; $sql.="kdnr int(3) NOT NULL default '0', shipto int , PRIMARY KEY (cid)) TYPE=MyISAM"; $rc=@$dbM->query($sql); if ($rc->code==-1) { echo "Fehler beim Erzeugen der Tabelle 'customers_number' in der Shop-db"; } else { echo "Tabelle 'customers_number' in der Shop-db angelegt."; } } else { $sql="select shipto from customers_number limit 1"; $rc=@$dbM->query($sql); if ($rc->code==-19) { $sql="alter table customers_number add column shipto int"; $rc=@$dbM->query($sql); if ($rc->code==-1) { echo "Fehler beim Anlegen der Spalte 'shipto' in 'customers_number'"; } else { echo "'shipto' in 'customers_number' angelegt."; } } } } else { $ERPuser=$_POST["ERPuser"]; $ERPpass=$_POST["ERPpass"]; $ERPhost=$_POST["ERPhost"]; $ERPport=$_POST["ERPport"]; $ERPdbname=$_POST["ERPdbname"]; $ERPusrN=$_POST["ERPusrN"]; $ERPdir=$_POST["ERPdir"]; $ERPimgdir=$_POST["ERPimgdir"]; $maxSize=$_POST["maxSize"]; $ERPftphost=$_POST["ERPftphost"]; $ERPftpuser=$_POST["ERPftpuser"]; $ERPftppwd=$_POST["ERPftppwd"]; $SHOPuser=$_POST["SHOPuser"]; $SHOPpass=$_POST["SHOPpass"]; $SHOPhost=$_POST["SHOPhost"]; $SHOPport=$_POST["SHOPport"]; $SHOPchart=$_POST["SHOPchart"]; $SHOPdbname=$_POST["SHOPdbname"]; $SHOPlang=$_POST["SHOPlang"]; $SHOPdir=$_POST["SHOPdir"]; $SHOPimgdir=$_POST["SHOPimgdir"]; $SHOPftphost=$_POST["SHOPftphost"]; $SHOPftpuser=$_POST["SHOPftpuser"]; $SHOPftppwd=$_POST["SHOPftppwd"]; $div16NR=$_POST["div16NR"]; $div07NR=$_POST["div07NR"]; $versandNR=$_POST["versandNR"]; $nachnNR=$_POST["nachnNR"]; $minderNR=$_POST["minderNR"]; $paypalNR=$_POST["paypalNR"]; $preA=$_POST["preA"]; $preK=$_POST["preK"]; $kdnum=$_POST["kdnum"]; $auftrnr=$_POST["auftrnr"]; $debug=$_POST["debug"]; $altprice=$_POST["altprice"]; $stdprice=$_POST["stdprice"]; $nopic=$_POST["nopic"]; } $ERPlangs=getERPlangs(); $CntERPLang=count($ERPlangs); //$rs[0][0]; } else { if (file_exists ("conf$login.php")) { require "conf$login.php"; } else { require "conf.php"; } $dsnP = array( 'phptype' => 'pgsql', 'username' => $ERPuser, 'password' => $ERPpass, 'hostspec' => $ERPhost, 'database' => $ERPdbname, 'port' => $ERPport ); $dbP=@DB::connect($dsnP); if (DB::isError($dbP)||!$dbP) { echo "Keine Verbindung zur ERP"; $dbP=false; //echo $dbP->userinfo; } else { //$rs=$dbP->getAll("select count(*) from language"); $ERPlangs=getERPlangs(); $CntERPLang=count($ERPlangs); //$rs[0][0]; } $dsnM = array( 'phptype' => 'mysql', 'username' => $SHOPuser, 'password' => $SHOPpass, 'hostspec' => $SHOPhost, 'database' => $SHOPdbname, 'port' => $SHOPport ); $dbM=@DB::connect($dsnM); if (DB::isError($dbM)||!$dbM) { echo "Keine Verbindung zum SHOP"; $dbM=false; //echo $dbM->userinfo; } else { $ShopDefaultLang=getShopDefault(); } } ?> "> "> "> "> "> "> "> DatenLx-ERPShop db-Host db-Port Database db-User Name db-User PWD User-ID "> onFocus="blur();"> Charset Shop: charset($SHOPchar); ?> CSV-Dir Image-Dir FTP-Host FTP-User FTP-User PWD ID Diverse 16% "> > ID Diverse 7% "> > ID Versand "> > ID Nachname "> > ID Paypal "> > ID Mindemenge "> > Sprachen Standard --> ">= $ShopDefaultLang["name"] ?> for($i=0; $i < $CntERPLang; $i++) { ?> Sprachen ">= $ERPlangs[$i]["description"] ?> --> = shoplang($Language[$i+1]["SHOP"],$ShopDefaultLang); ?> } ?> Nur übersetzte Artikel > Ja "true")?"checked":"" ?>> Nein Standardpreis pg($stdprice); ?> Defaultbild abweichender Preis pg($altprice); ?> Kundengruppe Auftragsnummern durch > LxO 1)?"checked":"" ?>> Shop Kundennummern durch > LxO 1)?"checked":"" ?>> Shop Nummernerweiterung Auftrag Kunde Logging ein> aus> } ?>