Skip to content

Commit

Permalink
FIX: Check for cURL
Browse files Browse the repository at this point in the history
- resolves #45
  • Loading branch information
aljawaid committed Apr 15, 2023
1 parent 61a3d10 commit 98d5b4d
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions Helper/PluginManagerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,36 @@ public function isNotInstallable(array $plugin)

public function lastUpdatedDirectory()
{
// https://www.appsloveworld.com/php/12/get-the-last-modified-date-of-a-remote-file
$curl = curl_init(PLUGIN_API_URL);
$curlCheck = $this->httpClient->backend();

//don't fetch the actual page, you only want headers
curl_setopt($curl, CURLOPT_NOBODY, true);

//stop it from outputting stuff to stdout
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if ($curlCheck == 'cURL') {
// https://www.appsloveworld.com/php/12/get-the-last-modified-date-of-a-remote-file
$curl = curl_init(PLUGIN_API_URL);

// attempt to retrieve the modification date
curl_setopt($curl, CURLOPT_FILETIME, true);
//don't fetch the actual page, you only want headers
curl_setopt($curl, CURLOPT_NOBODY, true);

$result = curl_exec($curl);
//stop it from outputting stuff to stdout
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

if ($result === false) {
die (curl_error($curl));
}
// attempt to retrieve the modification date
curl_setopt($curl, CURLOPT_FILETIME, true);

$result = curl_exec($curl);

if ($result === false) {
die (curl_error($curl));
}

$timestamp = curl_getinfo($curl, CURLINFO_FILETIME);
$timestamp = curl_getinfo($curl, CURLINFO_FILETIME);

if ($timestamp != -1) { //otherwise unknown
return date("d F Y H:i", $timestamp); //etc
if ($timestamp != -1) { //otherwise unknown
return date("d F Y H:i", $timestamp); //etc
}

} else {
return t('Not Available');
}
}
}

0 comments on commit 98d5b4d

Please sign in to comment.