Rev 506 | Rev 510 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 506 | Rev 507 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | #!/usr/bin/perl -w |
1 | #!/usr/bin/perl -w |
| - | 2 | ||
| - | 3 | use Encode; |
|
| 2 | 4 | ||
| 3 | $debugmode = 0; |
5 | $debugmode = 0; |
| 4 | 6 | ||
| 5 | $outputpath = " |
7 | $outputpath = "H:/shared/www/projekt/data/pages/common/irc/hobby/"; |
| 6 | $linenrpath = "linenr.txt"; |
8 | $linenrpath = "linenr.txt"; |
| 7 | $contentspath = "contents.txt"; |
9 | $contentspath = "contents.txt"; |
| 8 | $currentfilepath = "currentfile.txt"; |
10 | $currentfilepath = "currentfile.txt"; |
| 9 | $logfilepath = "#hobby.log"; |
11 | $logfilepath = "C:/Prgm/mIRC/logs/EFnet/#hobby.log"; |
| 10 | $contentsfileoutput = " |
12 | $contentsfileoutput = "H:/shared/www/projekt/data/pages/common/irc/"; |
| 11 | $contentsfilename = "hobby.txt"; |
13 | $contentsfilename = "hobby.txt"; |
| 12 | $contentsheader = "====== Log of #hobby-channel ======\n"; |
14 | $contentsheader = "====== Log of #hobby-channel ======\n"; |
| - | 15 | $namespace = "common:irc:hobby:"; |
|
| 13 | 16 | ||
| 14 | $numArgs = $#ARGV + 1; |
17 | $numArgs = $#ARGV + 1; |
| 15 | if ($numArgs == 1) { |
18 | if ($numArgs == 1) { |
| 16 | if ($ARGV[0] eq "-r") { |
19 | if ($ARGV[0] eq "-r") { |
| 17 | #reset log system |
20 | #reset log system |
| 18 | 21 | ||
| 19 | $fileopenerr = 0; |
22 | $fileopenerr = 0; |
| 20 | open (LINENR, ">".$linenrpath) or $fileopenerr = 1; |
23 | open (LINENR, ">".$linenrpath) or $fileopenerr = 1; |
| 21 | if ($fileopenerr == 0) { |
24 | if ($fileopenerr == 0) { |
| 22 | print LINENR "0"; |
25 | print LINENR "0"; |
| 23 | close(LINENR); |
26 | close(LINENR); |
| 24 | } |
27 | } |
| 25 | 28 | ||
| 26 | $fileopenerr = 0; |
29 | $fileopenerr = 0; |
| 27 | open (CONTENTSFILE, ">".$contentspath) or $fileopenerr = 1; |
30 | open (CONTENTSFILE, ">".$contentspath) or $fileopenerr = 1; |
| 28 | if ($fileopenerr == 0) { |
31 | if ($fileopenerr == 0) { |
| 29 | print CONTENTSFILE ""; |
32 | print CONTENTSFILE ""; |
| 30 | close(CONTENTSFILE); |
33 | close(CONTENTSFILE); |
| 31 | } |
34 | } |
| 32 | close(CONTENTSFILE); |
35 | close(CONTENTSFILE); |
| 33 | 36 | ||
| 34 | $fileopenerr = 0; |
37 | $fileopenerr = 0; |
| 35 | open (CURRFILE, ">".$currentfilepath) or $fileopenerr = 1; |
38 | open (CURRFILE, ">".$currentfilepath) or $fileopenerr = 1; |
| 36 | if ($fileopenerr == 0) { |
39 | if ($fileopenerr == 0) { |
| 37 | print CURRFILE ""; |
40 | print CURRFILE ""; |
| 38 | close(CURRFILE); |
41 | close(CURRFILE); |
| 39 | } |
42 | } |
| 40 | #print "exit\n"; |
43 | #print "exit\n"; |
| 41 | exit; |
44 | exit; |
| 42 | } |
45 | } |
| 43 | } |
46 | } |
| 44 | 47 | ||
| 45 | 48 | ||
| 46 | $startAtLine = 0; |
49 | $startAtLine = 0; |
| 47 | $currentfile = ""; |
50 | $currentfile = ""; |
| Line 55... | Line 58... | ||
| 55 | exit; |
58 | exit; |
| 56 | } |
59 | } |
| 57 | close(LINENR); |
60 | close(LINENR); |
| 58 | } else { |
61 | } else { |
| 59 | print "Could not open ".$linenrpath; |
62 | print "Could not open ".$linenrpath; |
| 60 | exit; |
63 | exit; |
| 61 | } |
64 | } |
| 62 | 65 | ||
| 63 | $fileopenerr = 0; |
66 | $fileopenerr = 0; |
| 64 | open (CURRFILE, "<".$currentfilepath) or $fileopenerr = 1; |
67 | open (CURRFILE, "<".$currentfilepath) or $fileopenerr = 1; |
| 65 | if ($fileopenerr == 0) { |
68 | if ($fileopenerr == 0) { |
| 66 | $currentfile = <CURRFILE>; |
69 | $currentfile = <CURRFILE>; |
| 67 | if (!$currentfile && $startAtLine != 0) { |
70 | if (!$currentfile && $startAtLine != 0) { |
| 68 | print "Current file not ok\n"; |
71 | print "Current file not ok\n"; |
| 69 | exit; |
72 | exit; |
| 70 | } |
73 | } |
| 71 | close(CURRFILE); |
74 | close(CURRFILE); |
| 72 | } else { |
75 | } else { |
| 73 | print "Could not opeen ".$currentfilepath; |
76 | print "Could not opeen ".$currentfilepath; |
| 74 | if ($startAtLine != 0) { |
77 | if ($startAtLine != 0) { |
| 75 | exit; |
78 | exit; |
| 76 | } |
79 | } |
| 77 | } |
80 | } |
| 78 | 81 | ||
| 79 | $fileopenerr = 0; |
82 | $fileopenerr = 0; |
| 80 | open (LOGFILE, "<".$logfilepath) or $fileopenerr = 1; |
83 | open (LOGFILE, "<".$logfilepath) or $fileopenerr = 1; |
| 81 | if ($fileopenerr == 1) { |
84 | if ($fileopenerr == 1) { |
| 82 | print "Could not open ".$logfilepath; |
85 | print "Could not open ".$logfilepath; |
| 83 | exit; |
86 | exit; |
| 84 | } |
87 | } |
| Line 111... | Line 114... | ||
| 111 | $datetime =~ s/Session Time: //g; |
114 | $datetime =~ s/Session Time: //g; |
| 112 | $datetime =~ s/://g; |
115 | $datetime =~ s/://g; |
| 113 | $datetime =~ s/\n//g; |
116 | $datetime =~ s/\n//g; |
| 114 | $datetime =~ s/\r//g; |
117 | $datetime =~ s/\r//g; |
| 115 | $datetime =~ s/ /_/g; |
118 | $datetime =~ s/ /_/g; |
| - | 119 | $datetime = lc($datetime); |
|
| 116 | 120 | ||
| 117 | $currentfile = $datetime .".txt"; |
121 | $currentfile = $datetime .".txt"; |
| 118 | # skriv $datetimenice och $datetime till $contentspath |
122 | # skriv $datetimenice och $datetime till $contentspath |
| 119 | $fileopenerr = 0; |
123 | $fileopenerr = 0; |
| 120 | open (CONTENTSFILE, "<".$contentspath) or $fileopenerr = 1; |
124 | open (CONTENTSFILE, "<".$contentspath) or $fileopenerr = 1; |
| 121 | if ($fileopenerr == 0) { |
125 | if ($fileopenerr == 0) { |
| 122 | @contentsfilecontents = <CONTENTSFILE>; |
126 | @contentsfilecontents = <CONTENTSFILE>; |
| 123 | close(CONTENTSFILE); |
127 | close(CONTENTSFILE); |
| 124 | if ($debugmode == 0) { |
128 | if ($debugmode == 0) { |
| 125 | open (CONTENTSFILE, ">".$contentspath) or $fileopenerr = 1; |
129 | open (CONTENTSFILE, ">".$contentspath) or $fileopenerr = 1; |
| 126 | if ($fileopenerr == 0) { |
130 | if ($fileopenerr == 0) { |
| 127 | print CONTENTSFILE "[[ |
131 | print CONTENTSFILE "[[$namespace$datetime|$datetimenice]] \\\\ \n"; |
| 128 | foreach (@contentsfilecontents) { |
132 | foreach (@contentsfilecontents) { |
| 129 | print CONTENTSFILE $_; |
133 | print CONTENTSFILE $_; |
| 130 | } |
134 | } |
| 131 | close(CONTENTSFILE); |
135 | close(CONTENTSFILE); |
| 132 | } |
136 | } |
| 133 | } |
137 | } |
| 134 | } else { |
138 | } else { |
| 135 | exit; |
139 | exit; |
| 136 | } |
140 | } |
| 137 | 141 | ||
| 138 | if ($debugmode == 0) { |
142 | if ($debugmode == 0) { |
| 139 | $fileopenerr = 0; |
143 | $fileopenerr = 0; |
| 140 | open (OUTFILE, ">>".$outputpath.$currentfile) or $fileopenerr = 1; |
144 | open (OUTFILE, ">>".$outputpath.$currentfile) or $fileopenerr = 1; |
| 141 | if ($fileopenerr == 1) { |
145 | if ($fileopenerr == 1) { |
| 142 | print "Could not open ".$outputpath."/".$currentfile; |
146 | print "Could not open ".$outputpath."/".$currentfile; |
| 143 | exit; |
147 | exit; |
| 144 | } |
148 | } |
| 145 | } |
149 | } |
| 146 | 150 | ||
| 147 | #print $datetime; |
151 | #print $datetime; |
| 148 | } |
152 | } |
| 149 | 153 | ||
| 150 | if ($currentfile) { |
154 | if ($currentfile) { |
| 151 | $parsedLine = $line; |
155 | $parsedLine = $line; |
| 152 | $parsedLine =~ s/\n//g; |
156 | $parsedLine =~ s/\n//g; |
| 153 | $parsedLine =~ s/\r//g; |
157 | $parsedLine =~ s/\r//g; |
| 154 |
|
158 | #$parsedLine = $parsedLine; |
| - | 159 | ||
| 155 | $parsedLine =~ s/ |
160 | $parsedLine =~ s/\x{e5}/å/g; |
| 156 | $parsedLine =~ s/ |
161 | $parsedLine =~ s/\x{e4}/ä/g; |
| 157 | $parsedLine =~ s/ |
162 | $parsedLine =~ s/\x{f6}/ö/g; |
| 158 | $parsedLine =~ s/ |
163 | $parsedLine =~ s/\x{c5}/Å/g; |
| 159 | $parsedLine =~ s/ |
164 | $parsedLine =~ s/\x{c4}/Ä/g; |
| 160 | $parsedLine =~ s/ |
165 | $parsedLine =~ s/\x{d6}/Ö/g; |
| - | 166 | ||
| - | 167 | $parsedLine =~ s/\[wiki\]/**[wiki]**/g; |
|
| 161 | $parsedLine =~ s/ |
168 | $parsedLine =~ s/\[svn\]/**[svn]**/g; |
| 162 | 169 | ||
| 163 | $parsedLine .= "\\\\"."\n"; |
170 | $parsedLine .= "\\\\"."\n"; |
| 164 | if ($debugmode == 0) { |
171 | if ($debugmode == 0) { |
| 165 | print OUTFILE $parsedLine; |
172 | print OUTFILE $parsedLine; |
| 166 | } |
173 | } |