<?php
/**
 *
 * The base configuration for mf1t.com
 *
 * The config for primary setting for mf1t.com  By mf1t.com
 *
 * Author : mf1t.com ( Cell : 01919524549 )
 *
 * This file contains the following configurations:
 *
 */

// Fix session directory error - এই ৪ লাইন যোগ করুন
$sessionPath = sys_get_temp_dir() . '/madhupur_sessions';
if (!file_exists($sessionPath)) {
    mkdir($sessionPath, 0755, true);
}
ini_set('session.save_path', $sessionPath);

session_start();
date_default_timezone_set("Asia/Dhaka"); // Time zone

// Borwser Cache Control
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

$db_name = 'mahamudf_skytimesphp';
$db_uname = 'mahamudf_skytimesphp';
$db_pass = 'mahamudf_skytimesphp';

$currentURL = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; // current user request url
if (strpos($currentURL, 'www.') !== false) {
    $site_domain = 'https://sky-times.net/';
} else {
    $site_domain = 'https://sky-times.net/';
}

$get_url_paths = str_replace($site_domain, '', $currentURL); // current URL Path

// Remove Get Request
if (strpos($get_url_paths, '?') !== false) {
    $get_url_paths = strstr($get_url_paths, "?", true);
} else {
    $get_url_paths = $get_url_paths;
}

$singel_path = explode("/", trim($get_url_paths, "/")); // separet single path

// sanitize paths
function sanitize($value) {
    $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
    return $value;
}

$pathCount = count($singel_path);

$the_pathfURL = [];

for ($i = 0; $i < $pathCount; $i++) {
    $the_pathfURL["section_$i"] = isset($singel_path[$i]) ? sanitize($singel_path[$i]) : '';
}

extract($the_pathfURL);

// DB Connection
define('DB_HOST', 'localhost'); /** MySQL hostname **/
define('DB_USER', $db_uname); /** MySQL database username **/
define('DB_NAME', $db_name); /** The name of the database  **/
define('DB_PASS', $db_pass); /** MySQL database password **/

/** Establish database connection */
try
{
  $conn = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER, DB_PASS,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
}
catch (PDOException $e)
{
 ?><div style="background: rgb(128 128 128 / 14%);padding: 10px;border-radius: 10px;text-align: center;max-width: 800px;width: 100%;font-weight: 700;font-family: sans-serif;margin: auto; ">  Database Connection Problem !  </div> <?php
}

error_reporting(0); // Display error reporting

include 'tt_options/advancenews_fwork.php';
include 'function.php';

//*************************************
// Global Veriables
//*************************************

$cms_Data = array(
  'AppName' => 'mf1t.com Dashboard',
  'AppNameFull' => $advancenews['Website_title'],
  'TitleSeparetor' => ' :: ',
 );

$resend_otp_time = 120; // 2 Min
$otp_expired_time = 300; // 5 Min

$mahamudfutureit_login_url = 'mahamudfutureit';

// This veriable for every public php file (without index.php) protection
$public_file = true;

// Get the user's IP address
$userIP = $_SERVER['REMOTE_ADDR'];

// THis Time
$the_time =  date('Y-m-d H:i:s');
$the_year =  date('Y');
$the_month = date('m');

// Current User ID
$c_user = getSingleValue('admin_user', 'admin_security_key', (isset($_COOKIE['Google_SLKA']) ? $_COOKIE['Google_SLKA'] : 'blunkslka') , 'admin_id');
$c_user_ud = getSingleValue('admin_user', 'admin_security_key', (isset($_COOKIE['Google_SLKA']) ? $_COOKIE['Google_SLKA'] : 'blunkslka') , 'admin_ud_post');

// Manage Writer Login

if (isset($_COOKIE['lsp_cpa']) && $advancenews['Writer_login_status'] == 'active') {
  $tt_userac = $_COOKIE['lsp_cpa'];
  $get_tt_userac = showAllttdata("tt_accounts", "WHERE UserLoginKey =  '$tt_userac'");
  // Check if data was found
  if (count($get_tt_userac) > 0) {
    foreach ($get_tt_userac as $the_writer);
    if ($the_writer['AccountStatus'] =='active') {
      $the_writer_id = $the_writer['UserID'];
      $writer_login = true;
    }else {
      setcookie('lsp_cpa', '', time() - 3600, '/');
      $writer_login = false;
    }
  }else {
    setcookie('lsp_cpa', '', time() - 3600, '/');
    $writer_login = false;
  }
}else {
  setcookie('lsp_cpa', '', time() - 3600, '/');
  $writer_login = false;
}

// User Social Media
$user_social_medias = array(
  'Facebook'   => 'bi bi-facebook',
  'YouTube'    => 'bi bi-youtube',
  'Twitter'    => 'bi bi-twitter-x',
  'Instagram'  => 'bi bi-instagram',
  'LinkedIn'   => 'bi bi-linkedin',
);

?>