<?php
////////////////////////////////////////////////////////  Package Log Database /////////////////////////////////////////////////////
//define('PACKAGE_LOG_DB_NAME', 'shipap5_sarcina_usorum');
//define('PACKAGE_LOG_DB_SERVER', '173.231.198.99');
//define('PACKAGE_LOG_DB_PASS', 'gkxF,,9rCvlL');
//define('PACKAGE_LOG_DB_USER', 'shipap5_api');

define('PACKAGE_LOG_DB_NAME', 'shipap5_simul_copia');
define('PACKAGE_LOG_DB_SERVER', '173.231.198.99');
define('PACKAGE_LOG_DB_PASS', 'z85BPe0l4!iD');
define('PACKAGE_LOG_DB_USER', 'shipap5_shipapps');

define('MAX_EMAIL_LOGIN_ATTEMPTS', 100);
define('MAX_IP_LOGIN_ATTEMPTS', 100);

define('EMAIL_TO_WEBSITE_ERROR', 'david.mc@postandparcel.com');

// Determine the protocol (http or https)
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
             || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";

// Get the hostname with port if needed
$host = $_SERVER['HTTP_HOST'];

// Optionally, get the directory path of your application root (if your app is in a subfolder)
$scriptName = $_SERVER['SCRIPT_NAME']; // e.g. /folder/index.php
$scriptDir = rtrim(str_replace(basename($scriptName), '', $scriptName), '/');

// Construct base URL
$baseUrl = $protocol . $host . $scriptDir;
//$baseUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . str_replace('/pages', '', dirname($_SERVER['SCRIPT_NAME']));


function genRandomString($length) {

	$string = "";
	
	if($length){
		
	}else{
		$length = 50;
	}
  $scratch = "0 1 2 3 4 5 6 7 8 9 a b c d e f";
  $characters = explode(" ", $scratch);
	for ($p = 0; $p < $length ; $p++) {
		$string .= $characters[mt_rand(0, sizeof($characters)-1)];
	}
	return $string;
}

function HashPassword($input, $salt){

	if($salt===NULL || !isset($salt) || !$salt){
		$salt = bin2hex(random_bytes(32)); 
	}
	$hash = hash("sha256", $salt . $input); 
	$final = $salt . $hash; 
	return $final;
}