Exemplo n.º 1
0
 public static function isExists($date)
 {
     $draw = Draw::where('date', '=', date("Y-m-d H:i:s", strtotime($date)))->count();
     if ($draw > 0) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 private function setPastDraws($date)
 {
     try {
         $count = Draw::where('draw_date', $date)->count();
         if ($count === 0) {
             $drawByDate = $this->client->getGewinnzahlenFromDatum($date);
             if ($drawByDate->Fehlernummer === 0) {
                 $draw = array('draw_date' => $drawByDate->Ziehungsdatum, 'number_1' => $drawByDate->Gewinnzahl_1, 'number_2' => $drawByDate->Gewinnzahl_2, 'number_3' => $drawByDate->Gewinnzahl_3, 'number_4' => $drawByDate->Gewinnzahl_4, 'number_5' => $drawByDate->Gewinnzahl_5, 'number_6' => $drawByDate->Gewinnzahl_6, 'super_number' => $drawByDate->Superzahl, 'game_77' => $drawByDate->Spiel77, 'game_6' => $drawByDate->Super6);
                 Draw::create($draw);
             }
         }
     } catch (SoapFault $error) {
         return $error->faultstring;
     }
 }
Exemplo n.º 3
0
 /**
  * @param int $XSize
  * @param int $YSize
  * @param Data $DataSet
  * @param boolean $TransparentBackground
  */
 public function __construct($XSize, $YSize, Data $DataSet = null, $TransparentBackground = false)
 {
     parent::__construct();
     $this->TransparentBackground = $TransparentBackground;
     if ($DataSet) {
         $this->DataSet = $DataSet;
     }
     $this->XSize = $XSize;
     $this->YSize = $YSize;
     $this->Picture = imagecreatetruecolor($XSize, $YSize);
     if ($this->TransparentBackground) {
         imagealphablending($this->Picture, false);
         imagefilledrectangle($this->Picture, 0, 0, $XSize, $YSize, imagecolorallocatealpha($this->Picture, 255, 255, 255, 127));
         imagealphablending($this->Picture, true);
         imagesavealpha($this->Picture, true);
     } else {
         $C_White = $this->AllocateColor($this->Picture, 255, 255, 255);
         imagefilledrectangle($this->Picture, 0, 0, $XSize, $YSize, $C_White);
     }
 }
Exemplo n.º 4
0
}
$class_dir = 'Codebar';
include_once $class_dir . DIRECTORY_SEPARATOR . 'Barcode.php';
require_once $class_dir . DIRECTORY_SEPARATOR . 'Color.php';
require_once $class_dir . DIRECTORY_SEPARATOR . 'Draw.php';
$drawException = null;
try {
    $color_black = new Color(0, 0, 0);
    $color_white = new Color(255, 255, 255);
    $code_generated = new Barcode();
    $code_generated->setScale(max(1, min(4, $_GET['scale'])));
    $code_generated->setBackgroundColor($color_white);
    $code_generated->setForegroundColor($color_black);
    if ($_GET['text'] !== '') {
        $text = convertText($_GET['text']);
        $code_generated->parse($text);
    }
} catch (Exception $exception) {
    $drawException = $exception;
}
$drawing = new Draw('', $color_white);
if ($drawException) {
    $drawing->drawException($drawException);
} else {
    $drawing->setBarcode($code_generated);
    $drawing->setRotationAngle($_GET['rotation']);
    $drawing->setDPI($_GET['dpi'] === 'NULL' ? null : max(72, min(300, intval($_GET['dpi']))));
    $drawing->draw();
}
header('Content-Type: image/png');
$drawing->finish();
Exemplo n.º 5
0
            $str = iconv("utf-8", "utf-8", $labLst[$i]);
            $percent = round($datLst[$i] / $total / 100 * 10000) . "%";
            $dastr = $str . ":" . $datLst[$i] . "(" . $percent . ")";
            //echo "<br/>percent:".$percent." datlist:".$datLst[$i]." dastr:".$dastr."x:".(5+2*$fw)." y:".($ly+13)."<br/>";
            imagettftext($img, $font, 0, 5 + 2 * $fw, $ly + 13, $clrt, $this->font_used, $dastr);
            $ly += $fh + 2;
            //echo "<br/>第".$i."个扇区<br/>";
        }
        imagepng($img);
    }
}
header("Content-type:image/png");
//$img = imagecreatetruecolor(800, 800);
//$cor = imagecolorallocate($img, 0, 255, 255);
//imagefill($img, 0, 0, $cor);
$draw = new Draw();
//$draw->draw_arc($img,400,400,300,200,20,340,0x009999);
//$draw->drew_sector($img,400,400,300,200,20,340,0x009999);
//$draw->draw_sector3d($img,400,400,300,200,20,72,120,0x009999);
$datLst = array(30, 20, 20, 20, 10, 20, 10, 20);
//数据
$labLst = array("浙江省", "广东省", "上海市", "北京市", "福建省", "江苏省", "湖北省", "安徽省");
//标签
$clrLst = array(0x99ff00, 0xff6666, 0x99ff, 0xff99ff, 0xffff99, 0x99ffff, 0x9999, 0xff3333);
//画图
$draw->draw_img($datLst, $labLst, $clrLst);
?>



Exemplo n.º 6
0
 if ($time == "21:00" && $draw->numbers == '') {
     //
     $draw_id = $draw->id;
     $draw_winning_price = $draw->winning_price;
     // GENERATE RANDOM NUMBERS FROM 1-42
     $range = range(1, 42);
     shuffle($range);
     $num = 6;
     $r = array();
     for ($i = 0; $i < $num; $i++) {
         $r[] = $range[$i];
     }
     $shuffled = $num == 1 ? $r[0] : $r;
     sort($shuffled, SORT_NUMERIC);
     // SAVE THE WINNING NUMBER TO DATABASE
     $draw = Draw::where("date", "=", $date)->update(array('numbers' => implode(",", $shuffled), 'status' => 'closed'));
     // FIND WINNERS
     $bets = Bet::where("draw_id", "=", $draw_id)->where("numbers", "=", implode(",", $shuffled));
     // GET NUMBER OF WINNERS AND DIVIDED IT
     $price = $draw_winning_price / $bets->count();
     // WINNERS
     $winners = $bets->get();
     // SAVE WINNERS TO DATABASE
     foreach ($winners as $winner) {
         $w = new Winner();
         $w->draw_id = $draw_id;
         $w->winning_numbers = implode(",", $shuffled);
         $w->winning_price = $price;
         $w->ticket_number = $winner->ticket_number;
         $w->security_code = $winner->security_code;
         $w->draw_date = $date;
Exemplo n.º 7
0
                $fts_box = imagettfbbox($this->size, 0, $this->font, $fts_txt);
                $ftx_beg = $cdx_beg - floor($fts_box[4] - $fts_box[6]) / 2;
                $fty_beg = $this->height - $this->offset + $this->fontA;
                imagettftext($this->image, $this->size, 0, $ftx_beg, $fty_beg, $this->fontC, $this->font, $fts_txt);
                $cdx_beg += $cdx_add;
            }
            $this->outPut();
        } else {
            exit('统计数据为空!');
        }
    }
}
$w = 640;
$h = 480;
$info = array('春季' => 78, '夏季' => 65, '秋季' => 86, '冬季' => 55);
$draw_ins = new Draw($w, $h);
//echo "柱状图";
$draw_ins->ImportData($info);
// 柱状图
$draw_ins->DrawColumn();
// 线形图
//$draw_ins->DrawLine();
// 饼形图
//$draw_ins->DrawPie();
unset($draw_ins);
?>




Exemplo n.º 8
0
        $app->flash('error', 'Your are not administrator.');
        $app->redirect('/managers/login');
    }
    $gump = new GUMP();
    $_POST = $gump->sanitize($_POST);
    // You don't have to sanitize, but it's safest to do so.
    $gump->validation_rules(array('winning_price' => 'required|numeric', 'draw_date' => 'required|max_len,10|min_len,6'));
    $gump->filter_rules(array('winning_price' => 'trim', 'draw_date' => 'trim'));
    if (!preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $_POST['draw_date'])) {
        $app->flash('error', "Invalid Date");
        $app->redirect('/managers/draws');
    }
    $validator = $gump->run($_POST);
    if ($validator === false) {
        $app->flash('error', $gump->get_readable_errors(true));
        $app->redirect('/managers/draws');
    } else {
        if (!Draw::isExists($_POST['draw_date']) && Draw::validDate($_POST['draw_date'])) {
            $draw = new Draw();
            $draw->winning_price = $_POST['winning_price'];
            $draw->date = date("Y-m-d H:i:s", strtotime($_POST['draw_date']));
            $draw->status = "open";
            $draw->save();
            $app->flash('info', "Draw has been successfully created.");
            $app->redirect('/managers/draws');
        } else {
            $app->flash('error', "There is already a draw scheduled for this day or the date is invalid.");
            $app->redirect('/managers/draws');
        }
    }
});
Exemplo n.º 9
0
 private static function make_crc_table()
 {
     for ($n = 0; $n < 256; $n++) {
         $c = $n;
         for ($k = 0; $k < 8; $k++) {
             if (($c & 1) == 1) {
                 $c = 0xedb88320 ^ self::SHR($c, 1);
             } else {
                 $c = self::SHR($c, 1);
             }
         }
         self::$crc_table[$n] = $c;
     }
     self::$crc_table_computed = true;
 }
Exemplo n.º 10
0
<?php

$app->get('/', function () {
    $twig = Twig::get();
    $template = $twig->loadTemplate('index.html');
    $cur = strtotime(date("Y-m-d H:i:s"));
    $lap = strtotime(date("Y-m-d 20:00:00"));
    $left = $lap - $cur;
    echo $template->render(array('left' => $left, 'time' => date("Hi")));
});
$app->get('/live-draw/', function () use($app) {
    $draw = Draw::where("status", "=", "closed")->where("numbers", "!=", "")->orderBy('id', 'desc')->first();
    header("Content-Type:text/json");
    if (is_object($draw)) {
        echo json_encode(explode(",", $draw->numbers), JSON_NUMERIC_CHECK);
    }
});
Exemplo n.º 11
0
            return array('type' => 'image/jpeg', 'ext' => 'jpg', 'func' => 'imagejpeg');
        }
        if ($img_supt & IMG_PNG && function_exists('imagepng')) {
            return array('type' => 'image/png', 'ext' => 'png', 'func' => 'imagepng');
        }
    }
    function __destruct()
    {
        image_destroy($this->image);
    }
}
// 使用方法
$w = 640;
$h = 480;
$info = array('春季' => 78, '夏季' => 65, '秋季' => 86, '冬季' => 55);
$draw_ins = new Draw($w, $h);
//echo "柱状图";
$draw_ins->ImportData($info);
// 柱状图
//$draw_ins->DrawColumn();
// 线形图
$draw_ins->DrawLine();
// 饼形图
//$draw_ins->DrawPie();
unset($draw_ins);
?>