public function testIfDirIsNotIncluded() { $skipDirs = array($this->_notIncludeDir); $files = uwFindAllFiles(self::WEBALIZER_DIR_NAME, array(), true, $skipDirs); $this->assertNotContains($this->_notIncludeDir, $files, "Directory {$this->_notIncludeDir} shouldn't been included in this list"); $this->assertContains($this->_includeDir, $files, "Directory {$this->_includeDir} should been included in this list"); }
function systemCheckJsonGetFiles($persistence) { global $sugar_config; global $mod_strings; // add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one) $skipDirs = array($sugar_config['upload_dir'], 'themes'); if (!isset($persistence['dirs_checked'])) { $the_array = array(); $files = array(); $dir = getcwd(); $d = dir($dir); while ($f = $d->read()) { if ($f == "." || $f == "..") { // skip *nix self/parent continue; } if (is_dir("{$dir}/{$f}")) { $the_array[] = clean_path("{$dir}/{$f}"); } else { $files[] = clean_path("{$dir}/{$f}"); } } $persistence['files_to_check'] = $files; $persistence['dirs_to_check'] = $the_array; $persistence['dirs_total'] = count($the_array); $persistence['dirs_checked'] = false; $out = "1% {$mod_strings['LBL_UW_DONE']}"; return $persistence; } elseif ($persistence['dirs_checked'] == false) { $dir = array_pop($persistence['dirs_to_check']); $files = uwFindAllFiles($dir, array(), true, $skipDirs); $persistence['files_to_check'] = array_merge($persistence['files_to_check'], $files); $whatsLeft = count($persistence['dirs_to_check']); if (!isset($persistence['dirs_to_check']) || $whatsLeft < 1) { $whatsLeft = 0; $persistence['dirs_checked'] = true; } $out = round(($persistence['dirs_total'] - $whatsLeft) / 21 * 100, 1) . "% {$mod_strings['LBL_UW_DONE']}"; $out .= " [{$mod_strings['LBL_UW_SYSTEM_CHECK_CHECKING_JSON']} {$dir}]"; } else { $out = "Done"; } echo trim($out); return $persistence; }
/** * generates an array with all files in the SugarCRM root directory, skipping * cache/ * @return array files Array of files with absolute paths */ function getFilesForPermsCheck() { global $sugar_config; logThis('Got JSON call to find all files...'); $filesNotWritable = array(); $filesNWPerms = array(); // add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one) $skipDirs = array($sugar_config['upload_dir']); $files = uwFindAllFiles(".", array(), true, $skipDirs, true); return $files; }
/********************************************************************************* * Description: * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights * Reserved. Contributor(s): ______________________________________.. * *******************************************************************************/ logThis('[At systemCheck.php]'); $stop = false; // flag to prevent going to next step /////////////////////////////////////////////////////////////////////////////// //// FILE CHECKS logThis('Starting file permission check...'); $filesNotWritable = array(); $filesNWPerms = array(); // add directories here that should be skipped when doing file permissions checks (cache/upload is the nasty one) $skipDirs = array($sugar_config['upload_dir'], '.svn'); $files = uwFindAllFiles(getcwd(), array(), true, $skipDirs); $i = 0; $filesOut = "\n\t<a href='javascript:void(0); toggleNwFiles(\"filesNw\");'>{$mod_strings['LBL_UW_SHOW_NW_FILES']}</a>\n\t<div id='filesNw' style='display:none;'>\n\t<table cellpadding='3' cellspacing='0' border='0'>\n\t<tr>\n\t\t<th align='left'>{$mod_strings['LBL_UW_FILE']}</th>\n\t\t<th align='left'>{$mod_strings['LBL_UW_FILE_PERMS']}</th>\n\t\t<th align='left'>{$mod_strings['LBL_UW_FILE_OWNER']}</th>\n\t\t<th align='left'>{$mod_strings['LBL_UW_FILE_GROUP']}</th>\n\t</tr>"; $isWindows = is_windows(); foreach ($files as $file) { if ($isWindows) { if (!is_writable_windows($file)) { logThis('WINDOWS: File [' . $file . '] not readable - saving for display'); // don't warn yet - we're going to use this to check against replacement files $filesNotWritable[$i] = $file; $filesNWPerms[$i] = substr(sprintf('%o', fileperms($file)), -4); $filesOut .= "<tr>" . "<td><span class='error'>{$file}</span></td>" . "<td>{$filesNWPerms[$i]}</td>" . "<td>" . $mod_strings['ERR_UW_CANNOT_DETERMINE_USER'] . "</td>" . "<td>" . $mod_strings['ERR_UW_CANNOT_DETERMINE_GROUP'] . "</td>" . "</tr>"; } } else { if (!is_writable($file)) { logThis('File [' . $file . '] not writable - saving for display');