diff --git a/src/set-up-database.php b/src/set-up-database.php index b2a1d41..7b46801 100755 --- a/src/set-up-database.php +++ b/src/set-up-database.php @@ -1294,8 +1294,10 @@ function format($pMessage, $pLevel) { // XML File Writing try { - file_put_contents($lAccountXMLFilePath, $lAccountsXML); - echo format("Wrote accounts to " . $lAccountXMLFilePath, "S"); + if (is_writable(pathinfo($lAccountXMLFilePath, PATHINFO_DIRNAME))) { + file_put_contents($lAccountXMLFilePath, $lAccountsXML); + echo format("Wrote accounts to " . $lAccountXMLFilePath, "S"); + } } catch (Exception $e) { echo format("Could not write accounts XML to " . $lAccountXMLFilePath . " - " . $e->getMessage(), "W"); echo format("Using default version of accounts.xml", "W"); @@ -1303,8 +1305,10 @@ function format($pMessage, $pLevel) { // Text File Writing try { - file_put_contents($lPasswordFilePath, $lAccountsText); - echo format("Wrote accounts to " . $lPasswordFilePath, "S"); + if (is_writable(pathinfo($lPasswordFilePath, PATHINFO_DIRNAME))) { + file_put_contents($lPasswordFilePath, $lAccountsText); + echo format("Wrote accounts to " . $lPasswordFilePath, "S"); + } } catch (Exception $e) { echo format("Could not write accounts text to " . $lPasswordFilePath . " - " . $e->getMessage(), "W"); echo format("Using default version of accounts.txt", "W");