mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 19:23:24 +02:00
Squid-accounting: New Version using dma mailservice
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
committed by
Michael Tremer
parent
afd6e1931d
commit
0f14446a89
@@ -9,15 +9,15 @@
|
|||||||
|
|
||||||
include Config
|
include Config
|
||||||
|
|
||||||
VER = 1.0.3
|
VER = 1.0.4
|
||||||
|
|
||||||
THISAPP = squid-accounting-$(VER)
|
THISAPP = squid-accounting-$(VER)
|
||||||
DIR_APP = $(DIR_SRC)/$(THISAPP)
|
DIR_APP = $(DIR_SRC)/$(THISAPP)
|
||||||
TARGET = $(DIR_INFO)/$(THISAPP)
|
TARGET = $(DIR_INFO)/$(THISAPP)
|
||||||
PROG = squid-accounting
|
PROG = squid-accounting
|
||||||
PAK_VER = 6
|
PAK_VER = 7
|
||||||
|
|
||||||
DEPS = "perl-DBI perl-DBD-SQLite perl-File-ReadBackwards perl-PDF-API2 sendEmail"
|
DEPS = "perl-DBI perl-DBD-SQLite perl-File-ReadBackwards perl-PDF-API2"
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Top-level Rules
|
# Top-level Rules
|
||||||
@@ -50,8 +50,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
|
|||||||
chmod 777 /var/log/accounting.log
|
chmod 777 /var/log/accounting.log
|
||||||
#Set permissions for logo and graphs
|
#Set permissions for logo and graphs
|
||||||
chmod -R 777 /srv/web/ipfire/html/accounting
|
chmod -R 777 /srv/web/ipfire/html/accounting
|
||||||
|
|
||||||
|
|
||||||
install -v -m 755 $(DIR_APP)/squid-accounting/accounting.cgi /srv/web/ipfire/cgi-bin/
|
install -v -m 755 $(DIR_APP)/squid-accounting/accounting.cgi /srv/web/ipfire/cgi-bin/
|
||||||
install -v -m 755 $(DIR_APP)/squid-accounting/acct.pl /usr/local/bin/
|
install -v -m 755 $(DIR_APP)/squid-accounting/acct.pl /usr/local/bin/
|
||||||
install -v -m 644 $(DIR_APP)/squid-accounting/acct-lib.pl /var/ipfire/accounting/
|
install -v -m 644 $(DIR_APP)/squid-accounting/acct-lib.pl /var/ipfire/accounting/
|
||||||
@@ -61,10 +60,9 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
|
|||||||
install -v -m 755 $(DIR_APP)/squid-accounting/dbinstall.pl /var/ipfire/accounting/
|
install -v -m 755 $(DIR_APP)/squid-accounting/dbinstall.pl /var/ipfire/accounting/
|
||||||
install -v -m 644 $(DIR_APP)/squid-accounting/config/backup/includes/squid-accounting \
|
install -v -m 644 $(DIR_APP)/squid-accounting/config/backup/includes/squid-accounting \
|
||||||
/var/ipfire/backup/addons/includes/squid-accounting
|
/var/ipfire/backup/addons/includes/squid-accounting
|
||||||
|
|
||||||
#activate hourly logging of proxy logfile
|
#activate hourly logging of proxy logfile
|
||||||
ln -sf /usr/local/bin/acct.pl /etc/fcron.hourly/squid-accounting
|
ln -sf /usr/local/bin/acct.pl /etc/fcron.hourly/squid-accounting
|
||||||
|
|
||||||
chown -R nobody.nobody /var/ipfire/accounting
|
chown -R nobody.nobody /var/ipfire/accounting
|
||||||
@rm -rf $(DIR_APP)
|
@rm -rf $(DIR_APP)
|
||||||
@$(POSTBUILD)
|
@$(POSTBUILD)
|
||||||
|
|||||||
@@ -56,12 +56,17 @@ my $count=0;
|
|||||||
my $col;
|
my $col;
|
||||||
my $proxlog=$Lang::tr{'stopped'};
|
my $proxlog=$Lang::tr{'stopped'};
|
||||||
my $proxsrv=$Lang::tr{'stopped'};
|
my $proxsrv=$Lang::tr{'stopped'};
|
||||||
|
my $mailfile="${General::swroot}/dma/mail.conf";
|
||||||
|
|
||||||
&Header::getcgihash(\%cgiparams);
|
&Header::getcgihash(\%cgiparams);
|
||||||
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
|
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
|
||||||
&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
|
&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
|
||||||
&General::readhash("$settingsfile", \%settings) if(-f $settingsfile);
|
&General::readhash("$settingsfile", \%settings) if(-f $settingsfile);
|
||||||
|
|
||||||
|
if ( -f $mailfile){
|
||||||
|
&General::readhash($mailfile, \%mail);
|
||||||
|
}
|
||||||
|
|
||||||
#Find out which lang is set (used later to set decimal separator correctly)
|
#Find out which lang is set (used later to set decimal separator correctly)
|
||||||
my $uplang=uc($mainsettings{'LANGUAGE'});
|
my $uplang=uc($mainsettings{'LANGUAGE'});
|
||||||
setlocale LC_NUMERIC,"$mainsettings{'LANGUAGE'}_$uplang";
|
setlocale LC_NUMERIC,"$mainsettings{'LANGUAGE'}_$uplang";
|
||||||
@@ -136,11 +141,6 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ #SaveButton on configsite
|
|||||||
if ($cgiparams{'USEMAIL'} eq 'on'){
|
if ($cgiparams{'USEMAIL'} eq 'on'){
|
||||||
$errormessage=&checkmailsettings;
|
$errormessage=&checkmailsettings;
|
||||||
}elsif($cgiparams{'USEMAIL'} ne 'on'){
|
}elsif($cgiparams{'USEMAIL'} ne 'on'){
|
||||||
$cgiparams{'txt_mailserver'}='';
|
|
||||||
$cgiparams{'txt_mailport'}='';
|
|
||||||
$cgiparams{'txt_mailuser'}='';
|
|
||||||
$cgiparams{'txt_mailpass'}='';
|
|
||||||
$cgiparams{'mail_tls'}='';
|
|
||||||
$cgiparams{'txt_mailsender'}='';
|
$cgiparams{'txt_mailsender'}='';
|
||||||
$cgiparams{'txt_mailsubject'}='';
|
$cgiparams{'txt_mailsubject'}='';
|
||||||
$mailtxt='';
|
$mailtxt='';
|
||||||
@@ -155,11 +155,6 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}"){ #SaveButton on configsite
|
|||||||
$settings{'CURRENCY'} = $cgiparams{'txt_currency'};
|
$settings{'CURRENCY'} = $cgiparams{'txt_currency'};
|
||||||
$settings{'SKIPURLS'} = $skipurls;
|
$settings{'SKIPURLS'} = $skipurls;
|
||||||
$settings{'USEMAIL'} = $cgiparams{'USEMAIL'};
|
$settings{'USEMAIL'} = $cgiparams{'USEMAIL'};
|
||||||
$settings{'MAILSRV'} = $cgiparams{'txt_mailserver'};
|
|
||||||
$settings{'MAILPORT'} = $cgiparams{'txt_mailport'};
|
|
||||||
$settings{'MAILUSER'} = $cgiparams{'txt_mailuser'};
|
|
||||||
$settings{'MAILPASS'} = $cgiparams{'txt_mailpass'};
|
|
||||||
$settings{'TLS'} = $cgiparams{'mail_tls'};
|
|
||||||
$settings{'MAILSENDER'} = $cgiparams{'txt_mailsender'};
|
$settings{'MAILSENDER'} = $cgiparams{'txt_mailsender'};
|
||||||
$settings{'MAILSUB'} = $cgiparams{'txt_mailsubject'};
|
$settings{'MAILSUB'} = $cgiparams{'txt_mailsubject'};
|
||||||
$settings{'MAILTXT'} = $mailtxt;
|
$settings{'MAILTXT'} = $mailtxt;
|
||||||
@@ -568,10 +563,6 @@ sub configsite{
|
|||||||
#If update set fieldvalues new
|
#If update set fieldvalues new
|
||||||
if($cgiparams{'update'} eq 'on'){
|
if($cgiparams{'update'} eq 'on'){
|
||||||
$settings{'USEMAIL'} = 'on';
|
$settings{'USEMAIL'} = 'on';
|
||||||
$settings{'MAILSRV'} = $cgiparams{'txt_mailserver'};
|
|
||||||
$settings{'MAILPORT'} = $cgiparams{'txt_mailport'};
|
|
||||||
$settings{'MAILUSER'} = $cgiparams{'txt_mailuser'};
|
|
||||||
$settings{'MAILPASS'} = $cgiparams{'txt_mailpass'};
|
|
||||||
$settings{'MAILSUB'} = $cgiparams{'txt_mailsubject'};
|
$settings{'MAILSUB'} = $cgiparams{'txt_mailsubject'};
|
||||||
$settings{'MAILTXT'} = $cgiparams{'txt_mailtxt'};
|
$settings{'MAILTXT'} = $cgiparams{'txt_mailtxt'};
|
||||||
}
|
}
|
||||||
@@ -580,14 +571,13 @@ sub configsite{
|
|||||||
$checked{'logging'}{$settings{'LOG'}} = 'CHECKED';
|
$checked{'logging'}{$settings{'LOG'}} = 'CHECKED';
|
||||||
$checked{'multiuser'}{$settings{'MULTIUSER'}} = 'CHECKED';
|
$checked{'multiuser'}{$settings{'MULTIUSER'}} = 'CHECKED';
|
||||||
$checked{'usemail'}{$settings{'USEMAIL'}} = 'CHECKED';
|
$checked{'usemail'}{$settings{'USEMAIL'}} = 'CHECKED';
|
||||||
$checked{'mail_tls'}{$settings{'TLS'}} = 'CHECKED';
|
|
||||||
|
|
||||||
#Open site
|
#Open site
|
||||||
&Header::openpage($Lang::tr{'acct settings'}, 1, '');
|
&Header::openpage($Lang::tr{'acct settings'}, 1, '');
|
||||||
&Header::openbigbox('100%', 'center');
|
&Header::openbigbox('100%', 'center');
|
||||||
&error;
|
&error;
|
||||||
&Header::openbox('100%', 'left', $Lang::tr{'acct config'});
|
&Header::openbox('100%', 'left', $Lang::tr{'acct config'});
|
||||||
|
|
||||||
#### JAVA SCRIPT ####
|
#### JAVA SCRIPT ####
|
||||||
print<<END;
|
print<<END;
|
||||||
<script>
|
<script>
|
||||||
@@ -631,57 +621,45 @@ END
|
|||||||
<td>$Lang::tr{'acct multiuser'}</td>
|
<td>$Lang::tr{'acct multiuser'}</td>
|
||||||
<td><input type='checkbox' name='multiuser' $checked{'multiuser'}{'on'}></td>
|
<td><input type='checkbox' name='multiuser' $checked{'multiuser'}{'on'}></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct mwst'}</td>
|
<td>$Lang::tr{'acct mwst'}</td>
|
||||||
<td><input type='text' name='txt_mwst' value='$settings{'MWST'}' style='width:22em;'></td>
|
<td><input type='text' name='txt_mwst' value='$settings{'MWST'}' style='width:22em;'></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct currency'}</td>
|
<td>$Lang::tr{'acct currency'}</td>
|
||||||
<td><input type='text' name='txt_currency' value='$settings{'CURRENCY'}' style='width:22em;'></td>
|
<td><input type='text' name='txt_currency' value='$settings{'CURRENCY'}' style='width:22em;'></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign='top'>$Lang::tr{'acct skipurl'}</td>
|
<td valign='top'>$Lang::tr{'acct skipurl'}</td>
|
||||||
<td style='padding-left:0.2em;'><textarea name="txt_skipurls" cols="20" rows="6" style='width:22em;'>$settings{'SKIPURLS'}</textarea></td>
|
<td style='padding-left:0.2em;'><textarea name="txt_skipurls" cols="20" rows="6" style='width:22em;'>$settings{'SKIPURLS'}</textarea></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
END
|
||||||
|
|
||||||
|
if ($mail{'USEMAIL'} eq 'on'){
|
||||||
|
if (!$settings{'MAILSENDER'}){
|
||||||
|
$settings{'MAILSENDER'} = $mail{'SENDER'};
|
||||||
|
}
|
||||||
|
print <<END;
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct usemail'}</td>
|
<td>$Lang::tr{'acct usemail'}</td>
|
||||||
<td><label><input type='checkbox' name='USEMAIL' id='MAIL' $checked{'usemail'}{'on'}></label></td>
|
<td><label><input type='checkbox' name='USEMAIL' id='MAIL' $checked{'usemail'}{'on'}></label></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table><br>
|
END
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<END;
|
||||||
|
</table><br>
|
||||||
<div class="MAILSRV">
|
<div class="MAILSRV">
|
||||||
<table style='width:100%;'>
|
<table style='width:100%;'>
|
||||||
<tr>
|
<tr>
|
||||||
<td style='width:24em'>$Lang::tr{'acct mailaddr'}</td>
|
<td style='width:24em'>$Lang::tr{'acct mailsender'}</td>
|
||||||
<td><input type='text' name='txt_mailserver' value='$settings{'MAILSRV'}' style='width:22em;'></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>$Lang::tr{'acct mailport'}</td>
|
|
||||||
<td><input type='text' name='txt_mailport' value='$settings{'MAILPORT'}' size='3'></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>$Lang::tr{'acct mailuser'}<img src='/blob.gif' alt='*' /></td>
|
|
||||||
<td><input type='text' name='txt_mailuser' value='$settings{'MAILUSER'}' style='width:22em;'></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>$Lang::tr{'acct mailpass'}<img src='/blob.gif' alt='*' /></td>
|
|
||||||
<td><input type='password' name='txt_mailpass' value='$settings{'MAILPASS'}' style='width:22em;' ></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>$Lang::tr{'acct tls'}</td>
|
|
||||||
<td><input type='checkbox' name='mail_tls' $checked{'mail_tls'}{'on'}></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>$Lang::tr{'acct mailsender'}</td>
|
|
||||||
<td><input type='text' name='txt_mailsender' value='$settings{'MAILSENDER'}' style='width:22em;'></td>
|
<td><input type='text' name='txt_mailsender' value='$settings{'MAILSENDER'}' style='width:22em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td colspan='2'> </td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct subject'}</td>
|
<td>$Lang::tr{'acct subject'}</td>
|
||||||
<td><input type='text' name='txt_mailsubject' value='$settings{'MAILSUB'}' style='width:22em;'></td>
|
<td><input type='text' name='txt_mailsubject' value='$settings{'MAILSUB'}' style='width:22em;'></td>
|
||||||
@@ -693,7 +671,6 @@ END
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<table style='width:100%;'>
|
<table style='width:100%;'>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='3' display:inline align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}'></td>
|
<td colspan='3' display:inline align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}'></td>
|
||||||
@@ -1119,28 +1096,28 @@ print<<END;
|
|||||||
<td>
|
<td>
|
||||||
<input type='radio' name='rdo_companytype' value='CUST' $checked{'rdo_companytype'}{'CUST'}>$Lang::tr{'acct customer'}
|
<input type='radio' name='rdo_companytype' value='CUST' $checked{'rdo_companytype'}{'CUST'}>$Lang::tr{'acct customer'}
|
||||||
<input type='radio' name='rdo_companytype' value='HOST' $checked{'rdo_companytype'}{'HOST'}>$Lang::tr{'acct hoster'}</td>
|
<input type='radio' name='rdo_companytype' value='HOST' $checked{'rdo_companytype'}{'HOST'}>$Lang::tr{'acct hoster'}</td>
|
||||||
<td style='width:8em;'>$Lang::tr{'acct bank'}</td>
|
<td style='width:8em;'>$Lang::tr{'acct bank'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_bank' value='$cgiparams{'txt_bank'}' style='width:25em;'></td>
|
<input type='text' name='txt_bank' value='$cgiparams{'txt_bank'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct company'}</td>
|
<td>$Lang::tr{'acct company'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_company' value='$cgiparams{'txt_company'}' style='width:25em;'></td>
|
<input type='text' name='txt_company' value='$cgiparams{'txt_company'}' style='width:25em;'></td>
|
||||||
<td>$Lang::tr{'acct iban'}<img src='/blob.gif' alt='*' /></td>
|
<td>$Lang::tr{'acct iban'}</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_iban' value='$cgiparams{'txt_iban'}' style='width:25em;'></td>
|
<input type='text' name='txt_iban' value='$cgiparams{'txt_iban'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct name1'}<img src='/blob.gif' alt='*' /></td>
|
<td>$Lang::tr{'acct name1'}</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_name1' value='$cgiparams{'txt_name1'}' style='width:25em;'></td>
|
<input type='text' name='txt_name1' value='$cgiparams{'txt_name1'}' style='width:25em;'></td>
|
||||||
<td>$Lang::tr{'acct bic'}<img src='/blob.gif' alt='*' /></td>
|
<td>$Lang::tr{'acct bic'}</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_bic' maxlength='8' value='$cgiparams{'txt_bic'}' style='width:25em;'></td>
|
<input type='text' name='txt_bic' maxlength='8' value='$cgiparams{'txt_bic'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct str'}</td>
|
<td>$Lang::tr{'acct str'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td align='left'>
|
<td align='left'>
|
||||||
<input type='text' name='txt_str' value='$cgiparams{'txt_str'}' style='width:25em;'></td>
|
<input type='text' name='txt_str' value='$cgiparams{'txt_str'}' style='width:25em;'></td>
|
||||||
<td>$Lang::tr{'acct blz'}</td>
|
<td>$Lang::tr{'acct blz'}</td>
|
||||||
@@ -1148,7 +1125,7 @@ print<<END;
|
|||||||
<input type='text' name='txt_blz' maxlength='8' value='$cgiparams{'txt_blz'}' style='width:25em;'></td>
|
<input type='text' name='txt_blz' maxlength='8' value='$cgiparams{'txt_blz'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct str_nr'}</td>
|
<td>$Lang::tr{'acct str_nr'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td><input type='text' name='txt_str_nr' value='$cgiparams{'txt_str_nr'}' style='width:25em;'></td>
|
<td><input type='text' name='txt_str_nr' value='$cgiparams{'txt_str_nr'}' style='width:25em;'></td>
|
||||||
<td>$Lang::tr{'acct kto'}</td>
|
<td>$Lang::tr{'acct kto'}</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -1157,16 +1134,16 @@ print<<END;
|
|||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct plz'}</td>
|
<td>$Lang::tr{'acct plz'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_plz' value='$cgiparams{'txt_plz'}' style='width:25em;'></td>
|
<input type='text' name='txt_plz' value='$cgiparams{'txt_plz'}' style='width:25em;'></td>
|
||||||
<td>$Lang::tr{'acct email'}</td>
|
<td>$Lang::tr{'acct email'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td><input type='text' name='txt_email' value='$cgiparams{'txt_email'}' style='width:25em;'></td>
|
<td><input type='text' name='txt_email' value='$cgiparams{'txt_email'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$Lang::tr{'acct city'}</td>
|
<td>$Lang::tr{'acct city'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td><input type='text' name='txt_city' value='$cgiparams{'txt_city'}' style='width:25em;'></td>
|
<td><input type='text' name='txt_city' value='$cgiparams{'txt_city'}' style='width:25em;'></td>
|
||||||
<td>$Lang::tr{'acct inet'}<img src='/blob.gif' alt='*' /></td>
|
<td>$Lang::tr{'acct inet'}</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_inet' value='$cgiparams{'txt_inet'}' style='width:25em;'></td>
|
<input type='text' name='txt_inet' value='$cgiparams{'txt_inet'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -1180,25 +1157,25 @@ print<<END;
|
|||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>$Lang::tr{'acct ustid'}</td>
|
<td>$Lang::tr{'acct ustid'}<img src='/blob.gif' alt='*' /></td>
|
||||||
<td><input type='text' name='txt_ustid' value='$cgiparams{'txt_ustid'}' style='width:25em;'></td>
|
<td><input type='text' name='txt_ustid' value='$cgiparams{'txt_ustid'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>$Lang::tr{'acct tel'}<img src='/blob.gif' alt='*' /></td>
|
<td>$Lang::tr{'acct tel'}</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_tel' value='$cgiparams{'txt_tel'}' style='width:25em;'></td>
|
<input type='text' name='txt_tel' value='$cgiparams{'txt_tel'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>$Lang::tr{'acct fax'}<img src='/blob.gif' alt='*' /></td>
|
<td>$Lang::tr{'acct fax'}</td>
|
||||||
<td>
|
<td>
|
||||||
<input type='text' name='txt_fax' value='$cgiparams{'txt_fax'}' style='width:25em;'></td>
|
<input type='text' name='txt_fax' value='$cgiparams{'txt_fax'}' style='width:25em;'></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='6'><img src='/blob.gif' alt='*' /><font size="1">$Lang::tr{'acct optional'}</font></td>
|
<td colspan='6'><img src='/blob.gif' alt='*' /><font size="1">$Lang::tr{'acct not optional'}</font></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
END
|
END
|
||||||
@@ -2175,18 +2152,6 @@ END
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub checkmailsettings{
|
sub checkmailsettings{
|
||||||
#Check if mailserver is an ip address or a domain
|
|
||||||
if ($cgiparams{'txt_mailserver'} =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/){
|
|
||||||
if (! &General::validip($cgiparams{'txt_mailserver'})){
|
|
||||||
$errormessage.="$Lang::tr{'acct invalid mailip'} $cgiparams{'txt_mailserver'}<br>";
|
|
||||||
}
|
|
||||||
}elsif(! &General::validfqdn($cgiparams{'txt_mailserver'})){
|
|
||||||
$errormessage.="$Lang::tr{'acct invalid mailfqdn'} $cgiparams{'txt_mailserver'}<br>";
|
|
||||||
}
|
|
||||||
#Check valid mailserverport
|
|
||||||
if($cgiparams{'txt_mailport'} < 1 || $cgiparams{'txt_mailport'} > 65535){
|
|
||||||
$errormessage.="$Lang::tr{'acct invalid mailport'} $cgiparams{'txt_mailport'}<br>";
|
|
||||||
}
|
|
||||||
#Check valid sender
|
#Check valid sender
|
||||||
if(! $cgiparams{'txt_mailsender'}){
|
if(! $cgiparams{'txt_mailsender'}){
|
||||||
$errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct mailsender'}<br>";
|
$errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct mailsender'}<br>";
|
||||||
|
|||||||
@@ -88,9 +88,9 @@
|
|||||||
'acct mwst' => 'Mehrwertsteuer in %',
|
'acct mwst' => 'Mehrwertsteuer in %',
|
||||||
'acct name1' => 'Name 1',
|
'acct name1' => 'Name 1',
|
||||||
'acct name2' => 'Name 2',
|
'acct name2' => 'Name 2',
|
||||||
|
'acct not optional' => 'Diese Felder sind Pflichtfelder',
|
||||||
'acct nr' => 'RG-Nr.',
|
'acct nr' => 'RG-Nr.',
|
||||||
'acct oldestdb' => 'Erster DB-Eintrag',
|
'acct oldestdb' => 'Erster DB-Eintrag',
|
||||||
'acct optional' => 'Diese Felder sind optional',
|
|
||||||
'acct parameter' => 'Parameter',
|
'acct parameter' => 'Parameter',
|
||||||
'acct path' => 'Pfad',
|
'acct path' => 'Pfad',
|
||||||
'acct pdf billtxt' => 'Rechnung',
|
'acct pdf billtxt' => 'Rechnung',
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
'acct name2' => 'Name 2',
|
'acct name2' => 'Name 2',
|
||||||
'acct nr' => 'RG-No.',
|
'acct nr' => 'RG-No.',
|
||||||
'acct oldestdb' => 'Fist DB Entry',
|
'acct oldestdb' => 'Fist DB Entry',
|
||||||
'acct optional' => 'These fields are optional',
|
'acct not optional' => 'These fields are required',
|
||||||
'acct parameter' => 'Parameter',
|
'acct parameter' => 'Parameter',
|
||||||
'acct path' => 'Path',
|
'acct path' => 'Path',
|
||||||
'acct pdf billtxt' => 'Bill',
|
'acct pdf billtxt' => 'Bill',
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
use Time::Local;
|
use Time::Local;
|
||||||
use File::ReadBackwards;
|
use File::ReadBackwards;
|
||||||
use strict;
|
use strict;
|
||||||
|
use MIME::Lite;
|
||||||
|
|
||||||
#use warnings;
|
#use warnings;
|
||||||
|
|
||||||
require '/var/ipfire/general-functions.pl';
|
require '/var/ipfire/general-functions.pl';
|
||||||
@@ -62,6 +64,11 @@ my ($mini,$max)=&ACCT::getminmax;
|
|||||||
my $now = localtime;
|
my $now = localtime;
|
||||||
my $proxylog;
|
my $proxylog;
|
||||||
my $proxysrv;
|
my $proxysrv;
|
||||||
|
my $dmafile="${General::swroot}/dma/dma.conf";
|
||||||
|
my $authfile="${General::swroot}/dma/auth.conf";
|
||||||
|
my $mailfile="${General::swroot}/dma/mail.conf";
|
||||||
|
my %mail=();
|
||||||
|
my %dma=();
|
||||||
|
|
||||||
########
|
########
|
||||||
# Main #
|
# Main #
|
||||||
@@ -69,6 +76,7 @@ my $proxysrv;
|
|||||||
|
|
||||||
&checkproxy;
|
&checkproxy;
|
||||||
|
|
||||||
|
|
||||||
#If we have a disabled file and the proxy is off, we don't need to check anything, exit!
|
#If we have a disabled file and the proxy is off, we don't need to check anything, exit!
|
||||||
if((! -f $proxyenabled || $proxylog eq $Lang::tr{'stopped'}) && -f "${General::swroot}/accounting/disabled"){
|
if((! -f $proxyenabled || $proxylog eq $Lang::tr{'stopped'}) && -f "${General::swroot}/accounting/disabled"){
|
||||||
&ACCT::logger($settings{'LOG'}," Proxy or proxylogging disabled - exiting with no data collection\n");
|
&ACCT::logger($settings{'LOG'}," Proxy or proxylogging disabled - exiting with no data collection\n");
|
||||||
@@ -92,7 +100,7 @@ if (-f $proxyenabled && $proxylog eq $Lang::tr{'running'}){
|
|||||||
$dbh=&ACCT::connectdb;
|
$dbh=&ACCT::connectdb;
|
||||||
my $m=sprintf("%d",(localtime((time-3600)))[4]+1);
|
my $m=sprintf("%d",(localtime((time-3600)))[4]+1);
|
||||||
&ACCT::logger($settings{'LOG'},"month before one hour $m, now is ".($mon+1)."\n");
|
&ACCT::logger($settings{'LOG'},"month before one hour $m, now is ".($mon+1)."\n");
|
||||||
if ($m < ($mon+1) || $m == '12' && ($mon+1) == '1'){
|
if ($m = ($mon+1) || $m == '12' && ($mon+1) == '1'){
|
||||||
#Logrotate
|
#Logrotate
|
||||||
my $year1=$year+1900;
|
my $year1=$year+1900;
|
||||||
system ("tar", "cfz", "/var/log/accounting-$m-$year1.tar.gz", "/var/log/accounting.log");
|
system ("tar", "cfz", "/var/log/accounting-$m-$year1.tar.gz", "/var/log/accounting.log");
|
||||||
@@ -103,11 +111,22 @@ if (-f $proxyenabled && $proxylog eq $Lang::tr{'running'}){
|
|||||||
#move all db entries older than this month to second table and cumulate them daily
|
#move all db entries older than this month to second table and cumulate them daily
|
||||||
&ACCT::movedbdata;
|
&ACCT::movedbdata;
|
||||||
&ACCT::logger($settings{'LOG'},"New Month. Old trafficvalues moved to ACCT_HIST Table\n");
|
&ACCT::logger($settings{'LOG'},"New Month. Old trafficvalues moved to ACCT_HIST Table\n");
|
||||||
if ($settings{'USEMAIL'} eq 'on'){
|
#check if mail is enabled
|
||||||
|
if ( -f $mailfile){
|
||||||
|
&General::readhash($mailfile, \%mail);
|
||||||
|
}
|
||||||
|
if ($mail{'USEMAIL'} eq 'on'){
|
||||||
&ACCT::logger($settings{'LOG'},"Mailserver is activated - Now sending bills via mail...\n");
|
&ACCT::logger($settings{'LOG'},"Mailserver is activated - Now sending bills via mail...\n");
|
||||||
my $res=&ACCT::getbillgroups;
|
my $res=&ACCT::getbillgroups;
|
||||||
foreach my $line (@$res){
|
foreach my $line (@$res){
|
||||||
my ($grp) = @$line;
|
my ($grp) = @$line;
|
||||||
|
open (FILE, "<", $dmafile) or die $!;
|
||||||
|
foreach my $line (<FILE>) {
|
||||||
|
$line =~ m/^([A-Z]+)\s+?(.*)?$/;
|
||||||
|
my $key = $1;
|
||||||
|
my $val = $2;
|
||||||
|
$dma{$key}=$val;
|
||||||
|
}
|
||||||
&sendbill($grp,$settings{'MWST'},$settings{'CURRENCY'});
|
&sendbill($grp,$settings{'MWST'},$settings{'CURRENCY'});
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -214,7 +233,7 @@ sub sendbill {
|
|||||||
$month = '0'.$actmonth if $actmonth < 10;
|
$month = '0'.$actmonth if $actmonth < 10;
|
||||||
$month = '12' if $actmonth == 0;
|
$month = '12' if $actmonth == 0;
|
||||||
my $actyear = $now[5];
|
my $actyear = $now[5];
|
||||||
my ($from,$till)=&ACCT::getmonth($actmonth,$actyear); #FIXME month and year as variables!
|
my ($from,$till)=&ACCT::getmonth($actmonth,$actyear);
|
||||||
my @billar = &ACCT::GetTaValues($from,$till,$rggrp);
|
my @billar = &ACCT::GetTaValues($from,$till,$rggrp);
|
||||||
my $address_cust = &ACCT::getTaAddress($rggrp,'CUST');
|
my $address_cust = &ACCT::getTaAddress($rggrp,'CUST');
|
||||||
my $address_host = &ACCT::getTaAddress($rggrp,'HOST');
|
my $address_host = &ACCT::getTaAddress($rggrp,'HOST');
|
||||||
@@ -229,23 +248,34 @@ sub sendbill {
|
|||||||
|
|
||||||
if ($back eq '0'){
|
if ($back eq '0'){
|
||||||
&ACCT::logger($settings{'LOG'},"Bill for $company_cust successfully created.\n");
|
&ACCT::logger($settings{'LOG'},"Bill for $company_cust successfully created.\n");
|
||||||
my $file="'/var/ipfire/accounting/bill/$rggrp/$month-$actyear-$no.pdf'";
|
my $file="/var/ipfire/accounting/bill/$rggrp/$month-$actyear-$no.pdf";
|
||||||
$settings{'MAILTXT'} =~ tr/\|/\r\n/ ;
|
$settings{'MAILTXT'} =~ tr/\|/\r\n/ ;
|
||||||
my $cmd = "/usr/local/bin/sendEmail ";
|
|
||||||
$cmd .= " -f $settings{'MAILSENDER'}"; #Sender
|
#extract filename from path
|
||||||
$cmd .= " -t $email"; #Recipient
|
my ($filename) = $file =~ m{([^/]+)$};
|
||||||
if ($ccmail){
|
|
||||||
$cmd .= " -cc $ccmail";
|
my $msg = MIME::Lite->new(
|
||||||
}
|
From => $mail{'SENDER'},
|
||||||
#Send Mail via TLS?
|
To => $email,
|
||||||
if ($settings{'TLS'} eq 'on'){
|
Cc => $ccmail,
|
||||||
$cmd .= " -o tls=yes"; #TLS
|
Subject => $settings{'MAILSUB'},
|
||||||
}
|
Type => 'multipart/mixed'
|
||||||
$cmd .= " -u '$settings{'MAILSUB'}'"; #Subject
|
);
|
||||||
$cmd .= " -m '$settings{'MAILTXT'}'"; #Mailtext
|
|
||||||
$cmd .= " -s $settings{'MAILSRV'}:$settings{'MAILPORT'}"; #Mailserver:port
|
$msg->attach(
|
||||||
$cmd .= " -a $file";
|
Type => 'TEXT',
|
||||||
my $res=system ($cmd);
|
Data => $settings{'MAILTXT'}
|
||||||
|
);
|
||||||
|
|
||||||
|
$msg->attach(
|
||||||
|
Type => 'application/pdf',
|
||||||
|
Path => $file,
|
||||||
|
Filename => $filename,
|
||||||
|
Disposition => 'attachment'
|
||||||
|
);
|
||||||
|
|
||||||
|
my $res=$msg->send_by_sendmail;
|
||||||
|
|
||||||
if ($res == 0){
|
if ($res == 0){
|
||||||
&ACCT::logger($settings{'LOG'},"Bill for $company_cust successfully sent.\n");
|
&ACCT::logger($settings{'LOG'},"Bill for $company_cust successfully sent.\n");
|
||||||
}elsif ($res > 0){
|
}elsif ($res > 0){
|
||||||
@@ -255,13 +285,19 @@ sub sendbill {
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
&ACCT::logger($settings{'LOG'},"ERROR Bill for $company_cust could not be created.\n");
|
&ACCT::logger($settings{'LOG'},"ERROR Bill for $company_cust could not be created.\n");
|
||||||
my $cmd = "/usr/local/bin/sendEmail ";
|
my $msg = MIME::Lite->new(
|
||||||
$cmd .= " -f $settings{'MAILSENDER'}";
|
From => $mail{'SENDER'},
|
||||||
$cmd .= " -t $settings{'MAILSENDER'}";
|
To => $mail{'RECIPIENT'},
|
||||||
$cmd .= " -u Fehler Squid Accounting";
|
Subject => "ERROR Squid Accounting",
|
||||||
$cmd .= " -m 'Die Rechnung konnte nicht erzeugt und per Mail versendet werden' $company_cust";
|
Type => 'multipart/mixed'
|
||||||
$cmd .= " -s $settings{'MAILSRV'}:$settings{'MAILPORT'}";
|
);
|
||||||
my $res=system ($cmd);
|
|
||||||
|
$msg->attach(
|
||||||
|
Type => 'TEXT',
|
||||||
|
Data => "The bill could not be created for customer $company_cust"
|
||||||
|
);
|
||||||
|
|
||||||
|
$msg->send_by_sendmail;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user