403Webshell
Server IP : 172.67.187.206  /  Your IP : 172.71.28.156
Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30
System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586
User : SYSTEM ( 0)
PHP Version : 5.6.30
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  E:/Inetpub/www/supply_system/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : E:/Inetpub/www/supply_system/functions.php
<?php
// ตรวจสอบว่า config.php ถูก include แล้วหรือยัง ถ้ายังให้ include
if (!isset($conn)) {
    include_once 'config.php';
}

/**
 * Function to redirect to another page
 * @param string $url The URL to redirect to
 */
function redirect($url) {
    header("Location: " . $url);
    exit(); // Ensure script stops execution after redirect
}

/**
 * Function to check if the user is logged in
 * @return bool True if logged in, false otherwise
 */
function isLoggedIn() {
    return isset($_SESSION['user_id']);
}

/**
 * Function to get user data from session
 * @param string $key The key of the user data (e.g., 'user_id', 'full_name', 'user_type')
 * @return mixed|null The user data or null if not found
 */
function getUserData($key) {
    return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
}

/**
 * Function to format MySQL DATETIME or DATE to Thai format
 * Example: 2025-10-29 19:40:36 -> 29 ต.ค. 2568 19:40 น.
 * Example: 2025-10-29 -> 29 ต.ค. 2568
 * @param string|null $datetime_str The datetime string from MySQL
 * @param bool $include_time Include time in the output
 * @param bool $short_month Use short month name (e.g., ม.ค.)
 * @return string The formatted Thai date/time or empty string if input is invalid
 */
function formatThaiDate($datetime_str, $include_time = true, $short_month = true) {
    if (empty($datetime_str) || $datetime_str === '0000-00-00 00:00:00' || $datetime_str === '0000-00-00') {
        return '';
    }

    $thai_months_full = array(
        "1" => "มกราคม", "2" => "กุมภาพันธ์", "3" => "มีนาคม", "4" => "เมษายน",
        "5" => "พฤษภาคม", "6" => "มิถุนายน", "7" => "กรกฎาคม", "8" => "สิงหาคม",
        "9" => "กันยายน", "10" => "ตุลาคม", "11" => "พฤศจิกายน", "12" => "ธันวาคม"
    );
    $thai_months_short = array(
        "1" => "ม.ค.", "2" => "ก.พ.", "3" => "มี.ค.", "4" => "เม.ย.",
        "5" => "พ.ค.", "6" => "มิ.ย.", "7" => "ก.ค.", "8" => "ส.ค.",
        "9" => "ก.ย.", "10" => "ต.ค.", "11" => "พ.ย.", "12" => "ธ.ค."
    );

    try {
        $timestamp = strtotime($datetime_str);
        if ($timestamp === false) {
            return ''; // Invalid date/time string
        }

        $date_d = date('j', $timestamp);
        $date_m = date('n', $timestamp);
        $date_y = date('Y', $timestamp) + 543; // Convert to Buddhist Era

        $month_name = $short_month ? $thai_months_short[$date_m] : $thai_months_full[$date_m];

        $formatted_date = "$date_d $month_name $date_y";

        if ($include_time && strpos($datetime_str, ':') !== false) {
            $time_H = date('H', $timestamp);
            $time_i = date('i', $timestamp);
            $formatted_date .= " $time_H:$time_i น.";
        }

        return $formatted_date;
    } catch (Exception $e) {
        return ''; // Handle potential errors during date processing
    }
}

/**
 * Function to sanitize input data
 * @param mysqli $conn The database connection
 * @param string $data The input data
 * @return string The sanitized data
 */
function sanitize_input($conn, $data) {
    // Remove leading/trailing whitespace
    $data = trim($data);
    // Remove backslashes
    $data = stripslashes($data);
    // Convert special characters to HTML entities
    $data = htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
    // Escape special characters for SQL query
    $data = mysqli_real_escape_string($conn, $data);
    return $data;
}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit