Esempio n. 1
0
    return $tab;
}
$chosenNumbers = array();
// numbers chosen by user
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    for ($i = $lottoStart + 1; $i <= $lottoEnd + 1; $i++) {
        if ($_POST["check{$i}"] == 'on') {
            array_push($chosenNumbers, $i);
        }
    }
    if (count($chosenNumbers) != 6) {
        $chosenNumbers = array();
        $error = 'Wybierz dokładnie 6 liczb.';
    } else {
        $error = '';
        $generatedTab = Generate($lottoStart, $lottoEnd);
        // generated tab of numbers that can be chosen
        shuffle($generatedTab);
        $slicedTab = array_slice($generatedTab, 0, 6, true);
        sort($slicedTab);
        $numDisplay = '';
        // numbers to display at the end
        $count = 0;
        // counting good guesses
        foreach ($chosenNumbers as $chNum) {
            if (in_array($chNum, $slicedTab)) {
                $numDisplay .= "<font color=\"green\">" . $chNum . "</font> ";
                $count++;
            } else {
                $numDisplay .= $chNum . " ";
            }
Esempio n. 2
0
$i = 0;
class item
{
    public $o = '';
    public $f = '';
    public $s = '';
    public $t = '';
}
function Generate($num)
{
    $tagsMatrix = array();
    array_push($tagsMatrix, 'mulher', 'aids', 'UBS', 'UPA', 'ACS', 'hospital', 'DENG', 'complementares', 'eventos', 'saude', 'drogas', 'tecnologia');
    $return = array();
    $return[0] = $tagsMatrix;
    for ($i; $i < $num; $i++) {
        $item = new item();
        $item->o = ' ' . strval(rand(1, 16)) . ' ';
        $item->f = ' ' . strval(rand(1, 48)) . ' ';
        $item->s = rand(0, 5);
        $t = rand(1, 6);
        while ($t > 0) {
            $item->t .= rand(0, count($tagsMatrix) - 1) . ' ';
            --$t;
        }
        $item->t = ' ' . $item->t;
        array_push($return, $item);
    }
    return $return;
}
echo json_encode(Generate(1000));
Esempio n. 3
0
    $row = mysqli_fetch_array($res);
    $uploaded = $row['uploaded'];
    $downloaded = $row['downloaded'];
    if ($row["downloaded"] > 0) {
        $ratio = number_format($row["uploaded"] / $row["downloaded"], 2);
    } else {
        $ratio = 0.0;
    }
    $userbar = $row['img'];
}
$digits_ini = @parse_ini_file($file_ini) or die("Cannot load Digits Configuration file!");
$digits_img = @imagecreatefrompng($file_img) or die("Cannot Initialize new GD image stream!");
$img = @imagecreatefrompng($userbar_path . $userbar) or die("Cannot Initialize new GD image stream!");
Generate($ratio, $pos_ratio, false);
Generate($uploaded, $pos_upload, true);
Generate($downloaded, $pos_download, true);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
exit;
/************
 * Function *
 ************/
function Generate($value, $position, $units)
{
    global $img, $digits_ini, $digits_img;
    $size = array('b', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb');
    $numbers = number_format($value, 2);
    $siz = 'b';
    if ($units) {
        for ($x = 1; $x < 9; $x++) {