<?php
/*=======================================================================
 *
 * glob_defs.inc.php
 *
 * Autor: Carsten Annacker, Marc Vollmann
 *
 =======================================================================*/


// $dbhost="172.16.0.138:3221";  // sb_test
// $dbhost="172.16.0.216:3391";     // SB.TEST.NEU (@mysql-sb-test-0)
// $dbhost="172.16.0.158:3391";     // SB.TEST.MARIA (@mysql-sb-test-0)
$dbhost="votian-test-datenbank:3306";     // SB.TEST.MARIA (@mysql-sb-test-0)

// $dbhost="172.16.0.138:3211";  // test_sb
// $dbhost="172.16.0.123:3391";  // !!!!!!!!!!!!! LIVE - ACHTUNG !!!!!!!!!!!!!
// $dbhost="172.16.0.138:3301";  // test_sb_intern
$dblogin="phoenix_new";
$dbpassword="AdAdgkS13";
$dbname="phoenix";
// $dbport="3391";  // !!!!!!!!!!!!! LIVE - ACHTUNG !!!!!!!!!!!!! UND SB.TEST.NEU (@mysql-sb-test-0)
// $dbport="3221";  // sb_test
// $dbport="3211";  // test_sb
// $dbport="3391";
$dbport="3306";
// $dbhostOnly = "172.16.0.123";  // !!!!!!!!!!!!! LIVE - ACHTUNG !!!!!!!!!!!!!
// $dbhostOnly = "172.16.0.138";  // sb_test UND test_sb
// $dbhostOnly = "172.16.0.216";     // SB.TEST.NEU (@mysql-sb-test-0)
$dbhostOnly = "votian-test-datenbank";     // SB.TEST.MARIA (@mysql-sb-test-0)

$dbhost2=$dbhost;
$dblogin2=$dblogin;
$dbpassword2=$dbpassword;
$dbname2=$dbname;

$dbhost3=$dbhost;
$dblogin3=$dblogin2;
$dbpassword3=$dbpassword2;
$dbname3=$dbname2;

// $dbhostStatistic = "172.16.0.146:3391";  // SB-Replikant
$dbhostStatistic = $dbhost;

// $dbhostJob2History = $dbhost;

$dbhostPZM = "172.16.0.158:82";
//$dbhostPZM1 = "172.16.0.158:81";
$dbhostPZM1 = "";

ini_set('default_charset', 'windows-1252');
$htmlEntitiesCharset = "WINDOWS-1252";
$htmlEntitiesFlags = ENT_COMPAT | ENT_HTML401;

$dbhostJob2History = "172.16.0.123:3381";  // SB.MPS2.JOB2HISTORY
// $dbhostJob2History = "172.16.0.216:3391";    // SB-TEST-NEW
// $dbhostJob2History = "127.0.0.1:3391";
//$dbhostOnlyJob2History = "127.0.0.1";
//$dbportJob2History = "3391";

function my_addslashes($a) {
  if (!(strpos($a, "'") === false
    && strpos($a, "\"") === false
    && strpos($a, "\\") === false)) {
    return addslashes($a);
  }
  return $a;
}

// http://php.net/manual/de/function.addslashes.php
function addslashes_array($a) {
  if (is_array($a)){
    foreach($a as $k => $v) {
      $b[$k] = addslashes_array($v);
    }
    return $b;
  } else {
    return my_addslashes($a);
  }
}

// Seit Firefox 48.0 wird offensichtlich in jedem Fall Unicode in den Get-Vars �bertragen, auch wenn die Website selbst nicht Unicode ist.
// Daher m�ssen die Parameter mit potentiellen Umlauten erst decoded werden (siehe auch job_options.php).
foreach ($_GET as $k => $v) {
  // $_GET[$k] = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e", "chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)", $v);
  $_GET[$k] = preg_replace_callback("/([\xC2\xC3])([\x80-\xBF])/", 
                                      function ($matches) {
                                    	    foreach ($matches as $match) {
                                    	            return chr(ord($match) . "<<6&0xC0|" . ord($match) . "&0x3F");
                                    	    };
                                      },
                                    $v
                                   );
}


//print_r($_POST);
# https://www.php.net/manual/en/function.get-magic-quotes-gpc.php
# => get_magic_quotes_gpc() DEPRECATED as of PHP 7.4.0, and REMOVED as of PHP 8.0.0.
# 
# also see https://stackoverflow.com/questions/61054418/php-7-4-deprecated-get-magic-quotes-gpc-function-alternative
# => Since PHP no longer adds slashes to request parameters (removed in PHP 5.4), get_magic_quotes_gpc() always returns false.
# With that in mind, you don't have to do anything to your strings, they should always be clean.
//if (!get_magic_quotes_gpc()) {
if (!false) {
  if (!empty($HTTP_POST_VARS)) {
    foreach ($HTTP_POST_VARS as $k => $v) {
      $HTTP_POST_VARS[$k] = addslashes_array($v);
    }
  } else {
    foreach ($_POST as $k => $v) {
      $_POST[$k] = addslashes_array($v);
    }
  }
  if (!empty($HTTP_GET_VARS)) {
    foreach ($HTTP_GET_VARS as $k => $v) {
      $HTTP_GET_VARS[$k] = addslashes_array($v);
    }
  } else {
    foreach ($_GET as $k => $v) {
      $_GET[$k] = addslashes_array($v);
    }
  }
}
//print_r($_POST);

$HTTP_POST_VARS = !empty($HTTP_POST_VARS) ? $HTTP_POST_VARS : $_POST;
$HTTP_GET_VARS = !empty($HTTP_GET_VARS) ? $HTTP_GET_VARS : $_GET;
$HTTP_COOKIE_VARS = !empty($HTTP_COOKIE_VARS) ? $HTTP_COOKIE_VARS : $_COOKIE;
$HTTP_SERVER_VARS = !empty($HTTP_SERVER_VARS) ? $HTTP_SERVER_VARS : $_SERVER;
$HTTP_ENV_VARS = !empty($HTTP_ENV_VARS) ? $HTTP_ENV_VARS : $_ENV;
$HTTP_POST_FILES = !empty($HTTP_POST_FILES) ? $HTTP_POST_FILES : $_FILES;

// Array for 2-way-encryption containing primes
$eca[0] = "441523";
$eca[1] = "333433";
$eca[2] = "489733";
$eca[3] = "515993";
$eca[4] = "173099";

$priceFormular = "SUM(trs.trs_price * ((100 - trs.trs_discount) / 100))";

if (!isset($PHP_SELF))
  $PHP_SELF = $_SERVER["PHP_SELF"];

$languageText = array();     // Global associative array for language texts to be diplayed
$languageSelected = "0";     // Language selected ["0" = German, "1" = English, ...]
$languageDBUpdateMode = "1"; // If activated (= "1") then check existence of language text in the database
$currentScript = "";         // Current name of the script

$GLOBAL_USAGE_HASH = true;   // Global regulation for usage of the external HASH structure
$GLOBAL_DB_IS_LIVE = false;  // THIS DB instance is LIVE (!!!!)


// Wrapper for deprecated functions
$phpVersion = substr(phpversion(), 0, 3);
if ($phpVersion >= "7.0") :
   function spliti ($delimiter, $string) { return explode($delimiter, $string); };
   function split ($delimiter, $string) { return explode($delimiter, $string); };
   function ereg_replace ($pattern, $replacement, $string) { return preg_replace("/" . $pattern . "/", $replacement, $string); };
   function ereg ($pattern, $subject) { return preg_match("/" . $pattern . "/", $subject); };
endif;

function mcIsSet (&$var, $initVal = "") { if (!isset($var)) { $var = $initVal; }; return $var; };
function mcTrim (&$str, $initVal = "") { $str = trim(mcIsSet($str, $initVal)); return $str;};
function mcArrIsSet (&$arr, $key, $initVal = "") { $arr[$key] = (array_key_exists($key, $arr) ? $arr[$key] : $initVal); return $arr[$key]; };
function mcArrMultiDimIsSet (&$arr, $key, $initVal = "") { return (array_key_exists($key, $arr??[]) ? $arr[$key] : $initVal); };
function mcArrTrim (&$arr, $key) { return trim(mcArrIsSet($arr, $key)); };
function mcChkValOrArrCountIsEmpty (&$var) { return ( mcIsSet($var) == "" || (is_array($var) && count($var) == 0)  ? true : false); };
function mcArrCount ($arr, $retVal = 1) { return (is_array($arr) ? count($arr) : $retVal); };



// Global variables
mcIsSet($usedFramework);
mcIsSet($deactivateMenuStatic);

mcIsSet($customerId);
mcIsSet($cscIdRoot);
mcIsSet($cscIdActual);
mcIsSet($cscNameCurrent);
mcIsSet($htmlDefaultCharset);
mcIsSet($hqId);
mcIsSet($emp_id);
mcIsSet($usr_id);
mcIsSet($automailer);
mcIsSet($dbhistory);
mcIsSet($statusMessage);

$f_secretFileName = "";
$summationField = ""; $summationField2 = ""; $summationField3 = "";
$summationField4= ""; $summationField5 = ""; $summationField6 = "";
$summationField7= ""; $summationField8 = ""; $summationField9 = "";
$sumOfSummationField = ""; $sumOfSummationField2 = ""; $sumOfSummationField3 = ""; 
$sumOfSummationField4 = ""; $sumOfSummationField5 = ""; $sumOfSummationField6 = "";
$sumOfSummationField7 = ""; $sumOfSummationField8 = ""; $sumOfSummationField9 = ""; 
$summationFieldArrayLen = 0;
?>
