| * +----------------------------------------------------------------------+ * * $Id$ */ /* * This script searches for orphan notes in the phpdoc manual * You need a rsync'ed phpweb dir */ $inCli = true; include '../include/init.inc.php'; $manual_dir = SVN_DIR .'/phpweb/manual/en'; $notes_dir = SVN_DIR .'/phpweb/backend/notes'; /* Collect manual IDs */ function recurse_manual($dir) { global $files, $len; if (!$dh = opendir($dir)) { exit; } while (($file = readdir($dh)) !== false) { if($file == '.' || $file == '..') { continue; } $path = $dir.'/'.$file; if(is_dir($path)) { recurse_manual($path); } else { $files[substr(md5(substr($path, $len, -4)), 0, 16)] = 1; } } closedir($dh); } /* Search for bogus notes IDs */ function recurse_notes($dir) { global $array, $files, $n_files, $n_notes; if (!$dh = opendir($dir)) { exit; } while (($file = readdir($dh)) !== false) { if($file == '.' || $file == '..' || substr($file, -4) == '.bz2' || $file == 'last-updated' || $file == 'sections') { continue; } $path = $dir.'/'.$file; if(is_dir($path)) { recurse_notes($path); } else { if(isset($files[$file])) { continue; } $fp = fopen($path, 'r'); while (!feof($fp)) { $line = chop(fgets($fp, 12288)); if ($line == '') { continue; } list($id, $sect) = explode('|', $line); $array[$sect][] = $id; ++$n_notes; } // file orphan ++$n_files; } // file } // main while closedir($dh); } /* output HTML */ function output_html() { global $array, $n_notes, $n_files; echo "
"; if(count($array) == 0) { echo '
Currently, there are no orphan notes!
'; echo 'Last Check: ' . date('r') . '
'; echo ''; return; } echo 'Old ID | '. 'Notes IDs | Move to new ID: |
---|---|---|
'.$id.' | ' . preg_replace('/(\d+)/', '$1', implode(', ', $notes)) . ' |
Total Notes: $n_notes
Total files: $n_files
Last Check: ' . date('r') . '
'; } /* begin main program */ $len = strlen("$manual_dir/"); $n_notes = $n_files = 0; recurse_manual($manual_dir); recurse_notes($notes_dir); output_html(); ?>