/plugins/site/themes/custom/game.php
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
- <div class="centercontent_part">
- <div class="column2"><?php
- do_event("gamepage");
- $maxwidth = $config['maxgamewidth'];
- $minwidth = $config['mingamewidth'];
- $maxnopopwidth = $config['maxnopopwidth'];
- $game = get_game("id=" . _sp($params[1]) . "&maxwidth=" . _sp($maxwidth) . "&minwidth=" . _sp($minwidth));
- if (isset($game['id'])) {
- $cfg['pagetitle'] = $game['name'];
- $cfg['metakey'] = $game['keywords'];
- $cfg['metadesc'] = $game['desc'];
- $game['time'] = date("M d, Y", $game['time']);
- $db->query("UPDATE `games` SET `playcount`=`playcount` +1 WHERE `id` = " . $game['id']);
- if (hscode("highscore", $game['flags'])) {
- if (highscores_login_required() && get_logged_in_user() == false) {
- redirect(language("mustlogintoplayhs", true), $link, 5);
- }
- $_COOKIE['playtype'] = isset($_COOKIE['playtype']) ? $_COOKIE['playtype'] : '';
- if ($_COOKIE["playtype"] != "current") {
- setcookie("playtype", "current", time() + 3600, "/");
- }
- } ?>
- <div class="home_browsetxt_bg" style="font:bold 14px arial; height:40px;">
- <div style="float:left;">
- You are Playing: <a
- href="<?php echo get_category_link("name=" . $game['cat']); ?>"><?php echo $game['cat']; ?>
- Games</a> » <?php echo $game['name']; ?>
- </div>
- <div style="float:right; margin:-4px 10px 0 0;">
- <a href="javascript:history.go(-1)"><img src="[themedir]images/goback_btn.png" alt="Go Back"/></a>
- </div>
- </div>
- <div class="reg_topcurve"> </div>
- <div class="reg_middle" style="text-align:center;">
- <?php echo show_ad("location=abovegame468x60");
- $game['type'] = isset($game['type']) ? $game['type'] : '';
- if ($game['type'] != 'extlink') {
- if ($game['width'] <= $maxnopopwidth) {
- echo $game['code'] . "<br /><br />";
- do_event("gameplay");
- } else {
- $link = get_play_link("id=" . _sp($params[1]));
- $width = $game['width'];
- $height = $game['height'];
- $link = "javascript:popup('" . $link . "', " . $width . ", " . $height . ")";
- echo "<br /><br /><b><a href=\"" . $link . "\" class='darklink'>- " . language("clickhere", true) . " " . $game['name'] . " " . language("newwindow", true) . " -</a></b>";
- }
- } else {
- if (get_game_config("name=frameextlinks") == 1) {
- $target = "";
- } else {
- $target = "target='_blank'";
- }
- echo "<br /><b><a href=\"" . get_play_link("id=" . _sp($game['id'])) . "\" class='darklink' " . $target . ">- " . language("clickhere", true) . " " . $game['name'] . " -</a></b><br /><br />";
- }?>
- <br/><br/>
- <div class="gamedesc_white_middle" align="left">
- <div class="play_gm_det_img">
- <img src="[imgdir]<?php echo $game['nameid']; ?>.png" height="100px" width="100px" alt="Play!"/>
- </div>
- <div class="play_gm_all_det">
- <p class="play_gm_all_det_desc_tle">Description:</p>
- <p class="play_gm_all_det_desc"><?php echo $game['desc']; ?></p>
- <p class="play_gm_all_det_int_tle">Instructions:</p>
- <p class="play_gm_all_det_int_desc"><?php echo $game['instructions']; ?></p><?php
- if ($game['flags'] <> '') { /* If there are no flags set (i.e. a Mochi game), then don't show the score table*/ ?>
- <p class="play_gm_all_det_int_tle"><?php echo $language['top10score']; ?></p>
- <table width="97%" cellpadding="7px" cellspacing="0" class="contenttable">
- <tr>
- <td align="left"></td>
- <td align="left"><b><?php echo language("player", true) ?></b></td>
- <td align="left"><b><?php echo language("score", true) ?></b></td>
- <td align="left"><b><?php echo language("date", true) ?></b></td>
- </tr><?php
- if (hscode("lowhighscore", $game['flags'])) {
- $scores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=" . $themecfg['gametopscores'] . "&sort=ASC");
- $tscores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=1&sort=ASC"); //Trying to fix "bad" champ scores
- } else {
- $scores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=" . $themecfg['gametopscores'] . "&sort=DESC");
- $tscores = get_games_score("nameid=" . $game['id'] . "&limitstart=0&limitnum=1&sort=DESC"); //Trying to fix "bad" champ scores
- }
- $i = 0;
- if (count($scores) != 0) {
- foreach ($scores as $score) {
- ++$i;
- $d_score = date("m/d/Y", $score['date']);
- $user = get_user("id=" . _sp($score['player']));
- if (trim($user['avatarurl']) == '') {
- $user['avatarurl'] = get_home_link() . "plugins/users/noav.png";
- $user['avatarurl'] = str_replace("http://", "", $user['avatarurl']);
- }?>
- <tr>
- <td align="left"><b><?php echo $i ?></b></td>
- <td align="left"><img
- src="http://<?php echo str_replace('http://', '', $user['avatarurl']); ?>"
- width="16px" height="16px" alt="No Avatar"/>
- <a class='contentlink'
- href="<?php echo get_profile_link("id=" . _sp($user['id'])); ?>"><?php echo $user['username']; ?></a>
- </td>
- <td align="left"><?php echo formatScore($score['score']); ?></td>
- <td align="left"><?php echo $d_score; ?></td>
- </tr><?php
- }
- /* This next section corrects the "Games Champs Table. When you delete the games_champs that don't exist anymore,
- as done via CRON, it causes the "champ" to actually be the next person that plays... not the actual champ.
- As a result, this code patches that issue by taking the best score for that game and updating the champs table.
- This code is driven by above if (hscode("lowhighscore", $game['flags'])). Also, the champs table had a PK added on nameid to
- prevent duplicates. I'm not sure that $scores needs to be defined, but I'm not going to change it just yet.
- $info[0] is the score in the games_champs table
- $tscore['x'] is the top player in the games list.
- -- Sage 08/24/09, updated 09/07/09 */
- foreach ($tscores as $tscore) { //Get the top score on that game.
- $tnameid = $tscore['nameid'];
- $tuser = $tscore['player'];
- $tscore = $tscore['score'];
- $tdate = $tscore['date'];
- if ($tscore['score'] <> $info[0]) { //Compare the top score to the champ ($info) which is defined in scoreinfo.php
- // If the scores don't match, then correct it.
- $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.");
- }
- }
- } /* End Games Champs Fix */ ?>
- </table><?php
- } ?>
- </div>
- </div>
- <div class="gamedesc_white_btm"> </div><?php
- echo show_ad("location=belowgame468x60");?>
- </div>
- <div class="reg_btmcurve"> </div>
- <?php include "ads/top728x90ads.php"; ?>
- <div class="reg_topcurve"> </div>
- <div class="reg_middle" style="padding-top:0;">
- <div class="related_headerbg">Comments:</div>
- <div class="related_gms_list"><?php
- //TODO: Add option to turn disqus on and off from database
- $currentlink = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>
- <div id="disqus_thread"></div>
- <script type="text/javascript">
- //noinspection LocalVariableNamingConventionJS
- var disqus_shortname = '<?php echo $cfg['disqus_user'];?>'; // required: replace example with your forum shortname
- //noinspection LocalVariableNamingConventionJS
- var disqus_identifier = '<?php echo $game['id'];?>';
- //noinspection LocalVariableNamingConventionJS
- var disqus_url = '<?php echo $currentlink;?>';
- /* * * DON'T EDIT BELOW THIS LINE * * */
- (function () {
- var dsq = document.createElement('script');
- dsq.type = 'text/javascript';
- dsq.async = true;
- dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
- })();
- </script>
- <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments
- powered by Disqus.</a></noscript>
- <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
- </div>
- </div>
- <div class="reg_btmcurve"> </div>
- <div style="clear:both; height:10px;"> </div><?php
- } else {
- header("HTTP/1.0 404 Not Found");
- echo "Sorry, this game doesn't exist";
- } ?>
- </div>
- <div class="centercontent_btmcurve"> </div>
- <script type="text/javascript" src="[themedir]js/sageth-min.js" charset="utf-8"></script>
- <script language="JavaScript" type="text/javascript">
- <!--
- function setupGamerSafeBridge() {
- //noinspection UnnecessaryLocalVariableJS
- var bridgeConfig = {
- user: "<?php echo $user['username'];?>",
- session: "hostSessionID",
- game: "<?php echo $game['name'];?>",
- url: "scripts/GamerSafe/bridge_test.php"
- };
- return bridgeConfig;
- }
- // -->
- </script>
- </div>