Skip to content

Commit

Permalink
Merge pull request #1530 from ChurchCRM/2.4.1-1521-integrity-check
Browse files Browse the repository at this point in the history
2.4.1 1521 integrity check
  • Loading branch information
crossan007 authored Dec 7, 2016
2 parents 109c768 + 1556f33 commit 9c54b69
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ChurchCRM/Service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function runTimerJobs()
$diff = $previous->diff($now); // calculate the difference.
if (!SystemConfig::getValue("sLastIntegrityCheckTimeStamp") || $diff->h >= SystemConfig::getValue("sIntegrityCheckInterval")) // if there was no previous backup, or if the interval suggests we do a backup now.
{
$integrityCheckFile = dirname(__DIR__) . "/integrityCheck.json";
$integrityCheckFile = SystemURLs::getDocumentRoot() . "/integrityCheck.json";
$appIntegrity = $this->verifyApplicationIntegrity();
file_put_contents($integrityCheckFile, json_encode($appIntegrity));
$now = new \DateTime(); // update the LastBackupTimeStamp.
Expand Down
7 changes: 5 additions & 2 deletions src/ChurchCRM/Service/TaskService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public function __construct()

function getAdminTasks() {
requireUserGroupMembership("bAdmin");
$integrityCheckData = json_decode(file_get_contents(SystemURLs::getDocumentRoot()."/integrityCheck.json"));
if (file_exists(SystemURLs::getDocumentRoot()."/integrityCheck.json"))
{
$integrityCheckData = json_decode(file_get_contents(SystemURLs::getDocumentRoot()."/integrityCheck.json"));
}

$tasks = array();
if (SystemConfig::getValue("bRegistered") != 1) {
Expand All @@ -45,7 +48,7 @@ function getAdminTasks() {
array_push($tasks, $this->addTask(gettext("New Release") . " " . $this->latestVersion["name"], SystemURLs::getRootPath()."/UpgradeCRM.php", true));
}

if($integrityCheckData->status == "failure") {
if($integrityCheckData == null || $integrityCheckData->status == "failure") {
array_push($tasks, $this->addTask(gettext("Application Integrity Check Failed"), SystemURLs::getRootPath()."/IntegrityCheck.php", true));
}

Expand Down
14 changes: 12 additions & 2 deletions src/IntegrityCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require 'Include/Config.php';
require 'Include/Functions.php';

use ChurchCRM\dto\SystemURLs;

//Set the page title
$sPageTitle = gettext('Integrity Check Results');
if (!$_SESSION['bAdmin'])
Expand All @@ -12,8 +14,16 @@
exit;
}
require 'Include/Header.php';
$integrityCheckFile = __DIR__ ."/integrityCheck.json";
$IntegrityCheckDetails = json_decode(file_get_contents($integrityCheckFile));
$integrityCheckFile = SystemURLs::getDocumentRoot() ."/integrityCheck.json";

if (file_exists($integrityCheckFile))
{
$IntegrityCheckDetails = json_decode(file_get_contents($integrityCheckFile));
}
else {
$IntegrityCheckDetails->status = "failure";
$IntegrityCheckDetails->message = "integrityCheck.json file missing";
}

if ($IntegrityCheckDetails->status == "failure")
{
Expand Down

0 comments on commit 9c54b69

Please sign in to comment.