eval.in

Paste #57770

PHP — PHP 5.5.1, pasted 5 years ago (json)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?php

function check_forbidden($forbiddennames, $stringtocheck) 
{
    foreach ($forbiddennames as $name) {
        if (stripos($stringtocheck, $name) !== FALSE) {
            return true;
        }
    }
}

$forbiddennames= array(1 => 'Super-user', 'Root', 'Admin', 'Administrator', 'System', 'Website', 'Owner', 'Manager', 'Founder');    
$stringtocheck = 'admin12';

if(check_forbidden($forbiddennames, $stringtocheck)) {
    echo "This is a forbidden username.";
} else {
    echo "True";
}

Program Output

This is a forbidden username.

OK (0.008 sec real, 0.010 sec wall, 14 MB, 42 syscalls)

Fork