本文整理汇总了PHP中unix::CreateUnixUser方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::CreateUnixUser方法的具体用法?PHP unix::CreateUnixUser怎么用?PHP unix::CreateUnixUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::CreateUnixUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
function start($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$Masterbin = $unix->LOCATE_STUNNEL();
if (!is_file($Masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, not installed\n";
}
return;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
}
return;
}
$sTunnel4enabled = $sock->GET_INFO("sTunnel4enabled");
if (!is_numeric($sTunnel4enabled)) {
$sTunnel4enabled = 0;
}
if ($sTunnel4enabled == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see sTunnel4enabled)\n";
}
return;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$nohup = $unix->find_program("nohup");
$version = version();
$cmds = "{$Masterbin} /etc/stunnel/stunnel.conf";
$unix->CreateUnixUser("stunnel4", "stunnel4");
@mkdir("/var/run/stunnel", 0755, true);
@mkdir("/var/lib/stunnel4", 0755, true);
@chown("/var/run/stunnel", "stunnel4");
@chown("/var/lib/stunnel4", "stunnel4");
$stunnel = new stunnel4();
$relay = $stunnel->main_array["postfix_relayhost"]["connect"];
$relayPort = $stunnel->main_array["postfix_relayhost"]["port"];
$localport = $stunnel->main_array["postfix_relayhost"]["accept"];
if (!is_numeric($relayPort)) {
$relayPort = 465;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} version {$version}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Local to 127.0.0.1:{$localport}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} connection to {$relay}:{$relayPort}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
}
build();
$cmd = $cmds;
shell_exec($cmd);
for ($i = 1; $i < 5; $i++) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
}
sleep(1);
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
break;
}
}
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Failed\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$cmd}\n";
}
}
}
示例2: start
//.........这里部分代码省略.........
$EnableIntelCeleron = 0;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Use Statistics DB.....: {$EnableInfluxDB}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Use Intel Celeron mode: {$EnableIntelCeleron}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Use Performance.......: {$SquidPerformance}\n";
}
if ($EnableInfluxDB == 0) {
build_progress_restart("{starting} {failed} {disabled}", 110);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see EnableInflux)\n";
}
return;
}
if (!function_exists("pg_connect")) {
build_progress_restart("{starting} installing php5-pgsql", 35);
$unix->DEBIAN_INSTALL_PACKAGE("php5-pgsql");
system("/usr/share/artica-postfix/exec.php.ini.php");
if (!function_exists("pg_connect")) {
build_progress_restart("{starting} installing php5-pgsql {failed}", 110);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} pg_connect no such function\n";
}
return;
}
system("/etc/init.d/artica-webconsole restart");
}
build_progress_restart("{starting}", 40);
if (!$unix->UnixUserExists("ArticaStats")) {
$unix->CreateUnixUser("ArticaStats", "ArticaStats");
}
@mkdir("/var/run/ArticaStats", 0755, true);
@mkdir("/home/ArticaStatsDB", 0700, true);
@mkdir("/var/log/ArticaStatsDB", 0755, true);
@chown("/home/ArticaStatsDB", "ArticaStats");
@chgrp("/home/ArticaStatsDB", "ArticaStats");
@chown("/var/run/ArticaStats", "ArticaStats");
@chgrp("/var/run/ArticaStats", "ArticaStats");
@chown("/var/log/ArticaStatsDB", "ArticaStats");
@chgrp("/var/log/ArticaStatsDB", "ArticaStats");
if (is_file("/var/log/ArticaStatsDB/ArticaStatsDB.log")) {
@unlink("/var/log/ArticaStatsDB/ArticaStatsDB.log");
@touch("/var/log/ArticaStatsDB/ArticaStatsDB.log");
}
@chown("/var/log/ArticaStatsDB/ArticaStatsDB.log", "ArticaStats");
@chgrp("/var/log/ArticaStatsDB/ArticaStatsDB.log", "ArticaStats");
if (is_file("/var/run/ArticaStats/.s.PGSQL.8086")) {
@unlink("/var/run/ArticaStats/.s.PGSQL.8086");
}
$php = $unix->LOCATE_PHP5_BIN();
if (!is_file("/etc/artica-postfix/locales.gen")) {
squid_admin_mysql(1, "Generating languages for the PostGreSQL compatibility", null, __FILE__, __LINE__);
build_progress_restart("{generating_langs}", 42);
system("{$php} /usr/share/artica-postfix/exec.locale.gen.php");
}
if (!is_dir("/home/ArticaStatsDB/base/1")) {
squid_admin_mysql(0, "Creating a new PostgreSQL database in ArticaStatsDB", null, __FILE__, __LINE__);
build_progress_restart("{starting}", 45);
$rm = $unix->find_program("rm");
shell_exec("{$rm} -rf /home/ArticaStatsDB/*");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} initialize database...\n";
示例3: BuildDHCP
function BuildDHCP($nopid = false)
{
$LOGBIN = "DHCP Server";
$timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$unix = new unix();
if (!$nopid) {
if (!$GLOBALS["FORCE"]) {
if ($unix->file_time_min($timefile) < 2) {
if ($GLOBALS["VERBOSE"]) {
echo "{$timefile} -> is less than 2mn\n";
}
return;
}
}
}
build_progress("{starting_service}", 65);
$dhcpd = new dhcpd();
$conf = $dhcpd->BuildConf();
$confpath = dhcp3Config();
$unix = new unix();
@mkdir(dirname($confpath), null, true);
@file_put_contents($confpath, $conf);
echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} saving \"{$confpath}\" (" . strlen($conf) . " bytes) done\n";
if (!$unix->UnixUserExists("dhcpd")) {
$unix->CreateUnixUser("dhcpd", "dhcpd");
}
if (!is_dir("/var/lib/dhcp3")) {
@mkdir("/var/lib/dhcp3", 0755, true);
}
$unix->chown_func("dhcpd", "dhcpd", "/var/lib/dhcp3/*");
$unix->chmod_func(0755, "/var/lib/dhcp3");
$complain = $unix->find_program("aa-complain");
if (is_file($complain)) {
$dhcpd3 = $unix->DHCPD_BIN_PATH();
if (is_file($dhcpd3)) {
shell_exec("{$complain} {$dhcpd3} >/dev/null 2>&1");
}
}
@unlink($timefile);
@file_put_contents($timefile, time());
if ($GLOBALS["PROGRESS"]) {
build_progress("{starting_service}", 70);
$sock = new sockets();
$sock->getFrameWork("dnsmasq.php?restart=yes");
$sock->getFrameWork("services.php?restart-monit=yes");
$sock->getFrameWork("cmd.php?restart-artica-status=yes");
}
}
示例4: build
function build()
{
$unix = new unix();
@mkdir("/var/run/lighttpd", 0755, true);
@mkdir("/var/log/lighttpd", 0755, true);
$username = $unix->LIGHTTPD_USER();
$sock = new sockets();
$phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
$chown = $unix->find_program("chown");
$perlbin = $unix->find_program("perl");
$nohup = $unix->find_program("nohup");
$php = $unix->LOCATE_PHP5_BIN();
$PHP_STANDARD_MODE = true;
$SquidGuardApachePort = intval($sock->GET_INFO("SquidGuardApachePort"));
$SquidGuardApacheSSLPort = intval($sock->GET_INFO("SquidGuardApacheSSLPort"));
if ($SquidGuardApachePort == 0) {
$SquidGuardApachePort = 9020;
}
if ($SquidGuardApacheSSLPort == 0) {
$SquidGuardApacheSSLPort = 9025;
}
$SquidGuardWebSSLCertificate = $sock->GET_INFO("SquidGuardWebSSLCertificate");
@mkdir("/home/squid/error_page_sessions", 0755, true);
@mkdir("/home/squid/error_page_cache", 0755, true);
if ($username == null) {
$username = "www-data";
$unix->CreateUnixUser($username, $username, "lighttpd username");
}
if (preg_match("#^(.+?):(.+)#", $username, $re)) {
$username = $re[1];
$username = $re[1];
}
$SquidGuardStorageDir = $sock->GET_INFO("SquidGuardStorageDir");
@unlink("/var/log/lighttpd/squidguard-lighttpd-error.log");
@unlink("/var/log/lighttpd/squidguard-lighttpd.log");
if (!is_file("/var/log/lighttpd/squidguard-lighttpd.log")) {
@file_put_contents("/var/log/lighttpd/squidguard-lighttpd.log", "#");
}
if (!is_file("/var/log/lighttpd/squidguard-lighttpd-error.log")) {
@file_put_contents("/var/log/artica-postfix/lighttpd-error.log", "#");
}
$unix->chown_func($username, $username, "/var/log/lighttpd/squidguard-lighttpd.log");
$unix->chown_func($username, $username, "/var/log/lighttpd/squidguard-lighttpd-error.log");
$unix->chown_func($username, $username, "/home/squid/error_page_sessions");
$unix->chown_func($username, $username, "/home/squid/error_page_cache");
$unix->chown_func($username, $username, "/usr/share/artica-postfix/bin/install/squid/adzap/zaps/*");
@chmod("/var/log/lighttpd/squidguard-lighttpd-error.log", 0777);
@chmod("/var/log/lighttpd/squidguard-lighttpd.log", 0777);
if ($SquidGuardStorageDir == null) {
$SquidGuardStorageDir = "/home/artica/cache";
}
@mkdir($SquidGuardStorageDir, 0755, true);
$unix->chown_func($username, $username, $SquidGuardStorageDir);
$LighttpdUseUnixSocket = $sock->GET_INFO('LighttpdUseUnixSocket');
if (!is_numeric($LighttpdUseUnixSocket)) {
$LighttpdUseUnixSocket = 0;
}
$lighttpdPhpPort = $sock->GET_INFO('lighttpdPhpPort');
if (!is_numeric($lighttpdPhpPort)) {
$lighttpdPhpPort = 1808;
}
$LighttpdArticaMaxProcs = $sock->GET_INFO('LighttpdArticaMaxProcs');
if (!is_numeric($LighttpdArticaMaxProcs)) {
$LighttpdArticaMaxProcs = 0;
}
$LighttpdArticaMaxChildren = $sock->GET_INFO('LighttpdArticaMaxChildren');
if (!is_numeric($LighttpdArticaMaxChildren)) {
$LighttpdArticaMaxChildren = 0;
}
$LighttpdRunAsminimal = $sock->GET_INFO('LighttpdRunAsminimal');
if (!is_numeric($LighttpdRunAsminimal)) {
$LighttpdRunAsminimal = 0;
}
$PHP_FCGI_MAX_REQUESTS = $sock->GET_INFO('PHP_FCGI_MAX_REQUESTS');
if (!is_numeric($PHP_FCGI_MAX_REQUESTS)) {
$PHP_FCGI_MAX_REQUESTS = 200;
}
$EnablePHPFPM = $sock->GET_INFO('EnablePHPFPM');
if (!is_numeric($EnablePHPFPM)) {
$EnablePHPFPM = 0;
}
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if ($EnableArticaApachePHPFPM == 0) {
$EnablePHPFPM = 0;
}
$PHP_STANDARD_MODE = true;
$phpcgi_path = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Run as: {$username}\n";
}
$PHP_FCGI_CHILDREN = 1;
$max_procs = 2;
if ($LighttpdArticaMaxProcs > 0) {
$max_procs = $LighttpdArticaMaxProcs;
}
if ($LighttpdArticaMaxChildren > 0) {
$HP_FCGI_CHILDREN = $LighttpdArticaMaxChildren;
//.........这里部分代码省略.........
示例5: apache_config
function apache_config()
{
$sock = new sockets();
$unix = new unix();
$EnablePHPFPM = 0;
$ipaddr = null;
@mkdir("/var/run/apache2", 0755, true);
@mkdir("/var/run/sarg-apache", 0755, true);
@mkdir("/var/log/apache2", 0755, true);
@mkdir(dirname($GLOBALS["APACHE_PID_PATH"]), 0755, true);
$APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
$APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
$APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
$SargOutputDir = $sock->GET_INFO("SargOutputDir");
if ($SargOutputDir == null) {
$SargOutputDir = "/var/www/html/squid-reports";
}
$SargWebPort = intval($sock->GET_INFO("SargWebPort"));
if ($SargWebPort == 0) {
$SargWebPort = rand(55600, 59000);
$sock->SET_INFO("SargWebPort", $SargWebPort);
}
if (is_link($SargOutputDir)) {
$SargOutputDir = @readlink($SargOutputDir);
}
@mkdir($SargOutputDir, 0755, true);
if (!is_file("{$SargOutputDir}/index.html")) {
$php = $unix->LOCATE_PHP5_BIN();
shell_exec("{$php} /usr/share/artica-postfix/exec.sarg.php --exec --force >/dev/null 2>&1 &");
}
if ($ipaddr == null) {
$ipaddr = "*";
}
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$php = $unix->LOCATE_PHP5_BIN();
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnableArticaApachePHPFPM = 0;
}
$logfile = "/var/log/apache2/apache-sarg-access.log";
$ErrorLog = "/var/log/apache2/apache-sarg-error.log";
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/sarg-apache");
$apache_LOCATE_MIME_TYPES = $unix->apache_LOCATE_MIME_TYPES();
if ($EnableArticaApachePHPFPM == 1) {
if (!is_file("{$APACHE_MODULES_PATH}/mod_fastcgi.so")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} mod_fastcgi.so is required to use PHP5-FPM\n";
}
$EnableArticaApachePHPFPM = 0;
}
}
if ($APACHE_SRC_ACCOUNT == null) {
$APACHE_SRC_ACCOUNT = "www-data";
$APACHE_SRC_GROUP = "www-data";
$unix->CreateUnixUser($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "Apache username");
}
@unlink($ErrorLog);
@unlink($logfile);
if (!is_file("{$logfile}")) {
@touch("{$logfile}");
}
if (!is_file("{$ErrorLog}")) {
@touch("{$ErrorLog}");
}
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, $ErrorLog);
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, $logfile);
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/sarg-apache");
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/log/apache2");
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, dirname($GLOBALS["APACHE_PID_PATH"]));
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Run as {$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HTTP Port: {$ArticaSplashHotSpotPort} SSL Port: {$ArticaSplashHotSpotPortSSL}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM: {$EnablePHPFPM}\n";
}
$f[] = "LockFile /var/run/apache2/sarg-artica-accept.lock";
$f[] = "PidFile {$GLOBALS["APACHE_PID_PATH"]}";
$f[] = "AcceptMutex flock";
$f[] = "DocumentRoot {$SargOutputDir}";
$f[] = "DirectoryIndex index.html";
$f[] = "ErrorDocument 400 /index.html";
$f[] = "ErrorDocument 401 /index.html";
$f[] = "ErrorDocument 403 /index.html";
$f[] = "ErrorDocument 404 /index.html";
$f[] = "ErrorDocument 500 /index.html";
$f[] = "NameVirtualHost {$ipaddr}:{$SargWebPort}";
$f[] = "Listen {$ipaddr}:{$SargWebPort}";
$f[] = "<VirtualHost {$ipaddr}:{$SargWebPort}>";
$f[] = "\tServerName {$ipaddr}";
$f[] = "\tDocumentRoot {$SargOutputDir}";
$f[] = "</VirtualHost>";
$f[] = "<IfModule mpm_prefork_module>";
$f[] = "</IfModule>";
$f[] = "<IfModule mpm_worker_module>";
//.........这里部分代码省略.........
示例6: apache_config
//.........这里部分代码省略.........
$ipaddr = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"];
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HotSpot run as {$ArticaHotSpotInterface} ( {$ipaddr} )\n";
}
if ($ipaddr == "0.0.0.0") {
$ipaddr = "*";
}
if ($ipaddr == null) {
$ipaddr = "*";
}
$GLOBALS["HOSTPOT_WEB_INTERFACE"] = $ipaddr;
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$php = $unix->LOCATE_PHP5_BIN();
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnableArticaApachePHPFPM = 0;
}
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/artica-apache");
$apache_LOCATE_MIME_TYPES = $unix->apache_LOCATE_MIME_TYPES();
if ($EnableArticaApachePHPFPM == 1) {
if (!is_file("{$APACHE_MODULES_PATH}/mod_fastcgi.so")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} mod_fastcgi.so is required to use PHP5-FPM\n";
}
$EnableArticaApachePHPFPM = 0;
}
}
if ($APACHE_SRC_ACCOUNT == null) {
$APACHE_SRC_ACCOUNT = "www-data";
$APACHE_SRC_GROUP = "www-data";
$unix->CreateUnixUser($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "Apache username");
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Run as....: {$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HTTP Port.: {$ArticaSplashHotSpotPort} SSL Port: {$ArticaSplashHotSpotPortSSL}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM...: {$EnablePHPFPM}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} MaxClients: {$HotSpotMaxClients}\n";
}
$f[] = "Group {$APACHE_SRC_GROUP}";
$f[] = "User {$APACHE_SRC_ACCOUNT}";
$f[] = "LockFile /var/run/apache2/hotspot-artica-accept.lock";
$f[] = "PidFile /var/run/artica-apache/hotspot-apache.pid";
$f[] = "AcceptMutex flock";
$f[] = "SSLRandomSeed startup file:/dev/urandom 256";
$f[] = "SSLRandomSeed connect builtin";
$f[] = "SSLSessionCache shmcb:/var/run/apache2/ssl_scache-hotspot(512000)";
$f[] = "SSLSessionCacheTimeout 300";
$f[] = "SSLSessionCacheTimeout 300";
$f[] = "DocumentRoot /usr/share/artica-postfix";
$f[] = "DirectoryIndex hotspot.html";
$f[] = "ErrorDocument 400 /hotspot.html";
$f[] = "ErrorDocument 401 /hotspot.html";
$f[] = "ErrorDocument 403 /hotspot.html";
$f[] = "ErrorDocument 404 /hotspot.html";
$f[] = "ErrorDocument 500 /hotspot.html";
$NameVirtualHost = $ipaddr;
if ($HospotHTTPServerName != null) {
示例7: start
function start($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$postconf = $unix->find_program("postconf");
$postfix = $unix->find_program("postfix");
$usermod = $unix->find_program("usermod");
$users = new usersMenus();
if (!is_file($postconf)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix, not installed\n";
}
return;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix Service already started {$pid} since {$timepid}Mn...\n";
}
return;
}
$EnablePostfix = $sock->GET_INFO("EnablePostfix");
$EnableStopPostfix = $sock->GET_INFO("EnableStopPostfix");
if (!is_numeric($EnablePostfix)) {
$EnablePostfix = 1;
}
if (!is_numeric($EnableStopPostfix)) {
$EnableStopPostfix = 0;
}
if ($EnableStopPostfix == 1) {
$EnablePostfix = 0;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix EnablePostfix = {$EnablePostfix}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix EnableStopPostfix = {$EnableStopPostfix}\n";
}
if ($EnablePostfix == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix service disabled\n";
}
return;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix checking postfix user\n";
}
$unix->CreateUnixUser("postfix", "postfix");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix checking clamav user\n";
}
$unix->CreateUnixUser("clamav", "clamav");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Postfix checking postdrop group\n";
}
$unix->SystemCreateGroup("postdrop");
shell_exec("{$usermod} -a -G postfix clamav >/dev/null 2>&1");
@mkdir("/var/amavis", 0755, true);
@chmod("/var/amavis", 0755);
if (!is_file("/etc/postfix/relay_domains.db")) {
@touch("/etc/postfix/relay_domains");
shell_exec("postmap hash:/etc/postfix/relay_domains");
}
if (is_file("/etc/sasldb2")) {
@chown("/etc/sasldb2", "postfix");
@chgrp("/etc/sasldb2", "postfix");
}
$unixsocket = $users->cyrus_lmtp_path;
if ($unixsocket == null) {
$unixsocket = "/var/spool/postfix/var/run/cyrus/socket/lmtp";
}
@chown($unixsocket, "postfix");
@chgrp($unixsocket, "postfix");
@chmod($unixsocket, 0777);
$nohup = $unix->find_program("nohup");
$php5 = $unix->LOCATE_PHP5_BIN();
$TMPFILE = $unix->FILE_TEMP();
$cmd = "{$nohup} {$postfix} start >{$TMPFILE} 2>&1 &";
if ($GLOBALS["VERBOSE"]) {
echo "{$cmd}\n";
}
shell_exec($cmd);
for ($i = 0; $i < 6; $i++) {
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
break;
}
//.........这里部分代码省略.........
示例8: start
function start($aspid = false)
{
$unix = new unix();
$sock = new sockets();
$Masterbin = "/opt/kaspersky/kav4proxy/sbin/kav4proxy-kavicapserver";
if (!is_file($Masterbin)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Not installed\n";
}
return;
}
if (!$aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
if ($unix->MEM_TOTAL_INSTALLEE() < 624288) {
$sock->SET_INFO("kavicapserverEnabled", 0);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Not enough memory\n";
}
if ($unix->process_exists($pid)) {
stop();
}
return;
}
$pid = PID_NUM();
$kavicapserverEnabled = intval($sock->GET_INFO("kavicapserverEnabled"));
if ($unix->process_exists($pid)) {
$timepid = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service already started {$pid} since {$timepid}Mn...\n";
}
if ($kavicapserverEnabled == 0) {
stop();
}
return;
}
if ($kavicapserverEnabled == 0) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see kavicapserverEnabled)\n";
}
return;
}
$php5 = $unix->LOCATE_PHP5_BIN();
$sysctl = $unix->find_program("sysctl");
$echo = $unix->find_program("echo");
$nohup = $unix->find_program("nohup");
$unix->CreateUnixUser("kluser", "klusers");
build();
$version = kav4proxy_version();
$KL_SERVICE_CONFIG = "/etc/opt/kaspersky/kav4proxy.conf";
$f[] = $nohup;
$f[] = $Masterbin;
$f[] = "-C \"{$KL_SERVICE_CONFIG}\"";
$cmd = @implode(" ", $f) . " >/dev/null 2>&1 &";
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n";
}
shell_exec($cmd);
for ($i = 1; $i < 5; $i++) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} waiting {$i}/5\n";
}
sleep(1);
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
break;
}
}
$pid = PID_NUM();
if ($unix->process_exists($pid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid}\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Failed\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$cmd}\n";
}
}
}
示例9: start_prepare
function start_prepare()
{
if ($GLOBALS["CRASHED"]) {
return;
}
buil_init_squid_cache_log();
initd_squid();
$reconfigure = false;
$unix = new unix();
$sock = new sockets();
$NtpdateAD = $sock->GET_INFO("NtpdateAD");
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
if (!is_file("/etc/squid3/malwares.acl")) {
@file_put_contents("/etc/squid3/malwares.acl", "\n");
}
if (!is_file("/etc/squid3/squid-block.acl")) {
@file_put_contents("/etc/squid3/squid-block.acl", "\n");
}
$EXPLODED = explode("\n", @file_get_contents("/etc/squid3/squid.conf"));
while (list($index, $val) = each($EXPLODED)) {
if (preg_match("#INSERT YOUR OWN RULE#", $val)) {
if ($GLOBALS["OUTPUT"]) {
echo "Preparing.....: " . date("H:i:s") . " squid must be reconfigured...\n";
}
$reconfigure = true;
}
}
if ($reconfigure) {
if ($GLOBALS["OUTPUT"]) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Rebuild configuration\n";
}
system("{$php} /usr/share/artica-postfix/exec.squid.php --build --withoutloading");
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Rebuild configuration\n";
}
exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --withoutloading 2>&1", $GLOBALS["LOGS"]);
}
}
if ($NtpdateAD == 1) {
shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.kerbauth.php --ntpdate >/dev/null 2>&1 &");
}
$unix->CreateUnixUser("squid", "squid");
if (!is_file("/etc/squid3/squid.conf")) {
if ($GLOBALS["OUTPUT"]) {
echo "Preparing.....: " . date("H:i:s") . " Warning /etc/squid3/squid.conf no such file\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Preparing.....: " . date("H:i:s") . " Ask to build it and die\n";
}
shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force --withoutloading");
die;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " initd-squid\n";
}
shell_exec("{$php} /usr/share/artica-postfix/exec.initd-squid.php >/dev/null 2>&1");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Watchdog config\n";
}
shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --watchdog-config >/dev/null 2>&1");
exec("{$php} /usr/share/artica-postfix/exec.squid.transparent.php", $GLOBALS["LOGS"]);
if (!is_file("/etc/init.d/tproxy start")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Building transparent method\n";
}
exec("{$php} /usr/share/artica-postfix/exec.squid.transparent.php", $GLOBALS["LOGS"]);
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " Starting transparent method\n";
}
exec("/etc/init.d/tproxy start", $GLOBALS["LOGS"]);
}
$directories_squid[] = "/var/squid";
$directories_squid[] = "/var/squid/cache";
$directories_squid[] = "/usr/share/squid3/icons";
$directories_squid[] = "/var/log/squid";
$directories_squid[] = "/etc/squid3";
$directories_squid[] = "/var/lib/squidguard";
$directories_squid[] = "/var/run/squid";
$directories_squid[] = "/lib/squid3";
$directories_chmod[] = "/var/logs";
$directories_chmod[] = "/var/log";
$directories_chmod[] = "/var";
$directories_chmod_owned[] = "/home/squid";
$filesOblig[] = "/etc/squid3/url_rewrite_program.deny.db";
$filesOblig[] = "/var/run/squid/squid.pid";
while (list($num, $directory) = each($directories_squid)) {
if ($GLOBALS["OUTPUT"]) {
echo "Preparing.....: " . date("H:i:s") . " {$directory}\n";
}
if (!is_dir($directory)) {
@mkdir($directory, 0755, true);
}
@chmod($directory, 0755);
$unix->chmod_func(0755, "{$directory}/*");
$unix->chown_func("squid", "squid", "{$directory}/*");
}
//.........这里部分代码省略.........
示例10: checkdb
function checkdb()
{
$unix = new unix();
$q = new mysql();
$JAVA_HOME = $unix->JAVA_HOME_GET();
if (strlen($JAVA_HOME) == 0) {
echo "Starting......: " . date("H:i:s") . " OpenEMM JAVA_HOME failed\n";
return;
}
echo "Starting......: " . date("H:i:s") . " OpenEMM JAVA_HOME {$JAVA_HOME}\n";
if (!is_file("/home/openemm/bin/openemm.sh")) {
echo "Starting......: " . date("H:i:s") . " OpenEMM /home/openemm/bin/openemm.sh no such file\n";
return;
}
if (!is_file("/opt/openemm/tomcat6/bin/startup.sh")) {
echo "Starting......: " . date("H:i:s") . " OpenEMM tomcat 6.x is not installed\n";
return;
}
if (!$q->DATABASE_EXISTS("openemm")) {
$q->CREATE_DATABASE("openemm");
}
if (!$q->DATABASE_EXISTS("openemm")) {
echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating database openemm\n";
return;
}
echo "Starting......: " . date("H:i:s") . " OpenEMM database openemm OK\n";
if (!$q->DATABASE_EXISTS("openemm_cms")) {
$q->CREATE_DATABASE("openemm_cms");
}
if (!$q->DATABASE_EXISTS("openemm_cms")) {
echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating database openemm_cms\n";
return;
}
if (!test_cms_tables()) {
if (is_file("/home/openemm/USR_SHARE/openemm_cms-2011.sql")) {
$mysql = $unix->find_program("mysql");
$cmd = "{$mysql} -u {$q->mysql_admin} -p\"{$q->mysql_password}\" --batch --database=openemm_cms < /home/openemm/USR_SHARE/openemm_cms-2011.sql";
shell_exec($cmd);
}
}
if (!testtables()) {
$mysql = $unix->find_program("mysql");
if (is_file("/home/openemm/USR_SHARE/openemm-2011.sql")) {
$cmd = "{$mysql} -u {$q->mysql_admin} -p\"{$q->mysql_password}\" --batch --database=openemm < /home/openemm/USR_SHARE/openemm-2011.sql";
shell_exec($cmd);
}
}
if (!testtables()) {
echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating openemm tables\n";
return;
}
if (!test_cms_tables()) {
echo "Starting......: " . date("H:i:s") . " OpenEMM failed creating openemm_cms tables\n";
return;
}
echo "Starting......: " . date("H:i:s") . " OpenEMM tables in openemm base OK\n";
echo "Starting......: " . date("H:i:s") . " OpenEMM tables in openemm_cms base OK\n";
if (!$unix->CreateUnixUser("openemm")) {
echo "Starting......: " . date("H:i:s") . " OpenEMM unix user openemm failed\n";
return;
}
echo "Starting......: " . date("H:i:s") . " OpenEMM unix user openemm OK\n";
patch_javahome($JAVA_HOME);
patch_tomcat_dir("/opt/openemm/tomcat6");
if (!is_dir("/home/openemm/logs")) {
echo "Starting......: " . date("H:i:s") . " OpenEMM creating /home/openemm/logs directory\n";
@mkdir("/home/openemm/logs", 0755, true);
}
$aa_complain = $unix->find_program("aa-complain");
if (is_file($aa_complain)) {
shell_exec("{$aa_complain} {$JAVA_HOME}/bin/java");
}
if (!is_file("/home/openemm/webapps/openemm/WEB-INF/classes/messages_en_US.properties")) {
shell_exec("/bin/cp /home/openemm/webapps/openemm/WEB-INF/classes/messages_en.properties /home/openemm/webapps/openemm/WEB-INF/classes/messages_en_US.properties");
}
cms_properties();
if (!is_dir("/home/openemm/work/Catalina/openemm/_")) {
@mkdir("/home/openemm/work/Catalina/openemm/_", 0755, true);
}
shell_exec("/bin/chown openemm /home/openemm");
shell_exec("/bin/chown -R openemm /home/openemm");
if (is_numeric(is_tomcat_running())) {
echo "Starting......: " . date("H:i:s") . " OpenEMM stopping tomcat first...\n";
shell_exec("/etc/init.d/artica-postfix stop tomcat");
}
@unlink("/home/openemm/logs/catalina.out");
@unlink("/home/openemm/logs/openemm/openemm_axis.log");
@unlink("/home/openemm/logs/openemm/openemm_axis.log");
@unlink("/home/openemm/logs/openemm/openemm_core.log");
@unlink("/home/openemm/logs/openemm/userlogs.log");
}
示例11: apache_config
function apache_config()
{
$sock = new sockets();
$unix = new unix();
$EnablePHPFPM = 0;
@mkdir("/var/run/apache2", 0755, true);
@mkdir("/var/run/artica-apache", 0755, true);
@mkdir("/var/log/lighttpd", 0755, true);
$APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
$APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
$APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
$pydio_installed = false;
if (is_file(" /etc/php5/cli/conf.d/ming.ini")) {
@unlink(" /etc/php5/cli/conf.d/ming.ini");
}
@unlink("/var/log/lighttpd/apache-error.log");
@touch("/var/log/lighttpd/apache-error.log");
@chmod("/var/log/lighttpd/apache-error.log", 0755);
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/log/lighttpd/*");
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/usr/share/artica-postfix/ressources/logs/*");
if (is_dir("/usr/share/artica-postfix/pydio")) {
$pydio_installed = true;
}
$ArticaHttpsPort = 9000;
$NoLDAPInLighttpdd = 0;
$ArticaHttpUseSSL = 1;
$ArticaHttpsPort = $sock->GET_INFO("ArticaHttpsPort");
$ArticaHttpUseSSL = $sock->GET_INFO("ArticaHttpUseSSL");
if (!is_numeric($ArticaHttpUseSSL)) {
$ArticaHttpUseSSL = 1;
}
if (!is_numeric($ArticaHttpsPort)) {
$ArticaHttpsPort = "9000";
}
$LighttpdArticaListenIP = $sock->GET_INFO("LighttpdArticaListenIP");
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$php = $unix->LOCATE_PHP5_BIN();
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnableArticaApachePHPFPM = 0;
}
$EnablePHPFPM = intval($sock->GET_INFO("EnablePHPFPM"));
if (!is_numeric($EnablePHPFPM)) {
$EnablePHPFPM = 0;
}
if ($EnablePHPFPM == 0) {
$EnableArticaApachePHPFPM = 0;
}
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/artica-apache");
$apache_LOCATE_MIME_TYPES = $unix->apache_LOCATE_MIME_TYPES();
if ($EnableArticaApachePHPFPM == 1) {
if (!is_file("{$APACHE_MODULES_PATH}/mod_fastcgi.so")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} mod_fastcgi.so is required to use PHP5-FPM\n";
}
$EnableArticaApachePHPFPM = 0;
}
}
if ($APACHE_SRC_ACCOUNT == null) {
$APACHE_SRC_ACCOUNT = "www-data";
$APACHE_SRC_GROUP = "www-data";
$unix->CreateUnixUser($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "Apache username");
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Run as {$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM: {$EnablePHPFPM}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM Enabled: {$EnableArticaApachePHPFPM}\n";
}
$f[] = "LockFile /var/run/apache2/artica-accept.lock";
$f[] = "PidFile /var/run/artica-apache/apache.pid";
$f[] = "DocumentRoot /usr/share/artica-postfix";
$open_basedir[] = "/usr/share/artica-postfix";
$open_basedir[] = "/etc/artica-postfix";
$open_basedir[] = "/etc/artica-postfix/settings";
$open_basedir[] = "/var/log";
$open_basedir[] = "/var/run/mysqld";
$open_basedir[] = "/usr/share/php";
$open_basedir[] = "/usr/share/php5";
$open_basedir[] = "/var/lib/php5";
$open_basedir[] = "/var/lighttpd/upload";
$open_basedir[] = "/usr/share/artica-postfix/ressources";
$open_basedir[] = "/usr/share/artica-postfix/framework";
$open_basedir[] = "/etc/ssl/certs/mysql-client-download";
$open_basedir[] = "/var/run";
$open_basedir[] = "/bin";
$open_basedir[] = "/tmp";
$open_basedir[] = "/usr/sbin";
$open_basedir[] = "/home";
//$f[]="php_value open_basedir \"".@implode(":", $open_basedir)."\"";
//$f[]="php_value output_buffering Off";
//$f[]="php_flag magic_quotes_gpc Off";
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Listen Port: {$ArticaHttpsPort}\n";
//.........这里部分代码省略.........
示例12: CheckFilesAndSecurity
function CheckFilesAndSecurity()
{
$unix = new unix();
$unix->CreateUnixUser("redis", "redis");
$f[] = "/var/run/redis";
$f[] = "/var/log/redis";
$f[] = "/home/redis";
$f[] = "/etc/redis";
while (list($num, $val) = each($f)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} checking \"{$val}\"\n";
}
if (!is_dir($val)) {
@mkdir($val, 0755, true);
}
$unix->chown_func("redis", "redis", "{$val}/*");
}
}
示例13: build
function build()
{
build_progress("{reconfigure} (1)", 2);
if ($GLOBALS["VERBOSE"]) {
echo "Running build...\n";
}
$unix = new unix();
$sock = new sockets();
$users = new usersMenus();
$forceCMD = null;
$argv = null;
$PHP = $unix->LOCATE_PHP5_BIN();
$mypid = getmypid();
if (isset($argv[1])) {
$argv = $argv[1];
}
$pids = $unix->PIDOF_PATTERN_ALL(basename(__FILE__) . ".*?{$argv}");
if (count($pids) > 1) {
build_progress("{already_process_exists_try_later}", 110);
while (list($num, $ligne) = each($pids)) {
$cmdline = @file_get_contents("/proc/{$num}/cmdline");
echo "Starting......: " . date("H:i:s") . " [SERV]: [{$mypid}] Already process PID {$num} {$cmdline} exists..\n";
echo "Starting......: " . date("H:i:s") . " [SERV]: [{$mypid}] Running " . @file_get_contents("/proc/{$num}/cmdline") . "\n";
}
die;
}
$EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
if (!is_numeric($EnableKerbAuth)) {
$EnableKerbAuth = 0;
}
$EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
$EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
if (!is_numeric($EnableRemoteStatisticsAppliance)) {
$EnableRemoteStatisticsAppliance = 0;
}
if (!is_numeric($EnableWebProxyStatsAppliance)) {
$EnableWebProxyStatsAppliance = 0;
}
$UnlockWebStats = $sock->GET_INFO("UnlockWebStats");
if (!is_numeric($UnlockWebStats)) {
$UnlockWebStats = 0;
}
$ServiceFTPEnabled = intval($sock->GET_INFO("ServiceFTPEnabled"));
if ($users->WEBSTATS_APPLIANCE) {
$EnableWebProxyStatsAppliance = 1;
$sock->SET_INFO("{$EnableWebProxyStatsAppliance}", 1);
}
if ($EnableWebProxyStatsAppliance == 1) {
notify_remote_proxys();
}
if ($UnlockWebStats == 1) {
$EnableRemoteStatisticsAppliance = 0;
}
//Vérifie le compte utilisateur.
//------------------------------------------------------------------------------------------------------------------------------------------------------------
$unix->CreateUnixUser("squid", "squid", "Squid Cache Service");
$MustHave[] = "/etc/squid3/artica-meta/whitelist-nets.db";
$MustHave[] = "/var/logs/cache.log";
$MustHave[] = "/etc/squid3/squid-block.acl";
$MustHave[] = "/etc/squid3/allowed-user-agents.acl";
$MustHave[] = "/etc/squid3/GlobalAccessManager_auth.conf";
$MustHave[] = "/etc/squid3/icap.conf";
$MustHave[] = "/etc/squid3/GlobalAccessManager_url_rewrite.conf";
$MustHave[] = "/etc/squid3/GlobalAccessManager_deny_cache.conf";
$MustHave[] = "/etc/squid3/GlobalAccessManager_deny.conf";
$MustHave[] = "/etc/squid3/squid-block.acl";
$MustHave[] = "/etc/squid3/clients_ftp.acl";
$MustHave[] = "/etc/squid3/allowed-user-agents.acl";
$MustHave[] = "/etc/squid3/whitelisted-computers-by-mac.acl";
while (list($none, $path) = each($MustHave)) {
echo "Starting......: " . date("H:i:s") . " [SYS]: checking {$path}\n";
if (!is_file($path)) {
@touch($path);
}
@chown($path, "squid");
@chgrp($path, "squid");
}
if ($GLOBALS["FORCE"]) {
$forceCMD = " --force";
}
$squidbin = $unix->LOCATE_SQUID_BIN();
if (!is_file($squidbin)) {
build_progress("{squid_binary_not_found}", 110);
echo "Starting......: " . date("H:i:s") . " [SERV]: Unable to stat squid binary, aborting..\n";
die;
}
$EXEC_TIME_FILE = "/etc/artica-postfix/" . basename(__FILE__) . ".build.time";
if (!$GLOBALS["FORCE"]) {
$time = $unix->file_time_min($EXEC_TIME_FILE);
if ($time == 0) {
build_progress("Failed! Only one config per minute !!!", 110);
echo "Starting......: " . date("H:i:s") . " [SERV]: Only one config per minute...\n";
die;
}
}
@unlink($EXEC_TIME_FILE);
@file_put_contents($EXEC_TIME_FILE, time());
if ($GLOBALS["EMERGENCY"]) {
squid_admin_mysql(0, "Reconfiguring Proxy service after Emergency enabled", null, __FILE__, __LINE__);
}
//.........这里部分代码省略.........
示例14: start
function start($nopid = false)
{
$users = new usersMenus();
$unix = new unix();
$ettercap_bin = $unix->find_program("ettercap");
if (!$users->ETTERCAP_INSTALLED) {
echo "ArpSpoofing.........: [START]: Ettercap, not installed...\n";
return;
}
if (!is_file($ettercap_bin)) {
echo "ArpSpoofing.........: [START]: Ettercap, not such binary...\n";
return;
}
$sock = new sockets();
$ArpSpoofEnabled = $sock->GET_INFO("ArpSpoofEnabled");
if (!is_numeric($ArpSpoofEnabled)) {
$ArpSpoofEnabled = 0;
}
if (!$nopid) {
$me = basename(__FILE__);
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, $me)) {
$time = $unix->PROCCESS_TIME_MIN($pid);
echo "ArpSpoofing.........: [START]: Ettercap, Already start instance executed PID {$pid} since {$time}Mn...\n";
return;
}
@file_put_contents($pidfile, getmypid());
}
if ($ArpSpoofEnabled == 0) {
echo "ArpSpoofing.........: [START]: Ettercap, not enabled\n";
stop(true);
}
$nohup = $unix->find_program("nohup");
$q = new mysql();
if (!$q->BD_CONNECT()) {
echo "ArpSpoofing.........: [START]: unable to connect to MySQL database...\n";
return;
}
if (!$unix->SystemUserExists("nobody")) {
echo "ArpSpoofing.........: [START]: Creating nobody user...\n";
$unix->CreateUnixUser("nobody", "nogroup");
}
if (!$unix->SystemGroupExists("nogroup")) {
$unix->SystemCreateGroup("nogroup");
$unix->CreateUnixUser("nobody", "nogroup");
}
$uid = $unix->SystemUserGetuid("nobody");
$guid = $unix->SystemGroupUid("nogroup");
init_debian();
$sql = "SELECT * FROM arpspoof_rules WHERE enabled=1";
$results = $q->QUERY_SQL($sql, "artica_backup");
while ($ligne = mysql_fetch_assoc($results)) {
$rulename = $ligne["rulename"];
$pid = get_rule_pid($ligne["ID"]);
if ($unix->process_exists($pid)) {
echo "ArpSpoofing.........: [START]: `{$rulename}` already running pid {$pid}\n";
continue;
}
$sources = getobjects($ligne["ID"]);
$gateway = $ligne["gateway"];
if ($sources == null) {
echo "ArpSpoofing.........: [START]: `{$rulename}` no item set...\n";
continue;
}
if ($sources == "all") {
$sources = null;
}
$f = array();
$f[] = "[privs]";
$f[] = "ec_uid = {$uid} # nobody is the default";
$f[] = "ec_gid = {$guid} # nobody is the default";
$f[] = "[mitm]";
$f[] = "arp_storm_delay = 10";
$f[] = "arp_poison_warm_up = 1";
$f[] = "arp_poison_delay = 10";
$f[] = "arp_poison_equal_mac= 1";
$f[] = "arp_poison_reply=1";
$f[] = "arp_poison_icmp = 1";
$f[] = "dhcp_lease_time = 600";
$f[] = "port_steal_delay = 10 # milliseconds";
$f[] = "port_steal_send_delay = 2000 # microseconds";
$f[] = "[connections]";
$f[] = "connection_timeout = 300 # seconds";
$f[] = "connection_idle = 5 # seconds";
$f[] = "connection_buffer = 10000 # bytes";
$f[] = "connect_timeout = 5 # seconds";
$f[] = "";
$f[] = "[stats]";
$f[] = "sampling_rate = 50 # number of packets";
$f[] = "";
$f[] = "[misc]";
$f[] = "close_on_eof = 1 # boolean value";
$f[] = "store_profiles = 1 # 0 = disabled; 1 = all; 2 = local; 3 = remote";
$f[] = "aggressive_dissectors = 1 # boolean value";
$f[] = "skip_forwarded_pcks = 1 # boolean value";
$f[] = "checksum_check = 0 # boolean value";
$f[] = "checksum_warning = 0 # boolean value (valid only if checksum_check is 1)";
$f[] = "";
@mkdir("/etc/ettercap", 0755, true);
//.........这里部分代码省略.........
示例15: install
function install()
{
$filename = "kav4proxy_5.5-88.tar.gz";
$uri = "http://articatech.net/download/kaspersky/{$filename}";
$time = time();
$unix = new unix();
$pidFile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidFile);
if ($unix->process_exists($pid)) {
if ($unix->PROCCESS_TIME_MIN($pid, 10) < 2) {
return;
}
}
$cacheFile = "/usr/share/artica-postfix/ressources/logs/web/KAV4PROXYINST.status";
@unlink($cacheFile);
$rm = $unix->find_program("rm");
$cp = $unix->find_program("cp");
$TMPDIR = $unix->TEMP_DIR() . "/{$time}";
$FINAL_TARGET_DIR = null;
$TARGET_PATH = "{$TMPDIR}/{$filename}";
progress("{downloading} 5.5.88 version", "Downloading {$filename}", 30);
progress("{downloading} 5.5.88 version", "Temporary directory = {$TMPDIR}", 30);
$curl = new ccurl("{$uri}");
$debianbin = $unix->find_program("update-rc.d");
$redhatbin = $unix->find_program("chkconfig");
@mkdir($TMPDIR);
if (!$curl->GetFile($TARGET_PATH)) {
progress("{failed}", $curl->error, 100);
shell_exec("{$rm} -rf {$TMPDIR}");
return;
}
progress("{downloading} 5.5.88 version {success}", "success saving {$TARGET_PATH} ", 50);
progress("{extracting} 5.5.88 version", "Extracting {$TARGET_PATH} ", 55);
$tar = $unix->find_program("tar");
exec("{$tar} xvf {$TARGET_PATH} -C /{$TMPDIR}/ 2>&1", $results);
while (list($index, $line) = each($results)) {
progress("{extracting} 5.5.88 version", $line, 60);
}
$dir = $unix->dirdir($TMPDIR);
while (list($index, $line) = each($dir)) {
progress("{search} {directory}", $line, 65);
if (preg_match("#kav4proxy#", $line)) {
progress("{search} {directory}", "Found directory {$line}", 65);
$FINAL_TARGET_DIR = $line;
break;
}
}
if ($FINAL_TARGET_DIR == null) {
progress("{extracting} 5.5.88 version {failed}", "Unable to find a suitable directory", 100);
shell_exec("{$rm} -rf {$TMPDIR}");
return;
}
progress("{installing} 5.5.88 version", "Copy the content of {$FINAL_TARGET_DIR}", 70);
exec("{$cp} -rfdv {$FINAL_TARGET_DIR}/* / 2>&1", $resultsA);
while (list($index, $line) = each($resultsA)) {
progress("{installing} 5.5.88 version", $line, 70);
}
progress("{installing} 5.5.88 version", "Removing the {$TMPDIR} directory", 71);
shell_exec("{$rm} -rf {$TMPDIR}");
if (!is_file("/opt/kaspersky/kav4proxy/bin/kav4proxy-licensemanager")) {
progress("{installing} 5.5.88 version {failed}", "install from {$FINAL_TARGET_DIR} failed ", 100);
return;
}
$ln = $unix->find_program("ln");
$chown = $unix->find_program("chown");
$chmod = $unix->find_program("chmod");
progress("{installing} 5.5.88 version", "linking /etc/init.d/kav4proxy", 75);
shell_exec("ln -s --force /opt/kaspersky/kav4proxy/lib/bin/kav4proxy /etc/init.d/kav4proxy");
if (is_file($debianbin)) {
shell_exec("{$debianbin} -f kav4proxy defaults >/dev/null 2>&1");
}
if (is_file($redhatbin)) {
shell_exec("{$redhatbin} --add kav4proxy >/dev/null 2>&1");
}
progress("{installing} 5.5.88 version", "executing preinstall", 78);
exec('/usr/share/artica-postfix/bin/install/kavgroup/kav4prox_predoinst.sh 2>&1', $results2);
while (list($index, $line) = each($results2)) {
progress("{installing} 5.5.88 version", $line, 78);
}
progress("{installing} 5.5.88 version", "Creating kluser user", 80);
$unix->CreateUnixUser("kluser", "klusers");
progress("{installing} 5.5.88 version", "Apply permissions", 85);
@mkdir("/var/log/kaspersky/kav4proxy", 0755, true);
@mkdir("/var/run/kav4proxy", 0755, true);
shell_exec("{$chown} -R kluser:klusers /var/log/kaspersky/kav4proxy");
shell_exec("{$chown} -R kluser:klusers /var/opt/kaspersky/kav4proxy");
shell_exec("{$chown} -R kluser:klusers /var/run/kav4proxy");
shell_exec("{$chown} -R kluser:klusers /var/opt/kaspersky/kav4proxy");
shell_exec("{$chmod} 0755 /var/opt/kaspersky/kav4proxy");
$f[] = "EULA_AGREED=yes";
$f[] = "";
@file_put_contents("/var/opt/kaspersky/kav4proxy/installer.dat", @implode("\n", $f));
$f = array();
$f[] = "CONFIGURE_ENTER_KEY_PATH=";
$f[] = "KAVMS_SETUP_LICENSE_DOMAINS=*";
$f[] = "CONFIGURE_KEEPUP2DATE_ASKPROXY=no";
$f[] = "CONFIGURE_RUN_KEEPUP2DATE=no";
$f[] = "CONFIGURE_WEBMIN_ASKCFGPATH=";
$f[] = "KAV4PROXY_SETUP_TYPE=3";
$f[] = "KAV4PROXY_SETUP_LISTENADDRESS=127.0.0.1:1344";
//.........这里部分代码省略.........