<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

include_once( "inc/conn.php" );
include_once( "inc/function.php" );
login_check( );
$query = $db->query( "Select id from ".$web_dbtop."game11 where kj=0 Order by id asc" );
if ( $rs = $db->fetch_array( $query ) )
{
		$kgqh = $rs['id'];
}
$query = $db->query( "Select id from ".$web_dbtop."game11_auto where uid=".intval( $_COOKIE['usersid'] )." Order by id desc" );
if ( $rs = $db->fetch_array( $query ) )
{
		echo "<script language=javascript>location.href='joyousautodetail.php';</script>";
		exit( );
}
if ( $_GET['act'] == "autostart" )
{
		if ( !$_POST['tbID'] )
		{
				echo "<script language=javascript>alert('对不起,请先添加投注模式！');location.href='joyousmodel.php';</script>";
				exit( );
		}
		if ( $_POST['tbStartNO'] < $kgqh + 1 )
		{
				echo "<script language=javascript>alert('对不起,开始期数必须大于当前期数两期！');history.go(-1);</script>";
				exit( );
		}
		if ( $_POST['tbEndNO'] < $_POST['tbStartNO'] )
		{
				echo "<script language=javascript>alert('对不起,结束期数不能小于开始期数！');history.go(-1);</script>";
				exit( );
		}
		if ( 3000 < $_POST['tbEndNO'] - $_POST['tbStartNO'] )
		{
				echo "<script language=javascript>alert('对不起,最大总自动投注期数为3000期！');history.go(-1);</script>";
				exit( );
		}
		if ( $_POST['tbMinG'] < 0 )
		{
				echo "<script language=javascript>alert('对不起,帐户".$web_moneyname."最小值不能小于0！');history.go(-1);</script>";
				exit( );
		}
		if ( $_POST['tbMaxG'] < 0 )
		{
				echo "<script language=javascript>alert('对不起,帐户".$web_moneyname."最大值不能小于0！');history.go(-1);</script>";
				exit( );
		}
		$db->query( "INSERT INTO ".$web_dbtop."game11_auto (startNO,endNO,minG,maxG,autoid,uid) VALUES (".intval( $_POST['tbStartNO'] ).",".intval( $_POST['tbEndNO'] ).",".intval( $_POST['tbMinG'] ).",".intval( $_POST['tbMaxG'] ).",".intval( $_POST['tbID'] ).",".intval( $_COOKIE['usersid'] ).")" );
		$i = 0;
		for ( ;	$i < count( $_POST['sID'] );	++$i	)
		{
				$db->query( "update ".$web_dbtop."game11_auto_tz set winid=".intval( $_POST['sWinModel'][$i] ).",lossid=".intval( $_POST['sLossModel'][$i] )." where id =".intval( $_POST['sID'][$i] ) );
		}
		echo "<script language=javascript>alert('自动投注设置成功！');location.href='joyousautodetail.php';</script>";
		exit( );
}
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\">\r\n<HTML xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<title>欢乐11-游戏中心-";
echo $web_name;
echo "</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\r\n<meta name=\"keywords\" content=\"";
echo $web_keywords;
echo "\" />\r\n<meta name=\"description\" content=\"";
echo $web_description;
echo "\" />\r\n<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>\r\n<link href=\"style/default.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n</head>\r\n";
include_once( "top.php" );
echo "<script language=\"javascript\">\r\nqiehuan(2);\r\ndocument.getElementById(\"qh_con2\").getElementsByTagName('li')[4].className=\"current\";</script>\r\n<DIV class=\"wrapper\">\r\n\t<DIV class=\"page_content\">\r\n\t\t<DIV class=\"webgame-info-title\">\r\n\t\t  <UL>\r\n\t\t\t<LI><A href=\"joyous.php\">欢乐11首页</A></LI>\r\n\t\t\t<LI><A href=\"joyoushelp.php\">欢乐11规则</A></LI>\r\n\t\t\t<LI><A href=\"joyousmylist.php\">我的投注记录</A></LI>\r\n\t\t\t<LI><A href=\"joyousmodel.php\">投注模式编辑</A></LI>\r\n\t\t\t<LI class=\"current\"><A href=\"joyousautoset.php\">自动投注</A></LI>\r\n\t\t\t<LI><A href=\"joyousdirection.php\">欢乐11走势图</A></LI>\r\n\t\t  </UL>\r\n\t\t</DIV>\r\n\t\t<DIV class=\"webgame-info\">\r\n\t\t\t<DIV class=\"webgame-info-tabs\">\r\n\t\t\t  <table width=\"940\" height=\"27\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\r\n                <tr>\r\n                  <td width=\"12\"><img src=\"images/game2_03.jpg\" width=\"12\" height=\"27\" /></td>\r\n                  <td background=\"images/game2_04.jpg\" class=\"font14\">自动投注设置:</td>\r\n                  <td width=\"13\"><img src=\"images/game2_06.jpg\" width=\"13\" height=\"27\" /></td>\r\n                </tr>\r\n              </table>\r\n\t\t\t  <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n                <tr>\r\n                  <td height=\"5\"></td>\r\n                </tr>\r\n              </table>\r\n\t\t\t  <form action=\"?act=autostart\" method=\"post\" onsubmit=\"return ChkSetAuto()\">\r\n                <table width=\"940\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\r\n                  <tr>\r\n                    <td bgcolor=\"#FFB91F\"><table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\">\r\n                        <tr>\r\n                          <td width=\"25%\" height=\"28\" align=\"right\" bgcolor=\"#FFFFFF\">请选择使用的投注模式：</td>\r\n                          <td bgcolor=\"#FFFFFF\"><strong>\r\n                            <select name=\"tbID\">\r\n                              ";
$query = $db->query( "Select * from ".$web_dbtop."game11_auto_tz where uid=".intval( $_COOKIE['usersid'] )." Order by tzid asc" );
while ( $rs = $db->fetch_array( $query ) )
{
		echo "                              <option label=\"";
		echo $rs['tzname'];
		echo "\" value=\"";
		echo $rs['id'];
		echo "\">\r\n                              ";
		echo $rs['tzname'];
		echo "                              </option>\r\n                              ";
}
echo "                            </select>\r\n                          </strong></td>\r\n                        </tr>\r\n                        <tr>\r\n                          <td height=\"28\" align=\"right\" bgcolor=\"#FFFFFF\">自动投注开始期数：</td>\r\n                          <td bgcolor=\"#FFFFFF\"><input type=\"text\" name=\"tbStartNO\" id=\"tbStartNO\" value=\"";
echo $kgqh + 2;
echo "\" />\r\n                            开始期数必须大于当前期数（\r\n                              ";
echo $kgqh + 1;
echo "                              ） </td>\r\n                        </tr>\r\n                        <tr>\r\n                          <td height=\"28\" align=\"right\" bgcolor=\"#FFFFFF\">自动投注结束期数：</td>\r\n                          <td bgcolor=\"#FFFFFF\"><input type=\"text\" name=\"tbEndNO\" id=\"tbEndNO\" value=\"";
echo $kgqh + 3001;
echo "\" />\r\n                            最大总自动投注期数为3000期 </td>\r\n                        </tr>\r\n                        <tr>\r\n                          <td height=\"28\" align=\"right\" bgcolor=\"#FFFFFF\">帐户";
echo $web_moneyname;
echo "最小值：</td>\r\n                          <td bgcolor=\"#FFFFFF\"><input name=\"tbMinG\" type=\"text\" id=\"tbMinG\" value=\"0\" />\r\n                            当帐户";
echo $web_moneyname;
echo "小于此数时自动停止投注。</td>\r\n                        </tr>\r\n                        <tr>\r\n                          <td height=\"28\" align=\"right\" bgcolor=\"#FFFFFF\">帐户";
echo $web_moneyname;
echo "最大值：</td>\r\n                          <td bgcolor=\"#FFFFFF\"><input type=\"text\" name=\"tbMaxG\" id=\"tbMaxG\" value=\"0\" />\r\n                            当帐户";
echo $web_moneyname;
echo "大于此数时自动停止投注。</td>\r\n                        </tr>\r\n                        <tr>\r\n                          <td height=\"85\" colspan=\"2\" align=\"center\" bgcolor=\"#FFFFFF\" class=\"rf\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"3\">\r\n                              <tr>\r\n                                <td width=\"23%\" align=\"center\" class=\"rf\">投注模式</td>\r\n                                <td width=\"24%\" align=\"center\" class=\"rf\">投注";
echo $web_moneyname;
echo "</td>\r\n                                <td width=\"28%\" align=\"center\" class=\"rf\">赢后使用的投注模式</td>\r\n                                <td width=\"25%\" align=\"center\" class=\"rf\">输后使用的投注模式</td>\r\n                              </tr>\r\n                              ";
$i = 0;
$query_f = $db->query( "Select * from ".$web_dbtop."game11_auto_tz where uid=".intval( $_COOKIE['usersid'] )." Order by tzid asc" );
while ( $rs_f = $db->fetch_array( $query_f ) )
{
		echo "                              <tr>\r\n                                <td align=\"center\"><input type=\"hidden\" name=\"sID[]\" id=\"sID";
		echo $i;
		echo "\" value=\"";
		echo $rs_f['id'];
		echo "\" />\r\n                                    ";
		echo $rs_f['tzname'];
		echo "</td>\r\n                                <td align=\"center\">";
		echo $rs_f['tzpoints'];
		echo "</td>\r\n                                <td align=\"center\"><select name=\"sWinModel[]\" id=\"sWinModel";
		echo $i;
		echo "\">\r\n                                    ";
		$query = $db->query( "Select * from ".$web_dbtop."game11_auto_tz where uid=".intval( $_COOKIE['usersid'] )." Order by tzid asc" );
		while ( $rs = $db->fetch_array( $query ) )
		{
				echo "                                    <option label=\"";
				echo $rs['tzname'];
				echo "\" value=\"";
				echo $rs['id'];
				echo "\">\r\n                                    ";
				echo $rs['tzname'];
				echo "                                    </option>\r\n                                    ";
		}
		echo "                                  </select>\r\n                                </td>\r\n                                <td align=\"center\"><select name=\"sLossModel[]\" id=\"sLossModel";
		echo $i;
		echo "\">\r\n                                    ";
		$query = $db->query( "Select * from ".$web_dbtop."game11_auto_tz where uid=".intval( $_COOKIE['usersid'] )." Order by tzid asc" );
		while ( $rs = $db->fetch_array( $query ) )
		{
				echo "                                    <option label=\"";
				echo $rs['tzname'];
				echo "\" value=\"";
				echo $rs['id'];
				echo "\">\r\n                                    ";
				echo $rs['tzname'];
				echo "                                    </option>\r\n                                    ";
		}
		echo "                                  </select>\r\n                                </td>\r\n                              </tr>\r\n                              ";
		++$i;
}
echo "                            </table>\r\n                              <br />\r\n                              <input name=\"image\" type=\"image\" id=\"btnSubmit\" src=\"images/joyous11_01.gif\" width=\"115\" height=\"29\" border=\"0\" />\r\n                &nbsp;<img src=\"images/joyous11_02.gif\" width=\"115\" height=\"29\" border=\"0\" class=\"pointer\" onclick=\"javascript:history.back()\" /></td>\r\n                        </tr>\r\n                        <tr>\r\n                          <td height=\"28\" colspan=\"2\" align=\"left\" valign=\"top\" bgcolor=\"#FFFFFF\"><p >设置方法：<br />\r\n                1．选择投注模式<br />\r\n                2．设置自动投注开始与结束的期号<br />\r\n                3．设置帐户";
echo $web_moneyname;
echo "最小值<br />\r\n                4．确认并开始自动投注后，系统将会在你指定的期数内帮您自动投注，不论你的离线或在线都会持续运 行直到期数终止或您关闭为止。<br />\r\n                5．银行内所存";
echo $web_moneyname;
echo "不能用于投注 </p></td>\r\n                        </tr>\r\n                    </table></td>\r\n                  </tr>\r\n                </table>\r\n\t\t      </form>\r\n\t\t\t  <script type=\"text/javascript\">\r\n\t\t\t\t<!--\r\n\t\t\t\tfunction ChkSetAuto(){\r\n\t\t\t\t\tvar s = parseInt(\"\");\r\n\t\t\t\t\tvar starLuckNO = parseInt(document.getElementById(\"tbStarLuckNO\").value);\r\n\t\t\t\t\tvar endLuckNO = parseInt(document.getElementById(\"tbEndLuckNO\").value);\r\n\t\t\t\t\tvar minMoney = parseInt(document.getElementById(\"tbMinMoney\").value);\r\n\t\t\t\t\tif(ChkInt(starLuckNO,1,10)==false || starLuckNO < s){\r\n\t\t\t\t\t\talert(\"开始投注期数格式错误！\");\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(ChkInt(endLuckNO,1,10)==false || endLuckNO > s+2999 || endLuckNO <= starLuckNO){\r\n\t\t\t\t\t\talert(\"结束投注期数格式错误！\");\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(ChkInt(minMoney,1,10,\"[0-9]+\")==false){\r\n\t\t\t\t\t\talert(\"";
echo $web_moneyname;
echo "最小值格式错误！\");\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tdocument.getElementById(\"btnSubmit\").disabled=true;\r\n\t\t\t\t}\r\n\t\t\t\tfunction ResetModel(t){\r\n\t\t\t\t\tfor(i=0;i<t;i++){\r\n\t\t\t\t\t\tdocument.getElementById(\"sWinModel\"+i).selectedIndex = GetSIndex(\"sWinModel\"+i,document.getElementById(\"sID\"+i).value);\r\n\t\t\t\t\t\tdocument.getElementById(\"sLossModel\"+i).selectedIndex = GetSIndex(\"sLossModel\"+i,document.getElementById(\"sID\"+i).value);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tfunction GetSIndex(obj,v){\r\n\t\t\t\t\tvar l = document.getElementById(obj).options.length;\r\n\t\t\t\t\tfor(o=0;o<l;o++){\r\n\t\t\t\t\t\tif(document.getElementById(obj).options[o].value == v){\r\n\t\t\t\t\t\t\treturn o;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\t\t\t\tResetModel('";
echo $i;
echo "');\r\n\t\t\t\t-->\r\n\t\t\t\t</script>\r\n\t\t\t</DIV>\r\n\t\t\t<DIV class=cl></DIV>\r\n\t\t</DIV>\r\n\t\t<DIV class=\"area960-b h5px\"></DIV>\r\n\t<!--Flink End-->\r\n\t<div class=\"blank10\"></div>\r\n\t<!--Footer Start-->\r\n";
include_once( "footer.php" );
echo "</DIV>";
?>
