diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2015-05-07 23:14:47 -0500 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2015-05-07 23:14:47 -0500 |
commit | 3dc3919ce1b5336861979cde56884842615c967b (patch) | |
tree | f0a2418290cecd15f20c834bb071ffa9f3694b09 /pages | |
parent | 29e872fbc6c552ef02208fe9fa5416b69773aa38 (diff) | |
parent | c517b645c8723b5f4d20cbb91cbc4b9f45579cbb (diff) | |
download | pathery-3dc3919ce1b5336861979cde56884842615c967b.tar.xz |
Merge branch 'master' of git.raylu.net:pathery
Diffstat (limited to 'pages')
-rw-r--r-- | pages/chat.php | 427 | ||||
-rw-r--r-- | pages/creategame.php | 50 | ||||
-rw-r--r-- | pages/feedback.php | 45 | ||||
-rw-r--r-- | pages/games.php | 151 | ||||
-rw-r--r-- | pages/home.php | 1 | ||||
-rw-r--r-- | pages/login.php | 107 | ||||
-rw-r--r-- | pages/mapeditor.php | 47 | ||||
-rw-r--r-- | pages/matches.php | 140 |
8 files changed, 486 insertions, 482 deletions
diff --git a/pages/chat.php b/pages/chat.php index a1870a6..5fe5d9e 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -2,7 +2,7 @@ htmlHeader(
array('stats', 'chat'), 'Chat',
'Chat for Pathery.com',
- array('scores', 'dateformat')
+ array('scores', 'dateformat', 'chat')
);
?>
@@ -17,431 +17,6 @@ if (!$accepted) { <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
-<script>
-
-var lastID = 1;
-//Internet Explorer doesn't support "const"
-//CONSTANTS: ...
-var chatTimerDelayUpper = 9000;
-var chatTimerDelayLower = 2000;
-var chatTimerDelayDefault = 5000;
-var chatTimerDelayWindowHidden = 90000;
-
-var chatTimerDelay = chatTimerDelayDefault;
-var isChatWindowVisible = true;
-var skipNextGetChat = false;
-var chatBuffer = new Array();
-
-getChatTimer();
-function getChatTimer() {
- setTimeout("getChatTimer()", chatTimerDelay);
- if (isChatWindowVisible)
- chatTimerDelay = Math.min(chatTimerDelay + 300, chatTimerDelayUpper);
- if (skipNextGetChat) {
- skipNextGetChat = false;
- return;
- }
- getChat();
- //addChatMessage("Debug", "Chat timer called!");
-}
-
-var firstGetChat = true;
-function getChatDone(data) {
- var newChats = false;
-
- ////console.log('datalength', data.length);
-
- if (data.length < 3 || data == 'false')
- return;
-
- //console.log("START BUILD");
-
- //console.log("JSON TO PARSE", data);
-
- json = jQuery.parseJSON(data);
-
- //console.log("JSON PREPED");
-
- $.each(json, function(key, chat) {
-
- var postDate = new Date();
- postDate.setTime(postDate.getTime() + chat.secondsSince * 1000);
-
- if (!chat.message) return;
-
- var isSelf = (chat.userID == userObj.ID);
- var isServer = false;
-
- if (chat.userID == null || chat.userID <= 0) {
- isServer = true;
- chat.displayName = 'SERVER'
- }
-
- if (chat.isJoinLeave == 'true') {
- console.log('IsJoin Leave!')
- //return true;
- }
-
- //Message is legitmently new or a server message?
- if (chat.ID > lastID || typeof(chat.ID) == 'undefined') {
- addChatMessage(chat.displayName, chat.message, postDate, isSelf, isServer, chat.wallColor, chat.wallEmblem,
- chat.wallOrientation, chat.userID, chat.displayColor, chat.ID);
- newChats = true;
- }
-
- //console.log("INSIDE BUILD START");
- if (chat.ID > 0)
- lastID = chat.ID;
- });
-
- //console.log("BUILD DONE");
-
- if (newChats && !firstGetChat) {
- if (isChatWindowVisible)
- chatTimerDelay = chatTimerDelayLower;
-
- if (chatIsMuted == 'false') {
- soundManager.setVolume('charm', 20);
- soundManager.setPan('charm', -60)
- soundManager.setPosition('charm',150);
- soundManager.play('charm');
- }
- }
-
- firstGetChat = false;
-}
-
-function addChatMessage(displayName, message, postDate, isSelf, isServer, wallColor, wallEmblem, wallOrientation, userID, displayColor, chatID)
-{
- if(!postDate)
- postDate = new Date();
- var timestamp = postDate.format("hh:MM:ss");
- var timestampDetails = postDate.format("ddd h:MM TT");
-
- var strClass = '';
- if (isSelf)
- strClass += ' self';
- if (isServer)
- strClass += ' server';
-
- var usernameClass = '';
- if (message.indexOf("/me ") == 0) {
- message = message.substring(4);
- usernameClass = ' me';
- }
-
- var isSpoiler = false;
- if (message.indexOf("/spoiler ") == 0) {
- message = message.substring(9);
- isSpoiler = true;
- }
-
- if (!isSpoiler) {
- document.title = displayName + ': '+ message.substring(0, 20) + ' | Pathery Chat';
- } else {
- document.title = displayName + ': ~Spoiler~ | Pathery Chat';
- }
-
- var p = '';
- p = p+ " <div class='chatColumn1'>";
- p = p+ " <span class='chatTimestamp' title='"+timestampDetails+"'>["+timestamp+"]</span>";
- p = p+ " <div class='grid_td chatBadge' style='float:left; width:35px; height:35px; background:"+wallColor+" url("+linkEmblem(wallEmblem, wallOrientation)+");'>";
- p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
- p = p+ " </div>";
- p = p+ " </div>";
- p = p+ " </div>";
-
- p = p+ " <div class='chatColumn2'>";
- if (userID == null || userID <= 0) {
- p = p+ "<span class='chatUsername"+usernameClass+"'><a href='home'>";
- } else {
- p = p+ "<span class='chatUsername"+usernameClass+"'><a href='achievements?id="+userID+"' style='color:"+displayColor+"'>";
- }
- p = p+ displayName+"</a></span>";
-
- if (isSpoiler == true) p = p+ " <span class='chatText spoiler' onclick='spoil(this);'>";
- else p = p+ " <span class='chatText'>";
- p = p+ chatReplaceAndEncode(message);
- p = p+ " </span>";
- p = p+ " </div>";
-
- var chatContainer = $("#chatContainer");
- var isAtBottom = (chatContainer.length == 1 && chatContainer.scrollTop() >= chatContainer[0].scrollHeight - chatContainer.outerHeight() - 1);
-
- chatContainer.append('<div class="chatMessage'+strClass+'" id="C_' + chatID + '">' + p + '</div>');
-
- if (isAtBottom || firstGetChat) {
- chatContainer.scrollTop(chatContainer[0].scrollHeight);
- }
-}
-
-function chatReplaceAndEncode(chat) {
- chat = htmlEncode(chat);
- chat = chat.replace(/\*\*(\S(.*?\S)?)\*\*/gm, "<b>$1</b>");
- chat = chat.replace(/\~\~(\S(.*?\S)?)\~\~/gm, "<s>$1</s>");
- chat = chat.replace(/\*(\S(.*?\S)?)\*/gm, "<i>$1</i>");
-
- chat = replaceSmileys(chat);
-
- //Surround all URLs with a <a> link
- var URLexp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
- chat = chat.replace(URLexp, "<a href='redirect?to=$1' target='_blank' onclick='return doNothingWhenClickingLinks(this);'>$1</a>");
-
- //Replace # with %23, & with %26, ? with %3F
- chat = chat.replace(/<a href='redirect\?to=(.*?)(#)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%23$3' target='_blank'");
- chat = chat.replace(/<a href='redirect\?to=(.*?)(&)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%26$3' target='_blank'");
- chat = chat.replace(/<a href='redirect\?to=(.*?)(\?)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%3F$3' target='_blank'");
- //Making the bet that not all browsers do the same:
- chat = chat.replace(/<a href='redirect\?to=(.*?)(&)(.*?)' target='_blank'/ig, "<a href='redirect?to=$1%26$3' target='_blank'");
-
- return chat;
-}
-
-function replaceSmileys(chat) {
- chat = chat.replace(/:\)|\(:|=\)/g, '<img title=":)" class="chatSmiley" src="images/smileys/Smiling.png" />');
- chat = chat.replace(/:\(|=\(/g, '<img title=":(" class="chatSmiley" src="images/smileys/Unhappy.png" />');
- chat = chat.replace(/\^\_\^/g, '<img title="^_^" class="chatSmiley" src="images/smileys/Happy_3.png" />');
- chat = chat.replace(/\:d/gi, '<img title=":D" class="chatSmiley" src="images/smileys/Grinning.png" />');
- chat = chat.replace(/\:o/gi, '<img title=":O" class="chatSmiley" src="images/smileys/Gasping.png" />');
- chat = chat.replace(/\:p/gi, '<img title=":P" class="chatSmiley" src="images/smileys/Tongue_Out.png" />');
- chat = chat.replace(/;p/gi, '<img title=":s" class="chatSmiley" src="images/smileys/Tongue_Out_Winking.png" />');
- chat = chat.replace(/\:c/gi, '<img title=":c" class="chatSmiley" src="images/smileys/Childish.png" />');
- chat = chat.replace(/\:s/gi, '<img title=":s" class="chatSmiley" src="images/smileys/Confused.png" />');
- chat = chat.replace(/\>_\</g, '<img title=">_<" class="chatSmiley" src="images/smileys/Gah.png" />');
- chat = chat.replace(/\$_\$/gi, '<img title="$_$" class="chatSmiley" src="images/smileys/Greedy.png" />');
- chat = chat.replace(/-\.-|-_-/gi, '<img title="-.-" class="chatSmiley" src="images/smileys/Tired.png" />');
- chat = chat.replace(/o\.O|o\_O/g, '<img title="o_O" class="chatSmiley" src="images/smileys/Huh.png" />');
- chat = chat.replace(/O\.o|O\_o/g, '<img title="O_o" class="chatSmiley" src="images/smileys/Huh_2.png" />');
- chat = chat.replace(/O\.O|O\_O/g, '<img title="O_O" class="chatSmiley" src="images/smileys/Madness.png" />');
- chat = chat.replace(/\:-\//g, '<img title="O_O" class="chatSmiley" src="images/smileys/Uncertain.png" />');
- chat = chat.replace(/\(y\)/gi, '<img title="(y)" class="chatSmiley" src="images/smileys/Thumb_Up.png" />');
- chat = chat.replace(/\(n\)/gi, '<img title="(n)" class="chatSmiley" src="images/smileys/Thumb_Down.png" />');
- chat = chat.replace(/\<3/g, '<img title="<3" class="chatSmiley" src="images/smileys/Heart.png" />');
- return chat;
-}
-
-function prepChat(chat) {
- chat = chat.join('|:|');
- chat = chat.replace(/\&/g,'%26')
- chat = chat.replace(/\+/g,'%2B')
- return chat;
-}
-
-var chatIsBusy = false;
-function getChat(message) {
- var dataString = 'getChatFromID='+lastID;
- var backup = new Array();
-
- var fncComplete = '';
- if (!chatIsBusy && chatBuffer.length > 0) {
- chatIsBusy = true;
- dataString += '&send=true&messages='+prepChat(chatBuffer);
- backup = chatBuffer.slice(0);
- chatBuffer.length = 0;
- fncComplete = function() {chatIsBusy = false;};
- }
- $.ajax({
- type: "POST",
- url: "ajax/chat.ajax.php",
- data: dataString,
- error: function() {
- chatBuffer = backup.concat(chatBuffer);
- //console.log('concated:', chatBuffer, backup);
- },
- success: function(data) {
- getChatDone(data);
- //console.log('b:', backup);
- },
- complete: fncComplete
- });
-}
-
-function pollChannelList() {
- $.ajax({
- //type: "POST",
- url: "ajax/chat.ajax.php?pollChannelList=1",
- error: function() {
- console.log('Error: Failed pollChannelList');
- },
- success: function(data) {
- console.log("ChannelPoll data recieved", data);
- pollChannelListDone(data);
- }
- });
-}
-
-function pollChannelListDone(data) {
-
- console.log('data recieved:', data);
- if (data.length < 3 || data == 'false') return;
- json = jQuery.parseJSON(data);
-
- console.log('Loading channel.');
- var c = channelListShow(json)
- console.log(c);
-
- var b = $("#channelContainer");
- b.html(c);
-}
-
-
-function channelListShow(JO) {
- console.log("Formating channelList");
-
- var p = "<table class='membersList score' style='max-height:400px; width:220px; background-color:transparent; '>";
-
- console.log('beginloop');
-
- var previousI = 0;
- for (var i in JO.users) {
- console.log('loop')
- var u = JO.users[i];
- var styleClass = '';
-
- if (previousI != i + 1) {
- if (previousI < i - 1 && previousI != 0) {
- styleClass = 'border-top: 6px solid #777799;';
- }
- }
-
- if (u.wallEmblem == undefined) u.wallEmblem = 'blank.png';
- p = p+ "<tr style='"+styleClass+" background-color: "+u.background+"; color:"+u.displayColor+";' title='Last Active: "+u.dateLastActive+"'>";
-
- p = p+ "<td style='vertical-align: middle;width:100px;'>";
- p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url("+linkEmblem(u.wallEmblem, u.wallOrientation)+");'>";
- p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
- p = p+ " </div>";
- p = p+ " </div>";
- p = p+ " <span class='scoreName' style='float:left;'><a target='_blank' href='achievements?id="+u.ID+"' style='color:"+u.displayColor+"'>"+u.display+"</a></span>";
- p = p+ "</td>";
-
- previousI = i;
- }
- p = p+"</table>";
- return p;
-}
-
-
-
-function sendChat() {
- var message = $("input#message").val().replace("|:|", "||");
- if (message == '') return false;
- chatBuffer.push(message);
- $("input#message").val('');
- if (skipNextGetChat == false) {
- skipNextGetChat = true;
- }
- getChat();
- return false;
-}
-
-function spoil(obj) {
- $(obj).removeClass("spoiler").hide().fadeIn(600);
- $(obj).children().removeAttr('onclick');
-}
-
-$(document).ready(function() {
- $('#sendChat').live("submit", function() {
- sendChat()
- });
-
- //Prevent clicking on links in spoilers
- $(document).on('click', '.spoiler > a', function()
- {
- addChatMessage("Debug", "Child called");
- });
-});
-
-function htmlEncode(value){
- if (value) {
- return jQuery('<div />').text(value).html();
- } else {
- return '';
- }
-}
-
-function doNothingWhenClickingLinks(self)
-{
- return !$(self).closest('.spoiler').length;
-}
-
-//Code for checking if the window is currently visible or not
-//Adapted from http://stackoverflow.com/a/1060034/238419
-$(function() {
- var hidden = "hidden";
-
- // Standards:
- if (hidden in document)
- document.addEventListener("visibilitychange", onchange);
- else if ((hidden = "mozHidden") in document)
- document.addEventListener("mozvisibilitychange", onchange);
- else if ((hidden = "webkitHidden") in document)
- document.addEventListener("webkitvisibilitychange", onchange);
- else if ((hidden = "msHidden") in document)
- document.addEventListener("msvisibilitychange", onchange);
- // IE 9 and lower:
- else if ('onfocusin' in document)
- document.onfocusin = document.onfocusout = onchange;
- // All others:
- else
- window.onpageshow = window.onpagehide
- = window.onfocus = window.onblur = onchange;
-
- function onchange (evt) {
- var eventMapIsWindowShown = {
- focus:true, focusin:true, pageshow:true, blur:false, focusout:false, pagehide:false
- };
-
- evt = evt || window.event;
- if (evt.type in eventMapIsWindowShown)
- isChatWindowVisible = eventMapIsWindowShown[evt.type];
- else
- isChatWindowVisible = !this[hidden];
-
- if(isChatWindowVisible)
- onChatWindowShown();
- else
- onChatWindowHidden();
- }
-});
-
-function onChatWindowShown()
-{
- chatTimerDelay = chatTimerDelayDefault;
- getChatTimer();
-}
-
-function onChatWindowHidden()
-{
- chatTimerDelay = chatTimerDelayWindowHidden;
-}
-
-<?
-$chatMute = (isset($_COOKIE['pref_chatMute']) && $_COOKIE['pref_chatMute'] == "true");
-$chatMute = ($chatMute) ? 'true' : 'false';
-?>
-var chatIsMuted = '<? echo $chatMute; ?>';
-function setChatMute() {
- var value = chatIsMuted;
-
- $('#chatMute').removeClass("chatMute_"+value);
- if (value == 'true') {
- value = 'false';
- soundManager.setVolume('pit', 20);
- soundManager.setPan('pit', -60)
- soundManager.play('pit');
- } else {
- value = 'true';
- }
- chatIsMuted = value;
- $('#chatMute').addClass("chatMute_"+value);
- savePref('chatMute', value);
-}
-
-pollChannelList();
-
-</script>
-
<div class='wrapper'>
<h3>Pathery Chat - BETA</h3>
diff --git a/pages/creategame.php b/pages/creategame.php new file mode 100644 index 0000000..ee8af67 --- /dev/null +++ b/pages/creategame.php @@ -0,0 +1,50 @@ +<?php
+//If thar be a game to be creatin
+if (isset($_POST['playerCount'])) {
+
+ //Confirm yarn data and fill them be databases. Hah har!
+
+
+
+ $gameID = 22;
+
+ //Return tiz be the gameID and change yarn header location! to games?id=ID
+ header("Location: $mydomain"."games?ID=" . $gameID);
+}
+
+htmlHeader(array(), 'Create Game', 'Create a game');
+topbar($headerLinks);
+?>
+
+
+<div class="wrapper" style="width:600px;">
+<h2>Create Game</h2>
+
+<p>
+
+Doesn't matter what you do - you'll go to games?ID=22 ! (Testing still; sorry)
+</p>
+
+<form action="createGame" method="post" name="gameOptions">
+
+<select id='playerCount' name='playerCount'>
+ <option value='2' selected='selected'>2</option>
+ <option value='3'>3</option>
+ <option value='4'>4</option>
+ <option value='5'>5</option>
+
+</select>
+<br /><br />
+
+<input type="checkbox" name="smartTime" value="yes" /> Use Smart-Time? *
+<br /><br />
+<input type="submit" value="Create Game" />
+
+</form>
+
+</div>
+
+
+<?php
+htmlFooter();
+?>
\ No newline at end of file diff --git a/pages/feedback.php b/pages/feedback.php index 3831d24..882bc03 100644 --- a/pages/feedback.php +++ b/pages/feedback.php @@ -1,23 +1,24 @@ <?php
-if (isset($_POST['regarding']) AND isset($_SESSION['accepted'])) {
- if (!$accepted)
- return;
- $data = $_POST;
- $data['session'] = print_r($_SESSION, true);
+if (isset($_POST['regarding'])) {
- $userID = $_SESSION['userID'] * 1;
- if (!is_int($userID))
- return;
- include_once "includes/sqlEmbedded.php";
- $sql = "SELECT `email` FROM `users`
- WHERE `ID` = '$userID'";
- $result = mysql_query($sql);
+ $data = $_POST;
- $email = mysql_result($result, 0, 'email');
+ if ($accepted) {
+ $data['session'] = print_r($_SESSION, true);
- $data['email'] = $email;
+ $userID = $_SESSION['userID'] * 1;
+ if (!is_int($userID))
+ return;
+
+ include_once "includes/sqlEmbedded.php";
+ $sql = "SELECT `email` FROM `users`
+ WHERE `ID` = '$userID'";
+ $result = mysql_query($sql);
+ $email = mysql_result($result, 0, 'email');
+ $data['email'] = $email;
+ }
EmailError($data, "Pathery Feedback");
DoRedirect("<b>Thank you for your feedback!</b> <br />
@@ -36,7 +37,7 @@ htmlHeader(array(), 'Feedback & Contact', 'Send feedback or contact us.'); <?php
topbar($headerLinks);
-if (!$accepted) {
+/* if (!$accepted) {
echo "
<div class='wrapper'>
Sorry, you must be logged in to use this.
@@ -44,7 +45,7 @@ if (!$accepted) { </div>";
htmlFooter();
exit;
-}
+} */
?>
@@ -56,6 +57,8 @@ if (!$accepted) { <p>Thanks so much for taking the time to say hello!
+<br />You can email me @ snap@pathery.com if you'd rather.
+
</p>
<form action="feedback" method="post" name="feedback">
@@ -70,8 +73,18 @@ if (!$accepted) { </select>
<br /><br />
+<?
+if (!$accepted) {
+ echo '
+ Email address*: <input type="email" size="25" maxlength="60" value="" name="entered_email" class="forminput" /><br />
+ ';
+}
+?>
+
+
Title: <input type="text" size="25" maxlength="60" value="" name="title" class="forminput" /><br />
+
<textarea name='body' rows="10" cols="30"></textarea><br />
<input type="checkbox" name="emailback" value="yes" /> Please email me back
diff --git a/pages/games.php b/pages/games.php new file mode 100644 index 0000000..b68a530 --- /dev/null +++ b/pages/games.php @@ -0,0 +1,151 @@ +<?php
+htmlHeader(
+ array('stats'), 'Game Lobby',
+ 'Match',
+ array('scores', 'dateformat')
+);
+
+htmlHeader(array(), 'Game Lobby', 'Game Lobby');
+echo soundManager2();
+topbar($headerLinks);
+
+
+if (is_int($_GET['ID'])) {
+ $matchID = $_GET['ID'];
+}
+
+
+?>
+
+
+<script>
+
+mapID = 222;
+pointerPage = 1;
+
+displayMap(mapID, "mapDisplay", 600);
+scoresShowPage(pointerPage, mapID);
+
+
+var matchUpdateTimerDelay = 6000;
+
+
+var playerIsReady = false;
+var matchMapReceived = false;
+var matchCountdownStarted = false;
+var matchStarted = false;
+
+matchUpdateTimer();
+function matchUpdateTimer() {
+ setTimeout("matchUpdateTimer()", matchUpdateTimerDelay);
+
+}
+
+function pollMatchStatus() {
+ var dataString = 'requestUpdate=1';
+ dataString += '&matchID=<? echo $matchID; ?>';
+ dataString += '&playerIsReady='+playerIsReady;
+
+ $.ajax({
+ //type: "POST",
+ url: "ajax/match.ajax.php?" + dataString,
+ error: function() {
+ console.log('Error: Failed pollMatchStatus');
+ },
+ success: function(data) {
+ console.log("Data recieved", data);
+ pollMatchStatusDone(data);
+ }
+ });
+}
+
+function pollMatchStatusDone(data) {
+
+ console.log('data recieved:', data);
+ if (data.length < 3 || data == 'false') return;
+ json = jQuery.parseJSON(data);
+
+ if (json.gameStarted == true) {
+ // Show the game if it's ready
+ if (json.mapReady == true && matchMapReceived == false) {
+ console.log("match countdown start!");
+ displayMap(json.mapID, "mapDisplay", 600);
+ matchMapReceived = true;
+
+ displayCountDownToGame(json.secondsTillGameExpires);
+
+ }
+
+ //This will be a negative number if the game is going.
+ if (json.secondsTillGameStarts > 0 && matchCountdownStarted == false) {
+ displayCountDownToGame(json.secondsTillGameStarts);
+
+ //Make sure we're making a call when the map is ready.
+ setTimeout("pollMatchStatus()", ((json.secondsTillGameStarts) * 1000) - 10);
+ matchCountdownStarted = true;
+ }
+
+ // json.secondsTillGameStarts
+ // var gameStartsDate = new Date();
+ //gameStartsDate.setTime(gameStartsDate.getTime() + json.secondsTillGameStarts * 1000);
+ }
+
+}
+
+function isInt(n) {
+ return n % 1 === 0;
+}
+
+
+function displayCountDownToGame(seconds) {
+ decSeconds = Math.round(seconds * 10);
+ var x = 0;
+ for (var i = decSeconds; i > 0; i--) {
+ x++;
+ setTimeout("setDisplay(" + i / 10 + ")", x * 100);
+ }
+}
+function setDisplay(newContent) {
+ $("#countDown").html(newContent);
+}
+
+function setReady() {
+ playerIsReady = true;
+ pollMatchStatus();
+}
+
+</script>
+
+
+<div class="wrapper">
+
+<br />
+<br /><h2>Game Lobby</h2>
+<br /><h2 id='countDown'>X</h2>
+<br />
+ <div>
+ <div class='scoreCol' id='scoreDisplay'></div>
+ <div class="mapCol" id='mapDisplay' style='display:none; float:left;'></div>
+ </div>
+
+ <div style='clear:both'></div>
+</div>
+
+
+<div class="wrapper">
+ <form id='markReady' onsubmit="return false">
+ <input type="hidden" name="stuff" value="1724">
+
+ <?
+ echo "
+ <a title='TmpBtn?' class='readyButton_unready unselectable' href='javascript:setReady()' id='readyButton'/>BTN!</a>";
+ ?>
+ </form>
+</div>
+
+
+
+
+<?php
+htmlFooter();
+?>
\ No newline at end of file diff --git a/pages/home.php b/pages/home.php index 56c846d..d82ba21 100644 --- a/pages/home.php +++ b/pages/home.php @@ -118,7 +118,6 @@ $adContent = " <br />
-
<?
if ($accepted) {
if (!hasCompletedTutorial($userID)) {
diff --git a/pages/login.php b/pages/login.php index d277cb7..b0caf07 100644 --- a/pages/login.php +++ b/pages/login.php @@ -19,35 +19,36 @@ include_once('./includes/HybridAuth/Auth.php'); $hybrid_config_file = 'includes/HybridAuth/HybridAuthConfig.php';
+//TODO: SQL needs to be updated to sqli instead.
+
try {
- //OpenID Method
- if (!$_GET['op'] || $_GET['op'] == 'google' || $_GET['op'] == 'steam' || $_GET['op'] == 'yahoo') {
- $openid = new LightOpenID;
+
+ //OpenID 2.0 Method
+ if (!$_GET['op'] || $_GET['op'] == 'steam' || $_GET['op'] == 'yahoo') {
+ $openid = new LightOpenID;
//Require Email, and first name.
$openid->required = array('namePerson/first', 'contact/email');
//Are we not logged in?
if (!$openid->mode) {
- if (!$_GET['op'] || $_GET['op'] == 'google')
- $openid->identity = 'https://www.google.com/accounts/o8/id';
- else if ($_GET['op'] == 'yahoo')
+ if ($_GET['op'] == 'yahoo')
$openid->identity = 'https://me.yahoo.com';
else if ($_GET['op'] == 'steam')
$openid->identity = 'http://steamcommunity.com/openid';
header('Location: ' . $openid->authUrl());
- } //Did we try to log in, but then the user canceled it?
+ } //Did we try to log in, but then the user cancelled it?
else if ($openid->mode == 'cancel') {
// header('Location: ' . $mydomain);
- //echo 'User has canceled authentication!';
+ //echo 'User has cancelled authentication!';
} //We logged in and it worked!
else if ($openid->validate()) {
- //What's in the goodie bag labeled "personal information"... hmmm
+ //What's in the goody bag labelled "personal information"... hmmm
$openIdAttributes = $openid->getAttributes();
$display = $openIdAttributes['namePerson/first'];
- //You don't have a name entered? whyfore!?
+ //You don't have a name entered?
if (strlen($display) == 0) {
$display = 'noname';
}
@@ -67,16 +68,58 @@ try { } else {
DoRedirect("Login failed. Back to the home page with you!");
}
- }
+
+ //Google's OpenID Connect method
+ } else if ($_GET['op'] == 'google') {
+
+ include_once('./includes/google-api-php-client-master/src/Google/autoload.php');
+
+ $redirect_uri = $mydomain . "login?op=google";
+
+ $client = new Google_Client();
+ $client->setClientId($google_client_id);
+ $client->setClientSecret($google_client_secret);
+ $client->setRedirectUri($redirect_uri);
+ $client->setScopes('email');
+
+ if (isset($_GET['code'])) {
+ //echo 'code recpt';
+ $client->authenticate($_GET['code']);
+ $_SESSION['access_token'] = $client->getAccessToken();
+ $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
+ //header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
+ //echo 'Location: ' . filter_var($redirect, FILTER_SANITIZE_URL);
+ }
+
+ if ($client->getAccessToken()) {
+ //echo 'token success';
+ $_SESSION['access_token'] = $client->getAccessToken();
+ $token_data = $client->verifyIdToken()->getAttributes();
+
+ //var_dump($token_data);
+
+ $email = $token_data['payload']['email'];
+ $emailIsVerified = $token_data['payload']['email_verified'];
+ $oldID = $token_data['payload']['openid_id'];
+ //Prefix our ID with "google" because we use multiple providers
+ $tokenID = "google|" . $token_data['payload']['sub'];
+
+ if ($emailIsVerified !== true) {
+ die(throwLoginError($token_data, "Your provider (Google) has not yet verified the email you used. ($email)."));
+ }
+
+ //createNewUser($claimedid, "noname", $email);
+ createNewUser($tokenID, "noname", $email, $claimedid);
+ }
+
+ //Use HybridAuth for everything else
- //Use HybridAuth for everything else
- else if ($_GET['op'] == 'twitter' || $_GET['op'] == 'facebook' || $_GET['op'] == 'live') {
+ } else if ($_GET['op'] == 'twitter' || $_GET['op'] == 'facebook' || $_GET['op'] == 'live') {
$provider = $_GET['op'];
$hybridAuth = new Hybrid_Auth($hybrid_config_file);
$authenticator = $hybridAuth->authenticate($provider);
- if(!$authenticator)
- {
+ if(!$authenticator) {
//If user cancelled request, return to home page (?)
return;
}
@@ -88,8 +131,7 @@ try { $email = $userProfile->email;
//TODO: This will always fail for Twitter - we need to reconsider our needs...
- if($email == '')
- {
+ if($email == '') {
//$userProfile['op'] = $_GET['op']; //TODO This isn't valid, whoops - but, plan on deleting anyways...
die(throwLoginError($userProfile, "No email provided by {$authenticator->id} - please try a different provider"));
}
@@ -107,21 +149,27 @@ try { // // Authenticate with Yahoo! then grab the user profile
// $adapter = $ha->authenticate( "OpenID", array( "openid_identifier" => "https://me.yahoo.com/"));
// $user_profile = $adapter->getUserProfile();
- }
-
- //Unknown provider
- else {
+
+ //Unknown provider
+ } else {
DoRedirect("Unknown login provider. Back to the home page with you!");
}
+
} catch (ErrorException $e) {
echo $e->getMessage();
}
-function createNewUser($claimedid, $display, $email)
+
+
+function createNewUser($claimedid, $display, $email, $oldID = NULL)
{
//I know just where to put this stuff!
//Unless I already have this information...
- $sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName`, `dateJoined` FROM `users` WHERE `openID` = '$claimedid' OR `email` = '$email'";
+ $sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName`, `dateJoined` FROM `users`
+ WHERE `openID` = '$claimedid' OR `email` = '$email'";
+ if (isset($oldID)) {
+ $sql = $sql." OR `openID` = '" . $oldID . "'";
+ }
$result = mysql_query($sql);
$_SESSION['isAdmin'] = false;
@@ -146,9 +194,10 @@ function createNewUser($claimedid, $display, $email) $d['claimedid'] = $claimedid;
$d['email'] = $email;
$d['display'] = $display;
+ $d['oldID'] = $oldID;
EmailError($d);
}
- // Continue Loging in; should be fine.
+ // Continue Logging in; should be fine.
//TEMPORARY CODE
//Check openID; and update it if necessary
if (mysql_result($result, 0, 'openID') == $claimedid) {
@@ -182,7 +231,7 @@ function createNewUser($claimedid, $display, $email) if ($result) {
$userID = mysql_insert_id();
$dateJoined = date(DateTime::ISO8601);
-
+
//Tutorial done?
if (isset($_SESSION['preCompletedTutorial'])) {
if ($_SESSION['preCompletedTutorial'] == true) {
@@ -225,7 +274,7 @@ function createNewUser($claimedid, $display, $email) $refTo = $_GET['ref'];
//DoRedirect("Thank you $display.", $_GET['ref']);
DoRedirect("", $refTo, 0);
- exit;
+ return true;
}
function sendNewUserEmail($userID, $email, $display, $dateJoined) {
@@ -251,10 +300,12 @@ function throwLoginError($data, $explanation) { $errortext = "<br />Error; $explanation \n
<br />The error details have been emailed to the administrator.
<br />If this problem continues; please email me:
+ <!--email_off-->
<a target='top' href='mailto:snap@pathery.com?Subject=Pathery%20Login%20Error%20$randCode'>
snap@pathery.com
</a>
- <br />Your error code is: $randCode
+ <!--/email_off-->
+ <br />Please use this code for reference when emailing me: $randCode
<br />";
$errortext .= mysql_error();
DoRedirect($errortext, NULL, 500);
@@ -264,4 +315,4 @@ function throwLoginError($data, $explanation) { EmailError($data);
}
-?>
+?>
\ No newline at end of file diff --git a/pages/mapeditor.php b/pages/mapeditor.php index 9e1e57c..f67cad1 100644 --- a/pages/mapeditor.php +++ b/pages/mapeditor.php @@ -1,10 +1,17 @@ <?php include_once('./includes/maps.php'); include_once('./includes/mapclass.php'); +include_once('./includes/mapoftheday.php'); + +echo "too broken; will fix soon"; + +exit; //Self-ajax. if ($_REQUEST['mapByCode']) { $map = new map($_REQUEST['mapByCode']); + $map->oldCode = $map->getOldCode(); + $map->code = $map->getCode(); echo json_encode($map); exit; } @@ -17,24 +24,40 @@ if ($_REQUEST['mapByMap']) { $map->$key = $value; } //Store the code in the object - $code = $map->getOldCode(); - $map->code = $code; + $map->oldCode = $map->getOldCode(); + $map->code = $map->getCode(); echo json_encode($map); exit; } if ($_REQUEST['genMap']) { -//function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1, $mapName = '') { - $map = GenerateMap($_REQUEST['width'], $_REQUEST['height'], $_REQUEST['rockChance'], $_REQUEST['wallCount'], $_REQUEST['checkpoints'] % 6, $_REQUEST['teleports'] % 6); - //$map = GenerateMap($_REQUEST['height'], $_REQUEST['width'], $_REQUEST['rockChance'], 0, 0, 0); - //$map = insertPoint($map, $_REQUEST['points'], 'o'); +/* + $map = GenerateMap( + normalizeNumber($_REQUEST['width'], 50, 6), + normalizeNumber($_REQUEST['height'], 50, 6), + normalizeNumber($_REQUEST['rockChance'], 999, 5), + normalizeNumber($_REQUEST['wallCount'], 9999, 0), + normalizeNumber($_REQUEST['checkpoints'], 5, 0), + normalizeNumber($_REQUEST['teleports'], 5, 0) + ); + */ + $map = getRandomSpecialMap(); + $code = GenerateMapCode($map); + $map = new map($code); + $map->oldCode = $map->getOldCode(); + $map->code = $map->getCode(); echo json_encode($map); exit; } - +function normalizeNumber($numberToFix, $upperBound, $lowerBound) { + if (!is_int($numberToFix + 0)) return $lowerBound; + if ($numberToFix < $lowerBound) return $lowerBound; + if ($numberToFix > $upperBound) return $upperBound; + return $numberToFix; +} //Add's a new custom challenge map - returns mapid @@ -180,8 +203,8 @@ function updateName() { } function changeDimensions(width, height) { - width = Math.Min(width, 50); - height = Math.Min(height, 50); + width = Math.min(width, 50); + height = Math.min(height, 50); testMap.tiles = constructTiles(width, height, testMap); //testMap.tiles[0][3] = Array('s'); @@ -221,6 +244,7 @@ function loadPlayableMap() { playableMap.ID = -1; $('#playableMapDisplay').html(mapAsHTML(playableMap, 960)); $('#playableMapCodeDisplay').val(playableMap.code); + $('#playableMapCodeDisplayOLD').val(playableMap.oldCode); isLoadingMap = false; } }); @@ -322,7 +346,7 @@ function constructTiles(width, height, baseMap) { </form> </div> - <form><div> + <form onsubmit='return false'><div> <div class='' id='' style='float:left; width:340px;height:450px;'> <fieldset style='width:300px'> @@ -391,7 +415,8 @@ function constructTiles(width, height, baseMap) { <div class="divide"><strong>Playable Map</strong></div> <div style='clear:both;'></div> <div class='wrapper'> - MapCode: <input id='playableMapCodeDisplay' size="100" type="text" value="" class="forminput"/> + OLD MapCode: <input id='playableMapCodeDisplayOLD' size="100" type="text" value="" class="forminput"/> + <br/>NEW MapCode: <input id='playableMapCodeDisplay' size="100" type="text" value="" class="forminput"/> </div> <div id='playableMapDisplay' style='float:left;'> Returned map goes here. diff --git a/pages/matches.php b/pages/matches.php new file mode 100644 index 0000000..7fd8559 --- /dev/null +++ b/pages/matches.php @@ -0,0 +1,140 @@ +<?PHP
+htmlHeader(
+ array('stats'), 'Matches',
+ 'View available games',
+ array('scores', 'dateformat')
+);
+?>
+
+<?php
+topbar($headerLinks);
+?>
+
+<script>
+ // javascript:membersShowPage(1);
+
+//
+
+
+updateGameList();
+
+function updateGameList() {
+ var dataString = 'getGameList=1';
+
+ $.ajax({
+ //type: "POST",
+ url: "ajax/match.ajax.php?" + dataString,
+ error: function() {
+ console.log('Error: Failed updateGameList');
+ },
+ success: function(data) {
+ console.log("Data recieved", data);
+ updateGameListDone(data);
+ }
+ });
+}
+
+function updateGameListDone(data) {
+
+ console.log('data recieved:', data);
+ if (data.length < 3 || data == 'false') return;
+ json = jQuery.parseJSON(data);
+
+ $('#games').html(gamesFormat(json));
+
+}
+
+
+
+function gamesFormat(JO) {
+
+ var p = "<table class='score'>";
+/*
+ var localTime = new Date();
+ var updatedLocalTime = new Date();
+ updatedLocalTime.setTime(JO.updateTime * 1000);
+
+ p = p+"<tr title='Last-Update: "+updatedLocalTime.format("mmm d, h:MM TT")+"'>";
+ p = p+"<th>Rank</th>";
+ p = p+"<th style='width:125px; overflow:hidden; text-align:left; padding-left:42px;'>Name</th>";
+ p = p+"<th>Moves</th>";
+ p = p+"</tr>";
+ */
+
+ p = p+"<tr>";
+ p = p+"<th style='width:125px; overflow:hidden; text-align:left; padding-left:42px;'>Created By</th>";
+ p = p+"<th>Made</th>";
+ p = p+"<th>link to join</th>";
+ p = p+"<th>Players</th>";
+
+ p = p+"</tr>";
+
+
+ var showedLastUser = true;
+ var x = 0;
+
+ var previousI = 0;
+ for (var i in JO.matches) {
+ var u = JO.matches[i];
+
+ var createdLocalTime = new Date();
+ createdLocalTime.setTime(createdLocalTime.getTime() - u.secondsSinceCreated * 1000);
+ createdLocalTime = createdLocalTime.format("h:MM:ss TT");
+
+ var styleClass = '';
+
+ if (previousI != i + 1 && previousI < i - 1 && previousI != 0) {
+ styleClass = 'border-top: 6px solid #777799;';
+ }
+ //var wasLongAgo = localTime.getTime() > (scoredLocalTime.getTime() + 43200000); //12*60*60*1000
+ //var scoredTimeFormat = (wasLongAgo ? "mmm d, h:MM:ss TT" : "h:MM:ss TT");
+ //var scoredTimeStr = scoredLocalTime.format(scoredTimeFormat);
+
+ var rowclass = 'scoreRow'+((i % 2)+1);
+ //Wall Avatar
+ p = p+ "<td style='vertical-align: middle;'>";
+ p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url("+linkEmblem(u.wallEmblem, u.wallOrientation)+");'>";
+ p = p+ " <div style='background-color:transparent;' class='grid_td_inner grid_td_rocks'>";
+ p = p+ " </div>";
+ p = p+ " </div>";
+ p = p+ "";
+ p = p+ "<span class='scoreName'><a href='achievements?id="+u.creatorUserID+"' style='color:"+u.displayColor+"'>"+u.displayName+"</a></span>";
+ p = p+ "</td>";
+
+ p = p+ "<td class='scoreMedal' style='color:"+u.displayColor+"'>";
+ p = p+ createdLocalTime+ "</td>";
+
+ p = p+ "<td><a href='#NotYetSry!" + u.ID + "'>Join Game</a></td>";
+ p = p+ "<td>" + u.currentPlayers + "/" + u.requiredPlayers + "</td>";
+
+
+ p = p+ "</tr>";
+
+ previousI = i;
+ }
+
+ p = p+"</table>";
+
+ p = "<div class='scoreContainer1'>"+p+"</div>";
+ return p;
+}
+
+
+
+
+</script>
+
+<div class='wrapper'>
+ <h2>Available Matches</h2>
+
+ <div id='games'>
+
+ </div>
+</div>
+<br />
+<br />
+<?
+
+htmlfooter();
+
+?>
|