Skip to content

Commit bcfae40

Browse files
committed
FIX #24
1 parent 5b0a1eb commit bcfae40

File tree

7 files changed

+4379
-4308
lines changed

7 files changed

+4379
-4308
lines changed

make/fixdosfiles.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
#------------------------------------------------------
3+
# Script to find files that are not Unix encoded
4+
#
5+
# Laurent Destailleur - eldy@users.sourceforge.net
6+
#------------------------------------------------------
7+
# Usage: fixdosfiles.sh [list|fix]
8+
#------------------------------------------------------
9+
10+
# Syntax
11+
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
12+
then
13+
echo "This script detect or clean files with CR+LF into files with LF only. All source files are included, also files into includes."
14+
echo "Usage: fixdosfiles.sh [list|fix]"
15+
fi
16+
17+
# To detec
18+
if [ "x$1" = "xlist" ]
19+
then
20+
find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v '\/test' | grep CRLF
21+
fi
22+
23+
# To convert
24+
if [ "x$1" = "xfix" ]
25+
then
26+
for fic in `find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v '\/test' | grep CRLF | awk -F':' '{ print $1 }' `
27+
do
28+
echo "Fix file $fic"
29+
dos2unix "$fic"
30+
done;
31+
fi

make/fixutf8bomfiles.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
#
3+
# Checks of fix files contains UTF-8 BOM in dolibarr source tree,
4+
# excluding git repository, custom modules and included libraries.
5+
#
6+
# Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr
7+
# Laurent Destailleur eldy@users.sourceforge.net
8+
#------------------------------------------------------
9+
# Usage: fixutf8bomfiles.sh [list|fix]
10+
#------------------------------------------------------
11+
12+
# Syntax
13+
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
14+
then
15+
echo "Detect and fix bad UTF8 encoded files (UTF8 must not use BOM char)"
16+
echo "Usage: fixutf8bomfiles.sh (list|fix) [addincludes]"
17+
fi
18+
19+
if [ "x$2" != "xaddincludes" ]
20+
then
21+
export moreoptions="--exclude-dir='includes'"
22+
fi
23+
24+
# To detec
25+
if [ "x$1" = "xlist" ]
26+
then
27+
#find . \( -iname '*.php' -print0 -o -iname '*.sh' -print0 -o -iname '*.pl' -print0 -o -iname '*.lang' -print0 -o -iname '*.txt' \) -print0 | xargs -0 awk '/^\xEF\xBB\xBF/ {print FILENAME} {nextfile}'
28+
echo "grep -rlIZ --include='*.php' --include='*.sh' --include='*.pl' --include='*.lang' --include='*.txt' --exclude-dir='.git' --exclude-dir='.tx' $moreoptions --exclude-dir='custom' . . | xargs -0 awk '/^\xEF\xBB\xBF/ {print FILENAME} {nextfile}'"
29+
grep -rlIZ --include='*.php' --include='*.sh' --include='*.pl' --include='*.lang' --include='*.txt' --exclude-dir='.git' --exclude-dir='.tx' $moreoptions --exclude-dir='custom' . . | xargs -0 awk '/^\xEF\xBB\xBF/ {print FILENAME} {nextfile}'
30+
fi
31+
32+
# To convert
33+
if [ "x$1" = "xfix" ]
34+
then
35+
for fic in `grep -rlIZ --include='*.php' --include='*.sh' --include='*.pl' --include='*.lang' --include='*.txt' --exclude-dir='.git' --exclude-dir='.tx' $moreoptions --exclude-dir='custom' . . | xargs -0 awk '/^\xEF\xBB\xBF/ {print FILENAME} {nextfile}'`
36+
do
37+
echo "Fixing $fic"
38+
sed -i '1s/^\xEF\xBB\xBF//' $fic
39+
done;
40+
fi

wwwroot/cgi-bin/awdownloadcsv.pl

Lines changed: 152 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,152 @@
1-
#!/usr/bin/perl -w
2-
#------------------------------------------------------------------------------
3-
# Free addition to AWStats Web Log Analyzer. Used to export the contents of
4-
# sections of the Apache server log database to CSV for use in other tools.
5-
# Works from command line or as a CGI.
6-
#
7-
# This program is free software; you can redistribute it and/or modify
8-
# it under the terms of the GNU General Public License as published by
9-
# the Free Software Foundation; either version 2 of the License, or
10-
# (at your option) any later version.
11-
#
12-
# This program is distributed in the hope that it will be useful,
13-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
# GNU General Public License for more details.
16-
#
17-
# You should have received a copy of the GNU General Public License
18-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
#------------------------------------------------------------------------------
20-
use CGI qw(:standard);
21-
22-
my $ALLOWDOWNLOAD=0;
23-
24-
# Disabled by default for security reason
25-
if (! $ALLOWDOWNLOAD)
26-
{
27-
print("Error: You must first edit script to change ALLOWDOWNLOAD to 1 to allow usage of this script.\n");
28-
print("Reason is that enabling this script may be a security hole as it allows someone to download/view details of your awstats data files.\n");
29-
exit;
30-
}
31-
32-
my $q = new CGI;
33-
my $outputFile = ""; # used to write the output to a file
34-
my $inputFile = ""; # the fully qualified path to the input log database file
35-
my $sectionToReport = ""; # contains the tag to search for in the database file
36-
my $startSearchStr = "BEGIN_";
37-
my $endSearchStr = "END_";
38-
my $startPrinting = 0; # flag to indicate that the start tag has been found
39-
my $attachFileName = "";
40-
41-
# These parameters are used to build the input file name of the awstats log database
42-
my $baseName = "";
43-
my $month = "";
44-
my $year = "";
45-
my $day = "";
46-
my $siteConfig = "";
47-
48-
if ($q->param("outputFile")) {
49-
if ($outputFile eq '') { $outputFile = $q->param("outputFile"); }
50-
}
51-
52-
if ($q->param("inputFile")) {
53-
if ($inputFile eq '') { $inputFile = $q->param("inputFile"); }
54-
}
55-
56-
if ($q->param("section")) {
57-
if ($sectionToReport eq '' ) { $sectionToReport = $q->param("section"); }
58-
}
59-
60-
if ($q->param("baseName")) {
61-
if ($baseName eq '' ) { $baseName = $q->param("baseName"); }
62-
}
63-
64-
if ($q->param("month")) {
65-
if ($month eq '' ) { $month = $q->param("month"); }
66-
}
67-
68-
if ($q->param("year")) {
69-
if ($year eq '' ) { $year = $q->param("year"); }
70-
}
71-
72-
if ($q->param("day")) { $day = $q->param("day"); }
73-
74-
if ($q->param("siteConfig")) {
75-
if ($siteConfig eq '' ) { $siteConfig = $q->param("siteConfig"); }
76-
}
77-
78-
# set the attachment file name to the report section
79-
if ($sectionToReport ne '' ) {
80-
$attachFileName = $sectionToReport . ".csv";
81-
} else {
82-
$attachFileName = "exportCSV.csv";
83-
}
84-
print $q->header(-type=> "application/force-download", -attachment=>$attachFileName);
85-
86-
# Build the start/end search tags
87-
$startSearchStr = $startSearchStr . $sectionToReport;
88-
$endSearchStr = $endSearchStr . $sectionToReport;
89-
90-
if ( !$inputFile ) { $inputFile ="$baseName$month$year$day.$siteConfig.txt" };
91-
92-
open (IN, $inputFile) || die "cannot open $inputFile\n";
93-
94-
# If there's a parameter for the output, open it here
95-
if ($outputFile ne '') {
96-
open (OUT,">$outputFile") || die "cannot create $outputFile\n";
97-
flock (OUT, 2);
98-
}
99-
# Loop through the input file searching for the start string. When
100-
# found, start displaying the input lines (with spaces changed
101-
# to commas) until the end tag is found.
102-
103-
# Array to store comments for printing once we hit the desired section
104-
my $commentCount = -1;
105-
my %commentArray;
106-
107-
while (<IN>) {
108-
chomp;
109-
110-
if (/^#\s(.*-)\s/){ # search for comment lines
111-
s/ - /,/g; # replace dashes with commas
112-
s/#//; # get rid of the comment sign
113-
$commentArray[++$commentCount] = $_;
114-
}
115-
116-
# put the test to end printing here to eliminate printing
117-
# the line with the END tag
118-
if (/^$endSearchStr\b/) {
119-
$startPrinting = 0;
120-
}
121-
122-
if ($startPrinting) {
123-
s/ /,/g;
124-
print "$_\n";
125-
if ($outputFile ne '') {
126-
print OUT "$_\n";
127-
}
128-
}
129-
# if we find an END tag and we haven't started printing, reset the
130-
# comment array to start re-capturing comments for next section
131-
if ((/^END_/) && ($startPrinting == 0)) {
132-
$commentCount = -1;
133-
}
134-
135-
# put the start printing test after the first input line
136-
# to eliminate printing the line with the BEGIN tag...find it
137-
# here, then start printing on the next input line
138-
if (/^$startSearchStr\b/) {
139-
$startPrinting = 1;
140-
# print the comment array - it provides labels for the columns
141-
for ($i = 0; $i <= $commentCount; $i++ ) {
142-
print "$commentArray[$i]\n";
143-
}
144-
}
145-
}
146-
147-
close(IN);
148-
149-
# Close the output file if there was one used
150-
if ($outputFile ne '') {
151-
close(OUT);
152-
}
1+
#!/usr/bin/perl -w
2+
#------------------------------------------------------------------------------
3+
# Free addition to AWStats Web Log Analyzer. Used to export the contents of
4+
# sections of the Apache server log database to CSV for use in other tools.
5+
# Works from command line or as a CGI.
6+
#
7+
# This program is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#------------------------------------------------------------------------------
20+
use CGI qw(:standard);
21+
22+
my $ALLOWDOWNLOAD=0;
23+
24+
# Disabled by default for security reason
25+
if (! $ALLOWDOWNLOAD)
26+
{
27+
print("Error: You must first edit script to change ALLOWDOWNLOAD to 1 to allow usage of this script.\n");
28+
print("Reason is that enabling this script may be a security hole as it allows someone to download/view details of your awstats data files.\n");
29+
exit;
30+
}
31+
32+
my $q = new CGI;
33+
my $outputFile = ""; # used to write the output to a file
34+
my $inputFile = ""; # the fully qualified path to the input log database file
35+
my $sectionToReport = ""; # contains the tag to search for in the database file
36+
my $startSearchStr = "BEGIN_";
37+
my $endSearchStr = "END_";
38+
my $startPrinting = 0; # flag to indicate that the start tag has been found
39+
my $attachFileName = "";
40+
41+
# These parameters are used to build the input file name of the awstats log database
42+
my $baseName = "";
43+
my $month = "";
44+
my $year = "";
45+
my $day = "";
46+
my $siteConfig = "";
47+
48+
if ($q->param("outputFile")) {
49+
if ($outputFile eq '') { $outputFile = $q->param("outputFile"); }
50+
}
51+
52+
if ($q->param("inputFile")) {
53+
if ($inputFile eq '') { $inputFile = $q->param("inputFile"); }
54+
}
55+
56+
if ($q->param("section")) {
57+
if ($sectionToReport eq '' ) { $sectionToReport = $q->param("section"); }
58+
}
59+
60+
if ($q->param("baseName")) {
61+
if ($baseName eq '' ) { $baseName = $q->param("baseName"); }
62+
}
63+
64+
if ($q->param("month")) {
65+
if ($month eq '' ) { $month = $q->param("month"); }
66+
}
67+
68+
if ($q->param("year")) {
69+
if ($year eq '' ) { $year = $q->param("year"); }
70+
}
71+
72+
if ($q->param("day")) { $day = $q->param("day"); }
73+
74+
if ($q->param("siteConfig")) {
75+
if ($siteConfig eq '' ) { $siteConfig = $q->param("siteConfig"); }
76+
}
77+
78+
# set the attachment file name to the report section
79+
if ($sectionToReport ne '' ) {
80+
$attachFileName = $sectionToReport . ".csv";
81+
} else {
82+
$attachFileName = "exportCSV.csv";
83+
}
84+
print $q->header(-type=> "application/force-download", -attachment=>$attachFileName);
85+
86+
# Build the start/end search tags
87+
$startSearchStr = $startSearchStr . $sectionToReport;
88+
$endSearchStr = $endSearchStr . $sectionToReport;
89+
90+
if ( !$inputFile ) { $inputFile ="$baseName$month$year$day.$siteConfig.txt" };
91+
92+
open (IN, $inputFile) || die "cannot open $inputFile\n";
93+
94+
# If there's a parameter for the output, open it here
95+
if ($outputFile ne '') {
96+
open (OUT,">$outputFile") || die "cannot create $outputFile\n";
97+
flock (OUT, 2);
98+
}
99+
# Loop through the input file searching for the start string. When
100+
# found, start displaying the input lines (with spaces changed
101+
# to commas) until the end tag is found.
102+
103+
# Array to store comments for printing once we hit the desired section
104+
my $commentCount = -1;
105+
my %commentArray;
106+
107+
while (<IN>) {
108+
chomp;
109+
110+
if (/^#\s(.*-)\s/){ # search for comment lines
111+
s/ - /,/g; # replace dashes with commas
112+
s/#//; # get rid of the comment sign
113+
$commentArray[++$commentCount] = $_;
114+
}
115+
116+
# put the test to end printing here to eliminate printing
117+
# the line with the END tag
118+
if (/^$endSearchStr\b/) {
119+
$startPrinting = 0;
120+
}
121+
122+
if ($startPrinting) {
123+
s/ /,/g;
124+
print "$_\n";
125+
if ($outputFile ne '') {
126+
print OUT "$_\n";
127+
}
128+
}
129+
# if we find an END tag and we haven't started printing, reset the
130+
# comment array to start re-capturing comments for next section
131+
if ((/^END_/) && ($startPrinting == 0)) {
132+
$commentCount = -1;
133+
}
134+
135+
# put the start printing test after the first input line
136+
# to eliminate printing the line with the BEGIN tag...find it
137+
# here, then start printing on the next input line
138+
if (/^$startSearchStr\b/) {
139+
$startPrinting = 1;
140+
# print the comment array - it provides labels for the columns
141+
for ($i = 0; $i <= $commentCount; $i++ ) {
142+
print "$commentArray[$i]\n";
143+
}
144+
}
145+
}
146+
147+
close(IN);
148+
149+
# Close the output file if there was one used
150+
if ($outputFile ne '') {
151+
close(OUT);
152+
}

0 commit comments

Comments
 (0)