Files
archived-doc-base/htmlhelp/split_notes.php
Gabor Hojtsy d80306f046 Adding the "new CHM" build system to CVS.
Here is my Christmas present to you all ;)

This also contains a short README and a not too short TODO.


git-svn-id: https://svn.php.net/repository/phpdoc/doc-base/trunk@109055 c90b9560-bf6c-de11-be94-00142212c4b1
2002-12-26 19:11:03 +00:00

48 lines
1.2 KiB
PHP

<?php
/*
This file is part of the Windows Compiled HTML Help
Manual Generator of the PHP Documentation project.
This code splits up the notes file to be easily
processeable by the notes CHM generator script.
*/
// Check for previous run
if (@is_dir("$NOTES_SRC/0")) {
echo "\n> Previous user note split detected, skipping\n";
}
// We have no splitted notes files, do it now
else {
// Open all notes source file for reading
$fp = @fopen("all", "r");
if (!$fp) { die("ERROR: No all notes file present"); }
// Read through the file, and write individual files
while (!feof($fp)) {
$line = chop(fgets($fp,8096));
if ($line == "") continue;
// Get data from one line
list($id,$sect,$rate,$ts,$user,$note) = explode("|",$line);
$hash = substr(md5($sect),0,16);
// Create dir if nonexistent
if (!@is_dir("$NOTES_SRC/" . $hash[0])) {
mkdir("$NOTES_SRC/" . $hash[0], 0700);
}
// Append line to appropriate file
$nf = fopen("$NOTES_SRC/" . $hash[0] . "/$hash", "a");
fwrite($nf, $line . "\n");
fclose($nf);
}
// Close all notes file
fclose($fp);
}
?>