public function fileChecksum() { $messageArray = []; $dirList = PHPExt::dirSearch(Cfg::get('site_path'), '/^[^_].*$/'); $len = strlen(Cfg::get('site_path')) + 1; foreach ($dirList as &$path) { $path = substr($path, $len); } $tab = new DBTable(DB::DEF, 'SELECT * FROM tblFileCheck'); foreach ($tab as $row) { if (in_array($row['fldFileName'], $dirList)) { $fullPath = Cfg::get('site_path') . '/' . $row['fldFileName']; $fileSize = filesize($fullPath); $sha1 = sha1_file($fullPath); if ($fileSize != $row['fldSize']) { $messageArray[$row['fldFileName']] = 'Mismatch file size. was: ' . $row['fldSize'] . ' now: ' . $fileSize; } else { if ($sha1 != $row['fldCRC']) { $messageArray[$row['fldFileName']] = 'Mismatch SHA1. was: ' . $row['fldCRC'] . ' now: ' . $sha1; } } } else { $messageArray[$row['fldFileName']] = 'File deleted'; } } $oldFileList = $tab->getColumn('fldFileName'); foreach ($dirList as $fileName) { if (!in_array($fileName, $oldFileList)) { $messageArray[$fileName] = 'New file'; } } $html = ''; if (count($messageArray) != 0) { foreach ($messageArray as $key => $val) { $html .= $key . ': ' . $val . '<br/>'; } } else { $html = 'No Changes<br/>'; } $rebaseButton = Tag::linkButton('?' . Response::factory()->action(__CLASS__ . '->' . __FUNCTION__ . 'Rebase()'), 'Rebase'); return $rebaseButton . '<br/>' . $html . $rebaseButton; }
public static function getSecurityLevel($level) { if (self::$securityLevels == null) { $tab = new DBTable(DB::DEF, Admin::LEVEL_SQL, null, DB::FETCH_NUM); $valCol = $tab->getColumn(0); $namCol = $tab->getColumn(1); self::$securityLevels = array_merge(array_combine($valCol, $namCol), array_combine($namCol, $valCol)); } return self::$securityLevels[$level]; }