mirror of
https://github.com/e107inc/e107.git
synced 2025-04-14 09:32:17 +02:00
Cache Fixes. Core update-check fixed. Core-update via Scheduled Task fixed.
This commit is contained in:
parent
a4f3fc2886
commit
38dae889e2
@ -601,9 +601,9 @@ function update_706_to_800($type='')
|
||||
$sql2 = e107::getDb('sql2');
|
||||
$tp = e107::getParser();
|
||||
$ns = e107::getRender();
|
||||
|
||||
|
||||
e107::getCache()->clearAll('db');
|
||||
e107::getCache()->clearAll('system');
|
||||
e107::getCache()->clear_sys('Config');
|
||||
|
||||
e107::getMessage()->setUnique();
|
||||
|
||||
@ -779,7 +779,7 @@ function update_706_to_800($type='')
|
||||
|
||||
|
||||
// Move the maximum online counts from menu prefs to a separate pref - 'history'
|
||||
e107::getCache()->clearAll('system');
|
||||
e107::getCache()->clear_sys('Config');
|
||||
$menuConfig = e107::getConfig('menu',true,true);
|
||||
|
||||
if ($menuConfig->get('most_members_online') || $menuConfig->get('most_guests_online') || $menuConfig->get('most_online_datestamp'))
|
||||
@ -1184,9 +1184,7 @@ function update_706_to_800($type='')
|
||||
|
||||
// $notify_prefs = $sysprefs -> get('notify_prefs');
|
||||
// $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
|
||||
e107::getCache()->clearAll('system');
|
||||
|
||||
|
||||
e107::getCache()->clear_sys('Config');
|
||||
|
||||
$notify_prefs = e107::getConfig('notify',true,true)->getPref();
|
||||
|
||||
@ -1969,7 +1967,7 @@ function theme_foot()
|
||||
{
|
||||
$data = array('name'=>SITENAME, 'theme'=>$pref['sitetheme'], 'language'=>e_LANGUAGE, 'url'=>SITEURL, 'type'=>'upgrade');
|
||||
$base = base64_encode(http_build_query($data, null, '&'));
|
||||
$url = "https://e107.org/e-install/".$base;
|
||||
$url = "http://e107.org/e-install/".$base;
|
||||
return "<img src='".$url."' style='width:1px; height:1px;border:0' />";
|
||||
}
|
||||
|
||||
|
@ -1319,61 +1319,66 @@ Inverse 10 <span class="badge badge-inverse">10</span>
|
||||
|
||||
function sc_admin_update()
|
||||
{
|
||||
if (!ADMIN) { return ''; }
|
||||
if (!ADMIN) { return null; }
|
||||
|
||||
global $e107cache,$ns, $pref;
|
||||
if (!varset($pref['check_updates'], FALSE)) { return ''; }
|
||||
$pref = e107::getPref();
|
||||
|
||||
if (is_readable(e_ADMIN.'ver.php'))
|
||||
if(empty($pref['check_updates']))
|
||||
{
|
||||
include(e_ADMIN.'ver.php');
|
||||
return null;
|
||||
}
|
||||
|
||||
$feed = "http://sourceforge.net/export/rss2_projfiles.php?group_id=63748&rss_limit=5";
|
||||
$e107cache->CachePageMD5 = md5($e107info['e107_version']);
|
||||
$cacheTag = 'Update_core';
|
||||
|
||||
if($cacheData = $e107cache->retrieve('updatecheck', 3600, TRUE))
|
||||
if(!$cached = e107::getCache()->retrieve($cacheTag, 1440, true, true))
|
||||
{
|
||||
return $ns -> tablerender(LAN_NEWVERSION, $cacheData);
|
||||
e107::getDebug()->log("Checking for Core Update");
|
||||
$status = e107::coreUpdateAvailable();
|
||||
|
||||
if($status === false)
|
||||
{
|
||||
$status = array('status'=>'not needed');
|
||||
}
|
||||
|
||||
$cached = e107::serialize($status,'json');
|
||||
e107::getCache()->set_sys($cacheTag, $cached,true,true);
|
||||
}
|
||||
else
|
||||
{
|
||||
e107::getDebug()->log("Using Cached Core Update Data");
|
||||
|
||||
}
|
||||
|
||||
$data = e107::unserialize($cached);
|
||||
|
||||
if($data === false || isset($data['status']))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Don't check for updates if running locally (comment out the next line to allow check - but
|
||||
// remember it can cause delays/errors if its not possible to access the Internet
|
||||
if ((strpos(e_SELF,'localhost') !== FALSE) || (strpos(e_SELF,'127.0.0.1') !== FALSE)) { return ''; }
|
||||
|
||||
$xml = e107::getXml();
|
||||
|
||||
require_once(e_HANDLER."magpie_rss.php");
|
||||
|
||||
$ftext = '';
|
||||
if($rawData = $xml -> getRemoteFile($feed))
|
||||
if(e_DEBUG !== true)
|
||||
{
|
||||
$rss = new MagpieRSS( $rawData );
|
||||
list($cur_version,$tag) = explode(" ",$e107info['e107_version']);
|
||||
$c = 0;
|
||||
foreach($rss->items as $val)
|
||||
{
|
||||
$search = array((strstr($val['title'], '(')), 'e107', 'released', ' v');
|
||||
$version = trim(str_replace($search, '', $val['title']));
|
||||
|
||||
if(version_compare($version,$cur_version)==1)
|
||||
{
|
||||
$ftext = "<a rel='external' href='".$val['link']."' >e107 v".$version."</a><br />\n";
|
||||
break;
|
||||
}
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Error getting data
|
||||
$ftext = ADLAN_154;
|
||||
if ((strpos(e_SELF,'localhost') !== false) || (strpos(e_SELF,'127.0.0.1') !== false)) { return null; }
|
||||
}
|
||||
|
||||
$e107cache->set('updatecheck', $ftext, TRUE);
|
||||
if($ftext)
|
||||
{
|
||||
return $ns -> tablerender(LAN_NEWVERSION, $ftext);
|
||||
}
|
||||
|
||||
return '<ul class="core-update-available nav navbar-nav navbar-left">
|
||||
<li class="dropdown open">
|
||||
<a class="dropdown-toggle " title="Core Update Available" role="button" data-toggle="dropdown" href="#" aria-expanded="true">
|
||||
<i class="fa fa-cloud-download text-success"></i>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li class="nav-header navbar-header dropdown-header">'.e107::getParser()->lanVars(LAN_NEWVERSION,$data['version']).'</li>
|
||||
<li><a href="'.$data['url'].'" rel="external"><i class="fa fa-download" ></i> '.LAN_DOWNLOAD.'</a></li>
|
||||
<li><a href="'.$data['infourl'].'" rel="external"><i class="fa fa-file-text-o "></i> Release Notes</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Does actually the same than ADMIN_SEL_LAN
|
||||
|
@ -122,21 +122,24 @@ class ecache {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @param string $query
|
||||
* @param int $MaximumAge the time in minutes before the cache file 'expires'
|
||||
* @param Forced check if cache is disabled.
|
||||
* @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query.
|
||||
* @scope public
|
||||
*/
|
||||
* Retrieve Cache data.
|
||||
* @param $CacheTag
|
||||
* @param bool|int $MaximumAge the time in minutes before the cache file 'expires'
|
||||
* @param bool $ForcedCheck check even if cache pref is disabled.
|
||||
* @param bool $syscache set to true when checking sys cache.
|
||||
* @return string
|
||||
* @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query.
|
||||
* @scope public
|
||||
*/
|
||||
public function retrieve($CacheTag, $MaximumAge = false, $ForcedCheck = false, $syscache = false)
|
||||
{
|
||||
if(($ForcedCheck != false ) || ($syscache == false && $this->UserCacheActive) || ($syscache == true && $this->SystemCacheActive) && !e107::getParser()->checkHighlighting())
|
||||
{
|
||||
$cache_file = (isset($this) && $this instanceof ecache ? $this->cache_fname($CacheTag, $syscache) : self::cache_fname($CacheTag, $syscache));
|
||||
if (file_exists($cache_file))
|
||||
|
||||
if(file_exists($cache_file))
|
||||
{
|
||||
if ($MaximumAge != false && (filemtime($cache_file) + ($MaximumAge * 60)) < time()) {
|
||||
if ($MaximumAge !== false && (filemtime($cache_file) + ($MaximumAge * 60)) < time()) {
|
||||
unlink($cache_file);
|
||||
return false;
|
||||
}
|
||||
@ -147,13 +150,16 @@ class ecache {
|
||||
{
|
||||
$ret = substr($ret, strlen(self::CACHE_PREFIX));
|
||||
}
|
||||
else
|
||||
elseif(substr($ret,0,5) == '<?php')
|
||||
{
|
||||
$ret = substr($ret, 5); // Handle the history for now
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// e107::getDebug()->log("Couldn't find cache file: ".json_encode($cache_file));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -234,6 +240,7 @@ class ecache {
|
||||
*/
|
||||
public function clear($CacheTag = '', $syscache = false, $related = false)
|
||||
{
|
||||
|
||||
$file = ($CacheTag) ? preg_replace("#\W#", "_", $CacheTag)."*.cache.php" : "*.cache.php";
|
||||
e107::getEvent()->triggerAdminEvent('cache_clear', "cachetag=$CacheTag&file=$file&syscache=$syscache");
|
||||
$ret = self::delete(e_CACHE_CONTENT, $file, $syscache);
|
||||
@ -255,6 +262,8 @@ class ecache {
|
||||
*/
|
||||
function clear_sys($CacheTag = '', $related = false)
|
||||
{
|
||||
|
||||
|
||||
if(isset($this) && $this instanceof ecache)
|
||||
{
|
||||
return $this->clear($CacheTag, true, $related);
|
||||
|
@ -67,80 +67,27 @@ class _system_cron
|
||||
*/
|
||||
function checkCoreUpdate () // Check if there is an e107 Core update and email Site Admin if so
|
||||
{
|
||||
// Check if there's a core e107 update available
|
||||
|
||||
// Get site version
|
||||
if (is_readable(e_ADMIN."ver.php"))
|
||||
{
|
||||
include (e_ADMIN."ver.php"); // $e107info['e107_version'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find alternate way to get local site version or throw an error
|
||||
}
|
||||
|
||||
// Check for updates for currently installed version
|
||||
$localVersion = (int) $e107info['e107_version'];
|
||||
|
||||
switch ($localVersion) {
|
||||
case 0:
|
||||
// Local version is <= 0.7
|
||||
// Run update routine for 0.x
|
||||
break;
|
||||
case 1:
|
||||
// Local version is == 1.x
|
||||
// Run update routine for 1.x
|
||||
break;
|
||||
case 2:
|
||||
// Local version is == 2.x
|
||||
// Run update routine for 2.x
|
||||
|
||||
// Get newest available release version
|
||||
$xml = e107::getXml();
|
||||
$file = "http://e107.org/releases.php?mode=2";
|
||||
$xdata = $xml->loadXMLfile($file,true,false);
|
||||
|
||||
// Check for update
|
||||
if ($e107info['e107_version'] < $xdata['core']['@attributes']['version'])
|
||||
{
|
||||
// If there is a new version of e107 available, notify Site Admin by email, make a log entry, and notify Admin in Admin Area, $versionTest = false
|
||||
|
||||
$pref = e107::getPref();
|
||||
require_once(e_HANDLER.'mail.php');
|
||||
$message = "There is a new version of e107 available. Please visit http://www.e107.org for further details.";
|
||||
sendemail($pref['siteadminemail'], "e107 - Update(s) Available For " . $pref['sitename'], $message, $pref['siteadmin'],$pref['siteadminemail'], $pref['siteadmin']);
|
||||
|
||||
// Add entry to the log
|
||||
e107::getAdminLog()->add("Update(s) Available", "There is a new version of e107 available. Please visit http://www.e107.org for further details.", 3);
|
||||
|
||||
$versionTest = $xdata['core']['@attributes']['version'];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// If there is not a new version of e107 available, $versionTest = false
|
||||
$versionTest = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//$versionTest = "{CHECK THE VERSION}"; // If out of date, return some text, if up-to-date , return false;
|
||||
|
||||
$che = e107::getCache();
|
||||
$che->setMD5(e_LANGUAGE);
|
||||
|
||||
if($versionTest)
|
||||
{
|
||||
$che->set("releasecheck",$versionTest, TRUE);
|
||||
return $versionTest;
|
||||
// e107::getMessage()=>addInfo($versionTest);
|
||||
}
|
||||
else
|
||||
{
|
||||
$che->set("releasecheck", 'false', TRUE);
|
||||
return false;
|
||||
}
|
||||
if(!$data = e107::coreUpdateAvailable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
$message = "<p>There is a new version of e107 available.<br />
|
||||
Please visit ".$data['infourl']." for further details.</p>
|
||||
<a class='btn btn-primary' href=''>Download v".$data['version']."</a>";
|
||||
|
||||
$eml = array(
|
||||
'subject' => "e107 v".$data['version']." is now available.",
|
||||
'sender_name' => SITENAME . " Automation",
|
||||
'html' => true,
|
||||
'template' => 'default',
|
||||
'body' => $message
|
||||
);
|
||||
|
||||
e107::getEmail()->sendEmail($pref['siteadminemail'], $pref['siteadmin'], $eml);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -4495,4 +4495,66 @@ class e107
|
||||
self::$_registry = null;
|
||||
self::$_instance = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if there's a core e107 release available
|
||||
* @return array|bool - return array of data or false if no update available.
|
||||
*/
|
||||
public static function coreUpdateAvailable()
|
||||
{
|
||||
|
||||
// Get site version
|
||||
$e107info= array();
|
||||
|
||||
if(is_readable(e_ADMIN."ver.php"))
|
||||
{
|
||||
include(e_ADMIN."ver.php"); // $e107info['e107_version'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$xml = e107::getXml();
|
||||
$file = "https://e107.org/releases.php";
|
||||
if(!$xdata = $xml->loadXMLfile($file,true,false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$curVersion = str_replace(' (git)', '', $e107info['e107_version']);
|
||||
|
||||
if(empty($xdata['core'][0]['@attributes']['version']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$newVersion = $xdata['core'][0]['@attributes']['version'];
|
||||
}
|
||||
|
||||
|
||||
e107::getDebug()->log("New Version:".$newVersion);
|
||||
|
||||
if(version_compare($curVersion,$newVersion) === -1)
|
||||
{
|
||||
$data = array(
|
||||
'name' => $xdata['core'][0]['@attributes']['name'],
|
||||
'url' => $xdata['core'][0]['@attributes']['url'],
|
||||
'date' => $xdata['core'][0]['@attributes']['date'],
|
||||
'version' => $xdata['core'][0]['@attributes']['version'],
|
||||
'infourl' => $xdata['core'][0]['@attributes']['infourl'],
|
||||
'description' => $xdata['core'][0]['description'],
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ define("LAN_CONFIGURE", "Configure");
|
||||
define("LAN_NOPERMISSION", "no permissions");
|
||||
|
||||
define("LAN_CREDITS","Credits");
|
||||
define("LAN_NEWVERSION","New Version Available");
|
||||
define("LAN_NEWVERSION","e107 v[x] Available");
|
||||
|
||||
define("LAN_CHECKALL", "Check All");
|
||||
define("LAN_UNCHECKALL", "Uncheck All");
|
||||
|
@ -1282,6 +1282,12 @@ li.after-submit:hover { background-color: #337AB7; color:white }
|
||||
.admin-left-panel .panel-title span { display: inline-block; vertical-align: middle; color:white;text-shadow:0 1px 1px #000}
|
||||
.admin-left-panel .panel-title .S24, .admin-left-panel .panel-title img { margin-right:6px; width:24px; height:24px; vertical-align:middle}
|
||||
|
||||
|
||||
ul.core-update-available li a.dropdown-toggle i { opacity:1; color:white; transition: none; !important}
|
||||
ul.core-update-available li { color: white }
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
body { background-color: rgb(68, 68, 68); }
|
||||
|
@ -253,6 +253,7 @@ $ADMIN_HEADER = $ADMIN_MODAL . '
|
||||
{ADMIN_NAVIGATION=home}
|
||||
{ADMIN_PM}
|
||||
{ADMIN_DEBUG}
|
||||
{ADMIN_UPDATE}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -276,7 +277,7 @@ else
|
||||
<div class="col-md-3 col-lg-2 admin-left-panel">
|
||||
{SETSTYLE=admin_menu}
|
||||
{ADMIN_MENU}
|
||||
|
||||
|
||||
{ADMIN_PWORD}
|
||||
{ADMIN_MENUMANAGER}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user