forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec.squid.reconfigure.php
executable file
·85 lines (63 loc) · 2.8 KB
/
exec.squid.reconfigure.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
<?php
$GLOBALS["SCHEDULE_ID"]=0;
$GLOBALS["AD_PROGRESS"]=0;
$GLOBALS["DEBUG_INCLUDES"]=false;
$GLOBALS["ARGVS"]=implode(" ",$argv);
if(preg_match("#schedule-id=([0-9]+)#",implode(" ",$argv),$re)){$GLOBALS["SCHEDULE_ID"]=$re[1];}
if(posix_getuid()<>0){die("Cannot be used in web server mode\n\n");}
if(preg_match("#--includes#",implode(" ",$argv))){$GLOBALS["DEBUG_INCLUDES"]=true;}
if(preg_match("#--progress-activedirectory=([0-9]+)#",implode(" ",$argv),$re)){$GLOBALS["AD_PROGRESS"]=$re[1];}
if($GLOBALS["DEBUG_INCLUDES"]){echo basename(__FILE__)."::class.templates.inc\n";}
include_once(dirname(__FILE__).'/ressources/class.templates.inc');
include_once(dirname(__FILE__).'/ressources/class.squid.remote-stats-appliance.inc');
if($GLOBALS["DEBUG_INCLUDES"]){echo basename(__FILE__)."::class.ini.inc\n";}
include_once(dirname(__FILE__).'/ressources/class.ini.inc');
if($GLOBALS["DEBUG_INCLUDES"]){echo basename(__FILE__)."::class.squid.inc\n";}
include_once(dirname(__FILE__).'/ressources/class.squid.inc');
if($GLOBALS["DEBUG_INCLUDES"]){echo basename(__FILE__)."::framework/class.unix.inc\n";}
include_once(dirname(__FILE__).'/framework/class.unix.inc');
if($GLOBALS["DEBUG_INCLUDES"]){echo basename(__FILE__)."::frame.class.inc\n";}
include_once(dirname(__FILE__).'/framework/frame.class.inc');
include_once(dirname(__FILE__).'/ressources/class.mysql.inc');
include_once(dirname(__FILE__).'/ressources/class.squid.acls.inc');
squid_reconfigure_exe();
function SQUID_PID(){
$unix=new unix();
$squidbin=$unix->LOCATE_SQUID_BIN();
$pid=$unix->get_pid_from_file($unix->LOCATE_SQUID_PID());
if(!$unix->process_exists($pid)){
$pid=$unix->PIDOF($squidbin);
}
return $pid;
}
function squid_reconfigure_exe(){
$unix=new unix();
$squidbin=$unix->LOCATE_SQUID_BIN();
build_progress("Reloading Proxy service...",10);
$pid=SQUID_PID();
if($unix->process_exists($pid)){
build_progress("Reloading Proxy service...",50);
system("/etc/init.d/squid reload --force --script=exec.squid.reconfigure.php/".__LINE__);
sleep(2);
$sock=new sockets();
$EnableTransparent27=intval($sock->GET_INFO("EnableTransparent27"));
if($EnableTransparent27==1){
build_progress("Reloading Proxy NAT service...",60);
system("/etc/init.d/squid-nat reload --script=".basename(__FILE__));
}
build_progress("Reloading Proxy service...{done}",100);
return;
}
echo "Not running !\n";
build_progress("Reloading Proxy service {failed}...",110);
}
function build_progress($text,$pourc){
$echotext=$text;
$echotext=str_replace("{reconfigure}", "Reconfigure", $echotext);
echo "Starting......: ".date("H:i:s")." {$pourc}% $echotext\n";
$cachefile="/usr/share/artica-postfix/ressources/logs/squid.build.progress";
$array["POURC"]=$pourc;
$array["TEXT"]=$text;
@file_put_contents($cachefile, serialize($array));
@chmod($cachefile,0755);
}