File: split_notes.php

package info (click to toggle)
php-doc 20241205~git.dfcbb86%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 70,956 kB
  • sloc: xml: 968,269; php: 23,883; javascript: 671; sh: 177; makefile: 37
file content (48 lines) | stat: -rw-r--r-- 1,244 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?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);

}

?>