Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $port = 22003; // Define a default port to follow
- function stripAddress($address) {
- $strip_address = preg_replace("/[^A-Za-z0-9.-:]/", "", str_replace("mtasa://", "", $address)); // Take out the mtasa:// protocol from the address and remove any unwanted characters
- $straps = preg_split("/:/", $strip_address); // Strip all beginnings with a colon
- $strip = preg_replace("/[^0-9]/", "", $straps[count($straps)-1]); // Take the latter colon ending and strip everything that isn't a number
- if (strlen($strip) > 1) { $port = (integer)$strip; } // Re-define the default port with the new one
- $strip_address = str_replace((string)$port, "", preg_replace("/[^A-Za-z0-9.-]/", "", $strip_address)); // Take out the port number from the full address and remove any unwanted characters again
- return '<a href="mtasa://' . $strip_address . ':' . $port . '">mtasa://' . $strip_address . ':' . $port . '</a>'; // Glue the protocol, address and port
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement