Ejemplo n.º 1
0
/**
 * Start a process
 *
 * @param string $filename The PHP file of the process to run
 * @param int $type The type (class) of process (so we can run multiple processes at the same time) defaults to 1
 * @return bool|int False if we couldnt start a process, else the process id from the process table
 * 
 * @link http://www.djkaty.com/php/fork Cross platform process tutorial (this code adapted from here)
 */
function start_process($filename, $type = 1)
{
    //create a record only if no process already running
    global $db;
    $db->StartTrans();
    $process = is_process_running($type);
    $args = 0;
    if ($process == false) {
        $sql = "INSERT INTO `process` (`process_id`,`type`,`start`,`stop`,`kill`)\r\n\t\t\tVALUES (NULL,'{$type}',NOW(),NULL,0)";
        $rs = $db->Execute($sql);
        $args = $db->Insert_ID();
        //execute the process in the background - pass the process_id as the first argument
        if (substr(PHP_OS, 0, 3) == 'WIN') {
            $proc = popen(WINDOWS_PHP_EXEC . ' ' . $filename . ' ' . $args, 'r');
        } else {
            $proc = popen(PHP_EXEC . ' ' . $filename . ' ' . $args . ' &', 'r');
        }
        pclose($proc);
    } else {
        $db->FailTrans();
    }
    $db->CompleteTrans();
    if ($args != 0) {
        return $args;
    }
    return false;
}
Ejemplo n.º 2
0
										<i class="icon-play icon-white"></i>
									</span>
								<?php 
} else {
    ?>
									<span title="Durduruldu" class="label service red">
										<i class="icon-stop icon-white"></i>
									</span>
								<?php 
}
?>
								</td>
							</tr>
							<tr>
								<?php 
$ntpdrunning = is_process_running("ntpd");
?>
								<td class="cell">
									ntpd
								</td>
								<td class="cell description sv">
									NTP zaman eşitleme servisi
								</td>
								<td class="cell status">
								<?php 
if ($ntpdrunning) {
    ?>
									<span title="Çalışıyor" class="label service blue">
										<i class="icon-play icon-white"></i>
									</span>
								<?php 
                            }
                        }
                    }
                }
            }
            if ($changed == true) {
                @file_put_contents($file, implode("\n", $splitcontents));
            }
        }
    }
}
if ($snortdownload == 'on' || $emergingthreats == 'on') {
    /* You are Not Up to date, always stop snort when updating rules for low end machines */
    /* Start the proccess for every interface rule */
    if (is_array($config['installedpackages']['snortglobal']['rule'])) {
        foreach ($config['installedpackages']['snortglobal']['rule'] as $id => $value) {
            $if_real = snort_get_real_interface($value['interface']);
            /* make oinkmaster.conf for each interface rule */
            snort_apply_customizations($value, $if_real);
        }
    }
    exec("/bin/sh /usr/local/etc/rc.d/snort.sh restart");
    sleep(10);
    if (!is_process_running("snort")) {
        exec("/bin/sh /usr/local/etc/rc.d/snort.sh start");
    }
    update_output_window(gettext("Snort has restarted with your new set of rules..."));
    log_error("Snort has restarted with your new set of rules...");
}
update_status(gettext("The Rules update finished..."));
conf_mount_ro();
Ejemplo n.º 4
0
 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
 * 
 */
if (php_sapi_name() !== "cli") {
    die;
}
/**
 * Configuration file
 */
include realpath(dirname(__FILE__) . "/../config.inc.php");
/**
 * Database file
 */
include realpath(dirname(__FILE__) . "/../db.inc.php");
/**
 * Process
 */
include realpath(dirname(__FILE__) . "/../functions/functions.process.php");
//end any other process
$p = is_process_running(2);
if ($p) {
    kill_process($p);
    end_process($p);
}
start_process(realpath(dirname(__FILE__) . "/../admin/systemsortprocess.php"), 2);
$p = is_process_running();
if ($p) {
    kill_process($p);
    end_process($p);
}
start_process(realpath(dirname(__FILE__) . "/../admin/process.php"));
Ejemplo n.º 5
0
    $pconfig['name'] = "racoon";
    $pconfig['description'] = gettext("IPsec VPN");
    $services[] = $pconfig;
    unset($pconfig);
}
if ($services) {
    foreach ($services as $service) {
        if (!$service['name']) {
            continue;
        }
        if (!$service['description']) {
            $service['description'] = get_pkg_descr($service['name']);
        }
        echo '<tr><td class="listlr">' . $service['name'] . '</td>';
        echo '<td class="listr">' . $service['description'] . '</td>';
        if (is_service_running($service['name'], $ps) or is_process_running($service['name'])) {
            echo '<td class="listr"><center>';
            echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\"> Running</td>";
            $running = true;
        } else {
            echo '<td class="listbg"><center>';
            echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\"> <font color=\"white\">Stopped</td>";
            $running = false;
        }
        echo '<td valign="middle" class="list" nowrap>';
        if ($running) {
            echo "<a href='status_services.php?mode=restartservice&service={$service['name']}'>";
            echo "<img title='Restart Service' border='0' src='./themes/" . $g['theme'] . "/images/icons/icon_service_restart.gif'></a> ";
            echo "<a href='status_services.php?mode=stopservice&service={$service['name']}'>";
            echo "<img title='Stop Service' border='0' src='./themes/" . $g['theme'] . "/images/icons/icon_service_stop.gif'> ";
            echo "</a>";
Ejemplo n.º 6
0
$f5_web_client_port = $f5_credentials["f5_web_client_port"];
$f5_partition = $f5_credentials["f5_partition"];
$f5_user = $f5_credentials["f5_user"];
$f5_pass = $f5_credentials["f5_pass"];
$f5_pool = $f5_credentials["f5_pool"];
$f5_ip1 = $f5_credentials["f5_ip1"];
$f5_ip2 = $f5_credentials["f5_ip2"];
$fast_rollback_target = sprintf($server_cfg['config_directory'], $game_name);
$fast_rollback_target = $fast_rollback_target . $pool_name . ".sh";
foreach ($ip_list as $key => $ip) {
    $rollback_command = "";
    $pid[$ip] = register_node($ip, $f5_web_client_port, $f5_partition, $f5_user, $f5_pass, $f5_pool, $f5_ip1, $f5_ip2);
}
// Waiting for the registrarion process to complete
foreach ($ip_list as $key => $ip) {
    while (is_process_running($pid[$ip])) {
        sleep(1);
    }
    $ip_log_target = sprintf($server_cfg['log_file'], $ip);
    $log_contents[$ip] = file_get_contents($ip_log_target);
}
$failed = false;
foreach ($log_contents as $ip => $log) {
    if (stripos($log, "Terminating with exit code 0") !== false) {
        echo "Registered node {$ip} with F5... \n";
    } else {
        $game_log = sprintf($server_cfg['log_file'], $game_name);
        echo "Registration of node {$ip} failed. Check the game log. \n";
        error_log('[' . date("F j, Y, g:i:s a e") . "]\n" . $log . "\n", 3, $game_log);
        $failed = true;
    }
Ejemplo n.º 7
0
    $config['captiveportal'] = array();
    $config['captiveportal']['page'] = array();
    $config['captiveportal']['timeout'] = 300;
}
$pconfig['cinterface'] = $config['captiveportal']['interface'];
$pconfig['timeout'] = $config['captiveportal']['timeout'];
$pconfig['idletimeout'] = $config['captiveportal']['idletimeout'];
$pconfig['enable'] = isset($config['captiveportal']['enable']);
if ($_POST) {
    unset($input_errors);
    $pconfig = $_POST;
    if ($_POST['enable']) {
        $reqdfields = explode(' ', 'cinterface');
        $reqdfieldsn = array("Arayüz");
        do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
        if (!is_process_running("mysqld")) {
            start_mysql();
        }
        start_radius();
    } else {
        stop_radius();
    }
    if ($_POST['timeout'] && (!is_numeric($_POST['timeout']) || $_POST['timeout'] < 1)) {
        $input_errors[] = 'Aktif oturum süresi 1 dakikadan az olamaz.';
    }
    if ($_POST['idletimeout'] && (!is_numeric($_POST['idletimeout']) || $_POST['idletimeout'] < 1)) {
        $input_errors[] = 'Aktif oturum süresi 1 dakikadan az olamaz.';
    }
    if (!$input_errors) {
        if (is_array($_POST['cinterface'])) {
            $config['captiveportal']['interface'] = implode(',', $_POST['cinterface']);
         }
         suricata_apply_customizations($value, $if_real);
         $tmp = "\t" . $tmp . "\n";
         error_log($tmp, 3, SURICATA_RULES_UPD_LOGFILE);
     }
 } else {
     if ($pkg_interface != "console") {
         update_output_window(gettext("Warning:  No interfaces configured for Suricata were found..."));
         update_output_window(gettext("No interfaces currently have Suricata configured and enabled on them..."));
     }
     error_log(gettext("\tWarning:  No interfaces configured for Suricata were found...\n"), 3, SURICATA_RULES_UPD_LOGFILE);
 }
 /* Clear the rebuild rules flag.  */
 $rebuild_rules = false;
 /* Restart Suricata if already running and we are not in post-install, so as to pick up the new rules. */
 if (is_process_running("suricata") && !$g['suricata_postinstall'] && count($config['installedpackages']['suricata']['rule']) > 0) {
     // See if "Live Reload" is configured and signal each Suricata instance
     // if enabled, else just do a hard restart of all the instances.
     if ($config['installedpackages']['suricata']['config'][0]['live_swap_updates'] == 'on') {
         if ($pkg_interface != "console") {
             update_status(gettext('Signaling Suricata to live-load the new set of rules...'));
             update_output_window(gettext("Please wait ... the process should complete in a few seconds..."));
         }
         log_error(gettext("[Suricata] Live-Reload of rules from auto-update is enabled..."));
         error_log(gettext("\tLive-Reload of updated rules is enabled...\n"), 3, SURICATA_RULES_UPD_LOGFILE);
         foreach ($config['installedpackages']['suricata']['rule'] as $value) {
             suricata_reload_config($value);
             error_log(gettext("\tLive swap of updated rules requested for " . convert_friendly_interface_to_friendly_descr($value['interface']) . ".\n"), 3, SURICATA_RULES_UPD_LOGFILE);
         }
         log_error(gettext("[Suricata] Live-Reload of updated rules completed..."));
         error_log(gettext("\tLive-Reload of the updated rules is complete.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
    if (download_file("{$et_iqrisk_url}iprepdata.txt.gz", "{$iqRisk_tmppath}iprepdata.txt.gz") != true) {
        log_error(gettext("[Suricata] An error occurred downloading the 'iprepdata.txt.gz' file for IQRisk."));
    } else {
        // If the files downloaded successfully, unpack them and store
        // the list files in the SURICATA_IPREP_PATH directory.
        if (file_exists("{$iqRisk_tmppath}iprepdata.txt.gz") && file_exists("{$iqRisk_tmppath}iprepdata.txt.gz.md5")) {
            $new_md5 = trim(file_get_contents("{$iqRisk_tmppath}iprepdata.txt.gz.md5"));
            if ($new_md5 == md5_file("{$iqRisk_tmppath}iprepdata.txt.gz")) {
                mwexec("/usr/bin/gunzip -f {$iqRisk_tmppath}iprepdata.txt.gz");
                @rename("{$iqRisk_tmppath}iprepdata.txt", "{$iprep_path}iprepdata.txt");
                @rename("{$iqRisk_tmppath}iprepdata.txt.gz.md5", "{$iprep_path}iprepdata.txt.gz.md5");
                $success = TRUE;
                log_error(gettext("[Suricata] Successfully updated IPREP file 'iprepdata.txt'."));
            } else {
                log_error(gettext("[Suricata] MD5 integrity check of downloaded 'iprepdata.txt.gz' file failed!  Skipping update of this IPREP file."));
            }
        }
    }
}
// Cleanup the tmp directory path
rmdir_recursive("{$iqRisk_tmppath}");
log_error(gettext("[Suricata] Emerging Threats IQRisk IP List update finished."));
// If successful, signal any running Suricata process to live reload the rules and IP lists
if ($success == TRUE && is_process_running("suricata")) {
    foreach ($config['installedpackages']['suricata']['rule'] as $value) {
        if ($value['enable_iprep'] == "on") {
            suricata_reload_config($value);
            sleep(2);
        }
    }
}
function getUPSData()
{
    global $config;
    $data = "";
    $cmd = "";
    $nut_config = $config['installedpackages']['nut']['config'][0];
    if ($nut_config['monitor'] == "local") {
        // "Monitoring" field - upsdata_array[0]
        $data = gettext("Local UPS");
        $cmd = "upsc {$nut_config['name']}@localhost";
    } elseif ($nut_config['monitor'] == "remote") {
        // "Monitoring" field - upsdata_array[0]
        $data = gettext("Remote UPS");
        $cmd = "upsc {$nut_config['remotename']}@{$nut_config['remoteaddr']}";
    } elseif ($nut_config['monitor'] == "snmp") {
        // "Monitoring" field - upsdata_array[0]
        $data = gettext("SNMP UPS");
        $cmd = "upsc {$nut_config['snmpname']}@localhost";
    }
    if (is_process_running('upsmon')) {
        $handle = popen($cmd, 'r');
        if ($handle) {
            $read = fread($handle, 4096);
            pclose($handle);
            $lines = explode("\n", $read);
            if (count($lines) == 1) {
                $condition = gettext("Data stale!");
            } else {
                $ups = array();
                foreach ($lines as $line) {
                    $line = explode(':', $line);
                    $ups[$line[0]] = trim($line[1]);
                }
            }
        }
    } else {
        $condition = gettext("NUT enabled, but service not running!");
        if ($nut_config['monitor'] == "snmp") {
            $condition .= gettext("\nSNMP UPS may be unreachable.");
        }
    }
    if (isset($condition)) {
        // Return error description
        return $condition;
    }
    // "Model" field - upsdata_array[1]
    $data .= ":" . ($ups['ups.model'] != "" ? $ups['ups.model'] : gettext("n/a"));
    // "Status" field - upsdata_array[2]
    $status = explode(" ", $ups['ups.status']);
    foreach ($status as $condition) {
        if ($disp_status) {
            $disp_status .= ", ";
        }
        switch ($condition) {
            case "WAIT":
                $disp_status .= gettext("Waiting");
                break;
            case "OFF":
                $disp_status .= gettext("Off Line");
                break;
            case "OL":
                $disp_status .= gettext("On Line");
                break;
            case "OB":
                $disp_status .= gettext("On Battery");
                break;
            case "TRIM":
                $disp_status .= gettext("SmartTrim");
                break;
            case "BOOST":
                $disp_status .= gettext("SmartBoost");
                break;
            case "OVER":
                $disp_status .= gettext("Overload");
                break;
            case "LB":
                $disp_status .= gettext("Battery Low");
                break;
            case "RB":
                $disp_status .= gettext("Replace Battery");
                break;
            case "CAL":
                $disp_status .= gettext("Calibration");
                break;
            case "CHRG":
                $disp_status .= gettext("Charging");
                break;
            default:
                $disp_status .= $condition;
                break;
        }
    }
    $data .= ":" . $disp_status;
    // "Battery Charge" bars and field - upsdata_array[3]
    $data .= ":" . $ups['battery.charge'] . "%";
    // "Time Remaning" field - upsdata_array[4]
    $secs = $ups['battery.runtime'];
    if ($secs < 0 || $secs == "") {
        $data .= ":" . gettext("n/a");
    } else {
        $m = (int) ($secs / 60);
        $h = (int) ($m / 60) % 24;
        $m = $m % 60;
        $s = $secs % 60;
        $data .= ":" . $h . "h " . $m . "m " . $s . "s";
    }
    // "Battery Voltage or Battery Temp" field - upsdata_array[5]
    if ($ups['battery.voltage'] > 0) {
        $data .= ":" . $ups['battery.voltage'] . "&nbsp;V";
    } elseif ($ups['ups.temperature'] > 0) {
        $data .= ":" . $ups['ups.temperature'] . "&#38;#176;C";
    } else {
        $data .= ":" . "";
    }
    // "Load" bars and field - upsdata_array[6]
    $data .= ":" . $ups['ups.load'] . "%";
    // "Input Voltage" field - upsdata_array[7]
    $data .= ":" . $ups['input.voltage'] . "&nbsp;V";
    // "Output Voltage" field - upsdata_array[8]
    $data .= ":" . $ups['output.voltage'] . "&nbsp;V";
    return $data;
}
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/
require "guiconfig.inc";
// Define basedir constant for unbound according to FreeBSD version (PBI support or no PBI)
if (floatval(php_uname("r")) >= 8.300000000000001) {
    define("UNBOUND_BASE", "/usr/pbi/unbound-" . php_uname("m"));
} else {
    define("UNBOUND_BASE", "/usr/local");
}
if (!is_process_running("unbound")) {
    Header("Location: /pkg_edit.php?xml=unbound.xml&id=0");
    exit;
}
$pgtitle = "Services: Unbound DNS Forwarder: Status";
include "head.inc";
function doCmdT($title, $command, $rows)
{
    echo "<p>\n";
    echo "<a name=\"" . $title . "\">\n";
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
    echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n";
    echo "<tr><td class=\"listlr\"><textarea style=\"font-family:courier\"cols=\"101\" rows=\"{$rows}\">";
    /* no newline after pre */
    if ($command == "dumpconfigxml") {
        $fd = @fopen("/conf/config.xml", "r");
         }
         suricata_apply_customizations($value, $if_real);
         $tmp = "\t" . $tmp . "\n";
         error_log($tmp, 3, $suricata_rules_upd_log);
     }
 } else {
     if ($pkg_interface != "console") {
         update_output_window(gettext("Warning:  No interfaces configured for Suricata were found..."));
         update_output_window(gettext("No interfaces currently have Suricata configured and enabled on them..."));
     }
     error_log(gettext("\tWarning:  No interfaces configured for Suricata were found...\n"), 3, $suricata_rules_upd_log);
 }
 /* Clear the rebuild rules flag.  */
 $rebuild_rules = false;
 /* Restart Suricata if already running and we are not rebooting to pick up the new rules. */
 if (is_process_running("suricata") && !$g['booting'] && !empty($config['installedpackages']['suricata']['rule'])) {
     // See if "Live Reload" is configured and signal each Suricata instance
     // if enabled, else just do a hard restart of all the instances.
     if ($config['installedpackages']['suricata']['config'][0]['live_swap_updates'] == 'on') {
         if ($pkg_interface != "console") {
             update_status(gettext('Signalling Suricata to live-load the new set of rules...'));
             update_output_window(gettext("Please wait ... the process should complete in a few seconds..."));
         }
         log_error(gettext("[Suricata] Live-Reload of rules from auto-update is enabled..."));
         error_log(gettext("\tLive-Reload of updated rules is enabled...\n"), 3, $suricata_rules_upd_log);
         foreach ($config['installedpackages']['suricata']['rule'] as $value) {
             $if_real = get_real_interface($value['interface']);
             suricata_reload_config($value);
             error_log(gettext("\tLive swap of updated rules requested for " . convert_friendly_interface_to_friendly_descr($value['interface']) . ".\n"), 3, $suricata_rules_upd_log);
         }
         log_error(gettext("[Suricata] Live-Reload of updated rules completed..."));
Ejemplo n.º 13
0
             if ($service_running) {
                 echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=stop' alt='stop'>" . $text['label-stop'] . "</a>";
             } else {
                 echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=start' alt='start'>" . $text['label-start'] . "</a>";
             }
         }
     } else {
         echo "<strong>UNSUPPORT</strong>";
         echo "</td>\n";
         echo "\t<td valign='top' class='" . $row_style[$c] . "'>\n";
         echo "<strong>UNSUPPORT</strong>";
     }
 } else {
     if ($row[service_type] == "pid" || $row[service_type] == "pid_file") {
         $pid = file_get_contents($row[service_data]);
         $service_running = is_process_running($pid);
     }
     if ($row[service_type] == "file") {
         $service_data = $row[service_data];
         $service_running = file_exists($service_data);
     }
     if ($service_running) {
         echo "<strong>" . $text['label-running'] . "</strong>";
     } else {
         echo "<strong>" . $text['label-stopped'] . "</strong>";
     }
     echo "</td>\n";
     echo "\t<td valign='top' class='" . $row_style[$c] . "'>\n";
     if ($service_running) {
         echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=stop' alt='stop'>" . $text['label-stop'] . "</a>";
     } else {
Ejemplo n.º 14
0
function get_pdt_per_page($pool_ip, $instance_count, $prev_pdt = NULL)
{
    $dir = "/tmp/pdts/";
    // Delete the previous pdts
    del_dir_create($dir);
    $relative_path = realpath(dirname(__FILE__));
    $pdt_count = -1;
    $loop = 0;
    $parallel = 20;
    if ($instance_count < 20) {
        $parallel = $instance_count;
    }
    $instance_count_parallel = $instance_count / $parallel;
    $required_pdt = (int) (0.66 * $instance_count);
    // 2/3 rd of instance_count
    $cmd = "php {$relative_path}/get_pdt.php -p " . $pool_ip . " -c " . $instance_count_parallel;
    $pid_array = array();
    //Maximum number of hits = 2*instance_count
    while ($pdt_count < $required_pdt && $loop < 3) {
        for ($i = 0; $i < $parallel; $i++) {
            $pid_array[] = run_in_background($cmd);
        }
        // Wait for the process to complete
        foreach ($pid_array as $pid) {
            while (is_process_running($pid)) {
                sleep(1);
            }
        }
        $pdt_count = count(glob($dir . "*"));
        $loop++;
    }
    if ($pdt_count < $required_pdt) {
        die("ERROR: Required number ( {$required_pdt} ) of pdt.json not fetched. Fetched {$pdt_count} pdt.json from 3*instance_count fetches.\n");
    }
    exec("/usr/local/zperfmon/bin/pdt.py " . $dir . "*", $pdt_aggr);
    $file_count = array_shift($pdt_aggr);
    $file_count = explode(" ", $file_count);
    $file_count = intval($file_count[1]);
    $page_pdt = array();
    foreach ($pdt_aggr as $pdt_list) {
        $pdt_list_array = explode(",", $pdt_list);
        $page_name = $pdt_list_array[0];
        $pdt = "";
        $count_per_file = intval($pdt_list_array[1] / $file_count);
        $time_per_file = intval($pdt_list_array[2] / $file_count);
        if ($prev_pdt != NULL) {
            $prev_count = $prev_pdt[$page_name][0];
            $prev_time = $prev_pdt[$page_name][1];
            if ($prev_count < $count_per_file) {
                $count_diff = $count_per_file - $prev_count;
                $time_diff = $time_per_file - $prev_time;
                $pdt = intval($time_diff / $count_diff);
            } else {
                $pdt = $pdt_list_array[3];
            }
        } else {
            $pdt = $pdt_list_array[3];
        }
        $page_pdt[$page_name] = array($count_per_file, $time_per_file, $pdt);
    }
    return $page_pdt;
}
             $tmp .= gettext("\tPreprocessor text rules flagged as protected and not updated for ");
             $tmp .= convert_friendly_interface_to_friendly_descr($value['interface']) . "...\n";
         }
         error_log($tmp, 3, $snort_rules_upd_log);
     }
 } else {
     if ($pkg_interface != "console") {
         update_output_window(gettext("Warning:  No interfaces configured for Snort were found..."));
         update_output_window(gettext("No interfaces currently have Snort configured and enabled on them..."));
     }
     error_log(gettext("\tWarning:  No interfaces configured for Snort were found...\n"), 3, $snort_rules_upd_log);
 }
 /* Clear the rebuild rules flag.  */
 $rebuild_rules = false;
 /* Restart snort if already running and we are not rebooting to pick up the new rules. */
 if (is_process_running("snort") && !$g['booting']) {
     if ($pkg_interface != "console") {
         update_status(gettext('Restarting Snort to activate the new set of rules...'));
         update_output_window(gettext("Please wait ... restarting Snort will take some time..."));
     }
     error_log(gettext("\tRestarting Snort to activate the new set of rules...\n"), 3, $snort_rules_upd_log);
     restart_service("snort");
     if ($pkg_interface != "console") {
         update_output_window(gettext("Snort has restarted with your new set of rules..."));
     }
     log_error(gettext("[Snort] Snort has restarted with your new set of rules..."));
     error_log(gettext("\tSnort has restarted with your new set of rules.\n"), 3, $snort_rules_upd_log);
 } else {
     if ($pkg_interface != "console") {
         update_output_window(gettext("The rules update task is complete..."));
     }
function curldownload($remote_file, $local_file)
{
    $pid = simple_run_background("curl -L -C - -o {$local_file} {$remote_file}");
    print "started download with pid: {$pid} \n";
    $remote_size = remotefsize($remote_file);
    $prev_byte = 0;
    while (is_process_running($pid)) {
        $speed = hr_bytes((filesize($local_file) - $prev_byte) / 10);
        echo "downloaded (" . hr_bytes(filesize($local_file)) . ' of ' . hr_bytes($remote_size) . ") " . $speed . "/s \n";
        $prev_byte = filesize($local_file);
        clearstatcache();
        sleep(10);
    }
    return true;
}
Ejemplo n.º 17
0
     } else {
         echo "<strong>" . $text['label-stopped'] . "</strong>";
     }
 }
 if ($row[service_type] == "file") {
     $service_data = $row[service_data];
     if (file_exists($service_data)) {
         echo "<strong>" . $text['label-running'] . "</strong>";
     } else {
         echo "<strong>" . $text['label-stopped'] . "</strong>";
     }
 }
 echo "</td>\n";
 echo "\t<td valign='top' class='" . $row_style[$c] . "'>\n";
 if ($row[service_type] == "pid" || $row[service_type] == "pid_file") {
     if (is_process_running($pid)) {
         echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=stop' alt='stop'>" . $text['label-stop'] . "</a>";
     } else {
         echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=start' alt='start'>" . $text['label-start'] . "</a>";
     }
 }
 if ($row[service_type] == "file") {
     if (file_exists($service_data)) {
         echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=stop' alt='stop'>" . $text['label-stop'] . "</a>";
     } else {
         echo "\t\t<a href='services.php?id=" . $row[service_uuid] . "&a=start' alt='start'>" . $text['label-start'] . "</a>";
     }
 }
 echo "</td>\n";
 echo "\t<td valign='top' class='row_stylebg'>" . $row[service_description] . "&nbsp;</td>\n";
 echo "\t<td class='list_control_icons'>";
Ejemplo n.º 18
0
					<?php 
echo "<input height='14' title='Show Proxy settings page' name='scan' type='image' value='scan' src='./themes/" . $g['theme'] . "/images/icons/icon_service_start.gif' />";
?>
					&nbsp;Proxy Settings
				</a>
			</td>
			-->
		</tr>
		<tr>
			<td class="listlr">Antivirus Server ( <?php 
echo clamd_status();
?>
 )</td>
			<td class="listr"><center>
			<?php 
$running = (is_service_running("clamd", $ps) or is_process_running("clamd"));
if ($running) {
    echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\" alt=\"\" /> Running";
} else {
    echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\" alt=\"\" /> Stopped";
}
?>
			</td>
			<td class="listr">&nbsp;</td>
			<td class="listr">
			<?php 
echo exec("clamd -V");
?>
			</td>
			<!--
			<td class="listr">
// Initialize some common values from defined constants
$suricatadir = SURICATADIR;
$suricatalogdir = SURICATALOGDIR;
$flowbit_rules_file = FLOWBITS_FILENAME;
$suricata_enforcing_rules_file = SURICATA_ENFORCING_RULES_FILENAME;
$rcdir = RCFILEPREFIX;
// Hard kill any running Suricata process that may have been started by any
// of the pfSense scripts such as check_reload_status() or rc.start_packages
if (is_process_running("suricata")) {
    killbyname("suricata");
    sleep(2);
    // Delete any leftover suricata PID files in /var/run
    unlink_if_exists("{$g['varrun_path']}/suricata_*.pid");
}
// Hard kill any running Barnyard2 processes
if (is_process_running("barnyard")) {
    killbyname("barnyard2");
    sleep(2);
    // Delete any leftover barnyard2 PID files in /var/run
    unlink_if_exists("{$g['varrun_path']}/barnyard2_*.pid");
}
// Set flag for post-install in progress
$g['suricata_postinstall'] = true;
// Mount file system read/write so we can modify some files
conf_mount_rw();
// Remove any previously installed script since we rebuild it
unlink_if_exists("{$rcdir}suricata.sh");
// Create the top-tier log directory
safe_mkdir(SURICATALOGDIR);
// Create the IP Rep and SID Mods lists directory
safe_mkdir(SURICATA_SID_MODS_PATH);
     $local_fl = $mvMountedDest . $stream_name . '.flv';
 }
 print "looking at: {$local_fl} \n";
 clearstatcache();
 if (!is_file($local_fl)) {
     $doneWithTrascode = false;
     print "flv NOT found run trascode for: {$source_file}\n";
     //replace input:
     $current_encodeCMD = str_replace('$input', $mvMountedSource . $source_file, $flvEncodeCommand);
     //replace output
     $current_encodeCMD = str_replace('$output', $local_fl, $current_encodeCMD);
     print "\nrun:{$current_encodeCMD} \n\n";
     $pid = simple_run_background($current_encodeCMD);
     sleep(1);
     //give time for the proccess to start up
     while (is_process_running($pid)) {
         clearstatcache();
         print "running trascode: " . hr_bytes(filesize($local_fl)) . "\n";
         sleep(10);
     }
     //now it should be there
     if (is_file($local_fl)) {
         //flv is found
         print "flv found: " . $mvMountedDest . $stream_name . ".flv \n";
         //check for .meta
         if (!is_file($local_fl . META_DATA_EXT)) {
             echo "gennerating flv metadata for {$local_fl} \n";
             $flv = new MyFLV();
             try {
                 $flv->open($local_fl);
             } catch (Exception $e) {