/** * Check Files Integrity */ function checkFilesIntegrity() { require_once $this->_template_folder_path . DS . 'includes' . DS . 'lib' . DS . 'jsn_checksum_integrity_comparison.php'; $checksum = new JSNChecksumIntegrityComparison(); $result = $checksum->compareIntegrity(); if (is_array($result) && count($result) && (isset($result['added']) || isset($result['deleted']) || isset($result['modified']))) { if (count(@$result['added']) || count(@$result['deleted']) || count(@$result['modified'])) { // Some files have been modified , added, or deleted echo json_encode(array('integrity' => 1)); } else { // No files modification found echo json_encode(array('integrity' => 0)); } } else { // The checksum file is missing or empty echo json_encode(array('integrity' => 2)); } }
<?php /** * @author JoomlaShine.com http://www.joomlashine.com * @copyright Copyright (C) 2008 - 2011 JoomlaShine.com. All rights reserved. * @license GNU/GPL v2 http://www.gnu.org/licenses/gpl-2.0.html * @version $Id: jsn_listmodifiedfiles.php 10887 2012-01-18 09:13:22Z giangnd $ */ // No direct access defined('_JEXEC') or die('Restricted index access'); require_once dirname(__FILE__) . DS . 'includes' . DS . 'lib' . DS . 'jsn_checksum_integrity_comparison.php'; $obj_checksum = new JSNChecksumIntegrityComparison(); $results = $obj_checksum->compareIntegrity(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?> " lang="<?php echo $this->language; ?> " dir="<?php echo $this->direction; ?> "> <head> <title>Modified files list</title> <link rel="stylesheet" href="<?php echo JURI::base(true); ?> /templates/<?php
function backupModifiedFile($upgrade = false) { $session = JFactory::getSession(); $modifiedFileIdentifier = md5('state_modified_file_' . strtolower($this->_template_name)); $checksum = new JSNChecksumIntegrityComparison(); $result = $checksum->compareIntegrity(); $files = array(); $paths = array(); $tmpPath = JPATH_ROOT . DS . 'tmp'; $tmpTemplatePath = $tmpPath . DS . $this->_template_folder_name; $tmpFiles = array(); if (count($result)) { if ($upgrade === true) { $fileList = array_merge($result['modified'], $result['added']); } else { $fileList = $result['modified']; } $count = count($fileList); if ($count) { foreach ($fileList as $value) { $slash = strrpos($value, '/'); $files[] = $value; if ($slash) { $paths[] = substr($value, 0, $slash + 1); } } if (count($paths)) { foreach ($paths as $path) { $path = str_replace('/', DS, $path); $path = $tmpTemplatePath . DS . $path; JFolder::create($path); } } else { JFolder::create($tmpTemplatePath); } if (count($files)) { foreach ($files as $file) { $slash = strrpos($file, '/'); $fileName = JFile::getName(str_replace('/', DS, $file)); if ($slash) { $path = substr($file, 0, $slash + 1); } else { $path = ''; } if ($path != '') { $path = str_replace('/', DS, $path); } $tmpFiles[] = $file; $file = str_replace('/', DS, $file); $dest = $tmpTemplatePath . DS . $path . $fileName; $src = $this->_template_folder_path . DS . $file; JFile::copy($src, $dest); } } $session->set($modifiedFileIdentifier, $tmpFiles, 'jsntemplatesession'); $zipResult = $this->createZip($tmpTemplatePath); if ($zipResult) { $tmpName = JFile::getName($zipResult); if ($upgrade === false) { $backupPath = $this->_template_folder_path . DS . 'backups'; if (!JFolder::exists($backupPath)) { JFolder::create($backupPath); } $dest = $this->_template_folder_path . DS . 'backups' . DS . $tmpName; $src = $zipResult; JFile::copy($src, $dest); } JFolder::delete($tmpTemplatePath); return $tmpName; } else { return false; } } } return true; }