Example #1
0
                echo '<table border="0" cellspacing="1" cellpadding="3">';
                foreach ($serv_s as $s) {
                    echo '<tr><td><strong>(' . $s->getAttribute('type') . ')</strong></td><td><a href="servers.php?action=manage&fqdn=' . $s->fqdn . '">' . $s->fqdn . '</a></td></tr>';
                }
                echo '</table>';
            }
            echo '</td>';
            echo '</tr>';
            $count++;
        }
        echo '</tbody>';
        echo '</table>';
    }
}
echo '<h2>' . _('List of servers') . '</h2>';
$servs_all = Abstract_Server::load_all();
if (is_null($servs_all)) {
    echo _('No server available') . '<br />';
} else {
    if (count($servs_all) == 0) {
        echo _('No server available') . '<br />';
    } else {
        ?>
		<table id="servers_table" class="main_sub sortable" border="0" cellspacing="1" cellpadding="3">
		<thead>
		<tr class="title">
			<th><?php 
        echo _('FQDN');
        ?>
</th>
			<th><?php 
Example #2
0
function show_all($flags_)
{
    $logfiles = glob(SESSIONMANAGER_LOGS . '/*.log');
    $logfiles = array_reverse($logfiles);
    $display = array();
    foreach ($logfiles as $logfile) {
        $lines = get_lines_from_file($logfile, 20, $flags_);
        $display[basename($logfile)] = $lines;
    }
    $servers = Abstract_Server::load_all();
    $display2 = array();
    foreach ($servers as $server) {
        $buf = new Server_Logs($server);
        $buf->process();
        $lines = $buf->getLog(20);
        if ($lines !== false) {
            $display2[$server->getAttribute('fqdn')] = array();
        }
        if ($lines !== false) {
            $display2[$server->getAttribute('fqdn')]['web'] = get_lines_from_string($lines, 20, $flags_);
        }
    }
    page_header();
    echo '<h1>' . _('Logs') . '</h1>';
    echo '<div>';
    echo '<div class="section">';
    echo '<h1>' . _('Session Manager') . '</h1>';
    foreach ($display as $name => $lines) {
        echo '<h3>' . $name;
        echo ' <a href="?show=1&amp;where=sm&amp;name=' . $name . '"><img src="media/image/view.png" width="22" height="22" alt="view" onmouseover="showInfoBulle(\'' . _('View full log file online') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>';
        echo ' <a href="?download=1&amp;where=sm&amp;name=' . $name . '"><img src="media/image/download.png" width="22" height="22" alt="download" onmouseover="showInfoBulle(\'' . _('Download full log file') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>';
        echo '</h3>';
        echo '<div style="border: 1px solid #ccc; background: #fff; padding: 5px; text-align: left;" class="section">';
        echo implode("<br />\n", $lines);
        echo '</div>';
    }
    echo '</div>';
    echo '<div class="section">';
    echo '<h1>' . _('Slave Servers') . '</h1>';
    foreach ($display2 as $fqdn => $logs) {
        $server = Abstract_Server::load($fqdn);
        echo '<h2><img src="media/image/server-' . $server->stringType() . '.png" alt="' . $server->stringType() . '" title="' . $server->stringType() . '" /> <a href="servers.php?action=manage&amp;fqdn=' . $fqdn . '">' . $fqdn . '</a></h2>';
        echo '<div class="section">';
        echo '<h4>' . _('Log');
        echo ' <a href="?show=1&amp;where=aps&amp;server=' . $fqdn . '"><img src="media/image/view.png" width="22" height="22" alt="view" onmouseover="showInfoBulle(\'' . _('View full log file online') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>';
        echo ' <a href="?download=1&amp;where=aps&amp;server=' . $fqdn . '"><img src="media/image/download.png" width="22" height="22" alt="download" onmouseover="showInfoBulle(\'' . _('Download full log file') . '\'); return false;" onmouseout="hideInfoBulle(); return false;" /></a>';
        echo '</h4>';
        echo '<div style="border: 1px solid #ccc; background: #fff; padding: 5px; text-align: left;" class="section">';
        echo implode("<br />\n", $logs['web']);
        echo '</div>';
        echo '</div>';
    }
    echo '</div>';
    echo '</div>';
    page_footer();
    die;
}
Example #3
0
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
require_once dirname(__FILE__) . '/../admin/includes/core-minimal.inc.php';
if (Preferences::fileExists() === false) {
    exit(1);
}
//BEGIN Updating logs cache
$servers = Abstract_Server::load_all();
foreach ($servers as $server) {
    $buf = new Server_Logs($server);
    $buf->process();
}
//END Updating logs cache
//BEGIN UserGroupDBDynamic_cached update
if (Preferences::moduleIsEnabled('UserGroupDBDynamicCached')) {
    $ugdbdc = UserGroupDBDynamicCached::getInstance();
    $groups = $ugdbdc->getList();
    if (!is_array($groups)) {
        Logger::error('main', '(hourly cron) UserGroupDBDynamic_cached->getList() failed');
    } else {
        foreach ($groups as $a_group) {
            $ret = $ugdbdc->updateCache($a_group);
            if ($ret !== true) {
Example #4
0
 public function log_preview()
 {
     $this->check_authorized('viewStatus');
     $logfiles = glob(SESSIONMANAGER_LOGS . '/*.log');
     $logfiles = array_reverse($logfiles);
     $ret = array();
     foreach ($logfiles as $logfile) {
         $obj = new FileTailer($logfile);
         $lines = $obj->tail(20);
         $ret[basename($logfile)] = $lines;
     }
     $servers = Abstract_Server::load_all();
     $ret['servers'] = array();
     foreach ($servers as $server) {
         $buf = new Server_Logs($server);
         $buf->process();
         $lines = $buf->getLog(20);
         if ($lines !== false) {
             $ret['servers'][$server->id] = explode("\n", $lines);
         }
     }
     return $ret;
 }
Example #5
0
 public static function load_registered($registered_ = true)
 {
     $servers = Abstract_Server::load_all();
     foreach ($servers as $k => $server) {
         if (!$server->getAttribute('registered') && $registered_ === true) {
             unset($servers[$k]);
         } elseif ($server->getAttribute('registered') && $registered_ === false) {
             unset($servers[$k]);
         }
     }
     return $servers;
 }
Example #6
0
function show_manage($id, $applicationDB)
{
    $applicationsGroupDB = ApplicationsGroupDB::getInstance();
    $app = $applicationDB->import($id);
    if (!is_object($app)) {
        return false;
    }
    //     die_error('Unable to import application "'.$id.'"',__FILE__,__LINE__);
    if ($app->getAttribute('static')) {
        redirect('applications_static.php?action=manage&id=' . $app->getAttribute('id'));
    }
    $is_rw = $applicationDB->isWriteable();
    if ($app->getAttribute('published')) {
        $status = '<span class="msg_ok">' . _('Available') . '</span>';
        $status_change = _('Block');
        $status_change_value = 0;
    } else {
        $status = '<span class="msg_error">' . _('Blocked') . '</span>';
        $status_change = _('Unblock');
        $status_change_value = 1;
    }
    // Tasks
    $tm = new Tasks_Manager();
    $tm->load_from_application($id);
    $tm->refresh_all();
    $servers_in_install = array();
    $servers_in_remove = array();
    $tasks = array();
    foreach ($tm->tasks as $task) {
        if ($task->succeed()) {
            continue;
        }
        if ($task->failed()) {
            continue;
        }
        $tasks[] = $task;
        if (get_class($task) == 'Task_install') {
            if (!in_array($task->server, $servers_in_install)) {
                $servers_in_install[] = $task->server;
            }
        }
        if (get_class($task) == 'Task_remove') {
            if (!in_array($task->server, $servers_in_remove)) {
                $servers_in_remove[] = $task->server;
            }
        }
    }
    // Servers
    if ($app->getAttribute('static')) {
        $servers_all = array();
    } else {
        $servers_all = Abstract_Server::load_all();
    }
    $liaisons = Abstract_Liaison::load('ApplicationServer', $app->getAttribute('id'), NULL);
    $servers_id = array();
    foreach ($liaisons as $liaison) {
        $servers_id[] = $liaison->group;
    }
    $servers = array();
    $servers_available = array();
    foreach ($servers_all as $server) {
        if (in_array($server->fqdn, $servers_id)) {
            $servers[] = $server;
        } elseif (in_array($server->fqdn, $servers_in_install)) {
            continue;
        } elseif (!$server->isOnline()) {
            continue;
        } elseif ($server->type != $app->getAttribute('type')) {
            continue;
        } elseif (is_array($server->roles) && array_key_exists(Server::SERVER_ROLE_APS, $server->roles)) {
            $servers_available[] = $server;
        }
    }
    // App groups
    $appgroups = $applicationsGroupDB->getList(true);
    $groups_id = array();
    $liaisons = Abstract_Liaison::load('AppsGroup', $app->getAttribute('id'), NULL);
    foreach ($liaisons as $liaison) {
        $groups_id[] = $liaison->group;
    }
    $groups = array();
    $groups_available = array();
    foreach ($appgroups as $group) {
        if (in_array($group->id, $groups_id)) {
            $groups[] = $group;
        } else {
            $groups_available[] = $group;
        }
    }
    $can_manage_server = isAuthorized('manageServers');
    $can_manage_applicationsgroups = isAuthorized('manageApplicationsGroups');
    page_header();
    echo '<div>';
    echo '<h1><img src="media/image/cache.php?id=' . $app->getAttribute('id') . '" alt="" title="" /> ' . $app->getAttribute('name') . '</h1>';
    echo '<table class="main_sub" border="0" cellspacing="1" cellpadding="3">';
    echo '<tr class="title">';
    echo '<th>' . _('Package') . '</th>';
    echo '<th>' . _('Type') . '</th>';
    //   echo '<th>'._('Status').'</th>';
    echo '<th>' . _('Description') . '</th>';
    echo '<th>' . _('Executable') . '</th>';
    echo '</tr>';
    echo '<tr class="content1">';
    echo '<td>' . $app->getAttribute('package') . '</td>';
    echo '<td style="text-align: center;"><img src="media/image/server-' . $app->getAttribute('type') . '.png" alt="' . $app->getAttribute('type') . '" title="' . $app->getAttribute('type') . '" /><br />' . $app->getAttribute('type') . '</td>';
    //   echo '<td>'.$status.'</td>';
    echo '<td>' . $app->getAttribute('description') . '</td>';
    echo '<td>' . $app->getAttribute('executable_path') . '</td>';
    echo '</tr>';
    echo '</table>';
    echo '<br />';
    echo '<table border="0" cellspacing="0" cellpadding="0">';
    echo '<tr><td>';
    echo '<form action="applications.php" method="get"">';
    echo '<input type="hidden" name="action" value="icon" />';
    echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
    echo '<input type="submit" value="' . _('Set custom icon') . '"/>';
    echo '</form>';
    echo '</td><td style="width: 10px;"></td><td>';
    echo '<form action="actions.php" method="post"">';
    echo '<input type="hidden" name="name" value="Application" />';
    echo '<input type="hidden" name="action" value="clone" />';
    echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
    echo '<input type="submit" value="' . _('Clone to static application') . '"/>';
    echo '</form>';
    echo '</td></tr>';
    echo '</table>';
    echo '<br />';
    // orphan part
    if ($app->isOrphan() && !$app->getAttribute('static')) {
        echo '<br />';
        echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to remove this application?') . '\');">';
        echo '<input type="hidden" name="action" value="del" />';
        echo '<input type="hidden" name="name" value="Application" />';
        echo '<input type="hidden" name="id" value="' . $app->getAttribute('id') . '" />';
        echo _('This application is orphan') . ' <input type="submit" value="' . _('Remove this application') . '"/>';
        echo '</form>';
        echo '<br />';
    }
    //   if ($is_rw) {
    //     echo '<h2>'._('Settings').'</h2>';
    //
    //     echo '<form action="" method="post">';
    //     echo '<input type="hidden" name="action" value="modify" />';
    //     echo '<input type="hidden" name="id" value="'.$app->getAttribute('id').'" />';
    //     echo '<input type="hidden" name="published" value="'.$status_change_value.'" />';
    //     echo '<input type="submit" value="'.$status_change.'"/>';
    //     echo '</form>';
    //   }
    // Server part
    if (count($servers) + count($servers_in_install) + count($servers_available) > 0) {
        echo '<div>';
        echo '<h2>' . _('Servers with this application') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($servers as $server) {
            $remove_in_progress = in_array($server->fqdn, $servers_in_remove);
            echo '<tr><td>';
            echo '<a href="servers.php?action=manage&fqdn=' . $server->fqdn . '">' . $server->fqdn . '</a>';
            echo '</td>';
            echo '<td>';
            if ($remove_in_progress) {
                echo 'remove in progress';
            } elseif ($server->isOnline() and $can_manage_server and $app->getAttribute('type') == 'linux' and $app->hasAttribute('package') and $app->getAttribute('package') !== '') {
                echo '<form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to remove this application from this server?') . '\');">';
                echo '<input type="hidden" name="action" value="del" />';
                echo '<input type="hidden" name="name" value="Application_Server" />';
                echo '<input type="hidden" name="application" value="' . $id . '" />';
                echo '<input type="hidden" name="server" value="' . $server->fqdn . '" />';
                echo '<input type="submit" value="' . _('Remove from this server') . '"/>';
                echo '</form>';
            }
            echo '</td>';
            echo '</tr>';
        }
        foreach ($servers_in_install as $server) {
            echo '<tr><td>';
            echo '<a href="servers.php?action=manage&fqdn=' . $server . '">' . $server . '</a>';
            echo '</td>';
            echo '<td>install in progress</td>';
            echo '</tr>';
        }
        if (count($servers_available) > 0 and $can_manage_server and $app->getAttribute('type') == 'linux' and $app->hasAttribute('package') and $app->getAttribute('package') !== '') {
            $display_list = false;
            foreach ($servers_available as $server) {
                if ($server->hasAttribute('ulteo_system') && $server->getAttribute('ulteo_system') == 1) {
                    $display_list = true;
                    break;
                }
            }
            if ($display_list) {
                echo '<tr>';
                echo '<form action="actions.php" method="post"><td>';
                echo '<input type="hidden" name="name" value="Application_Server" />';
                echo '<input type="hidden" name="action" value="add" />';
                echo '<input type="hidden" name="application" value="' . $id . '" />';
                echo '<select name="server">';
                foreach ($servers_available as $server) {
                    if ($server->hasAttribute('ulteo_system') && $server->getAttribute('ulteo_system') == 1) {
                        echo '<option value="' . $server->fqdn . '">' . $server->fqdn . '</option>';
                    }
                }
                echo '</select>';
                echo '</td><td><input type="submit" value="' . _('Install on this server') . '" /></td>';
                echo '</form>';
                echo '</tr>';
            }
        }
        echo '</table>';
        echo "<div>\n";
    }
    if (count($tasks) > 0) {
        echo '<h2>' . _('Active tasks on this application') . '</h1>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        echo '<tr class="title">';
        echo '<th>' . _('ID') . '</th>';
        echo '<th>' . _('Type') . '</th>';
        echo '<th>' . _('Status') . '</th>';
        echo '<th>' . _('Details') . '</th>';
        echo '</tr>';
        $count = 0;
        foreach ($tasks as $task) {
            $content = 'content' . ($count++ % 2 == 0 ? 1 : 2);
            if ($task->failed()) {
                $status = '<span class="msg_error">' . _('Error') . '</span>';
            } else {
                $status = '<span class="msg_ok">' . $task->status . '</span>';
            }
            echo '<tr class="' . $content . '">';
            echo '<td><a href="tasks.php?action=manage&id=' . $task->id . '">' . $task->id . '</a></td>';
            echo '<td>' . get_class($task) . '</td>';
            echo '<td>' . $status . '</td>';
            echo '<td>' . $task->server . ', ' . $task->getRequest() . ', ' . $task->status_code . '</td>';
            echo '</tr>';
        }
        echo '</table>';
        echo "<div>\n";
    }
    if (count($appgroups) > 0) {
        echo '<div>';
        echo '<h2>' . _('Groups with this application') . '</h2>';
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($groups as $group) {
            echo '<tr>';
            echo '<td>';
            echo '<a href="appsgroup.php?action=manage&id=' . $group->id . '">' . $group->name . '</a>';
            echo '</td>';
            if ($can_manage_applicationsgroups) {
                echo '<td><form action="actions.php" method="post" onsubmit="return confirm(\'' . _('Are you sure you want to delete this application from this group?') . '\');">';
                echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
                echo '<input type="hidden" name="action" value="del" />';
                echo '<input type="hidden" name="element" value="' . $id . '" />';
                echo '<input type="hidden" name="group" value="' . $group->id . '" />';
                echo '<input type="submit" value="' . _('Delete from this group') . '" />';
                echo '</form></td>';
            }
            echo '</tr>';
        }
        if (count($groups_available) > 0 and $can_manage_applicationsgroups) {
            echo '<tr>';
            echo '<form action="actions.php" method="post"><td>';
            echo '<input type="hidden" name="name" value="Application_ApplicationGroup" />';
            echo '<input type="hidden" name="action" value="add" />';
            echo '<input type="hidden" name="element" value="' . $id . '" />';
            echo '<select name="group">';
            foreach ($groups_available as $group) {
                echo '<option value="' . $group->id . '">' . $group->name . '</option>';
            }
            echo '</select>';
            echo '</td><td><input type="submit" value="' . _('Add to this group') . '" /></td>';
            echo '</form>';
            echo '</tr>';
        }
        echo '</table>';
        echo "<div>\n";
    }
    // Mime-Type part
    echo '<div>';
    echo '<h2>' . _('Mime-Types') . '</h2>';
    echo '<div>';
    if (count($app->getMimeTypes()) == 0) {
        echo _('No available mimes-type') . '<br />';
    } else {
        echo '<table border="0" cellspacing="1" cellpadding="3">';
        foreach ($app->getMimeTypes() as $mime) {
            echo '<tr><td>';
            echo '<a href="mimetypes.php?action=manage&id=' . urlencode($mime) . '">' . $mime . '</a>';
            echo '</td></tr>';
        }
        echo '</table>';
    }
    echo '</div>';
    echo '</div>';
    // mime div
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
    page_footer();
    die;
}