From 595efb141fdda1f36498d9814b715cdb35d79bb7 Mon Sep 17 00:00:00 2001 From: jburns131 Date: Sun, 12 May 2013 02:16:03 -0400 Subject: [PATCH] Issues Addressed: Created cron task that will check if there is a newer version of e107 available. If so, email site admin, create log entry and trigger message for site admin Files altered: e107_admin\cron.php e107_handlers\cron_class.php e107_languages\English\admin\lan_cron.php Related to: https://github.com/e107inc/e107/commit/20cb65f53936155210ab75475ff1f5f59d1f71b1 --- e107_admin/cron.php | 14 ++++ e107_handlers/cron_class.php | 78 ++++++++++++++++++++++- e107_languages/English/admin/lan_cron.php | 5 ++ 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/e107_admin/cron.php b/e107_admin/cron.php index 44b71bbcd..0af31cbbe 100644 --- a/e107_admin/cron.php +++ b/e107_admin/cron.php @@ -155,6 +155,20 @@ class cron_admin_ui extends e_admin_ui 'description' => LAN_CRON_05_2 .' '.e_SYSTEM.'backups/' // 'available' => e107::getPref('ban_retrigger') ), + 5 => array( + 'name' => LAN_CRON_06_1, + 'category' => 'user', + 'function' => 'procBanRetrigger', + 'description' => LAN_CRON_06_2 ."
". LAN_CRON_06_3, + // 'available' => e107::getPref('ban_retrigger') + ), + 6 => array( + 'name' => LAN_CRON_20_1, + 'category' => '', + 'function' => 'checkCoreUpdate', + 'description' => LAN_CRON_20_2 ."
". LAN_CRON_20_3, + // 'available' => e107::getPref('ban_retrigger') + ), ); if(!vartrue($_GET['action']) || $_GET['action'] == 'refresh') diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php index b22c27187..6834b7ebb 100644 --- a/e107_handlers/cron_class.php +++ b/e107_handlers/cron_class.php @@ -34,9 +34,83 @@ class _system_cron * Burnsy - This is just a test * */ - function checkForUpate () + function checkCoreUpdate () // Check if there is an e107 Core update and email Site Admin if so { - // Do something + // 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; + } + } diff --git a/e107_languages/English/admin/lan_cron.php b/e107_languages/English/admin/lan_cron.php index 65938ef36..d020431f4 100644 --- a/e107_languages/English/admin/lan_cron.php +++ b/e107_languages/English/admin/lan_cron.php @@ -56,6 +56,11 @@ define("LAN_CRON_16", "Using your server control panel (eg. cPanel, DirectAdmin, // leave some room for additions/changes +// Info for checkCoreUpdate cron +define("LAN_CRON_20_1", "Check for e107 Update"); +define("LAN_CRON_20_2", "Check e107.org for Core updates"); // [eml] is automatically replaced by head admin e-mail address. +define("LAN_CRON_20_3", "Recommended to keep system up to date."); + define("LAN_CRON_30", "Every Minute"); define("LAN_CRON_31", "Every Other Minute"); define("LAN_CRON_32", "Every 5 Minutes");