forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec.squid.statistics-build.php
executable file
·98 lines (79 loc) · 3.34 KB
/
exec.squid.statistics-build.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
if(posix_getuid()<>0){die("Cannot be used in web server mode\n\n");}
$GLOBALS["FORCE"]=false;
$GLOBALS["RECONFIGURE"]=false;
$GLOBALS["SWAPSTATE"]=false;
$GLOBALS["NOSQUIDOUTPUT"]=true;
$GLOBALS["TITLENAME"]="vsFTPD Daemon";
if(preg_match("#--verbose#",implode(" ",$argv))){$GLOBALS["VERBOSE"]=true;$GLOBALS["OUTPUT"]=true;$GLOBALS["debug"]=true;ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string',null);ini_set('error_append_string',null);}
if(preg_match("#--output#",implode(" ",$argv))){$GLOBALS["OUTPUT"]=true;}
if(preg_match("#schedule-id=([0-9]+)#",implode(" ",$argv),$re)){$GLOBALS["SCHEDULE_ID"]=$re[1];}
if(preg_match("#--force#",implode(" ",$argv),$re)){$GLOBALS["FORCE"]=true;}
if(preg_match("#--reconfigure#",implode(" ",$argv),$re)){$GLOBALS["RECONFIGURE"]=true;}
$GLOBALS["AS_ROOT"]=true;
include_once(dirname(__FILE__).'/ressources/class.ldap.inc');
include_once(dirname(__FILE__).'/ressources/class.squid.inc');
include_once(dirname(__FILE__).'/ressources/class.mysql.inc');
include_once(dirname(__FILE__).'/framework/class.unix.inc');
include_once(dirname(__FILE__).'/framework/frame.class.inc');
include_once(dirname(__FILE__).'/framework/class.settings.inc');
include_once(dirname(__FILE__).'/ressources/class.os.system.inc');
include_once(dirname(__FILE__).'/ressources/class.system.nics.inc');
include_once(dirname(__FILE__)."/ressources/class.influx.inc");
xstart($argv[1]);
function build_progress($text,$pourc){
$GLOBALS["PROGRESS_FILE"]="/usr/share/artica-postfix/ressources/logs/web/squid.statistics-{$GLOBALS["zMD5"]}.progress";
$array["POURC"]=$pourc;
$array["TEXT"]=$text;
echo "[$pourc]: $text\n";
@file_put_contents($GLOBALS["PROGRESS_FILE"], serialize($array));
@chmod($GLOBALS["PROGRESS_FILE"],0755);
}
function xstart($md5){
$GLOBALS["zMD5"]=$md5;
echo "***********************************\n";
echo "Report ID: $md5\n";
echo "***********************************\n";
$unix=new unix();
$php=$unix->LOCATE_PHP5_BIN();
$q=new mysql_squid_builder();
$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT report_type FROM reports_cache WHERE `zmd5`='$md5'"));
if(!$q->ok){
echo $q->mysql_error."\n";
build_progress("MySQL {failed}",110);
return;
}
$report_type=$ligne["report_type"];
echo "Report type: $report_type\n";
switch ($report_type) {
case "FLOW":
system("$php /usr/share/artica-postfix/exec.squid.statistics.FLOW.build.php $md5");
exit;
break;
case "MEMBERS":
system("$php /usr/share/artica-postfix/exec.squid.statistics.MEMBERS.build.php $md5");
exit;
break;
case "MEMBER_UNIQ":
echo "Running /usr/share/artica-postfix/exec.squid.statistics.MEMBERUNIQUE.build.php $md5\n";
system("$php /usr/share/artica-postfix/exec.squid.statistics.MEMBERUNIQUE.build.php $md5");
exit;
break;
case "WEBSITES":
echo "Running exec.squid.statistics.WEBSITES.build.php $md5\n";
system("$php /usr/share/artica-postfix/exec.squid.statistics.WEBSITES.build.php $md5");
exit;
break;
case "CATEGORIES":
system("$php /usr/share/artica-postfix/exec.squid.statistics.CATEGORIES.build.php $md5");
exit;
break;
case "WEBFILTERING":
system("$php /usr/share/artica-postfix/exec.squid.statistics.WEBFILTERING.build.php $md5");
exit;
break;
default:
build_progress("Unable to understand report $report_type {failed}",110);
break;
}
}