Skip to content

Instantly share code, notes, and snippets.

@farfromunique
Created August 27, 2013 01:56
Show Gist options
  • Save farfromunique/6348840 to your computer and use it in GitHub Desktop.
Save farfromunique/6348840 to your computer and use it in GitHub Desktop.
This Gist is related to the issue described in http://www.reddit.com/r/PHPhelp/comments/1l3ete/my_object_isnt_an_object_help/ Files with _ in the name should be in directories, but Gists don't support directories.
<?php
class Character {
/** @var int the UID of this character. Corresponds to User->Character */
public $UID;
/** @var string The Character's name */
protected $aName;
/** @var int Character's Age in years */
protected $Age;
/** @var string Character's Gender: M, F, or Other */
protected $Gender;
/** @var int Character's rank (game term) */
protected $Rank;
/** @var int Character's height in CM */
protected $Height;
/** @var string Descriptor of height in relative terms (Very Short, short, average, tall, very tall) */
protected $Height_Category;
/** @var string description of the character's skin */
protected $Skin;
/** @var string description of the character's eyes */
protected $Eyes;
/** @var string description of the character's hair */
protected $Hair;
/** @var string description of any distinguishing marks the character may have (may be blank) */
protected $Distinguishing_Marks;
/** @var int character's current XP */
protected $XP;
/** @var string array of character's powers */
protected $Powers;
/** @var string array of pronouns to use based on character's gender */
protected $Pronouns;
/** @param mixed $connection A PDO connection that has SELECT access to Character_Details table
* @param string $name The name the user wishes to check availability of
* @return bool true = name is free or error; false = name is taken */
public function nameAvailable($connection,$name) {
/** @noinspection PhpUndefinedMethodInspection */
$check = $connection->prepare("SELECT COUNT(*) FROM Character_Details WHERE Name = :name");
/** @noinspection PhpUndefinedMethodInspection */
$check->bindParam(':name',$name);
/** @noinspection PhpUndefinedMethodInspection */
/** @noinspection PhpUndefinedMethodInspection */
if ( ! $check->execute() || $check->fetchColumn() == 0 ) {
return true; // returning true if 0 results are returned, or there is an error
}
return false; // returning false if more than 0 results
}
/** Sets the list of pronouns to use for the character */
public function setPronouns() {
switch ($this->Gender) {
case "M":
$this->Pronouns=array("Male","guy","dude","He","His");
break;
case "F":
$this->Pronouns=array("Female","gal","chick","She","Her");
break;
case "Other":
$this->Pronouns=array("Individual","person","person",$this->aName,"Their");
break;
}
}
/** @param mixed $connection A PDO object with UPDATE access to the Character_Details table
* Sets the height category for the character, based on average heights by age and gender. */
public function setHeightCategory($connection) {
$heightCat = array();
$heightCat[0] = 'very short';
$heightCat[1] = 'short';
$heightCat[2] = 'average';
$heightCat[3] = 'tall';
$heightCat[4] = 'very tall';
$heightCutoff = array();
$heightCutoff['M'][0][0] = 146;
$heightCutoff['M'][0][1] = 153;
$heightCutoff['M'][0][2] = 158;
$heightCutoff['M'][0][3] = 163;
$heightCutoff['M'][0][4] = 171;
$heightCutoff['M'][1][0] = 150;
$heightCutoff['M'][1][1] = 158;
$heightCutoff['M'][1][2] = 163;
$heightCutoff['M'][1][3] = 169;
$heightCutoff['M'][1][4] = 176;
$heightCutoff['M'][2][0] = 155;
$heightCutoff['M'][2][1] = 163;
$heightCutoff['M'][2][2] = 168;
$heightCutoff['M'][2][3] = 173;
$heightCutoff['M'][2][4] = 180;
$heightCutoff['M'][3][0] = 159;
$heightCutoff['M'][3][1] = 167;
$heightCutoff['M'][3][2] = 171;
$heightCutoff['M'][3][3] = 177;
$heightCutoff['M'][3][4] = 183;
$heightCutoff['M'][4][0] = 162;
$heightCutoff['M'][4][1] = 168;
$heightCutoff['M'][4][2] = 173;
$heightCutoff['M'][4][3] = 178;
$heightCutoff['M'][4][4] = 185;
$heightCutoff['M'][5][0] = 163;
$heightCutoff['M'][5][1] = 169;
$heightCutoff['M'][5][2] = 173;
$heightCutoff['M'][5][3] = 179;
$heightCutoff['M'][5][4] = 185;
$heightCutoff['F'][0][0] = 145;
$heightCutoff['F'][0][1] = 151;
$heightCutoff['F'][0][2] = 156;
$heightCutoff['F'][0][3] = 162;
$heightCutoff['F'][0][4] = 167;
$heightCutoff['F'][1][0] = 148;
$heightCutoff['F'][1][1] = 154;
$heightCutoff['F'][1][2] = 159;
$heightCutoff['F'][1][3] = 164;
$heightCutoff['F'][1][4] = 170;
$heightCutoff['F'][2][0] = 150;
$heightCutoff['F'][2][1] = 156;
$heightCutoff['F'][2][2] = 161;
$heightCutoff['F'][2][3] = 166;
$heightCutoff['F'][2][4] = 171;
$heightCutoff['F'][3][0] = 151;
$heightCutoff['F'][3][1] = 157;
$heightCutoff['F'][3][2] = 162;
$heightCutoff['F'][3][3] = 166;
$heightCutoff['F'][3][4] = 172;
$heightCutoff['F'][4][0] = 152;
$heightCutoff['F'][4][1] = 157;
$heightCutoff['F'][4][2] = 162;
$heightCutoff['F'][4][3] = 166;
$heightCutoff['F'][4][4] = 172;
$heightCutoff['F'][5][0] = 152;
$heightCutoff['F'][5][1] = 158;
$heightCutoff['F'][5][2] = 162;
$heightCutoff['F'][5][3] = 166;
$heightCutoff['F'][5][4] = 172;
$heightCutoff['Other'][0][0] = 145;
$heightCutoff['Other'][0][1] = 152;
$heightCutoff['Other'][0][2] = 157;
$heightCutoff['Other'][0][3] = 163;
$heightCutoff['Other'][0][4] = 169;
$heightCutoff['Other'][1][0] = 149;
$heightCutoff['Other'][1][1] = 156;
$heightCutoff['Other'][1][2] = 161;
$heightCutoff['Other'][1][3] = 166;
$heightCutoff['Other'][1][4] = 173;
$heightCutoff['Other'][2][0] = 153;
$heightCutoff['Other'][2][1] = 159;
$heightCutoff['Other'][2][2] = 164;
$heightCutoff['Other'][2][3] = 169;
$heightCutoff['Other'][2][4] = 176;
$heightCutoff['Other'][3][0] = 155;
$heightCutoff['Other'][3][1] = 162;
$heightCutoff['Other'][3][2] = 166;
$heightCutoff['Other'][3][3] = 171;
$heightCutoff['Other'][3][4] = 177;
$heightCutoff['Other'][4][0] = 157;
$heightCutoff['Other'][4][1] = 163;
$heightCutoff['Other'][4][2] = 167;
$heightCutoff['Other'][4][3] = 172;
$heightCutoff['Other'][4][4] = 178;
$heightCutoff['Other'][5][0] = 157;
$heightCutoff['Other'][5][1] = 163;
$heightCutoff['Other'][5][2] = 167;
$heightCutoff['Other'][5][3] = 172;
$heightCutoff['Other'][5][4] = 178;
$age = $this->Age - 13;
$height = $this->Height;
for ($i=0;$i<4;$i++) {
if ($height <= $heightCutoff[$this->Gender][$age][$i]) {
$this->Height_Category = $heightCat[$i];
/** @noinspection PhpUndefinedMethodInspection */
$setHC = $connection->prepare("UPDATE Character_Details SET Height_Category = :hc WHERE UID = :uid");
/** @noinspection PhpUndefinedMethodInspection */
$setHC->bindParam(":hc",$this->Height_Category);
/** @noinspection PhpUndefinedMethodInspection */
$setHC->bindParam(":uid",$this->UID);
/** @noinspection PhpUndefinedMethodInspection */
$setHC->execute();
return;
}
}
$this->Height_Category = $heightCat[4];
/** @noinspection PhpUndefinedMethodInspection */
$setHC = $connection->prepare("UPDATE Character_Details SET Height_Category = :hc WHERE UID = :uid");
/** @noinspection PhpUndefinedMethodInspection */
$setHC->bindParam(":hc",$this->Height_Category);
/** @noinspection PhpUndefinedMethodInspection */
$setHC->bindParam(":uid",$this->UID);
/** @noinspection PhpUndefinedMethodInspection */
$setHC->execute();
return;
}
/** @param mixed $connection A PDO object with UPDATE access to the Character_Details table
* @param int $UID The UID of the character data to load. */
public function load($connection, $UID) {
$this->UID = $UID;
/** @noinspection PhpUndefinedMethodInspection */
$details = $connection->prepare("SELECT * FROM Character_Details WHERE UID = :uid");
/** @noinspection PhpUndefinedMethodInspection */
$details->bindParam(':uid', $UID);
/** @noinspection PhpUndefinedMethodInspection */
$details->execute();
/** @noinspection PhpUndefinedMethodInspection */
$myDetails = $details->fetch();
$this->aName = $myDetails['Name'];
$this->Age = $myDetails['Age'];
$this->Gender = $myDetails['Gender'];
$this->Rank = $myDetails['Rank'];
$this->Height = $myDetails['Height'];
$this->Skin = $myDetails['Skin'];
$this->Eyes = $myDetails['Eyes'];
$this->Hair = $myDetails['Hair'];
$this->Distinguishing_Marks = $myDetails['Distinguishing_Marks'];
$this->XP = $myDetails['XP'];
$this->setPronouns();
if ($this->Height_Category == "") {
$this->setHeightCategory($connection);
}
}
/** @return string An HTML chunk describing the relevant character. */
public function DescribeMe() {
$output = "<h2>Character Description for: {$this->aName}</h2>
<h3>{$this->Age} year-old {$this->Pronouns[0]} of Rank {$this->Rank}</h3>
<p>{$this->aName} is a {$this->Height_Category} {$this->Pronouns[1]},
with {$this->Hair} hair and eyes of {$this->Eyes}.
{$this->Pronouns[4]} skin is {$this->Skin}";
if($this->Distinguishing_Marks) {
$output .= " and " . lcfirst($this->Pronouns[3]) . " has " . lcfirst($this->Distinguishing_Marks) . ".";
} else {
$output .= ".";
}
return $output;
}
}
<?php
require_once('Parser.class.php');
class Conversation {
protected $lastMessage; // UID of last message displayed
protected $location; // UID of location
protected $allChat = array(); // Contents of query for last up to 10 messages, ending at $lastMessage
public function __toString() {
global $you;
$tz = 'UTC';
if (isset($you->timezone)) {
$tz = $you->timezone;
}
return $this->output($tz);
}
public function output($timezone) {
$parser = new Parser;
$gm_stuff = "";
if ($_SESSION["IsGM"]) {
$gm_stuff = "<input type='submit' class='GM_Button' value='Delete' onClick='removeRecord(::UID::)'>";
}
$discussion = '';
for ($i=0;$i<count($this->allChat);$i++) {
$uid = $this->allChat[$i]["UID"];
$beginning = "<div class='comment' id=" . $uid . ">";
$attribution = "<span class='attribution'><a href='show.php?id=" . $this->allChat[$i]["CharUID"] . "'>" . $this->allChat[$i]["Name"] . "</a> wrote, at ";
$tds = ':-:UTC:-:' . $this->allChat[$i]["TDS"] . ':-:';
$tds = $parser->fixUTC($tds,$you->TimeZoneOffset,'g:i A') . ':</span><br /> ';
$ending = "</div>";
$discussion = $discussion . $gm_stuff . $beginning . $attribution . $tds . $this->allChat[$i]["Comment"] . $ending;
}
return $discussion;
}
public function Send($chatVar,$character,$message) {
/** @noinspection PhpUndefinedMethodInspection */
$chatVar->bindParam(":charUID",$character);
/** @noinspection PhpUndefinedMethodInspection */
$chatVar->bindParam(":message",$message);
/** @noinspection PhpUndefinedMethodInspection */
$chatVar->execute();
}
public function getAllNewChats($converseVar) {
/** @noinspection PhpUndefinedMethodInspection */
if ($converseVar->execute()) {
/** @noinspection PhpUndefinedMethodInspection */
$this->allChat = $converseVar->fetchAll(PDO::FETCH_ASSOC);
$this->lastMessage = $this->allChat[0]["UID"];
}
}
public function getChatLog($connection) {
$defaultMessage = 'Nobody seems to have said anything for a while...';
/** @noinspection PhpUndefinedMethodInspection */
$messageCount = $connection->prepare("SELECT MAX(UID) FROM Conversations WHERE Location = :loc");
/** @noinspection PhpUndefinedMethodInspection */
$messageCount->bindParam(":loc",$this->location);
/** @noinspection PhpUndefinedMethodInspection */
$messageCount->execute();
/** @noinspection PhpUndefinedMethodInspection */
$newest = $messageCount->fetch(PDO::FETCH_ASSOC);
if ($newest === false) {
$this->allChat = $defaultMessage;
return $this->allChat;
}
if ($newest == $this->location) {
$this->allChat = 'No change';
return $this->allChat;
}
$this->allChat = $newest['MAX(UID)'];
return $this->allChat;
}
public function __construct($connection,$converseVar,$locationUID) {
$this->location = $locationUID;
$this->lastMessage = 0;
$displayChat = $this->GetChatLog($connection);
switch ($displayChat) {
case 'Nobody seems to have said anything for a while...':
return $displayChat;
break;
default:
$this->getAllNewChats($converseVar);
global $you;
$tz = 'UTC';
if (isset($you->timezone)) {
$tz = $you->timezone;
}
return $this->output($tz);
break;
}
}
}
<?php
/** Provides parsing tools for Sweet Dreams Online */
class Parser {
/** @param string $str String containing a time in UTC surrounded by ":-:UTC:-:" on one side and ":-:" on the other.
* @param mixed $TimeZoneOffset The difference from a given timezone.
* @param string $timeFormat The PHP-style time format desired by the user.
* @return string The string returned either has the time adjusted by the offset given, or (on error) the original text.
*/
public function fixUTC($str,$TimeZoneOffset,$timeFormat) {
$bits = explode(":-:",$str);
for ($i=0;$i<count($bits);$i++) {
if ($bits[$i] == "UTC") {
$tds = explode(' ',$bits[$i + 1]); // Format is (2013-08-14 05:00:00)
$tds_date = explode('-',$tds[0]);
$tds_time = explode(':',$tds[1]);
$fixTime = date($timeFormat,mktime($tds_time[0],$tds_time[1],$tds_time[2],$tds_date[1],$tds_date[2],$tds_date[0]) + $TimeZoneOffset);
$bits[$i] = '';
$bits[$i+1] = $fixTime;
$output = implode($bits);
return $output;
}
}
return $str;
}
public function makeMainDiv($str) {
return "<div id='content' class='content'>$str</div>";
}
public function buildOutput($pageName) {
ob_start();
/** @noinspection PhpIncludeInspection */
require_once($pageName);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
public function getParameters($uri) {
$request = str_replace("", "", $uri);
$site_array = mb_split("/", $request);
foreach($site_array as $key => $value) {
if($value == "") {
unset($site_array[$key]);
}
}
return array_values($site_array);
}
}
?>
<?php
require_once('pbkdf2.class.php');
/**
* Class User
*/
class User {
/** @var int Contains the UID of the User (from the db) */
protected $UID;
/** @var string Contains the User's login name */
protected $LoginName;
/** @var string Contains the user's password (as supplied)
* parsed by pbkdf2 */
protected $Password;
/** @var string Contains the User's timezone in Region/City format */
public $TimeZone;
/** @var mixed Contains the User's timezone in Region/City format (as a DateTimeZone object) */
public $TimeZoneOffset;
/** @var bool is the user logged in? */
public $LoggedIn;
/** @var int The UID of the User's Character */
public $Character;
/** @param string $reason The reason for the logout
* @return string Display string for the User */
public function logout($reason) {
$this->UID = "";
$this->LoginName = "";
$this->TimeZone = "";
$this->Password = "";
$this->LoggedIn = False;
switch ($reason)
{
case "Bad Login":
return 'Invalid Login name or Password';
case "Logout":
return 'Logout successful.';
default:
return 'Logout successful.';
}
}
/** @param mixed $connection A PDO connection that has SELECT access to Logins table
* @param string $login The user's login name
* @param string $pass The password (plaintext) supplied by the user
* @return string An error message for delivery to the users, or 'Logged in' if login was successful */
public function login($connection,$login,$pass) {
/** @noinspection PhpUndefinedMethodInspection */
$checkUser = $connection->prepare("SELECT UID, Password, TimeZone, CharUID FROM Logins WHERE LoginName = :login");
/** @noinspection PhpUndefinedMethodInspection */
$checkUser->bindParam(':login',$login);
/** @noinspection PhpUndefinedMethodInspection */
if ( ! $checkUser->execute() ) {
return $this->logout('Bad Login');
}
/** @noinspection PhpUndefinedMethodInspection */
$result = $checkUser->fetch();
$RightPass = $result['Password'];
if ( ! validate_password($pass,$RightPass) ) {
return $this->logout('Bad Login');
}
$this->UID = $result['UID'];
$this->TimeZone = $result['TimeZone'];
$tzo = new DateTimeZone($this->TimeZone);
$time = new DateTime('now');
$this->TimeZoneOffset = $tzo->getOffset($time);
$this->LoginName = $login;
$this->Character = $result['CharUID'];
$this->LoggedIn = True;
return 'Logged in';
}
/** @param mixed $connection A PDO connection that has UPDATE access to Logins table
* @param mixed $raw_date the current Time/Date stamp in UTC as a string (updating to a datetime object soon)
* @return string indicating success ('Updated') or failure ('Failed') */
public function updateLastActive($connection,$raw_date) {
/** @noinspection PhpUndefinedMethodInspection */
$lastActive = $connection->prepare("UPDATE Logins SET LastLogin = :active WHERE UID = :UID");
/** @noinspection PhpUndefinedMethodInspection */
$lastActive->bindParam(':active', $raw_date);
/** @noinspection PhpUndefinedMethodInspection */
$lastActive->bindParam(':UID', $this->UID);
/** @noinspection PhpUndefinedMethodInspection */
if ($lastActive->execute()) {
return 'Failure';
}
return 'Updated';
}
/** @param mixed $connection A PDO connection that has SELECT access to Logins table
* @param string $name The name the user wishes to check availability of
* @return bool true = name is free or error; false = name is taken */
public function nameAvailable($connection,$name) {
/** @noinspection PhpUndefinedMethodInspection */
$check = $connection->prepare("SELECT COUNT(*) FROM Logins WHERE LoginName = :name");
/** @noinspection PhpUndefinedMethodInspection */
$check->bindParam(':name',$name);
/** @noinspection PhpUndefinedMethodInspection */
if ( ! $check->execute() || $check->fetchColumn() == 0 ) {
return true; // returning true if 0 results are returned, or there is an error
}
return false; // returning false if more than 0 results
}
/** @param mixed $connection A PDO connection that has INSERT access to Logins table
* @param string $login The user's desired login name
* @param string $pass The password (plaintext) supplied by the user
* @return string An error message for delivery to the users, or 'Logged in' if login was successful */
public function register($connection,$login,$pass) {
if ( ! $this->nameAvailable($connection,$login) ) {
return $this->logout("Bad Login");
}
$this->LoginName = $login;
$this->Password = create_hash($pass);
/** @noinspection PhpUndefinedMethodInspection */
$registration = $connection->prepare("INSERT INTO Logins (LoginName, Password) VALUES (:login, :pass)");
/** @noinspection PhpUndefinedMethodInspection */
$registration->bindParam(':login',$this->LoginName);
/** @noinspection PhpUndefinedMethodInspection */
$registration->bindParam(':pass',$this->Password);
/** @noinspection PhpUndefinedMethodInspection */
if( $registration->execute() ) {
return 'Success';
}
return 'Failed to execute';
}
}
<?php
// $user and $pw are obfuscators. You understand. I have them plaintext normally; ignore that this won't run.
$con = new PDO('mysql:host=sdgame.db;dbname=Characters',$user,$pw);
$ud = new PDO('mysql:host=sdgame.db;dbname=Characters',$user,$pw);
$pw = new PDO('mysql:host=sdgame.db;dbname=Characters',$user,$pw);
$optimize = new PDO('mysql:host=sdgame.db;dbname=Characters',$user,$pw);
$time = new DateTime('now',new DateTimeZone('UTC'));
//debugging
$tu = '2013-08-14 05:00:00';
$tfOld = '2013-08-14 00:00:00';
$loc = 1;
$specificLocation = $con->prepare("SELECT * FROM Locations WHERE UID = ?");
$specificLocation->bindParam(1, $_SESSION["CurrLoc"]);
$allLocations = $con->prepare("SELECT * FROM Locations");
$conversation = $con->prepare("SELECT Conversations.UID, Conversations.Location, Conversations.TDS,
Character_Details.Name, Conversations.Comment, Character_Details.UID AS CharUID
FROM Conversations
INNER JOIN Character_Details ON Conversations.Char_num = Character_Details.UID
WHERE TDS >= :tds AND Location = :location ORDER BY UID DESC LIMIT 0, 10");
$conversation->bindParam(":tds", $tfOld);
$conversation->bindParam(":location",$loc);
//$conversation->bindParam(":location", $_SESSION["CurrLoc"]);
$charactersHere = $con->prepare("SELECT UID, Name, Rank FROM Character_Details WHERE Current_Location_W = ?");
$charactersHere->bindParam(1, $_SESSION["CurrLoc"]);
$allCharacters = $con->prepare("SELECT Character_Details.UID, Character_Details.Name, Character_Details.Rank,
Locations.LocationName_W AS Location, Locations.UID AS LocUID
FROM Character_Details
JOIN Locations ON Character_Details.Current_Location_W=Locations.UID
ORDER BY Locations.UID ASC");
$sendChat = $ud->prepare("INSERT INTO Conversations (Location, TDS, Char_num, Comment)
VALUES (:location,:updateTime,:charUID,:message)");
//$sendChat->bindParam(":location",$_SESSION["CurrLoc"]);
$sendChat->bindParam(":location",$loc); // using debug variable
$sendChat->bindParam(":updateTime",$time->format('Y-m-d G:i:s'));
$lastActive = $pw->prepare("UPDATE Logins SET LastLogin=:tds WHERE CharUID=:uid");
$lastActive->bindParam(":tds",$time->format('Y-m-d'));
$lastActive->bindparam(":uid",$you->Character);
?>
<?php
$site_root = 'http://obfuscated.com/OO/';
$serverRoot = '/site/root/obfuscated/OO/';
spl_autoload_register(function ($class) {
global $serverRoot;
include_once $serverRoot . 'classes/' . $class . '.class.php';
});
session_start();
include_once ($serverRoot . 'include/connections.php');
// include_once $remoteRoot . 'time.php';
$parser = new Parser;
$params = $parser->getParameters($_SERVER['REQUEST_URI']);
if ($params[1] != 'kronjob') {
if ( ! isset($_SESSION['User'])) {
$params[1] = "login"; // should be 0 once deployed
}
}
$title = 'Sweet Dreams Online';
switch (strtolower($params[1])) { // should be 0 once deployed
case 'logout': // 'fall through' behavior emulated within logout.php with header: Location command.
$useHeader = false;
$useHeadBar = false;
$main = $parser->buildOutput('pages/logout.php');
$useFooter = false;
break;
case "login":
$title .= ' | Login';
$useHeader = true;
$useHeadBar = false;
$main = $parser->buildOutput('pages/register.php');
$useFooter = false;
break;
case "kronjob":
$useHeader = false;
$useHeadBar = false;
$main = $parser->buildOutput('pages/kronjob.php');
$useFooter = false;
break;
case "powers":
$title .= ' | Powers';
$useHeader = true;
$useHeadBar = true;
$main = $parser->buildOutput('pages/buyPowers.php');
$useFooter = true;
break;
case "character":
$title .= ' | Character';
$useHeader = true;
$useHeadBar = true;
$main = $parser->buildOutput('pages/newchar.php');
$useFooter = true;
break;
case "goto":
$useHeader = false;
$useHeadBar = false;
$main = $parser->buildOutput('pages/goto.php');
$useFooter = true;
break;
case "timezone":
$title .= ' | Set Timezone';
$useHeader = true;
$useHeadBar = true;
$main = $parser->buildOutput('pages/TZChoice.php');
$useFooter = true;
break;
case "insert":
$title .= ' | GM-Only: Insert';
$useHeader = true;
$useHeadBar = true;
if ($_SESSION["IsGM"]) {
$main = $parser->buildOutput('pages/insert.php');
} else {
$main = $parser->buildOutput('pages/converse.php');
}
$useFooter = true;
break;
default:
$useHeader = true;
$useHeadBar = true;
$main = $parser->buildOutput('pages/converse.php');
$useFooter = true;
break;
}
$header = '';
$footer = '';
if ($useHeader) {
$header = $parser->buildOutput('include/header.php');
echo $header;
}
if ($useHeadBar) {
$headbar = $parser->buildOutput('include/headbar.php');
echo $headbar;
}
echo $main;
if ($useFooter) {
$footer = $parser->buildOutput('include/footer.php');
echo $footer;
}
?>
<?php
$site_root = 'http://obfuscated.com/OO/';
$serverRoot = '/site/root/obfuscated/OO/';
spl_autoload_register(function ($class) {
global $serverRoot;
include_once $serverRoot . 'classes/' . $class . '.class.php';
});
include_once ($serverRoot . 'include/connections.php');
session_start();
if ( ! isset($yours)) {
$yours = unserialize($_SESSION["Character"]);
}
$chat = new Conversation($con,$conversation,1); // '1' needs to be replaced with the character's location'
$chat->getAllNewChats($conversation);
$currentChar = $_SESSION["CharUID"];
if (isset($_POST["UD_type"])) {
if ($_POST["UD_type"]="Converse") {
$newComment = $_POST["Comm"];
$chat->Send($sendChat,$yours->UID,$newComment);
}
}
$TDS=strtotime($row['TDS']);
$TDS=$TDS-$tzOffset;
?>
<!--suppress HtmlFormInputWithoutLabel -->
<?php echo $chat ?>
<input type='text' name='Comm' class='TalkBox' id='message' onkeypress='return typeChat(event)'>
<input type='submit' value='Talk' class='TalkButton' onClick='chat()'>
<?php
$site_root = 'http://obfuscated.com/OO/';
$serverRoot = '/site/root/obfuscated/OO/';
spl_autoload_register(function ($class) {
global $serverRoot;
include_once $serverRoot . 'classes/' . $class . '.class.php';
});
session_start();
include_once ($serverRoot . 'include/connections.php');
$you = new User;
if ($you->login($pw,$_POST["User"],$_POST["Pword"]) == 'Invalid Login name or Password') {
header('Location: ' . $site_root . 'login/failed');
exit;
}
$yours = new Character();
$yours->load($ud,$you->Character);
$_SESSION["User"] = serialize($you);
$_SESSION["Character"] = serialize($yours);
header('Location: ' . $site_root);
?>
<?php
$site_root = 'http://obfuscated.com/OO/';
$serverRoot = '/site/root/obfuscated/OO/';
spl_autoload_register(function ($class) {
global $serverRoot;
include_once $serverRoot . 'classes/' . $class . '.class.php';
});
session_start();
include_once ($serverRoot . 'include/connections.php');
?>
<div class='register'><h1>Welcome!</h1>
<p>You don't seem to be logged in at the moment. Please take a moment to either Log In or Register.</p>
<br /><br />
<div class='table-replace centered-div' width='400px'>
<strong>Login:</strong>
<form action='<?php echo $site_root ?>pages/login.php' method='POST'>
<label for='User'>Username:</label>
<input name='User' maxlength='32' type='text'>
<br />
<label for='Pword'>Password:</label>
<input name='Pword' maxlength='32' type='password'>
<br />
<input name='Submit' type='submit' value='Log In!'>
</form>
<hr />
<strong>Register:</strong>
<form action='<?php echo $site_root ?>pages/registered.php' method='post'>
<label for='Uname'>Username:</label>
<input name='Uname' maxlength='32'>
<br />
<label for='Cname'>Character Name:</label>
<input name='Cname' maxlength='32'>
<br />
<input name='Submit' type='submit' class='left' value='Log In!'>
</form>
</div>
<br /><br />
Please note that you must be 13 to register.<br />
Current server time and date: <?php echo date('Y-m-d h:i:s',time()); ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment