Path : /var/www/html/smart_kpp2_v2/
File Upload :
Current File : /var/www/html/smart_kpp2_v2/login_1.php

<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
$p = (get_magic_quotes_gpc()) ? $_GET['p']  : addslashes($_GET['p']);

$url_id = (get_magic_quotes_gpc()) ? $_GET['url_id']  : addslashes($_GET['url_id']);
$userId = (get_magic_quotes_gpc()) ? $_GET['userId']  : addslashes($_GET['userId']); //line id

	$sql_officename = "select * from system_office_name";
    $dbquery_officename = mysqli_query($connect,$sql_officename);
    $result_officename = mysqli_fetch_array($dbquery_officename);
    $office_name = $result_officename['office_name'];

    //ตรวจสอบการลงทะเบียน Line ID
    $sql_line = "select * from line_user where line_userId='$userId' ";
    $dbquery_line= mysqli_query($connect,$sql_line);
    $result_line = mysqli_fetch_array($dbquery_line);
    $totalRows_line_userId = mysqli_num_rows($dbquery_line); 
    $p_id = $result_line['person_id']; //เลข ปชช.ที่เชื่อมกับ Line 

//exit();


$user_agent = $_SERVER['HTTP_USER_AGENT'];
function getOS() { 
    global $user_agent;
    $os_platform = "desktop";
    $os_array = array(
        '/windows nt 10.0/i' => 'Windows 10',
        '/windows nt 6.3/i' => 'Windows 8.1',
        '/windows nt 6.2/i' => 'Windows 8',
        '/windows nt 6.1/i' => 'Windows 7',
        '/windows nt 6.0/i' => 'Windows Vista',
        '/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
        '/windows nt 5.1/i' => 'Windows XP',
        '/windows xp/i' => 'Windows XP',
        '/windows nt 5.0/i' => 'Windows 2000',
        '/macintosh|mac os x/i' => 'Mac OS X',
        '/mac_powerpc/i' => 'Mac OS 9',
        '/linux/i' => 'Linux',
        '/ubuntu/i' => 'Ubuntu',
        '/iphone/i' => 'iPhone',
        '/ipod/i' => 'iPod',
        '/ipad/i' => 'iPad',
        '/android/i' => 'Android',
        '/blackberry/i' => 'BlackBerry',
        '/webos/i' => 'Mobile'
    );
    foreach ($os_array as $regex => $value) { 
        if (preg_match($regex, $user_agent)) {
            $os_platform = $value;
            if(($os_platform=='Android') or ($os_platform=='BlackBerry') or ($os_platform=='iPhone') or ($os_platform=='iPad')){
                $os_platform="mobile";
            } else {
                $os_platform="desktop";
            }
        }
    }   
    return $os_platform;
}
$user_os = getOS();
?>

<!DOCTYPE html>
<html lang="th">
<head>
    <title>เข้าสู่ระบบ Smart Area : YST1</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="images/favicon.ico">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Kanit', 'Arial', sans-serif;
        }

        body {
            background: url('images/bg_yst1.jpg') no-repeat center center fixed;
            background-size: cover;
            background-position: center;
            display: flex;
            justify-content: flex-start; /* ปรับให้ชิดซ้าย */
            align-items: center;
            min-height: 100vh;
            position: relative;
        }

        body::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.2); /* เพิ่มความมืดเล็กน้อย */
            z-index: -1;
        }

        .login {
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
            backdrop-filter: blur(12px); /* Glassmorphism effect */
            border-radius: 15px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
            width: 400px;
            padding: 30px;
            text-align: center;
            border: 1px solid rgba(255, 255, 255, 0.3);
            margin-left: 10%; /* ห่างจากขอบซ้าย 10% */
            transition: transform 0.3s ease;
        }

        .login:hover {
            transform: translateY(-5px); /* เอฟเฟกต์ลอยเมื่อ hover */
        }

        .login-header {
            margin-bottom: 20px;
        }

        .login-header img {
            max-width: 100%;
            height: auto;
            margin-bottom: 10px;
        }

        .login-header p {
            color: #fff;
            font-size: 14px;
            opacity: 0.8;
        }

        .inputlabel {
            color: #0dcec1;
            font-weight: bold;
            font-size: 20px;
            margin-bottom: 8px;
            text-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5);
        }

        .inputbox {
            width: 100%;
            padding: 12px 15px;
            margin-bottom: 15px;
            border: 2px solid rgba(255, 255, 255, 0.5);
            border-radius: 8px;
            font-size: 16px;
            background: rgba(255, 255, 255, 0.9);
            transition: border-color 0.3s, box-shadow 0.3s;
        }

        .inputbox:focus {
            border-color: #4CAF50;
            box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
            outline: none;
        }

        .button {
            padding: 12px 25px;
            background: linear-gradient(45deg, #4CAF50, #66BB6A);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-right: 10px;
        }

        .button:hover {
            background: linear-gradient(45deg, #45a049, #5cb860);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .button[type="reset"] {
            background: linear-gradient(45deg, #FF8C00, #FFB300);
        }

        .button[type="reset"]:hover {
            background: linear-gradient(45deg, #E67300, #FFA000);
        }

        .remember-forgot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 15px 0;
            font-size: 14px;
            color: #fff;
        }

        .remember-me input {
            margin-right: 5px;
        }

        .forgot-password a {
            color: #0dcec1;
            font-weight: bold;
            text-decoration: none;
            text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
        }

        .forgot-password a:hover {
            color: #FF8C00;
            text-decoration: underline;
        }

        .browser-recommendation {
            margin-top: 20px;
            color: #fff;
            font-size: 12px;
            opacity: 0.9;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
        }

        @media (max-width: 768px) {
            .login {
                width: 90%;
                margin-left: 5%;
                padding: 20px;
            }

            .inputbox {
                padding: 10px;
            }

            .button {
                padding: 10px 20px;
            }
        }

        .clr {
            clear: both;
        }
    </style>
    <link href="https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;600&display=swap" rel="stylesheet">
    <script language="javascript" type="text/javascript">
        function setFocus() {
            document.loginForm.username.select();
            document.loginForm.username.focus();
        }
    </script>
</head>
<body onLoad="setFocus();">
    <div id="ctr" class="login">
    
        <div class="login-form">
            <div class="login-header">
                <h1><img src="images/logo.png" alt="Smart Area Logo"></h1>
                <p>หากเป็นบุคลากรในหน่วยงาน ถ้ายังไม่มี Username และ Password สามารถ Login ด้วยเลขประจำตัวประชาชน</p>
            </div>
            <form action="index.php" method="post" name="loginForm" id="loginForm">

            <?php if($p==""){ //login ปกติ ?>

                <div class="form-block">
                    <div class="inputlabel">ชื่อผู้ใช้งาน</div>
                    <input name="username" type="text" class="inputbox" size="15" 
                        required title="กรุณากรอกชื่อผู้ใช้"
                        oninvalid="this.setCustomValidity('กรุณากรอกชื่อผู้ใช้')"
                        oninput="this.setCustomValidity('')">
                    <div class="inputlabel">รหัสผ่าน</div>
                    <input name="pass" type="password" class="inputbox" size="15"
                        required title="กรุณากรอกรหัสผ่าน"
                        oninvalid="this.setCustomValidity('กรุณากรอกรหัสผ่าน')"
                        oninput="this.setCustomValidity('')">
                    <input name="user_os" type="hidden" value="<?php echo $user_os ?>">
                    <div align="left">
                        <input type="submit" name="login_submit" class="button" value="เข้าสู่ระบบ" />
                        <input type="reset" class="button" value="Reset" />
                    </div>
                    <div class="remember-forgot">
                        <div class="remember-me">
                            <input type="checkbox" id="remember">
                            <label for="remember">จดจำฉัน</label>
                        </div>
                        <div class="forgot-password">
                            <a href="forgotpassword.php?p=chk">ลืมรหัสผ่าน</a>
                        </div>
                    </div>
                </div>

                <?php } //end login ปกติ ?>

<?php if($p > ""){ //login line ?>
<?php
/** ensure this file is being included by a parent file */
//defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
require_once "amssplus_connect.php";
//require_once "modules/permission/time_inc.php"; 
$sql_chk = "select * from system_user where person_id='$p_id'";
$dbquery_chk = mysqli_query($connect,$sql_chk);
$result1_chk = mysqli_fetch_array($dbquery_chk);
$username = $result1_chk['username'];
$pass = $result1_chk['userpass'];
//เขต
$sql_person = "select * from person_main where person_id='$p_id' ";
$dbquery_person = mysqli_query($connect,$sql_person);
$result_person = mysqli_fetch_array($dbquery_person);
$total_pid = mysqli_num_rows($dbquery_person);
$position_code = $result_person['position_code'];
$department = $result_person['department'];
$id_person = $result_person['id'];
$fullname=$result_person['name']." ".$result_person['surname'];
    //หาตำแหน่ง
    $sql_position = "select * from  person_position where position_code='$position_code' ";
    $dbquery_position = mysqli_query($connect,$sql_position);
    $result_position = mysqli_fetch_array($dbquery_position);
    $position_name = $result_position['position_name'];
    //หาหน่วยงาน
    $sql_workgroup = "select * from  system_workgroup where workgroup='$department' ";
    $dbquery_workgroup = mysqli_query($connect,$sql_workgroup);
    $result_workgroup = mysqli_fetch_array($dbquery_workgroup);
    $school_name = $result_workgroup['workgroup_desc'];
?>  
<div id="ctr" align="center">
    <table width="100%">
        <tr>
            <td><center><h3><font color='red'>สวัสดีคุณ</font> <font color='blue'><?php echo $fullname?></font></h3>
            <h4>เข้าระบบ Smart Area YST1 ด้วย <br><font color='green'><b>LINE Notify</b></font></h4>
            </center>
            <input name="username" type="hidden"  class="form-control" placeholder="ชื่อผู้ใช้งาน (Username)" size="15" value="<?php echo $username?>"/><br>
            <input name="pass" type="hidden" class="form-control" placeholder="รหัสผ่าน (Password)" value="<?php echo $pass?>"/><br>
            <input name="p" type="hidden"  class="form-control" value="1" size="15" />
            <input name="user_os" type="hidden" value="desktop">
            <input name="url_id" type="hidden" size="100" value="<?php echo $url_id ?>">
            <button type="submit" name="login_submit" class="btn btn-primary btn-large btn-block"> กดปุ่มเพื่อเข้าสู่ระบบ </button>
            </td>
        </tr>
    </table>  
</div>  
<?php } //end login line ?>




            </form>
            <div class="browser-recommendation">
                <p>SmartArea by DLiCT YST1.GO.TH V.6.65 (2025)<br>กลุ่มส่งเสริมการศึกษาทางไกล เทคโนโลยีสารสนเทศและการสื่อสาร</p>
                <p>แนะนำให้ใช้บราวเซอร์ Google Chrome</p>
            </div>
        </div>
    </div>
    <noscript>
        <div style="color: red; text-align: center; margin-top: 20px; background: white; padding: 10px; border-radius: 5px;">
            !Warning! Javascript must be enabled for proper operation of the Administrator
        </div>
    </noscript>
    <div class="clr"></div>
    
</body>
</html>