aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores')
-rw-r--r--sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README1
-rwxr-xr-xsources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml2
-rwxr-xr-xsources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl28
-rwxr-xr-xsources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php31
4 files changed, 62 insertions, 0 deletions
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README
new file mode 100644
index 000000000..eaa00fae3
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/README
@@ -0,0 +1 @@
+The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it.
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml
new file mode 100755
index 000000000..c3fd90d9c
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_data.xml
@@ -0,0 +1,2 @@
+<record><score>1000000</score><name>Alan the Tester</name><gridSize>0x0</gridSize><seconds>0</seconds></record>
+<record><score>6213</score><name>Alan</name><gridSize>12x17</gridSize><seconds>51</seconds></record>
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl
new file mode 100755
index 000000000..670354c96
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/score_style.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/">
+ <html>
+ <head><title>SameGame High Scores</title></head>
+ <body>
+ <h2>SameGame High Scores</h2>
+ <table border="1">
+ <tr bgcolor="lightsteelblue">
+ <th>Name</th>
+ <th>Score</th>
+ <th>Grid Size</th>
+ <th>Time, s</th>
+ </tr>
+ <xsl:for-each select="records/record">
+ <xsl:sort select="score" data-type="number" order="descending"/>
+ <tr>
+ <td><xsl:value-of select="name"/></td>
+ <td><xsl:value-of select="score"/></td>
+ <td><xsl:value-of select="gridSize"/></td>
+ <td><xsl:value-of select="seconds"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php
new file mode 100755
index 000000000..daf480e21
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/qmladvancedtutorial/samegame/samegame4/highscores/scores.php
@@ -0,0 +1,31 @@
+<?php
+ $score = $_POST["score"];
+ echo "<html>";
+ echo "<head><title>SameGame High Scores</title></head><body>";
+ if($score > 0){#Sending in a new high score
+ $name = $_POST["name"];
+ $grid = $_POST["gridSize"];
+ $time = $_POST["time"];
+ if($name == "")
+ $name = "Anonymous";
+ $file = fopen("score_data.xml", "a");
+ $ret = fwrite($file, "<record><score>". $score . "</score><name>"
+ . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
+ . $time . "</seconds></record>\n");
+ echo "Your score has been recorded. Thanks for playing!";
+ if($ret == False)
+ echo "<br/> There was an error though, so don't expect to see that score again.";
+ }else{#Read high score list
+ #Now uses XSLT to display. So just print the file. With XML cruft added.
+ #Note that firefox at least won't apply the XSLT on a php file. So redirecting
+ $file = fopen("scores.xml", "w");
+ $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
+ . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
+ . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
+ if($ret == False)
+ echo "There was an internal error. Sorry.";
+ else
+ echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
+ }
+ echo "</body></html>";
+?>