Exemplo n.º 1
0
function validPassword($pass)
{
    $digit = 0;
    $letter = 0;
    $specialChar = 0;
    function hasSpecialChar($ch)
    {
        return $ch == '!' || $ch == '@' || $ch == '#' || $ch == '$' || $ch == '%' || $ch == '*' || $ch == '(' || $ch == ')' || $ch == '+' || $ch == '=' || $ch == '.';
    }
    function hasDigit($ch)
    {
        return is_numeric($ch);
    }
    function isLetter($cha)
    {
        return ctype_alpha($cha);
    }
    for ($i = 0; $i < strlen($pass); $i++) {
        $c = substr($pass, $i, 1);
        if (hasSpecialChar($c)) {
            $specialChar++;
        }
        if (hasDigit($c)) {
            $digit++;
        }
        if (isLetter($c)) {
            $letter++;
        }
    }
    return $specialChar > 0 && $digit > 0 && $letter > 0 && strlen($pass) >= 8;
}
Exemplo n.º 2
0
    }
    if ($c >= 'A' && $c <= 'Z') {
        return true;
    }
    return false;
}
if (isset($_GET['first']) && isset($_GET['last'])) {
    $first = $_GET['first'];
    $last = $_GET['last'];
    for ($i = 0; $i < strlen($first); $i++) {
        if (!isLetter($first[$i])) {
            die("nice try, asshole");
        }
    }
    for ($i = 0; $i < strlen($last); $i++) {
        if (!isLetter($last[$i])) {
            die("nice try, asshole");
        }
    }
    include 'sql.php';
    $dateinfo = getdate();
    $host = $_SERVER['HTTP_HOST'];
    $date = $dateinfo['month'] . " " . $dateinfo['mday'] . ", " . $dateinfo['year'];
    if (sql('friends', 0, "select count(*) from names where first=\"{$first}\" and last=\"{$last}\" and host=\"{$host}\" and date=\"{$date}\"")[0][0] == 0) {
        sql('friends', 0, 'insert into names (first, last, host, date) values ("' . $first . '","' . $last . '","' . $host . '","' . $date . '");');
    }
}
?>

<h1>Thanks for signing up!</h1>
Exemplo n.º 3
0
$text = $_GET['text'];
$minFontSize = intval($_GET['minFontSize']);
$maxFontSize = intval($_GET['maxFontSize']);
$step = intval($_GET['step']);
$currentSize = $minFontSize;
$isIncrementing = true;
$decoration = "";
for ($i = 0; $i < strlen($text); $i++) {
    if (ord($text[$i]) % 2 == 0) {
        $decoration = "text-decoration:line-through;";
    } else {
        $decoration = "";
    }
    echo "<span style='font-size:{$currentSize};{$decoration}'>" . htmlspecialchars($text[$i]) . "</span>";
    $isLetter = isLetter($text[$i]);
    if ($isLetter) {
        if ($isIncrementing) {
            $currentSize += $step;
        } else {
            $currentSize -= $step;
        }
    }
    if ($isLetter && ($currentSize >= $maxFontSize || $currentSize <= $minFontSize)) {
        $isIncrementing = !$isIncrementing;
    }
}
function isLetter($char)
{
    return ord($char) >= ord('a') && ord($char) <= ord('z') || ord($char) >= ord('A') && ord($char) <= ord('Z');
}