From 8192744aa00c11aaf63a31a711b583aabbeec2bd Mon Sep 17 00:00:00 2001 From: Rick Hays Date: Wed, 11 Sep 2019 11:36:12 -0500 Subject: [PATCH] First Commit of URL PHP Class Signed-off-by: Rick Hays --- class/url.php | 168 ++++++++++++++++++++++++++++++++++++++++++++++++ url-example.php | 59 +++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 class/url.php create mode 100644 url-example.php diff --git a/class/url.php b/class/url.php new file mode 100644 index 0000000..d7ac7fa --- /dev/null +++ b/class/url.php @@ -0,0 +1,168 @@ + 0); + return $isCrawler; + } + +} // End URL Class + diff --git a/url-example.php b/url-example.php new file mode 100644 index 0000000..8386d7d --- /dev/null +++ b/url-example.php @@ -0,0 +1,59 @@ +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; + + +