forked from poppyred/1.6.x
/
exec.ntopng.disable.php
executable file
·60 lines (50 loc) · 2.57 KB
/
exec.ntopng.disable.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
<?php
if(is_file("/etc/artica-postfix/FROM_ISO")){if(is_file("/etc/init.d/artica-cd")){print "Starting......: ".date("H:i:s")." artica-". basename(__FILE__)." Waiting Artica-CD to finish\n";die();}}
if(posix_getuid()<>0){die("Cannot be used in web server mode\n\n");}
$GLOBALS["FORCE"]=false;
$GLOBALS["RECONFIGURE"]=false;
$GLOBALS["SWAPSTATE"]=false;
$GLOBALS["SERVICE_NAME"]="Network traffic probe";
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__).'/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.squid.inc');
include_once(dirname(__FILE__).'/ressources/class.system.network.inc');
$GLOBALS["ARGVS"]=implode(" ",$argv);
if($argv[1]=="--stop"){$GLOBALS["OUTPUT"]=true;stop();die();}
if($argv[1]=="--start"){$GLOBALS["OUTPUT"]=true;start();die();}
if($argv[1]=="--restart"){$GLOBALS["OUTPUT"]=true;restart();die();}
if($argv[1]=="--reload"){$GLOBALS["OUTPUT"]=true;reload();die();}
if($argv[1]=="--build"){$GLOBALS["OUTPUT"]=true;build();die();}
if($argv[1]=="--clean"){$GLOBALS["OUTPUT"]=true;cleanstorage();die();}
$GLOBALS["OUTPUT"]=true;
xstart();
function build_progress($text,$pourc){
$GLOBALS["CACHEFILE"]="/usr/share/artica-postfix/ressources/logs/web/disable-ntopng.progress";
echo "[{$pourc}%] $text\n";
$array["POURC"]=$pourc;
$array["TEXT"]=$text;
@file_put_contents($GLOBALS["CACHEFILE"], serialize($array));
@chmod($GLOBALS["CACHEFILE"],0755);
if($GLOBALS["OUTPUT"]){sleep(1);}
}
function xstart(){
build_progress("Change settings...",10);
$sock=new sockets();
$unix=new unix();
$sock->SET_INFO("Enablentopng", 0);
build_progress("Stopping service..",15);
system("/etc/init.d/ntopng stop");
build_progress("Restarting Artica-Status..",20);
system("/etc/init.d/artica-status restart --force");
build_progress("Remove history..",50);
$rm=$unix->find_program("rm");
system("$rm -rf /home/ntopng/*");
build_progress("{done}",100);
}