온라인 로또복권

· 15년 전 · 2000
온라인로또가 어떤건지 게임 한판 해보기 ->

http://www.lottogame.wo.to

온라인 로또복권 입니다.
기능은, 로또복권과 100% 동일합니다.

제가 가상적으로 상상한 로또복권의 방식은
로또복권 기기에 OMR 방식으로 숫자를 읽은다음 DB 에 저장하고
영수증을 발부하는 그런 형태 라고 생각되었습니다.

제가만든 온라인 로또복권은 그와 동일합니다.

1. 사용자의 입력을 받는다
2. db 에 저장한다
3. 영수증 비스무리한 페이지를 출력한다.
4. 추첨한다(컴퓨터가 자동으로)


<b>계층구조를 설명해 보면 다음과 같습니다.</b>

index.html (자바스크립트와 html 로 구성,체크박스로 숫자를 입력받을수 있음)
success.php (index.html 에서 넘어온 값을 db 에 저장. 이메일과, 당첨확인용 비밀번호 저장)
statics.php (번호별로 찍은 횟수를 통계냄. -_- 저의 개인적인이유로 제작.)
select.php (추첨기. 중복되지않는 6개의 숫자와 보너스숫자생성하고 DB 안의 로또번호와 대조
각 등위조건에 해당하는 사람들의 레코드를 파일로 저장한다)

<b>보안적 측면</b>

보안적 측면으로는 한번에 2장의 복권 발매를 금지합니다. (브라우저를 껏다키면 가능. 쿠키이용)
그리고 success.php 로 곧바로 엑세스할수 없습니다.
db password 를 따로 만들어 include 함.

<b>소스공개</b>

index.html 은 (http://www.lottogame.wo.to 에 오시면 볼수있습니다.)
자바스크립트는 Onlymarch 홈페이지에서 복사하여 용도에맞게 수정해 썼습니다.

<b>DB 스키마</b>

CREATE TABLE lotto (
email varchar(35) NOT NULL,
name varchar(10) NOT NULL,
password varchar(10) NOT NULL,
lotto1 int(2) NOT NULL,
lotto2 int(2) NOT NULL,
lotto3 int(2) NOT NULL,
lotto4 int(2) NOT NULL,
lotto5 int(2) NOT NULL,
lotto6 int(2) NOT NULL
)

<b>소스 URL : http://hirosue.rootguide.com/lotto/success.phps

### success.php ###
### 제작 by Dopesoul ###</b>
<pre>
<?
$where = "$HTTP_POST_VARS[where]";

if ( $where != "right" ) {
echo ("<script>window.alert('올바른곳에서 방문하십시요 Do not Hacking');</script> ");
echo "<meta http-equiv=\"refresh\" content=\"0;url=http://hirosue.rootguide.com/lotto\">";
}

include "password.php";
$connect = @mysql_connect($hostname,$user_id,$password) or die("MySQL-DB Connect<br>Error!!!");
$db = mysql_select_db($dbname);

if(!db) {
echo (" <script>window.alert('db 가 없습니다');</script> ");
}

$email = "$HTTP_POST_VARS[email]";
$name = "$HTTP_POST_VARS[name]";
$password = "$HTTP_POST_VARS[password]";
$checksum = "$HTTP_POST_VARS[checksum]";
$lotto[1] = "$HTTP_POST_VARS[lottov1]";
$lotto[2] = "$HTTP_POST_VARS[lottov2]";
$lotto[3] = "$HTTP_POST_VARS[lottov3]";
$lotto[4] = "$HTTP_POST_VARS[lottov4]";
$lotto[5] = "$HTTP_POST_VARS[lottov5]";
$lotto[6] = "$HTTP_POST_VARS[lottov6]";

//쿠키를 받아온다.
$getcookie = "$HTTP_COOKIE_VARS[selectornot]";

if ( $getcookie == "1" ) {
echo"<script>window.alert('복권 발매는 1회로 한정되어 있습니다.');</script>";
echo "<b>복권 발매는 1회로 한정되어 있습니다.</b>";
}

if ( $getcookie != "1" && $where == "right" ){
Setcookie("selectornot","1","0");
//Cookie
$table="insert into lotto (email,name,password,lotto1,lotto2,lotto3,lotto4,lotto5,lotto6) VALUES ('$email','$name','$password','$lotto[1]','$lotto[2]','$lotto[3]','$lotto[4]','$lotto[5]','$lotto[6]')";
$result = mysql_query($table, $connect) or die ("테이블 생성실패");
echo "<table border=0 width=400>";
echo "<tr>";
echo "<td colspan=6><b>복권이 발매되었습니다. 결과가 Database 에 저장되었습니다.</b></td>";
echo "</tr>";
for($i=1;$i<=6;$i++){
echo "<td width=16% bgcolor=FFE641 align=center>";
echo "<b>".$lotto[$i]."</b>";
echo "</td>";
}
echo "<img src=logo.gif>";
echo "<h1>대박 나시길 바랍니다!</h1><br><br>";

}
?>
</pre>

<b>소스 URL : http://hirosue.rootguide.com/lotto/select.phps
### 추첨기 프로그램 ###</b>
<pre>
<?
// 당첨자 파일 지정
$fp = fopen("/home/dopesoul/public_html/lotto/당첨자.txt","w+");
if(!$fp){
echo "<b>파일오픈 실패</b>";
}
include "password.php";
$connect = @mysql_connect($hostname,$user_id,$password) or die("MySQL-DB Connect<br>Error!!!");
$db = mysql_select_db($dbname);

if(!db) {
echo (" <script>window.alert('db 가 없습니다');</script> ");
}

srand ((double) microtime() * 1000000);
//당첨번호 생성루틴
$dang[0] = rand(1,45);
do { $dang[1] = rand(1,45); } while ( $dang[1] == $dang[0] );
do { $dang[2] = rand(1,45); } while ( $dang[2] == $dang[0] || $dang[2] == $dang[1] );
do { $dang[3] = rand(1,45); } while ( $dang[3] == $dang[0] || $dang[3] == $dang[1] || $dang[3] == $dang[2] );
do { $dang[4] = rand(1,45); } while ( $dang[4] == $dang[0] || $dang[4] == $dang[1] || $dang[4] == $dang[2] || $dang[4] == $dang[3] );
do { $dang[5] = rand(1,45); } while ( $dang[5] == $dang[0] || $dang[5] == $dang[1] || $dang[5] == $dang[2] || $dang[5] == $dang[3] || $dang[5] == $dang[4] );
do { $dang[6] = rand(1,45); } while ( $dang[6] == $dang[0] || $dang[6] == $dang[1] || $dang[6] == $dang[2] || $dang[6] == $dang[3] || $dang[6] == $dang[4] || $dang[6] == $dang[5] );

/*
임현을 기준으로 되어있다.
$dang[0]="1";
$dang[1]="4";
$dang[2]="11";
$dang[3]="17";
$dang[4]="18";
$dang[5]="45";
$dang[6]="25"; // 보너스숫자
*/


?>

<?
//출력 루틴
$query = "select * from lotto";
$result = mysql_query($query);
$fields = mysql_num_fields($result);

$howmany = mysql_num_rows($result);
echo "<b>현재까지 $howmany 명 참여<br></b>";
//당첨번호 출력
echo "컴퓨터가 뽑은 당첨번호는 ";
for($x=0;$x<=6;$x++){

if ($x != 6) {
echo "$dang[$x] ";
}

if ( $x == 6 ) {
echo "보너스 숫자는 $dang[$x]";
}
}
echo " 입니다.";


//당첨번호는 쿠키값이 1이 아닐때만 가동
echo("<table width=100% border=1>\n");
echo("<tr>\n");
// fiend 정보를 읽어온다.
for($i = 0 ; $i < $fields; $i++){
$field_name = mysql_field_name($result,$i);
echo("<td align=center>$field_name</td>\n");
}

// 등위판정칸을 위한 마지막칸
echo "<td align=center> </td>";

//한줄끝냄
echo("</tr>\n");


$num = mysql_num_rows($result);
$detector = "0";
$secondplace = "0";
for ($j=0 ; $j < $num; $j++ ) {
echo("<tr>\n");
$row = mysql_fetch_row($result);

// $fields = 9 까지 이다. 즉, 이메일 이름 비번 로또번호 6자리
for($k=0; $k<$fields ; $k++){

// 테이블컬러 변수 초기화
$tablecolor="";

// 당첨여부로 테이블 색깔결정 및 detector 라는 변수로 당첨판정한다. 그리고 필드 0 1 2 는 판정하지 않는다. 왜냐면 이름과 이메일 비번이니까!
if ( $k!=0 && $k!=1 && $k!=2) {

if ($row[$k] == $dang[0] || $row[$k] == $dang[1] || $row[$k] == $dang[2] || $row[$k] == $dang[3] || $row[$k] == $dang[4] || $row[$k] == $dang[5]) {
$tablecolor="red";
$detector++;
}

// 2등판정 $secondplace 라는 변수로 판정하며 , 1이 2등을 의미하고 0 은 아무것도아님.
if ($detector == 5 && $dang[6] == $row[$k] ){ $secondplace = "1"; }
// 2등판정 끝

}
// 당첨 판정 및 테이블 종류 판정끝.

echo("<td align=center bgcolor=$tablecolor>$row[$k]</td>\n");

}

$file = "";
if ($detector == 6){ $yesno="1등"; $file = "$yesno Email $row[0] 이름 $row[1] 비번 $row[2] 맞춘갯수 $detector\n"; fwrite($fp,$file);}
if ($detector == 5 && $secondplace == "0"){ $yesno="3등"; $file = "$yesno EMAIL $row[0] 이름 $row[1] 비번 $row[2] 맞춘갯수 $detector\n"; fwrite($fp,$file); }

// 위의 3등판정보다 후에있어야 변수내용이 바뀌면서 2등당첨자가 addon 된다. php 의 interpreter 적 요소를 이용함
if ($detector ==5 && $secondplace == "1"){
$yesno="2등";
$file = "$yesno Email $row[0] 이름 $row[1] 비번 $row[2] 맞춘갯수 $detector\n";
fwrite($fp,$file);
}
// 2등판정 끝

if ($detector == 4){ $yesno="4등"; $file = "$yesno EMAIL $row[0] 이름 $row[1] 비번 $row[2] 맞춘갯수 $detector\n"; fwrite($fp,$file); }
if ($detector == 3){ $yesno="5등"; $file = "$yesno EMAIL $row[0] 이름 $row[1] 비번 $row[2] 맞춘갯수 $detector\n"; fwrite($fp,$file); }
if ($detector < 3){ $yesno = "꽝"; }
echo("<td align=center>$yesno <b>$detector 개 맞춤</b></td>");
echo("</tr>\n");
$detector = "0";

}

echo("</table>");

?>
</pre> 
 
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
15년 전 조회 2,642
15년 전 조회 1,467
15년 전 조회 837
15년 전 조회 864
15년 전 조회 1,305
15년 전 조회 1,344
15년 전 조회 1,593
15년 전 조회 1,077
15년 전 조회 1,447
15년 전 조회 736
15년 전 조회 1,096
15년 전 조회 1,349
15년 전 조회 2,764
15년 전 조회 1,131
15년 전 조회 1,103
15년 전 조회 995
15년 전 조회 879
15년 전 조회 887
15년 전 조회 3,480
15년 전 조회 2,858
15년 전 조회 2,033
15년 전 조회 2,479
15년 전 조회 1,562
15년 전 조회 1,110
15년 전 조회 1,108
15년 전 조회 2,395
15년 전 조회 935
15년 전 조회 1,979
15년 전 조회 776
15년 전 조회 1,922
15년 전 조회 858
15년 전 조회 2,531
15년 전 조회 770
15년 전 조회 1,215
15년 전 조회 761
15년 전 조회 2,931
15년 전 조회 1,311
15년 전 조회 1,344
15년 전 조회 1,354
15년 전 조회 1,405
15년 전 조회 1,017
15년 전 조회 1,782
15년 전 조회 1,306
15년 전 조회 886
15년 전 조회 2,749
15년 전 조회 1,133
15년 전 조회 1,336
15년 전 조회 1,134
15년 전 조회 1,989
15년 전 조회 2,001
15년 전 조회 1,652
15년 전 조회 1,010
15년 전 조회 1,242
15년 전 조회 937
15년 전 조회 883
15년 전 조회 1,141
15년 전 조회 2,486
15년 전 조회 2,520
15년 전 조회 1,498
15년 전 조회 1,032
15년 전 조회 1,191
15년 전 조회 1,193
15년 전 조회 1,062
15년 전 조회 962
15년 전 조회 889
15년 전 조회 1,252
15년 전 조회 1,201
15년 전 조회 950
15년 전 조회 928
15년 전 조회 1,108
15년 전 조회 1,563
15년 전 조회 1,096
15년 전 조회 1,424
15년 전 조회 1,259
15년 전 조회 1,929
15년 전 조회 2,993
15년 전 조회 2,334
15년 전 조회 933
15년 전 조회 1,943
15년 전 조회 2,122
15년 전 조회 1,427
15년 전 조회 1,396
15년 전 조회 2,663
15년 전 조회 2,555
15년 전 조회 5,537
15년 전 조회 1,505
15년 전 조회 4,265
15년 전 조회 1,397
15년 전 조회 1,698
15년 전 조회 1,660
15년 전 조회 1,654
15년 전 조회 1,154
15년 전 조회 1,398
15년 전 조회 1,537
15년 전 조회 1,454
15년 전 조회 2,168
15년 전 조회 1,319
15년 전 조회 1,378
15년 전 조회 927
15년 전 조회 1,029