function build() { echo "Starting......: " . date("H:i:s") . " GreenSQL checking Database....\n"; $q = new mysql(); if (!$q->DATABASE_EXISTS("greensql")) { echo "Starting......: " . date("H:i:s") . " GreenSQL creating database greensql\n"; $q->CREATE_DATABASE("greensql"); } checkGreenTables(); buildconfig(); }
die("alert('no access');"); } if (isset($_GET["popup"])) { tabs(); exit; } if (isset($_GET["popup-main"])) { popup(); exit; } if (isset($_GET["help"])) { help(); exit; } if (isset($_POST["connection_name"])) { buildconfig(); exit; } js(); function help() { $tpl = new templates(); $page = CurrentPageName(); $downloadvinvin = Paragraphe("setup-icon-64.png", "{DOWNLOAD_OPENVPN_CLIENT}", "{DOWNLOAD_OPENVPN_CLIENT_TEXT}", "javascript:s_PopUp('http://www.articatech.net/download/openvpn-2.1.4-install.exe')", "{DOWNLOAD_OPENVPN_CLIENT_TEXT}"); $downloadapple = Paragraphe("apple-logo-64.png", "{DOWNLOAD_OPENVPN_CLIENT_APPLE}", "{DOWNLOAD_OPENVPN_CLIENT_TEXT}", "javascript:s_PopUp('http://www.articatech.net/download/Tunnelblick_3.1.7.dmg')", "{DOWNLOAD_OPENVPN_CLIENT_TEXT}"); $html = "\n\t<div class=text-info>{OPENVPN_ADMIN_HELP_TEXT}</div>\n\t<table style='width:99%' class=form>\n\t<tbody>\n\t<tr>\n\t\t<td width=1%>{$downloadvinvin}</td>\n\t</tr>\n\t<tr>\n\t\t<td width=1%>{$downloadapple}</td>\n\t</tr>\t\n\t</tboy>\n\t</table>\n\t\n\t"; echo $tpl->_ENGINE_parse_body($html); } function js() { $tpl = new templates();
function restart() { $unix = new unix(); $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()); build_progress("{stopping_service}", 5); stop(true); sleep(1); build_progress("{building_settings}", 45); buildconfig(); build_progress("{starting_service}", 50); if (!start(true)) { build_progress("{starting_service} {failed}", 110); return; } build_progress("{starting_service} {done}", 100); }
<?php session_start(); include_once('ressources/class.templates.inc'); include_once('ressources/class.users.menus.inc'); include_once('ressources/class.openvpn.inc'); include_once('ressources/class.system.network.inc'); include_once('ressources/class.tcpip.inc'); $users=new usersMenus(); if(!$users->AsSystemAdministrator){die("alert('no access');");} if(isset($_GET["popup"])){popup();exit();} if(isset($_POST["connection_name"])){buildconfig();exit;} js(); function js(){ $tpl=new templates(); $page=CurrentPageName(); $title=$tpl->_ENGINE_parse_body("{BUILD_OPENVPN_CLIENT_CONFIG}"); $html="YahooWin4('550','$page?popup=yes','$title')"; echo $html; } function popup(){ $tpl=new templates(); $page=CurrentPageName();
function start($aspid = false, $verifdbs = false) { $unix = new unix(); $sock = new sockets(); $Masterbin = "/opt/ufdbcat/bin/ufdbcatdd"; if (!is_file($Masterbin)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, ufdbguardd 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"; } if ($GLOBALS["MONIT"]) { @file_put_contents($GLOBALS["PID_PATH"], $pid); } return; } $DisableUfdbCat = $sock->DisableUfdbCat(); if ($DisableUfdbCat == 1) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service disabled (see DisableUfdbCat)\n"; } stop(); return; } $php5 = $unix->LOCATE_PHP5_BIN(); $sysctl = $unix->find_program("sysctl"); $echo = $unix->find_program("echo"); $nohup = $unix->find_program("nohup"); $kill = $unix->find_program("kill"); $cp = $unix->find_program("cp"); @mkdir("/etc/ufdbcat", 0755, true); @mkdir("/var/log/ufdbcat", 0755, true); @mkdir(dirname($GLOBALS["PID_PATH"]), 0755, true); @chmod($GLOBALS["PID_PATH"], 0755); @chmod($Masterbin, 0755); build_progress("{starting_service}", 10); CheckDirectories($verifdbs); if (is_file("/var/log/ufdbcat/ufdbguardd.log")) { @unlink("/var/log/ufdbcat/ufdbguardd.log"); } if (is_file("/var/run/ufdbcat-03977")) { @unlink("/var/run/ufdbcat-03977"); } if ($unix->is_socket("/var/run/ufdbcat-03977")) { @unlink("/var/run/ufdbcat-03977"); } $AsCategoriesAppliance = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/AsCategoriesAppliance")); $Threads = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/UfdbCatThreads")); if ($Threads == 0) { $Threads = 4; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} pid path: {$GLOBALS["PID_PATH"]}\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Threads:{$Threads}\n"; } if (is_file("/opt/ufdbcat/bin/ufdbhttpd")) { @unlink("/opt/ufdbcat/bin/ufdbhttpd"); } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} ** Categories Appliance Mode ***\n"; } $isRemoteSockets = isRemoteSockets(); if ($isRemoteSockets) { if (!is_file("{$Masterbin}.sock")) { @copy($Masterbin, "{$Masterbin}.sock"); } $ufdbguardd = $unix->find_program("ufdbguardd"); if (!is_file($ufdbguardd)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Fatal ufdbguardd no such binary!!!\n"; } return false; } @unlink($Masterbin); @copy($ufdbguardd, $Masterbin); } if (!$isRemoteSockets) { if (is_file("{$Masterbin}.sock")) { @copy("{$Masterbin}.sock", $Masterbin); @unlink("{$Masterbin}.sock"); } } @unlink($GLOBALS["PID_PATH"]); @chmod($Masterbin, 0755); $cmd = "{$Masterbin} -c /etc/ufdbcat/ufdbGuard.conf -U root -w {$Threads} -N >/dev/null 2>&1 &"; if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service\n"; } build_progress("{starting_service}", 96); squid_admin_mysql(2, "Starting Categories Service", "nothing", __FILE__, __LINE__); buildconfig(); shell_exec($cmd); for ($i = 1; $i < 5; $i++) { build_progress("{starting_service} {$i}/5", 98); 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"; } if (!$isRemoteSockets) { for ($i = 1; $i < 10; $i++) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Checking socket {$i}/5...\n"; } sleep(1); if ($unix->is_socket("/var/run/ufdbcat-03977")) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Checking socket success...\n"; } @chmod("/var/run/ufdbcat-03977", 0777); break; } } } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success\n"; } build_progress("{success}", 100); return true; } squid_admin_mysql(0, "Failed to start Categories Service", "nothing", __FILE__, __LINE__); build_progress("{failed}", 110); 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"; } }
function RECONFIGURE_PROGRESS() { $unix = new unix(); $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"; } build_progress_reconfigure("{failed}", 110); return; } $sock = new sockets(); $ArticaHotSpotEnableMIT = $sock->GET_INFO("ArticaHotSpotEnableMIT"); $ArticaHotSpotEnableProxy = $sock->GET_INFO("ArticaHotSpotEnableProxy"); if (!is_numeric($ArticaHotSpotEnableMIT)) { $ArticaHotSpotEnableMIT = 1; } if (!is_numeric($ArticaHotSpotEnableProxy)) { $ArticaHotSpotEnableProxy = 1; } $proxyRestart = 0; if ($ArticaHotSpotEnableMIT == 1) { $proxyRestart = 1; } if ($ArticaHotSpotEnableProxy == 1) { $proxyRestart = 1; } $php = $unix->LOCATE_PHP5_BIN(); build_progress_reconfigure("{reconfigure_hostpot_service}", 5); build_progress_reconfigure("{stopping_service} Hostpot", 10); stop(true); build_progress_reconfigure("Building templates", 20); sleep(2); shell_exec("{$php} /usr/share/artica-postfix/hostpot.php --templates"); build_progress_reconfigure("{building_parameters}", 30); buildconfig(); sleep(2); build_progress_reconfigure("{starting_service} Hostpot", 40); start(true); if ($proxyRestart == 1) { build_progress_reconfigure("{reconfigure_proxy_service}", 50); system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force"); } build_progress_reconfigure("{reconfiguring} {webserver}", 60); system("{$php} /usr/share/artica-postfix/exec.hostpot-web.php --build"); sleep(2); build_progress_reconfigure("{restarting} {webserver}", 70); system("{$php} /usr/share/artica-postfix/exec.hostpot-web.php --restart --force"); sleep(2); $pid = PID_NUM(); if (!$unix->process_exists($pid)) { build_progress_reconfigure("{starting_service} HotSpot {failed}", 110); return; } build_progress_reconfigure("{starting_service} HotSpot {success}", 95); $pid = apache_pid(); if (!$unix->process_exists($pid)) { build_progress_reconfigure("{starting_service} {webserver} {failed}", 110); return; } build_progress_reconfigure("{starting_service} {webserver} {success}", 98); sleep(3); build_progress_reconfigure("{reconfigure_hostpot_service} {done}", 100); }
function duplicate_vps($from_id, $to_id) { $q = new mysql(); $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$from_id}.{$to_id}.pid"; $pid = @file_get_contents($pidfile); $unix = new unix(); if ($unix->process_exists($pid)) { echo2("Starting......: VPS server: vps-{$to_id}: Already instance executed {$pid}"); return; } $pid = getmypid(); @file_put_contents($pidfile, $pid); $q->QUERY_SQL("UPDATE lxc_machines SET `state`='configure' WHERE ID='{$to_id}'", "artica_backup"); $source_dir = root_directory($from_id); $destdir = root_directory($to_id); @mkdir($destdir); echo2("Starting......: VPS server: vps-{$to_id}: copying {$source_dir} to {$source_dir}"); shell_exec("/bin/cp -rf {$source_dir}/* {$destdir}/"); buildconfig($to_id); $q->QUERY_SQL("UPDATE lxc_machines SET `state`='installed' WHERE ID='{$to_id}'", "artica_backup"); vps_start($to_id); }
function restart($aspid = false) { $unix = new unix(); 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 "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} service Already Artica task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); } $amavisbin = $unix->LOCATE_AMAVISD_BIN_PATH(); if (!is_file($amavisbin)) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service Not installed\n"; } die; } $pid = PID_NUM(); buildconfig(); if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Restarting....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service is stopped...\n"; } start(true); } $timepid = $unix->PROCCESS_TIME_MIN($pid); $pid = PID_NUM(); $nohup = $unix->find_program("nohup"); $php5 = $unix->LOCATE_PHP5_BIN(); $kill = $unix->find_program("kill"); if ($GLOBALS["OUTPUT"]) { echo "Restarting....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Binary: {$amavisbin}\n"; } if ($GLOBALS["OUTPUT"]) { echo "Restarting....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service restarting pid {$pid} running since {$timepid}mn...\n"; } $cmd = "{$nohup} {$amavisbin} -c /usr/local/etc/amavisd.conf restart >/dev/null 2>&1 &"; shell_exec($cmd); $pid = PID_NUM(); for ($i = 1; $i < 5; $i++) { if (!$unix->process_exists($pid)) { $word = "Stopped"; } else { $word = "Started"; } if ($GLOBALS["OUTPUT"]) { echo "Restarting....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Waiting ({$word}) {$i}/5\n"; } sleep(1); $pid = PID_NUM(); } if (!$unix->process_exists($pid)) { if ($GLOBALS["OUTPUT"]) { echo "Restarting....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Service is Stopped...\n"; } start(true); } else { if ($GLOBALS["OUTPUT"]) { echo "Restarting....: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success\n"; } } }