public function pjActionConfig() { $this->checkLogin(); if ($this->isAdmin()) { $pjLogConfigModel = pjLogConfigModel::factory(); if (isset($_POST['update_config'])) { $pjLogConfigModel->eraseAll(); if (isset($_POST['filename']) && count($_POST['filename']) > 0) { $pjLogConfigModel->begin(); foreach ($_POST['filename'] as $filename) { $pjLogConfigModel->reset()->set('filename', $filename)->insert(); } $pjLogConfigModel->commit(); } pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjLog&action=pjActionConfig&err=PLG01"); } $data = array(); pjUtil::readDir($data, 'app/controllers/'); pjUtil::readDir($data, 'app/plugins/'); $this->set('data', $data); $this->set('config_arr', $pjLogConfigModel->findAll()->getDataPair('id', 'filename')); } else { $this->set('status', 2); } }
public function pjActionHash() { @set_time_limit(0); if (!function_exists('md5_file')) { die("Function <b>md5_file</b> doesn't exists"); } require 'app/config/config.inc.php'; # Origin hash ------------- if (!is_file(PJ_CONFIG_PATH . 'files.check')) { die("File <b>files.check</b> is missing"); } $json = @file_get_contents(PJ_CONFIG_PATH . 'files.check'); $Services_JSON = new pjServices_JSON(); $data = $Services_JSON->decode($json); if (is_null($data)) { die("File <b>files.check</b> is empty or broken"); } $origin = get_object_vars($data); # Current hash ------------ $data = array(); pjUtil::readDir($data, PJ_INSTALL_PATH); $current = array(); foreach ($data as $file) { $current[str_replace(PJ_INSTALL_PATH, '', $file)] = md5_file($file); } $html = '<style type="text/css"> table{border: solid 1px #000; border-collapse: collapse; font-family: Verdana, Arial, sans-serif; font-size: 14px} td{border: solid 1px #000; padding: 3px 5px; background-color: #fff; color: #000} .diff{background-color: #0066FF; color: #fff} .miss{background-color: #CC0000; color: #fff} </style> <table cellpadding="0" cellspacing="0"> <tr><td><strong>Filename</strong></td><td><strong>Status</strong></td></tr> '; foreach ($origin as $file => $hash) { if (isset($current[$file])) { if ($current[$file] == $hash) { } else { $html .= '<tr><td>' . $file . '</td><td class="diff">changed</td></tr>'; } } else { $html .= '<tr><td>' . $file . '</td><td class="miss">missing</td></tr>'; } } $html .= '<table>'; echo $html; exit; }