Last active
December 8, 2024 22:53
-
-
Save cliffordp/8473186110d6274d6bc6552a22cdfd24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
// Do NOT USE OPENING <?php TAG IN ALFRED APP | |
// | |
/** | |
* Open 1 or more (comma or new line separated) IP Addresses from selection. | |
* | |
* @link https://github.com/cliffordp/alfred-app-workflows Download this Alfred App Workflow's code (and more). | |
* @link https://gist.github.com/cliffordp/ This Alfred App Workflow's code snippet. | |
*/ | |
// Base URL for DNS checker | |
$url_base = 'https://dnschecker.org/ip-location.php?ip='; | |
// Turn New Lines into commas | |
$query = str_replace(PHP_EOL, ',', "{query}"); | |
// Convert Query to array | |
if (false === strpos($query, ',')) { | |
$array = array($query); | |
} else { | |
$array = explode(',', $query); | |
} | |
// Open each URL | |
foreach ($array as $key => $value) { | |
$value = preg_replace('/\s/', '', $value); // remove any whitespace | |
if ($value !== '') { | |
system('open "' . $url_base . $value . '"'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment