Skip to content

Commit

Permalink
Get base URL from STDIN if not in argv
Browse files Browse the repository at this point in the history
  • Loading branch information
pabzm committed Dec 10, 2024
1 parent a100606 commit d3d8cff
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bin/test-remote-access.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,21 @@ function test_dir($dir_name, $base_url)
}
}

if (!isset($argv[1]) || in_array($argv[1], ['', '-h', '--help'])) {
error('Usage: ' . basename(__FILE__) . ' your_roundcubemail_base_url');
# Get base URL from argv or STDIN.
if (isset($argv[1])) {
if (in_array($argv[1], ['', '-h', '--help'])) {
error('Usage: ' . basename(__FILE__) . ' your_roundcubemail_base_url');
}
$input = $argv[1];
} else {
print("Please enter the base URL of your Roundcubemail installation (empty cancels): ");
$input = trim(fgets(STDIN));
if ($input === '') {
error("Empty input, cancelling.");
}
}

$base_url = filter_var($argv[1], \FILTER_VALIDATE_URL);
$base_url = filter_var($input, \FILTER_VALIDATE_URL);

if ($base_url === false) {
error('⚠️ The given argument not a valid base URL!');
Expand Down

0 comments on commit d3d8cff

Please sign in to comment.