กระดานสนทนา 
            ShortChargeShock.com 
         
         
          
           
            
          
             
                
                  
    mysql_connect($host,$user,$passwd);
	mysql_select_db($dbname);
    
	// ติดต่อ database เพื่ออ่านข้อมูล
	
	$sql = "select * from $smf_data where No='$No'";
	
	$result = mysql_query($sql);
	$NRow = mysql_num_rows($result);
	
	
	
	if($NRow==0) { echo "Error"; exit(); }
	$row = mysql_fetch_array($result);
	// กำหนดค่าตัวแปร เพื่อนำไปแสดง
	$No = $row["No"]; 
	$mid = $row["mid"];
	$Question = $row["Question"];
	$Note = $row["Note"];
	//$Note = htmlspecialchars($row["Note"]);
	$Name = $row["Name"];
	$Member = $row["Member"];
	$Email = $row["Email"];
	$Date = $row["Date"];
	$imgpath = $row["imgpath"];
	$read = $row["read"];
	$imageType = $row["imageType"];
	$youtubeQ = $row["youtube"];
	$EditNameQ=$row["EditName"];
	$EditDateQ=$row["EditDate"];
	$EditIPQ=$row["EditIP"];
	
	
	
	/*
	
	// Youtube VDO embed
function autolink($string){
  // force http: on www.
    $string = str_ireplace( "www.", "http://www.", $string );
    // eliminate duplicates after force
    $string = str_ireplace( "http://http://www.", "http://www.", $string );
    $string = str_ireplace( "https://http://www.", "https://www.", $string );
    // The Regular Expression filter
    $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
    // Check if there is a url in the text
$m = preg_match_all($reg_exUrl, $string, $match); 
if ($m) { 
$links=$match[0]; 
for ($j=0;$j<$m;$j++) { 
    if(substr($links[$j], 0, 18) == 'http://www.youtube'){
    $string='
VIDEO ';
    //$string=str_replace($links[$j],'
'.$links[$j].' ',$string).'
VIDEO ';
    }else{
    $string=str_replace($links[$j],'
'.$links[$j].' ',$string);
        } 
    } 
} 
               return ($string);
 }
*/
//$string="http://www.youtube.com/watch?v=1P6mhwb4OtU";
//$string=$youtubeQ;
	//echo $youtube;
	
	   // YOU TUBE 
      //$url = 'http://www.youtube.com/watch?v=NMAYr709-9Y&feature=dir';
      // we get the unique video id from the url by matching the pattern
      preg_match("/v=([^&]+)/i", $youtubeQ, $matches);
      $id = $matches[1];
      // this is your template for generating embed codes
      $code = '
 
	   
	   
	  
	   ';
     
	  // we replace each {id} with the actual ID of the video to get embed code for this particular video
      $codeQ = str_replace('{id}', $id, $code); 
	
	
	// ตรวจสอบรูปแบบการแสดง IP Address 
	switch ($showIP) {
		case "ALL" : $IP = "(IP=".$row["IP"].")"; break;
		case "BAN" : $IP = "(IP=".substr($row["IP"],0,strrpos($row["IP"],".")).".*)"; break;
		case "NONE": $IP = ""; break;
		default : $IP = $row["IP"];
	}
	if($Member) {
		$sql = "select * from $smf_member where User='$Name'   "; 
		$result = mysql_query($sql);
		$NRow = mysql_num_rows($result);
	
		//if($NRow==0) { echo "Error"; exit(); }
		$row = mysql_fetch_array($result);
		// กำหนดค่าตัวแปร เพื่อนำไปแสดง
		$mid =$row["mid"];
		$mid_show = "SMF".sprintf("%06d",$row["mid"]);
		$Ustatus=$row["Ustatus"]; 
		
		//echo $Ustatus;
		if  ($Ustatus==0) {  
		$Ustatus="Member"; 
		}else if ($Ustatus==1) { 
		$Ustatus="
Administrator "; 
		}else if ($Ustatus==2) { 
		$Ustatus="
Moderator "; 
		}
		
		
		
		$Facebook = $row["Facebook"]; 
		/*
		if ($Facebook) {
		$Facebook=$Facebook;
		} else {
		$Facebook="-";
		}
		*/
		
		$Date2=$row["Date"];
		$Email = $row["Email"]; 
		$Slogan= $row["Slogan"]; 
		$Profilepic= $row["Profilepic"]; 
		$Profile_dis=$row["Profile_dis"];
		$email_dis=$row["email_dis"];
		$tel_dis=$row["tel_dis"];
	}
	
	
	
	//Total post  ของคนตั้งหัวข้อกระทู้
			$sqlP = "select * from $smf_data where mid = '$mid' ";
			$resultP= mysql_query($sqlP);
			$NRowP = mysql_num_rows($resultP);
			$cate=mysql_fetch_array($resultP);
			
			
			
			//Total Comment 
			$sqlC = "select * from $smf_ans where mid = '$mid' ";
			$resultC= mysql_query($sqlC);
			$NRowC = mysql_num_rows($resultC);
			
			$totalpost=$NRowP+$NRowC;
	
		//Total post  ของคนตั้งหัวข้อกระทู้
		
		// กำหนด Level ของสมาชิก
		if ($row["Ustatus"]==0) { 
		
		if ($totalpost <10) {
		$exp="สาวกหน้าใหม่";
		} else if ($totalpost >=10 && $totalpost <50 ) {
		$exp="สาวกระดับหนึ่ง";
		} else if ($totalpost >=50 && $totalpost <100 ) {
		$exp="สาวกระดับสอง";
		} else if ($totalpost >=100 && $totalpost <500) {
		$exp="สาวกพันธุ์แท้";
		} else if ($totalpost >=500 && $totalpost <1000) {
		$exp="อาจารย์ระดับหนึ่ง";
		} else if ($totalpost >=1000 && $totalpost <2000) {
		$exp="อาจารย์ระดับสอง";
		} else {
		$exp="ปรมาจารย์หิน เหล็ก ไฟ";
		
		}
		}else{
		
			if ($row["Ustatus"]==1) {
			$exp="ผู้ดูแลระบบ";
			} else {
			$exp="ผู้ตรวจทาน";
			}
		} 
	
	// แสดงข้อมูลของคำถาม(กระทู้)
	echo "
\n";
	echo "\n";
	
	echo "\n";
	echo "\n";
	echo "\t$Question  \n";
	//echo "\n";
	
	/*
	if ($NRow12<>0) {  
	echo "[ Edit    ] \n"; 
	
     } 
	 */
	 
	 echo " \n";
	  echo "
\n";
	 
	echo " \n";
	echo "\t\n";
	
	echo "\t\n";
	
	echo "
		";
		
		
		
		// ตรวจสอบว่ามีรูปหรือไม่
		if($imgpath) {
		
		    if ($imageType=="1") { 
			//echo $imageType;
			
			
			$image_new = "$imgpath"; //url of picture 
			//echo $image_new;
			
			$image_new = str_replace(' ','%20',$image_new); //take url and replace spaces 
			$max_width= $imgzise;  //maximum width allowed for pictures 
			$resize_width= $imgzise;  //same as max width  
			$size = getimagesize("$image_new");    //get the actual size of the picture 
			$width= $size[0];           // get width of picture 
			//echo $width;
			$height= $size[1];   // get height of picture 
			if ($width>$max_width){ 
            $new_width=$resize_width;  // Resize Image If over max width 
			$zoom_title=0;
			}else { 
            $new_width=$width;       // Keep original size from array because smaller than max 
            $zoom_title=1;
			} 
//echo " "   //print image with new width 
	        if ($zoom_title==0) {
			echo "\t\t ";   
			} else {
			echo "\t\t ";   
			
			}
			//echo "ภาพนี้ถูกย่อคลิกที่ภาพเพื่อดูขนาดจริง  ";
			
			
			//echo $imageType;
			//echo "\t\t \n";   
			}else{
			echo "\t\t     คลิกดาวน์โหลดไฟล์แนบที่นี่เลย    \n"; 
			echo "\t\t  ------------------------------ \n";  
			echo " \n";
			
			}
			//echo "\t\t \n";		
		
			
			
			
		}
		
		
		
		
		// Display youtube vdo
		if ($youtubeQ) {
		echo "".$codeQ."  ";
		}
		
		
		echo "\t\t".auto_link($Note)." \n";
		echo "\t ";
		echo " \n";
		echo "\t
\n";
		//echo " \n";
		echo "  \n";
	echo "\n";
		echo "\t\n";
		echo "\t\n";
		
		echo "\t\t   $Name  \n";
		//echo "\t\t   $Name  \n";
		echo "\t \n";
		echo "\t\n";
		
	 //echo "\t\tโดยคุณ $Name \n";
	 
	//	}
	    if ($EditNameQ<>"") {
			echo "แก้ไขล่าสุด $EditDateQ โดย $EditNameQ   ";
			}
		echo "\t\t$IP\n";
		echo "\t\t[$Date]\n";
		
		
		// If admin display del icon 
		if (isset($s_Ustatus) && $s_Ustatus<>0) {
		echo "  ";
		echo "--     \n";
		
		} else if (isset($s_Ustatus) && $mid==$s_ID )  { 
		
		echo "   "; 
		//echo "--    \n";
		
		} else if (isset($s_Ustatus) && $row['fb_id']==$s_ID )  { 
		
		echo "   "; 
		//echo "--    \n";
		
		}else {
		echo "\t\n";
		} 
		echo "\t
\n";
	echo "  \n";
	echo "
\n";
	
	
	
	/*
	
	if ($Profile_dis==1) {
	/// Display Profile Info
	
	echo "\t
\n";
	echo "\t";
	
	// Profile Pic
	echo  "\n";
	
	if ($Profilepic!="") { 
	echo "  ";
	} else {
	echo "  ";
	}
	echo " ";
	
	
	//Uer Profile Info
	echo  "\n";
	echo "หมายเลขสมาชิก    $mid_show    ";
	echo "ระดับสมาชิก    $Ustatus    "; 
	echo "โพสต์ทั้งหมด    $totalpost ครั้ง - ตั้ง $NRowP ตอบ $NRowC    [ แสดง   ] ";
	echo "ประสบการณ์    $exp    ";
	echo "สมัครสมาชิก    $Date2    ";
	
	if ($email_dis==1) { 
	echo "Email    $Email     ";
	}
	if ($Facebook!="") {
	echo "Facebook    $Facebook   ";
	}
	echo " ";
	
	// Slogan, Signature
	echo  "\n";
	
	if ($Slogan) {
	echo "";
	//echo "";
	echo "$Slogan";
	echo " 
";
	}
	
	echo " ";
	
	echo " \n";
	echo "
\n";
	
	
	/// Display Profile Info
	
	
	}
*/
?>
                  
 
 
   ///// Paging  code ---------------------------------------------------------------------------------------------
	
	$chk_date = date("j M Y",mktime( date("H")+$p_hour, date("i")+$p_min ));
	if (empty($page)){
		$page=1;
	}
	
	$list_page=20;
	
	$sql= "select * from $smf_ans where QuestionNo='$No' order by No ASC"; 
	
	$result = mysql_query($sql);
	$NRow = mysql_num_rows($result);
	$rt = $NRow%$list_page;
	if($rt!=0) { 
		$totalpage = floor($NRow/$list_page)+1; 
	}
	else {
		$totalpage = floor($NRow/$list_page); 
	}
	$goto = ($page-1)*$list_page;
	
	
	$sql = "select * from $smf_ans where QuestionNo='$No' order by No ASC  limit $goto,$list_page";
	$result = mysql_query($sql);
	$NRow = mysql_num_rows($result);
	
	//echo $NRow;
	//echo $goto;
	
	
	///// Paging  code ---------------------------------------------------------------------------------------------
	
 
 
 
 
    /*
	// ส่วนแสดงคำตอบของคำถาม(กระทู้)
	$sql = "select * from $smf_ans where QuestionNo='$No' order by No ASC";  
	//$sql = "select * from $smf_ans where QuestionNo='$No' order by No ". $order; 
	$result = mysql_query($sql);
	$NRow = mysql_num_rows($result);
    */
	
	
	if($order=="ASC") $i = 1; else $i = $NRow; 
	if($result==0) { 
		echo "Error "; 
		exit();
	} 
    
	
	if ($_GET[page] == 2  ) { 
	$y=$list_page;
	} else if ( $_GET[page] > 2 ) { 
	$y=$list_page*($page-1);
	} else { 
	$y=0;
	}
	// วนลูปแสดงข้อมูลที่อ่านได้
	while ($row = mysql_fetch_array($result)) {
	
	#echo $page;
	
     $y++;
	
		// กำหนดค่าตัวแปร เพื่อนำไปแสดง
		$QuestionNo = $row["No"];
		$Name = $row["Name"];
		$Member = $row["Member"];
		$mid = $row["mid"];
		$Email = $row["Email"];
		$Msg = $row["Msg"];
		$Date = $row["Date"];
		$imgpath2 = $row["imgpath2"];
		$imageType2 = $row["imageType2"];
		$EditName = $row["EditName"];
		$EditDate = $row["EditDate"];
		$EditIP = $row["EditIP"];
		//echo $imageType2;
		// ตรวจสอบรูปแบบการแสดง IP Address 
		$youtubeA = $row["youtube"];
	
		// -------------------------**********************************************///////////////////////////////
		//User profile
		$sql3 = "select * from $smf_member where mid='$mid' ";
		$result3 = mysql_query($sql3);
		$NRow3 = mysql_num_rows($result3);
		$row3 = mysql_fetch_array($result3);
		
		$mid3 =$row3["mid"];
		$mid_show3 = "SMF".sprintf("%06d",$row3["mid"]);
		$Ustatus3=$row3["Ustatus"]; 
		
		
		//echo $mid3;
		
		//echo $Ustatus;
		if  ($Ustatus3==0) {  
		$Ustatus3="Member"; 
		}else if ($Ustatus3==1) { 
		$Ustatus3="Administrator  "; 
		}else if ($Ustatus3==2) { 
		$Ustatus3="Moderator  "; 
		}
		
		$Facebook3 = $row3["Facebook"]; 
		/*
		if ($Facebook3) {
		$Faceboo3k=$Facebook3;
		} else {
		$Facebook3="-";
		}
		*/
		
		
		$Date3=$row3["Date"];
		$Email3 = $row3["Email"]; 
		$Slogan3= $row3["Slogan"]; 
		$Profilepic3= $row3["Profilepic"]; 
		$Profile_dis3=$row3["Profile_dis"];
		$email_dis3=$row3["email_dis"];
		$tel_dis3=$row3["tel_dis"];
		
		//echo $Profile_dis3;
	//}
	
	
	
	//Total post  ของคนตั้งหัวข้อกระทู้
			$sqlP3 = "select * from $smf_data where mid = '$mid' ";
			$resultP3= mysql_query($sqlP3);
			$NRowP3 = mysql_num_rows($resultP3);
			$cate3=mysql_fetch_array($resultP3);
			
		
			
			
			//Total Comment 
			$sqlC3 = "select * from $smf_ans where mid = '$mid' ";
			$resultC3= mysql_query($sqlC3);
			$NRowC3 = mysql_num_rows($resultC3);
			
			$totalpost3=$NRowP3+$NRowC3;
	
		//Total post  ของคนตั้งหัวข้อกระทู้
		
		// กำหนด Level ของสมาชิก
		if ($row3["Ustatus"]==0) {
		
		if ($totalpost3<10) {
		$exp3="สาวกหน้าใหม่";
		} else if ($totalpost3 >=10 && $totalpost3 <50 ) {
		$exp3="สาวกระดับหนึ่ง";
		} else if ($totalpost3 >=50 && $totalpost3 <100 ) {
		$exp3="สาวกระดับสอง";
		} else if ($totalpost3 >=100 && $totalpost3 <500) {
		$exp3="สาวกพันธุ์แท้";
		} else if ($totalpost3 >=500 && $totalpost3 <1000) {
		$exp3="อาจารย์ระดับหนึ่ง";
		} else if ($totalpost3 >=1000 && $totalpost3 <2000) {
		$exp3="อาจารย์ระดับสอง";
		} else {
		$exp3="ปรมาจารย์หิน เหล็ก ไฟ";
		
		}
		}else{
		
			if ($row3["Ustatus"]==1) {
			$exp3="ผู้ดูแลระบบ";
			} else {
			$exp3="ผู้ตรวจทาน";
			}
		}
		// -------------------------**********************************************///////////////////////////////
	
	   // YOU TUBE 
      //$url = 'http://www.youtube.com/watch?v=NMAYr709-9Y&feature=dir';
      // we get the unique video id from the url by matching the pattern
      
	  preg_match("/v=([^&]+)/i", $youtubeA, $matches);
      $id = $matches[1];
      // this is your template for generating embed codes
      $code = ' 
	   
	   
	  
	    ';
     
	  // we replace each {id} with the actual ID of the video to get embed code for this particular video
      $codeA = str_replace('{id}', $id, $code); 
		
		
		switch ($showIP) {
		case "ALL" : $IP = "(IP=".$row["IP"].")"; break;
		case "BAN" : $IP = "(IP=".substr($row["IP"],0,strrpos($row["IP"],".")).".*)"; break;
		case "NONE": $IP = ""; break;
		default : $IP = $row["IP"];
		}
        //echo $Name;
		
		/*
		if($Member) {
			$sql2 = "select * from $smf_member where User='$Name' "; 
			$result2 = mysql_query($sql2);
			$NRow2 = mysql_num_rows($result2);
	
			//if($NRow2==0) { echo "Error"; exit(); }
			$qrow = mysql_fetch_array($result2);
			// กำหนดค่าตัวแปร เพื่อนำไปแสดง
			$Facebook = $qrow["Facebook"]; 
			
		}
		
		*/
		
		//echo $Member;
		    
			echo " ";
		    echo "\n";
			echo "\t\n";
			echo "\t\t\n";
			echo "\t\t• ความเห็นที่ $y\n";
			echo "   
";
			
		
		
			
		echo "\t\n";
		//echo "\n";
		echo "\n";
		
		
		
		
		if ($imgpath2 || $youtubeA) { 
		echo "\t\n";
	         echo "\t\n";
			// ตรวจสอบว่ามีรูปหรือไม่
			if($imgpath2) {
			
			//echo  $imgpath2;
			if ($imageType2=="1") { 
			//echo  $imageType2;
			$image_new = "$imgpath2"; //url of picture 
			$image_new = str_replace(' ','%20',$image_new); //take url and replace spaces 
			$max_width= $imgzise;  //maximum width allowed for pictures 
			$resize_width= $imgzise;  //same as max width  
			//echo  "image new = ".$image_new;
			$size = getimagesize("$image_new");    //get the actual size of the picture 
			$width= $size[0];           // get width of picture 
			//echo $width;
			$height= $size[1];   // get height of picture 
			if ($width>$max_width){ 
            $new_width=$resize_width;  // Resize Image If over max width 
			$zoom_title=0;
			}else { 
            $new_width=$width;       // Keep original size from array because smaller than max 
			$zoom_title=1;
			} 
			
			
			if ($zoom_title==0) {
			echo "\t\t ";   
			} else {
			echo "\t\t ";   
			
			}
	
			}else{
			echo "\t\t     คลิกดาวน์โหลดไฟล์แนบที่นี่เลย    \n"; 
			echo "\t\t  ------------------------------ \n";  
			echo " \n";
			
			}
			}
			
			
			// Display youtube vdo
		if ($youtubeA) {
		echo "".$codeA."  ";
		}
		
		echo "".auto_link($Msg)." ";
		echo "\t  ";
		echo "\t
";
		}  else {
			echo "\n";
			echo "";
			echo "".auto_link($Msg)." ";
			echo "  ";
			echo "
";
			
		}
			
			echo "\t  ";
			
		echo "
\n";
		
		
		
		
		// รายละเอียดผู้แสดงความคิืดเห็น -----------------------------------------------------------------------------------------
		//echo "\t
  include("footer.php");
?>