Beispiel #1
0
/**
 * Return supported encryption algorithms
 */
function sumo_get_datasource_enctype($datasource_type = '')
{
    $ds = sumo_get_available_datasources(true);
    switch ($datasource_type) {
        // for databases based ds
        case in_array($datasource_type, $ds):
            return array('md5', 'crypt', 'sha1', 'crc32');
            break;
        case in_array($datasource_type, array('LDAP', 'LDAPS', 'ADAM')):
            return array('md5', 'crc32');
            break;
    }
}
Beispiel #2
0
/**
 * Validate network data
 * 
 * Note: see also sumo_validate_data() in libs/lib.core.php
 */
function sumo_validate_data_network($data = array(), $message = FALSE)
{
    $elements = count($data);
    $err = FALSE;
    if ($elements > 0) {
        for ($d = 0; $d < $elements; $d++) {
            if ($data[$d][2] == 1 || $data[$d][2] == 0 && $data[$d][1]) {
                switch ($data[$d][0]) {
                    case 'id':
                        // INT = 256^4-1
                        if ($data[$d][1] < 1 || $data[$d][1] > 4294967296) {
                            $err = 'W00029C';
                        }
                        break;
                    case 'node_name':
                        if (!preg_match("/^[a-z0-9" . SUMO_REGEXP_ALLOWED_CHARS . "\\-\\_\\.\\=\\&\\/\\\\'\\ ]{4,50}\$/i", $data[$d][1])) {
                            $err = 'W09015C';
                        }
                        break;
                    case 'dsname':
                        if (!preg_match("/^[a-z0-9" . SUMO_REGEXP_ALLOWED_CHARS . "\\-\\_\\.\\=\\&\\/\\\\'\\ ]{4,128}\$/i", $data[$d][1])) {
                            $err = 'W09001C';
                        }
                        break;
                    case 'type':
                        if (!in_array($data[$d][1], sumo_get_available_datasources())) {
                            $err = 'W09002C';
                        }
                        break;
                    case 'port':
                        if ($data[$d][1] < 1 || $data[$d][1] > 65535) {
                            $err = 'W09004C';
                        }
                        break;
                    case 'protocol':
                        $protocols = array('http', 'https');
                        if (!in_array($data[$d][1], $protocols)) {
                            $err = 'W09017C';
                        }
                        break;
                    case 'username':
                        if (!preg_match('/^[a-z0-9]{3,32}$/i', $data[$d][1])) {
                            $err = 'W09005C';
                        }
                        break;
                    case 'password':
                        if (!preg_match('/[a-z0-9\\.\\,\\:\\;\\_\\-\\$\\!\\"\'\\/\\\\£\\%\\&\\(\\)\\=\\?\\^\\+\\*\\ ' . SUMO_REGEXP_ALLOWED_CHARS . ']{3,255}$/i', $data[$d][1])) {
                            $err = 'W09006C';
                        }
                        break;
                    case 'db_name':
                        if (!preg_match('/^[a-z0-9\\_]{3,32}$/i', $data[$d][1])) {
                            $err = 'W09007C';
                        }
                        break;
                    case 'db_table':
                        if (!preg_match('/[a-z0-9\\_]{3,255}$/i', $data[$d][1])) {
                            $err = 'W09008C';
                        }
                        break;
                    case 'enctype':
                        $enctype = sumo_get_datasource_enctype();
                        if (!in_array($data[$d][1], $enctype)) {
                            $err = 'W09018C';
                        }
                        break;
                    case 'ldap_base':
                        if (!preg_match('/^[a-z0-9\\.\\,\\:\\;\\_\\-\\=\\\\/\\+\\*\\ ' . SUMO_REGEXP_ALLOWED_CHARS . ']{4,255}$/i', $data[$d][1])) {
                            $err = 'W00027C';
                        }
                        break;
                    case 'iptype':
                        $type = array('L', 'P');
                        if (!in_array($data[$d][1], $type)) {
                            $err = 'W09010C';
                        }
                        break;
                    case 'host':
                        if (!sumo_validate_ip($data[$d][1], FALSE) && !preg_match('/[a-z0-9\\.\\_\\-]{3,128}$/i', $data[$d][1])) {
                            $err = 'W09011C';
                        }
                        break;
                    case 'hostname':
                        if (!preg_match('/[a-z0-9\\.\\_\\-]{3,128}$/i', $data[$d][1])) {
                            $err = 'W09003C';
                        }
                        break;
                    case 'iprange':
                        if (!sumo_validate_iprange($data[$d][1], FALSE)) {
                            $err = 'W09009C';
                        }
                        break;
                    case 'status':
                        if ($data[$d][1] != 0 && $data[$d][1] != 1) {
                            $err = 'W09012C';
                        }
                        break;
                    case 'sumo_path':
                        if (!preg_match("/^\\/[a-z0-9\\-\\_\\.\\/]{1,253}\\/\$/i", $data[$d][1])) {
                            $err = 'W09014C';
                        }
                        break;
                    default:
                        $err = 'W00019C';
                        break;
                }
                if ($err) {
                    break;
                }
            }
        }
        if ($message) {
            return !$err ? array(TRUE, '') : array(FALSE, sumo_get_message($err));
        } else {
            return !$err ? true : false;
        }
    } else {
        return false;
    }
}
Beispiel #3
0
     echo $status;
     break;
 case 'CREATE_SID':
     if (SUMO_SESSIONS_REPLICA) {
         $session = sumo_get_session_info($_GET['id']);
         setcookie('SUMO', $session['session_id'], null, '/');
     }
     break;
     // Get datasource status
 // Get datasource status
 case 'GET_DS_STATUS':
     $id = intval($_GET['id']);
     if ($id < 2) {
         exit("E09000X");
     }
     $available_ds = sumo_get_available_datasources();
     switch ($_GET['type']) {
         case 'LDAP':
             $ds = 'ldap';
             break;
         case 'LDAPS':
             $ds = 'ldaps';
             break;
         case 'ADAM':
             $ds = 'adam';
             break;
         case 'MySQL':
             $ds = 'mysql';
             break;
         case 'MySQLUsers':
             $ds = 'mysql_users';
<?php

/**
 * SUMO MODULE: Network | New Datasource
 * 
 * @version    0.5.0
 * @link       http://sumoam.sourceforge.net SUMO Access Manager
 * @author     Alberto Basso <*****@*****.**>
 * @copyright  Copyright &copy; 2003-2009, Alberto Basso
 * @package    SUMO
 * @category   Console
 */
$ds = sumo_get_available_datasources(true);
switch ($_POST['type']) {
    // DB
    case in_array($_POST['type'], $ds):
        $_POST['ldap_base'] = '';
        break;
    case in_array($type, array('LDAP', 'LDAPS', 'ADAM')):
        $_POST['db_name'] = '';
        $_POST['db_table'] = '';
        $_POST['db_field_user'] = '';
        $_POST['db_field_password'] = '';
        break;
    case 'Joomla15':
        $_POST['db_table'] = 'jos_users';
        $_POST['db_field_user'] = '******';
        $_POST['db_field_password'] = '******';
        break;
}
// Set default port