1 ? strval($parts[1]) : "0");
$errors = array();
$ERROR_START_TAG = '';
$ERROR_END_TAG = '';
$CODE_START_TAG = '';
$CODE_END_TAG = '';
$END_OF_SUBREPORT = "--- --- ---";
if(!function_exists("mysqli_connect"))
{
$errors[] = $ERROR_START_TAG . "mysqli (MySQL Improved Extension) is not available." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "On Windows, you should enable the mysqli extension in the php.ini file with the following setting:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "extension=mysqli" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG. "On Unix/Linux, you should install the php".$packageVersion."-mysql or the php".$packageVersion."-mysqli package:" . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "e.g. on Ubuntu:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "sudo apt install php".$packageVersion."-mysql" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "or" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "sudo apt install php".$packageVersion."-mysqli" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "If you still see this error message, you should enable the mysqli extension in the php.ini file with one of the following settings:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "extension=mysqli" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "or" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "extension=php_mysqli" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $END_OF_SUBREPORT;
}
if (!class_exists('ZipArchive'))
{
$errors[] = $ERROR_START_TAG . "ZipArchive class is not available." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "On Windows, you should enable the zip extension in the php.ini file with the following setting:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "extension=zip" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG. "On Unix/Linux, you should install the php".$packageVersion."-zip package:" . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "e.g. on Ubuntu:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "sudo apt install php".$packageVersion."-zip" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "If you still see this error message, you should enable zip extension in the php.ini file with the following setting:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "extension=zip" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $END_OF_SUBREPORT;
}
if (!class_exists('SimpleXMLElement'))
{
$errors[] = $ERROR_START_TAG . "SimpleXMLElement class is not available." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "On Windows, you should enable the xml extension in the php.ini file with the following setting:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "extension=xml" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG. "On Unix/Linux, you should install the php".$packageVersion."-xml package:" . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "e.g. on Ubuntu:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "sudo apt install php".$packageVersion."-xml" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "If you still see this error message, you should enable xml extension in the php.ini file with the following setting:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "extension=xml" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $END_OF_SUBREPORT;
}
if (ini_get("allow_url_fopen")!="On" && ini_get("allow_url_fopen")!="1" && ini_get("allow_url_fopen")!=1)
{
$errors[] = $ERROR_START_TAG . "allow_url_fopen is not enabled. (Current value: " . strval(ini_get("allow_url_fopen")) . ")". $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "You should enable it in the php.ini file with the following setting:" . $ERROR_END_TAG;
$errors[] = $CODE_START_TAG . "allow_url_fopen = On" . $CODE_END_TAG;
$errors[] = $ERROR_START_TAG . "Then restart your web server." . $ERROR_END_TAG;
$errors[] = $END_OF_SUBREPORT;
}
else
{
$content = "test";
$tmpFileName = generateTempFileName();
$result = file_put_contents($tmpFileName, $content);
if($result === false || !file_exists($tmpFileName) || filesize($tmpFileName) == 0)
{
$errors[] = $ERROR_START_TAG . "Permission denied when trying to write a test file in this temporary file folder:" . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . sys_get_temp_dir() . $ERROR_END_TAG;
$errors[] = $ERROR_START_TAG . "Modify the file system permission settings of this folder, find out what user your web server is running as, and check and/or modify the user's file system permissions." . $ERROR_END_TAG;
$errors[] = $END_OF_SUBREPORT;
}
unlink($tmpFileName);
}
return $errors;
}
function generateTempFileName()
{
$r = null;
$chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$len = strlen($chars);
while(!isset($r))
{
$tmp = "";
for ($i = 0; $i < 10; $i++)
{
$tmp .= $chars[rand(0, $len - 1)];
}
$fn = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "mydbdiffo_temp_".$tmp.".zzz";
if(!file_exists($fn))
{
$r = $fn;
}
}
return $r;
}
function createTableIfDoesNotExist($dbms, $tableName)
{
$r = true;
$display_errors = ini_get('display_errors');
ini_set('display_errors', 0);
$sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES ";
$sql .= "WHERE TABLE_CATALOG = 'def' AND TABLE_SCHEMA = DATABASE() ";
$sql .= "AND TABLE_NAME = '" . $tableName . "'";
$result = $dbms->executeQuery($sql);
if (is_array($result))
{
if(count($result) == 0)
{
$createTable = "CREATE TABLE `".$tableName."` ";
$createTable .= "(";
$createTable .= "set_id bigint NOT NULL AUTO_INCREMENT, ";
$createTable .= "app_name varchar(50) NOT NULL, ";
$createTable .= "set_name varchar(50) NOT NULL, ";
$createTable .= "set_type varchar(20) NOT NULL COMMENT 'VARIABLE - The set_value contains the value of a variable.\nAPPLICATION - The set_value contains the XML definition of an M13E application.', ";
$createTable .= "set_value longtext, ";
$createTable .= "CONSTRAINT `pk_".$tableName."` PRIMARY KEY (set_id)";
$createTable .= ") CHARSET=utf8mb4";
$r = $dbms->executeUpdate($createTable);
if($r===true)
{
$createIndex = "CREATE INDEX `ix_".$tableName."_ant` ";
$createIndex .= "ON `".$tableName."` (app_name, set_name, set_type)";
$r = $dbms->executeUpdate($createIndex);
}
if($r!==true)
{
// In case of any error we drop the table and its index.
$dbms->executeUpdate("DROP INDEX `ix_".$tableName."_ant` ON `".$tableName."`");
$dbms->executeUpdate("DROP TABLE `".$tableName."`");
}
}
}
else
{
$r = $result;
}
if($r === true)
{
$result = $dbms->executeQuery("SELECT * FROM `".$tableName."` WHERE app_name = 'myDbDiffo' AND set_name = 'lastExecutedStepId' AND set_type = 'VARIABLE'");
if (is_array($result))
{
if(count($result)==0)
{
$lesiInsert = "INSERT INTO `".$tableName."` (app_name, set_name, set_type, set_value) VALUES ";
$lesiInsert .= "('myDbDiffo', 'lastExecutedStepId', 'VARIABLE', null)";
$dbms->executeUpdate($lesiInsert);
}
}
$result = $dbms->executeQuery("SELECT * FROM `".$tableName."` WHERE app_name = 'myDbDiffo' AND set_name = 'model' AND set_type = 'VARIABLE'");
if (is_array($result))
{
if(count($result)==0)
{
$modelInsert = "INSERT INTO `".$tableName."` (app_name, set_name, set_type, set_value) VALUES ";
$modelInsert .= "('myDbDiffo', 'model', 'VARIABLE', null)";
$dbms->executeUpdate($modelInsert);
}
}
$result = $dbms->executeQuery("SELECT * FROM `".$tableName."` WHERE app_name = 'myDbDiffo' AND set_name = 'sqls' AND set_type = 'VARIABLE'");
if (is_array($result))
{
if(count($result)==0)
{
$sqlsInsert = "INSERT INTO `".$tableName."` (app_name, set_name, set_type, set_value) VALUES ";
$sqlsInsert .= "('myDbDiffo', 'sqls', 'VARIABLE', null)";
$dbms->executeUpdate($sqlsInsert);
}
}
}
ini_set('display_errors', $display_errors);
return $r;
}
// Returns an error message in case of error otherwise true.
function saveLastExecutedStepId($dbms, $tableName, $lesi)
{
$r = true;
$update = "UPDATE `".$tableName."` SET set_value = '".strval($lesi)."' "; // $lesi is an integer (always), so it is safe to use strval here.
$update .= "WHERE app_name = 'myDbDiffo' AND set_name = 'lastExecutedStepId' AND set_type = 'VARIABLE'";
$r = $dbms->executeUpdate($update);
return $r;
}
// Returns the id or an error message.
function loadLastExecutedStepId($dbms, $tableName)
{
$lesi = null;
$select = "SELECT set_value FROM `".$tableName."` ";
$select .= "WHERE app_name = 'myDbDiffo' AND set_name = 'lastExecutedStepId' AND set_type = 'VARIABLE'";
$result = $dbms->executeQuery($select);
if (is_array($result))
{
if(count($result)>0)
{
$row = $result[0];
$v = $row["set_value"];
$lesi = isset($v) ? intval($v) : "'lastExecutedStepId' is null in table ".$tableName.".";
}
else
{
$lesi = "Missing 'lastExecutedStepId' setting in table ".$tableName.".";
}
}
else
{
$lesi = $result;
}
return $lesi;
}
// Returns the sqls as JSON-string or null.
function getSQLArrayJSONString($dbms, $tableName)
{
$sqlArrayString = null;
$select = "SELECT set_value FROM `".$tableName."` ";
$select .= "WHERE app_name = 'myDbDiffo' AND set_name = 'sqls' AND set_type = 'VARIABLE'";
$result = $dbms->executeQuery($select);
if (is_array($result))
{
if(count($result)>0)
{
$row = $result[0];
$sqlArrayString = $row["set_value"];
if(!isset($sqlArrayString))
{
$sqlArrayString = "[]";
}
}
}
return $sqlArrayString;
}
// Returns an error message in case of error otherwise true.
function saveSQLs($dbms, $tableName, &$sqls)
{
$r = true;
$sqlArrayString = $dbms->escapeString(json_encode($sqls));
$update = "UPDATE `".$tableName."` SET set_value = '".$sqlArrayString."' ";
$update .= "WHERE app_name = 'myDbDiffo' AND set_name = 'sqls' AND set_type = 'VARIABLE'";
$r = $dbms->executeUpdate($update);
return $r;
}
// Returns true if the model data exists otherwise false.
function checkModel($dbms, $tableName)
{
$exists = false;
$select = "SELECT 'true' AS check_result FROM `".$tableName."` ";
$select .= "WHERE app_name = 'myDbDiffo' AND set_name = 'model' AND set_type = 'VARIABLE' AND set_value IS NOT NULL AND LENGTH(set_value) > 0";
$result = $dbms->executeQuery($select);
if (is_array($result))
{
if(count($result)>0)
{
$row = $result[0];
$exists = $row["check_result"] == "true";
}
}
return $exists;
}
// Returns the model data or null if it does not exist.
function &loadModel($dbms, $tableName)
{
$modelData = null;
$select = "SELECT set_value FROM `".$tableName."` ";
$select .= "WHERE app_name = 'myDbDiffo' AND set_name = 'model' AND set_type = 'VARIABLE' AND set_value IS NOT NULL AND LENGTH(set_value) > 0";
$result = $dbms->executeQuery($select);
if (is_array($result))
{
if(count($result)>0)
{
$row = $result[0];
$modelData = $row["set_value"];
}
}
return $modelData;
}
// Returns an error message in case of error otherwise true.
function saveModel($dbms, $tableName, &$modelData)
{
$r = true;
$md = $dbms->escapeString($modelData);
$update = "UPDATE `".$tableName."` SET set_value = '".$md."' ";
$update .= "WHERE app_name = 'myDbDiffo' AND set_name = 'model' AND set_type = 'VARIABLE'";
$r = $dbms->executeUpdate($update);
return $r;
}
$tableName = "mydbdiffo_m13e";
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 ");
session_start();
$start_errors = checkOnStart();
if(count($start_errors))
{
foreach($start_errors as $se)
{
echo $se . "
" . "\r\n";
}
echo("End of Error Report.");
exit;
}
// DEAR USER,
// YOU CAN IMPLEMENT YOUR MODIFICATIONS IN mydbdiffo_modifications.php.
// IF THE FILE EXISTS THE PROGRAM WILL INCLUDE IT.
//
// FOR EXAMPLE:
// - YOU CAN MODIFY THE VALUE OF $tableName IF YOU WANT TO STORE YOUR
// MYDBDIFFO AND M13E SETTINGS IN A TABLE NAMED OTHER THAN mydbdiffo_m13e.
// (IN THIS CASE YOU MUST RENAME THE TABLE mydbdiffo_m13e IN YOUR DB, TOO.)
// - BY SETTING $timestamp TO 4000000000 YOU CAN DISABLE SOFTWARE UPDATES.
// - BY SETTING $timestamp TO 0 THE SOFTWARE ALWAYS UPDATES ITSELF FROM
// dbdiffo.com.
if (file_exists("mydbdiffo_modifications.php"))
{
include "mydbdiffo_modifications.php";
}
$result = null;
$myAction = isset($_REQUEST["_myaction"]) ? $_REQUEST["_myaction"] : null;
if (!isset($myAction))
{
$result = file_get_contents("dbdiffo.php");
}
else
{
// THESE ACTIONS DO NOT REQUIRE AN AUTHENTICATED LOCAL AND DBDIFFO SESSIONS.
if ($myAction == "mykeepalive")
{
$result = "OK";
}
else
if ($myAction == "mylogin")
{
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$connectionResult = $dbms->connect($_REQUEST["mydbdiffo_hostname"],
intval($_REQUEST["mydbdiffo_port"]),
$_REQUEST["mydbdiffo_database"],
$_REQUEST["mydbdiffo_user"],
$_REQUEST["mydbdiffo_password"],
$_REQUEST["mydbdiffo_charset"]);
if (!isset($connectionResult))
{
// store auth data in session
$_SESSION["mydbdiffo_hostname"] = $_REQUEST["mydbdiffo_hostname"];
$_SESSION["mydbdiffo_port"] = intval($_REQUEST["mydbdiffo_port"]);
$_SESSION["mydbdiffo_database"] = $_REQUEST["mydbdiffo_database"];
$_SESSION["mydbdiffo_user"] = $_REQUEST["mydbdiffo_user"];
$_SESSION["mydbdiffo_password"] = $_REQUEST["mydbdiffo_password"];
$_SESSION["mydbdiffo_charset"] = $_REQUEST["mydbdiffo_charset"];
$createTableResult = createTableIfDoesNotExist($dbms, $tableName);
if($createTableResult===true)
{
$result = "OK";
}
else
{
$result = "ERROR:".$createTableResult;
}
$dbms->disconnect();
}
else
{
$result = $connectionResult;
}
}
else
if ($myAction == "add_bugreport")
{
// myDbDiffo does not report bugs anymore, because it can't communicate with dbdiffo.com
// CODE REMOVED.
$result = '';
}
else
if ($myAction == "add_aexception")
{
// myDbDiffo does not report exceptions anymore, because it can't communicate with dbdiffo.com
// CODE REMOVED.
$result = '';
}
else
if ($myAction == "mychecklogin")
{
$result = isset($_SESSION["mydbdiffo_user"]) ? "OK" : "NOT LOGGED IN";
}
else
{
if (strpos($myAction, "my", 0) === 0)
{
// THESE ACTIONS ARE PROCESSED ON THE LOCAL SERVER.
if (isset($_SESSION["mydbdiffo_user"])) // DO WE HAVE AN AUTHENTICATED LOCAL SESSION?
{
// THESE ACTIONS REQUIRE AN AUTHENTICATED LOCAL SESSION.
if ($myAction == "mysavelesi")
{
$sValue = $_REQUEST["lastexecutedstepid"];
$lesi = isset($sValue) && strlen($sValue)>0 ? intval($sValue) : null;
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
"utf8mb4");
$lesiUpdateResult = saveLastExecutedStepId($dbms, $tableName, $lesi);
$dbms->disconnect();
$result = $lesiUpdateResult===true ? "OK" : $lesiUpdateResult;
}
else
if($myAction == "mygetfile")
{
if(isset($_REQUEST["type"]) && isset($_SESSION["mydbdiffo_uploaded_file"]) && isset($_REQUEST["filename"]))
{
header('Content-Disposition: attachment; filename="' . $_REQUEST["filename"] . '"');
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
$uploaded = isset($_SESSION["mydbdiffo_uploaded_file"]);
if($uploaded)
{
$s = file_get_contents($_SESSION["mydbdiffo_uploaded_file"]);
unlink($_SESSION["mydbdiffo_uploaded_file"]);
unset($_SESSION["mydbdiffo_uploaded_file"]);
if($_REQUEST["type"]=="document")
{
header('Content-Type: text/xml');
}
else
if($_REQUEST["type"]=="sqlScript")
{
header('Content-Type: text/plain');
}
else
if($_REQUEST["type"]=="diagramImage")
{
header('Content-Type: image/png');
$data = explode( ',', $s); // "data:image/png;base64,..."
if(count($data)==2)
{
$s = base64_decode($data[1]);
}
}
$result = $s;
}
}
}
else
if ($myAction == "mygetlesi")
{
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
"utf8mb4");
$lesi = loadLastExecutedStepId($dbms, $tableName);
$dbms->disconnect();
$result = isset($lesi) && is_numeric($lesi) ? strval($lesi) : "ERROR:".$lesi;
}
else
if ($myAction == "myuploadfile")
{
$tempFileName = generateTempFileName();
if(move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], $tempFileName)===false)
{
$result = "ERROR";
}
else
{
$_SESSION["mydbdiffo_uploaded_file"] = $tempFileName;
$result = "OK";
}
}
else
if ($myAction == "mygetsqls")
{
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
"utf8mb4");
$sqlArrayString = getSQLArrayJSONString($dbms, $tableName);
$dbms->disconnect();
if(isset($sqlArrayString))
{
$result = $sqlArrayString;
}
else
{
$result = "ERROR";
}
}
else
if ($myAction == "myexecutesqls")
{
if(isset($_SESSION["mydbdiffo_uploaded_file"]))
{
$result = "ERROR";
$edbms = new \com\dbdiffo\ret\dbms\MySQL();
$edbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
$_SESSION["mydbdiffo_charset"]);
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
"utf8mb4");
$append = isset($_REQUEST["append"]) ? $_REQUEST["append"] == "true" : false;
$sqlArrayString = null;
if($append)
{
$sqlArrayString = getSQLArrayJSONString($dbms, $tableName);
}
if(!$append || isset($sqlArrayString))
{
$sqls = null;
$newSQLs = json_decode(file_get_contents($_SESSION["mydbdiffo_uploaded_file"]), true);
unlink($_SESSION["mydbdiffo_uploaded_file"]);
unset($_SESSION["mydbdiffo_uploaded_file"]);
if($append)
{
$sqls = json_decode($sqlArrayString, true);
$sqls = array_merge($sqls, $newSQLs);
}
else
{
$sqls = $newSQLs;
}
$saveResult = saveSQLs($dbms, $tableName, $sqls);
if($saveResult===true)
{
$sqlCount = count($sqls);
$i = 0;
$errorOccured = false;
$display_errors = ini_get('display_errors');
ini_set('display_errors', 0);
while(!$errorOccured && $i<$sqlCount)
{
$sql = &$sqls[$i];
if($sql["executed"]===false)
{
$updateResult = $edbms->executeUpdate($sql["sql"]);
if($updateResult===true)
{
$sql["executed"] = true;
$sql["error"] = null;
}
else
{
$errorOccured = true;
$sql["error"] = $updateResult;
}
}
$i++;
}
ini_set('display_errors', $display_errors);
$saveResult = saveSQLs($dbms, $tableName, $sqls);
if($saveResult===true)
{
$result = "OK";
}
else
{
$result = "ERROR:".$saveResult;
}
}
else
{
$result = "ERROR:".$saveResult;
}
}
$dbms->disconnect();
$edbms->disconnect();
}
}
else
if ($myAction == "myreveng")
{
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
$_SESSION["mydbdiffo_charset"]);
$catalogFilter = array("def");
$schemaFilter = array();
$fv = array("catalog" => "def", "schema" => $_SESSION["mydbdiffo_database"]);
$schemaFilter[] = $fv;
$model = $dbms->getExportedModel($catalogFilter, $schemaFilter, null);
$dbms->disconnect();
header('Content-Type: text/xml');
$result = $model->toXML()->asXML();
}
else
if ($myAction == "mycheckmodel")
{
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
"utf8mb4");
createTableIfDoesNotExist($dbms, $tableName);
$result = checkModel($dbms, $tableName) ? "OK" : "MISSING";
$dbms->disconnect();
}
else
if ($myAction == "mysavemodel")
{
if (isset($_SESSION["mydbdiffo_uploaded_file"]))
{
$modelData = file_get_contents($_SESSION["mydbdiffo_uploaded_file"]);
unlink($_SESSION["mydbdiffo_uploaded_file"]);
unset($_SESSION["mydbdiffo_uploaded_file"]);
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
"utf8mb4");
$saveResult = saveModel($dbms, $tableName, $modelData);
if($saveResult===true)
{
$result = "OK";
}
else
{
$result = "ERROR:".$saveResult;
}
$dbms->disconnect();
}
}
else
if ($myAction == "myopenmodel")
{
$dbms = new \com\dbdiffo\ret\dbms\MySQL();
$dbms->connect($_SESSION["mydbdiffo_hostname"],
$_SESSION["mydbdiffo_port"],
$_SESSION["mydbdiffo_database"],
$_SESSION["mydbdiffo_user"],
$_SESSION["mydbdiffo_password"],
"utf8mb4");
$modelData = loadModel($dbms, $tableName);
$dbms->disconnect();
if(isset($modelData))
{
$result = $modelData;
}
else
{
$result = "ERROR";
}
}
}
}
else
{
// THESE ACTIONS WERE PROCESSED ON THE DBDIFFO.COM SERVER BEFORE.
// NOW WE HANDLE THEM ON THE LOCAL SERVER.
if($myAction=="genscript")
{
// THIS ACTION IS HANDLED BY THE LOCAL genscript.php FILE.
// CODE REMOVED.
}
else
{
$data = array();
$url = null;
switch ($myAction)
{
case "reginfo":
if (isset($_SESSION["mydbdiffo_user"]))
{
$email = $_SESSION["mydbdiffo_user"]."@".$_SESSION["mydbdiffo_hostname"];
$result = '';
}
else
{
$result = "";
}
break;
case "opencloud":
case "listfiles":
case "userfiles":
case "savecloud":
case "login":
case "register":
case "update_settings":
// THESE ACTIONS ARE NOT HANDLED ANYMORE IN myDbDiffo.
// OUR SERVICE PROVIDER DISABLED A LOT OF COMMUNICATION CHANNELS WITH dbdiffo.com.
// SORRY!
$result = 'OK';
break;
}
}
}
}
}
if (isset($result))
{
echo $result;
}
?>