Parameter frü Cli-Aufruf angepasst
authorHolger Lindemann <hli@lenny.hoch.ul>
Tue, 19 Jun 2012 12:12:32 +0000 (14:12 +0200)
committerHolger Lindemann <hli@lenny.hoch.ul>
Tue, 19 Jun 2012 12:12:32 +0000 (14:12 +0200)
peppershop/ArtikelErpToShop.php
peppershop/ArtikelShopToErp.php
peppershop/BestellungShopToErp.php

index ff8a56a..087e207 100644 (file)
@@ -11,14 +11,23 @@ if ( $api != "cli" ) {
     $shopnr = $_GET["Shop"];
     $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
 } else {
+    $p = array('shopnr','nofiles');
     if ( $argc > 1 ) {
-        $tmp = explode("=",trim($argv[1]));
-        if ( count($tmp) != 2 ) {
-            echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
-            exit (-1);
-        } else {
-            $shopnr = $tmp[1];
+        for( $i=1; $i<count($argv); $i++)  {
+                $tmp = explode("=",trim($argv[$i]));
+                if ( count($tmp) < 2 ) {
+                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
+                    exit (-1);
+                };
+                if ( ! in_array(strtolower($tmp[0]),$p) ) {
+                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
+                    exit (-1);
+                };
+                ${$tmp[0]} = trim($tmp[1]);
         }
+    } else {
+        $shopnr=false;
+        $nofiles=false;
     }
 }
 
@@ -46,7 +55,8 @@ if ($erpdb->db->connected_database_name == $ERPdbname) {
     exit();
 }
 //Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err);
+$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
+
 if ($shopdb->db->connected_database_name == $SHOPdbname) {
      $shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr,$pict,$nopic,$nopicerr,$nofiles);
 } else {
index d7b4d1e..173e2fa 100644 (file)
@@ -11,14 +11,23 @@ if ( $api != "cli" ) {
     $shopnr = $_GET["Shop"];
     $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
 } else {
+    $p = array('shopnr','nofiles');
     if ( $argc > 1 ) {
-        $tmp = explode("=",trim($argv[1]));
-        if ( count($tmp) != 2 ) {
-             echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
-             exit (-1);
-         } else {
-              $shopnr = $tmp[1];
-         }
+        for( $i=1; $i<count($argv); $i++)  {
+                $tmp = explode("=",trim($argv[$i]));
+                if ( count($tmp) < 2 ) {
+                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
+                    exit (-1);
+                };
+                if ( ! in_array(strtolower($tmp[0]),$p) ) {
+                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
+                    exit (-1);
+                };
+                ${$tmp[0]} = trim($tmp[1]);
+        }
+    } else {
+        $shopnr=false;
+        $nofiles=false;
     }
 }
 
index b0e1d74..6031024 100644 (file)
@@ -11,21 +11,30 @@ if ( $api != "cli" ) {
     $shopnr = $_GET["Shop"];
     $nofiles = ( $_GET["nofiles"] == '1' )?true:false;
 } else {
+    $p = array('shopnr','nofiles');
     if ( $argc > 1 ) {
-        $tmp = explode("=",trim($argv[1]));
-        if ( count($tmp) != 2 ) {
-            echo "Falscher Aufruf: php <scriptname.php> shop=1\n";
-            exit (-1);
-        } else {
-             $shopnr = $tmp[1];
+        for( $i=1; $i<count($argv); $i++)  {
+                $tmp = explode("=",trim($argv[$i]));
+                if ( count($tmp) < 2 ) {
+                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
+                    exit (-1);
+                };
+                if ( ! in_array(strtolower($tmp[0]),$p) ) {
+                    echo "Falscher Aufruf: php ArtikelErpToShop.php shopnr=1 [nofiles=1]\n";
+                    exit (-1);
+                };
+                ${$tmp[0]} = trim($tmp[1]);
         }
+    } else {
+        $shopnr=false;
+        $nofiles=false;
     }
 }
 
 include_once("conf$shopnr.php");
 include_once("error.php");
 //Fehlerinstanz
-$err = new error();
+$err = new error($api);
 
 include_once("dblib.php");
 include_once("pepper.php");
@@ -43,7 +52,7 @@ if ($erpdb->db->connected_database_name == $ERPdbname) {
 }
 
 //Shop-Instanz
-$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err);
+$shopdb = new mydb($SHOPhost,$SHOPdbname,$SHOPuser,$SHOPpass,$SHOPport,'mysql',$err,$debug);
 if ($shopdb->db->connected_database_name == $SHOPdbname) {
      $shop = new pepper($shopdb,$err,$SHOPdbname,$divStd,$divVerm,$minder,$nachn,$versandS,$versandV,$paypal,$treuhand,$mwstLX,$mwstS,$variantnr);
 //echo "<pre>"; print_r($shopdb->db); print_r($shopnr); echo "</pre>";