示例#1
0
<?php

function getRandNumber($fMin, $fMax)
{
    srand((double) microtime() * 1000000);
    $fLen = "%0 " . strlen($fMax) . "d ";
    return sprintf($fLen, rand($fMin, $fMax));
}
$str = getRandNumber(1000, 9999);
setcookie("chknumber", $str);
$width = 45;
$height = 18;
@header("Content-Type:image/png");
$im = imagecreate($width, $height);
$back = imagecolorallocatealpha($im, 0, 0, 0, 127);
$font = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 5, 5, 4, $str, $font);
imagepng($im);
imagedestroy($im);
?>

    default:
        die("Invalid Access");
        break;
}
if (array_key_exists("width", $_GET)) {
    $_webcam_width = $_GET["width"];
} else {
    $_webcam_width = 640;
}
if (array_key_exists("stamp", $_GET)) {
    if ($_GET["stamp"] == "0") {
        $_timestamp = false;
    }
}
$_webcam_height = $_webcam_width * $_webcam_size_ratio;
$source = $_webcam . "?cache=" . getRandNumber();
doImage($source, $_webcam_width, $_webcam_height, $_timestamp, $_webcam_name);
function doImage($source, $width, $height, $timestamp = true, $name)
{
    $origImage = getImage($source, $width, $height);
    if (is_null($origImage)) {
        die("Rendering Error");
    }
    $image = resize($origImage, $width, $height);
    $thumb = resize($origImage, 100, 75);
    if ($timestamp) {
        $image = addTimeStamp($image);
    }
    $compression = 75;
    $filepath = "screenshots/";
    $filename = $filepath . $name . "_" . time() . ".jpg";