Plugin version and updates

This commit is contained in:
Diego Najar 2017-06-29 22:13:25 +02:00
parent b1b0d6013d
commit a4e143151d
5 changed files with 26 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
bl-content/*
bl-plugins/timemachine
bl-kernel/bludit.pro.php

View File

@ -187,6 +187,11 @@ include(PATH_HELPERS.'paginator.class.php');
include(PATH_HELPERS.'image.class.php');
include(PATH_HELPERS.'tcp.class.php');
// Include Bludit PRO
if( file_exists(PATH_KERNEL.'bludit.pro.php') ) {
include(PATH_KERNEL.'bludit.pro.php');
}
// Session
Session::start();
if(Session::started()===false) {

View File

@ -54,4 +54,8 @@ class Filesystem {
return unlink($filename);
}
public static function fileExists($filename)
{
return file_exists($filename);
}
}

View File

@ -2,7 +2,7 @@
class TCP {
public static function http($url, $method='GET', $verifySSL=true)
public static function http($url, $method='GET', $verifySSL=true, $timeOut=1)
{
if( function_exists('curl_version') ) {
$ch = curl_init();
@ -10,6 +10,8 @@ class TCP {
// TRUE to include the header in the output
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verifySSL);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeOut);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeOut);
if($method=='POST') {
curl_setopt($ch, CURLOPT_POST, true);
}
@ -22,7 +24,8 @@ class TCP {
else {
$options = array(
'http'=>array(
'method'=>$method
'method'=>$method,
'timeout'=>$timeOut
),
"ssl"=>array(
"verify_peer"=>$verifySSL,

View File

@ -28,18 +28,22 @@ class pluginVersion extends Plugin {
{
global $ADMIN_CONTROLLER;
$timeToCheck = time() + 10;
if( ($ADMIN_CONTROLLER=='dashboard') && (Session::get('timeToCheck')>$timeToCheck) ) {
//$versions = $this->getVersion();
$versions = array('latest'=>'2.1');
Session::set('timeToCheck', $timeToCheck);
$timeToCheck = Session::get('timeToCheck') + 10*60;
if( ($ADMIN_CONTROLLER=='dashboard') && ($timeToCheck<time()) ) {
$versions = $this->getVersion();
$versions = array('latest'=>'2.0');
Session::set('timeToCheck', time());
Session::set('latestVersion', $versions['latest']);
}
if( version_compare(Session::get('latestVersion'), BLUDIT_VERSION, '>') ) {
$html = '<div id="plugin-version"><a href="https://www.bludit.com">New version available</a></div>';
} else {
$html = '<div id="plugin-version">Bludit v'.BLUDIT_VERSION.'<a href="">Upgrade to Bludit PRO</a></div>';
if(BLUDIT_PRO) {
$html = '<div id="plugin-version">Bludit PRO v'.BLUDIT_VERSION.'</div>';
} else {
$html = '<div id="plugin-version">Bludit v'.BLUDIT_VERSION.'<a href="">Upgrade to Bludit PRO</a></div>';
}
}
return $html;
@ -48,12 +52,11 @@ class pluginVersion extends Plugin {
private function getVersion()
{
$url = 'https://version.bludit.com';
$output = TCP::http($url);
$json = json_decode($output, true);
if(empty($json)) {
return array('version'=>'');
return array('latest'=>'');
}
return $json;