]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/ServerBlock.php
Issue 9657: Check the age of an item
[friendica.git] / src / Console / ServerBlock.php
index 40d8e45e74ba7180d2afb6daf7ee8d3b30ceea65..4d8c930c58963754efa92d91519ee10cad0fc5a5 100644 (file)
@@ -112,6 +112,9 @@ HELP;
                $filename = $this->getArgument(1);
                $blocklist = $config->get('system', 'blocklist', []);
                $fp = fopen($filename, 'w');
+               if (!$fp) {
+                       throw new Exception(sprintf('The file "%s" could not be created.', $filename));
+               }
                foreach ($blocklist as $domain) {
                        fputcsv($fp, $domain);
                }
@@ -141,12 +144,12 @@ HELP;
                                ];
                                if (!in_array($data, $newBlockList)) {
                                        $newBlockList[] = $data;
-                }
+                               }
                        }
                        foreach ($currBlockList as $blocked) {
                                if (!in_array($blocked, $newBlockList)) {
                                        $newBlockList[] = $blocked;
-                }
+                               }
                        }
                        if ($config->set('system', 'blocklist', $newBlockList)) {
                                $this->out(sprintf("Entries from %s that were not blocked before are now blocked", $filename));
@@ -156,13 +159,15 @@ HELP;
                                return 1;
                        }
 
+               } else {
+                       throw new Exception(sprintf('The file "%s" could not be opened for importing', $filename));
                }
        }
 
        /**
         * Prints the whole list of blocked domains including the reason
         *
-        /* @param IConfig $config
+        * @param IConfig $config
         */
        private function printBlockedServers(IConfig $config)
        {