<?php 
$conn=mysqli_connect("localhost", "avcampus_events", "5CJxGD.@yiCH", "avcampus_events") or die("Couldn't connet to SQL server");
if(!$conn){
    echo "Database Connection Failed";
}
date_default_timezone_set("Asia/Kolkata");
$regon = date("Y-m-d H:i:s");
error_reporting(1);
ini_set('display_errors', 1);

// function insert_val($conn, $input) {
//     $trimmed_input = trim($input);
//     //$escaped_input = addslashes($trimmed_input);
//     // Use mysqli_real_escape_string to escape special characters
//     $sanitized_input = mysqli_real_escape_string($conn, $trimmed_input);
    
//     // Return sanitized input
//     return $sanitized_input;
// }
function insert_val($conn, $input) {
    if (is_array($input)) {
        // Convert each value to a sanitized string, then implode
        $sanitized_array = array_map(function($value) use ($conn) {
            return mysqli_real_escape_string($conn, trim($value));
        }, $input);

        return implode(', ', $sanitized_array); // Join with comma or your chosen delimiter
    } else {
        return mysqli_real_escape_string($conn, trim($input));
    }
}
function encrypt_pass($string) {
    $result = '';
    for ($i = 0; $i < strlen($string); $i++) {
        $char = substr($string, $i, 1);
        $keychar = substr(ENC_KEY, $i % strlen(ENC_KEY), 1); // fixed
        $char = chr(ord($char) + ord($keychar));
        $result .= $char;
    }
    return base64_encode($result);
}

function decrypt_pass($string) {
    $result = '';
    $string = base64_decode($string);
    for ($i = 0; $i < strlen($string); $i++) {
        $char = substr($string, $i, 1);
        $keychar = substr(ENC_KEY, $i % strlen(ENC_KEY), 1); // fixed
        $char = chr(ord($char) - ord($keychar));
        $result .= $char;
    }
    return $result;
}

function strip_slashes($val){
	return stripslashes(trim($val));
}
function db_now(){
	return date('Y-m-d');
}

function db_now_time(){
	return date('Y-m-d H:i:s');
}

function display_now(){
	return date('d-m-Y');
}

function display_now_time(){
	return date('d-m-Y H:i');
}

function display_now_timee(){
	return date('d-m-Y H:i');
}