Esempio n. 1
0
function initial()
{
    global $status, $debug, $log, $function_name, $argv;
    // first parse the pmc.ini
    $ini = parse_ini_file("pmc.ini");
    // Set variable
    $status = $ini["Status"];
    $debug = $ini["Debug"];
    $log = $ini["Log"];
    // Debug_mode
    service_debug();
    // checking...
    service_status();
    // log...
    service_log();
    // parse URL into Params
    parse_param();
    // include module
    include_module();
    // call module function
    if ($function_name != NULL) {
        if ($debug == 1) {
            echo "use function " . $function_name . ".<br>";
        }
        if ($argv == NULL) {
            $function_name();
        } else {
            $function_name($argv);
        }
    }
}
Esempio n. 2
0
<?php

include_once dirname(__FILE__) . "/frame.class.inc";
include_once dirname(__FILE__) . "/class.unix.inc";
include_once dirname(__FILE__) . "/class.hd.inc";
include_once dirname(__FILE__) . "/class.postfix.inc";
if (isset($_GET["service-status"])) {
    service_status();
    exit;
}
if (isset($_GET["install-tgz"])) {
    install_tgz();
    exit;
}
if (isset($_GET["is-installed"])) {
    is_installed();
    exit;
}
if (isset($_GET["install"])) {
    install();
    exit;
}
if (isset($_GET["installv1"])) {
    installv1();
    exit;
}
if (isset($_GET["InfluxDBPassword"])) {
    InfluxDBPassword();
    exit;
}
if (isset($_GET["backup"])) {
        ynh_setting_set('opt_chat', isset($_POST['opt_chat']) ? 1 : 0);
        ynh_setting_set('wifi_device_id', $_POST['wifi_device_id']);
        $retcode = start_service();
        if ($retcode == 0) {
            flash('success', _('Configuration updated and service successfully reloaded'));
        } else {
            flash('error', _('Configuration updated but service reload failed'));
        }
    } else {
        flash('success', _('Service successfully disabled'));
    }
    redirect:
    redirect_to('/');
});
dispatch('/status', function () {
    $status_lines = service_status();
    $status_list = '';
    foreach ($status_lines as $status_line) {
        if (preg_match('/^\\[INFO\\]/', $status_line)) {
            $status_list .= '<li class="status-info">' . htmlspecialchars($status_line) . '</li>';
        } elseif (preg_match('/^\\[OK\\]/', $status_line)) {
            $status_list .= '<li class="status-success">' . htmlspecialchars($status_line) . '</li>';
        } elseif (preg_match('/^\\[WARN\\]/', $status_line)) {
            $status_list .= '<li class="status-warning">' . htmlspecialchars($status_line) . '</li>';
        } elseif (preg_match('/^\\[ERR\\]/', $status_line)) {
            $status_list .= '<li class="status-danger">' . htmlspecialchars($status_line) . '</li>';
        }
    }
    echo $status_list;
});
dispatch('/lang/:locale', function ($locale = 'en') {
Esempio n. 4
0
	include_once('ressources/class.templates.inc');
	include_once('ressources/class.ldap.inc');
	include_once('ressources/class.users.menus.inc');
	include_once('ressources/class.squid.inc');
	include_once('ressources/class.ActiveDirectory.inc');
	include_once('ressources/class.compile.ufdbguard.inc');
	
	
$usersmenus=new usersMenus();
if(!$usersmenus->AsDansGuardianAdministrator){
	$tpl=new templates();
	$alert=$tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}');
	echo "alert('$alert');";
	die();	
}
	if(isset($_GET["service-status"])){service_status();exit;}
	if(isset($_GET["main"])){main();exit;}
	if(isset($_POST["EnableGoogleSafeSearch"])){EnableGoogleSafeSearch_save();exit;}
	if(isset($_POST["EnableGoogleSafeBrowsing"])){EnableGoogleSafeBrowsing_save();exit;}
	if(isset($_GET["GoogleSafeBrowsingApiKey-js"])){GoogleSafeBrowsingApiKey_js();exit;}
	if(isset($_GET["GoogleSafeBrowsingApiKey-popup"])){GoogleSafeBrowsingApiKey_popup();exit;}
	if(isset($_POST["GoogleSafeBrowsingApiKey"])){GoogleSafeBrowsingApiKey_save();exit;}
page();


function service_cmds_js(){
	$page=CurrentPageName();
	$tpl=new templates();
	$cmd=$_GET["service-cmds"];
	$mailman=$tpl->_ENGINE_parse_body("{APP_UFDBGUARD}");
	$html="YahooWin4('650','$page?service-cmds-popup=$cmd','$mailman::$cmd');";
Esempio n. 5
0
	include_once('ressources/class.users.menus.inc');
	
	
	
	if(posix_getuid()==0){die();}
	
	$user=new usersMenus();
	if($user->AsSystemAdministrator==false){
		$tpl=new templates();
		echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
		die();exit();
	}
	
	if(isset($_GET["popup"])){popup();exit;}
	if(isset($_GET["status"])){status();exit;}
	if(isset($_GET["kav4fs-status"])){service_status();exit;}
	if(isset($_GET["license"])){popup_license();exit;}
	if(isset($_GET["InstallLicenseFile"])){license_add();exit;}
	if(isset($_GET["update"])){update();exit;}
			
	js();
	
	
function js(){

	$tpl=new templates();
	$title=$tpl->_ENGINE_parse_body("{APP_KAV4FS}");
	$page=CurrentPageName();
	
	$html="
		function kav4fs_start(){
function show_page()
{
    global $gearmanxi_cfg;
    global $errors;
    $make_worker_html = true;
    // make the apache_safe_dir if we need to
    if (!file_exists($gearmanxi_cfg["apache_safe_dir"])) {
        if (!mkdir($gearmanxi_cfg["apache_safe_dir"], 0777, true)) {
            $errors[] .= "Unable to create apache safe directory: " . $gearmanxi_cfg["apache_safe_dir"];
        }
    }
    // rudimentary check to see if user has set up the config array
    if (!empty($gearmanxi_cfg["worker"]["example1"]) && !empty($gearmanxi_cfg["worker"]["example2.fqdn.com"])) {
        $errors[] = "It looks like you haven't set up the configuration array in " . dirname(__FILE__) . "/modgearmanxi.config.inc.php";
        $make_worker_html = false;
    }
    do_page_start(array("page_title" => "ModGearman XI Manager"), true);
    echo "<h1>ModGearman XI Manager</h1>";
    show_errors($errors);
    // build the correlating list of tabs and div content for that div - all while building a portion of the overview status table
    $worker_tabs = "";
    $worker_divs = "";
    $overview_status_table = "<table class='infotable table table-condensed table-bordered' style='width: 60%;'>";
    if ($make_worker_html) {
        foreach ($gearmanxi_cfg["worker"] as $worker_name => $worker) {
            $worker_id = base64_encode($worker_name);
            // build the tabs section
            $worker_tabs .= "<li><a href='#{$worker_name}' title='{$worker_name}'><span>{$worker_name}</span></a></li>\n";
            // get the info we need to build the rest of the html
            $worker_can_connect = test_ssh_connectivity($worker["user"], $worker["ip"]);
            $worker_gearman_cfg_readable = test_cfg_writable($worker["user"], $worker["ip"], $worker["cfg"]);
            $worker_gearman_cfg_writable = test_cfg_writable($worker["user"], $worker["ip"], $worker["cfg"]);
            $worker_gearman_dir_writable = test_dir_writable($worker["user"], $worker["ip"], dirname($worker["cfg"]));
            // copy the remote file so we can edit it if we need to
            $worker_local_conf = local_copy_cfg($worker["user"], $worker["ip"], $worker["cfg"]);
            $worker_copy_conf_successful = scp_remote_file($worker["user"], $worker["ip"], $worker["cfg"], $worker_local_conf);
            // service control stuff
            $worker_gearman_running = service_status($worker["user"], $worker["ip"], $worker["initd"], $worker_gearman_running_text);
            $action_value = "Restart Worker";
            $stop_button = "<input type='submit' name='cmd' value='Stop Worker' style='margin-left: 5px;' />";
            if ($worker_gearman_running == false) {
                $stop_button = "";
                if (strpos($worker_gearman_running_text, "is not running") !== false) {
                    $action_value = "Start Worker";
                } else {
                    $action_value = "Attempt to Start Worker";
                }
            }
            // build this workers div
            $worker_divs .= "<div id='{$worker_name}' style='width: 60%;'>" . "<form method='post'>" . "<input type='hidden' name='worker_id' value='{$worker_id}' />" . "<table class='infotable table table-condensed table-striped table-bordered'>" . "<tr><td>Username:</td><td>" . $worker["user"] . "</td></tr>" . "<tr><td>IP Address:</td><td>" . $worker["ip"] . "</td></tr>" . "<tr><td>Configuration File:</td><td>" . $worker["cfg"] . "</td></tr>" . "<tr><td>Service Control:</td><td>" . $worker["initd"] . "</td></tr>" . "</table>" . worker_status_table("infotable table table-condensed table-striped table-bordered", $worker_can_connect, $worker_gearman_cfg_readable, $worker_gearman_cfg_writable, $worker_gearman_dir_writable, $worker_gearman_running, $worker_gearman_running_text) . "<input type='submit' name='cmd' value='{$action_value}' />" . $stop_button . "<input type='submit' name='cmd' value='Update Configuration' style='float: right;' />" . "<textarea name='conf' rows='24' style='width: 100%; margin-top: 5px;'>" . file_get_contents($worker_local_conf) . "</textarea>" . "</form>" . "</div>";
            // build the status table for overview
            $overview_status_table .= "<tr>" . "<td><strong>{$worker_name}</strong>&nbsp;" . $worker["user"] . "@" . $worker["ip"] . ":" . $worker["cfg"] . " (" . $worker["initd"] . ")</td>" . "</tr><tr>" . "<td align='right'>" . worker_status_table("infotable table table-condensed table-striped table-bordered", $worker_can_connect, $worker_gearman_cfg_readable, $worker_gearman_cfg_writable, $worker_gearman_dir_writable, $worker_gearman_running, $worker_gearman_running_text) . "<form method='post'>" . "<input type='hidden' name='worker_id' value='{$worker_id}' />" . "<div style='float: right; display: inline-block; margin-top: 5px;'>" . "<input type='submit' name='cmd' value='{$action_value}' />" . $stop_button . "</div>" . "</form>" . "</td>" . "</tr>";
        }
    }
    $overview_status_table .= "</table>";
    ?>
  <script>
  $(function () {
    $("#tabs").tabs().show();
  });
  window.setInterval(function() {
    $.ajax("modgearmanxi.php?cmd=top&ver=<?php 
    echo $gearmanxi_cfg["mod_gearman_version"];
    ?>
").done(function(html) {
      $("#gearman_top").empty().append(html);
    });
  }, 1000);
  </script>
  <p>Manage all of your remote ModGearman Workers from a central location!</p>
  <p>In order to make full use of this component, you'll need to make sure that 
     this servers apache user can connect remotely - without password authentication -
     to each of the worker servers you want to manage. The user that you connect as to 
     each of those servers needs to have read/write access to the configuration 
     files listed in modgearmanxi.config.inc.php.</p>
  <p>There is a script that you can run (it isn't necessary as long as you've met the 
     previous listed requirements) to make all that easier. Its located at 
  <strong style="font-family: courier;"><?php 
    echo dirname(__FILE__) . "/setup.sh";
    ?>
</strong>.</p>
  <div id="tabs" class="hide">
  <ul class="tabnavigation">
  <li><a href="#overview" title="Overview"><span>Overview</span></a></li>
  <?php 
    echo $worker_tabs;
    ?>
  </ul>
  <div id="overview" class="ui-tabs-hide">
  <h5 class="ul">gearman_top Output</h5>
  <div id="gearman_top" style="display: inline-block;"></div>
  <h5 class="ul">ModGearman Workers</h5>
  <?php 
    echo $overview_status_table;
    ?>
  </div>
  <?php 
    echo $worker_divs;
    ?>
  </div>
  <?php 
}