diff --git a/ws2011/BP/QS-Dokument/QS-Dokument.pdf b/ws2011/BP/QS-Dokument/QS-Dokument.pdf
index 2127f001..7c4c0679 100644
Binary files a/ws2011/BP/QS-Dokument/QS-Dokument.pdf and b/ws2011/BP/QS-Dokument/QS-Dokument.pdf differ
diff --git a/ws2011/BP/QS-Dokument/QS-Dokument.tex b/ws2011/BP/QS-Dokument/QS-Dokument.tex
index 248f7d2f..f4c0e5cd 100644
--- a/ws2011/BP/QS-Dokument/QS-Dokument.tex
+++ b/ws2011/BP/QS-Dokument/QS-Dokument.tex
@@ -82,12 +82,12 @@ ma
Für eine bessere Nachvollziehbarkeit sind die Änderungen in diesem Dokument tabellarisch festgehalten.
-\begin{tabular}{|| l || p{12cm} ||}
+\begin{tabular}{ || l | p{12cm} || }
\hline
v. 0.0.0 - 01.12.2011 - MS & Dokument angelegt
\\ \hline
-test & test2
+test & dies soll nur ein langer sinnloser text werden, damit man überprüfen kann, ob auch der zeilenumbruch in der tabelle funktioniert.
\\ \hline
test & test2
\\ \hline
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/.DS_Store b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/.DS_Store
new file mode 100644
index 00000000..7e824193
Binary files /dev/null and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/.DS_Store differ
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/index.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/index.php
new file mode 100644
index 00000000..d8c04bea
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/index.php
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+ This Page is only a small Semantic Web Application which allows you to find information
+ about movies using "Linked Movie Data Base" and "Freebase".
+
+ Which Movie are you interested in?
+
+
+ Getting Infos for: " . $movieTitleByUser;
+
+ echo '
';
+
+
+
+ $mainController = new controller();
+ $mainController->getData($movieTitleByUser);
+ }
+
+ ?>
+
+
+

+
+

+
+
+
+
+
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/controller.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/controller.php
new file mode 100644
index 00000000..e386ebe6
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/controller.php
@@ -0,0 +1,120 @@
+buildNamespaces();
+
+
+ if( !$db ) { print sparql_errno() . ": " . sparql_error(). "\n"; exit; }
+
+ sparql_ns("prop", "http://dbpedia.org/property/");
+ sparql_ns("type", "http://dbpedia.org/class/yago/");
+
+
+ sparql_ns("test1", "http://dbpedia.org/ontology/");
+ sparql_ns("test2", "http://www.w3.org/2000/01/");
+ // sparql_ns("test3", "");
+
+ //folgende Abfragen funktionieren:
+// $sparql = "SELECT ?country_name ?population WHERE {
+// ?country a type:LandlockedCountries ;
+// rdfs:label ?country_name ;
+// prop:populationEstimate ?population .
+// FILTER (?population > 15000000) .
+// }";
+//
+ //$sparql = "select DISTINCT ?label2 WHERE { ?country ?city . ?country ?label1 . ?city ?label2 . FILTER (str(?label1) = \"".$userInput."\" && LANG(?label2) = \"en\") }";
+
+
+ //$sparql = "SELECT ?movie WHERE { ?arni linkedmdbRes:actor_name \"Arnold Schwarzeneger\" . ?movie linkedmdbRes:actor ?arni . ";
+
+
+ $sparql = "SELECT ?actorName WHERE { ?woody linkedmdbRes:director_name \"Woody Allen\" .
+ ?movie ?woody;
+ ?actor.
+ ?actor ?actorName .
+ }";
+
+ $result = $db->query( $sparql );
+
+ $resultsReady = true;
+
+ if( !$result )
+ { print sparql_errno() . ": " . sparql_error(). "\n"; exit; }
+
+ $fields = $result->field_array( $result );
+
+
+// if($userInput == "Test"){
+// echo "No way! I won't search infos about " . $userInput;
+// }else{
+ print "Found: ".sparql_num_rows( $result )." entries.
";
+ print "";
+ print "";
+ foreach( $fields as $field )
+ {
+ print "| $field | ";
+ }
+ print "
";
+ while( $row = sparql_fetch_array( $result ) )
+ {
+ print "";
+ foreach( $fields as $field )
+ {
+ print "| $row[$field] | ";
+ }
+ print "
";
+ }
+ print "
";
+ // }
+
+
+ }
+
+}
+
+?>
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/freebaseController.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/freebaseController.php
new file mode 100644
index 00000000..f0281657
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/freebaseController.php
@@ -0,0 +1,24 @@
+
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/mdbController.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/mdbController.php
new file mode 100644
index 00000000..7afda6f9
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logic/mdbController.php
@@ -0,0 +1,28 @@
+
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/freebase.jpg b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/freebase.jpg
new file mode 100644
index 00000000..f2cf42d3
Binary files /dev/null and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/freebase.jpg differ
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/mdb.png b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/mdb.png
new file mode 100644
index 00000000..9dd61a97
Binary files /dev/null and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/logos/mdb.png differ
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/config.properties b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/config.properties
new file mode 100644
index 00000000..e69de29b
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.properties b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.properties
new file mode 100644
index 00000000..49665daa
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.properties
@@ -0,0 +1,5 @@
+copy.src.files=true
+copy.src.target=/Applications/XAMPP/htdocs/SemanticWebApp
+index.file=index.php
+run.as=LOCAL
+url=http://localhost/SemanticWebApp/
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml
new file mode 100644
index 00000000..7d386c35
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml
@@ -0,0 +1,9 @@
+
+
+
+
+ logic/controller.php
+ 15
+
+
+
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.0.nblh~ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.0.nblh~
new file mode 100644
index 00000000..c1f155a7
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/private/private.xml.0.nblh~
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.properties b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.properties
new file mode 100644
index 00000000..94429c9b
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.properties
@@ -0,0 +1,7 @@
+include.path=${php.global.include.path}
+php.version=PHP_53
+source.encoding=UTF-8
+src.dir=.
+tags.asp=false
+tags.short=true
+web.root=.
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.xml b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.xml
new file mode 100644
index 00000000..81dca232
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/nbproject/project.xml
@@ -0,0 +1,9 @@
+
+
+ org.netbeans.modules.php.project
+
+
+ SemanticWebApp
+
+
+
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/.DS_Store b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/.DS_Store
new file mode 100644
index 00000000..0b1b5236
Binary files /dev/null and b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/.DS_Store differ
diff --git a/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/sparqllib.php b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/sparqllib.php
new file mode 100644
index 00000000..66c685b0
--- /dev/null
+++ b/ws2011/Semantic Web/Uebungen/1. Bonus Aufgabe/SemanticWebApp/rdfLib/sparqllib.php
@@ -0,0 +1,335 @@
+
+
+###############################
+# Christopher Gutteridge 2010
+# cjg@ecs.soton.ac.uk
+# cc-by License
+# http://graphite.ecs.soton.ac.uk/sparqllib/
+###############################
+
+function sparql_connect( $endpoint ) { return new sparql_connection( $endpoint ); }
+
+function sparql_ns( $short, $long, $db = null ) { return _sparql_a_connection( $db )->ns( $short, $long ); }
+function sparql_query( $sparql, $db = null ) { return _sparql_a_connection( $db )->query( $sparql ); }
+function sparql_errno( $db = null ) { return _sparql_a_connection( $db )->errno(); }
+function sparql_error( $db = null ) { return _sparql_a_connection( $db )->error(); }
+
+function sparql_fetch_array( $result ) { return $result->fetch_array(); }
+function sparql_num_rows( $result ) { return $result->num_rows(); }
+function sparql_field_array( $result ) { return $result->field_array(); }
+function sparql_field_name( $result, $i ) { return $result->field_name( $i ); }
+
+function sparql_fetch_all( $result ) { return $result->fetch_all(); }
+
+function sparql_get( $endpoint, $sparql )
+{
+ $db = sparql_connect( $endpoint );
+ if( !$db ) { return; }
+ $result = $db->query( $sparql );
+ if( !$result ) { return; }
+ return $result->fetch_all();
+}
+
+function _sparql_a_connection( $db )
+{
+ global $sparql_last_connection;
+ if( !isset( $db ) )
+ {
+ if( !isset( $sparql_last_connection ) )
+ {
+ print( "No currect SPARQL connection (connection) in play!" );
+ return;
+ }
+ $db = $sparql_last_connection;
+ }
+ return $db;
+}
+
+
+# $timeout = 20;
+# $old = ini_set('default_socket_timeout', $timeout);
+# ini_set('default_socket_timeout', $old);
+class sparql_connection
+{
+ var $db;
+ var $debug = false;
+ var $errno = null;
+ var $error = null;
+ var $ns = array();
+ function __construct( $endpoint )
+ {
+ $this->endpoint = $endpoint;
+ global $sparql_last_connection;
+ $sparql_last_connection = $this;
+ }
+
+ function ns( $short, $long )
+ {
+ $this->ns[$short] = $long;
+ }
+
+ function errno() { return $this->errno; }
+ function error() { return $this->error; }
+
+ function query( $query )
+ {
+ $this->errno = null;
+ $this->error = null;
+ $prefixes = "";
+ foreach( $this->ns as $k=>$v )
+ {
+ $prefixes .= "PREFIX $k: <$v>\n";
+ }
+ $url = $this->endpoint."?query=".urlencode( $prefixes.$query );
+ if( $this->debug ) { print "\n"; }
+ $ch = curl_init($url);
+ #curl_setopt($ch, CURLOPT_HEADER, 1);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ $output = curl_exec($ch);
+ $info = curl_getinfo($ch);
+ if(curl_errno($ch))
+ {
+ $this->errno = curl_errno( $ch );
+ $this->error = 'Curl error: ' . curl_error($ch);
+ return;
+ }
+ if( $output === '' )
+ {
+ $this->errno = "-1";
+ $this->error = 'URL returned no data';
+ return;
+ }
+ if( $info['http_code'] != 200)
+ {
+ $this->errno = $info['http_code'];
+ $this->error = 'Bad response, '.$info['http_code'].': '.$output;
+ return;
+ }
+ curl_close($ch);
+
+ $parser = new xx_xml($output, 'contents');
+ return new sparql_result( $this, $parser->rows, $parser->fields );
+ }
+}
+
+class sparql_result
+{
+ var $rows;
+ var $fields;
+ var $db;
+ var $i = 0;
+ function __construct( $db, $rows, $fields )
+ {
+ $this->rows = $rows;
+ $this->fields = $fields;
+ $this->db = $db;
+ }
+
+ function fetch_array()
+ {
+ if( !@$this->rows[$this->i] ) { return; }
+ $r = array();
+ foreach( $this->rows[$this->i++] as $k=>$v )
+ {
+ $r[$k] = $v["value"];
+ }
+ return $r;
+ }
+
+ function fetch_all()
+ {
+ $r = new sparql_results();
+ $r->fields = $this->fields;
+ foreach( $this->rows as $i=>$row )
+ {
+ $r []= $this->fetch_array();
+ }
+ return $r;
+ }
+
+ function num_rows()
+ {
+ return sizeof( $this->rows );
+ }
+
+ function field_array()
+ {
+ return $this->fields;
+ }
+
+ function field_name($i)
+ {
+ return $this->fields[$i];
+ }
+}
+
+
+# class xx_xml adapted code found at http://php.net/manual/en/function.xml-parse.php
+# class is cc-by
+# hello at rootsy dot co dot uk / 24-May-2008 09:30
+class xx_xml {
+
+ // XML parser variables
+ var $parser;
+ var $name;
+ var $attr;
+ var $data = array();
+ var $stack = array();
+ var $keys;
+ var $path;
+
+ // either you pass url atau contents.
+ // Use 'url' or 'contents' for the parameter
+ var $type;
+
+ // function with the default parameter value
+ function xx_xml($url='http://www.opocot.com', $type='url') {
+ $this->type = $type;
+ $this->url = $url;
+ $this->parse();
+ }
+
+ // parse XML data
+ function parse()
+ {
+ $this->rows = array();
+ $this->fields = array();
+ $data = '';
+ $this->parser = xml_parser_create ("UTF-8");
+ xml_set_object($this->parser, $this);
+ xml_set_element_handler($this->parser, 'startXML', 'endXML');
+ xml_set_character_data_handler($this->parser, 'charXML');
+
+ xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
+
+ if ($this->type == 'url') {
+ // if use type = 'url' now we open the XML with fopen
+
+ if (!($fp = fopen($this->url, 'rb'))) {
+ $this->error("Cannot open {$this->url}");
+ }
+
+ while (($data = fread($fp, 8192))) {
+ if (!xml_parse($this->parser, $data, feof($fp))) {
+ $this->error(sprintf('XML error at line %d column %d',
+ xml_get_current_line_number($this->parser),
+ xml_get_current_column_number($this->parser)));
+ }
+ }
+ } else if ($this->type == 'contents') {
+ // Now we can pass the contents, maybe if you want
+ // to use CURL, SOCK or other method.
+ $lines = explode("\n",$this->url);
+ foreach ($lines as $val) {
+ $data = $val . "\n";
+ if (!xml_parse($this->parser, $data)) {
+ echo $data.'
';
+ $this->error(sprintf('XML error at line %d column %d',
+ xml_get_current_line_number($this->parser),
+ xml_get_current_column_number($this->parser)));
+ }
+ }
+ }
+ }
+
+ function startXML($parser, $name, $attr)
+ {
+ if( $name == "result" )
+ {
+ $this->result = array();
+ }
+ if( $name == "binding" )
+ {
+ $this->part = $attr["name"];
+ }
+ if( $name == "uri" || $name == "bnode" )
+ {
+ $this->part_type = "uri";
+ $this->chars = "";
+ }
+ if( $name == "literal" )
+ {
+ $this->part_type = "literal";
+ if( isset( $attr["datatype"] ) )
+ {
+ $this->part_datatype = $attr["datatype"];
+ }
+ if( isset( $attr["xml:lang"] ) )
+ {
+ $this->part_lang = $attr["xml:lang"];
+ }
+ $this->chars = "";
+ }
+ if( $name == "variable" )
+ {
+ $this->fields[] = $attr["name"];
+ }
+ }
+
+ function endXML($parser, $name) {
+ if( $name == "result" )
+ {
+ $this->rows[] = $this->result;
+ $this->result = array();
+ }
+ if( $name == "uri" || $name == "bnode" || $name == "literal" )
+ {
+ $this->result[$this->part] = array( "type"=>$name, "value"=>$this->chars );
+ if( isset( $this->part_lang ) )
+ {
+ $this->result[$this->part]["lang"] = $this->part_lang;
+ }
+ if( isset( $this->part_datatype ) )
+ {
+ $this->result[$this->part]["datatype"] = $this->part_datatype;
+ }
+ $this->part_datatype = null;
+ $this->part_lang = null;
+ }
+ }
+
+ function charXML($parser, $data) {
+ @$this->chars .= $data;
+ }
+
+ function error($msg) {
+ echo "
+ Error: $msg
+
";
+ exit();
+ }
+}
+
+class sparql_results extends ArrayIterator
+{
+ var $fields;
+ function fields() { return $this->fields; }
+
+ function render_table()
+ {
+ $html = "";
+ foreach( $this->fields as $i=>$field )
+ {
+ $html .= "| ?$field | ";
+ }
+ $html .= "
";
+ foreach( $this as $row )
+ {
+ $html.="";
+ foreach( $row as $cell )
+ {
+ $html .= "| ".htmlspecialchars( $cell )." | ";
+ }
+ $html.="
";
+ }
+ $html.="
+
+";
+ return $html;exit;
+ }
+
+}