<?php
/*
index.php is part of XaJaQ, see http://xajaq.sourceforge.net/
Copyright 2005-2007 Dennis Toddenroth
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
$include_dir = "include/php/";
require_once($include_dir. "config.inc.php" );
require_once($include_dir. "directory_functions.inc.php" );
require_once($include_dir. "xmlconfig.inc.php" );
require_once($include_dir. "collect_themes.inc.php" );
require_once($include_dir. "db_functions.inc.php" );
require_once($include_dir. "svg_creator.inc.php" );
require_once($include_dir. "forms.inc.php" );
require_once($include_dir. "xsltransform.inc.php" );
require_once($include_dir. "menu.inc.php" );
header("Content-type: text/xml; charset=UTF-8");
echo "<?xml version=\"1.0\"?>\n"; ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve"
><head>
<script type="text/ecmascript"><![CDATA[
<?php echo file_get_contents("./ecmascript/HelperFunctions.es");?>
<?php echo file_get_contents("./ecmascript/MovementClosures.es");?>
<?php echo file_get_contents("./ecmascript/DragManager.es");?>
<?php echo file_get_contents("./ecmascript/GuiFunctions.es");?>
<?php echo file_get_contents("./ecmascript/ToggleVisibility.es");?>
]]></script>
<style type="text/css" media="all">
@import url("css/xajaq-main.css");
</style>
</head>
<body onload="initialize();">
<div id="head">
<a href="<?php echo $programUrl; ?>">
<img src="images/logo-gray.png" alt="Logo XaJaQ"/>
</a>
<h1><?php echo $programName; ?></h1>
<p><?php echo $programUrl; ?></p>
</div>
<div id="flag_row"> </div>
<?php
$themes = collectThemes("./themes" );
if (isset($_POST["SERIAL_CONTAINER"] ) ) {
$saveFilename = $_POST["SAVENAME"];
file_put_contents("./sessions/". $saveFilename,
stripslashes($_POST["SERIAL_CONTAINER"] ) );
echo stripslashes($_POST["SERIAL_CONTAINER"] );
} else {
if (isset($_GET["LOADSESSION"] ) ) {
echo file_get_contents("./sessions/". $_GET["LOADSESSION"] );
$currentFile = $_GET["LOADSESSION"];
} else {
if ($_POST["username"] ) try {
$dbDriver = $_POST["driver"];
$connectionString = $dbDriver.":host=".$_POST["host"].";dbname=".$_POST["database"];
$dbHandle = new PDO($connectionString, $_POST["username"], $_POST["password"] );
$dbHandle->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true );
if ($columns = getDbColumns($dbHandle, $dbDriver ) ) {
$theme = $themes[$_POST["theme"]];
$resolutions = explode("x", $_POST["resolution"] );
$theme["clientWidth"] = $resolutions[0];
$theme["clientHeight"] = $resolutions[1];
createSVG($columns, $theme, $connectionString );
}
$dbHandle = null;
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
}
}
if ((!$_GET["LOADSESSION"] )&& (!$_POST["SERIAL_CONTAINER"] )&& (!$columns ) ) {
createDialog($themes, $resolutions, $dbHost, $dbUsername );
echo "<div id=\"menu\"><h3>open a saved session</h3><p>"hide@address.com( )."</p>".
"<h3>export a saved session as SVG</h3><p>"hide@address.com( )."</p></div>";
} else {
$currentFile = (isset($_GET["LOADSESSION"] ) )
? urldecode($_GET["LOADSESSION"] ) : "";
if (isset($_POST["SERIAL_CONTAINER"] ) )
$currentFile = $saveFilename;
if (isset($_POST["theme"] ) )
$currentFile = $_POST["database"]. " (".
$themes[$_POST["theme"]]["caption"]. " - ".
$_POST["resolution"]. ") - ".
substr(md5(time( ) ), 0, 4 );
$menuContents = array(
"sql" => "<textarea id=\"__SqlOutput\" cols=\"80\" rows=\"12\" />",
"save-on-server" => saveDialog($currentFile ),
"new" => "Click <a href=\"?\">here</a> to work on another database. ",
"open" => @collectSavedSessions($currentFile ),
"download" => @collectExportLinks( ),
"help" => file_get_contents("include/tutorial.markup" ),
);
createMenu($menuContents );
}
?>
<div id="foot"><?php echo $version. " - ". $lastChanged; ?></div>
</body></html>