Moved urlExist to file helper class.

This commit is contained in:
2022-06-11 19:11:00 +02:00
parent 9f04566c81
commit 9e4a6e0c53
9 changed files with 74 additions and 96 deletions

View File

@@ -143,11 +143,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 2nd June, 2022
+ *Last Build*: 11th June, 2022
+ *Version*: 2.13.1
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **287278**
+ *Line count*: **287256**
+ *Field count*: **1581**
+ *File count*: **1853**
+ *Folder count*: **261**

View File

@@ -140,13 +140,9 @@
name="github_access_token"
label="COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_LABEL"
size="128"
default="secret"
description="COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_DESCRIPTION"
message="Error! Please add token here."
class="text_area"
readonly="false"
disabled="false"
required="false"
filter="STRING"
hint="COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_HINT"
autocomplete="off"

View File

@@ -3705,49 +3705,6 @@ abstract class ComponentbuilderHelper
}
/**
* Check if the url exist
*
* @param string $url The url to check
*
* @return bool If exist true
*
*/
public static function urlExists($url)
{
$exists = false;
// check if we can use curl
if (function_exists('curl_version'))
{
// initiate curl
$ch = curl_init($url);
// CURLOPT_NOBODY (do not return body)
curl_setopt($ch, CURLOPT_NOBODY, true);
// make call
$result = curl_exec($ch);
// check return value
if ($result !== false)
{
// get the http CODE
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode !== 404)
{
$exists = true;
}
}
// close the connection
curl_close($ch);
}
elseif ($headers = @get_headers($url))
{
if(isset($headers[0]) && is_string($headers[0]) && strpos($headers[0],'404') === false)
{
$exists = true;
}
}
return $exists;
}
/**
* Get the file path or url
*