+ return $output;
+}
+
+function format_score_table_html($score,$userid)
+{
+ global $INDEX;
+
+ if(sizeof($score)==0)
+ return "";
+
+ $output = "<div class=\"scoretable\">\n<table class=\"score\">\n <thead>\n <tr>\n";
+
+ /* output header */
+ $output.= " <th> No </th>";
+ foreach($score[0]['players'] as $id=>$points)
+ {
+ $name = DB_get_name('userid',$id); /*TODO*/
+ $output.= "<th> ".substr($name,0,2)." </th>";
+ }
+ $output.="<th>P</th>\n </tr>\n </thead>\n <tbody>\n";
+
+ $i=0;
+ foreach($score as $game)
+ {
+ $i++;
+ $output.=" <tr>";
+ $userhash = DB_get_hash_from_gameid_and_userid($game['gameid'],$userid);
+ /* create link to old games only if you are logged in and its your game*/
+ if(isset($_SESSION['id']) && $_SESSION['id']==$userid)
+ $output.=" <td> <a href=\"".$INDEX."?action=game&me=".$userhash."\">$i</a></td>";
+ else
+ $output.=" <td>$i</td>";
+
+ foreach($game['players'] as $id=>$points)
+ $output.="<td>".$points."</td>";
+ $output.="<td>".$game['points'];
+
+ /* check for solo */
+ if($game['solo'])
+ $output.= " S";
+ $output.="</td></tr>\n";
+ }
+
+ $output.=" </tbody>\n</table>\n</div>\n";
+
+ return $output;
+}
+
+function createCache($content, $cacheFile)
+{
+ $fp = fopen($cacheFile,"w");
+ if($fp)
+ {
+ fwrite($fp,$content);
+ fclose($fp);
+ }
+ else
+ echo "WARNING: couldn't create cache file";
+