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

include_once( "inc/conn.php" );
include_once( "inc/function.php" );
login_check( );
if ( $_GET['act'] == "modelsave" )
{
		$tzmodel_array = array( );
		$query = $db->query( "Select tznum,tzpoints,points from ".$web_dbtop."game11_users_tz where NO=".intval( $_GET['joyousno'] )." and uid=".intval( $_COOKIE['usersid'] )." Order by id desc" );
		if ( $rs = $db->fetch_array( $query ) )
		{
				$tznum = explode( "|", $rs['tznum'] );
				$tzpoints_array = explode( "|", $rs['tzpoints'] );
				$tzpoints = $rs['points'];
		}
		$i = 0;
		for ( ;	$i < 11;	++$i	)
		{
				$tzmodel_array[$i] = 0;
				$y = 0;
				for ( ;	$y < count( $tznum );	++$y	)
				{
						if ( $tznum[$y] == $i + 2 )
						{
								$tzmodel_array[$i] = $tzpoints_array[$y];
						}
				}
		}
		$tznum = implode( "|", $tzmodel_array );
		if ( $_POST['tbID'] )
		{
				$db->query( "update ".$web_dbtop."game11_auto_tz set tzname='".str_check( $_POST['tbModelName'] )."',tzunm='".$tznum.( "',tzpoints=".$tzpoints." where id =" ).intval( $_POST['tbID'] ) );
		}
		else
		{
				$db->query( "INSERT INTO ".$web_dbtop."game11_auto_tz (uid,tzname,tzunm,tzpoints,tzid) VALUES (".intval( $_COOKIE['usersid'] ).",'".str_check( $_POST['tbModelName'] )."','".$tznum.( "',".$tzpoints."," ).intval( $_POST['tbModelID'] ).")" );
		}
		echo "<script language=javascript>alert('投注模式保存成功！');location.href='joyousmodelsave.php?joyousno=".$_GET['joyousno']."';</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 class=\"current\"><A href=\"joyousmodel.php\">投注模式编辑</A></LI>\r\n\t\t\t<LI><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\">\t\t  \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  <table width=\"940\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\r\n                <tr>\r\n                  <td bgcolor=\"#FFB91F\"><form action=\"?act=modelsave&joyousno=";
echo $_GET['joyousno'];
echo "\" method=\"post\">\r\n                      <input name=\"tbID\" id=\"hidID\" type=\"hidden\" value=\"\" />\r\n                      <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\">\r\n                        <tr>\r\n                          <td width=\"40%\" height=\"28\" align=\"right\" bgcolor=\"#FFFFFF\">请选择保存的投注模式名称：</td>\r\n                          <td width=\"60%\" bgcolor=\"#FFFFFF\"><select name=\"tbModelID\" id=\"tbModelID\" onchange=\"chgModel(this.selectedIndex)\">\r\n                              ";
$tzname = array( "投注模式一", "投注模式二", "投注模式三", "投注模式四", "投注模式五", "投注模式六", "投注模式七", "投注模式八", "投注模式九", "投注模式十", "投注模式十一", "投注模式十二", "投注模式十三", "投注模式十四", "投注模式十五", "投注模式十六", "投注模式十七", "投注模式十八", "投注模式十九", "投注模式二十", "投注模式二一", "投注模式二二", "投注模式二三", "投注模式二四", "投注模式二五", "投注模式二六", "投注模式二七", "投注模式二八", "投注模式二九", "投注模式三十", "投注模式三一", "投注模式三二", "投注模式三三", "投注模式三四", "投注模式三五", "投注模式三六", "投注模式三七", "投注模式三八", "投注模式三九", "投注模式四十" );
$i = 1;
foreach ( $tzname as $tzarray )
{
		$query = $db->query( "Select tzname,tzid from ".$web_dbtop."game11_auto_tz where uid=".intval( $_COOKIE['usersid'] ).( " and tzid=".$i." Order by tzid asc" ) );
		if ( $rs = $db->fetch_array( $query ) )
		{
				echo "<option label=\"".$rs['tzname']."\" value=\"".$i."\">".$rs['tzname']."</option>";
		}
		else
		{
				echo "<option label=\"".$tzarray."\" value=\"".$i."\">".$tzarray."</option>";
		}
		++$i;
}
echo "                          </select></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=\"tbModelName\" id=\"tbModelName\" value=\"\"/></td>\r\n                        </tr>\r\n                        <tr>\r\n                          <td height=\"28\" colspan=\"2\" align=\"center\" valign=\"top\" bgcolor=\"#FFFFFF\"><input value=\" 保  存 \" type=\"submit\" id=\"btnSubmit\" /></td>\r\n                        </tr>\r\n                      </table>\r\n                  </form></td>\r\n                </tr>\r\n              </table>\r\n\t\t\t  ";
$game11tz_array = array( );
$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 ) )
{
		$game11tz_array[] = "{\"ID\":\"".$rs['id']."\",\"modelID\":\"".$rs['tzid']."\",\"modelName\":\"".$rs['tzname']."\"}";
}
$tzjs = implode( ",", $game11tz_array );
echo "\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t<!--\r\n\t\t\t\tfunction chgModel(index){\r\n\t\t\t\t\tvar modelID = document.getElementById(\"tbModelID\").options[index].value;\r\n\t\t\t\t\tdocument.getElementById(\"hidID\").value = '';\r\n\t\t\t\t\tvar flag = false;\r\n\t\t\t\t\tvar result = {\"arrJsonModel\":[";
echo $tzjs;
echo "]};\r\n\t\t\t\t\tif(result.arrJsonModel != null){\r\n\t\t\t\t\t\tdocument.getElementById(\"tbModelName\").value = document.getElementById(\"tbModelID\").options[index].text;\t\r\n\t\t\t\t\t\tfor(i=0;i<result.arrJsonModel.length;i++){\r\n\t\t\t\t\t\t\tif(result.arrJsonModel[i].modelID==modelID){\r\n\t\t\t\t\t\t\t\tflag = true;\r\n\t\t\t\t\t\t\t\tindex = i;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif(flag){\r\n\t\t\t\t\t\t\tdocument.getElementById(\"hidID\").value = result.arrJsonModel[index].ID;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tchgModel(0);\r\n\t\t\t\t-->\r\n\t\t\t\t</script>\r\n\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>";
?>
