<commit_before><?php
/**
 * No user created main file
 *
 * PHP version 5
 *
 * @category   SimpleSAMLphp
 * @package    JANUS
 * @subpackage Site
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @copyright  2009 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT License
 * @version    SVN: $Id$
 * @link       http://code.google.com/p/janus-ssp/
 * @since      File available since Release 1.0.0
 */
$session = SimpleSAML_Session::getInstance();
$config = SimpleSAML_Configuration::getInstance();
$janus_config = SimpleSAML_Configuration::getConfig('module_janus.php');

$authsource = $janus_config->getValue('auth', 'login-admin');
$useridattr = $janus_config->getValue('useridattr', 'eduPersonPrincipalName');

// Validate user
if ($session->isValid($authsource)) {
    $attributes = $session->getAttributes();
    // Check if userid exists
    if (!isset($attributes[$useridattr]))
        throw new Exception('User ID is missing');
    $userid = $attributes[$useridattr][0];
} else {
    SimpleSAML_Utilities::redirect(SimpleSAML_Module::getModuleURL('janus/index.php'));
}

// Backwards compatible function for checking urls
function check_url ($url) {
    // filter_var with URLs have a bug that is solved in 5.3.3/5.2.14
    if (version_compare(PHP_VERSION, '5.3.3', '>=')) {
        return filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
    } else {
        // backport from PHP 5.2
        // http://svn.php.net/viewvc/php/php-src/trunk/ext/filter/logical_filters.c
        // see php_filter_validate_url function
        $parts = parse_url($url);
        if ($parts == FALSE) {
            return FALSE;
        } else if (!isset($parts['scheme']) ||
                  (!isset($parts['host']) &&
                  ($parts['scheme'] !== 'mailto' &&
                   $parts['scheme'] !== 'news' &&
                   $parts['scheme'] !== 'file'))) {
            return FALSE;
        }
        return TRUE;
    }
}

$mcontrol = new sspmod_janus_UserController($janus_config);
$pm = new sspmod_janus_Postman();

if(!$user = $mcontrol->setUser($userid)) {
    die('Error in setUser');
}

$selectedtab = isset($_REQUEST['selectedtab']) ? $_REQUEST['selectedtab'] : 1;

if(isset($_POST['add_usersubmit'])) {
    if(empty($_POST['userid']) || empty($_POST['type'])) {
        $msg = 'error_user_not_created_due_params';
    } else {
        $new_user = new sspmod_janus_User($janus_config->getValue('store'));
        $new_user->setUserid($_POST['userid']);
        $new_user->setType($_POST['type']);
        if(isset($_POST['active']) && $_POST['active'] == 'on') {
            $active = 'yes';
        } else {
            $active = 'no';
        }
        $new_user->setActive($active);
        $new_user->setData($_POST['userdata']);
        if(!$new_user->save()) {
            $msg = 'error_user_not_created';
        } else {
            SimpleSAML_Utilities::redirect(
                SimpleSAML_Utilities::selfURLNoQuery(), 
                Array('selectedtab' => $selectedtab)    
            );
        }
    }
}

if(isset($_POST['submit'])) {
    if (!empty($_POST['entityid'])) {
        if (check_url($_POST['entityid'])) {
            if(!isset($_POST['entityid']) || empty($_POST['entitytype'])) {
                $msg = 'error_no_type';
                $old_entityid = $_POST['entityid'];
            } else {
                $msg = $mcontrol->createNewEntity($_POST['entityid'], $_POST['entitytype']);
                if(is_int($msg)) {<commit_msg>Update issue 222 Updated the check that validates the entityID in dashboard to allow absolute URI's.<commit_after><?php
/**
 * No user created main file
 *
 * PHP version 5
 *
 * @category   SimpleSAMLphp
 * @package    JANUS
 * @subpackage Site
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @copyright  2009 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT License
 * @version    SVN: $Id$
 * @link       http://code.google.com/p/janus-ssp/
 * @since      File available since Release 1.0.0
 */
$session = SimpleSAML_Session::getInstance();
$config = SimpleSAML_Configuration::getInstance();
$janus_config = SimpleSAML_Configuration::getConfig('module_janus.php');

$authsource = $janus_config->getValue('auth', 'login-admin');
$useridattr = $janus_config->getValue('useridattr', 'eduPersonPrincipalName');

// Validate user
if ($session->isValid($authsource)) {
    $attributes = $session->getAttributes();
    // Check if userid exists
    if (!isset($attributes[$useridattr]))
        throw new Exception('User ID is missing');
    $userid = $attributes[$useridattr][0];
} else {
    SimpleSAML_Utilities::redirect(SimpleSAML_Module::getModuleURL('janus/index.php'));
}

function check_uri ($uri)
{
    if (preg_match('/^[a-z][a-z0-9+-\.]*:.+$/i', $uri) == 1) {
        return TRUE;
    }
    return FALSE;
}

$mcontrol = new sspmod_janus_UserController($janus_config);
$pm = new sspmod_janus_Postman();

if(!$user = $mcontrol->setUser($userid)) {
    die('Error in setUser');
}

$selectedtab = isset($_REQUEST['selectedtab']) ? $_REQUEST['selectedtab'] : 1;

if(isset($_POST['add_usersubmit'])) {
    if(empty($_POST['userid']) || empty($_POST['type'])) {
        $msg = 'error_user_not_created_due_params';
    } else {
        $new_user = new sspmod_janus_User($janus_config->getValue('store'));
        $new_user->setUserid($_POST['userid']);
        $new_user->setType($_POST['type']);
        if(isset($_POST['active']) && $_POST['active'] == 'on') {
            $active = 'yes';
        } else {
            $active = 'no';
        }
        $new_user->setActive($active);
        $new_user->setData($_POST['userdata']);
        if(!$new_user->save()) {
            $msg = 'error_user_not_created';
        } else {
            SimpleSAML_Utilities::redirect(
                SimpleSAML_Utilities::selfURLNoQuery(), 
                Array('selectedtab' => $selectedtab)    
            );
        }
    }
}

if(isset($_POST['submit'])) {
    if (!empty($_POST['entityid'])) {
        if (check_uri($_POST['entityid'])) {
            if(!isset($_POST['entityid']) || empty($_POST['entitytype'])) {
                $msg = 'error_no_type';
                $old_entityid = $_POST['entityid'];
            } else {
                $msg = $mcontrol->createNewEntity($_POST['entityid'], $_POST['entitytype']);
                if(is_int($msg)) {
{'fraction_non_alphanumeric': 0.17646153846153848, 'fraction_numerical': 0.005846153846153846, 'mean_word_length': 2.9423893268647667, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1257641', 'n_tokens_mistral': 2087, 'n_tokens_neox': 2037, 'n_words': 355}