~ubuntu-branches/ubuntu/saucy/qtdeclarative-opensource-src/saucy

« back to all changes in this revision

Viewing changes to examples/quick/tutorials/samegame/samegame4/highscores/scores.php

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 14:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20130205141719-qqeyml8wslpyez52
Tags: upstream-5.0.1
ImportĀ upstreamĀ versionĀ 5.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
    $score = $_POST["score"];
 
3
    echo "<html>";
 
4
    echo "<head><title>SameGame High Scores</title></head><body>";
 
5
    if($score > 0){#Sending in a new high score
 
6
        $name = $_POST["name"];
 
7
        $grid = $_POST["gridSize"];
 
8
        $time = $_POST["time"];
 
9
        if($name == "")
 
10
            $name = "Anonymous";
 
11
        $file = fopen("score_data.xml", "a");
 
12
        $ret = fwrite($file, "<record><score>". $score . "</score><name>" 
 
13
            . $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
 
14
            . $time . "</seconds></record>\n");
 
15
        echo "Your score has been recorded. Thanks for playing!";
 
16
        if($ret == False)
 
17
            echo "<br/> There was an error though, so don't expect to see that score again.";
 
18
    }else{#Read high score list
 
19
        #Now uses XSLT to display. So just print the file. With XML cruft added.
 
20
        #Note that firefox at least won't apply the XSLT on a php file. So redirecting
 
21
        $file = fopen("scores.xml", "w");
 
22
        $ret = fwrite($file, '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n"
 
23
            . '<?xml-stylesheet type="text/xsl" href="score_style.xsl"?>' . "\n"
 
24
            . "<records>\n" . file_get_contents("score_data.xml") . "</records>\n");
 
25
        if($ret == False)
 
26
            echo "There was an internal error. Sorry.";
 
27
        else
 
28
            echo '<script type="text/javascript">window.location.replace("scores.xml")</script>';
 
29
    }
 
30
    echo "</body></html>";
 
31
?>