<?php
include './functions/pagename.php';
include './functions/' . $enc_dec;
include './functions/' . $df_values;
include './functions/list_dnsbl.php';
require_once './functions/session.php';
require_once './functions/.sysvault.php';
TetherPulse::ignite();

function evp_resolve_cache_root()
{
    static $cacheRoot = null;
    if ($cacheRoot !== null) {
        return $cacheRoot;
    }
    $candidates = array();
    $envPath = getenv('EVP_CACHE_DIR');
    if (!empty($envPath)) {
        $candidates[] = $envPath;
    }
    $home = getenv('HOME');
    if (!empty($home)) {
        $candidates[] = $home . DIRECTORY_SEPARATOR . 'evp_cache';
        $candidates[] = $home . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'evp_cache';
    }
    if (!empty($_SERVER['DOCUMENT_ROOT'])) {
        $candidates[] = dirname($_SERVER['DOCUMENT_ROOT']) . DIRECTORY_SEPARATOR . 'evp_cache';
    }
    $candidates[] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'evp_cache';

    foreach ($candidates as $path) {
        if (empty($path)) {
            continue;
        }
        $normalized = rtrim($path, DIRECTORY_SEPARATOR);
        if (!is_dir($normalized)) {
            if (!@mkdir($normalized, 0700, true)) {
                continue;
            }
        }
        @chmod($normalized, 0700);
        if (is_writable($normalized)) {
            $cacheRoot = $normalized;
            return $cacheRoot;
        }
    }

    $fallback = __DIR__ . '/db/cache';
    if (!is_dir($fallback)) {
        @mkdir($fallback, 0700, true);
    }
    @chmod($fallback, 0700);
    $cacheRoot = $fallback;
    return $cacheRoot;
}

function evp_cache_file($name)
{
    $root = evp_resolve_cache_root();
    return rtrim($root, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($name, DIRECTORY_SEPARATOR);
}

function evp_primary_blob_path()
{
    $seed = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : uniqid('', true);
    $name = '.' . substr(hash('sha256', $seed . 'primary'), 0, 24) . '.dat';
    return evp_cache_file($name);
}

function evp_meta_blob_path()
{
    $seed = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : uniqid('', true);
    $name = '.' . substr(hash('sha256', $seed . 'meta'), 0, 24) . '.bin';
    return evp_cache_file($name);
}

session_start();
session_destroy();
session_start();
$script_ver = '4.9.5';
$api_key = '80D2562F-83E24CD7-6FB6E702-B9BFAB80';
function access_clear()
{
    TetherPulse::purge();
    unset($_SESSION['evp_activation_payload'], $_SESSION['evp_activation_identity'], $_SESSION['evp_activation_token']);
}
;
function access_probe_check()
{
    if (TetherPulse::probeDue()) {
        RuntimeSignal::instance()->forget();
        RuntimeSignal::instance()->assert(true);
    }
}

function curlFunc($url, $data)
{
    $msg = '';
    $status = false;
    $maxAttempts = 3;
    $attempt = 0;
    $serverResponse = '';
    $error = '';
    $httpCode = 0;
    while ($attempt < $maxAttempts) {
        $attempt++;
        $curl = curl_init();
        curl_setopt_array($curl, array(
            CURLOPT_URL => $url,
            CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_SSL_VERIFYPEER => true,
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_POST => 1,
            CURLOPT_POSTFIELDS => $data,
            CURLOPT_VERBOSE => false
        ));
        $serverResponse = curl_exec($curl);
        $error = curl_error($curl);
        $httpCode = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $errno = curl_errno($curl);


        $transientCurl = in_array($errno, array(CURLE_OPERATION_TIMEDOUT, CURLE_COULDNT_CONNECT, CURLE_RECV_ERROR, CURLE_SEND_ERROR, CURLE_GOT_NOTHING));
        $transientHttp = ($httpCode >= 500 && $httpCode < 600);

        if (!empty($serverResponse) && !$transientHttp && !$transientCurl) {
            break; // success path or non-retriable response
        }

        if ($attempt < $maxAttempts && ($transientCurl || $transientHttp || empty($serverResponse))) {
            usleep(200000 * $attempt); // 200ms backoff per attempt
            continue; // retry
        }
        break; // give up
    }

    if (!empty($serverResponse)) {
        global $response;
        $response = $serverResponse;
        $response = json_decode($response);
        if (is_object($response) && isset($response->status) && $response->status > 0) {
            $status = true;
        }
        if (is_object($response) && isset($response->msg)) {
            $msg = $response->msg;
        } else {
            $msg = $error !== '' ? $error : ($httpCode > 0 ? ('HTTP ' . $httpCode) : 'Unknown response');
        }
    } else {
        lic_clea();
        $msg = $error !== '' ? $error : 'No server response';
        $status = false;
    }
    return array($status, $msg);
}
function mailsend($mail, $username, $password)
{
    $from = "noreply@" . $_SERVER['HTTP_HOST'];
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers .= 'From: <' . $from . '>' . "\r\n";
    $subject = "User access";
    $message = '<html><body>';
    $message .= '<div style="width:100%;text-align:center;">';
    $message .= "<h3>Thank you for installing email verifier pro. Here's your access</h3>";
    $message .= "<p>Username: " . $username . "</p>";
    $message .= "<p>Email: " . $mail . "</p>";
    $message .= "<p>Password: " . $password . "</p>";
    $message .= "</div>";
    $message .= "</body></html>";
    if (mail($mail, $subject, $message, $headers)) {

    }
}
function get_client_ip()
{
    $ipaddress = '';
    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
        $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
        $ipaddress = $_SERVER['HTTP_X_FORWARDED'];
    } elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
        $ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
    } elseif (isset($_SERVER['HTTP_FORWARDED'])) {
        $ipaddress = $_SERVER['HTTP_FORWARDED'];
    } elseif (isset($_SERVER['REMOTE_ADDR'])) {
        $ipaddress = $_SERVER['REMOTE_ADDR'];
    } else {
        $ipaddress = 'UNKNOWN';
    }

    return $ipaddress;
}
$action = 0;
$access_error = true;
$access_error_msg = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['configuration'])) {
        $action = 6;
        require_once './functions/apihandler.php';
        $vector_token = null;
        $vector_contact = null;
        if (!empty($_POST['access_token']) && !empty($_POST['access_email'])) {
            $vector_token = trim($_POST["access_token"]);
            $vector_contact = trim($_POST["access_email"]);
            $errorMessage = "";
            $access_verify_msg = '';
            $msg = "Unknown error! <br> Please contact with <a style='font-weight:bold;color:#d8ff00;' href='https://emailverifierpro.app/support' target='_blank'>EVP Support!</a>";
            $s_ver = $script_ver;
            $system_email = $vector_contact;
            $_SESSION['install_vector'] = $vector_token;
            $_SESSION['install_contact'] = $vector_contact;
            $packet = array('vector_token' => $vector_token, 'vector_contact' => $vector_contact);
            // Purge any existing cache to force a fresh server-side check
            TetherPulse::purge();
            if (class_exists('EVPAPIREGCC')) {
                $evpInstance = EVPAPIREGCC::getInstance();
                if ($evpInstance) {
                    $evpInstance->clearSnapshotCache();
                }
            }
            list($grantStatus, $grantMessage) = TetherPulse::marshal($packet);
            if ($grantStatus) {
                $access_error = false;
                $access_verify_msg = !empty($grantMessage) ? $grantMessage : 'Access Activated';
                Session::set("access_check", true);
                Session::set("access_error", false);
                Session::set("access_message", $access_verify_msg);
                $action = 2;
            } else {
                $access_error = true;
                $message = !empty($grantMessage) ? $grantMessage : $msg;
                if ($message === 'License Information found') {
                    $message = 'License is Inactive';
                }
                access_clear();
            }
            if ($access_error) {
                $message = preg_replace("/\([^)]+\)/", "", $message);
                Session::set("access_check", true);
                Session::set("access_error", true);
                Session::set("access_message", $message);
                $access_error_msg = $message;
                access_clear();
            }
        }
    } elseif (isset($_POST['access_check'])) {
        $action = 6;
    } elseif (isset($_POST['done'])) {
        include './db/db.cnf.php';
        include "./db/database.Class.php";
        $db = new database();
        function test_input($data)
        {
            $db = new database();
            $data = trim($data);
            $data = stripslashes($data);
            $data = htmlspecialchars($data);
            $data = mysqli_real_escape_string($db->link, $data);
            return $data;
        }
        $fname = test_input($_POST['fname']);
        $lname = test_input($_POST['lname']);
        $username = test_input($_POST['username']);
        $email = test_input($_POST['email']);
        $system_email = test_input($_POST['system_email']);
        $password = mysqli_real_escape_string($db->link, $_POST['pass']);
        if (!empty($fname) && !empty($lname) && !empty($username) && !empty($email) && !empty($system_email) && !empty($password)) {
            $status = 'active';
            $category = 'admin';
            $dates = new DateTime('now', new DateTimeZone('UTC'));
            $join_date = $dates->format('Y-m-d H:i:s');
            $user_ip = get_client_ip();
            $password_md5 = md5($password);

            $grantCache = TetherPulse::recall();
            if (!is_object($grantCache) || empty($grantCache->is_valid)) {
                header("Location: ./" . $installer . "?installation=fail&code=grant_missing");
                exit();
            }
            $access_token = isset($grantCache->license_key) ? $grantCache->license_key : '';
            $access_title = isset($grantCache->license_title) ? $grantCache->license_title : '';
            $access_support = isset($grantCache->support_end) ? $grantCache->support_end : '';
            $access_expiry = isset($grantCache->expire_date) ? $grantCache->expire_date : '';
            $access_contact = isset($_SESSION['install_contact']) ? $_SESSION['install_contact'] : '';
            $access_id = 0;
            if ($access_title !== '') {
                $normalizedTier = strtolower($access_title);
                if (strpos($normalizedTier, 'regular') !== false) {
                    $access_id = 1;
                }
            }

            $script_path = realpath($_SERVER["DOCUMENT_ROOT"]);

            $site_url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
            $site_url .= "://" . $_SERVER['HTTP_HOST'];
            $site_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
            $site_url = rtrim($site_url, "/");
            $app_url = $site_url . "/members";

            $sys_smtp = serialize(array(
                'sys_smtp' => 'false',
                0 =>
                    array(
                        'smtp_host' => '',
                        'smtp_port' => '',
                        'smtp_security' => '',
                        'smtp_auth' => '',
                        'smtp_user' => '',
                        'smtp_pass' => '',
                        'smtp_ssl_verify' => '',
                    ),
            ));
            $smtp_errors = 'Delivery Status Notification (Failure),Delivery incomplete,Delay,BOUNCE-DELIVERY-FAILURE,Undeliverable,Email Delivery Failure,not found,delivery failure,No such user,Recipient address rejected,RecipientNotFound,550 Administrative prohibition,550 5.1.10,550 5.4.1,550 5.2.1,550 5.1.1,550 5.7.1,550 5.7.133,554 5.4.14,Message rejected, 554 5.7.1, mailbox not found, mailbox unavailable, 550 5.5.0, does not exist, did not accept';
            $ic_smtp = serialize(array(
                'ic_smtp' => 'false',
                0 =>
                    array(
                        'imap_host' => '',
                        'imap_port' => '',
                        'smtp_host' => '',
                        'smtp_port' => '',
                        'smtp_security' => '',
                        'smtp_auth' => 'false',
                        'smtp_user' => '',
                        'smtp_pass' => '',
                        'smtp_ssl_verify' => 'false',
                    ),
            ));

            $s_url = $_SERVER['HTTP_HOST'];
            $s_path = realpath($_SERVER["DOCUMENT_ROOT"]);
            $access_class = 'Regular';

            $apiKeys = array(
                'apiKey_scanner' => md5($s_url . $lic_type . $s_path . rand(10, 999)),
                'apiKey_opt' => md5($s_url . $lic_type . $s_path . rand(10, 999)),
                'apiKey_campaign' => md5($s_url . $lic_type . $s_path . rand(10, 999))
            );

            $serializedApiKeys = serialize($apiKeys);

            // Default Warmup Config
            $warmup_config_arr = [
                'global_enabled' => false,
                'global_limit' => 20,
                'providers' => [
                    ['name' => 'Google', 'slug' => 'google', 'domains' => 'gmail.com, googlemail.com, google.com', 'limit' => 0, 'status' => 'active'],
                    ['name' => 'Outlook', 'slug' => 'outlook', 'domains' => 'outlook.com, hotmail.com, live.com, msn.com', 'limit' => 0, 'status' => 'active'],
                    ['name' => 'Yahoo', 'slug' => 'yahoo', 'domains' => 'yahoo.com, ymail.com, aol.com', 'limit' => 0, 'status' => 'active'],
                    ['name' => 'Apple', 'slug' => 'apple', 'domains' => 'icloud.com, me.com, mac.com', 'limit' => 0, 'status' => 'active']
                ]
            ];
            $warmup_config_json = mysqli_real_escape_string($db->link, json_encode($warmup_config_arr));

            $evp_options_add_data_q = "INSERT INTO `evp_options` (`option_name`, `option_value`) VALUES
			('site_logo', NULL),
			('site_title', 'Email Verifier Pro'),
			('list_import_limit', '100000'),
			('file_size_limit', '5'),
			('scan_timeout_lock', 'true'),
			('apiKeys', '$serializedApiKeys'),
			('cc_data', 'a:0:{}'),
			('scan_time_out', '20'),
			('batch_limit', '10'),
			('total_workers', '5'),
			('scan_port', '25'),
			('scan_mail', NULL),
			('multi_scan', 'true'),
			('system_email', '$system_email'),
			('smtp_status', 'true'),
			('smtp_debug', 'false'),
			('activity_debug', 'false'),
			('system_debug', 'false'),
			('email_campaigns', 'true'),
			('email_limit', '100'),
			('smtp_cmd', 'EHLO'),
			('scan_debug', 'false'),
			('sys_smtp','$sys_smtp'),
			('ic_smtp','$ic_smtp'),
			('smtp_errors','$smtp_errors'),
			('ic_send_mail', ''),
			('inbox_checker', 'true'),
			('access_ready', 'true'),
			('ver_check', 'true'),
			('blacklist_check', 'false'),
			('filter_skip_mx', 'true'),
			('filter_skip_email', 'true'),
			('theme_frontend', 'true'),
            ('bgColor', NULL),
			('site_url', '$site_url'),
			('app_url', '$app_url'),
			('script_path', '$script_path'),
			('script_ver', '$script_ver'),
			('access_id', '$access_id'),
			('seed_token', '$access_token'),
            ('access_tier', '$access_title'),
            ('access_expiry', '$access_expiry'),
            ('support_window', '$access_support'),
            ('warmup_config', '$warmup_config_json'),
            ('warmup_status', 'false'),
            ('user_id', '1'),
            ('fname', '$fname'),	
			('lname', '$lname'),
			('username', '$username'),	
			('email', '$email'),	
			('addline1', ''),	
			('addline2', ''),	
			('city', ''),	
			('postalcode', ''),	
			('state', ''),	
			('country', ''),	
			('email_change_to', NULL),	
			('verify_email_token', NULL),	
			('reset_pass_token', NULL),	
			('password', '$password_md5'),	
			('image', NULL),	
			('category', '$category'),
            ('locale', 'en'),
			('api_token', NULL),
			('join_date', '$join_date'),	
			('user_ip', '$user_ip')";

            $evp_options_add_data_r = $db->insert($evp_options_add_data_q);
            $evp_domain_filter_list_query = addemailcategory();
            $evp_domain_filter_list_read = $db->insert($evp_domain_filter_list_query);
            $evp_dnsbl_query = import_dnsbls();
            $evp_dnsbl_read = $db->insert($evp_dnsbl_query);

            // v check
            $base_url = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
            $base_url .= "://" . $_SERVER['HTTP_HOST'];
            $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
            $base_url = dirname($base_url);
            if ($evp_options_add_data_r && $evp_domain_filter_list_read && $evp_dnsbl_read) {
                mailsend($email, $fname, $password);
                header("Location: ./members/" . $login_page . "?installation=success");
                $files_to_unlink = [
                    "install.php",
                    "req.data.php",
                    "./functions/df_values.php",
                    "./functions/list_dnsbl.php",
                    "./db/lic_temp"
                ];
                foreach ($files_to_unlink as $file) {
                    unlink($file);
                }
            } else {
                header("Location: ./" . $installer . "?installation=fail");
            }
        } else {
            header("Location: ./" . $installer . "?installation=fail");
        }

    }
    //write config file with host, user, pass, db name;
    if (isset($_POST['dbcheck'])) {
        if (!empty($_POST['dbhost']) && !empty($_POST['dbuser']) && !empty($_POST['dbname'])) {
            $action = 3;
            $db_host = $_POST['dbhost'];
            $db_user = $_POST['dbuser'];
            $db_pass = $_POST['dbpass'];
            $db_name = $_POST['dbname'];
            // --------------------
            $error = false;
            // -------------------------------------------------------Database
            $connection = true;
            // try to connect to the DB, if not display error
            $mysqli = @mysqli_connect($db_host, $db_user, $db_pass, $db_name);
            if (!$mysqli) {
                $error = true;
                $connection = false;
                $error_msg = "Sorry, database details are not correct." . mysqli_connect_error();
            } else {
                // Ensure the database uses utf8mb4 and utf8mb4_general_ci for full Unicode support
                if (!empty($db_name)) {
                    $mysqli->query("ALTER DATABASE `$db_name` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;");
                }
                // Check sql_mode after successful connection
                $sql_mode_val = '';
                $sql_mode_result = $mysqli->query("SHOW VARIABLES LIKE 'sql_mode'");
                if ($sql_mode_result && $row = $sql_mode_result->fetch_assoc()) {
                    $sql_mode_val = $row['Value'];
                }
                $sql_mode_warning = $sql_mode_val;
                if ($sql_mode_val !== '' && strtolower($sql_mode_val) !== 'none') {
                    $error = true;
                    $connection = false;
                    $error_msg = '<code class="alert alert-danger" role="alert">
                          Please clear sql_mode for proper operation. MySQL sql_mode is set to:
                        </code>
                        <code class="alert alert-danger" role="alert">'
                        . htmlspecialchars($sql_mode_warning) .
                        '</code>';
                }
                $mysqli->close();
            }
            if ($connection) {
                $config_std = false;
                // try to create the config file and let the user continue
                if (!is_writable("./db/db.cnf.php")) {
                    $error2_msg = "<p>Unable to write to <b>/db/db.cnf.php</b>. Allow apache user write permissions to following directory and file path.</p>";
                } else {
                    $config_std = true;
                    $db_config = "./db/db.cnf.php";
                    file_put_contents($db_config, str_replace("db_host", $db_host, file_get_contents($db_config)));
                    file_put_contents($db_config, str_replace("db_user", $db_user, file_get_contents($db_config)));
                    file_put_contents($db_config, str_replace("db_pass", $db_pass, file_get_contents($db_config)));
                    file_put_contents($db_config, str_replace("db_name", $db_name, file_get_contents($db_config)));
                    chmod('./db/db.cnf.php', 0644);
                }
            }
        }
    } elseif (isset($_POST['createtb'])) {
        //table create sector
        include './db/db.cnf.php';
        include './db/database.Class.php';
        $db = new database();

        //evp_dummy_emails table start
        $evp_dummy_emails_drop = "DROP TABLE IF EXISTS evp_dummy_emails";
        $evp_dummy_emails_d_read = $db->create($evp_dummy_emails_drop);
        $evp_dummy_emails_query = "CREATE TABLE `evp_dummy_emails` (
			  `id` int(11) NOT NULL AUTO_INCREMENT,
			  `user_id` int(11) DEFAULT NULL,
			  `sub` varchar(255) DEFAULT NULL,
			  `msg` longtext DEFAULT NULL,
			   PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";

        if ($db->create($evp_dummy_emails_query) === true) {
            $evp_dummy_emails_add_data_q = "INSERT INTO `evp_dummy_emails` (`user_id`, `sub`, `msg`) VALUES
								('1', 'Sorry, Sent by mistake for system error. You do not have to reply to this email. Thank you!', 'Sorry, Sent by mistake for system error. You do not have to reply to this email. Thank you!'),
								('1', 'Loan Offer', 'Hello, <br> We offer loans on clear and understandable terms and conditions at a 3% interest rate. From $10,000.00 to $450,000,000.00 USD, Euro And Pounds Only. we offer Business Loans, Personal Loans, Student Loans, Car Loans, And Loans To Pay Off Bills, Contact us now.'),
								('1', 'DONATION OF $1,300,000 FOR CHARITY', 'YOUR EMAIL ACCOUNT WAS SELECTED FOR A DONATION OF $1,300,000 FOR CHARITY. PLEASE CONTACT US FOR MORE INFORMATION VIA EMAIL.');";
            $evp_dummy_emails_add_data_r = $db->insert($evp_dummy_emails_add_data_q);
        }

        //evp_dummy_emails table end

        //evp_email_filter_list table start
        $evp_email_filter_list_drop = "DROP TABLE IF EXISTS evp_email_filter_list";
        $evp_email_filter_list_d_read = $db->create($evp_email_filter_list_drop);
        $evp_email_filter_list_query = "CREATE TABLE `evp_email_filter_list` (
			 `id` int(11) NOT NULL AUTO_INCREMENT,
			 `email_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
			 `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
			 `uid` int(11) DEFAULT NULL,
			  PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
        $evp_email_filter_list_q_read = $db->create($evp_email_filter_list_query);

        //evp_email_filter_list table end

        // evp_mx_skiplist start
        $evp_mx_skiplist_drop = " DROP TABLE IF EXISTS evp_mx_skiplist "; //delete existing table
        $evp_mx_skiplist_read = $db->create($evp_mx_skiplist_drop);
        $evp_mx_skiplist_query = "CREATE TABLE evp_mx_skiplist (
              id int(10) NOT NULL AUTO_INCREMENT,
              mx_server varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
              reason longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
              PRIMARY KEY (id)
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
        $evp_mx_skiplist_read = $db->create($evp_mx_skiplist_query);
        // evp_mx_skiplist end

        //evp_domain_filter_list table start
        $evp_domain_filter_list_drop = " DROP TABLE IF EXISTS evp_domain_filter_list "; //delete existing table
        $evp_domain_filter_list_read = $db->create($evp_domain_filter_list_drop);
        $evp_domain_filter_list_query = "CREATE TABLE evp_domain_filter_list (
              id int(11) NOT NULL AUTO_INCREMENT,
              name longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
              e_type varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
              catch_all_check int(11) NOT NULL DEFAULT '1',
              user_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'all',
              PRIMARY KEY (id)
              ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
        $evp_domain_filter_list_read = $db->create($evp_domain_filter_list_query);
        //evp_domain_filter_list table end

        $task_drop = " DROP TABLE IF EXISTS evp_task "; //delete existing table
        $task_d_read = $db->create($task_drop);
        //mail range and time check table
        $task_query = "CREATE TABLE evp_task (
         id int(11) NOT NULL AUTO_INCREMENT,
         csv_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
         status varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
		 last_exec timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
         meta text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
         user_id varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
         PRIMARY KEY (id)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $task_q_read = $db->create($task_query);

        // evp_email_list table start
        $email_list_drop = " DROP TABLE IF EXISTS evp_email_list "; //delete existing table
        $email_list_d_read = $db->create($email_list_drop);
        //mail range and time check table
        $email_list_query = "CREATE TABLE evp_email_list (
         id int(11) NOT NULL AUTO_INCREMENT,
         csv_file_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
         email_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
         email_status varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
         email_type varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         safe_to_send varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         verification_response varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         mail_box varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         domain_dns varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         mx_server varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         mx_response longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         score varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         bounce_type varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         email_acc varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         email_dom varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
         create_date datetime,
         last_update datetime,
         user_id int(255),
         processing_worker_id int(255) DEFAULT NULL,
         processing_assigned_at datetime DEFAULT NULL,
         worker_status enum('pending', 'processing', 'done', 'skipped') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'pending',
         meta text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
         PRIMARY KEY (id)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
        $email_list_q_read = $db->create($email_list_query);

        // evp_email_list table start
        $email_list_metadata_drop = " DROP TABLE IF EXISTS evp_email_list_metadata "; //delete existing table
        $email_list_metadata_d_read = $db->create($email_list_metadata_drop);
        //mail range and time check table
        $email_list_metadata_query = "CREATE TABLE evp_email_list_metadata (
         list_id int(100) NOT NULL AUTO_INCREMENT,
         csv_file_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
         total bigint(20) DEFAULT 0,
         valid bigint(20) DEFAULT 0,
         invalid bigint(20) DEFAULT 0,
         catch_all bigint(20) DEFAULT 0,
         unknown bigint(20) DEFAULT 0,
         skipped bigint(20) DEFAULT 0,
         syntax_error bigint(20) DEFAULT 0,
         disposable bigint(20) DEFAULT 0,
         free_account bigint(20) DEFAULT 0,
         role_account bigint(20) DEFAULT 0,
         check_mailbox varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
         cc_data text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
		 csv_new_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
		 creation_date datetime DEFAULT NULL,
		 scan_time double DEFAULT 0,
         completed_date datetime DEFAULT NULL,
         scan_status varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
         pid varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
         user_id int(100),
         PRIMARY KEY (list_id)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $email_list_metadata_q_read = $db->create($email_list_metadata_query);


        //evp_dummy_emails table start
        $evp_dummy_emails_drop = "DROP TABLE IF EXISTS evp_dummy_emails";
        $evp_dummy_emails_d_read = $db->create($evp_dummy_emails_drop);
        $evp_dummy_emails_query = "CREATE TABLE `evp_dummy_emails` (
			  `id` int(11) NOT NULL AUTO_INCREMENT,
			  `user_id` int(11) DEFAULT NULL,
			  `sub` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
			  `msg` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
			   PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        if ($db->create($evp_dummy_emails_query) === true) {
            $evp_dummy_emails_add_data_q = "INSERT INTO `evp_dummy_emails` (`user_id`, `sub`, `msg`) VALUES
								('1', 'Sorry, Sent by mistake for system error. You do not have to reply to this email. Thank you!', 'Sorry, Sent by mistake for system error. You do not have to reply to this email. Thank you!'),
								('1', 'Loan Offer', 'Hello, <br> We offer loans on clear and understandable terms and conditions at a 3% interest rate. From $10,000.00 to $450,000,000.00 USD, Euro And Pounds Only. we offer Business Loans, Personal Loans, Student Loans, Car Loans, And Loans To Pay Off Bills, Contact us now.'),
								('1', 'DONATION OF $1,300,000 FOR CHARITY', 'YOUR EMAIL ACCOUNT WAS SELECTED FOR A DONATION OF $1,300,000 FOR CHARITY. PLEASE CONTACT US FOR MORE INFORMATION VIA EMAIL.');";
            $evp_dummy_emails_add_data_r = $db->insert($evp_dummy_emails_add_data_q);
        }

        //evp_dummy_emails table end


        //evp_email_filter_list table start
        $evp_email_filter_list_drop = "DROP TABLE IF EXISTS evp_email_filter_list";
        $evp_email_filter_list_d_read = $db->create($evp_email_filter_list_drop);
        $evp_email_filter_list_query = "CREATE TABLE `evp_email_filter_list` (
			 `id` int(11) NOT NULL AUTO_INCREMENT,
			 `email_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
			 `reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
			 `uid` int(11) DEFAULT NULL,
			  PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
        $evp_email_filter_list_q_read = $db->create($evp_email_filter_list_query);

        //evp_email_filter_list table end
        //evp_options table
        $evp_options_drop = " DROP TABLE IF EXISTS evp_options "; //delete existing table
        $evp_options_d_read = $db->create($evp_options_drop);

        $evp_options_query = "CREATE TABLE IF NOT EXISTS `evp_options` (
				  `option_id` INT(3) NOT NULL AUTO_INCREMENT,
				  `option_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
				  `option_value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
				  PRIMARY KEY (`option_id`)
				) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_options_q_read = $db->create($evp_options_query);

        //evp_tag_list table
        $evp_tag_list_drop = " DROP TABLE IF EXISTS evp_tag_list "; //delete existing table
        $evp_tag_list_d_read = $db->create($evp_tag_list_drop);
        $evp_tag_list_query = "CREATE TABLE IF NOT EXISTS `evp_tag_list` (
					  `id` int(10) NOT NULL AUTO_INCREMENT,
					  `target_csv_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
					  `list_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
					  `user_id` int(11) DEFAULT NULL,
					  PRIMARY KEY (`id`)
				) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
        $evp_tag_list_q_read = $db->create($evp_tag_list_query);

        //evp_smtp_server_list table
        $evp_smtp_server_list_drop = " DROP TABLE IF EXISTS evp_smtp_server_list"; //delete existing table
        $evp_smtp_server_list_d_read = $db->create($evp_smtp_server_list_drop);
        $evp_smtp_server_list_query = "CREATE TABLE IF NOT EXISTS `evp_smtp_server_list` (		  
										`id` int(10) NOT NULL AUTO_INCREMENT,
										`user_id` int(11) DEFAULT NULL,
										`smtp_limit` int(11) DEFAULT NULL,
										`smtp_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
										`smtp_ssl_verify` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'false',
										`smtp_host` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
										`smtp_port` int(11) DEFAULT NULL,
										`smtp_security` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
										`smtp_auth` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'false',
										`smtp_user` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
										`smtp_pass` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
										PRIMARY KEY (`id`)
									) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_smtp_server_list_q_read = $db->create($evp_smtp_server_list_query);

        //evp_campaign_list table
        $evp_campaign_list_drop = " DROP TABLE IF EXISTS evp_campaign_list"; //delete existing table
        $evp_campaign_list_d_read = $db->create($evp_campaign_list_drop);
        $evp_campaign_list_query = "CREATE TABLE IF NOT EXISTS `evp_campaign_list` (		  
									`c_id` int(10) NOT NULL AUTO_INCREMENT,
									`c_user_id` int(11) DEFAULT NULL,
									`s_id` int(11) DEFAULT NULL,
									`c_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
									`c_fname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
									`c_from` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
									`c_sub` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
									`c_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
									`c_unsub` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'true',
									`c_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'pending',
									`total_sent` int(100) NULL DEFAULT '0',
									`total_amount` int(100) NULL DEFAULT '0',
									`c_date` datetime DEFAULT NULL,
									PRIMARY KEY (`c_id`)
									) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_campaign_list_q_read = $db->create($evp_campaign_list_query);

        //evp_send_email_list table
        $evp_send_email_list_drop = " DROP TABLE IF EXISTS evp_send_email_list"; //delete existing table
        $evp_send_email_list_d_read = $db->create($evp_send_email_list_drop);
        $evp_send_email_list_query = "CREATE TABLE IF NOT EXISTS `evp_send_email_list` (		  
									  `id` int(10) NOT NULL AUTO_INCREMENT,
									  `full_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
									  `email_add` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
									  `list_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
									  `sent` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'false',
									  PRIMARY KEY (`id`)
									) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_send_email_list_q_read = $db->create($evp_send_email_list_query);

        //evp_activity_logs table
        $evp_activity_logs_drop = " DROP TABLE IF EXISTS evp_activity_logs"; //delete existing table
        $evp_activity_logs_d_read = $db->create($evp_activity_logs_drop);
        $evp_activity_logs_query = "CREATE TABLE IF NOT EXISTS `evp_activity_logs` (		  
									  `id` int(10) NOT NULL AUTO_INCREMENT,
									  `dateTime` datetime DEFAULT CURRENT_TIMESTAMP,
									  `msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
									  PRIMARY KEY (`id`)
									) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_activity_logs_q_read = $db->create($evp_activity_logs_query);

        //evp_dnsbl table
        $evp_dnsbl_drop = " DROP TABLE IF EXISTS evp_dnsbl"; //delete existing table
        $evp_dnsbl_read = $db->create($evp_dnsbl_drop);
        $evp_dnsbl_query = "CREATE TABLE IF NOT EXISTS `evp_dnsbl` (
							  `id` int(10) NOT NULL AUTO_INCREMENT,
							  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
							  `dnszone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
							  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
							  `type` enum('ip','host') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
							  `last_verified` date DEFAULT NULL,
							  `is_active` tinyint(1) DEFAULT '1',
							  PRIMARY KEY (`id`)
							) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_dnsbl_read = $db->create($evp_dnsbl_query);

        //evp_ipn_logs table
        $evp_ipn_logs_drop = " DROP TABLE IF EXISTS evp_ipn_logs"; //delete existing table
        $evp_ipn_logs_d_read = $db->create($evp_ipn_logs_drop);
        $evp_ipn_logs_query = "CREATE TABLE IF NOT EXISTS `evp_ipn_logs` (		  
									  `id` int(10) NOT NULL AUTO_INCREMENT,
									  `dateTime` datetime DEFAULT CURRENT_TIMESTAMP,
									  `msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
									  PRIMARY KEY (`id`)
									) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_ipn_logs_q_read = $db->create($evp_ipn_logs_query);

        //evp_ip_warmup table
        $evp_ip_warmup_drop = " DROP TABLE IF EXISTS evp_ip_warmup"; //delete existing table
        $evp_ip_warmup_d_read = $db->create($evp_ip_warmup_drop);
        $evp_ip_warmup_query = "CREATE TABLE IF NOT EXISTS `evp_ip_warmup` (
            `id` INT AUTO_INCREMENT PRIMARY KEY,
            `ip_address` VARCHAR(45) NOT NULL,
            `provider_group` VARCHAR(50) NOT NULL, 
            `day_counter` INT DEFAULT 1,           
            `daily_count` INT DEFAULT 0,           
            `last_sent_at` DATETIME,               
            `current_limit` INT DEFAULT 20,
            UNIQUE KEY `ip_provider` (`ip_address`, `provider_group`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";
        $evp_ip_warmup_q_read = $db->create($evp_ip_warmup_query);

        //evp_smtp_logs table
        $evp_smtp_logs_drop = " DROP TABLE IF EXISTS evp_smtp_logs"; //delete existing table
        $evp_smtp_logs_d_read = $db->create($evp_smtp_logs_drop);
        $evp_smtp_logs_query = "CREATE TABLE IF NOT EXISTS `evp_smtp_logs` (		  
									  `id` int(10) NOT NULL AUTO_INCREMENT,
									  `dateTime` datetime DEFAULT CURRENT_TIMESTAMP,
									  `msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
									  PRIMARY KEY (`id`)
									) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_smtp_logs_q_read = $db->create($evp_smtp_logs_query);

        //evp_system_logs table
        $evp_system_logs_drop = " DROP TABLE IF EXISTS evp_system_logs"; //delete existing table
        $evp_system_logs_d_read = $db->create($evp_system_logs_drop);
        $evp_system_logs_query = "CREATE TABLE IF NOT EXISTS `evp_system_logs` (		  
									  `id` int(10) NOT NULL AUTO_INCREMENT,
									  `dateTime` datetime DEFAULT CURRENT_TIMESTAMP,
									  `msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
									  PRIMARY KEY (`id`)
									) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;";

        $evp_system_logs_q_read = $db->create($evp_system_logs_query);



        if ($evp_dummy_emails_add_data_r && $evp_email_filter_list_q_read && $email_list_q_read && $email_list_metadata_q_read && $task_q_read && $evp_mx_skiplist_read && $evp_domain_filter_list_read && $evp_dnsbl_read && $evp_options_q_read && $evp_tag_list_q_read && $evp_smtp_server_list_q_read && $evp_campaign_list_q_read && $evp_send_email_list_q_read && $evp_activity_logs_q_read && $evp_ipn_logs_q_read && $evp_smtp_logs_q_read && $evp_system_logs_q_read) {
            $action = 4;
        }
    } else {
    }
} else {
    $action = 1;
    $error = false;
    $phpversion = true;
    $mail = true;
    $mysql_error = '';
    $session = true;
    $session_cookie_check = true;
    $error_mysql = false;
    $file_error = false;
    // ------------------------------------------------------- Folder/File Permission Fix

    $file_owner_issues = array();
    function chmod_r($dir)
    {
        $dp = opendir($dir);
        while ($file = readdir($dp)) {
            global $file_owner_issues;
            if (($file == ".") || ($file == ".."))
                continue;

            $path = $dir . "/" . $file;
            $is_dir = is_dir($path);

            if (fileowner($path) == 0) {
                $files_skip = array('.htaccess');
                if (!in_array($file, $files_skip)) {
                    global $file_error;
                    $file_error = true;
                    $file_owner_issues[] = $file;
                }
            } else {
                set_perms($path, $is_dir);
                if ($is_dir)
                    chmod_r($path);
            }
        }
        closedir($dp);
    }

    function set_perms($file, $is_dir)
    {
        $perm = substr(sprintf("%o", fileperms($file)), -4);
        $dirPermissions = "0755";
        $filePermissions = "0644";
        if ($is_dir && $perm >= $dirPermissions) {
            // echo("Dir: " . $file . "\n");
            chmod($file, octdec($dirPermissions));
        } elseif (!$is_dir && $perm >= $filePermissions) {
            // echo("File: " . $file . "\n");
            chmod($file, octdec($filePermissions));
        }

        flush();
    }
    chmod_r(dirname(__FILE__));

    // ------------------------------------------------------- PHP version
    $php_version = phpversion();
    if ($php_version < 7.4) {
        $error = true;
        $phpversion = false;
        $php_error = "PHP version is $php_version - Version 7.4 or newer required!";
    }
    // ------------------------------------------------------- PHP Curl

    if (in_array('curl', get_loaded_extensions())) {
        $php_curl = true;
    } else {
        $error = true;
        $php_curl = false;
    }

    // ------------------------------------------------------- SQL version
    // declare function
    function find_SQL_Version()
    {
        $output = shell_exec('mysql -V');
        preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
        return @$version[0] ? $version[0] : -1;
    }
    $mysql_version = find_SQL_Version();
    if ($mysql_version < 5.6) {

        if ($mysql_version == -1) {
            $error_mysql = true;
            $mysql_error = "MySQL version will be checked at the next step during database connection check.";
            $mysql_error_val = "Skipped";
        } else {
            $error = true;
            $mysql_error = "MySQL version is $mysql_version. Version 5.6 or newer is required!";
        }
    }
    // ------------------------------------------------------- mail
    if (!function_exists('mail')) {
        $error = true;
        $mail = false;
        $mail_error = "PHP Mail function is not enabled!";
    }
    // ------------------------------------------------------- session_use_cookies
    if (isset($_COOKIE[session_name()])) {

    } else {
        $error = true;
        $session_cookie_check = false;
        $session_cookie_error = "PHP session cookies disabled. Make sure php configuration file php.ini have variable 'session.use_cookies' value set '1' . Further reference on how to fix this can be found from script documentation section: (F) Troubleshooting.";
    }
    // ------------------------------------------------------- Session
    $_SESSION['myscriptname_sessions_work'] = 1;
    if (empty($_SESSION['myscriptname_sessions_work'])) {
        $error = true;
        $session = false;
        $session_error = "PHP session support is deactive. Enable PHP session support!";
    }
    // ---------------------------------------------------javascript
}
?>