diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d449d3e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0115355 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# URL Class + +Set of class functions I use from time to time. + +1. isValidURL - Returns TRUE/FALSE if the string is a Valid URL +2. stripWWW - Strips the WWW off the incoming URL +3. getDomainName - Strips the WWW off the incoming URL +4. Status_Code - Returns the Status Code of a URL ie(200 or 404) +5. FavIcon - Get an image object of the FavIcon, Returns (T/F) if present +6. Save_FavIcon - Saves the Websites FavIcon to the File/Path +7. GetParam - Returns a Form Value +8. isMobileDevice - Tests the User Agent to see if it is a mobile device +9. isSpiderBot - Tests the User Agent to see if it is a Bot/Spider/Crawler + +Quick Example +----- +**url-example.php** + +``` +isValidURL('https://www.rick.us') ? 'TRUE' : 'FALSE') . '
'; + +// -- stripWWW --------------------------------- +// Strips off everything but the domain name. + echo $url->stripWWW('https://www.rhays.us') . '
'; + +// -- getDomainName ---------------------------- + echo $url->getDomainName('https://www.rhays.us') . '
'; + +// -- Return Status from URL ------------------- +// Returns current html status code for site (2xx, 3xx, 4xx, 5xx). + echo $url->Status_Code('https://www.rick.us') . '
'; + +// -- Does site have a FavIcon (T/F) ----------- +// Returns a True/False if site has a favicon present. + echo ($url->FavIcon('https://www.rick.us') ? 'TRUE' : 'FALSE') . '
'; + +// -- Save and Display favicon Image (T/F) ----- +// Saves the favicon as a PNG image to location of your choice. + echo ($url->Save_FavIcon('https://www.rick.us', 'favicon.png') ? 'TRUE' : 'FALSE') . '
'; + echo 'FavIcon'; + echo '
'; + +// -- Display current user agent --------------- + echo $_SERVER['HTTP_USER_AGENT'] . '
'; + +// -- isMobileDevice --------------------------- + echo ($url->isMobileDevice() ? 'TRUE' : 'FALSE') . '
'; + +// -- isSpiderBot ------------------------------ + echo ($url->isSpiderBot() ? 'TRUE' : 'FALSE') . '
'; + +// -- Returns the GET/POST param value else returns a default value + $_GET['TEST-GET'] = 'TEST GET'; + var_dump($_GET); + echo '
'; + $_POST['TEST-POST'] = 'TEST POST'; + $_POST['TEST-DEFAULT'] = NULL; + var_dump($_POST); + echo '
'; + + echo $url->GetParam('TEST-GET', 'No Data') . '
'; + echo $url->GetParam('TEST-POST', 'No Data') . '
'; + echo $url->GetParam('TEST-DEFAULT', 'DEFAULT') . '
'; + // =================================================== + +$url = null; + +``` \ No newline at end of file