Example #1
0
function core_function_link($function_name, $hostname, $service = '', $options = '')
{
    $core_commands = get_commands();
    $function_num = $core_commands['CMD_' . $function_name];
    $cmd = CORECMD . "cmd_typ={$function_num}&host={$hostname}";
    if (isset($service) && $service != '') {
        $cmd .= "&service={$service}";
    }
    if (isset($options) && $options != '') {
        $cmd .= $options;
    }
    return $cmd;
}
<?php

include 'inc/functions.php';
include_once "inc/header.php";
$commandArray = get_commands();
//DISPLAY ARRAYS
foreach ($commandArray as &$sysproc) {
    echo "{$sysproc->image} {$sysproc->commandline}";
    echo "<br><br>";
}
Example #3
0
function get_role_rights($role_id)
{
    $modules = get_modules();
    $module_rights = db::get_single_values_array("SELECT module_id FROM " . TABLE_ROLES_TO_MODULES . " WHERE role_id = " . $role_id);
    $submodule_rights = db::get_single_values_array("SELECT submodule_id FROM " . TABLE_ROLES_TO_SUBMODULES . " WHERE role_id = " . $role_id);
    $command_rights = db::get_single_values_array("SELECT command_id FROM " . TABLE_ROLES_TO_COMMANDS . " WHERE role_id = " . $role_id);
    $column_rights = db::get_single_values_array("SELECT column_id FROM " . TABLE_ROLES_TO_COLUMNS . " WHERE role_id = " . $role_id);
    $result = array();
    $result[] = '<table style="width: 100%;">';
    if (count($modules)) {
        foreach ($modules as $module_id => $module_name) {
            $result[] = '<tr style="background-color: #d3d3d3;">';
            $result[] = '<td style="width: 100px;">';
            $result[] = '<i>модуль</i>';
            $result[] = '</td>';
            $result[] = '<td colspan="100">';
            //      $result[] = '<div class="module">';
            $result[] = '<div class="module_name"><label for="module[' . $module_id . ']">' . $module_name . '</label></div>';
            $result[] = '<input type="checkbox" ' . (in_array($module_id, $module_rights) ? 'checked="checked"' : '') . ' name="module[' . $module_id . ']" class="module_checkbox" id="module[' . $module_id . ']">';
            $result[] = '</td>';
            //      $result[] = '<div class="clear"></div>';
            $result[] = '</tr>';
            $submodules = get_submodules($module_id);
            if (count($submodules)) {
                foreach ($submodules as $submodule_id => $submodule_name) {
                    $result[] = '<tr>';
                    $result[] = '<td>';
                    $result[] = '</td>';
                    $result[] = '<td style="width: 100px;">';
                    $result[] = '<i>подмодуль</i>';
                    $result[] = '</td>';
                    $result[] = '<td colspan="2">';
                    //          $result[] = '<div class="submodule">';
                    $result[] = '<div class="submodule_name"><label for="submodule[' . $submodule_id . ']">' . $submodule_name . '</label></div>';
                    $result[] = '<input type="checkbox" ' . (in_array($submodule_id, $submodule_rights) ? 'checked="checked"' : '') . ' name="submodule[' . $submodule_id . ']" class="submodule_checkbox" id="submodule[' . $submodule_id . ']">';
                    //          $result[] = '</div>';
                    $result[] = '</tr>';
                    $commands = get_commands($submodule_id);
                    if (count($commands)) {
                        $result[] = '<tr>';
                        $result[] = '<td>';
                        $result[] = '</td>';
                        $result[] = '<td>';
                        $result[] = '</td>';
                        $result[] = '<td style="width: 100px;">';
                        $result[] = '<i>команды</i>';
                        $result[] = '</td>';
                        $result[] = '<td>';
                        foreach ($commands as $command_id => $command_name) {
                            $result[] = '<div class="command_wrap">';
                            $result[] = '<div class="command_name"><label for="command[' . $command_id . ']">' . $command_name . '</label></div>';
                            $result[] = '<input type="checkbox" ' . (in_array($command_id, $command_rights) ? 'checked="checked"' : '') . ' name="command[' . $command_id . ']" class="command_checkbox" id="command[' . $command_id . ']">';
                            $result[] = '</div>';
                        }
                        $result[] = '</td>';
                        $result[] = '</tr>';
                    }
                    $columns = get_columns($submodule_id);
                    if (count($columns)) {
                        $result[] = '<tr style="background-color: lightCyan;">';
                        $result[] = '<td>';
                        $result[] = '</td>';
                        $result[] = '<td>';
                        $result[] = '</td>';
                        $result[] = '<td style="width: 100px;">';
                        $result[] = '<i>колонки</i>';
                        $result[] = '</td>';
                        $result[] = '<td>';
                        foreach ($columns as $column_id => $column_name) {
                            $result[] = '<div class="column_wrap">';
                            $result[] = '<div class="column_name"><label for="column[' . $column_id . ']">' . $column_name . '</label></div>';
                            $result[] = '<input type="checkbox" ' . (in_array($column_id, $column_rights) ? 'checked="checked"' : '') . ' name="column[' . $column_id . ']" class="column_checkbox" id="column[' . $column_id . ']">';
                            $result[] = '</div>';
                        }
                        $result[] = '</td>';
                        $result[] = '</tr>';
                    }
                    $result[] = '</td>';
                }
                //        $result[] = '</tr>';
            }
            //      $result[] = '</div>';
            //      $result[] = '</tr>';
            //      $result[] = '<div class="clear"></div>';
        }
    }
    $result[] = '</table>';
    return join($result, "\n");
}
/**
 * 
 * @param unknown $infos
 * @return string error
 */
function create_cert($infos, $renew = FALSE)
{
    echo PHP_EOL;
    echo '-----------------------------------------------------' . PHP_EOL;
    echo "DATE = " . date(DateTime::COOKIE) . PHP_EOL;
    echo 'begining of treatment.' . PHP_EOL;
    echo PHP_EOL;
    verify_parameters($infos);
    //  generate commands
    $commands = get_commands($infos, $renew);
    // 	echo "<pre>"; print_r($commands); echo "/<pre>"; return;
    $error_buffer = '';
    //  let's encrypt command execution
    echo 'let\'s encrypt command : ' . PHP_EOL;
    echo $commands['le_command'] . PHP_EOL;
    exec($commands['le_command'], $output, $return_var);
    if ($return_var !== 0) {
        foreach ($output as $o) {
            echo $o . PHP_EOL;
            $error_buffer .= $o . PHP_EOL;
        }
        echo 'RETURN = ' . $return_var . PHP_EOL;
        $error_buffer .= 'RETURN = ' . $return_var . PHP_EOL;
        return $error_buffer;
    }
    //  let's encrypt command execution
    echo 'clean command : ' . PHP_EOL;
    echo $commands['clean_command'] . PHP_EOL;
    exec($commands['clean_command'], $output, $return_var);
    if ($return_var !== 0) {
        foreach ($output as $o) {
            echo $o . PHP_EOL;
            $error_buffer .= $o . PHP_EOL;
        }
        echo 'RETURN = ' . $return_var . PHP_EOL;
        $error_buffer .= 'RETURN = ' . $return_var . PHP_EOL;
        return $error_buffer;
    }
    //  nginx config file writing
    echo 'nginx config : ' . PHP_EOL;
    echo $commands['ng_conf'] . PHP_EOL;
    echo 'nginx config file : ' . PHP_EOL;
    echo $commands['ng_conf_file'] . PHP_EOL;
    $return_var = file_put_contents($commands['ng_conf_file'], $commands['ng_conf']);
    if ($return_var === FALSE) {
        echo 'RETURN = ' . $return_var . PHP_EOL;
        $error_buffer .= 'RETURN = ' . $return_var . PHP_EOL;
        return $error_buffer;
    } else {
        echo 'config file written.' . PHP_EOL;
    }
    //  nginx config enabling
    echo 'nginx config enable : ' . PHP_EOL;
    foreach ($commands['ng_conf_enable'] as $command) {
        echo $command . PHP_EOL;
    }
    echo PHP_EOL;
    foreach ($commands['ng_conf_enable'] as $command) {
        exec($command, $output, $return_var);
        if ($return_var !== 0) {
            foreach ($output as $o) {
                echo $o . PHP_EOL;
                $error_buffer .= $o . PHP_EOL;
            }
            echo 'RETURN = ' . $return_var . PHP_EOL;
            $error_buffer .= 'RETURN = ' . $return_var . PHP_EOL;
            return $error_buffer;
        }
    }
    //  nginx config reload
    echo 'nginx config reload : ' . PHP_EOL;
    echo $commands['ng_conf_activation'] . PHP_EOL;
    exec($commands['ng_conf_activation'], $output, $return_var);
    if ($return_var !== 0) {
        foreach ($output as $o) {
            echo $o . PHP_EOL;
            $error_buffer .= $o . PHP_EOL;
        }
        echo 'RETURN = ' . $return_var . PHP_EOL;
        $error_buffer .= 'RETURN = ' . $return_var . PHP_EOL;
        return $error_buffer;
    }
    echo PHP_EOL;
    echo 'end of treatment.' . PHP_EOL;
    echo "DATE = " . date(DateTime::COOKIE) . PHP_EOL;
    echo '-----------------------------------------------------' . PHP_EOL;
    echo PHP_EOL;
    return NULL;
}