Exemplo n.º 1
0
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}", 10);
    stop(true);
    build_progress("{reconfiguring}", 40);
    build();
    sleep(1);
    build_progress("{starting_service}", 45);
    if (!start(true)) {
        build_progress("{starting_service} {failed}", 110);
        return;
    }
    system("/etc/init.d/monit restart");
    build_progress("{starting_service} {success}", 100);
}
Exemplo n.º 2
0
function restart()
{
    $unix = new unix();
    $shorewall = $unix->find_program("shorewall");
    if (!is_file($shorewall)) {
        return;
    }
    $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"]}, Already task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    stop(true);
    start(true);
    if (is_file("/etc/init.d/ssh")) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, restarting SSH service.\n";
        }
        system("/etc/init.d/ssh restart");
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Stopping......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, ACTION DONE.\n";
    }
}
Exemplo n.º 3
0
function newGame()
{
    start();
    echo "<div class='title'> " . getNumber() . " </div>";
    echo "<div class='sub-title'>Quedan por salir - " . getRest() . "</div>";
    drawBoard();
    fillTable(18);
    showTable();
}
Exemplo n.º 4
0
function logout()
{
    global $pid, $pcat;
    $pid = '';
    $pcat = '';
    setcookie("player");
    setcookie("CUP_ID");
    start();
}
Exemplo n.º 5
0
function check($queue_name)
{
    $pidfile = APP . "log/monitor/{$queue_name}.pid";
    if (file_exists($pidfile)) {
        $pid = file_get_contents($pidfile);
        //        debugLog("check {$queue_name} pid = $pid");
        if (!intval($pid) || !posix_kill($pid, 0)) {
            debugLog("{$queue_name} pid = {$pid} is kill");
            start($queue_name);
        }
    } else {
        start($queue_name);
    }
}
Exemplo n.º 6
0
/**
 * This is the default function that is run the first time this script is called.
 * This function creates an initial state of the world, and displays it within an HTML structure.
 */
function display()
{
    # Global Variables
    global $world, $cell_size;
    # Create Initial Random Chaos within the world
    start();
    $_SESSION['world'] = $world;
    # Create a graphical representation of the world
    $content = display_world($world);
    # Generaet the HTML for the page
    $html = "\n\t<html>\n\t\t<head>\n\t\t\t<title>Game of Life | Implementation by Ralfe Poisson</title>\n\t\t\t<style>\n\t\t\t\t* {\n\t\t\t\t\tfont-size: 10px;\n\t\t\t\t}\n\t\t\t\ttable tr td {\n\t\t\t\t\twidth: {$cell_size};\n\t\t\t\t\theight: {$cell_size};\n\t\t\t\t\tfont-size: 1px;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'></script>\n\t\t\t<script>\n\t\t\t\tfunction refresh_gof() {\n\t\t\t\t\tvar new_html = \$.ajax({\n\t\t\t\t\t\turl: 'php-gol.php?action=refresh',\n\t\t\t\t\t\ttype: 'html',\n\t\t\t\t\t\tasync: false\n\t\t\t\t\t}).responseText;\n\t\t\t\t\t\$('#gof').html(new_html);\n\t\t\t\t}\n\t\t\t\tsetInterval('refresh_gof()', 1000);\n\t\t\t</script>\n\t\t</head>\n\t\t<body>\n\t\t\t<div id='gof'>\n\t\t\t\t{$content}\n\t\t\t</div>\n\t\t</body>\t\n\t</html>";
    # Display the html page
    print $html;
}
Exemplo n.º 7
0
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]: Memcached Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    stop(true);
    start(true);
}
Exemplo n.º 8
0
function executeCommand($params, $chatID)
{
    // Prepare an array of parameters without the command
    for ($i = 1; $i < count($params); $i++) {
        $parameters[$i - 1] = $params[$i];
    }
    $command = $params[0];
    // Execute command
    if ($command == "/start") {
        start($chatID);
    }
    if ($command == "/help") {
        help($chatID);
    }
    if ($command == "/tex") {
        tex($chatID, $parameters);
    }
}
Exemplo n.º 9
0
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());
    vsftpd_admin_mysql(1, "Restarting VSFTPD service...", null, __FILE__, __LINE__);
    stop(true);
    sleep(1);
    start(true);
}
Exemplo n.º 10
0
function restart()
{
    $users = new usersMenus();
    $unix = new unix();
    if (!$users->ETTERCAP_INSTALLED) {
        echo "ArpSpoofing.........: [STOP]: Ettercap, not installed...\n";
        return;
    }
    $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.........: [RESTART]: Ettercap, Already start instance executed PID {$pid} since {$time}Mn...\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    stop(true);
    start(true);
}
Exemplo n.º 11
0
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 "Restarting....: [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)) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Restarting....: [INIT]: {$GLOBALS["TITLENAME"]} PID {$pid} running since {$time}mn\n";
        }
    }
    stop(true);
    sleep(1);
    start(true);
}
Exemplo n.º 12
0
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(10, "{stopping} {APP_FRESHCLAM}");
    stop(true);
    build_progress(50, "{building_configuration}");
    build();
    sleep(1);
    build_progress(70, "{starting} {APP_FRESHCLAM}");
    if (start(true)) {
        if ($GLOBALS["PROGRESS"]) {
            build_progress(95, "{restarting} {watchdog}");
            system("/etc/init.d/artica-status restart");
        }
        build_progress(100, "{done} {APP_FRESHCLAM}");
    }
}
Exemplo n.º 13
0
<?php

// Version
define('VERSION', '2.2.0.1b');
// Configuration
if (is_file('config.php')) {
    require_once 'config.php';
}
// Install
if (!defined('DIR_APPLICATION')) {
    header('Location: ../install/index.php');
    exit;
}
// Startup
require_once DIR_SYSTEM . 'startup.php';
start('admin');
Exemplo n.º 14
0
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 "ReStarting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    stop(true);
    if ($GLOBALS["OUTPUT"]) {
        echo "Restarting....: [INIT]: {$GLOBALS["TITLENAME"]} Removing sessions\n";
    }
    remove_sessions();
    if ($GLOBALS["OUTPUT"]) {
        echo "Restarting....: [INIT]: {$GLOBALS["TITLENAME"]} Building rules\n";
    }
    build();
    start(true);
    if ($GLOBALS["OUTPUT"]) {
        echo "Restarting....: [INIT]: {$GLOBALS["TITLENAME"]} Success starting PID 0\n";
    }
}
Exemplo n.º 15
0
<?php

	include_once('ressources/class.templates.inc');
	include_once('ressources/class.ldap.inc');
	include_once('ressources/class.users.menus.inc');
	include_once('ressources/class.mysql.inc');	
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["find"])){find();exit;}
if(isset($_GET["icon"])){icon();exit;}
if(isset($_GET["start"])){start();exit;}	
if(isset($_POST["UnityPurge"])){UnityPurge();exit;}		
	js();

	
	
function icon(){
	return;
	$users=new usersMenus();
	$tpl=new templates();
		$LinuxDistriCode=$users->LinuxDistriCode;
		$LinuxDistriCodeIMG="unity-ubuntu-22.png";
		if($LinuxDistriCode=="DEBIAN"){$LinuxDistriCodeIMG="unity-debian-22.png";}
		if($LinuxDistriCode=="CENTOS"){$LinuxDistriCodeIMG="CENTOS-22.png";}
		if($LinuxDistriCode=="SUSE"){$LinuxDistriCodeIMG="unity-suse-22.png";}
		echo $tpl->_ENGINE_parse_body("<span style='float:left;margin-left:-4px'>".imgtootltip($LinuxDistriCodeIMG,"{find_features_and_options}","Loadjs('unity.php')")."</span>");
		
}	
	

function js(){
	
Exemplo n.º 16
0
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());
    stop(true);
    $php5 = $unix->LOCATE_PHP5_BIN();
    build();
    shell_exec("{$php5} /usr/share/artica-postfix/exec.pdns.php --mysql");
    sleep(1);
    start(true);
}
Exemplo n.º 17
0
function reload()
{
    $unix = new unix();
    $LOGBIN = "DHCP Server";
    $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]: {$LOGBIN} Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $pid = PID_NUM();
    $time = $unix->PROCCESS_TIME_MIN($pid);
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $kill = $unix->find_program("kill");
    BuildDHCP(true);
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$LOGBIN} reloading PID {$pid} since {$time}mn\n";
    }
    stop(true);
    start(true);
}
Exemplo n.º 18
0
function clean($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $pidfile = "/etc/artica-postfix/pids/zarafa-search-starter.pid";
    if (!$aspid) {
        $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["SERVICE_NAME"]} Engine Artica Task Already running PID {$pid} since {$time}mn\n";
            }
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    $ZarafaIndexPath = $sock->GET_INFO("ZarafaIndexPath");
    if ($ZarafaIndexPath == null) {
        $ZarafaIndexPath = "/var/lib/zarafa/index";
    }
    $rm = $unix->find_program("rm");
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} directory {$ZarafaIndexPath}\n";
    }
    stop(true);
    recursive_remove_directory($ZarafaIndexPath, true);
    start(true);
}
function wizard2_ipv4()
{
    if ($_SESSION["WIZINSTANCE"]["WIZINTERFACE"] == null) {
        start();
        exit;
    }
    include_once dirname(__FILE__) . "/ressources/class.system.network.inc";
    $tpc = new networking();
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $EnableipV6 = $sock->GET_INFO("EnableipV6");
    if (!is_numeric($EnableipV6)) {
        $EnableipV6 = 0;
    }
    if (!isset($_SESSION["WIZINSTANCE"]["WIZIPADDR"])) {
        $tpc->ifconfig($_SESSION["WIZINSTANCE"]["WIZINTERFACE"]);
        $ipaddr = $tpc->tcp_addr;
        $exploded = explode(".", $ipaddr);
        $lastNumber = $exploded[3];
        $lastNumberPrefix = "{$exploded[0]}.{$exploded[1]}.{$exploded[2]}.";
        $iptrue = true;
        while ($iptrue == true) {
            $lastNumber = $lastNumber + 1;
            $q = new mysql();
            if ($lastNumber > 254) {
                break;
            }
            $newipaddr = $lastNumberPrefix . $lastNumber;
            $sql = "SELECT ip_address FROM postfix_multi WHERE ip_address='{$newipaddr}'";
            $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
            if (trim($ligne["ip_address"] == null)) {
                break;
            }
        }
        $network = $tpc->netmask;
        $gw = $tpc->gateway;
    } else {
        $newipaddr = $_SESSION["WIZINSTANCE"]["WIZIPADDR"];
        $network = $_SESSION["WIZINSTANCE"]["WIZIPMASK"];
        $gw = $_SESSION["WIZINSTANCE"]["WIZIPGW"];
    }
    $html = "<strong style='font-size:16px'>{Interface}:{$_SESSION["WIZINSTANCE"]["WIZINTERFACE"]}</strong>\n\t<div class=explain style='font-size:14px'>{welcome_new_instance_wizard_interface}</div>\n\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{ipaddr}:</td>\n\t\t<td>" . field_ipv4("WIZIPADDR", $newipaddr, "font-size:14px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{netmask}:</td>\n\t\t<td>" . field_ipv4("WIZIPMASK", $network, "font-size:14px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{gateway}:</td>\n\t\t<td>" . field_ipv4("WIZIPGW", $gw, "font-size:14px") . "</td>\n\t</tr>\t\n\t\t<tr>\n\t\t<td colspan=2><hr></td>\n\t</tR>\n\t<tr>\n\t\t<td align='left'>" . button("{previous}", "LoadAjax('new_instance_wizard','{$page}?start=yes');", 16) . "</td>\n\t\t<td align='right'>" . button("{next}", "WIZ_WIZIPSAVE()", 16) . "</td>\n\t</tr>\n\t</tbody>\n\t</table>\t\n\t<script>\n\tvar XWIZ_WIZIPSAVE= function (obj) {\n\t var results=obj.responseText;\n\t if(results.length>3){alert(results);return;}\n\t \tWIZMULTI3();\n\t}\t\n\t\n\tfunction WIZ_WIZIPSAVE(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('WIZIPADDR',document.getElementById('WIZIPADDR').value);\n\t\tXHR.appendData('WIZIPMASK',document.getElementById('WIZIPMASK').value);\n\t\tXHR.appendData('WIZIPGW',document.getElementById('WIZIPGW').value);\n\t\tAnimateDiv('new_instance_wizard');\n\t\tXHR.sendAndLoad('{$page}', 'POST',XWIZ_WIZIPSAVE);\t\n\t}\n\t\n\t</script>\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemplo n.º 20
0
function build()
{
    $unix = new unix();
    $sock = new sockets();
    $Isagetway = false;
    $INSTALL_SERVICE = false;
    $KernelSendRedirects = $sock->GET_INFO("KernelSendRedirects");
    if (!is_numeric($KernelSendRedirects)) {
        $KernelSendRedirects = 1;
    }
    $conntrack = $unix->find_program("conntrack");
    $EnableChilli = $sock->GET_INFO("EnableChilli");
    $EnableArticaAsGateway = $sock->GET_INFO("EnableArticaAsGateway");
    if (!is_numeric($EnableChilli)) {
        $EnableChilli = 0;
    }
    $hasProxyTransparent = $sock->GET_INFO("hasProxyTransparent");
    if (!is_numeric($hasProxyTransparent)) {
        $hasProxyTransparent = 0;
    }
    $hostname = trim(@file_get_contents("/etc/artica-postfix/FULL_HOSTNAME"));
    if ($EnableChilli == 1) {
        $Isagetway = true;
    }
    if ($EnableArticaAsGateway == 1) {
        $Isagetway = true;
    }
    if ($hasProxyTransparent == 1) {
        $Isagetway = true;
    }
    if (is_file("/etc/artica-postfix/IPTABLES_BR_BRIDGE")) {
        $Isagetway = true;
    }
    if (is_file("/etc/artica-postfix/IPTABLES_BRIDGE")) {
        $Isagetway = true;
    }
    $EnableipV6 = $sock->GET_INFO("EnableipV6");
    if (!is_numeric($EnableipV6)) {
        $EnableipV6 = 0;
    }
    $ARRAY = unserialize(base64_decode($sock->GET_INFO("kernel_values")));
    $swappiness = intval($ARRAY["swappiness"]);
    if ($swappiness == 0) {
        $swappiness = 10;
    }
    $tcp_max_syn_backlog = $ARRAY["tcp_max_syn_backlog"];
    if (!is_numeric($tcp_max_syn_backlog)) {
        $tcp_max_syn_backlog = 1024;
    }
    $EnableTCPOptimize = $sock->GET_INFO("EnableTCPOptimize");
    $DisableConntrack = intval($sock->GET_INFO("DisableConntrack"));
    if (!is_numeric($EnableTCPOptimize)) {
        $EnableTCPOptimize = 1;
    }
    $DisableTCPOptimizations = $sock->GET_INFO("DisableTCPOptimizations");
    if ($DisableTCPOptimizations == 1) {
        $EnableTCPOptimize = 0;
    }
    $echo = $unix->find_program("echo");
    $modprobe = $unix->find_program("modprobe");
    $DisableTCPEn = intval(trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/DisableTCPEn")));
    $DisableTCPWindowScaling = intval(trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/DisableTCPWindowScaling")));
    $EnableSystemOptimize = intval(trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableSystemOptimize")));
    $tcp_ecn = 2;
    $tcp_window_scaling = 1;
    if ($DisableTCPWindowScaling == 1) {
        $tcp_window_scaling = 0;
    }
    if ($DisableTCPEn == 1) {
        $tcp_ecn = 0;
    }
    $sysctl = $unix->find_program("sysctl");
    $f[] = "#";
    $f[] = "# /etc/sysctl.conf - Configuration file for setting system variables";
    $f[] = "# See /etc/sysctl.d/ for additonal system variables";
    $f[] = "# See sysctl.conf (5) for information.";
    $f[] = "#";
    $f[] = "";
    $f[] = "#kernel.domainname = example.com";
    $f[] = "";
    $f[] = "# Uncomment the following to stop low-level messages on console";
    $f[] = "#kernel.printk = 3 4 1 3";
    $f[] = "";
    $f[] = "##############################################################";
    // /proc/sys/vm/dirty_ratio defaults to 20% of RAM
    // /proc/sys/vm/dirty_background_ratio defaults to 10%of RAM
    $memory = $unix->MEM_TOTAL_INSTALLEE() * 1024;
    $dirty_ratio = round($memory * 0.8);
    if ($EnableSystemOptimize == 0) {
        shell_exec("{$echo} 33554432 >/proc/sys/vm/dirty_background_bytes");
        shell_exec("{$echo} {$dirty_ratio} >/proc/sys/vm/dirty_bytes");
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Memory: {$memory} bytes\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} dirty_ratio = {$dirty_ratio} bytes \n";
        }
    } else {
        $swappiness = 0;
        shell_exec("{$echo} 1024 > /sys/block/sda/queue/nr_requests");
    }
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $t = explode(".", $hostname);
    if (count($t) > 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} `hostname` = '{$hostname}'\n";
        }
        $f[] = "kernel.hostname={$t[0]}";
        unset($t[0]);
        $f[] = "kernel.domainname=" . @implode(".", $t);
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} `swappiness` = '{$swappiness}%'\n";
    }
    $f[] = "vm.swappiness = {$swappiness}";
    $f[] = "net.ipv4.icmp_ignore_bogus_error_responses = 1";
    $f[] = "net.ipv4.tcp_window_scaling = {$tcp_window_scaling}";
    $f[] = "net.ipv4.tcp_ecn = {$tcp_ecn}";
    $f[] = "net.ipv4.tcp_sack = 1";
    $f[] = "net.ipv4.tcp_fack = 1";
    $f[] = "net.ipv4.tcp_timestamps = 1";
    $f[] = "net.ipv4.icmp_echo_ignore_broadcasts = 1";
    $f[] = "";
    if ($EnableSystemOptimize == 1) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} set dirty pages\n";
        }
        $f[] = "vm.dirty_background_ratio = 4";
        $f[] = "vm.dirty_background_bytes = 33554432";
        $f[] = "vm.dirty_ratio = 64";
        shell_exec("{$echo} \"100663296\" > /proc/sys/vm/dirty_bytes");
        shell_exec("{$echo} \"33554432\" > /proc/sys/vm/dirty_background_bytes");
        if (is_file($squidbin)) {
            if (is_file("/proc/sys/net/local/dgram/recvspace")) {
                $f[] = "net.local.dgram.recvspace=262144";
            }
            if (is_file("/proc/sys/net/local/dgram/maxdgram")) {
                $f[] = "net.local.dgram.maxdgram=16384";
            }
        }
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} revert dirty pages to default\n";
        }
        $f[] = "vm.dirty_background_ratio = 10";
        $f[] = "vm.dirty_ratio = 20";
        $f[] = "vm.dirty_background_bytes = 0";
        $f[] = "vm.dirty_bytes = 0";
    }
    if (is_file($conntrack)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} conntrack installed\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} conntrack DisableConntrack = {$DisableConntrack}\n";
        }
        if ($DisableConntrack == 1) {
            $f[] = "net.ipv4.netfilter.ip_conntrack_generic_timeout = 600";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent = 120";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent2 = 120";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv = 60";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 432000";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_last_ack = 30";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_close = 10";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_max_retrans = 300";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_loose = 1";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_be_liberal = 0";
            $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_max_retrans = 3";
            $f[] = "net.ipv4.netfilter.ip_conntrack_udp_timeout = 30";
            $f[] = "net.ipv4.netfilter.ip_conntrack_udp_timeout_stream = 180";
            $f[] = "net.ipv4.netfilter.ip_conntrack_icmp_timeout = 30";
            $f[] = "net.ipv4.netfilter.ip_conntrack_max = 32088";
            $f[] = "net.ipv4.netfilter.ip_conntrack_log_invalid = 0";
            $f[] = "net.netfilter.nf_conntrack_acct = 0";
            shell_exec("{$echo} 8022 >/sys/module/nf_conntrack/parameters/hashsize >/dev/null 2>&1");
        } else {
            shell_exec("{$modprobe} nf_conntrack >/dev/null 2>&1");
            shell_exec("{$modprobe} nf_conntrack_ipv4 >/dev/null 2>&1");
            $nf_conntrack_max = 196608;
            $ip_conntrack_tcp_timeout_established = 86400;
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} conntrack MAX....: {$nf_conntrack_max}\n";
            }
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} conntrack Timeout: {$ip_conntrack_tcp_timeout_established}\n";
            }
            if (is_file("/proc/sys/net/netfilter/nf_conntrack_acct")) {
                $f[] = "net.netfilter.nf_conntrack_acct = 1";
                $f[] = "net.netfilter.nf_conntrack_checksum = 0";
                $f[] = "net.netfilter.nf_conntrack_max = {$nf_conntrack_max}";
                $f[] = "net.netfilter.nf_conntrack_tcp_timeout_established = {$ip_conntrack_tcp_timeout_established}";
                $f[] = "net.netfilter.nf_conntrack_udp_timeout = 60";
                $f[] = "net.netfilter.nf_conntrack_udp_timeout_stream = 180";
                $f[] = "net.ipv4.netfilter.ip_conntrack_generic_timeout = 600";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent = 120";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_sent2 = 120";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv = 60";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = {$ip_conntrack_tcp_timeout_established}";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_last_ack = 30";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_close = 10";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_timeout_max_retrans = 300";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_loose = 1";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_be_liberal = 0";
                $f[] = "net.ipv4.netfilter.ip_conntrack_tcp_max_retrans = 3";
                $f[] = "net.ipv4.netfilter.ip_conntrack_udp_timeout = 30";
                $f[] = "net.ipv4.netfilter.ip_conntrack_udp_timeout_stream = 180";
                $f[] = "net.ipv4.netfilter.ip_conntrack_icmp_timeout = 30";
                $f[] = "net.ipv4.netfilter.ip_conntrack_max = {$nf_conntrack_max}";
                $f[] = "net.ipv4.netfilter.ip_conntrack_checksum = 1";
                $f[] = "net.ipv4.netfilter.ip_conntrack_log_invalid = 0";
                shell_exec("{$echo} " . round($nf_conntrack_max / 8) . " > /sys/module/nf_conntrack/parameters/hashsize >/dev/null 2>&1");
            }
        }
    }
    if ($EnableTCPOptimize) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Optimize TCP stack\n";
        }
        $f[] = "net.ipv4.tcp_rfc1337 = 1";
        $f[] = "net.ipv4.tcp_syn_retries = 3";
        $f[] = "net.ipv4.tcp_synack_retries = 2";
        if ($tcp_max_syn_backlog < 1025) {
            $tcp_max_syn_backlog = 10240;
        }
        $wmem_max = trim(intval(@file_get_contents("/proc/sys/net/core/wmem_max")));
        $f[] = "net.ipv4.tcp_max_syn_backlog = {$tcp_max_syn_backlog}";
        $f[] = "net.ipv4.tcp_timestamps = 0";
        $f[] = "net.ipv4.tcp_fin_timeout = 15";
        $f[] = "net.ipv4.tcp_keepalive_time = 1800";
        $f[] = "net.ipv4.tcp_reordering = 5";
        $f[] = "net.ipv4.tcp_synack_retries = 3";
        $f[] = "net.ipv4.tcp_max_tw_buckets = 360000";
        $f[] = "net.core.netdev_max_backlog = 4000";
        $f[] = "net.core.rmem_default = 262144";
        $f[] = "net.core.rmem_max = 262144";
        $f[] = "net.core.wmem_max = 262144";
        $f[] = "net.ipv4.tcp_rmem=10240 87380 {$wmem_max}";
        $f[] = "net.ipv4.tcp_wmem=10240 87380 {$wmem_max}";
        $f[] = "net.ipv4.tcp_mem = {$wmem_max} {$wmem_max} {$wmem_max}";
        $f[] = "net.ipv4.conf.all.log_martians=0";
        $f[] = "net.ipv4.ip_local_port_range = 1024 65000";
        $f[] = "net.ipv4.tcp_window_scaling = {$tcp_window_scaling}";
        $f[] = "net.ipv4.tcp_ecn = {$tcp_ecn}";
        $f[] = "net.ipv4.tcp_low_latency =1 ";
        $f[] = "net.ipv4.tcp_timestamps=1";
        $f[] = "net.ipv4.tcp_sack=1";
        $f[] = "net.ipv4.tcp_no_metrics_save=1";
        $f[] = "net.core.netdev_max_backlog=16384";
        $f[] = "net.core.rmem_max=12582912";
        $f[] = "net.core.wmem_max = 12582912";
        $f[] = "net.core.wmem_default = 65535";
        $f[] = "net.core.optmem_max = 40960";
        $f[] = "net.ipv6.conf.all.accept_redirects = 1";
        $f[] = "net.ipv6.conf.all.accept_source_route = 0";
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} TCP stack set to default\n";
        }
        $f[] = "net.ipv4.tcp_rfc1337 = 0";
        $f[] = "net.ipv4.tcp_low_latency = 0 ";
        $f[] = "net.ipv4.tcp_syn_retries = 5";
        $f[] = "net.ipv4.tcp_synack_retries = 5";
        $f[] = "net.ipv4.tcp_max_syn_backlog = 512";
        $f[] = "net.ipv4.tcp_timestamps = 1";
        $f[] = "net.ipv4.tcp_fin_timeout = 60";
        $f[] = "net.ipv4.tcp_keepalive_time = 7200";
        $f[] = "net.ipv4.tcp_reordering = 3";
        $f[] = "net.ipv4.tcp_max_tw_buckets = 65536";
        $f[] = "net.ipv4.ip_local_port_range = 32768\t61000";
        $f[] = "net.core.rmem_default = 229376";
        $f[] = "net.core.netdev_max_backlog = 1000";
        $f[] = "net.core.rmem_max = 131071";
        $f[] = "net.core.wmem_max = 131071";
        $f[] = "net.ipv4.tcp_rmem = 4096\t87380\t1033696";
        $f[] = "net.ipv4.tcp_wmem = 4096\t16384\t1033696";
        $f[] = "net.ipv4.tcp_mem = 24225\t32303\t48450";
        $f[] = "net.ipv4.tcp_window_scaling = {$tcp_window_scaling}";
        $f[] = "net.ipv4.tcp_ecn = {$tcp_ecn}";
        $f[] = "net.ipv4.tcp_sack = 1";
        $f[] = "net.ipv4.tcp_no_metrics_save = 0";
        $f[] = "net.core.netdev_max_backlog = 1000";
        $f[] = "net.core.rmem_max = 131071";
        $f[] = "net.core.wmem_max = 131071";
        $f[] = "net.core.wmem_default = 229376";
        $f[] = "net.core.optmem_max = 20480";
        $f[] = "net.ipv4.icmp_echo_ignore_broadcasts = 1";
        $f[] = "net.ipv4.conf.all.send_redirects = 1";
        $f[] = "net.ipv4.conf.all.secure_redirects = 1";
        $f[] = "net.ipv4.conf.all.accept_redirects = 1";
        $f[] = "net.ipv4.conf.all.accept_source_route = 0";
        $f[] = "net.ipv4.conf.all.arp_accept = 0";
        $f[] = "net.ipv4.conf.all.arp_ignore = 0";
        $f[] = "net.ipv4.conf.all.arp_announce = 0";
        $f[] = "net.ipv4.conf.all.arp_filter = 0";
        $f[] = "net.ipv4.conf.all.arp_notify = 0";
        $f[] = "net.ipv4.ip_nonlocal_bind = 0";
        $f[] = "net.ipv4.conf.all.log_martians=0";
        $f[] = "net.ipv4.tcp_max_syn_backlog = 512";
    }
    if ($Isagetway) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Set as gateway...\n";
        }
        $f[] = "net.ipv4.ip_forward=1";
        if ($EnableipV6 == 1) {
            $f[] = "net.ipv6.conf.all.send_redirects = {$KernelSendRedirects}";
            $f[] = "net.ipv6.conf.all.forwarding=1";
            $f[] = "net.ipv6.conf.all.accept_redirects = 1";
            $f[] = "net.ipv6.conf.all.accept_source_route = 1";
            $f[] = "net.ipv6.conf.all.arp_accept=0";
            $f[] = "net.ipv6.conf.all.arp_ignore=1";
            $f[] = "net.ipv6.conf.all.arp_announce=2";
            $f[] = "net.ipv6.conf.all.arp_filter=1";
            $f[] = "net.ipv6.conf.all.arp_notify=1";
        }
    }
    if ($EnableipV6 == 1) {
        $f[] = "net.ipv6.conf.all.disable_ipv6 = 0";
        $f[] = "net.ipv6.conf.default.disable_ipv6 = 0";
        $f[] = "net.ipv6.conf.lo.disable_ipv6 = 0";
    } else {
        $f[] = "net.ipv6.conf.all.disable_ipv6 = 1";
        $f[] = "net.ipv6.conf.default.disable_ipv6 = 1";
        $f[] = "net.ipv6.conf.lo.disable_ipv6 = 1";
    }
    $SCRIPT[] = "#!/bin/sh";
    $SCRIPT[] = "### BEGIN INIT INFO";
    $SCRIPT[] = "# Provides:         artica-optimize";
    $SCRIPT[] = "# Required-Start:    \$local_fs";
    $SCRIPT[] = "# Required-Stop:     \$local_fs";
    $SCRIPT[] = "# Should-Start:";
    $SCRIPT[] = "# Should-Stop:";
    $SCRIPT[] = "# Default-Start:     2 3 4 5";
    $SCRIPT[] = "# Default-Stop:      0 1 6";
    $SCRIPT[] = "# Short-Description: artica-optimize";
    $SCRIPT[] = "# chkconfig: - 80 75";
    $SCRIPT[] = "# description: artica-optimize";
    $SCRIPT[] = "### END INIT INFO";
    $SCRIPT[] = "case \"\$1\" in";
    $SCRIPT[] = " start)";
    $SCRIPT[] = "echo \"Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}\"";
    $echo = $unix->find_program("echo");
    while (list($index, $line) = each($f)) {
        if (!preg_match("#(.+?)=(.+)#", $line, $re)) {
            continue;
        }
        $SCRIPT[] = "{$sysctl} -w \"" . trim($re[1]) . "=" . trim($re[2]) . "\" >/dev/null 2>&1 || true";
    }
    $SCRIPT[] = "echo \"Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}\" done.";
    $SCRIPT[] = ";;";
    $SCRIPT[] = "*)";
    $SCRIPT[] = "echo \"Usage: \$0 start\"";
    $SCRIPT[] = "exit 1";
    $SCRIPT[] = ";;";
    $SCRIPT[] = "esac";
    $SCRIPT[] = "exit 0";
    $SCRIPT[] = "";
    if (!is_file("/etc/init.d/artica-optimize")) {
        $INSTALL_SERVICE = true;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/init.d/artica-optimize done\n";
    }
    @file_put_contents("/etc/init.d/artica-optimize", @implode("\n", $SCRIPT));
    @chmod("/etc/init.d/artica-optimize", 0755);
    $f[] = "";
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Installing init service\n";
    }
    @file_put_contents("/etc/sysctl.conf", @implode("\n", $f));
    if (is_file('/usr/sbin/update-rc.d')) {
        shell_exec("/usr/sbin/update-rc.d -f artica-optimize defaults >/dev/null 2>&1");
    }
    if (is_file('/sbin/chkconfig')) {
        shell_exec("/sbin/chkconfig --add artica-optimize >/dev/null 2>&1");
        shell_exec("/sbin/chkconfig --level 345 artica-optimize on >/dev/null 2>&1");
    }
    shell_exec("/etc/init.d/artica-optimize start");
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} /etc/sysctl.conf done\n";
    }
    if ($GLOBALS["REBOOT"]) {
        $reboot = $unix->find_program("reboot");
        shell_exec("{$reboot}");
    }
    start(true);
}
Exemplo n.º 21
0
function restart()
{
    stop();
    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, build_index_page();\n";
    build_index_page();
    start();
}
Exemplo n.º 22
0
	<?php 
error_reporting(1);
require_once 'lib/WhatsAPI/whatsprot.class.php';
//require_once 'node.php';
$s_uso = "Usar--> main.php <numero> <encuesta>";
$s_phone = '549';
$s_phone = $s_phone . $_SERVER['argv'][1];
$s_encuestan = $_SERVER['argv'][2];
if (is_numeric($s_phone) && strlen($s_phone) == 13 && !empty($s_encuestan)) {
    start($s_phone, $s_encuestan);
} else {
    die($s_uso);
}
function start($s_num, $s_encuestan)
{
    require 'config/config_w.php';
    require 'strings.php';
    require 'frase.php';
    require_once 'encuestaloader.php';
    require_once 'encuesta.php';
    $encuestaloader = new Encuestaloader($s_encuestan);
    $encuesta = $encuestaloader->get_encuesta();
    $s_saludo = new Frase();
    echo "Enviar a--> {$s_num}\n";
    echo "Cantidad de preguntas: " . $encuesta->tam() . "\n\n";
    $wa = new WhatsProt($s_sender, $s_nickname, false);
    $wa->connect();
    $wa->loginWithPassword($s_password);
    echo "Presentando...\n";
    envio($wa, $s_saludo->get_stiempo(0) . $s_msg_hi, $s_num);
    $i_contfail = 0;
Exemplo n.º 23
0
            echo "FATAL! could not configure postgres or php config files\n";
            exit(1);
        }
        /*
        echo "*** Checking apache config ***\n";
        if(!configApache2($distros[0]))
        {
        echo "Fatal, could not configure apache2 to use fossology\n";
        }
        */
        if (!restart('apache2')) {
            echo "Erorr! Could not restart apache2, please restart by hand\n";
            exit(1);
        }
        echo "*** Starting FOSSology ***\n";
        if (!start('fossology')) {
            echo "Erorr! Could not start FOSSology, please restart by hand\n";
            exit(1);
        }
        break;
    default:
        echo "Fatal! unrecognized distribution! {$distros[0]}\n";
        exit(1);
        break;
}
class ConfigSys
{
    public $osFlavor;
    public $osVersion = 0;
    private $fossVersion;
    private $osCodeName;
Exemplo n.º 24
0
function restart()
{
    $unix = new unix();
    $sock = new sockets();
    $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_restart("{failed}", 110);
        return;
    }
    @file_put_contents($pidfile, getmypid());
    build_progress_restart("{stopping_service}", 15);
    if (!stop(true)) {
        build_progress_restart("{failed}", 110);
        return;
    }
    build_progress_restart("{reconfiguring}", 30);
    build();
    sleep(1);
    build_progress_restart("{starting_service}", 30);
    if (!start(true)) {
        build_progress_restart("{failed}", 110);
    }
    build_progress_restart("{reloading} Postfix", 90);
    system("/etc/init.d/postfix reload");
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    shell_exec("{$nohup} {$php} /usr/share/artica-postfix/exec.freshclam.php --execute >/dev/null 2>&1 &");
    build_progress_restart("{success}", 100);
}
Exemplo n.º 25
0
while (1) {
    $messages = $bot->getUpdates();
    if ($messages != false) {
        foreach ($messages as $msg) {
            if ($msg['message']['text'] && $msg['message']['from']['id'] == $msg['message']['chat']['id']) {
                if (debug == 1) {
                    echo 'Got text: ' . $msg['message']['text'] . "\n";
                }
                $from = $msg['message']['from'];
                $text = $msg['message']['text'];
                switch ($text) {
                    case '/start':
                    case '/старт':
                    case '/Старт':
                    case '/Start':
                        start($from['id'], $from['first_name'], $from['last_name']);
                        break;
                    case '/stop':
                    case '/end':
                    case '/стоп':
                    case '/Стоп':
                    case '/Stop':
                    case '/quit':
                    case '/exit':
                        stop($from['id']);
                        break;
                    case '/help':
                        help($from['id']);
                        break;
                    case '/top':
                        top($from['id']);
Exemplo n.º 26
0
             if ($node->getNType() != 'iol') {
                 // IOL nodes drop privileges, so need to be postponed
                 $rc = start($node, $node_id, $tenant, $lab->getNetworks());
                 if ($rc !== 0) {
                     // Failed to start the node
                     error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][$rc]);
                     error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][12]);
                     exit(12);
                 }
             }
         }
         // Starting all IOL nodes
         foreach ($lab->getNodes() as $node_id => $node) {
             if ($node->getNType() == 'iol') {
                 // IOL nodes drop privileges, so need to be postponed
                 $rc = start($node, $node_id, $tenant, $lab->getNetworks());
                 if ($rc !== 0) {
                     // Failed to start the node
                     error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][$rc]);
                     error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][12]);
                     exit(12);
                 }
             }
         }
     }
     break;
 case 'stop':
     // Stopping node(s)
     if (isset($node_id)) {
         // Node ID is set, stop and wipe the node
         stop($lab->getNodes()[$node_id]);
Exemplo n.º 27
0
function parse_memory()
{
    $unix = new unix();
    $nginx = $unix->find_program("nginx");
    $sock = new sockets();
    $nginx = $unix->find_program("nginx");
    if (!is_file($nginx)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, not installed\n";
        }
        return;
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidStampReload = $GLOBALS["pidStampReload"];
    if (!$GLOBALS["VERBOSE"]) {
        echo "{$pidtime}\n";
        $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]: Nginx Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        $TimExec = $unix->file_time_min($pidtime);
        if ($TimExec < 5) {
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    $python = $unix->find_program("python");
    $nice = $unix->EXEC_NICE();
    exec("{$nice}{$python} /usr/share/artica-postfix/bin/ps_mem.py 2>&1", $results);
    $FOUND = false;
    while (list($index, $line) = each($results)) {
        $line = trim($line);
        if ($line == null) {
            continue;
        }
        if (!preg_match("#^[0-9\\.]+.*?=\\s+([0-9\\.]+)\\s+(.+?)\\s+nginx#", $line, $re)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Not found \"{$line}\"\n";
            }
            continue;
        }
        $memoryValue = $re[1];
        $unit = trim(strtolower($re[2]));
        echo "Found {$memoryValue} {$unit}\n";
        if ($unit == "kib") {
            $memoryValue = $memoryValue / 1048.576;
        }
        if ($unit == "mib") {
            $memoryValue = $memoryValue * 1.048576;
        }
        if ($unit == "gib") {
            $memoryValue = $memoryValue * 1048.576;
        }
        $FOUND = true;
        break;
    }
    if (!$FOUND) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Not found...\n";
        }
        return;
    }
    $memoryValue = round($memoryValue, 2);
    $MaxMemory = max_memory();
    $MaxMemoryReload = $MaxMemory / 2;
    $memoryValueInt = intval($memoryValue);
    echo "Nginx = {$memoryValue} MB  INT({$memoryValueInt}) Reload on:{$MaxMemoryReload}MB; Restart on:{$MaxMemory}MB\n";
    $ACTION_DONE = false;
    if ($MaxMemory > 0) {
        if ($memoryValueInt > 0) {
            if ($memoryValueInt > $MaxMemoryReload) {
                $StampTime = $unix->file_time_min($pidStampReload);
                if ($StampTime > 20) {
                    squid_admin_mysql(1, "Reverse proxy reach medium memory {$memoryValueInt}MB Reload:{$MaxMemoryReload}MB [action=reload]", "The service will be restarted");
                    reload(true);
                    @unlink($pidStampReload);
                    @file_put_contents($pidStampReload, time());
                    $ACTION_DONE = true;
                }
            }
            if (!$ACTION_DONE) {
                if ($memoryValueInt > $MaxMemory) {
                    squid_admin_mysql(0, "Reverse proxy reach max memory allowed {$memoryValueInt}MB MAX:{$MaxMemory}MB [action=restart]", "The service will be restarted");
                    stop(true);
                    start(true);
                    @unlink($pidStampReload);
                }
            }
        }
    }
    add_memory_value($memoryValue);
}
Exemplo n.º 28
0
    build_squid();
    die;
}
if ($argv[1] == "--build") {
    $GLOBALS["OUTPUT"] = true;
    build();
    die;
}
if ($argv[1] == "--stop") {
    $GLOBALS["OUTPUT"] = true;
    stop($argv[2]);
    die;
}
if ($argv[1] == "--start") {
    $GLOBALS["OUTPUT"] = true;
    start($argv[2]);
    die;
}
function start($ID)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/sockd.pid";
    $SERV_NAME = $GLOBALS["SERV_NAME"];
    $pid = $unix->get_pid_from_file($pidfile);
    $sock = new sockets();
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Starting Task Already running PID {$pid} since {$time}mn\n";
        }
        return;
Exemplo n.º 29
0
}
$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();
Exemplo n.º 30
0
<?php

// Version
define('VERSION', '1.5.0.0');
// Configuration
require_once '../../../../config.php';
date_default_timezone_set('PRC');
// Startup
require_once DIR_SYSTEM . 'startup.php';
define('PAY_METHOD_CALLBACK', 'extension/payment/wxpay/callback');
start('catalog');