([^<]+)!Us", $content, $match); // Get user notes, or false on failure $user_notes = manualUserNotes($match[1], $filename); // If there are no user notes for this page, // no file will be generated, but if we generate // a file, we add it to project file too if ($user_notes != FALSE) { $WITH_NOTES++; $notes = fopen("$NOTES_TARGET/$filename", "w"); fwrite($notes, $user_notes); fclose($notes); fwrite($nproject, $filename . "\n"); $NOTE_FILE_LIST[] = $filename; echo "> $WITH_NOTES\r"; } else { $WITHOUT_NOTES++; } } } closedir($handle); // Copy note supplemental files, and add to file list copy("suppfiles/notes/_index.html", "$NOTES_TARGET/_index.html"); fwrite($nproject, "_index.html\n"); copy("suppfiles/notes/_style.css", "$NOTES_TARGET/_style.css"); fwrite($nproject, "_style.css\n"); // RAQ : Wednesday, 16 March 2005 01:54 pm : Allow all note pages to have a global JavaScript file. copy('suppfiles/notes/_notes_script.js', "$NOTES_TARGET/_notes_script.js"); fwrite($nproject, "_notes_script.js\n"); // Write out a list of files to work around an IE6 bug $jsfile = fopen("$NOTES_TARGET/_filelist.js", "w"); fwrite($jsfile, "note_file_list = ' " . join(" ", $NOTE_FILE_LIST) . " ';\n\n"); fwrite($jsfile, "if (note_file_list.indexOf(' ' + chmfile_page + ' ') != -1) { notesIframe(); }"); fclose($jsfile); fwrite($nproject, "_filelist.js\n"); // Close ready project file fclose($nproject); // Make entry HTML fragment for a user note function makeEntry($date, $name, $blurb) { // Begin user notes header $entryhtml = "

\n"; // Get email/name of the user note writer $name = htmlspecialchars($name); if ($name && $name != "php-general@lists.php.net" && $name != "user@example.com") { if (ereg("(.+)@(.+)\.(.+)", $name)) { $entryhtml .= "$name"; } else { $entryhtml .= "$name"; } } // Append date $entryhtml .= " (" . date("d-M-Y h:i", $date) . ")

\n"; // Append user note text, cleared $entryhtml .= "

" . clean_note($blurb) . "

\n"; // Return with entry HTML fragment return $entryhtml; } // Get user notes for this particular page, returns an array with notes function manualGetUserNotes($id) { global $NOTES_SRC, $NOTE_NUM; $notes = array(); $hash = substr(md5($id),0,16); $notes_file = "$NOTES_SRC/$hash[0]/$hash"; if ($fp = @fopen($notes_file,"r")) { while (!feof($fp)) { $line = chop(fgets($fp,8096)); if ($line == "") continue; list($id,$sect,$rate,$ts,$user,$note) = explode("|",$line); $notes[] = array( "id" => $id, "sect" => $sect, "rate" => $rate, "xwhen" => $ts, "user" => $user, "note" => base64_decode($note) ); } fclose($fp); } $NOTE_NUM += count($notes); return $notes; } // Get the HTML file for a user note page, or false on failure function manualUserNotes($title, $id) { // Don't want .html at the end of the ids if (substr($id,-5) == '.html') { $id = substr($id,0,-5); } // Get user notes $notes = manualGetUserNotes($id); // If we have no notes, do not produce useless HTML if (count($notes) == 0) { return FALSE; } // start HTML output // RAQ : Wednesday, 16 March 2005 01:54 pm : Allow all note pages to have a global JavaScript file and use new notesLoading() function for body's onLoad. $notehtml = << N: $title

User contributed notes:

END_OF_MULTI; // Go through manual notes, and make entries foreach ($notes as $note) { $notehtml .= makeEntry($note['xwhen'], $note['user'], $note['note'], $note['id']); } // Be good guys, and end HTML code here $notehtml .= "\n"; // Return with manual notes for this page return $notehtml; } // Clean note to get right display function clean_note($text) { // Do not allow people to fool the system with bogus HTML $text = htmlspecialchars(trim($text)); // turn urls into links $text = preg_replace("/((mailto|http|ftp|nntp|news):.+?)(>|\\s|\\)|\"|\\.\\s|$)/","\\1\\3",$text); // this 'fixing' code will go away eventually $fixes = array('
','

','

'); reset($fixes); while (list(,$f)=each($fixes)) { $text=str_replace(htmlspecialchars($f), $f, $text); $text=str_replace(htmlspecialchars(strtoupper($f)), $f, $text); } // Allow only one
(drop out long empty sections) $text = preg_replace("!(
\\s*)+!", "
", $text); // wordwrap is not applicable here, because (it is buggy and) // we need to make text break as window resized // Convert new lines in notes to
/
$text = nl2br(preg_replace("![\\n\\r]+!", "\n", $text)); // Get files to smaller size (bad hack :) $text = str_replace("
", "
", $text); // We do not use
 but would like to see indentation
    $text = str_replace("  ", "  ", $text);

    // Paras cannot be used here, replace with 

$text = str_replace("

", "

", $text); // Drop out end of paras $text = str_replace("

", "", $text); return $text; } ?>