'."\n"; ?> CS2310 IC Card Interaction Tool

IC Card Management System - IC Card Interaction Tool

$val) { if(strcmp($key,"dbscenario") == 0) { if(strcmp($val,"") != 0) { $scenario = $val; } } else if (strcmp($key,"dssystem") == 0) { if(strcmp($val,"") != 0) { $icSystem = $val; } } else { if(is_array($val)) { if(strcmp($key,"parent")==0) { foreach($val as $key2 => $val2) { $parentId[$key2] = $val2; } } if(strcmp($key,"scenario")==0) { foreach($val as $key2 => $val2) { $scenarioURL[$key2] = $val2; } } if(strcmp($key,"system")==0) { foreach($val as $key2 => $val2) { $systemURL[$key2] = $val2; } } } } } foreach($otherIcs as $key => $val) { $otherIcId[$key] = -1; foreach($names as $key2 => $val2) { if($val == $val2) { $otherIcId[$key] = $key2; } } } $outputData = ''."\n" .'' .serializeInteract($names, $parentId, $otherIcId, $systemURL, $scenarioURL, $scenario, $icSystem)."\n"; $fh = fopen('icInteractionDb.xml','w'); echo "
"; if($fh) { fwrite($fh,$outputData); fclose($fh); echo 'XML Database successfully generated.'; } else { echo 'An error occurred. XML Database was not generated.'; } echo '
'; } else { /* user did not post anything, present form. */ showForm($names, $scenario, $icSystem); } } else { echo "
"; echo '

IC Card XML database not found, you must create an IC card' .' database before specifying interactions.

'; echo '
'; } ?> createElement('icInteractions'); $dbNode->setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance'); $dbNode->setAttribute('xsi:noNamespaceSchemaLocation','icCardInteractions.xsd'); $dbNode->setAttribute('scenario', $scenario); $dbNode->setAttribute('icSystem', $icSystem); $dbDoc->appendChild($dbNode); } $key = 1; $val = $names[1]; foreach($names as $key => $val) { $tmpNode =& $dbDoc->createElement('icCard'); $tmpNode->setAttribute('id',$key); $tmpNode->setAttribute('icName',$val); $tmpNode->setAttribute('parentId',$parentId[$key]); $tmpNode->setAttribute('otherIcId',$otherIcId[$key]); if(strcmp($scenarioURL[$key],"")!=0) { $tmpNode->setAttribute('scenario',$scenarioURL[$key]); } if(strcmp($systemURL[$key],"")!=0) { $tmpNode->setAttribute('icSystem',$systemURL[$key]); } $dbNode->appendChild($tmpNode); } $serializer = new XmlSerializer('XML'); return $serializer->serializeNode($dbDoc); } function makeGlobalArrays() { include_once('dom4php/XmlParser.php'); $parser = new XmlParser(); $dbData = @file_get_contents('icdb.xml'); if($dbData == FALSE) { return false; } else { $names = array(); $otherIcs = array(); $dbDoc = $parser->parse($dbData); $idNode =& $dbDoc->childNodes[0]; $cardArray =& $idNode->getElementsByTagName('icCardEntry'); foreach(array_keys($cardArray) as $key) { $currId = $cardArray[$key]->getAttribute('id'); $tempArray = $cardArray[$key]->getElementsByTagName('icName'); $currName = $tempArray[0]->getAttribute('content'); $tempArray = $cardArray[$key]->getElementsByTagName('icOtherName'); $currOther = $tempArray[0]->getAttribute('content'); $names[$currId] = $currName; $otherIcs[$currId] = $currOther; } } $GLOBALS['names'] = $names; $GLOBALS['otherIcs'] = $otherIcs; return true; } function showForm($namesArray, $scenario, $icSystem) { echo '
'; echo "
"; echo ''."\n"; echo "\n"; foreach($namesArray as $currId => $currName) { echo '"; echo ''; echo ''; echo "\n"; } echo '
Please specify parent patterns, Scenario URLs, and IC System URLs for the IC Cards "; echo "listed below
'.$currName .''; echo 'Scenario: IC System:
'; echo '

'; echo 'You may specify the url of a scenario and IC system for the whole database below. '; echo 'If no url is specified, the scenario url will be set to '.$scenario; echo ', and the IC system url will be set to '.$icSystem.'

'; echo 'Scenario:
'; echo 'IC System
'; echo '

'; } ?>