$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);
}
];
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));
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)
{