'.$langmessage['Site Status'].''; $check_dir = $dataDir.'/data'; $this->check_dir_len = strlen($check_dir); $this->euid = '?'; if( function_exists('posix_geteuid') ){ $this->euid = posix_geteuid(); } ob_start(); $this->CheckDir($check_dir); $failed_output = ob_get_clean(); $checked = $this->passed_count + $this->failed_count; if( $this->failed_count == 0 ){ echo '

'; echo sprintf($langmessage['data_check_passed'],$checked,$checked); echo '

'; //$this->CheckPageFiles(); return; } echo '

'; echo sprintf($langmessage['data_check_failed'],$this->failed_count,$checked); echo '

'; if( $this->failed_count > $this->show_failed_max ){ echo '

'; echo sprintf($langmessage['showing_max_failed'],$this->show_failed_max); echo '

'; } echo ''; echo ''; echo ''; echo $failed_output; echo '
'; echo $langmessage['file_name']; echo ''; echo $langmessage['permissions']; echo ''; echo $langmessage['File Owner']; echo '
 '; echo $langmessage['Current_Value']; echo ''; echo $langmessage['Expected_Value']; echo ''; echo $langmessage['Current_Value']; echo ''; echo $langmessage['Expected_Value']; echo '
'; $this->CheckPageFiles(); } /** * Check page files for orphaned data files * */ protected function CheckPageFiles(){ global $dataDir,$gp_index; $pages_dir = $dataDir.'/data/_pages'; $all_files = \gp\tool\Files::ReadDir($pages_dir,'php'); foreach($all_files as $key => $file){ $all_files[$key] = $pages_dir.'/'.$file.'.php'; } $page_files = array(); foreach($gp_index as $slug => $index){ $page_files[] = \gp\tool\Files::PageFile($slug); } $diff = array_diff($all_files,$page_files); if( !count($diff) ){ return; } echo '

Orphaned Data Files

'; echo '

The following data files appear to be orphaned and are most likely no longer needed. Before completely removing these files, we recommend backing them up first.

'; echo ''; foreach($diff as $file){ echo ''; } echo '
File
' . $file . '
'; } protected function CheckDir($dir){ $this->CheckFile($dir); $dh = @opendir($dir); if( !$dh ){ echo ''; echo '

'; echo 'Could not open data directory: '.$check_dir; echo '

'; echo ''; return; } while( ($file = readdir($dh)) !== false){ if( $file == '.' || $file == '..' ){ continue; } $full_path = $dir.'/'.$file; if( is_link($full_path) ){ continue; } if( is_dir($full_path) ){ $this->CheckDir($full_path,'dir'); }else{ $this->CheckFile($full_path,'file'); } } } protected function CheckFile($path,$type='dir'){ $current = '?'; $expected = '777'; $euid = '?'; if( \gp\install\FilePermissions::HasFunctions() ){ $current = @substr(decoct( @fileperms($path)), -3); if( $type == 'file' ){ $expected = \gp\install\FilePermissions::getExpectedPerms_file($path); }else{ $expected = \gp\install\FilePermissions::getExpectedPerms($path); } if( \gp\install\FilePermissions::perm_compare($expected,$current) ){ $this->passed_count++; return; } $euid = \gp\install\FilePermissions::file_uid($path); }elseif( gp_is_writable($path) ){ $this->passed_count++; return; } $this->failed_count++; if( $this->failed_count > $this->show_failed_max ){ return; } echo ''; echo substr($path,$this->check_dir_len); echo ''; echo $current; echo ''; echo $expected; echo ''; echo $euid; echo ''; echo $this->euid; echo ''; } }