|
|
|
[PHP] ทำการทดสอบเว็บ login เข้าสู่ระบบแล้วจะขึ้นหน้าว่า ไม่สามารถเข้าถึงเว็บไซต์นี้ การเชื่อมต่อได้รับการรีเซ็ตแล้ว |
|
|
|
|
|
|
|
สวัสดีครับ ผมได้ทำการสร้างเว็บไซต์เช่าพระเครื่องออนไลน์ ของมูลนิธิสิรินธรราชวิทยาลัย ในพระราชูปถัมภ์ โดยได้ทำการทดสอบ Login เข้าสู่ระบบ โดยมีขั้นตอนดังต่อไปนี้
1) สร้างตารางฐานข้อมูล member และทำการ Insert ข้อมูลตัวอย่าง ดังต่อไปนี้
Code (SQL)
CREATE TABLE `member` (
`UserID` int(3) UNSIGNED ZEROFILL NOT NULL,
`Username` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`Password` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`Email` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
`Title` enum('Mr.','Miss','Mrs.') COLLATE utf8_unicode_ci DEFAULT NULL,
`Name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`Surname` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`Gender` enum('Male','Female') COLLATE utf8_unicode_ci DEFAULT NULL,
`Birthday` date NOT NULL,
`IDCard` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`Address` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
`PostalCode` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
`Tel` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`Mobile` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`Status` enum('Admin','User') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'User',
`SID` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`Active` enum('Yes','No') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'No',
`LoginStatus` int(1) NOT NULL,
`LastUpdate` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE `member`
ADD PRIMARY KEY (`UserID`),
ADD UNIQUE KEY `Username` (`Username`);
ALTER TABLE `member`
MODIFY `UserID` int(3) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
INSERT INTO `member` (`UserID`, `Username`, `Password`, `Email`, `Title`, `Name`, `Surname`, `Gender`, `Birthday`, `IDCard`, `Address`, `PostalCode`, `Tel`, `Mobile`, `Status`, `SID`, `Active`, `LoginStatus`, `LastUpdate`) VALUES
(001, 'RW', 'Rocket22110', '[email protected]', 'Mr.', 'Rungsimun', 'Wongnikorn', 'Male', '1993-02-27', '1110100134961', '69/11 ม.4 ซ.มิตรไมตรี 10 ถ.สุขุมวิท ต.บางเมืองใหม่ อ.เมือง จ.สมุทรปราการ', '10270', '023831729', '0851491948', 'Admin', '001', 'Yes', 0, '0000-00-00 00:00:00');
2) ทำการสร้างเพจ Login เข้าสู่ระบบ login, เพจตรวจสอบข้อมูลการล็อกอิน check_login, เพจเชื่อมต่อฐานข้อมูล connect, เพจแสดงข้อมูลแอดมิน admin_page และเพจแสดงข้อมูลผู้ใช้งาน user_page ที่ต้องการให้แสดงหลังจากล็อกอินเสร็จ ดังนี้ (เนื่องจากเพจ เพจ Login เข้าสู่ระบบ เพจแสดงข้อมูลแอดมิน admin_page และเพจแสดงข้อมูลผู้ใช้งาน user_page นั้นทำมาจากเว็บ template ดังนั้น ผมจึงนำโค้ดที่จำเป็นเฉพาะบางส่วนเท่านั้น)
เพจ Login เข้าสู่ระบบ (login.php)
<!doctype html>
<html>
<title>เช่าพระเครื่องออนไลน์ มูลนิธิสิรินธรราชวิทยาลัยฯ : เข้าสู่ระบบ (Log In)</title>
<p><a class="list-group-item active"><strong>เข้าสู่ระบบ (Log In) >>></strong></a></p>
<p> Login เข้าสู่ระบบของเว็บไซต์ (เฉพาะผู้ที่สมัครสมาชิกของเว็บไซต์เท่านั้น)</p>
<form name="frmLogin" method="post" action="check_login.php">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolordark="#CCCCCC" class="table table-striped">
<tbody>
<tr>
<td align="right" valign="top"><p><strong>ชื่อผู้ใช้งาน (Username) :</strong></p></td>
<td valign="top"><input name="txtUsername" type="text" id="txtUsername" size="30" maxlength="20" class="form-control"></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>รหัสผ่าน (Password) :</strong></p></td>
<td valign="top"><p><input name="txtPassword" type="password" id="txtPassword" size="30" maxlength="20" class="form-control"></p>
<p><input type="checkbox" name="checkbox" id="checkbox">
<strong>Remember Me</strong></p></tr>
<tr>
<td align="right" valign="top"><input type="submit" name="Submit" value="Login" class="btn btn-success"></td>
<td align="left" valign="top"><strong><a href="register.php" class="btn btn-warning" role="button">สมัครสมาชิกใหม่ (Register) >>></a></strong>
<p align="right"><strong><a href="ForgotPassword.php" class="btn btn-link" role="button">ลืมรหัสผ่าน (Forgot Password) >>></a></strong></p></td>
</tr>
</tbody>
</table>
</form>
</html>
เพจตรวจสอบข้อมูลการล็อกอิน (check_login.php)
<?php
session_start();
require_once("connect.php");
$strUsername = mysqli_real_escape_string($objCon,$_POST['txtUsername']);
$strPassword = mysqli_real_escape_string($objCon,$_POST['txtPassword']);
$strSQL = "SELECT * FROM member WHERE Username = '".$strUsername."' and Password = '".$strPassword."' and Active = 'Yes' ";
$objQuery = mysqli_query($objCon,$strSQL);
$objResult = mysqli_fetch_array($objQuery);
if(!$objResult)
{
echo "Username หรือ Password ไม่ถูกต้อง!";
exit();
}
else
{
if($objResult["LoginStatus"] == "1")
{
echo "'".$strUsername."' Exist Login!";
exit();
}
else
{
$strSQL = "UPDATE member SET LoginStatus = '1', LastUpdate = NOW() WHERE UserID = '".$objResult["UserID"]."' ";
$objQuery = mysqli_query($objCon,$strSQL);
$_SESSION["UserID"] = $objResult["UserID"];
$_SESSION["Status"] = $objResult["Status"];
session_write_close();
if($objResult["Status"] == "Admin")
{
echo "ขอต้อนรับ แอดมิน";
header("location:admin_page.php");
}
else
{
echo "ขอต้อนรับ ผู้ใช้งาน";
header("location:user_page.php");
}
}
}
mysqli_close($objCon);
?>
เพจเชื่อมต่อฐานข้อมูล (connect.php)
<?php
ini_set('display errors',1);
error_reporting(0);
$serverName = "localhost";
$userName = "root";
$userPassword = "RocketSQL";
$dbName = "memberdb";
$objCon = mysqli_connect($serverName,$userName,$userPassword,$dbName);
if(mysqli_connect_errno())
{
echo "ไม่สามารถเชื่อมต่อกับฐานข้อมูลได้ : ". mysqli_connect_error();
exit();
}
//ออกจากระบบเมื่อ user ไม่ได้ออนไลน์เป็นเวลา 20 นาที
$RejectTime = 20;
$sql = "UPDATE member SET LoginStatus = '0', LastUpdate = '0000-00-00 00:00:00' WHERE 1 AND DATE_ADD(LastUpdate,INTERVAL $RejectTime MINUTE) <= NOW() ";
$query = mysqli_query($objCon,$sql);
?>
เพจแสดงข้อมูลแอดมิน (admin_page.php)
<?php
session_start();
require_once("connect.php");
if($_SESSION["UserID"] == "")
{
echo "กรุณา Login เข้าสู่ระบบก่อน!";
exit();
}
if($_SESSION["Status"] == "Admin")
{
echo "เพจนี้สำหรับแอดมิน (Admin) เท่านั้น!";
exit();
}
$sql = "UPDATE member SET LastUpdate = NOW() WHERE UserID = '".$_SESSION["UserID"]."' ";
$query = mysqli_query($objCon,$sql);
$strSQL = "SELECT * FROM member WHERE UserID = '".$_SESSION["UserID"]."' ";
$objQuery = mysqli_query($objCon,$strSQL);
$objResult = mysqli_fetch_array($objQuery, MYSQLI_ASSOC);
?>
<!doctype html>
<html>
<title>เช่าพระเครื่องออนไลน์ มูลนิธิสิรินธรราชวิทยาลัยฯ : ขอต้อนรับเข้าสู่หน้าแอดมิน (Welcome to Admin Page!)</title>
<p><a class="list-group-item active"><strong>ขอต้อนรับเข้าสู่หน้าแอดมิน (Welcome to Admin Page!) >>></strong></a></p>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolordark="#CCCCCC" class="table table-striped">
<tbody>
<tr>
<td align="right" valign="top"><p><strong>ชื่อผู้ใช้งาน (Username) : </strong></p></td>
<td valign="top"><?php echo $objResult["Username"]; ?></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>อีเมล์ (E-mail) : </strong></p></td>
<td valign="top"><?php echo $objResult["Email"]; ?></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>ชื่อ (Name) : </strong></p></td>
<td valign="top"><?php echo $objResult["Name"]; ?></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>นามสกุล (Surname) : </strong></p></td>
<td valign="top"><?php echo $objResult["Surname"]; ?></td>
</tr>
</tbody>
</table>
<p align="center"><strong><a href="edit_profile.php" class="btn btn-warning" role="button">แก้ไขโปรไฟล์แอดมิน (Admin) >>></a></strong> <strong><a href="logout.php" class="btn btn-danger" role="button">ออกจากระบบ >>></a></strong></p>
</html>
เพจแสดงข้อมูลผู้ใช้งาน (user_page.php)
<?php
session_start();
require_once("connect.php");
if($_SESSION["UserID"] == "")
{
echo "กรุณา Login เข้าสู่ระบบก่อน!";
exit();
}
if($_SESSION["Status"] == "User")
{
echo "เพจนี้สำหรับผู้ใช้งาน (User) เท่านั้น!";
exit();
}
$sql = "UPDATE member SET LastUpdate = NOW() WHERE UserID = '".$_SESSION["UserID"]."' ";
$query = mysqli_query($objCon,$sql);
$strSQL = "SELECT * FROM member WHERE UserID = '".$_SESSION["UserID"]."' ";
$objQuery = mysqli_query($objCon,$strSQL);
$objResult = mysqli_fetch_array($objQuery, MYSQLI_ASSOC);
?>
<!doctype html>
<html>
<title>เช่าพระเครื่องออนไลน์ มูลนิธิสิรินธรราชวิทยาลัยฯ : ขอต้อนรับเข้าสู่หน้าผู้ใช้งาน (Welcome to User Page!)</title>
<p><a class="list-group-item active"><strong>ขอต้อนรับเข้าสู่หน้าผู้ใช้งาน (Welcome to User Page!) >>></strong></a></p>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolordark="#CCCCCC" class="table table-striped">
<tbody>
<tr>
<td align="right" valign="top"><p><strong>ชื่อผู้ใช้งาน (Username) : </strong></p></td>
<td valign="top"><?php echo $objResult["Username"]; ?></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>อีเมล์ (E-mail) : </strong></p></td>
<td valign="top"><?php echo $objResult["Email"]; ?></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>ชื่อ (Name) : </strong></p></td>
<td valign="top"><?php echo $objResult["Name"]; ?></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>นามสกุล (Surname) : </strong></p></td>
<td valign="top"><?php echo $objResult["Surname"]; ?></td>
</tr>
</tbody>
</table>
<p align="center"><strong><a href="edit_profile.php" class="btn btn-warning" role="button">แก้ไขโปรไฟล์ผู้ใช้งาน (User) >>></a></strong> <strong><a href="logout.php" class="btn btn-danger" role="button">ออกจากระบบ >>></a></strong></p>
</html>
3) ทำการทดสอบ Login เข้าสู่ระบบ โดยทำการแสดงหน้าเพจ Login เข้าสู่ระบบ บนเว็บบราวเซอร์ จากนั้นทำการกรอก Username และ Password แล้วกดปุ่ม Login ดังภาพ
ผลปรากฏว่า หน้าเว็บทำการเชื่อมต่อกับ localhost เป็นเวลาถึง 8 นาทีกว่าๆ และแสดงหน้าเพจตรวจสอบข้อมูลการล็อกอิน พร้อมกับขึ้นข้อความว่า ไม่สามารถเข้าถึงเว็บไซต์นี้ การเชื่อมต่อได้รับการรีเซ็ตแล้ว ดังภาพ
ผมเลยอยากสอบถามครับว่า ปัญหานี้มีสาเหตุเกิดจากอะไรครับ แล้วพอจะมีวิธีแก้ปัญหานี้อย่างไรครับ
โปรแกรมที่ใช้งาน Adobe Dreamweaver CS6, ฐานข้อมูลใช้ MySQL โดยใช้งานผ่านโปรแกรม XAMPP Control Panel
Tag : PHP, MySQL, HTML/CSS, Windows
|
|
|
|
|
|
Date :
2016-06-06 15:14:54 |
By :
Rocket |
View :
3947 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง เปลียนจาก Code (PHP)
require_once("connect.php");
เป็น
Code (PHP)
include "connect.php" ;
|
|
|
|
|
Date :
2016-06-06 16:46:49 |
By :
newalway |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
require_once ดีอยู่แล้วครับ
แต่เปิด error ก่อนดีไหม จะได้ แสดงเออเร่อร์ออกมาให้เห็น
error_reporting(0);
แก้เป็น error_reporting(E_ALL);
|
|
|
|
|
Date :
2016-06-06 16:56:57 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมได้ทำการแก้เป็น error_reporting(E_ALL); ในหน้าเพจ connect.php ตามที่คุณ Chaidhanan ได้แนะนำไว้ครับ และลองใส่โค้ด error_reporting(E_ALL); ตรงหน้าเพจตรวจสอบข้อมูลการล็อกอิน (check_login.php) แต่ปรากฏว่า ยังเหมือนเดิมครับ ขึ้นข้อความว่า ไม่สามารถเข้าถึงเว็บไซต์นี้ การเชื่อมต่อได้รับการรีเซ็ตแล้ว เหมือนเดิมทุกประการ จะ view source ก็ไม่ได้อีกครับ
|
|
|
|
|
Date :
2016-06-06 22:33:39 |
By :
Rocket |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_login.php
mark บันทัดที่ 38 และ 44 ออกไปก่อน อย่าเพิ่งให้ redirect เช็คส่วนนี้ก่อนว่าทำงานถูกต้องไหม ไล่ไปทีละโปรแกรม
ส่วน html พยามเขียนให้ถูก format หน่อยก็จะดีครับ browser จะทำงานเร็วขึ้น
Code (JavaScript)
<!doctype html>
<html>
<head>
<title>xxxxx</title>
<meta charset="utf-8">
<link ......>
<script .....></script>
</head>
<body>
content
</body>
</html>
|
|
|
|
|
Date :
2016-06-07 06:15:46 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ไขโค้ดแล้วครับ
เพจ Login เข้าสู่ระบบ (login.php) สำหรับเทสเท่านั้น
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="check_login.php">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolordark="#CCCCCC">
<tbody>
<tr>
<td align="right" valign="top"><p><strong>ชื่อผู้ใช้งาน (Username) :</strong></p></td>
<td valign="top"><input name="txtUsername" type="text" id="txtUsername" size="30" maxlength="20"></td>
</tr>
<tr>
<td align="right" valign="top"><p><strong>รหัสผ่าน (Password) :</strong></p></td>
<td valign="top"><p><input name="txtPassword" type="password" id="txtPassword" size="30" maxlength="20"></p>
<tr>
<td align="right" valign="top"><input type="submit" name="Submit" value="Login" class="btn btn-success"></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
เพจตรวจสอบข้อมูลการล็อกอิน (check_login.php)
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();
require_once("connect.php");
$strSQL = "SELECT * FROM member WHERE Username = '".trim($_POST['txtUsername'])."' and Password = '".trim($_POST['txtPassword'])."' and Active = 'Yes' ";
$objQuery = mysqli_query($objCon,$strSQL);
$objResult = mysqli_fetch_array($objQuery);
if(!$objResult)
{
echo "Username หรือ Password ไม่ถูกต้อง!";
exit();
}
else
{
if($objResult["LoginStatus"] == "1")
{
echo "'".$strUsername."' Exist Login!";
exit();
}
else
{
$strSQL = "UPDATE member SET LoginStatus = '1', LastUpdate = NOW() WHERE UserID = '".$objResult["UserID"]."' ";
$objQuery = mysqli_query($objCon,$strSQL);
$_SESSION["UserID"] = $objResult["UserID"];
$_SESSION["Status"] = $objResult["Status"];
session_write_close();
if($objResult["Status"] == "Admin")
{
echo "ขอต้อนรับ แอดมิน";
//header("location:admin_page.php");
}
else
{
echo "ขอต้อนรับ ผู้ใช้งาน";
//header("location:user_page.php");
}
}
}
mysqli_close($objCon);
?>
Code (PHP)
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$serverName = "localhost";
$userName = "root";
$userPassword = "RocketSQL";
$dbName = "memberdb";
$objCon = mysqli_connect($serverName,$userName,$userPassword,$dbName);
if(!$objCon)
{
echo $objCon->connect_error;
exit();
}
//ออกจากระบบเมื่อ user ไม่ได้ออนไลน์เป็นเวลา 20 นาที
$RejectTime = 20;
$sql = "UPDATE member SET LoginStatus = '0', LastUpdate = '0000-00-00 00:00:00' WHERE 1 AND DATE_ADD(LastUpdate,INTERVAL $RejectTime MINUTE) <= NOW()";
$query = mysqli_query($objCon,$sql);
?>
ผลการทดสอบการ Login เข้าสู่ระบบ โดยใช้ web browser ต่างๆ มีดังนี้
1) google chrome ยังขึ้นคำว่า ไม่สามารถเข้าถึงเว็บไซต์นี้ การเชื่อมต่อได้รับการรีเซ็ตแล้ว ในหน้าเพจ check_login.php ดังภาพ
และได้ทำการคลิกขวาที่หน้าเว็บ check_login เลือกไปที่ ดูรหัสต้นฉบับ ก็ยังขึ้นคำว่า ไม่สามารถเข้าถึงเว็บไซต์นี้ การเชื่อมต่อได้รับการรีเซ็ตแล้ว เช่นเดียวกัน
2) Microsoft Internet Explorer จะขึ้นคำว่า This Page can't be displayed ดังภาพ
และได้ทำการคลิกขวาที่หน้าเว็บ check_login เลือกไปที่ View Source จะแสดงโค้ดดังนี้
View Source Code on IE
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="NewErrorPageTemplate.css" >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>This page can’t be displayed</title>
<script src="errorPageStrings.js" language="javascript" type="text/javascript">
</script>
<script src="httpErrorPagesScripts.js" language="javascript" type="text/javascript">
</script>
</head>
<body onLoad="javascript:getInfo();">
<div id="contentContainer" class="mainContent">
<div id="mainTitle" class="title">This page can’t be displayed</div>
<div class="taskSection" id="taskSection">
<ul id="cantDisplayTasks" class="tasks">
<li id="task1-1">Make sure the web address <span id="webpage" class="webpageURL"></span>is correct.</li>
<li id="task1-2">Look for the page with your search engine.</li>
<li id="task1-3">Refresh the page in a few minutes.</li>
</ul>
<ul id="notConnectedTasks" class="tasks" style="display:none">
<li id="task2-1">Check that all network cables are plugged in.</li>
<li id="task2-2">Verify that airplane mode is turned off.</li>
<li id="task2-3">Make sure your wireless switch is turned on.</li>
<li id="task2-4">See if you can connect to mobile broadband.</li>
<li id="task2-5">Restart your router.</li>
</ul>
</div>
<div><button id="diagnose" class="diagnoseButton" onclick="javascript:diagnoseConnectionAndRefresh(); return false;">Fix connection problems</button></div>
</div>
</body>
</html>
3) Microsoft Edge จะขึ้นคำว่า Hmm, we can't reach this page. ดังภาพ
และได้ทำการคลิกขวาที่หน้าเว็บ check_login เลือกไปที่ View Source หรือ Inspect Element จะแสดงโค้ดดังนี้
View Source Code on Microsoft Edge เอาตรง debugger มาแสดง
var resourceJSON = "";
function getUrl() {
"use strict";
var docUrl = document.location.href;
var urlResult = docUrl;
var beginIndex = docUrl.indexOf('#') + 1;
if (docUrl.indexOf("file://", beginIndex) == -1) {
var protocolEndIndex = docUrl.indexOf("://", beginIndex);
var endIndex = docUrl.indexOf("/", protocolEndIndex + 3);
urlResult = docUrl.substring(beginIndex, endIndex);
}
return urlResult;
}
function isExternalUrlSafeForNavigation(urlStr) {
"use strict";
var regEx = new RegExp("^(http(s?)|ftp|file)://", "i");
return regEx.exec(urlStr);
}
function clickRefresh() {
"use strict";
var currentLocation = document.location.href;
var poundIndex = currentLocation.indexOf('#');
if (poundIndex != -1 && poundIndex + 1 < currentLocation.length && isExternalUrlSafeForNavigation(currentLocation.substring(poundIndex + 1))) {
window.location.replace(currentLocation.substring(poundIndex + 1));
}
}
function clickSearch() {
"use strict";
var currentLocation = document.location.href;
var poundIndex = currentLocation.indexOf('#');
if (poundIndex != -1 && poundIndex + 1 < currentLocation.length && isExternalUrlSafeForNavigation(currentLocation.substring(poundIndex + 1))) {
window.open('http://www.bing.com/search?q=' + currentLocation.substring(poundIndex + 1));
}
}
function getNavigationURL() {
"use strict";
var currentLocation = document.location.href;
var poundIndex = currentLocation.indexOf('#');
var possibleNavigationURL = currentLocation.substring(poundIndex + 1);
if (poundIndex != -1 && poundIndex + 1 < currentLocation.length && isExternalUrlSafeForNavigation(possibleNavigationURL)) {
return possibleNavigationURL;
} else {
return '';
}
}
function isMergedErrorFile() {
"use strict";
var url = document.location.href.toLowerCase();
var localAnchor = url.indexOf("#");
url = url.substring(0, (localAnchor == -1) ? url.length : localAnchor);
var query = url.indexOf("?");
url = url.substring(0, (query == -1) ? url.length : query);
return url.indexOf("errorpages.html", url.lastIndexOf("/") + 1) >= 0;
}
function getErrorCodeFromQuery() {
"use strict";
var errorCode = '';
var errorQueryKey = "error=";
var query = document.location.search;
var errorQueryStart = query.indexOf(errorQueryKey);
if (errorQueryStart > 0) {
var ampersandStart = query.indexOf("&", errorQueryStart);
if (ampersandStart > 0) {
errorCode = query.substring(errorQueryStart + errorQueryKey.length, ampersandStart);
} else {
errorCode = query.substring(errorQueryStart + errorQueryKey.length);
}
}
return errorCode;
}
function showErrorPage() {
"use strict";
if (isMergedErrorFile()) {
setWebpageUrl();
var errorCode = getErrorCodeFromQuery();
setDocumentTitle(errorCode);
initializeErrorCodeDiv(errorCode);
initializeContinueLink(errorCode);
document.getElementById(errorCode).style.display = "inline";
}
}
function goToLocalizedErrorPage() {
"use strict";
showErrorPage();
}
function setWebpageUrl() {
"use strict";
var url = getUrl();
var urlElements = document.getElementsByClassName("webpageURL");
for (var i = 0; i < urlElements.length; i++) {
urlElements[i].textContent = url;
}
}
function setDocumentTitle(errorCode) {
"use strict";
if (errorCode == 3) { document.title = L_Syntax_Title_TEXT; }
else if (errorCode == 4) { document.title = L_NavCancel_Title_TEXT; }
else if (errorCode == 5) { document.title = L_PhishingSite_Title_TEXT; }
else if (errorCode == 6) { document.title = L_InvalidCert_Title_TEXT; }
else if (errorCode == 7) { document.title = L_SSLNavCancel_Title_TEXT; }
else if (errorCode == 8) { document.title = L_UnknownProtocol_Title_TEXT; }
else if (errorCode == 9) { document.title = L_ForbidFraming_Title_TEXT; }
else if (errorCode == 10) { document.title = L_ProxyError_Title_TEXT; }
else if (errorCode == 12) { document.title = L_TLSError_Title_TEXT; }
else if (errorCode == 14) { document.title = L_HSTS_Title_TEXT; }
else if (errorCode == 17) { document.title = L_PDF_Title_TEXT; }
else if (errorCode == 18) { document.title = L_PDF_Title_TEXT; }
else if (errorCode == 400) { document.title = L_Http_400_Title_TEXT; }
else if (errorCode == 403) { document.title = L_Http_403_Title_TEXT; }
else if (errorCode == 404) { document.title = L_Http_404_Title_TEXT; }
else if (errorCode == 405) { document.title = L_Http_405_Title_TEXT; }
else if (errorCode == 406) { document.title = L_Http_406_Title_TEXT; }
else if (errorCode == 408) { document.title = L_Http_408_409_Title_TEXT; }
else if (errorCode == 409) { document.title = L_Http_408_409_Title_TEXT; }
else if (errorCode == 410) { document.title = L_Http_410_Title_TEXT; }
else if (errorCode == 500) { document.title = L_Http_500_Title_TEXT; }
else if (errorCode == 501) { document.title = L_Http_501_Title_TEXT; }
else if (errorCode == 505) { document.title = L_Http_501_Title_TEXT; }
else if (errorCode == 100004) { document.title = L_WPC_Title_TEXT; }
}
function initializeErrorCodeDiv(errorCode) {
"use strict";
if (errorCode == 1 || errorCode == 2) {
initializeDnsError();
}
else if (errorCode == 100004) {
handleWpcBlockedFrame();
}
}
function initializeContinueLink(errorCode) {
"use strict";
if (errorCode == 6) {
document.getElementById('continueLink').href = getNavigationURL();
}
}
function initializeDnsError() {
"use strict";
checkConnectionForDnsError();
if (document.addEventListener) {
addEventListener("offline", reportConnectionEvent, false);
}
else {
attachEvent("onoffline", reportConnectionEvent);
}
document.body.ononline = reportConnectionEvent;
document.body.onoffline = reportConnectionEvent;
}
function checkConnectionForDnsError() {
"use strict";
var notConnected = document.getElementById("NotConnected");
var pageUnavailable = document.getElementById("PageUnavailable");
if (navigator.onLine) {
document.title = L_Unavailable_Title_TEXT;
notConnected.style.display = "none";
pageUnavailable.style.display = "";
}
else {
document.title = L_Disconnected_Title_TEXT;
notConnected.style.display = "";
pageUnavailable.style.display = "none";
}
}
function reportConnectionEvent(e) {
"use strict";
if (!e) e = window.event;
if ('online' == e.type) {
setTimeout("clickRefresh()", 1000);
}
else {
checkConnectionForDnsError();
}
}
function getWpcBlockPageURL() {
"use strict";
var params = document.location.search;
var server = "origin.sdx.microsoft.com";
var errorParam = "error=100004&"
var queryIdx = params.indexOf(errorParam);
if (queryIdx != -1) {
params = params.substring(queryIdx + errorParam.length);
}
var isIntEnv = "env=int&";
var intIdx = params.indexOf(isIntEnv);
if (intIdx != -1) {
server = "sdx.microsoft-int.com";
params = params.substring(intIdx + isIntEnv.length);
}
return 'https://' + server + '/family/restricted-web2?' + params;
}
function handleWpcBlockedFrame() {
"use strict";
var link = document.getElementById('wpcReqAcc');
if (link) {
link.href = getWpcBlockPageURL();
}
}
|
ประวัติการแก้ไข 2016-06-08 14:07:58 2016-06-08 14:09:33
|
|
|
|
Date :
2016-06-08 14:04:19 |
By :
Rocket |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|