コード例 #1
0
 private static function _checkFiles($basePath, array $files, $fileModifiedSince, $isWpRoot = false, $isWpContent = false, $isWpAdmin = false)
 {
     wssLog(__METHOD__ . '(). Scanning: ' . WsdUtil::normalizePath($basePath));
     foreach ($files as $file) {
         $_file = $basePath . $file;
         $_file = WsdUtil::normalizePath($_file);
         if (!is_file($_file)) {
             // if this is the root and wp-config.php file...
             if ($isWpRoot) {
                 // safely ignore this file
                 if (strcasecmp($file, 'wp-config-sample.php') == 0) {
                     wssLog('wp-config-sample.php file is missing but can be ignored. Skipping file check.');
                     continue;
                 } elseif (strcasecmp($file, 'wp-config.php') == 0) {
                     // check one level above
                     $path = realpath('../' . ABSPATH) . '/' . $file;
                     if (is_file($path)) {
                         $_file = $path;
                     } else {
                         //#! Mark file not found
                         self::_markFileNotFound($_file);
                         continue;
                     }
                 } elseif (strcasecmp($file, 'readme.html') == 0) {
                     wssLog('readme.html file is missing but can be ignored. Skipping file check.');
                     continue;
                 }
             } elseif ($isWpContent) {
                 // Ignore WP's default themes and plugins if not found
                 if (WsdUtil::canIgnoreScanPath($_file)) {
                     wssLog($_file . ' file is missing but can be ignored. Skipping file check.');
                     continue;
                 }
             } elseif ($isWpAdmin) {
                 // safely ignore marked files from /wp-admin
                 if (strcasecmp($file, 'install.php') == 0) {
                     wssLog('wp-admin/install.php file is missing but can be ignored. Skipping file check.');
                     continue;
                 } elseif (strcasecmp($file, 'upgrade.php') == 0) {
                     wssLog('wp-admin/upgrade.php file is missing but can be ignored. Skipping file check.');
                     continue;
                 }
             }
             //#! Mark file not found
             self::_markFileNotFound($_file);
             continue;
         }
         $mdate = filemtime($_file);
         if ($mdate > $fileModifiedSince) {
             //#! Mark file as modified
             self::_markFileModified($_file, $mdate);
         }
     }
 }