온라인 로또복권

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

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>&nbsp;</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,602
15년 전 조회 1,413
15년 전 조회 782
15년 전 조회 813
15년 전 조회 1,254
15년 전 조회 1,287
15년 전 조회 1,543
15년 전 조회 1,028
15년 전 조회 1,396
15년 전 조회 694
15년 전 조회 1,041
15년 전 조회 1,299
15년 전 조회 2,710
15년 전 조회 1,075
15년 전 조회 1,051
15년 전 조회 953
15년 전 조회 830
15년 전 조회 840
15년 전 조회 3,434
15년 전 조회 2,800
15년 전 조회 1,979
15년 전 조회 2,426
15년 전 조회 1,519
15년 전 조회 1,061
15년 전 조회 1,057
15년 전 조회 2,336
15년 전 조회 883
15년 전 조회 1,923
15년 전 조회 722
15년 전 조회 1,876
15년 전 조회 812
15년 전 조회 2,483
15년 전 조회 729
15년 전 조회 1,163
15년 전 조회 713
15년 전 조회 2,881
15년 전 조회 1,256
15년 전 조회 1,289
15년 전 조회 1,301
15년 전 조회 1,360
15년 전 조회 967
15년 전 조회 1,726
15년 전 조회 1,258
15년 전 조회 839
15년 전 조회 2,699
15년 전 조회 1,088
15년 전 조회 1,284
15년 전 조회 1,084
15년 전 조회 1,935
15년 전 조회 1,946
15년 전 조회 1,601
15년 전 조회 954
15년 전 조회 1,193
15년 전 조회 890
15년 전 조회 837
15년 전 조회 1,084
15년 전 조회 2,442
15년 전 조회 2,466
15년 전 조회 1,438
15년 전 조회 988
15년 전 조회 1,144
15년 전 조회 1,147
15년 전 조회 1,013
15년 전 조회 911
15년 전 조회 843
15년 전 조회 1,202
15년 전 조회 1,154
15년 전 조회 901
15년 전 조회 873
15년 전 조회 1,049
15년 전 조회 1,514
15년 전 조회 1,049
15년 전 조회 1,371
15년 전 조회 1,215
15년 전 조회 1,888
15년 전 조회 2,948
15년 전 조회 2,282
15년 전 조회 881
15년 전 조회 1,888
15년 전 조회 2,076
15년 전 조회 1,380
15년 전 조회 1,353
15년 전 조회 2,616
15년 전 조회 2,505
15년 전 조회 5,491
15년 전 조회 1,457
15년 전 조회 4,219
15년 전 조회 1,349
15년 전 조회 1,644
15년 전 조회 1,611
15년 전 조회 1,605
15년 전 조회 1,106
15년 전 조회 1,354
15년 전 조회 1,495
15년 전 조회 1,399
15년 전 조회 2,126
15년 전 조회 1,271
15년 전 조회 1,325
15년 전 조회 872
15년 전 조회 985
🐛 버그신고