コード例 #1
0
ファイル: functions.php プロジェクト: rishuchawla/my-projects
function checkmail($code, $country)
{
    $code = preg_replace("/[\\s|-]/", "", $code);
    $length = strlen($code);
    switch (strtoupper($country)) {
        case 'US':
            if ($length != 5 && $length != 9) {
                return FALSE;
            }
            return digits($code);
        case 'CA':
            if ($length != 6) {
                return FALSE;
            }
            return !preg_match("/([A-z][0-9]){3}/", $code);
    }
}
コード例 #2
0
ファイル: index.php プロジェクト: geonef/gitted.clipperz.demo
function base2dec($value, $base, $digits = FALSE)
{
    if ($base < 2 or $base > 256) {
        die("Invalid Base: " . $base);
    }
    bcscale(0);
    if ($base < 37) {
        $value = strtolower($value);
    }
    if (!$digits) {
        $digits = digits($base);
    }
    $size = strlen($value);
    $dec = "0";
    for ($loop = 0; $loop < $size; $loop++) {
        $element = strpos($digits, $value[$loop]);
        $power = bcpow($base, $size - $loop - 1);
        $dec = bcadd($dec, bcmul($element, $power));
    }
    return (string) $dec;
}
コード例 #3
0
ファイル: ppdgauge.php プロジェクト: STJrInuyasha/jul
function drawgauge($xpos, $ypos, $size, $startangle, $endangle)
{
    global $image, $color, $class, $classt, $classtxt;
    //		$startangle	= 90;
    $endangle = $startangle + $endangle;
    $angsize = $endangle - $startangle;
    $radius = $size / 2;
    imagefilledarc($image, $xpos, $ypos, $size, $size, 0, 360, $color['gray1'], IMG_ARC_PIE);
    imagearc($image, $xpos, $ypos, $size, $size, 0, 360, $color['black']);
    for ($i = 0; $i <= 100; $i++) {
        if ($i % 5 == 0) {
            $c = $color['white'];
            $l = 10;
        } else {
            $c = $color['black'];
            $l = 0;
        }
        if ($i >= 0 && $i <= 99) {
            if ($i <= 24) {
                $cx = $i / 25 * 255;
                $cc = imagecolorallocate($image, 255, $cx, 0);
            } elseif ($i <= 49) {
                $cx = ($i - 75) / 25 * 127;
                $cc = imagecolorallocate($image, 255 - $cx, 255 - $cx, $cx);
            } elseif ($i <= 74) {
                $cx = ($i - 50) / 25 * 31;
                $cc = imagecolorallocate($image, 128 - $cx, 128 - $cx, 128 + $cx);
            } else {
                $cx = ($i - 75) / 25 * 95;
                $cc = imagecolorallocate($image, 95 - $cx, 95 - $cx, 255 - $cx);
            }
            $r = $i * ($angsize * 0.01) - $startangle + $angsize * 0.01;
            $q[0] = anglepos($radius - 3, $xpos, $ypos, $r);
            $q[1] = anglepos($radius - 3 - 5, $xpos, $ypos, $r);
            $r = $i * ($angsize * 0.01) - $startangle - 1;
            $q[2] = anglepos($radius - 3, $xpos, $ypos, $r);
            $q[3] = anglepos($radius - 3 - 5, $xpos, $ypos, $r);
            $pts = array($q[0]['x'], $q[0]['y'], $q[2]['x'], $q[2]['y'], $q[3]['x'], $q[3]['y'], $q[1]['x'], $q[1]['y']);
            //				imageline($image, $p1['x'], $p1['y'], $p2['x'], $p2['y'], $cc);
            //				imageline($image, $p1['x'], $p1['y'], $p2['x'], $p2['y'], $cc);
            imagefilledpolygon($image, $pts, 4, $cc);
            //				imageline($image, $q[0]['x'], $q[0]['y'], $q[3]['x'], $q[3]['y'], $cc);
        }
        $r = $i * ($angsize * 0.01) - $startangle;
        $p1 = anglepos($radius - 3, $xpos, $ypos, $r);
        $p2 = anglepos($radius - 3 - $l, $xpos, $ypos, $r);
        imageline($image, $p1['x'], $p1['y'], $p2['x'], $p2['y'], $c);
        $markers = $size < 255 ? 25 : 10;
        if ($i % $markers == 0) {
            $p3 = anglepos($radius - 20, $xpos, $ypos, $r);
            $p4 = anglepos($radius - 42, $xpos, $ypos, $r);
            $n = round($classt * ($i / 100)) . "";
            $nl = strlen($n);
            $x = 2 + 3.5 * ($nl - 1);
            imagestring($image, 3, $p3['x'] - $x, $p3['y'] - 7, $n, $color['white']);
        }
    }
    $rad = 45;
    //	imageline($image, $radius, $radius, $point['x'], $point['y'], $color['black']);
    //	drawneedle($houra, $radius, $radius, $radius - 30,  7, - 3, $color['black']);
    //	drawneedle($mina,  $radius, $radius, $radius -  5,  5, - 5, $color['black']);
    //	drawneedle($seca,  $radius, $radius, $radius -  2,  4, -10, $color['red']);
    $ang = @(min($classt, $class) / $classt) * $angsize - $startangle;
    drawneedle($ang, $xpos, $ypos, $radius - 2, 5, -20, $color['blue']);
    if ($size >= 128) {
        imagestring($image, 1, $size / 2 - 26, $size * 0.7 + 4, $classtxt, $color['white']);
        //			if (!$_GET['p']) imagestring($image, 1, $size / 2 + 14, $size * .7 + 16, "%", 0xcccccc);
        digits($size * 0.5 - 12, $size * 0.7 + 14, $class, 3, 0);
    } else {
        digits($size * 0.5 - 12, $size * 0.7 + 9, $class, 3, 0);
    }
}
コード例 #4
0
ファイル: demo.php プロジェクト: rishuchawla/my-projects
<html>
<body>
<?php 
require_once 'functions.php';
$as = digits(23);
//echo(int) $as.'dfs'.'<br>';
$a = letter('123');
//echo(int) $a.'asd'.'<br>';
$b = checklength('adfdkzisdmfjk', 3, 9);
//echo(int) $b.'sd'.'<br>';
$d = checkmail('asd-432', 'CA');
//echo(int)$d.'fcxgxd'.'<br>';
$check = checkurl('http//www.someone.co');
//echo(int) $check.'sdg'.'<br.';
$emails = checkemail('*****@*****.**');
//echo(int) $emails.'sdaerg'.'<br>';
$pass = checkpassword('rishu-23');
echo (int) $pass . '<br>';
?>

</body>
</html>