온라인 로또복권

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

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,825
15년 전 조회 1,659
15년 전 조회 1,025
15년 전 조회 1,055
15년 전 조회 1,508
15년 전 조회 1,538
15년 전 조회 1,797
15년 전 조회 1,292
15년 전 조회 1,663
15년 전 조회 933
15년 전 조회 1,296
15년 전 조회 1,569
15년 전 조회 2,945
15년 전 조회 1,341
15년 전 조회 1,318
15년 전 조회 1,191
15년 전 조회 1,091
15년 전 조회 1,091
15년 전 조회 3,693
15년 전 조회 3,071
15년 전 조회 2,241
15년 전 조회 2,677
15년 전 조회 1,779
15년 전 조회 1,319
15년 전 조회 1,311
15년 전 조회 2,611
15년 전 조회 1,143
15년 전 조회 2,196
15년 전 조회 986
15년 전 조회 2,143
15년 전 조회 1,079
15년 전 조회 2,754
15년 전 조회 1,001
15년 전 조회 1,428
15년 전 조회 980
15년 전 조회 3,220
15년 전 조회 1,560
15년 전 조회 1,568
15년 전 조회 1,593
15년 전 조회 1,651
15년 전 조회 1,241
15년 전 조회 2,001
15년 전 조회 1,548
15년 전 조회 1,124
15년 전 조회 3,002
15년 전 조회 1,363
15년 전 조회 1,578
15년 전 조회 1,352
15년 전 조회 2,212
15년 전 조회 2,232
15년 전 조회 1,875
15년 전 조회 1,242
15년 전 조회 1,483
15년 전 조회 1,148
15년 전 조회 1,116
15년 전 조회 1,363
15년 전 조회 2,738
15년 전 조회 2,756
15년 전 조회 1,735
15년 전 조회 1,262
15년 전 조회 1,428
15년 전 조회 1,412
15년 전 조회 1,318
15년 전 조회 1,187
15년 전 조회 1,116
15년 전 조회 1,474
15년 전 조회 1,428
15년 전 조회 1,196
15년 전 조회 1,158
15년 전 조회 1,331
15년 전 조회 1,803
15년 전 조회 1,335
15년 전 조회 1,650
15년 전 조회 1,483
15년 전 조회 2,208
15년 전 조회 3,223
15년 전 조회 2,577
15년 전 조회 1,150
15년 전 조회 2,158
15년 전 조회 2,368
15년 전 조회 1,663
15년 전 조회 1,627
15년 전 조회 2,902
15년 전 조회 2,817
15년 전 조회 5,822
15년 전 조회 1,750
15년 전 조회 4,547
15년 전 조회 1,642
15년 전 조회 1,907
15년 전 조회 1,895
15년 전 조회 1,886
15년 전 조회 1,378
15년 전 조회 1,620
15년 전 조회 1,772
15년 전 조회 1,677
15년 전 조회 2,388
15년 전 조회 1,552
15년 전 조회 1,671
15년 전 조회 1,149
15년 전 조회 1,250