Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minecraft Name History - http://www.LB-Stuff.com/Minecraft-Name-History - really hacky PHP script, available in public domain
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Minecraft Name History - Nicholas "LB" Braden</title>
<link rel="canonical" href="http://www.LB-Stuff.com/Minecraft-Name-History" />
<link rel="stylesheet" href="/light.css" />
<link rel="icon" type="image/png" href="/LB.png" />
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<?php include 'ga.php'; ?>
<h1>Minecraft Name History</h1>
<div class="g-plusone" data-annotation="inline" data-width="450"></div>
<p>Enter a <em>current</em> or <em>original</em> Minecraft username, or a UUID, and click the button to get the name history.</p>
<form action="?" method="get">
<input type="text" name="user" value="<?php echo(htmlspecialchars($_GET['user'])); ?>" required>
<input type="submit" value="History Lesson">
</form>
<?php
$user = $_GET['user'];
if(strlen($user) > 0)
{
$name = null;
$uuid = null;
if(strlen($user) <= 16)
{
$name = $user;
$c = curl_init('https://api.mojang.com/users/profiles/minecraft/'.$name);
curl_setopt($c, CURLOPT_POST, 0);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($c);
curl_close($c);
$data = json_decode($result, true);
if(isset($data['id']))
{
$uuid = $data['id'];
}
else
{
$c = curl_init('https://api.mojang.com/users/profiles/minecraft/'.$name.'?at=1422986400');
curl_setopt($c, CURLOPT_POST, 0);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($c);
curl_close($c);
$data = json_decode($result, true);
if(isset($data['id']))
{
$uuid = $data['id'];
}
else
{
?>
<p style="color: red;">Could not get player UUID.</p>
<?php
}
}
}
else $uuid = $user;
$c = curl_init('https://api.mojang.com/user/profiles/'.$uuid.'/names');
curl_setopt($c, CURLOPT_POST, 0);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($c);
curl_close($c);
$data = json_decode($result, true);
if(isset($data[0]['name']))
{
if($name != null)
{
?>
<p>UUID for <code><?php echo(htmlspecialchars($name)); ?></code> is <code><?php echo(htmlspecialchars($uuid)) ?></code></p>
<?php
}
?>
<table>
<tr><th>Date</th><th>Username</th></tr>
<tr><td>Original</td><td><code><?php echo(htmlspecialchars($data[0]['name'])); ?></code></td></tr>
<?php
$i = 0;
while(isset($data[++$i]))
{
?>
<tr><td><?php echo(date('F j, Y ', $data[$i]['changedToAt']/1000).'at'.date(' g:i:s a', $data[$i]['changedToAt']/1000)); ?></td><td><code><?php echo(htmlspecialchars($data[$i]['name'])); ?></code></td></tr>
<?php
}
?>
</table>
<p>Thank you for not abusing this service.</p>
<?php
}
else
{
?>
<p style="color: red;">Could not get name history.</p>
<?php
}
}
else
{
?>
<p>This tool uses the <a href="http://wiki.vg/Mojang_API">Mojang API</a>.</p>
<p><a href="https://gist.github.com/LB--/b74baf9d75f9846e664b">Source code</a> available in public domain.</p>
<?php
}
?>
</body>
</html>
@LB--

This comment has been minimized.

Owner

LB-- commented Mar 5, 2015

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>
@GetSomeBlocks

This comment has been minimized.

GetSomeBlocks commented Feb 26, 2016

Can you help me to use this in my website? Im using get system and i want to show the Name history in the user profile;
See this
http://baldricnetwork.com/u?id=CodedGuy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment