<?php
#### สคริ๊ปนี้ใช้ในการเช็ค ว่าล็อกอินหรือยัง ให้นำสคริ๊ปนี้ไปไว้ที่หน้าที่คุณต้องการให้เช็ค ####
session_start() ;

if(session_is_registered("login_true_admin")) {
      //$usern = $_SESSION["login_true_admin"];
      $usern = "Administator";
	  $mlevel=3 ;
}elseif(session_is_registered("login_true")){
      $usern = $_SESSION["login_true"];
      $mlevel = $_SESSION["member_level"];	  
	 // if($mlevel <1)$mlevel=1;
}else{
//      $usern = "offline";
//	  $mlevel=-1; 
      $usern = "offline1";
	  $mlevel=1; 
	  
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>ห้างขายทอง ทองใบเยาวราช</title>
<!-- InstanceEndEditable -->
<SCRIPT src="swfobject.js"  type=text/javascript></SCRIPT>
<SCRIPT  src="DynamicOptionList.js"></SCRIPT>

<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {
	font-family: "MS Sans Serif", Arial, Tahoma;
	font-size: 14px;
}
.style3 {color: #000000}
.style9 {
	font-family: "MS Sans Serif", Arial, Tahoma;
	font-size: 18px;
	color: #FF0000;
}
.style10 {
	font-size: 12px;
	font-family: "MS Sans Serif", Arial, Tahoma;
}
.style11 {font-size: 24px}
.style14 {font-family: "MS Sans Serif", Arial, Tahoma; font-size: 18px; color: #FF0000; font-weight: bold; }
.style15 {
	color: #FF0000;
	font-weight: bold;
}
.style16 {font-family: "MS Sans Serif", Arial, Tahoma; font-size: 24px; color: #FF0000; font-weight: bold; }
-->
</style>
<!-- InstanceBeginEditable name="head" -->
<style type="text/css">
<!--
.style30 {color: #FF3300}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<!-- InstanceEndEditable -->
<link href="main.css" rel="stylesheet" type="text/css" />
</head>

<?php 
     if($snd==0) $sn=0; else  $sn=1;
	 echo "<script >sn=$sn;</script >";
?>

<?php 
$nd=date("w ") ;
switch ($nd)
{
case 0 :
$bgc="images/bg_red";
break;  
case 1:
$bgc="images/bg_yel";
break;
case 2:
$bgc="images/bg_pink";
break;
case 3:
$bgc="images/bg_gre";
break;
case 4:
$bgc="images/bg_ora";
break;
case 5:
$bgc="images/bg_blue";
break;
case 6:
$bgc="images/bg_vio";
break;
default:
$bgc="images/bg_whi";
}
?>


<SCRIPT LANGUAGE="JavaScript">
<!--
function setCookie(name, value)
{
  document.cookie = name+"="+value;
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function myGetCookie(name)
{
  if (document.cookie)
  {
    var cookies=document.cookie.split(";");
    for (var i=0; i<cookies.length; i++)
    {
      var varName=(cookies[i].split("=")[0]);
      var varValue=(cookies[i].split("=")[1]);

      while (varName.charAt(0)==" ")
        varName=varName.substr(1,varName.length);

      // the escape() function will url encode the value				
      if (varName==name)
        return escape(varValue);
    }
  }
  return " ";
}
//-->
</SCRIPT>

<body onload=initDynamicOptionLists();   background="<?php   printf("%s_01.jpg ",$bgc);    ?>">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><table width="100" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="33" background="<?php   printf("%s_02.jpg ",$bgc);    ?>"><img src="images/space.gif" width="33" height="33" /></td>
        <td valign="top"><table width="853" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr>
            <td height="20" align="right" bgcolor="#968001"><table border="0" cellspacing="2" cellpadding="0">
                <form id="form1" name="form1" method="post" action="member/login_check2.php">
                  <tr>
                    <td class="txt1"><?php		  
if($usern == "offline")		  
{
       echo "ขออภัยท่านไม่สามารถดูสินค้าได้ เนื่องจากท่านยังไม่ได้เป็นสมาชิก <strong> สมาชิกทั่วไป </strong>และ <strong>สมาชิก VIP</strong> เท่านั้นที่สามารถดูสินค้าได้ กรุณาสมัครสมาชิกก่อน <a href=\"http://www.aiyaree.com/khunhua/member/signup.php\" target=\"_blank\">(สมัครสมาชิกใหม่)</a>"; 
}elseif($mlevel<1 ){
       echo "ขออภัยท่านไม่สามารถดูสินค้าได้เพราะสถานะสมาชิกรอการยื่นยัน<strong> สมาชิกทั่วไป </strong>และ <strong>สมาชิก VIP</strong> เท่านั้นที่สามารถดูสินค้าได้"; 
}else{
if ($usern <> "offline1") echo "คุณ $usern";
if($mlevel==2)
{
echo " | <a href=\"chkcart.php\"> <font color=ffffee> ตรวจสอบสินค้าในตะกร้า </font> </a> | <a href=\"logout.php\"> <font color=ffffee> Logout </font> </a> ";
}
}
if ($usern == "offline1") {
?></td>
                    <td ><span class="txt1"><strong>Member</strong></span></td>
                    <td class="txt2" >::</td>
                    <td class="txt2">Username</td>
                    <td><input name="user_login" type="text" id="user_login" size="15" /></td>
                    <td >&nbsp;</td>
                    <td ><span class="txt2">Password</span></td>
                    <td><input name="pwd_login" type="password" id="pwd_login" size="15" /></td>
                    <td><input type="submit" name="Submit" value="SignIn" /></td>
                    <td >&nbsp;<a href="Templates/member/signup.php" target="_blank" > <font color="#ffffee"> (สมัครสมาชิกใหม่) </font> </a>
                        <?php }  ?>                    </td>
                  </tr>
                </form>
            </table></td>
          </tr>
          <tr>
            <td width="853" height="376" background="images/gold3_03.jpg">
<DIV align="center" id=flashContent> <font color="#ffffff">T</font><span class="style3">his site requires <a href="http://www.adobe.com/go/getflashplayer" target="_blank">Flash Player 8</a> and Javascript.</span><br>
</DIV>

            <SCRIPT type=text/javascript>
			var so = new SWFObject("head05.swf", "flash", "853", "376", "8", "#ffff88");
			so.addParam("allowscriptaccess", "always");
			so.addParam("allowscriptaccess", "always");
            so.addVariable('n', sn);
            so.addVariable('b01', '9');
			so.addVariable('d','<?php echo $d0 ?>');
			so.addVariable('d2','<?php echo $d11 ?>');
			so.addVariable('d1','<?php echo $d10 ?>');
			so.addVariable('m','<?php echo $m ?>');
			so.addVariable('y2','<?php echo $y1[0] ?>');
			so.addVariable('y1','<?php echo $y11 ?>');
			so.addVariable('s5','<?php echo $sB[0] ?>');
			so.addVariable('s4','<?php echo $sB[1] ?>');
			so.addVariable('s3','<?php echo $sB[2] ?>');
			so.addVariable('s2','<?php echo $sB[3] ?>');
			so.addVariable('s1','<?php echo $sB[4] ?>');
			so.addVariable('b5','<?php echo $bB[0] ?>');
			so.addVariable('b4','<?php echo $bB[1] ?>');
			so.addVariable('b3','<?php echo $bB[2] ?>');
			so.addVariable('b2','<?php echo $bB[3] ?>');
			so.addVariable('b1','<?php echo $bB[4] ?>');
			
			so.write("flashContent");
			</SCRIPT>		</td>
          </tr>
          <tr>
            <td height="30" background="images/bg_02.jpg"></td>
          </tr>
          <tr>
            <td background="images/bg_01.jpg"><!-- InstanceBeginEditable name="EditRegion1" -->
                <table width="100%" cellspacing="15" cellpadding="0">
                <tr>
                  <td><table width="100%" cellspacing="2" cellpadding="0">
                    <tr>
                      <td width="34%" align="left"><span class="style30">
                        <?php		  
if($usern == "offline")		  
{
       echo "ขออภัยท่านไม่สามารถดูสินค้าได้ เนื่องจากท่านยังไม่ได้เป็นสมาชิก <strong> สมาชิกทั่วไป </strong>และ <strong>สมาชิก VIP</strong> เท่านั้นที่สามารถดูสินค้าได้ กรุณาสมัครสมาชิกก่อน <a href=\"http://www.thongbai.com/member/signup.php\" target=\"_blank\">(สมัครสมาชิกใหม่)</a>"; 
}elseif($mlevel<1 ){
       echo "ขออภัยท่านไม่สามารถดูสินค้าได้เพราะสถานะสมาชิกรอการยื่นยัน<strong> สมาชิกทั่วไป </strong>และ <strong>สมาชิก VIP</strong> เท่านั้นที่สามารถดูสินค้าได้"; 
}else{

echo "คุณ $usern ";
?>
                        | &nbsp;<a href="logout.php">Logout</a></span></td>
                      <td width="66%" align="right"><?php 
			if(isset($_GET["clear_cart"]))
			{
  			     unset($_SESSION["gids"]);
			     unset($_SESSION["counts"]);
			     unset($_SESSION["details"]); // product detail 
			     unset($_SESSION["details1"]); // product detail 
			     unset($_SESSION["details2"]); // product detail 
                  echo "<meta http-equiv='refresh' content='$show;url=./cart.php'>" ;
			}

		if (isset($_GET["remove"]) && $_GET["remove"] > 0) //remove from cart product with productID == $remove
		{
			$i=0;
			while ($i<count($_SESSION["gids"]) && $_SESSION["gids"][$i] != $_GET["remove"]) $i++;
			if ($i<count($_SESSION["gids"])) 
			{
			     $buf_gid=$_SESSION["gids"];
			     $buf_counts=$_SESSION["counts"];
			     $buf_details=$_SESSION["details"];				 
			     $buf_details1=$_SESSION["details1"];				 
			     $buf_details2=$_SESSION["details2"];				 
  			     unset($_SESSION["gids"]);
			     unset($_SESSION["counts"]);
				 unset($_SESSION["details"]); // product detail 
				 unset($_SESSION["details1"]); // product detail 
				 unset($_SESSION["details2"]); // product detail 
				 
				$_SESSION["gids"] = array();
				$_SESSION["counts"] = array();
				$_SESSION["details"]= array();
				$_SESSION["details1"]= array();
				$_SESSION["details2"]= array();
				 //echo count($buf_gid);
				 $j1=count($buf_gid);
				 for( $j2=0; $j2<$j1 ; $j2++)
				 {
                           if($buf_gid[$j2]!=$remove)
						   {
						     	$_SESSION["gids"][]=$buf_gid[$j2];
						     	$_SESSION["counts"][]=$buf_counts[$j2];
						     	$_SESSION["details"][]=$buf_details[$j2];
						     	$_SESSION["details1"][]=$buf_details1[$j2];
						     	$_SESSION["details2"][]=$buf_details2[$j2];
							}	
				 }
			}
             echo "<meta http-equiv='refresh' content='$show;url=./cart.php'>" ;
		}
			
//********************update
		if (isset($_POST["update"])) //update shopping cart content
		{
            $ind=0;
			foreach ($_POST as $key => $val)
			 {

			    if(strstr($key, "detail_"))
				{
					for ($i=0; $i<count($_SESSION["gids"]); $i++)
                      {
							if ($i == str_replace("detail_","",$key))
							{
								$_SESSION["details"][$i] = $val;
							}					  
					  }				
				}
			    if(strstr($key, "detail1_"))
				{
					for ($i=0; $i<count($_SESSION["gids"]); $i++)
                      {
							if ($i == str_replace("detail1_","",$key))
							{
								$_SESSION["details1"][$i] = $val;
							}					  
					  }				
				}
			    if(strstr($key, "detail2_"))
				{
					for ($i=0; $i<count($_SESSION["gids"]); $i++)
                      {
							if ($i == str_replace("detail2_","",$key))
							{
								$_SESSION["details2"][$i] = $val;
							}					  
					  }				
				}
				
				if (strstr($key, "count_"))
				{
					if ($val > 0)
					{
						for ($i=0; $i<count($_SESSION["gids"]); $i++)
						{
							if ($i == str_replace("count_","",$key))
							{
								$_SESSION["counts"][$i] = floor($val);
							}
						}
					}
					else //remove
					{

						$i=0;
						while ($i != str_replace("count_","",$key) && $i<count($_SESSION["gids"])) $i++;
			if ($i<count($_SESSION["gids"])) 
			{
			     $buf_gid=$_SESSION["gids"];
			     $buf_counts=$_SESSION["counts"];
			     $buf_details=$_SESSION["details"];
			     $buf_details1=$_SESSION["details1"];
			     $buf_details2=$_SESSION["details2"];
  			     unset($_SESSION["gids"]);
			     unset($_SESSION["counts"]);
			     unset($_SESSION["details"]);
			     unset($_SESSION["details1"]);
			     unset($_SESSION["details2"]);
				$_SESSION["gids"] = array();
				$_SESSION["counts"] = array();
				$_SESSION["details"] = array();
				$_SESSION["details1"] = array();
				$_SESSION["details2"] = array();
				 //echo count($buf_gid);
				 $j1=count($buf_gid);
                 $buf_key=intval(str_replace("count_","",$key));
				 for( $j2=0; $j2<$j1 ; $j2++)
				 {
				 
                           if($buf_gid[$j2]!=$buf_key)
						   {
                                $_SESSION["gids"][]=$buf_gid[$j2];
						     	$_SESSION["counts"][]=$buf_counts[$j2];
						     	$_SESSION["details"][]=$buf_details[$j2];
						     	$_SESSION["details1"][]=$buf_details1[$j2];
						     	$_SESSION["details2"][]=$buf_details2[$j2];
							}	
				 }
			 }


					}
                }
           }
      }			
//**********************			
			if (isset($_SESSION["gids"]))
			{
			      $cid = count($_SESSION["gids"]); // จำนวนชนิดสินค้าที่อยู่ในตะกล้า
			      $cn = array_sum($_SESSION["counts"]); // จำนวนชนิดสินค้าที่อยู่ในตะกล้า			  
				 echo " จำนวนรหัส<strong>($cid)</strong>  จำนวนชิ้น <strong>($cn)</strong> | <a href=\"chkcart.php?clear_cart=yes\">ลบออกจากตะกร้าทั้งหมด</a>  | <a href=\"order.php?order=yes\">ส่งใบสั่งของ</a> ";
			}else{
			     echo "ไม่มีสินค้าในตะกร้า";
			}
			?></td>
                    </tr>
                  </table>
                    <form id="form1" name="form1" method="post" action="">
                      ขออภัยอยู่ในระหว่างทดสอบระบบ<br />
                      <?php
			
include("./member/config.inc.php") ;
mysql_select_db($db) ;
@mysql_select_db($db) or die( "Unable to select database");
mysql_db_query($db,"SET NAMES tis620");// 

mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=''tis620''");
mysql_query("SET character_set_connection=''tis620''");
mysql_query("collation_connection = tis620_thai_ci");
mysql_query("collation_database = tis620_thai_ci");
mysql_query("collation_server = tis620_thai_ci");

			$i=0;
			if(count($_SESSION["gids"])>0)
{			
			
echo "<center><br><strong>สินค้าที่สั่ง</strong> <br><br><table cellspacing=1 cellpadding=3 bgcolor=555555>";			
echo " <tr>
<td bgcolor=EEEECC align=\"center\">รหัส</td>
<td bgcolor=EEEECC  align=\"center\">ประเภท</td>
<td bgcolor=EEEECC  align=\"center\">กลุ่ม</td>
<td bgcolor=EEEECC  align=\"center\">ชื่อสินค้า</td>
<td bgcolor=EEEECC  align=\"center\">รูป</td>
<td bgcolor=EEEECC  align=\"center\"> จำนวน (ชิ้น) </td>
<td bgcolor=EEEECC  align=\"center\"> รายละเอียด </td>
<td bgcolor=EEEECC  align=\"center\"> ลบ </td>
</tr>";

			while ($i<count($_SESSION["gids"]))
			   {
 			       $b1=$_SESSION["gids"][$i];
 			       $b2=$_SESSION["counts"][$i];
 			       $b3=$_SESSION["details"][$i];
 			       $b4=$_SESSION["details1"][$i];
 			       $b5=$_SESSION["details2"][$i];
                   $query="SELECT * FROM product WHERE id = $b1";
                    $result = mysql_query($query) or die ("Err Can not to result") ;
                    $dbarr = mysql_fetch_array($result) ;
				   

 				  echo " <tr>
<td valign=top bgcolor=FFFFcc align=\"center\">".$dbarr['model'].
"</td><td  valign=top bgcolor=FFFFcc  align=\"center\">".$dbarr['type'].
"</td><td  valign=top bgcolor=FFFFcc  align=\"center\">".$dbarr['groups'].
"</td><td  valign=top bgcolor=FFFFcc  align=\"center\">".$dbarr['name'].
"</td><td  valign=top bgcolor=FFFFcc  align=\"center\"><a href=\"javascript:MM_openBrWindow('img.php?id=".$dbarr['id']."','','width=400,height=650')\"><img src=\"zz0504.php?id=$b1\" width=100 height=130></a></td>
<td  valign=top bgcolor=FFFFcc  align=\"center\"> <input name=\"count_$i\" type=\"text\" id=\"count_$i\"  size=\"7\" value=$b2 /></td>
<td  valign=top bgcolor=FFFFcc  align=\"left\"><select name=\"detail1_$i\" id=\"detail1_$i\">";

$query2="SELECT * FROM productsize WHERE name = '".$dbarr['type']."' ";
$result2=mysql_query($query2);
$num2=mysql_numrows($result2);
for($i2=0;$i2<$num2;$i2++)
{
  $idsize =mysql_result($result2,$i2,"id");
  $name =mysql_result($result2,$i2,"name");
  $weight =mysql_result($result2,$i2,"weight");
  $size =mysql_result($result2,$i2,"size");
  $unit =mysql_result($result2,$i2,"unit");
  $unit2 =mysql_result($result2,$i2,"unit2");
  if($idsize==$b4)
  {    
      echo "<option value=\"$idsize\" selected=\"selected\"> $weight</option>";
  }else{
               echo "<option value=\"$idsize\">น้ำหนัก $weight</option>";
           }
}
echo "</select><br><select name=\"detail2_$i\" id=\"detail2_$i\" >";
$query3="SELECT * FROM productsize2  WHERE name = '".$dbarr['type']."' ";
$result3=mysql_query($query3);
$num3=mysql_numrows($result3);
for($i3=0;$i3<$num3;$i3++)
{
  $idsize =mysql_result($result3,$i3,"id");
  $name =mysql_result($result3,$i3,"name");
  $weight =mysql_result($result3,$i3,"weight");
  $size =mysql_result($result3,$i3,"size");
  $unit =mysql_result($result3,$i3,"unit");
  $unit2 =mysql_result($result3,$i3,"unit2");
  
  if($idsize==$b5)
  {    
      echo "<option value=\"$idsize2\" selected=\"selected\">ขนาด $size $unit2</option>";
  }else{
               echo "<option value=\"$idsize\">  $size $unit2</option>";
           }
}

echo " </select><br>เพิ่มเติม<br><textarea name=\"detail_$i\" id=\"detail_$i\">$b3</textarea>
</td>
<td  valign=top bgcolor=FFFFcc  ><a href=\"chkcart.php?remove=$b1\"><img src=\"images/bin.gif\" width=\"30\" height=\"30\" border=\"0\" /></a></td>
           				  </tr>";
				  
				  $i++;
				}				
echo "</table></center>";			
}
?>
                      <input type="hidden" name="update" value="1" />
                      <br />
                      <br />
                      <input type="submit" name="Submit" value="Update" />
                      <input type="reset" name="Submit2" value="Reset" />
					  
                    </form></td>
                </tr>
              </table>
			  
			  <? } ?>
            <!-- InstanceEndEditable --></td>
          </tr>
          <tr>
            <td width="853" valign="top" background="images/bg_03.jpg"><table width="840" height="163" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="49" height="69">&nbsp;</td>
                <td width="791">&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td align="left" valign="top"><p class="style1">ห้างขายทอง ทองใบเยาวราช ถนนเยาวราช เขตสัมพันธวงศ์ กรุงเทพฯ   10100<br />
                  โทร.0-2226-1235 โทรสาร.0-2226-3742 Email : <a href="mailto:info@thongbai.com">info@thongbai.com</a><br />
                  Copyright and disclaimer   2007,
		
		  </p>
		  
<div id="eXTReMe"><a href="http://extremetracking.com/open?login=thongbai">
<img src="http://t1.extreme-dm.com/i.gif" alt="eXTReMe Tracker" name="EXim" width="1"
height="1" id="EXim" style="border: 0;" /></a>
<script type="text/javascript"><!--
var EXlogin='thongbai' // Login
var EXvsrv='s11' // VServer
EXs=screen;EXw=EXs.width;navigator.appName!="Netscape"?
EXb=EXs.colorDepth:EXb=EXs.pixelDepth;
navigator.javaEnabled()==1?EXjv="y":EXjv="n";
EXd=document;EXw?"":EXw="na";EXb?"":EXb="na";
EXd.write("<img src=http://e2.extreme-dm.com",
"/"+EXvsrv+".g?login="+EXlogin+"&amp;",
"jv="+EXjv+"&amp;j=y&amp;srw="+EXw+"&amp;srb="+EXb+"&amp;",
"l="+escape(EXd.referrer)+" height=1 width=1>");//-->
</script><noscript><div id="neXTReMe"><img height="1" width="1" alt=""
src="http://e2.extreme-dm.com/s11.g?login=thongbai&amp;j=n&amp;jv=n" />
</div></noscript></div>
<script type="text/javascript" language="javascript1.1" src="http://tracker.stats.in.th/tracker.php?uid=11558"></script><noscript><a target="_blank" href="http://www.stats.in.th/">www.Stats.in.th</a></noscript>



  <p align="center">    <span class="style10"><a href="home.php">                  หน้าแรก</a> | <a href="about.php">เกี่ยวกับเรา</a> | <a href="acticle.php">บทความ</a> | <a href="product.php">สินค้าและบริการ</a> | <a href="news.php">ข่าวและกิจกรรม</a> | <a href="faq.php">ถามตอบ</a> | <a href="price.php">ราคาทอง</a> | <a href="map.php">แผนท</a>ี่ | <a href="webb/webboard.php" target="_blank">กระดานความคิดเห็น</a> | <a href="contact.php">ติดต่อเรา</a></span><br />
  </p>
    </p>
</div></noscript></div></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
        <td width="33" background="<?php   printf("%s_04.jpg ",$bgc);    ?>"><img src="images/space.gif" width="33" height="33" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
