온라인 로또복권

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

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,705
15년 전 조회 1,529
15년 전 조회 901
15년 전 조회 923
15년 전 조회 1,372
15년 전 조회 1,396
15년 전 조회 1,664
15년 전 조회 1,150
15년 전 조회 1,528
15년 전 조회 811
15년 전 조회 1,153
15년 전 조회 1,423
15년 전 조회 2,815
15년 전 조회 1,195
15년 전 조회 1,172
15년 전 조회 1,062
15년 전 조회 945
15년 전 조회 949
15년 전 조회 3,551
15년 전 조회 2,922
15년 전 조회 2,101
15년 전 조회 2,541
15년 전 조회 1,631
15년 전 조회 1,185
15년 전 조회 1,186
15년 전 조회 2,460
15년 전 조회 999
15년 전 조회 2,041
15년 전 조회 848
15년 전 조회 1,996
15년 전 조회 932
15년 전 조회 2,603
15년 전 조회 851
15년 전 조회 1,280
15년 전 조회 828
15년 전 조회 3,006
15년 전 조회 1,392
15년 전 조회 1,402
15년 전 조회 1,414
15년 전 조회 1,482
15년 전 조회 1,078
15년 전 조회 1,847
15년 전 조회 1,375
15년 전 조회 956
15년 전 조회 2,836
15년 전 조회 1,208
15년 전 조회 1,407
15년 전 조회 1,199
15년 전 조회 2,049
15년 전 조회 2,067
15년 전 조회 1,717
15년 전 조회 1,071
15년 전 조회 1,315
15년 전 조회 1,007
15년 전 조회 952
15년 전 조회 1,206
15년 전 조회 2,565
15년 전 조회 2,588
15년 전 조회 1,566
15년 전 조회 1,100
15년 전 조회 1,265
15년 전 조회 1,267
15년 전 조회 1,135
15년 전 조회 1,029
15년 전 조회 971
15년 전 조회 1,321
15년 전 조회 1,280
15년 전 조회 1,027
15년 전 조회 992
15년 전 조회 1,169
15년 전 조회 1,643
15년 전 조회 1,170
15년 전 조회 1,497
15년 전 조회 1,334
15년 전 조회 2,006
15년 전 조회 3,066
15년 전 조회 2,405
15년 전 조회 1,004
15년 전 조회 2,006
15년 전 조회 2,203
15년 전 조회 1,504
15년 전 조회 1,463
15년 전 조회 2,744
15년 전 조회 2,634
15년 전 조회 5,610
15년 전 조회 1,571
15년 전 조회 4,351
15년 전 조회 1,466
15년 전 조회 1,746
15년 전 조회 1,728
15년 전 조회 1,729
15년 전 조회 1,228
15년 전 조회 1,467
15년 전 조회 1,608
15년 전 조회 1,521
15년 전 조회 2,240
15년 전 조회 1,379
15년 전 조회 1,451
15년 전 조회 997
15년 전 조회 1,087