<?php
/*=======================================================================
 *
 * test_mc.php
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/

// include_once ("../include/mcglobal.inc.php");
// include_once ("../include/auth.in.php");
// include_once ("../include/inc_parseXML.inc.php");


echo "x = " . $x . "<br>";
echo "y = " . $y . "<br>";

/*
echo "Script has no syntax error! <br><br>";


$dbhost="127.0.0.1:3391";
$dblogin="phoenix_new";
// $dblogin="phoenix";
$dbpassword="AdAdgkS13";
$dbname="phoenix";
// $dbname="mysql";
$dbport="3391";
$dbhostOnly="127.0.0.1";

$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;

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.123:3391";  // SB.MPS2.LIVE
$dbhostJob2History = "127.0.0.1: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;









// $mysqli = new mysqli($dbhostOnly, $dblogin, $dbpassword, $dbname);
$mysqli = new mysqli($dbhostOnly, $dblogin, $dbpassword, $dbname);

if ($mysqli->connect_error) {
    die("Verbindungsfehler: " . $mysqli->connect_error);
}

$result = $mysqli->query("SELECT * FROM user");
printf("Select gab %d Zeilen zurück.\n", $result->num_rows);
*/

/*
$aaaa = 42;
echo "aaaa = " . $aaaa . "<br>";
$bbbb = $aaaa;
echo "bbbb = aaaa setzen <br>";
echo "bbbb = " . $bbbb . "<br>";
$bbbb = "99";
echo "bbbb wird geändert auf 99! <br>";
echo "bbbb = " . $bbbb . "<br>";
echo "aaaa = " . $aaaa . "<br>";

echo "<br><br>";

$aaaa = 42;
echo "aaaa = " . $aaaa . "<br>";
$bbbb = $aaaa;
echo "bbbb = aaaa setzen <br>";
echo "bbbb = " . $bbbb . "<br>";
$aaaa = "99";
echo "aaaa wird geändert auf 99! <br>";
echo "bbbb = " . $bbbb . "<br>";
echo "aaaa = " . $aaaa . "<br>";
*/


/*
Session:	949734773drt319d05f415ehrzfnd05f415ehrz
Salt: 	34a78d91s83g

metaobject:
mo_id = 12
mo_hash = 99316e770c89f319d05f4155391e6dd4

getPwd($salt)
checkPwd ($passPhrase, $salt)
checkRequestAuthenticationData2 ($sessionId, $passPhrase)

SELECT * FROM `parameter` WHERE par_key IN ('GLOBAL_UNIQUE_DB_INSTANCE_NO','GLOBAL_SESSION_SYSTEM_ID','GLOBAL_SESSION_SALT','EXTERNAL_DB_METAOBJECT');

parameter:
EXTERNAL_DB_METAOBJECT  172.16.0.111:3711
GLOBAL_SESSION_SALT 	34a78d91s83g
GLOBAL_SESSION_SYSTEM_ID 	42
GLOBAL_UNIQUE_DB_INSTANCE_NO  12

*/
?>
