PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/plugins/site/themes/custom/game.php

https://bitbucket.org/trujka/phparcade
PHP | 183 lines | 169 code | 0 blank | 14 comment | 25 complexity | 4027ab90276168425cfe34205cf1b51a MD5 | raw file
Possible License(s): LGPL-2.1, MIT, CC-BY-3.0
  1. <div class="centercontent_part">
  2. <div class="column2"><?php
  3. do_event("gamepage");
  4. $maxwidth = $config['maxgamewidth'];
  5. $minwidth = $config['mingamewidth'];
  6. $maxnopopwidth = $config['maxnopopwidth'];
  7. $game = get_game("id=" . _sp($params[1]) . "&maxwidth=" . _sp($maxwidth) . "&minwidth=" . _sp($minwidth));
  8. if (isset($game['id'])) {
  9. $cfg['pagetitle'] = $game['name'];
  10. $cfg['metakey'] = $game['keywords'];
  11. $cfg['metadesc'] = $game['desc'];
  12. $game['time'] = date("M d, Y", $game['time']);
  13. $db->query("UPDATE `games` SET `playcount`=`playcount` +1 WHERE `id` = " . $game['id']);
  14. if (hscode("highscore", $game['flags'])) {
  15. if (highscores_login_required() && get_logged_in_user() == false) {
  16. redirect(language("mustlogintoplayhs", true), $link, 5);
  17. }
  18. $_COOKIE['playtype'] = isset($_COOKIE['playtype']) ? $_COOKIE['playtype'] : '';
  19. if ($_COOKIE["playtype"] != "current") {
  20. setcookie("playtype", "current", time() + 3600, "/");
  21. }
  22. } ?>
  23. <div class="home_browsetxt_bg" style="font:bold 14px arial; height:40px;">
  24. <div style="float:left;">
  25. You are Playing: <a
  26. href="<?php echo get_category_link("name=" . $game['cat']); ?>"><?php echo $game['cat']; ?>
  27. Games</a> &raquo; <?php echo $game['name']; ?>
  28. </div>
  29. <div style="float:right; margin:-4px 10px 0 0;">
  30. <a href="javascript:history.go(-1)"><img src="[themedir]images/goback_btn.png" alt="Go Back"/></a>
  31. </div>
  32. </div>
  33. <div class="reg_topcurve">&nbsp;</div>
  34. <div class="reg_middle" style="text-align:center;">
  35. <?php echo show_ad("location=abovegame468x60");
  36. $game['type'] = isset($game['type']) ? $game['type'] : '';
  37. if ($game['type'] != 'extlink') {
  38. if ($game['width'] <= $maxnopopwidth) {
  39. echo $game['code'] . "<br /><br />";
  40. do_event("gameplay");
  41. } else {
  42. $link = get_play_link("id=" . _sp($params[1]));
  43. $width = $game['width'];
  44. $height = $game['height'];
  45. $link = "javascript:popup('" . $link . "', " . $width . ", " . $height . ")";
  46. echo "<br /><br /><b><a href=\"" . $link . "\" class='darklink'>- " . language("clickhere", true) . " " . $game['name'] . " " . language("newwindow", true) . " -</a></b>";
  47. }
  48. } else {
  49. if (get_game_config("name=frameextlinks") == 1) {
  50. $target = "";
  51. } else {
  52. $target = "target='_blank'";
  53. }
  54. echo "<br /><b><a href=\"" . get_play_link("id=" . _sp($game['id'])) . "\" class='darklink' " . $target . ">- " . language("clickhere", true) . " " . $game['name'] . " -</a></b><br /><br />";
  55. }?>
  56. <br/><br/>
  57. <div class="gamedesc_white_middle" align="left">
  58. <div class="play_gm_det_img">
  59. <img src="[imgdir]<?php echo $game['nameid']; ?>.png" height="100px" width="100px" alt="Play!"/>
  60. </div>
  61. <div class="play_gm_all_det">
  62. <p class="play_gm_all_det_desc_tle">Description:</p>
  63. <p class="play_gm_all_det_desc"><?php echo $game['desc']; ?></p>
  64. <p class="play_gm_all_det_int_tle">Instructions:</p>
  65. <p class="play_gm_all_det_int_desc"><?php echo $game['instructions']; ?></p><?php
  66. if ($game['flags'] <> '') { /* If there are no flags set (i.e. a Mochi game), then don't show the score table*/ ?>
  67. <p class="play_gm_all_det_int_tle"><?php echo $language['top10score']; ?></p>
  68. <table width="97%" cellpadding="7px" cellspacing="0" class="contenttable">
  69. <tr>
  70. <td align="left"></td>
  71. <td align="left"><b><?php echo language("player", true) ?></b></td>
  72. <td align="left"><b><?php echo language("score", true) ?></b></td>
  73. <td align="left"><b><?php echo language("date", true) ?></b></td>
  74. </tr><?php
  75. if (hscode("lowhighscore", $game['flags'])) {
  76. $scores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=" . $themecfg['gametopscores'] . "&sort=ASC");
  77. $tscores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=1&sort=ASC"); //Trying to fix "bad" champ scores
  78. } else {
  79. $scores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=" . $themecfg['gametopscores'] . "&sort=DESC");
  80. $tscores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=1&sort=DESC"); //Trying to fix "bad" champ scores
  81. }
  82. $i = 0;
  83. if (count($scores) != 0) {
  84. foreach ($scores as $score) {
  85. ++$i;
  86. $d_score = date("m/d/Y", $score['date']);
  87. $user = get_user("id=" . _sp($score['player']));
  88. if (trim($user['avatarurl']) == '') {
  89. $user['avatarurl'] = get_home_link() . "plugins/users/noav.png";
  90. $user['avatarurl'] = str_replace("http://", "", $user['avatarurl']);
  91. }?>
  92. <tr>
  93. <td align="left"><b><?php echo $i ?></b></td>
  94. <td align="left"><img
  95. src="http://<?php echo str_replace('http://', '', $user['avatarurl']); ?>"
  96. width="16px" height="16px" alt="No Avatar"/>
  97. <a class='contentlink'
  98. href="<?php echo get_profile_link("id=" . _sp($user['id'])); ?>"><?php echo $user['username']; ?></a>
  99. </td>
  100. <td align="left"><?php echo formatScore($score['score']); ?></td>
  101. <td align="left"><?php echo $d_score; ?></td>
  102. </tr><?php
  103. }
  104. /* This next section corrects the "Games Champs Table. When you delete the games_champs that don't exist anymore,
  105. as done via CRON, it causes the "champ" to actually be the next person that plays... not the actual champ.
  106. As a result, this code patches that issue by taking the best score for that game and updating the champs table.
  107. This code is driven by above if (hscode("lowhighscore", $game['flags'])). Also, the champs table had a PK added on nameid to
  108. prevent duplicates. I'm not sure that $scores needs to be defined, but I'm not going to change it just yet.
  109. $info[0] is the score in the games_champs table
  110. $tscore['x'] is the top player in the games list.
  111. -- Sage 08/24/09, updated 09/07/09 */
  112. foreach ($tscores as $tscore) { //Get the top score on that game.
  113. $tnameid = $tscore['nameid'];
  114. $tuser = $tscore['player'];
  115. $tscore = $tscore['score'];
  116. $tdate = $tscore['date'];
  117. if ($tscore['score'] <> $info[0]) { //Compare the top score to the champ ($info) which is defined in scoreinfo.php
  118. // If the scores don't match, then correct it.
  119. $db->query("UPDATE `games_champs` SET `nameid` = " . $tnameid . ", `player` = " . $tuser . ", `score` = " . $tscore . ", `date` = " . $ctime . " WHERE `nameid` = " . $game['id'] . " LIMIT 1") or die ("Whoops. Something went wrong during tscore.");
  120. }
  121. }
  122. } /* End Games Champs Fix */ ?>
  123. </table><?php
  124. } ?>
  125. </div>
  126. </div>
  127. <div class="gamedesc_white_btm">&nbsp;</div><?php
  128. echo show_ad("location=belowgame468x60");?>
  129. </div>
  130. <div class="reg_btmcurve">&nbsp;</div>
  131. <?php include "ads/top728x90ads.php"; ?>
  132. <div class="reg_topcurve">&nbsp;</div>
  133. <div class="reg_middle" style="padding-top:0;">
  134. <div class="related_headerbg">Comments:</div>
  135. <div class="related_gms_list"><?php
  136. //TODO: Add option to turn disqus on and off from database
  137. $currentlink = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>
  138. <div id="disqus_thread"></div>
  139. <script type="text/javascript">
  140. //noinspection LocalVariableNamingConventionJS
  141. var disqus_shortname = '<?php echo $cfg['disqus_user'];?>'; // required: replace example with your forum shortname
  142. //noinspection LocalVariableNamingConventionJS
  143. var disqus_identifier = '<?php echo $game['id'];?>';
  144. //noinspection LocalVariableNamingConventionJS
  145. var disqus_url = '<?php echo $currentlink;?>';
  146. /* * * DON'T EDIT BELOW THIS LINE * * */
  147. (function () {
  148. var dsq = document.createElement('script');
  149. dsq.type = 'text/javascript';
  150. dsq.async = true;
  151. dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  152. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  153. })();
  154. </script>
  155. <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments
  156. powered by Disqus.</a></noscript>
  157. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  158. </div>
  159. </div>
  160. <div class="reg_btmcurve">&nbsp;</div>
  161. <div style="clear:both; height:10px;">&nbsp;</div><?php
  162. } else {
  163. header("HTTP/1.0 404 Not Found");
  164. echo "Sorry, this game doesn't exist";
  165. } ?>
  166. </div>
  167. <div class="centercontent_btmcurve">&nbsp;</div>
  168. <script type="text/javascript" src="[themedir]js/sageth-min.js" charset="utf-8"></script>
  169. <script language="JavaScript" type="text/javascript">
  170. <!--
  171. function setupGamerSafeBridge() {
  172. //noinspection UnnecessaryLocalVariableJS
  173. var bridgeConfig = {
  174. user: "<?php echo $user['username'];?>",
  175. session: "hostSessionID",
  176. game: "<?php echo $game['name'];?>",
  177. url: "scripts/GamerSafe/bridge_test.php"
  178. };
  179. return bridgeConfig;
  180. }
  181. // -->
  182. </script>
  183. </div>