Index: /changelog
===================================================================
--- /changelog	(revision 7768)
+++ /changelog	(revision 7769)
@@ -396,2 +396,4 @@
 - Bugfix: Technische Einstellungen in Bestellung unter "Entwickleroptionen" verschoben um Verwirrungen zu vermeiden
 - Bugfix: Ist Mindestbestellmenge einzeln aktiviert erscheint es im Reiter "Bestand / Gew. / FÃŒllm." innerhalb der Produktverwaltung / Task #745
+- Bugfix: Bei Problemen mit dem Lizenzserver werden die API Anfragen jetzt 12h pausiert (AuÃer man erzwingt die ÃberprÃŒfung im Dashbord -> Aktualisierungen -> Erneut prÃŒfen)
+- Bugfix: Der Timeout fÃŒr API Anfragen wurde generell auf 5s gesetzt
Index: /controller/wpsg_SystemController.class.php
===================================================================
--- /controller/wpsg_SystemController.class.php	(revision 7768)
+++ /controller/wpsg_SystemController.class.php	(revision 7769)
@@ -26,4 +26,6 @@
 		 
 		var $htmlMail = false;
+
+		var $api_broken = false;
 		
 		/**
@@ -144,15 +146,23 @@
 		 * @throws Exception
 		 */
-        public function get_url_post_content($url, $post_data = []) {
-	
+        public function get_url_post_content($url, $post_data = [], $timeout = false) {
+
 			if (!wpsg_checkInput($url, WPSG_SANITIZE_URL)) throw \wpsg\Exception::getSanitizeException();
-        	
-			$result = \wp_remote_post($url, [
-				'body' => http_build_query($post_data, null, '&')
-			]);
+
+			$arOptions = [
+                'body' => http_build_query($post_data, null, '&')
+            ];
+
+			if (wpsg_isSizedInt($timeout)) {
+
+			    $arOptions['timeout'] = $timeout;
+
+            }
+
+			$result = \wp_remote_post($url, $arOptions);
 
             if (is_object($result) && get_class($result) == 'WP_Error') {
 
-                throw new \wpsg\Exception($result->get_error_message());
+                throw new \Exception($result->get_error_message());
 
             } else return $result['body'];
Index: /lib/filter_functions.inc.php
===================================================================
--- /lib/filter_functions.inc.php	(revision 7768)
+++ /lib/filter_functions.inc.php	(revision 7769)
@@ -384,52 +384,63 @@
     
     }
-    
-    function wpsg_api_call($func, $arParam = array(), $key = false)
-    {
-    
-        //wpsg_debug_console('wpsgApiCall: '.$func);
-        //wpsg_debug('wpsgApiCall: '.$func);
-    
+
+    /**
+     * @param $func
+     * @param array $arParam
+     * @param false $key
+     * @return false|mixed
+     * @throws Exception
+     */
+    function wpsg_api_call($func, $arParam = array(), $key = false) {
+
+        if (wpsg_ShopController::getShop()->api_broken) return false;
+
         $plugin_data = get_plugin_data(dirname(__FILE__).'/../wpshopgermany.php');
-    
+
         if ($key === false) $key = $GLOBALS['wpsg_sc']->get_option('wpsg_key', true);
-    
-        $api_return = $GLOBALS['wpsg_sc']->get_url_post_content('https://api.maennchen1.de/', array(
-            'f' => $func,
-            'app' => 'wpsg',
-            'key' => $key,
-            'version' => $plugin_data['Version'],
-            'host' => $_SERVER['HTTP_HOST'],
-            'data' => $arParam
-        ));
-    
+
+        try {
+
+            $api_return = $GLOBALS['wpsg_sc']->get_url_post_content('https://api.maennchen1.de/', array(
+                'f' => $func,
+                'app' => 'wpsg',
+                'key' => $key,
+                'version' => $plugin_data['Version'],
+                'host' => $_SERVER['HTTP_HOST'],
+                'data' => $arParam
+            ), 5);
+
+        } catch (\Exception $e) {
+
+            wpsg_ShopController::getShop()->api_broken = true;
+
+            throw $e;
+
+        }
+
         //wpsg_debug('wpsgApiReturn: '.$func.":".$api_return);die();
-    
+
         $api_return_json = json_decode($api_return, true);
-    
+
         //wpsg_debug_console($api_return_json);
-    
-        if (wpsg_isSizedArray($api_return_json))
-        {
-    
+
+        if (wpsg_isSizedArray($api_return_json)) {
+
             // In der Antwort waren gleich aktualisierte Daten enthalten
-            if (isset($api_return_json['wpsg_update_data']['updateData']))
-            {
-    
+            if (isset($api_return_json['wpsg_update_data']['updateData'])) {
+
                 $api_return_json['wpsg_update_data']['updateData'] = (object)$api_return_json['wpsg_update_data']['updateData'];
-    
+
                 $GLOBALS['wpsg_sc']->update_option('wpsg_lastupdate', strval(time()), true, false, WPSG_SANITIZE_NONE);
                 $GLOBALS['wpsg_sc']->update_option('wpsg_updatedata', $api_return_json['wpsg_update_data'], true, false, WPSG_SANITIZE_NONE);
-    
+
                 $GLOBALS['wpsg_sc']->update_option('wp_installed', (($api_return_json['wpsg_update_data']['returnCode']  != '0')?'1':'0'));
-    
+
             }
-    
+
             return $api_return_json;
-    
-        }
-        else
-        {
-    
+
+        } else {
+
             //wpsg_debug('wpsgApiReturn: '.$func.":".$api_return);
             return false;
@@ -439,6 +450,5 @@
     }
     
-    function wpsg_get_update_data($key = false, $force = false)
-    {
+    function wpsg_get_update_data($key = false, $force = false) {
     
         if ($key === false) $key = $GLOBALS['wpsg_sc']->get_option('wpsg_key', true);
@@ -446,39 +456,46 @@
         $wpsg_lastupdate = $GLOBALS['wpsg_sc']->get_option('wpsg_lastupdate', true);
         $wpsg_update_data = $GLOBALS['wpsg_sc']->get_option('wpsg_updatedata', true);
-    
+
+        $wpsg_lastapifail = intval($GLOBALS['wpsg_sc']->get_option('wpsg_lastapifail', true));
+
         if ($force === true) $wpsg_lastupdate = false;
     
         $min = 15;
-        //a$min = 0.2;
-
-        if ($wpsg_lastupdate == false || $wpsg_lastupdate < time() - 60 * $min || !wpsg_isSizedArray($wpsg_update_data))
-        {
-    
-            try
-            {
-    
-                $wpsg_update_data_return = wpsg_api_call('checkUpdate', array(), $key);
-
-                if (wpsg_isSizedArray($wpsg_update_data_return) && isset($wpsg_update_data_return['returnCode']))
-                {
-    
-                    $wpsg_update_data = $wpsg_update_data_return;
-                    $wpsg_update_data['updateData'] = (object)$wpsg_update_data['updateData'];
-    
-                    $GLOBALS['wpsg_sc']->update_option('wpsg_lastupdate', strval(time()), true, false, WPSG_SANITIZE_NONE);
-                    $GLOBALS['wpsg_sc']->update_option('wpsg_updatedata', $wpsg_update_data, true, false, WPSG_SANITIZE_NONE);
-    
-                    $GLOBALS['wpsg_sc']->update_option('wp_installed', (($wpsg_update_data['returnCode']  != '0')?'1':'0'));
-    
+        $min_api_fail = 720;
+
+        if ($wpsg_lastapifail <= 0 || $wpsg_lastapifail < time() - 60 * $min_api_fail || isset($_REQUEST['force_check'])) {
+
+            if ($wpsg_lastupdate == false || $wpsg_lastupdate < time() - 60 * $min || !wpsg_isSizedArray($wpsg_update_data)) {
+
+                try {
+
+                    $wpsg_update_data_return = wpsg_api_call('checkUpdate', array(), $key);
+
+                    if (wpsg_isSizedArray($wpsg_update_data_return) && isset($wpsg_update_data_return['returnCode'])) {
+
+                        $wpsg_update_data = $wpsg_update_data_return;
+                        $wpsg_update_data['updateData'] = (object)$wpsg_update_data['updateData'];
+
+                        $GLOBALS['wpsg_sc']->update_option('wpsg_lastupdate', strval(time()), true, false, WPSG_SANITIZE_NONE);
+                        $GLOBALS['wpsg_sc']->update_option('wpsg_updatedata', $wpsg_update_data, true, false, WPSG_SANITIZE_NONE);
+
+                        $GLOBALS['wpsg_sc']->update_option('wp_installed', (($wpsg_update_data['returnCode']  != '0')?'1':'0'));
+
+                        $GLOBALS['wpsg_sc']->update_option('wpsg_lastapifail', '0', true, false, WPSG_SANITIZE_INT);
+
+                    }
+
+                } catch (\Exception $e) {
+
+                    \wpsg\Exceptionhandler::exception($e, false);
+
+                    $GLOBALS['wpsg_sc']->update_option('wpsg_lastapifail', strval(time()), true, false, WPSG_SANITIZE_INT);
+
+                    $GLOBALS['wpsg_sc']->addBackendError(wpsg_translate(__('Fehler: #1#', 'wpsg'), $e->getMessage()));
+
                 }
-    
+
             }
-            catch (\Exception $e)
-            {
-    
-                $GLOBALS['wpsg_sc']->addBackendError(wpsg_translate(__('Fehler: #1#', 'wpsg'), $e->getMessage()));
-    
-            }
-    
+
         }
 
Index: /lib/wpsg_exceptionhandler.class.php
===================================================================
--- /lib/wpsg_exceptionhandler.class.php	(revision 7768)
+++ /lib/wpsg_exceptionhandler.class.php	(revision 7769)
@@ -16,5 +16,5 @@
          * @param $ex
          */
-        static function exception($ex) 
+        static function exception($ex, $break = true)
         {
          
@@ -63,5 +63,5 @@
             else file_put_contents($log_file, $strLogText);
 
-            die(wpsg_debug($typeLabel.": ".$msg."\r\n".$backtrace, true));
+            if ($break) die(wpsg_debug($typeLabel.": ".$msg."\r\n".$backtrace, true));
 
         } // static function myCallbackMethod($ex)
