Updated plugins, summer cleanup
This commit is contained in:
parent
8f310a5df4
commit
da71a8c9e9
2 changed files with 74 additions and 97 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
class YellowCommand
|
||||
{
|
||||
const VERSION = "0.7.5";
|
||||
const VERSION = "0.7.6";
|
||||
var $yellow; //access to API
|
||||
var $files; //number of files
|
||||
var $links; //number of links
|
||||
|
@ -333,50 +333,44 @@ class YellowCommand
|
|||
{
|
||||
$statusCode = 200;
|
||||
$broken = $redirect = $data = array();
|
||||
if(extension_loaded("curl"))
|
||||
$staticUrl = $this->yellow->config->get("staticUrl");
|
||||
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
|
||||
$staticLocations = $this->getContentLocations(true);
|
||||
uksort($links, "strnatcasecmp");
|
||||
foreach($links as $url=>$value)
|
||||
{
|
||||
$staticUrl = $this->yellow->config->get("staticUrl");
|
||||
list($scheme, $address, $base) = $this->yellow->lookup->getUrlInformation($staticUrl);
|
||||
$staticLocations = $this->getContentLocations(true);
|
||||
uksort($links, "strnatcasecmp");
|
||||
foreach($links as $url=>$value)
|
||||
if(defined("DEBUG") && DEBUG>=1) echo "YellowCommand::analyseLinks url:$url\n";
|
||||
if(preg_match("#^$staticUrl#", $url))
|
||||
{
|
||||
if(defined("DEBUG") && DEBUG>=1) echo "YellowCommand::analyseLinks url:$url\n";
|
||||
if(preg_match("#^$staticUrl#", $url))
|
||||
$location = substru($url, 32);
|
||||
$fileName = $path.substru($url, 32);
|
||||
if(is_readable($fileName)) continue;
|
||||
if(in_array($location, $staticLocations)) continue;
|
||||
}
|
||||
if(preg_match("/^(http|https):/", $url))
|
||||
{
|
||||
$referer = "$scheme://$address".(($pos = strposu($value, ',')) ? substru($value, 0, $pos) : $value);
|
||||
$statusCodeUrl = $this->getLinkStatus($url, $referer);
|
||||
if($statusCodeUrl!=200)
|
||||
{
|
||||
$location = substru($url, 32);
|
||||
$fileName = $path.substru($url, 32);
|
||||
if(is_readable($fileName)) continue;
|
||||
if(in_array($location, $staticLocations)) continue;
|
||||
}
|
||||
if(preg_match("/^(http|https):/", $url))
|
||||
{
|
||||
$referer = "$scheme://$address".(($pos = strposu($value, ',')) ? substru($value, 0, $pos) : $value);
|
||||
$statusCodeUrl = $this->getLinkStatus($url, $referer);
|
||||
if($statusCodeUrl!=200)
|
||||
{
|
||||
$statusCode = max($statusCode, $statusCodeUrl);
|
||||
$data[$url] = "$statusCodeUrl,$value";
|
||||
}
|
||||
$statusCode = max($statusCode, $statusCodeUrl);
|
||||
$data[$url] = "$statusCodeUrl,$value";
|
||||
}
|
||||
}
|
||||
foreach($data as $url=>$value)
|
||||
}
|
||||
foreach($data as $url=>$value)
|
||||
{
|
||||
$locations = preg_split("/\s*,\s*/", $value);
|
||||
$statusCodeUrl = array_shift($locations);
|
||||
foreach($locations as $location)
|
||||
{
|
||||
$locations = preg_split("/\s*,\s*/", $value);
|
||||
$statusCodeUrl = array_shift($locations);
|
||||
foreach($locations as $location)
|
||||
{
|
||||
if($statusCodeUrl==302) continue;
|
||||
if($statusCodeUrl>=300 && $statusCodeUrl<=399) {
|
||||
$redirect["$scheme://$address$location -> $url - ".$this->getStatusFormatted($statusCodeUrl)] = $statusCodeUrl;
|
||||
} else {
|
||||
$broken["$scheme://$address$location -> $url - ".$this->getStatusFormatted($statusCodeUrl)] = $statusCodeUrl;
|
||||
}
|
||||
if($statusCodeUrl==302) continue;
|
||||
if($statusCodeUrl>=300 && $statusCodeUrl<=399) {
|
||||
$redirect["$scheme://$address$location -> $url - ".$this->getStatusFormatted($statusCodeUrl)] = $statusCodeUrl;
|
||||
} else {
|
||||
$broken["$scheme://$address$location -> $url - ".$this->getStatusFormatted($statusCodeUrl)] = $statusCodeUrl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$statusCode = 500;
|
||||
echo "ERROR checking links: Plugin 'command' requires cURL library!\n";
|
||||
}
|
||||
return array($statusCode, $broken, $redirect);
|
||||
}
|
||||
|
@ -646,21 +640,16 @@ class YellowCommand
|
|||
// Return link status
|
||||
function getLinkStatus($url, $referer)
|
||||
{
|
||||
if(extension_loaded("curl"))
|
||||
{
|
||||
$curlHandle = curl_init();
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $url);
|
||||
curl_setopt($curlHandle, CURLOPT_REFERER, $referer);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; DatenstromYellow/".YellowCore::VERSION."; LinkChecker)");
|
||||
curl_setopt($curlHandle, CURLOPT_NOBODY, 1);
|
||||
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_exec($curlHandle);
|
||||
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
||||
curl_close($curlHandle);
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowCommand::getLinkStatus status:$statusCode url:$url<br/>\n";
|
||||
} else {
|
||||
$statusCode = 500;
|
||||
}
|
||||
$curlHandle = curl_init();
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $url);
|
||||
curl_setopt($curlHandle, CURLOPT_REFERER, $referer);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; DatenstromYellow/".YellowCore::VERSION."; LinkChecker)");
|
||||
curl_setopt($curlHandle, CURLOPT_NOBODY, 1);
|
||||
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_exec($curlHandle);
|
||||
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
||||
curl_close($curlHandle);
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowCommand::getLinkStatus status:$statusCode url:$url<br/>\n";
|
||||
return $statusCode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class YellowUpdate
|
||||
{
|
||||
const VERSION = "0.7.12";
|
||||
const VERSION = "0.7.13";
|
||||
var $yellow; //access to API
|
||||
var $updates; //number of updates
|
||||
|
||||
|
@ -639,22 +639,17 @@ class YellowUpdate
|
|||
// Check web server rewrite
|
||||
function checkServerRewrite($scheme, $address, $base, $location, $fileName)
|
||||
{
|
||||
$ok = true;
|
||||
if(extension_loaded("curl"))
|
||||
{
|
||||
$curlHandle = curl_init();
|
||||
$location = $this->yellow->config->get("assetLocation").$this->yellow->page->get("theme").".css";
|
||||
$url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $url);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowCore/".YellowCore::VERSION).")";
|
||||
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
$rawData = curl_exec($curlHandle);
|
||||
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
||||
curl_close($curlHandle);
|
||||
if(empty($rawData) || $statusCode!=200) $ok = false;
|
||||
}
|
||||
return $ok;
|
||||
$curlHandle = curl_init();
|
||||
$location = $this->yellow->config->get("assetLocation").$this->yellow->page->get("theme").".css";
|
||||
$url = $this->yellow->lookup->normaliseUrl($scheme, $address, $base, $location);
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $url);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; YellowCore/".YellowCore::VERSION).")";
|
||||
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
$rawData = curl_exec($curlHandle);
|
||||
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
||||
curl_close($curlHandle);
|
||||
return !empty($rawData) && $statusCode==200;
|
||||
}
|
||||
|
||||
// Return raw data for installation page
|
||||
|
@ -802,38 +797,31 @@ class YellowUpdate
|
|||
// Return software file
|
||||
function getSoftwareFile($url)
|
||||
{
|
||||
$fileData = "";
|
||||
if(extension_loaded("curl"))
|
||||
$urlRequest = $url;
|
||||
if(preg_match("#^https://github.com/(.+)/raw/(.+)$#", $url, $matches))
|
||||
{
|
||||
$urlRequest = $url;
|
||||
if(preg_match("#^https://github.com/(.+)/raw/(.+)$#", $url, $matches))
|
||||
{
|
||||
$urlRequest = "https://raw.githubusercontent.com/".$matches[1]."/".$matches[2];
|
||||
}
|
||||
$curlHandle = curl_init();
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $urlRequest);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; DatenstromYellow/".YellowCore::VERSION."; SoftwareUpdater)");
|
||||
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
$rawData = curl_exec($curlHandle);
|
||||
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
||||
curl_close($curlHandle);
|
||||
if($statusCode==200)
|
||||
{
|
||||
$fileData = $rawData;
|
||||
} else if($statusCode==0) {
|
||||
$statusCode = 500;
|
||||
list($scheme, $address) = $this->yellow->lookup->getUrlInformation($url);
|
||||
$this->yellow->page->error($statusCode, "Can't connect to server '$scheme://$address'!");
|
||||
} else {
|
||||
$statusCode = 500;
|
||||
$this->yellow->page->error($statusCode, "Can't download file '$url'!");
|
||||
}
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::getSoftwareFile status:$statusCode url:$url<br/>\n";
|
||||
$urlRequest = "https://raw.githubusercontent.com/".$matches[1]."/".$matches[2];
|
||||
}
|
||||
$curlHandle = curl_init();
|
||||
curl_setopt($curlHandle, CURLOPT_URL, $urlRequest);
|
||||
curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; DatenstromYellow/".YellowCore::VERSION."; SoftwareUpdater)");
|
||||
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
$rawData = curl_exec($curlHandle);
|
||||
$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
|
||||
curl_close($curlHandle);
|
||||
if($statusCode==200)
|
||||
{
|
||||
$fileData = $rawData;
|
||||
} else if($statusCode==0) {
|
||||
$statusCode = 500;
|
||||
list($scheme, $address) = $this->yellow->lookup->getUrlInformation($url);
|
||||
$this->yellow->page->error($statusCode, "Can't connect to server '$scheme://$address'!");
|
||||
} else {
|
||||
$statusCode = 500;
|
||||
$this->yellow->page->error($statusCode, "Plugin 'update' requires cURL library!");
|
||||
$this->yellow->page->error($statusCode, "Can't download file '$url'!");
|
||||
}
|
||||
if(defined("DEBUG") && DEBUG>=2) echo "YellowUpdate::getSoftwareFile status:$statusCode url:$url<br/>\n";
|
||||
return array($statusCode, $fileData);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue