Exemplo n.º 1
0
/**
 * Get list of pages that user can access
 * 
 * IS THE SAME FUNCTION OF USERS LIBRARY !!!!
 */
function sumo_get_user_accesspoints($id = NULL, $html = FALSE)
{
    if ($id) {
        global $SUMO, $language;
        $user_data = sumo_get_user_info($id, 'id', FALSE);
        $num_groups = count($user_data['group']);
        $group_query = '';
        if (!in_array('sumo', $user_data['group'])) {
            $group_query = " WHERE ";
            for ($g = 0; $g < $num_groups; $g++) {
                $group_query .= "usergroup='" . $user_data['group'][$g] . "' OR \n\t\t\t\t\t\t\t     usergroup LIKE '" . $user_data['group'][$g] . ";%' OR\n\t\t\t\t\t\t\t     usergroup LIKE '%;" . $user_data['group'][$g] . ";%'";
                if ($g < $num_groups - 1) {
                    $group_query .= " OR ";
                }
            }
        }
        $query = "SELECT * FROM " . SUMO_TABLE_ACCESSPOINTS . " \n\t\t\t\t " . $group_query . " \n\t\t\t\t  ORDER BY name";
        $rs = $SUMO['DB']->Execute($query);
        $ap = array();
        while ($tab = $rs->FetchRow()) {
            $ap[] = $tab;
        }
        // html output
        if ($html) {
            if (in_array('sumo', $user_data['group'])) {
                return $language['AllAccessPoints'];
            }
            $list = '';
            $num_ap = count($ap);
            if ($num_ap > 0) {
                $list = "<table cellspacing='0' class='tab'>\n" . " <tr>\n" . "  <td class='tab-title'>" . $language['Page'] . "</td>\n" . "  <td class='tab-title'>" . $language['Path'] . "</td>\n" . " </tr>\n";
                for ($p = 0; $p < $num_ap; $p++) {
                    $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
                    // Format group string to display it
                    $group = preg_replace("/sumo:7/", "<b><font color='#BB0000'>sumo:7</font></b>", $ap[$p]['usergroup']);
                    $group = preg_replace("/sumo:/", "<font color='#BB0000'>sumo</font>:", $group);
                    $group = str_replace(';', '; ', $group);
                    $group = strlen(strip_tags($group)) > 50 ? substr($group, 0, 50) . '...' : $group;
                    // Format path string to display it
                    $path = strlen($ap[$p]['path']) > 50 ? substr($ap[$p]['path'], 0, 50) . '...' : $ap[$p]['path'];
                    $path = "<a href='" . $ap[$p]['path'] . "' target='_blank'>" . $path . "</a>";
                    $name = sumo_get_accesspoint_name($ap[$p]['name'], $_COOKIE['language']);
                    $list .= "<tr>\n" . " <td class='" . $style . "'>" . $name . "</td>\n" . " <td class='" . $style . "'>" . $path . "</td>\n" . "</tr>\n";
                }
                $list .= "</table>";
            }
            $ap = $list;
        }
        return $ap;
    } else {
        return FALSE;
    }
}
Exemplo n.º 2
0
$rs = $SUMO['DB']->Execute($query1);
$tot = $rs->PO_RecordCount();
$rs = $SUMO['DB']->SelectLimit($query2, $_SESSION['rows_relationship_group2accesspoints'], $_SESSION['start_relationship_group2accesspoints']);
$vis = $rs->PO_RecordCount();
/**
 * Create list
 */
$list = sumo_get_table_header($table['data']['group2accesspoints']);
while ($tab = $rs->FetchRow()) {
    $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
    $query = "SELECT id,node,path,name FROM " . SUMO_TABLE_ACCESSPOINTS . "\n\t\t\t  WHERE (\n\t\t\t  \t\t usergroup LIKE '" . $tab['usergroup'] . "' \n\t\t\t\t\t OR usergroup LIKE '" . $tab['usergroup'] . ";%'\n\t\t\t\t\t OR usergroup LIKE '%;" . $tab['usergroup'] . "'\n\t\t\t\t\t OR usergroup LIKE '%;" . $tab['usergroup'] . ";%'\n\t\t\t\t\t )\n\t\t\t  ORDER BY node,name,path";
    $rs2 = $SUMO['DB']->Execute($query);
    $ap = "<table width='100%'>";
    $a = 0;
    while ($tab2 = $rs2->FetchRow()) {
        $style2 = sumo_alternate_str('tab-row-on', 'tab-row-off', $tab['usergroup']);
        $tab2['name'] = sumo_get_accesspoint_name($tab2['name'], $_COOKIE['language']);
        $ap .= "<tr>" . "<td width='100%' class='" . $style2 . "' nowrap>" . "<a href='javascript:sumo_ajax_get(\"accesspoints\",\"?module=accesspoints&action=edit&id=" . $tab2['id'] . "\");'>" . $tab2['name'] . "</a>" . "</td>" . "<td class='" . $style2 . "'>" . "<a href='javascript:sumo_ajax_get(\"accesspoints\",\"?module=accesspoints&action=edit&id=" . $tab2['id'] . "\");'>" . $tab2['path'] . "</a>" . "</td>" . "</tr>\n";
        $a++;
    }
    $ap .= "</table>";
    if ($search) {
        $tab['usergroup'] = sumo_color_match_string($field['usergroup'][1], $tab['usergroup']);
    }
    $width = $a > 5 ? " width='450'" : '';
    $list .= "<tr>\n" . " <td class='" . $style . "'><b>" . "<a href='javascript:sumo_ajax_get(\"groups\",\"?module=groups&action=edit&id=" . $tab['id'] . "\");'>" . $tab['usergroup'] . "</a>" . "</b>" . "<br>({$a} " . $language['accesspoints'] . ")</td>\n";
    if ($_SESSION['relationship']['group2accesspoints']['col'][100]) {
        $list .= " <td>" . $ap . "</td>\n";
    }
    if ($_SESSION['relationship']['group2accesspoints']['col'][101]) {
        $list .= " <td style='border-bottom:1px solid #DCDCDC'><img onclick='javascript:window.open(\"services.php?module=relationship&service=relationship&cmd=GET_GROUP2ACCESSPOINTS&id=" . $tab['id'] . "\",\"group2accesspoints\",\"height=200,width=500,resizable=yes,scrollbars=yes\");' " . " src='services.php?module=relationship&service=relationship&cmd=GET_GROUP2ACCESSPOINTS&id=" . $tab['id'] . "' alt=''{$width}></td>\n" . "</tr>\n";
Exemplo n.º 3
0
    $field['lastname'] = sumo_search_composer($_SESSION['search_relationship_user2accesspoints'], 'lastname');
    $search = $group_query ? " AND " : " WHERE ";
    $search = $search . "( (" . $field['user'][0] . ") OR " . "((" . $field['firstname'][0] . ") OR (" . $field['lastname'][0] . ")))";
}
$query1 = "SELECT id,username,firstname,lastname FROM " . SUMO_TABLE_USERS . " " . $group_query . " " . $search . "";
$query2 = $query1 . " ORDER BY " . $_SESSION['relationship']['user2accesspoints']['col_sql'] . " " . $_SESSION['relationship']['user2accesspoints']['mode_sql'];
$rs = $SUMO['DB']->Execute($query1);
$tot = $rs->PO_RecordCount();
$rs = $SUMO['DB']->SelectLimit($query2, $_SESSION['rows_relationship_user2accesspoints'], $_SESSION['start_relationship_user2accesspoints']);
$vis = $rs->PO_RecordCount();
/**
 * Create list
 */
$list = sumo_get_table_header($table['data']['user2accesspoints']);
while ($tab = $rs->FetchRow()) {
    $style = sumo_alternate_str('tab-row-on', 'tab-row-off', $tab['username']);
    $ap = sumo_get_user_accesspoints($tab['id'], true);
    if ($search) {
        $tab['username'] = sumo_color_match_string($field['username'][1], $tab['username']);
        $tab['firstname'] = sumo_color_match_string($field['firstname'][1], $tab['firstname']);
        $tab['lastname'] = sumo_color_match_string($field['lastname'][1], $tab['lastname']);
    }
    //$width = $a > 5 ? " width='400'" : '';
    $list .= "<tr>\n" . " <td class='" . $style . "' style='padding:10px'>" . "<a href='javascript:sumo_ajax_get(\"users\",\"?module=users&action=view&id=" . $tab['id'] . "\");'>" . "<b>" . $tab['username'] . "</b><br>" . $tab['lastname'] . " " . $tab['firstname'] . "</a>" . "</td>\n";
    if ($_SESSION['relationship']['user2accesspoints']['col'][100]) {
        $list .= " <td>" . $ap . "</td>\n";
    }
    /*
    if($_SESSION['relationship']['user2accesspoints']['col'][101])
    {
    	$list .= " <td style='border-bottom:1px solid #DCDCDC'><img onclick='javascript:window.open(\"services.php?module=relationship&service=relationship&cmd=GET_USER2ACCESSPOINTS&id=".$tab['id']."\",\"user2accesspoints\",\"height=200,width=500,resizable=yes,scrollbars=yes\");' "
Exemplo n.º 4
0
        $id_inactive = $tab['value'];
    }
}
$query1 = "SELECT * FROM " . SUMO_TABLE_SESSIONS . " " . $search;
$query2 = $query1 . " ORDER BY " . $_SESSION['sessions']['slist']['col_sql'] . " " . $_SESSION['sessions']['slist']['mode_sql'];
$rs = $SUMO['DB']->Execute($query1);
$tot = $rs->PO_RecordCount();
$rs = $SUMO['DB']->SelectLimit($query2, $_SESSION['rows_sessions_slist'], $_SESSION['start_sessions_slist']);
$vis = $rs->PO_RecordCount();
/**
 * Create list
 */
$list = sumo_get_table_header($table['data']['slist']);
$col = $_SESSION['sessions']['slist']['col'];
while ($tab = $rs->FetchRow()) {
    $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
    // verify if user is current user
    if ($tab['session_id'] == session_id()) {
        $style = 'tab-row-highlight';
    }
    $color = 'green';
    if ($tab['expire'] < $SUMO['server']['time'] + 500) {
        $color = 'orange';
    }
    if ($tab['expire'] < $SUMO['server']['time'] + 300) {
        $color = 'red';
    }
    $country = explode('-', $tab['country_name']);
    $country[0] = ucwords(strtolower($country[0]));
    $country[1] = strtolower($country[1]);
    $flag = trim($country[1]) ? trim($country[1]) . ".png" : "blank.png";
Exemplo n.º 5
0
/**
 * Get html list of group_level
 */
function sumo_get_user_grouplevel($group_level = FALSE)
{
    if ($group_level) {
        $num_groups = count($group_level);
        $group = array_keys($group_level);
        $value = array_values($group_level);
        $list = '';
        for ($g = 0; $g < $num_groups; $g++) {
            $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
            if ($group[$g]) {
                $list .= "<tr>\n" . " <td class='{$style}'>" . $group[$g] . "</td>\n" . " <td class='{$style}'>" . sumo_get_group_description($group[$g]) . "</td>\n" . " <td class='{$style}'>" . intval($value[$g]) . "</td>\n" . "</tr>\n";
            }
        }
        return $list;
    } else {
        return FALSE;
    }
}
Exemplo n.º 6
0
$available_group = sumo_get_available_group();
$col = $_SESSION['users']['list']['col'];
while ($tab = $rs->FetchRow()) {
    // Get user status of local Unix user
    if ($tab['datasource_id'] == 0) {
        $u = exec("egrep \"^{$tab['username']}:\" /etc/shadow");
        $p = explode(":", $u);
        $a = explode(" ", exec("passwd -S {$tab['username']}"));
        $tab['active'] = $a[1] == "P" ? 1 : 0;
    }
    $color = $tab['active'] ? 'on' : 'off';
    $rowcolor = $tab['active'] ? '' : " class='row-null'";
    $last_login = $tab['last_login'] ? sumo_get_human_date($tab['last_login']) : '&nbsp;';
    $created = $tab['created'] ? sumo_get_human_date($tab['created']) : '&nbsp;';
    $expire = $tab['day_limit'] != NULL ? sumo_get_human_date($tab['day_limit'] * 86400 + $SUMO['server']['time'], FALSE) : '';
    $style = $tab['username'] == $SUMO['user']['user'] ? 'tab-row-highlight' : sumo_alternate_str('tab-row-on', 'tab-row-off');
    //$style2     = ($tab['modified'] > $SUMO['server']['time'] - 10) ? " style='border-top:1px solid #FF7722;border-bottom:1px solid #FF7722'" : "";
    $username = sumo_get_formatted_username($tab['firstname'], $tab['lastname']);
    // Format group string to display it
    $group = preg_replace("/sumo:7/", "<b><font color='#BB0000'>sumo:7</font></b>", $tab['usergroup']);
    $group = preg_replace("/sumo:/", "<font color='#BB0000'>sumo</font>:", $group);
    $group = str_replace(';', ', ', $group);
    $group = strlen(strip_tags($group)) > 50 ? substr($group, 0, 50) . '...' : $group;
    //
    $usergroup = sumo_get_grouplevel($tab['usergroup'], true);
    for ($g = 0; $g < count($usergroup); $g++) {
        if (!in_array($usergroup[$g], $available_group)) {
            $group = str_replace($usergroup[$g], '<strike>' . $usergroup[$g] . '</strike>', $group);
        }
    }
    if ($search) {
Exemplo n.º 7
0
/**
 * Put accesspoint group (in Html format)
 * 
 * @author Alberto Basso
 */
function sumo_put_accesspoint_group($id = FALSE)
{
    if ($id > 0) {
        $accesspoint = sumo_get_accesspoint_info($id, 'id', FALSE);
        if (!empty($accesspoint['usergroup'])) {
            global $SUMO, $language;
            $list = "<table cellspacing='0' class='tab'>\n" . " <tr>\n" . "  <td class='tab-title'>" . $language['Name'] . "</td>\n" . "  <td class='tab-title'>" . $language['Description'] . "</td>\n" . "  <td class='tab-title'>&nbsp;</td>\n" . " </tr>\n";
            for ($g = 0; $g < count($accesspoint['usergroup']); $g++) {
                if ($accesspoint['usergroup'][$g]) {
                    $style = sumo_alternate_str('tab-row-on', 'tab-row-off');
                    $ap_name = $accesspoint['usergroup'][$g] == 'sumo' ? "<font color='#BB0000'><b>sumo</b></font>" : $accesspoint['usergroup'][$g];
                    $group_name = "<input type='hidden' size='25' name='group[" . $g . "]' value='" . $accesspoint['usergroup'][$g] . "'>" . $ap_name;
                    // Create link to remove group
                    $delete = "<a href='javascript:sumo_ajax_get(\"" . $_SESSION['module'] . "\",\"" . "?module=accesspoints&action=deletegroup&group=" . $accesspoint['usergroup'][$g] . "&id=" . intval($id) . "&SecurityOptions_visibility=1\");'>" . $language['Remove'] . "</a>";
                    $list .= "<tr>\n" . " <td class='" . $style . "'>" . $group_name . "</td>\n" . " <td class='" . $style . "'>" . sumo_get_group_description($accesspoint['usergroup'][$g]) . "</td>\n" . " <td class='" . $style . "'>" . $delete . "</td>\n" . "</tr>\n";
                }
            }
            $list .= "</table>";
            return $list;
        }
    } else {
        return FALSE;
    }
}
Exemplo n.º 8
0
        $query1 = "SELECT * FROM " . SUMO_TABLE_LOG_SYSTEM . " " . $search . " \n\t\t\tUNION \n\t               SELECT * FROM " . SUMO_TABLE_LOG_ACCESS . " " . $search . "\n\t\t\tUNION \n\t               SELECT * FROM " . SUMO_TABLE_LOG_ERRORS . " " . $search;
        break;
}
$query2 = $query1 . " ORDER BY " . $_SESSION['security'][$action]['col_sql'] . " " . $_SESSION['security'][$action]['mode_sql'];
$rs = $SUMO['DB']->Execute($query1);
$tot = $rs->PO_RecordCount();
$rs = $SUMO['DB']->SelectLimit($query2, $_SESSION['rows_security_' . $action], $_SESSION['start_security_' . $action]);
$vis = $rs->PO_RecordCount();
/**
 * Create list
 */
if ($tot > 0) {
    $list = sumo_get_table_header($table['data'][$action]);
    $col = $_SESSION['security'][$action]['col'];
    while ($tab = $rs->FetchRow()) {
        $style = "class='" . sumo_alternate_str('tab-row-on', 'tab-row-off') . "'";
        $node = sumo_get_node_info($tab['node'], 'ip');
        $node['name'] = !$node['name'] ? '&minus;' : $node['name'];
        if ($search) {
            $tab['code'] = sumo_color_match_string($field['code'][1], $tab['code']);
            $tab['ip'] = sumo_color_match_string($field['ip'][1], $tab['ip']);
            $tab['message'] = sumo_color_match_string($field['message'][1], $tab['message']);
            $tab['country_name'] = sumo_color_match_string($field['country_name'][1], $tab['country_name']);
        }
        $list .= "<tr>\n";
        if ($col[2]) {
            $list .= " <td {$style} align='center'><img src='themes/" . $SUMO['page']['theme'] . "/images/modules/security/priority_" . $tab['priority'] . ".gif' class='log-priority' alt='" . $tab['priority'] . "'></td>\n";
        }
        if ($col[3]) {
            $list .= " <td {$style} align='right'>" . $tab['code'] . "</td>\n";
        }