public function toHTML()
 {
     $returnHtml = $this->text;
     if (isset($this->params->vars)) {
         foreach ($this->params->vars as $i => $var) {
             $html = "<s>invalid</s>";
             switch ($var->type) {
                 case "user":
                     $user = UserManager::getFromBLID($var->blid);
                     $html = "<a href=\"/user/view.php?blid=" . $var->blid . "\">" . $user->getUserName() . "</a>";
                     break;
                 case "addon":
                     $addon = AddonManager::getFromID($var->id);
                     if ($addon) {
                         $html = "<a href=\"/addons/addon.php?id=" . $var->id . "\">" . $addon->getName() . "</a>";
                     } else {
                         $html = "<a href=\"/addons/addon.php?id=" . $var->id . "\">{error}</a>";
                     }
                     break;
             }
             $returnHtml = str_replace('$' . ($i + 1), $html, $returnHtml);
         }
     }
     return $returnHtml;
 }
 function hasGlassAccount()
 {
     $user = UserManager::getFromBLID($this->blid);
     if ($user !== false) {
         return true;
     } else {
         return false;
     }
 }
 public static function getCurrent()
 {
     if (!isset($_SESSION)) {
         return false;
     }
     if (isset($_SESSION['blid'])) {
         return UserManager::getFromBLID($_SESSION['blid']);
     } else {
         return false;
     }
 }
Exemple #4
0
 public static function addEntry($blid, $username, $ip = null)
 {
     if (isset($ip)) {
         if (!UserLog::isRemoteVerified($blid, $username, $ip)) {
             return "auth.blockland.us verification failed";
         }
     }
     $db = new DatabaseManager();
     UserLog::verifyTable($db);
     $resource = $db->query("SELECT * FROM `user_log` WHERE `blid`='" . $db->sanitize($blid) . "' AND `username`='" . $db->sanitize($username) . "'");
     if ($resource->num_rows == 0) {
         $db->query("INSERT INTO `user_log` (`blid`, `firstseen`, `lastseen`, `username`) VALUES ('" . $db->sanitize($blid) . "', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '" . $db->sanitize($username) . "');");
     } else {
         $db->query("UPDATE `user_log` SET `lastseen` = CURRENT_TIMESTAMP WHERE `blid`='" . $db->sanitize($blid) . "' AND `username`='" . $db->sanitize($username) . "'");
     }
     //update username
     if ($user = UserManager::getFromBLID($blid)) {
         if ($username != $user->getUsername()) {
             $user->setUsername($username);
         }
     }
 }
 public static function login($identifier, $password, $redirect = "/index.php")
 {
     if (is_numeric($identifier)) {
         $blid = intval($identifier);
         if (is_int($blid)) {
             $loginDetails = UserManager::getLoginDetailsFromBLID($blid);
             if (!$loginDetails) {
                 return ["message" => "This BL_ID has not been verified yet, please use your E-mail instead"];
             }
         } else {
             return ["message" => "Invalid BL_ID"];
         }
     } elseif (filter_var($identifier, FILTER_VALIDATE_EMAIL)) {
         $email = $identifier;
         $loginDetails = UserManager::getLoginDetailsFromEmail($email);
     } else {
         return ["message" => "Invalid E-mail/BL_ID"];
     }
     if (!$loginDetails) {
         //username not found
         return ["message" => "Incorrect login credentials"];
     }
     $hash = $loginDetails['hash'];
     $salt = $loginDetails['salt'];
     if ($hash === hash("sha256", $password . $salt)) {
         $_SESSION['loggedin'] = 1;
         $_SESSION['blid'] = $loginDetails['blid'];
         $_SESSION['email'] = $loginDetails['email'];
         $_SESSION['username'] = $loginDetails['username'];
         $userObject = UserManager::getFromBLID($_SESSION['blid']);
         if ($userObject == false || $userObject->isMigrated()) {
             return ["redirect" => $redirect];
         } else {
             return ["redirect" => "/user/migrate.php"];
         }
     }
     return ["message" => "Incorrect login credentials"];
 }
Exemple #6
0
            //$uo->initFromId($authors[0]->id);
            $uo = UserManager::getFromBLID($authors[0]->blid);
            $uo2 = new UserHandler();
            $uo2->initFromId($authors[1]->id);
            $uo2 = UserManager::getFromBLID($authors[1]->blid);
            echo "<a href=\"#\">" . $uo->getName() . "</a>";
            echo " and ";
            echo "<a href=\"#\">" . $uo2->getName() . "</a>";
        } else {
            $count = sizeof($authors);
            //echo("DATA: ");
            //print_r($authors);
            foreach ($authors as $num => $author) {
                //$uo = new UserHandler();
                //$uo->initFromId($auth->id);
                $uo = UserManager::getFromBLID($author->blid);
                if ($count - $num == 1) {
                    echo "and <a href=\"#\">" . $uo->getName() . "</a>";
                } else {
                    echo "<a href=\"#\">" . $uo->getName() . "</a>, ";
                }
            }
        }
    }
    ?>
		</td>
		<td>
			<image src="http://blocklandglass.com/icon/icons16/star.png" />
			<image src="http://blocklandglass.com/icon/icons16/star.png" />
			<image src="http://blocklandglass.com/icon/icons16/star.png" />
			<image src="http://blocklandglass.com/icon/icons16/star.png" />
 public static function addBLIDToGroupID($blid, $gid)
 {
     //make sure addon exists
     $user = UserManager::getFromBLID($blid);
     if ($user === false) {
         return false;
     }
     $group = GroupManager::getFromID($gid);
     if ($group === false) {
         return false;
     }
     //call real function
     return GroupManager::addUserToGroup($user, $group);
 }
<?php

require_once dirname(__DIR__) . '/class/UserManager.php';
$user = UserManager::getFromBLID(9789);
UserManager::sendPasswordResetEmail($user);
//UserManager::email($user, "Password Reset", $body);
<?php

//this page is designed to be requested by ajax or the in-game client
require_once realpath(dirname(__DIR__) . "/private/class/DatabaseManager.php");
require_once realpath(dirname(__DIR__) . "/private/lib/Parsedown.php");
if (!isset($_POST['query'])) {
    echo "Invalid search";
} else {
    $db = new DatabaseManager();
    $baseQuery = "SELECT * FROM `addon_addons` WHERE `name` LIKE '%" . $db->sanitize($_POST['query']) . "%'";
    //later on we can make it so administrators can search for deleted add-ons
    $extendedQuery = " AND `deleted` = 0";
    if (isset($_POST['blid'])) {
        try {
            require_once realpath(dirname(__DIR__) . "/private/class/UserManager.php");
            $user = UserManager::getFromBLID($_POST['blid']);
            $extendedQuery = $extendedQuery . " AND `author` = '" . $db->sanitize($_POST['blid']) . "'";
        } catch (Exception $e) {
            echo "<p>User " . htmlspecialchars($_POST['blid']) . " not found.</p>";
        }
    }
    //One of the few time's we'll use a direct SQL query on a page
    $result = $db->query($baseQuery . $extendedQuery);
    echo "<h2>Search Results for ";
    echo "\"<u>" . htmlspecialchars($_POST['query']) . "</u>\"";
    if (isset($user) && $user) {
        echo " by <a href=\"/user/view.php?id=" . $user->getID() . "\">" . htmlspecialchars($user->getUsername()) . "</a>";
    }
    echo "</h2><hr />";
    if ($result->num_rows) {
        while ($row = $result->fetch_object()) {
<?php

$addons = (include realpath(dirname(__FILE__) . "/searchAddons.php"));
require_once realpath(dirname(__DIR__) . "/class/UserManager.php");
$users = [];
foreach ($addons as $addon) {
    if (!isset($users[$addon->blid])) {
        $users[$addon->blid] = UserManager::getFromBLID($addon->blid);
    }
}
$response = ["addons" => $addons, "users" => $users];
return $response;
Exemple #11
0
    $board[3] = "Bricks";
    $board[4] = "Cosmetics";
    $board[5] = "Gamemodes";
    $board[6] = "Tools";
    $board[7] = "Weapons";
    $board[8] = "Colorsets";
    $board[9] = "Vehicles";
    $board[10] = "Bargain Bin";
    $board[11] = "Sounds";
    $o = new stdClass();
    $o->id = $ao->getId();
    $o->name = $ao->getName();
    $o->board = $board[$ao->getBoard()];
    $un = utf8_encode(UserLog::getCurrentUsername($ao->getManagerBLID()));
    if ($un === false) {
        $un = UserManager::getFromBLID($ao->getManagerBLID())->getUsername();
    }
    $o->author = $un;
    $ar[] = $o;
}
$dlg->uploads = $ar;
$ar = array();
foreach ($recentUpdates as $r) {
    $ao = $r->getAddon();
    if (!$ao->getApproved()) {
        continue;
    }
    if ($ao->getBoard() == 10) {
        // bargain bin
        continue;
    }
 public static function createGroupWithLeaderBLID($name, $description, $color, $icon, $blid)
 {
     $user = UserManager::getFromBLID($blid);
     if ($user === false) {
         return false;
     }
     return GroupManager::createGroupWithLeader($name, $description, $color, $icon, $user);
 }
require_once realpath(dirname(__DIR__) . "/private/class/NotificationManager.php");
require_once realpath(dirname(__DIR__) . "/private/class/NotificationObject.php");
if (isset($_REQUEST['token']) && isset($_REQUEST['id'])) {
    if (isset($_REQUEST['password']) && isset($_REQUEST['confirm'])) {
        if ($_REQUEST['password'] == $_REQUEST['confirm']) {
            UserManager::updatePassword($_REQUEST['id'], $_REQUEST['password']);
            header('Location: /login.php');
            return;
        } else {
            $response = ["message" => "Passwords dont match!", "form" => true];
        }
    } else {
        $blid = $_REQUEST['id'];
        $token = $_REQUEST['token'];
        apc_delete('userObject_' . $_REQUEST['id']);
        $userObj = UserManager::getFromBLID($blid);
        if ($userObj->getResetKey() !== $token) {
            $response = ["message" => "<b>Invalid reset token.</b> Did you request a password reset twice on accident?", "form" => false];
        } else {
            if (time() - $userObj->getResetTime() > 1800) {
                $response = ["message" => "<b>Your password reset has expired!</b> Try resending the email. " . (time() - $userObj->getResetTime()), "form" => false];
            } else {
                $response = ["message" => null, "form" => true];
            }
        }
    }
} else {
    $response = ["message" => "Reset token/id missing", "form" => false];
}
?>
<div class="maincontainer">
Exemple #14
0
 public function testGetFromBLID2()
 {
     $this->testRegisterSuccess();
     $response = UserManager::getFromBLID(1234);
     $this->assertFalse($response);
     $response = UserManager::getAllAccountsFromBLID(1234);
     $this->assertNotEquals(false, $response);
     $this->assertEquals(1, count($response));
     $acc = $response[0];
     $this->assertEquals(1234, $acc->getBLID());
 }
if (!isset($_GET['id'])) {
    $response = ["redirect" => "/builds/index.php"];
    return $response;
}
require_once realpath(dirname(__DIR__) . "/class/BuildManager.php");
require_once realpath(dirname(__DIR__) . "/class/UserManager.php");
require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php");
//	require_once(realpath(dirname(__DIR__) . "/class/TagManager.php"));
//	require_once(realpath(dirname(__DIR__) . "/class/DependencyManager.php"));
$build = BuildManager::getFromID($_GET['id'] + 0);
if ($build === false) {
    $response = ["redirect" => "/builds/index.php"];
    return $response;
}
$user = UserManager::getFromBLID($build->blid);
//	$tagIDs = $build->getTags();
//	$dependencyIDs = $build->getDependencies();
//	$tags = [];
//	$dependencies = [];
//
//	foreach($tagIDS as $tid) {
//		$tags[] = TagManager::getFromID($tid);
//	}
//
//	foreach($dependencyIDs as $did) {
//		$dependencies[] = DependencyManager::getFromID($did);
//	}
$screenshotIDs = ScreenshotManager::getScreenshotsFromBuild($build->id);
$primaryScreenshotID = ScreenshotManager::getBuildPrimaryScreenshot($build->id);
$screenshots = [];
Exemple #16
0
<?php

$_PAGETITLE = "Blockland Glass | Inspect Update";
include realpath(dirname(__DIR__) . "/../private/header.php");
include realpath(dirname(__DIR__) . "/../private/navigationbar.php");
require_once realpath(dirname(__DIR__) . "/../private/class/AddonManager.php");
require_once realpath(dirname(__DIR__) . "/../private/class/BoardManager.php");
require_once realpath(dirname(__DIR__) . "/../private/class/UserManager.php");
require_once realpath(dirname(__DIR__) . "/../private/class/UserLog.php");
$user = UserManager::getCurrent();
$review = false;
if (is_object($user)) {
    $review = $user->inGroup("Reviewer");
}
$addon = AddonManager::getFromID($_REQUEST['id']);
$manager = UserManager::getFromBLID($addon->getManagerBLID());
?>
<script type="text/javascript">
var addonId = <?php 
echo $addon->getId();
?>
;
var isReviewer = <?php 
echo $review ? 1 : 0;
?>
;
var root = null;

function openPopup(title, body) {
	$("#popupTitle").html(title);
	$("#popupBody").html(body);
     $ret->status = "fail";
     error_log("Auth failed for ident " . $_REQUEST['ident']);
 } else {
     error_log("Auth pass for " . $_REQUEST['ident']);
     $ret->ident = $con->getIdentifier();
     $ret->blid = $con->getBLID();
     if ($ret->blid == 118256 || $ret->blid == 43364 || $ret->blid == 21186) {
         $ret->status = "barred";
         $json = json_encode($ret, JSON_PRETTY_PRINT);
         die($json);
     }
     $ret->username = iconv("ISO-8859-1", "UTF-8", UserLog::getCurrentUsername($ret->blid));
     error_log("Username is " . $ret->username);
     $ret->admin = false;
     $ret->mod = false;
     $user = UserManager::getFromBLID($ret->blid);
     if ($user !== false) {
         $ret->beta = false;
         if ($user->inGroup("Administrator")) {
             $ret->admin = true;
             $ret->mod = true;
             $ret->beta = true;
         } else {
             if ($user->inGroup("Moderator")) {
                 $ret->mod = true;
                 $ret->beta = true;
             }
         }
         if ($user->inGroup("Beta") || $user->inGroup("Reviewer")) {
             $ret->beta = true;
         }
Exemple #18
0
<?php

include realpath(dirname(__DIR__) . "/private/header.php");
include realpath(dirname(__DIR__) . "/private/navigationbar.php");
require_once realpath(dirname(__DIR__) . "/private/class/UserManager.php");
require_once realpath(dirname(__DIR__) . "/private/class/UserLog.php");
$failed = false;
if (isset($_GET['blid'])) {
    try {
        $userObject = UserManager::getFromBLID($_GET['blid']);
    } catch (Exception $e) {
        $failed = true;
    }
} else {
    $failed = true;
}
?>
<div class="maincontainer">
<?php 
/*Ideas:
		- select avatar from some predetermined list
		- custom description
		- friends list
		- linking to steam
	*/
if ($failed) {
    echo "<h3>Uh-Oh</h3>";
    echo "<p>Whoever you're looking for either never existed or deleted their account.</p>";
} else {
    $history = UserLog::getHistory($userObject->getBLID());
    echo "<h3>" . htmlspecialchars($userObject->getName()) . "</h3>";
<?php

$comments = (include realpath(dirname(__FILE__) . "/getPageComments.php"));
require_once realpath(dirname(__DIR__) . "/class/UserManager.php");
$users = [];
foreach ($comments as $comment) {
    if (!isset($users[$comment->blid])) {
        $users[$comment->blid] = UserManager::getFromBLID($comment->blid);
    }
}
$response = ["comments" => $comments, "users" => $users];
return $response;