예제 #1
0
파일: validator.php 프로젝트: kennho/router
echo 'Signature: variable_name($variable)<br/>';
echo '//returns the variable name that was passed in';
$selected_item = 'item';
$arraylist_item = array('lalala');
echo 'variable_name($selected_item): ' . variable_name($selected_item) . '<br/>';
echo 'variable_name("test_item"): "' . variable_name("test_item") . '" >br/> //returns empty if variable is not an item<br/>';
echo 'variable_name($arraylist_item): ' . variable_name($arraylist_item) . '<br/>';
echo '<br/>Passed<br/><hr/>';
/* validates if input is a valid md5 string, checks for corresponding regex in /tools/contants/regex when defined in /tools/constants/constants $allowed_hash_types */
echo 'Signature: validate_hash($hash, $hash_type = "md5")<br/>';
echo '#checks if hash type is valid based on list in constants.php, checks if hash given matches the relevant regex<br/><br/>';
echo 'validate_hash("123asd", "md5): ' . (validate_hash('123asd', 'md5') ? 'true' : 'false') . '<br/>';
echo 'validate_hash("123asd", "lalalhash"): ' . (validate_hash('123asd', 'lalahash') ? 'true' : 'false') . '//if hash type not valid false <br/>';
echo 'validate_hash("5f4dcc3b5aa765d61d8327deb882cf99"): ' . (validate_hash('5f4dcc3b5aa765d61d8327deb882cf99') ? 'true' : 'false') . '<br/>';
echo '<br/>Passed<br/><hr/>';
/* validates the email address formatting and ensure that the domain exist */
echo 'Signature: validate_email($email)<br/><br/>';
echo 'validate_email("*****@*****.**"): ' . (validate_email("*****@*****.**") ? 'true' : 'false') . '<br/>';
echo 'validate_email("*****@*****.**"): ' . (validate_email("*****@*****.**") ? 'true' : 'false') . '<br/>';
echo 'validate_email("*****@*****.**"): ' . (validate_email("*****@*****.**") ? 'true' : 'false') . '<br/>';
echo 'validate_email("*****@*****.**"): ' . (validate_email("*****@*****.**") ? 'true' : 'false') . '<br/>';
echo 'validate_email("googogo@123.123"): ' . (validate_email("googogo@123.123") ? 'true' : 'false') . ' //must be valid tld<br/>';
echo 'validate_email("googogo@123.123.123.123"): ' . (validate_email("googogo@123.123.123.123") ? 'true' : 'false') . '//ip address will not work<br/>';
echo '<br/>Passed<br/><hr/>';
/* check if server is requested with ssl */
echo 'Signature: validate_https()';
echo 'validate_https(): ' . (validate_https() ? 'true' : 'false') . '<br/>';
echo '<br/>Passed<br/><hr/>';
?>
  
예제 #2
0
파일: enforcer.php 프로젝트: kennho/router
function enforce_https($return_type = 'json')
{
    $enable_https = Config::get('enable_https');
    if ($enable_https == true) {
        if (validate_https() == false) {
            Writer::write(412, 'Request is not sent securely with https.', Constants::get('error_tag'), $return_type);
        } else {
            return true;
        }
    }
}