debug = FALSE; //require_once(e_HANDLER.'form_handler.php'); $DOCS_DIRECTORY = $HELP_DIRECTORY; // Give a sensible, albeit probably invalid, value if (substr($HELP_DIRECTORY,-5,5) == 'help/') { $DOCS_DIRECTORY = substr($HELP_DIRECTORY,0,-5); // Whatever $HELP_DIRECTORY is set to, assume docs are in a subdirectory called 'help' off it } $maindirs = array('admin' => $ADMIN_DIRECTORY, 'files' => $FILES_DIRECTORY, 'images' => $IMAGES_DIRECTORY, 'themes' => $THEMES_DIRECTORY, 'plugins' => $PLUGINS_DIRECTORY, 'handlers' => $HANDLERS_DIRECTORY, 'languages' => $LANGUAGES_DIRECTORY, 'downloads' => $DOWNLOADS_DIRECTORY, 'docs' => $DOCS_DIRECTORY); foreach ($maindirs as $maindirs_key => $maindirs_value) { $coredir[$maindirs_key] = substr($maindirs_value, 0, -1); } require_once('core_image.php'); //$rs = new form; set_time_limit(18000); $e_sub_cat = 'fileinspector'; if(isset($_GET['scan'])) { session_write_close(); while (@ob_end_clean()); //header("Content-type: text/html; charset=".CHARSET, true); //$css_file = file_exists(e_THEME.$pref['admintheme'].'/'.$pref['admincss']) ? e_THEME.$pref['admintheme'].'/'.$pref['admincss'] : e_THEME.$pref['admintheme'].'/'.$pref['admincss']; // $fi = new file_inspector; $fi = e107::getSingleton('file_inspector'); echo " Results ".$fi->headerCss()." ".headerjs()." \n"; // define('e_IFRAME', true); // require_once(e_ADMIN."auth.php"); // echo "
loading.."; // echo ".."; //flush(); $_POST = $_GET; if(vartrue($_GET['exploit'])) { $fi->exploit(); } else { $fi->scan_results(); } // require_once(e_ADMIN."footer.php"); echo ""; exit(); } else { // $fi = new file_inspector; $fi = e107::getSingleton('file_inspector'); require_once(e_ADMIN.'auth.php'); // if (e_QUERY) { // $fi -> snapshot_interface(); //} if (varset($_POST['scan'])) { $fi->exploit_interface(); $fi->scan_config(); } elseif($_GET['mode'] == 'run') { $mes = e107::getMessage(); $mes->addInfo(FR_LAN_32);//Run a Scan first echo $mes->render(); } else { $fi->scan_config(); } } class file_inspector { var $root_dir; var $files = array(); var $parent; var $count = array(); var $results = 0; var $totalFiles = 0; var $coredir = array(); var $progress_units = 0; private $langs = array(); private $lang_short = array(); private $excludeFiles = array( '.', '..','/','.svn', 'CVS' ,'Thumbs.db', '.git'); private $knownSecurityIssues = array('htmlarea', 'e107_docs/docs.php'); // private $icon = array(); private $iconTag = array(); private $options = array( 'core' => '', 'type' =>'list', 'missing' => 0, 'noncore' => 9, 'nolang' => 1, 'oldcore' => 0, 'integrity' => 1, 'regex' => 0, 'mod' => '', 'num' => 0, 'line' => 0 ); function setOptions($post) { foreach($this->options as $k=>$v) { if(isset($post[$k])) { $this->options[$k] = $post[$k]; } } } function __construct() { $lng = e107::getLanguage(); $langs = $lng->installed(); if(isset($_GET['scan'])) { $this->setOptions($_GET); } $lang_short = array(); foreach($langs as $k=>$val) { if($val == "English") // Core release language, so ignore it. { unset($langs[$k]); continue; } $lang_short[] = $lng->convert($val); } $this->langs = $langs; $this->lang_short = $lang_short; //TODO LAN $this->glyph = array( 'folder_close' => array(''), 'folder_up' => array(''), 'folder_root' => array(''), 'warning' => array(''), 'info' => array(''), 'fileinspector' => array(''), 'folder' => array(''), 'folder_check' => array('', FC_LAN_24 ), 'folder_fail' => array('', FC_LAN_25 ), 'folder_missing' => array('', FC_LAN_26 ), 'folder_warning' => array(''), 'folder_old' => array('', FC_LAN_27 ), 'folder_old_dir' => array(''), 'folder_unknown' => array('', FC_LAN_28 ), 'file_check' => array('', FC_LAN_29), 'file_core' => array('', FC_LAN_30), 'file_fail' => array('', FC_LAN_31 ), 'file_missing' => array('', FC_LAN_32 ), 'file_old' => array('', FC_LAN_33 ), 'file_uncalc' => array('', FC_LAN_34 ), 'file_warning' => array('', FC_LAN_35 ), 'file_unknown' => array('', FC_LAN_36 ), ); foreach($this->glyph as $k=>$v) { $this->iconTag[$k] = $this->glyph[$k][0]; } global $e107,$core_image; //$this->totalFiles = count($core_image,COUNT_RECURSIVE); $this->countFiles($core_image); $this -> root_dir = $e107 -> file_path; if (substr($this -> root_dir, -1) == '/') { $this -> root_dir = substr($this -> root_dir, 0, -1); } if ($_POST['core'] == 'fail') { $_POST['integrity'] = TRUE; } if (MAGIC_QUOTES_GPC && vartrue($_POST['regex'])) { $_POST['regex'] = stripslashes($_POST['regex']); } if ($_POST['regex']) { if ($_POST['core'] == 'fail') { $_POST['core'] = 'all'; } $_POST['missing'] = 0; $_POST['integrity'] = 0; } } private function opt($key) { return $this->options[$key]; } // Find the Total number of core files before scanning begins. function countFiles($array) { foreach($array as $k=>$val) { if(is_array($val)) { $this->countFiles($val); } elseif($val) { $this->totalFiles++; } } } private function getDiz($key) { if(!empty($this->glyph[$key][1])) { return $this->glyph[$key][1]; } return $key; } public function getLegend() { return $this->glyph; } function renderHelp() { $text = ""; foreach($this->iconTag as $k=>$v) { $text .= ""; } $text .= "
".$v."".$k."
"; // echo $text; } function scan_config() { $frm = e107::getForm(); $ns = e107::getRender(); $pref = e107::pref('core'); if($_GET['mode'] == 'run') { return; } $tab = array(); $head = "
"; $text = " "; /* $text .= " ";*/ $coreOpts = array('full'=>FC_LAN_6, 'all'=>LAN_ALL, 'none'=> LAN_NONE); $text .= ""; $dispOpt = array('tree'=>FC_LAN_15, 'list'=>LAN_LIST); $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= "
".LAN_OPTIONS."
".LAN_SHOW." ".FC_LAN_5.": ".$frm->select('core',$coreOpts,$_POST['core'])."
".FC_LAN_14.": ".$frm->select('type', $dispOpt, $_POST['type'])."
".LAN_SHOW." ".FC_LAN_13.": ".LAN_YES."   ".LAN_NO."  
".LAN_SHOW." ".FC_LAN_7.": ".LAN_YES."   ".LAN_NO."   ".FC_LAN_23."  
".LAN_SHOW." ".FC_LAN_21.": ".LAN_YES."   ".LAN_NO."  
".FC_LAN_8.": ".LAN_YES."   ".LAN_NO."  
"; $tab['basic'] = array('caption'=>LAN_OPTIONS, 'text'=>$text); if ($pref['developer']) { $text2 = ""; /* $text2 .= "";*/ $text2 .= ""; $text2 .= ""; $text2 .= ""; $text2 .= "
".FC_LAN_17."
".FC_LAN_18.": ##
".FC_LAN_19.":
".FC_LAN_20.":
"; $tab['advanced'] = array('caption'=>FC_LAN_17, 'text'=>$text2); } $tabText = e107::getForm()->tabs($tab); $foot = "
".$frm->admin_button('scan', LAN_GO, 'other')."
"; $text = $head.$tabText.$foot; $ns -> tablerender(FC_LAN_1, $text); } function scan($dir, $image) { $handle = opendir($dir.'/'); while (false !== ($readdir = readdir($handle))) { if ($readdir != '.' && $readdir != '..' && $readdir != '/' && $readdir != 'CVS' && $readdir != 'Thumbs.db' && (strpos('._', $readdir) === FALSE)) { $path = $dir.'/'.$readdir; if (is_dir($path)) { $dirs[$path] = $readdir; } elseif (!isset($image[$readdir])) { $files[$readdir] = $this -> checksum($path, TRUE); } } } closedir($handle); if (isset($dirs)) { ksort ($dirs); foreach ($dirs as $dir_path => $dir_list) { $list[$dir_list] = ($set = $this -> scan($dir_path, $image[$dir_list])) ? $set : array(); } } if (isset($files)) { ksort ($files); foreach ($files as $file_name => $file_list) { $list[$file_name] = $file_list; } } return $list; } // Given a full path and filename, looks it up in the list to determine valid actions; returns: // 'check' - file is expected to be present, and validity is to be checked // 'ignore' - file may or may not be present - check its validity if found, but not an error if missing // 'uncalc' - file must be present, but its integrity cannot be checked. // 'nocalc' - file may be present, but its integrity cannot be checked. Not an error if missing function check_action($dir, $name) { global $coredir; if ($name == 'e_inspect.php') { return 'nocalc'; } // Special case for plugin integrity checking $filename = $dir.'/'.$name; $admin_dir = $this->root_dir.'/'.$coredir['admin'].'/'; $image_dir = $this->root_dir.'/'.$coredir['images'].'/'; $test_list = array(); // Files that are unable to be checked $test_list[$admin_dir.'core_image.php'] = 'uncalc'; $test_list[$this->root_dir.'/e107_config.php'] = 'uncalc'; // Files that are likely to be renamed by user $test_list[$admin_dir.'filetypes_.php'] = 'ignore'; $test_list[$this->root_dir.'/e107.htaccess'] = 'ignore'; $test_list[$this->root_dir.'/e107.robots.txt'] = 'ignore'; if (isset($test_list[$filename])) { return $test_list[$filename]; } return 'check'; } // This function does the real work // $list - // $deprecated // $level // $dir // &$tree_end // &$parent_expand function inspect($list, $deprecated, $level, $dir, &$tree_end, &$parent_expand) { global $coredir; $sub_text = ''; $langs = $this->langs; $lang_short = $this->lang_short; unset ($childOut); $parent_expand = false; if (substr($dir, -1) == '/') { $dir = substr($dir, 0, -1); } $dir_id = dechex(crc32($dir)); $this -> files[$dir_id]['.']['level'] = $level; $this -> files[$dir_id]['.']['parent'] = $this -> parent; $this -> files[$dir_id]['.']['file'] = $dir; $directory = $level ? basename($dir) : SITENAME; $level++; // $this->sendProgress(vartrue($this->count['core']['num']),$this->totalFiles,FR_LAN_1); foreach ($list as $key => $value) { // $dir_icon = 'fileinspector'; // default as unknown $this -> parent = $dir_id; if (is_array($value)) { // Entry is a subdirectory - recurse another level $path = $dir.'/'.$key; $child_open = false; $child_end = true; $dir_icon = 'folder_check'; $sub_text .= $this -> inspect($value, $deprecated[$key], $level, $path, $child_end, $child_expand); $tree_end = false; if ($child_expand) { $parent_expand = true; $last_expand = true; } } else { $this->sendProgress(vartrue($this->count['core']['num']),$this->totalFiles,FR_LAN_1); $path = $dir.'/'.$key; $fid = strtolower($key); $this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path; if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== false) { // We're checking a file here if ($this->opt('core') != 'none') { // Look at core files $this -> count['core']['num']++; $this -> count['core']['size'] += $this -> files[$dir_id][$fid]['size']; if ($_POST['regex']) // Developer prefs activated - search file contents according to regex { // TODO Max out of Memory when used $file_content = file($path); // Get contents of file if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE) { if ($this -> files[$dir_id][$fid]['lines'] = preg_grep("#".$_POST['regex']."#".$_POST['mod'], $file_content)) { // Search string found - add file to list $this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path; $this -> files[$dir_id][$fid]['icon'] = 'file_core'; $dir_icon = 'fileinspector'; $parent_expand = TRUE; $this -> results++; } else { // Search string not found - discard from list unset($this -> files[$dir_id][$fid]); $known[$dir_id][$fid] = true; $dir_icon = ($dir_icon == 'fileinspector') ? 'folder_unknown': $dir_icon ; } } } else { if ($this->opt('integrity')) { // Actually check file integrity switch ($this_action = $this->check_action($dir,$key)) { case 'ignore' : case 'check' : if ($this->checksum($path) != $value) { $this -> count['fail']['num']++; $this -> count['fail']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> files[$dir_id][$fid]['icon'] = 'file_fail'; $dir_icon = 'folder_fail'; $parent_expand = TRUE; } else { $this -> count['pass']['num']++; $this -> count['pass']['size'] += $this -> files[$dir_id][$fid]['size']; if ($this->opt('core') != 'fail') { $this -> files[$dir_id][$fid]['icon'] = 'file_check'; $dir_icon = ($dir_icon == 'folder_fail' || $dir_icon == 'folder_missing') ? $dir_icon : 'folder_check'; } else { unset($this -> files[$dir_id][$fid]); $known[$dir_id][$fid] = true; } } break; case 'uncalc' : case 'nocalc' : $this -> count['uncalculable']['num']++; $this -> count['uncalculable']['size'] += $this -> files[$dir_id][$fid]['size']; if ($this->opt('core') != 'fail') { $this -> files[$dir_id][$fid]['icon'] = 'file_uncalc'; } else { unset($this -> files[$dir_id][$fid]); $known[$dir_id][$fid] = true; } break; } } else { // Just identify as core file $this -> files[$dir_id][$fid]['icon'] = 'file_core'; } } } else { unset ($this -> files[$dir_id][$fid]); $known[$dir_id][$fid] = true; } } else if ($this->opt('missing')) { switch ($this_action = $this->check_action($dir,$key)) { case 'check' : case 'uncalc' : $this -> count['missing']['num']++; $this -> files[$dir_id][$fid]['icon'] = 'file_missing'; $dir_icon = ($dir_icon == 'folder_fail') ? $dir_icon : 'folder_missing'; $parent_expand = TRUE; break; case 'ignore' : case 'nocalc' : // These files can be missing without error - delete from the list unset ($this -> files[$dir_id][$fid]); $known[$dir_id][$fid] = true; break; } } else { unset ($this -> files[$dir_id][$fid]); } } } if ($this->opt('noncore') || $this->opt('oldcore')) { if(!$handle = opendir($dir.'/')) { //e107::getMessage()->addInfo("Couldn't Open : ".$dir); } while (is_resource($handle) && false !== ($readdir = readdir($handle))) { // $prog_count = $this->count['unknown']['num'] + $this->count['deprecated']['num']; // $this->sendProgress($prog_count,$this->totalFiles,FR_LAN_1); if (!in_array($readdir,$this->excludeFiles) && (strpos('._', $readdir) === false)) { if (is_dir($dir.'/'.$readdir)) { if (!isset($list[$readdir]) && ($level > 1 || $readdir == 'e107_install')) { $child_open = false; $child_end = true; $sub_text .= $this->inspect(array(), $deprecated[$readdir], $level, $dir.'/'.$readdir, $child_end, $child_expand); $tree_end = false; if ($child_expand) { $parent_expand = true; $last_expand = true; } } } else { if($this->opt('nolang') && !empty($langs) && !empty($lang_short)) // Hide Non-core Languages. { // PHP Lang files. $lreg = "/[\/_](".implode("|",$langs).")/"; if(preg_match($lreg, $dir.'/'.$readdir)) { continue; } // TinyMce Lang files. $lregs = "/[\/_](".implode("|",$lang_short).")_dlg\.js/"; if(preg_match($lregs, $dir.'/'.$readdir)) { continue; } // PhpMailer Lang Files. $lregsm = "/[\/_]phpmailer\.lang-(".implode("|",$lang_short).")\.php/"; if(preg_match($lregsm, $dir.'/'.$readdir)) { continue; } } $aid = strtolower($readdir); if (!isset($this -> files[$dir_id][$aid]['file']) && !$known[$dir_id][$aid]) { if ($this->checkKnownSecurity($dir.'/'.$readdir) === false) { if (isset($deprecated[$readdir])) { if ($this->opt('oldcore')) { $this -> files[$dir_id][$aid]['file'] = ($_POST['type'] == 'tree') ? $readdir : $dir.'/'.$readdir; $this -> files[$dir_id][$aid]['size'] = filesize($dir.'/'.$readdir); $this -> files[$dir_id][$aid]['icon'] = 'file_old'; $this -> count['deprecated']['num']++; $this -> count['deprecated']['size'] += $this -> files[$dir_id][$aid]['size']; $dir_icon = 'folder_old'; } } else { if ($this->opt('noncore')) { $this -> files[$dir_id][$aid]['file'] = ($_POST['type'] == 'tree') ? $readdir : $dir.'/'.$readdir; $this -> files[$dir_id][$aid]['size'] = filesize($dir.'/'.$readdir); //echo "
dir: ".$dir.'/'.$readdir. " ( ".$this -> files[$dir_id][$aid]['size'].")"; $this -> files[$dir_id][$aid]['icon'] = 'file_unknown'; $this -> count['unknown']['num']++; $this -> count['unknown']['size'] += $this -> files[$dir_id][$aid]['size']; } } } else { $this -> files[$dir_id][$aid]['file'] = ($_POST['type'] == 'tree') ? $readdir : $dir.'/'.$readdir; $this -> files[$dir_id][$aid]['size'] = filesize($dir.'/'.$readdir); $this -> files[$dir_id][$aid]['icon'] = 'file_warning'; $this -> count['warning']['num']++; $this -> count['warning']['size'] += $this -> files[$dir_id][$aid]['size']; $this -> count['deprecated']['num']++; $this -> count['deprecated']['size'] += $this -> files[$dir_id][$aid]['size']; $dir_icon = 'folder_warning'; $parent_expand = TRUE; } $regexOpt = $this->opt('regex'); if (!empty($regexOpt)) { $file_content = file($dir.'/'.$readdir); if ($this -> files[$dir_id][$aid]['lines'] = preg_grep("#".$_POST['regex']."#".$_POST['mod'], $file_content)) { $dir_icon = 'fileinspector'; $parent_expand = TRUE; $this -> results++; } else { unset($this -> files[$dir_id][$aid]); $dir_icon = ($dir_icon == 'fileinspector') ? $dir_icon : 'folder'; } } else { if (isset($deprecated[$readdir])) { if ($this->opt('oldcore')) { $dir_icon = ($dir_icon == 'folder_warning' || $dir_icon == 'folder_fail' || $dir_icon == 'folder_missing' ) ? $dir_icon : 'folder_old'; $parent_expand = TRUE; } } else { if ($this->opt('noncore')) { $dir_icon = ($dir_icon == 'folder_warning' || $dir_icon == 'folder_fail' || $dir_icon == 'folder_missing' || $dir_icon == 'folder_old' || $dir_icon == 'folder_old_dir') ? $dir_icon : 'folder_unknown'; $parent_expand = TRUE; } } } } else if ($this->opt('core') == 'none') { unset($this -> files[$dir_id][$aid]); } } } } closedir($handle); } $this->sendProgress($this->count['core']['num'],$this->totalFiles,FR_LAN_1); $dir_icon = $dir_icon ? $dir_icon : 'folder_unknown'; // $icon = ""; $icon = $this->iconTag[$dir_icon]; $tp = e107::getParser(); $imgBlank = $tp->toImage('{e_IMAGE}fileinspector/blank.png', array( 'alt' => '', 'legacy' => '{e_IMAGE}fileinspector/', 'w' => 9, 'h' => 9, 'class' => 'c', )); $imgExpand = $tp->toImage('{e_IMAGE}fileinspector/expand.png', array( 'alt' => '', 'legacy' => '{e_IMAGE}fileinspector/', 'w' => 15, 'class' => 'e', 'id' => 'e_' . $dir_id, )); $imgContract = $tp->toImage('{e_IMAGE}fileinspector/contract.png', array( 'alt' => '', 'legacy' => '{e_IMAGE}fileinspector/', 'w' => 15, 'class' => 'e', 'id' => 'e_' . $dir_id, )); $hide = ($last_expand && $dir_icon != 'folder_core') ? "" : "style='display: none'"; $text = '
'; $text .= $tree_end ? $imgBlank : '' . ($hide ? $imgExpand : $imgContract) . ''; $text .= ' ' . $icon . ' ' . $directory . ''; $text .= $tree_end ? '' : '
' . $sub_text . '
'; $text .= '
'; $this -> files[$dir_id]['.']['icon'] = $dir_icon; return $text; } private function checkKnownSecurity($path) { foreach($this->knownSecurityIssues as $v) { if(strpos($path, $v) !== false) { return true; } } return false; } function scan_results() { global $ns, $rs, $core_image, $deprecated_image; $scan_text = $this -> inspect($core_image, $deprecated_image, 0, $this -> root_dir); $this->sendProgress($this->totalFiles,$this->totalFiles,'      '); echo "
 
"; if ($this->opt('type') == 'tree') { $text = "
"; $text .= ""; $text .= ""; $text .= "
".FR_LAN_2."
".$scan_text."
"; } else { $text = "
"; $text .= "
".FR_LAN_2."
"; } $text .= ""; if ($this->opt('type') == 'tree') { $text .= ""; } else { $text .= ""; } if ($this->opt('core') != 'none') { $text .= ""; } if ($this->opt('missing')) { $text .= ""; } if ($this->opt('noncore')) { $text .= ""; } if ($this->opt('oldcore')) { $text .= ""; } if ($this->opt('core') == 'all') { $text .= ""; } if ($this -> count['warning']['num']) { $text .= ""; $text .= ""; $text .= ""; $text .= ""; } if ($this->opt('integrity') && ($this->opt('core') != 'none')) { $integrity_icon = $this -> count['fail']['num'] ? 'integrity_fail.png' : 'integrity_pass.png'; $integrity_text = $this -> count['fail']['num'] ? '( '.$this -> count['fail']['num'].' '.FR_LAN_19.' )' : '( '.FR_LAN_20.' )'; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; $text .= ""; } if ($this->opt('type') == 'tree' && !$this -> results && $this->opt('regex')) { $text .= ""; } $text .= "
".FR_LAN_3." root_dir))."')\">
".FR_LAN_3."
".$this->iconTag['file_core']." ".FC_LAN_5.": ".($this -> count['core']['num'] ? $this -> count['core']['num'] : LAN_NONE)."  ".$this -> parsesize($this -> count['core']['size'], 2)."
".$this->iconTag['file_missing']." ".FC_LAN_13.": ".($this -> count['missing']['num'] ? $this -> count['missing']['num'] : LAN_NONE)." 
".$this->iconTag['file_unknown']." ".FC_LAN_7.": ".($this -> count['unknown']['num'] ? $this -> count['unknown']['num'] : LAN_NONE)." ".$this -> parsesize($this -> count['unknown']['size'], 2)."
".$this->iconTag['file_old']." ".FR_LAN_24.": ".($this -> count['deprecated']['num'] ? $this -> count['deprecated']['num'] : LAN_NONE)." ".$this -> parsesize($this -> count['deprecated']['size'], 2)."
".$this->iconTag['file']." ".FR_LAN_6.": ".($this -> count['core']['num'] + $this -> count['unknown']['num'] + $this -> count['deprecated']['num'])." ".$this -> parsesize($this -> count['core']['size'] + $this -> count['unknown']['size'] + $this -> count['deprecated']['size'], 2)."
 
".$this->iconTag['warning']." ".FR_LAN_26."
".$this->iconTag['file_warning']." ".FR_LAN_28.": ".($this -> count['warning']['num'] ? $this -> count['warning']['num'] : LAN_NONE)." ".$this -> parsesize($this -> count['warning']['size'], 2)."
".FR_LAN_27."
 
".FR_LAN_7." ".$integrity_text."
".$this->iconTag['file_check']." ".FR_LAN_8.": ".($this -> count['pass']['num'] ? $this -> count['pass']['num'] : LAN_NONE)." ".$this -> parsesize($this -> count['pass']['size'], 2)."
".$this->iconTag['file_fail']." ".FR_LAN_9.": ".($this -> count['fail']['num'] ? $this -> count['fail']['num'] : LAN_NONE)." ".$this -> parsesize($this -> count['fail']['size'], 2)."
".$this->iconTag['file_uncalc']." ".FR_LAN_25.": ".($this -> count['uncalculable']['num'] ? $this -> count['uncalculable']['num'] : LAN_NONE)." ".$this -> parsesize($this -> count['uncalculable']['size'], 2)."
 
".$this->iconTag['info']." ".FR_LAN_10.": 

".FR_LAN_23."
"; if ($this->opt('type') != 'tree') { $text .= "
"; if (!$this -> results && $this->opt('regex')) { $text .= ""; } // print_a($this -> files); } foreach ($this -> files as $dir_id => $fid) { // $this->sendProgress($cnt,$this->totalFiles,$path); ksort($fid); $text .= ($this->opt('type') == 'tree') ? "
".FR_LAN_23."
" : ""; $initial = FALSE; foreach ($fid as $key => $stext) { // print_a($stext); $iconKey = $stext['icon']; if (!$initial) { if ($this->opt('type') == 'tree') { $rootIconKey = ($stext['level'] ? "folder_up" : "folder_root"); $text .= ""; } } else { if ($this->opt('type') != 'tree') { $stext['file'] = str_replace($this -> root_dir."/", "", $stext['file']); } $text .= $this->renderRow($stext); } $initial = TRUE; } $text .= ($this->opt('type') == 'tree') ? "" : ""; } if ($this->opt('type') != 'tree') { $text .= "
"; } $text .= "

"; echo e107::getMessage()->render(); echo $text; //$ns -> tablerender(FR_LAN_1.'...', $text); } function renderRow($stext) { $mode = $this->opt('core'); $iconKey = $stext['icon']; // return "".$mode." ( ".$iconKey.")"; if($mode == 'full' && $iconKey == 'file_check' ) { return ''; } if($mode == 'none') { // return ''; } $text = ''; $text .= " getDiz($iconKey)."\">".$this->iconTag[$iconKey]." ".$stext['file']." "; if ($this->opt('regex')) { if ($this->opt('num') || $this->opt('line')) { $text .= "
"; } foreach ($stext['lines'] as $rkey => $rvalue) { if ($this->opt('num')) { $text .= "[".($rkey + 1)."] "; } if ($this->opt('line')) { $text .= htmlspecialchars($rvalue)."
"; } } $text .= "
"; } else { $text .= " ".$this -> parsesize($stext['size']); } $text .= ""; return $text; } function create_image($dir) { global $core_image, $deprecated_image,$coredir; foreach ($coredir as $trim_key => $trim_dirs) { $search[$trim_key] = "'".$trim_dirs."'"; $replace[$trim_key] = "\$coredir['".$trim_key."']"; } $data = " scan($dir) : $core_image; $image_array = var_export($scan_current, true); $image_array = str_replace($search, $replace, $image_array); $data .= "\$core_image = ".$image_array.";\n\n"; $scan_deprecated = ($_POST['snaptype'] == 'deprecated') ? $this -> scan($dir, $core_image) : $deprecated_image; $image_array = var_export($scan_deprecated, true); $image_array = str_replace($search, $replace, $image_array); $data .= "\$deprecated_image = ".$image_array.";\n\n"; $data .= "?>"; $fp = fopen(e_ADMIN.'core_image.php', 'w'); fwrite($fp, $data); } function snapshot_interface() { $ns = e107::getRender(); $frm = e107::getRender(); $text = ""; if (isset($_POST['create_snapshot'])) { $this -> create_image($_POST['snapshot_path']); $text = "
snapshot_interface "; $text .= "
Snapshot Created
The snapshot (".e_ADMIN."core_image.php) was successfully created.
".$frm->admin_button('main_page', 'Return To Main Page', 'submit')."

"; } $text .= "
"; $text .= "
Create Snapshot
Absolute path of root directory to create image from: root_dir)."' />
Create snapshot of current or deprecated core files: Current   Deprecated  
".$frm->admin_button('create_snapshot', 'Create Snapshot', 'create')."
"; $ns -> tablerender('Snapshot', $text); } function checksum($filename) { $checksum = md5(str_replace(array(chr(13),chr(10)), "", file_get_contents($filename))); return $checksum; } function parsesize($size, $dec = 0) { $size = $size ? $size : 0; $kb = 1024; $mb = 1024 * $kb; $gb = 1024 * $mb; $tb = 1024 * $gb; if ($size < $kb) { return $size." ".CORE_LAN_B; } else if($size < $mb) { return round($size/$kb)." ".CORE_LAN_KB; } else if($size < $gb) { return round($size/$mb, $dec)." ".CORE_LAN_MB; } else if($size < $tb) { return round($size/$gb, $dec)." ".CORE_LAN_GB; } else { return round($size/$tb, $dec)." ".CORE_LAN_TB; } } function regex_match($file) { $file_content = file_get_contents($file); $match = preg_match($_POST['regex'], $file_content); return $match; } function sendProgress($rand,$total,$diz) { if($this->progress_units <40 && ($rand != $total)) { $this->progress_units++; return; } else { $this->progress_units = 0; } $inc = round(($rand / $total) * 100); if($inc == 0) { return; } echo "
"; $active = "active"; if($inc >= 100) { $inc = 100; $active = ""; } echo e107::getForm()->progressBar('inspector',$inc); /* echo '
';*/ echo "
"; return; // exit; /* echo "
"; */ /* echo "
".$diz."
"; if($total > 0) { echo "
".$inc ."%
"; } echo "
"; */ } function exploit_interface() { // global $ns; $ns = e107::getRender(); $query = http_build_query($_POST); $text = " "; $ns -> tablerender(FR_LAN_1, $text); } function headerCss() { $pref = e107::getPref(); echo "\n"; $e_js = e107::getJs(); // Core CSS - XXX awaiting for path changes if (!isset($no_core_css) || !$no_core_css) { //echo "\n"; $e_js->otherCSS('{e_WEB_CSS}e107.css'); } if (!deftrue('e_IFRAME') && isset($pref['admincss']) && $pref['admincss']) { $css_file = file_exists(THEME.'admin_'.$pref['admincss']) ? 'admin_'.$pref['admincss'] : $pref['admincss']; //echo "\n"; $e_js->themeCSS($css_file); } elseif (isset($pref['themecss']) && $pref['themecss']) { $css_file = file_exists(THEME.'admin_'.$pref['themecss']) ? 'admin_'.$pref['themecss'] : $pref['themecss']; //echo "\n"; $e_js->themeCSS($css_file); } else { $css_file = file_exists(THEME.'admin_style.css') ? 'admin_style.css' : 'style.css'; //echo "\n"; $e_js->themeCSS($css_file); } $e_js->renderJs('other_css', false, 'css', false); echo "\n\n"; // Core CSS $e_js->renderJs('core_css', false, 'css', false); echo "\n\n"; // Plugin CSS $e_js->renderJs('plugin_css', false, 'css', false); echo "\n\n"; // Theme CSS //echo "\n"; $e_js->renderJs('theme_css', false, 'css', false); echo "\n\n"; // Inline CSS - not sure if this should stay at all! $e_js->renderJs('inline_css', false, 'css', false); echo "\n\n"; /* echo "\n"; if (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === FALSE && isset($pref['admincss']) && $pref['admincss'] && file_exists(THEME.$pref['admincss'])) { $css_file = file_exists(THEME.'admin_'.$pref['admincss']) ? THEME_ABS.'admin_'.$pref['admincss'] : THEME_ABS.$pref['admincss']; echo "\n"; } else if (isset($pref['themecss']) && $pref['themecss'] && file_exists(THEME.$pref['themecss'])) { $css_file = file_exists(THEME.'admin_'.$pref['themecss']) ? THEME_ABS.'admin_'.$pref['themecss'] : THEME_ABS.$pref['themecss']; echo "\n"; } else { $css_file = file_exists(THEME.'admin_style.css') ? THEME_ABS.'admin_style.css' : THEME_ABS.'style.css'; echo "\n"; } if (!isset($no_core_css) || !$no_core_css) { echo "\n"; } * */ } } function fileinspector_adminmenu() //FIXME - has problems when navigation is on the LEFT instead of the right. { $var['setup']['text'] = FC_LAN_11; $var['setup']['link'] = e_SELF."?mode=setup"; $var['run']['text'] = FR_LAN_2; $var['run']['link'] = e_SELF."?mode=run"; e107::getNav()->admin(FC_LAN_1, $_GET['mode'], $var); } function e_help() { // $fi = new file_inspector; $fi = e107::getSingleton('file_inspector'); $list = $fi->getLegend(); $text = ''; foreach($list as $v) { if(!empty($v[1])) { $text .= "
".$v[0]." ".$v[1]."
"; } } return array('caption'=>FC_LAN_37, 'text'=>$text); } require_once(e_ADMIN.'footer.php'); function headerjs() { /*$c = e_IMAGE_ABS . 'fileinspector/contract.png'; $e = e_IMAGE_ABS . 'fileinspector/expand.png'; $text = '';*/ /* * // Start of rework e107::js('footer-inline', " c = new Image(); c = '".SITEURLBASE.e_IMAGE_ABS."fileinspector/contract.png'; e = '".SITEURLBASE.e_IMAGE_ABS."fileinspector/expand.png'; function ec(ecid) { icon = $('#e_' + ecid).src; if (icon == e) { $('#e_' + ecid).src = c; } else { $('#e_' + ecid).src = e; } div = $('#d_' + ecid).style; if (div.display == 'none') { div.display = ''; } else { div.display = 'none'; } } var hideid = 'initial'; function sh(showid) { if (hideid != showid) { show = $('#'+showid).style; hide = $('#'+hideid).style; show.display = ''; hide.display = 'none'; hideid = showid; } } ");*/ global $e107; $text = ""; $text .= " \n"; return $text; } ?>