Esempio n. 1
0
}
function validateHexColor($hex)
{
    $hex = substr($hex, 0, 1) == '#' ? $hex : '#' . $hex;
    if (preg_match('/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $hex)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
session_start();
if (isset($_GET['expected'])) {
    if ($_GET['expected'] == $_SESSION['expected']) {
        JSONP::output(TRUE);
    } else {
        JSONP::output(FALSE);
    }
} else {
    // Background color
    if (isset($_GET['bg']) && validateHexColor($_GET['bg'])) {
        $bgc = hex2rgb($_GET['bg']);
    } else {
        $bgc = hex2rgb('#fff');
    }
    // Foreground color
    if (isset($_GET['fg']) && validateHexColor($_GET['fg'])) {
        $fgc = hex2rgb($_GET['fg']);
    } else {
        $fgc = hex2rgb('#000');
    }
    // Font