Permalink
Browse files

Making a more compact code...

As you can see in index.php, next code will be a lot more compact.
A lot.
I still have to finish developing this and the new style, but after
finishing that I think I'm going to delete almost all the files, with an
exception for the font file, the stylev2 file, index.php, footer, form
and README.
  • Loading branch information...
thehowl committed Apr 8, 2014
1 parent 5082064 commit 79c021133ee9de791d1fc8e2cd3e763498511d13
Showing with 67 additions and 7 deletions.
  1. +3 −3 form.html
  2. +44 −3 index.php
  3. +20 −1 stylev2.css
View
@@ -1,3 +1,3 @@
<form action="calc.php" method="post">
Level you want to reach: <input type="text" name="leveltoreach" autocomplete="off" placeholder="Ex. 87" class="submit"> <button class="submit" style="background: #F0F0F0" type="submit">Find the score!</button>
</form>
<form action="index.php" method="post">
<span class="txt">insert nickname</span> <input type="text" name="nickname" autocomplete="off" placeholder="Ex. WubWoofWolf" class="submit"><br><span class="txt">mode <input type="radio" name="mode" value="0">osu! standard <input type="radio" name="mode" value="1">Taiko <input type="radio" name="mode" value="2">Catch the Beat <input type="radio" name="mode" value="3">osu!mania</span><br><span class="txt">and then</span> <button type="submit">submit!</button>
<input type="hidden" value="api" name="calct"></form>
View
@@ -1,11 +1,52 @@
<?
$apikey = "API KEY HERE"; // This is holy shit damn important. To make everything work, edit this as the page of the wiki "API key" says of the repo of osu! level calculator
// Thanks to pizza kun for the function
function ScoreLevelCalculator ($level,$currentScore = 0)
{
if ($level <= 100)
{
if ($level>=2) // This because if the value is 0 or 1, or any other value, it creates an error
{
$part = 4 * bcpow($level, 3, 0) - 3 * bcpow($level, 2, 0) - $level;
$result = 5000 / 3 * $part + 1.25 * bcpow(1.8, $level - 60, 0);
}
else
{
$result = 0;
}
}
elseif ($level >= 101)
{
$part = $level - 100;
$result = 26931190829 + 100000000000 * $part;
}
else throw new Exception ("Holy shit, this is an error.",111);
$result = abs($result);
return ($result - $currentScore);
}
if ($_POST['calct'] = 'api') {
$query = "https://osu.ppy.sh/api/get_user?k=" . $apikey . "&u=" . $_POST["nickname"] . "&m=" . $_POST["mode"];
$json = file_get_contents($query);
$data = json_decode($json);
$actlvl = round($data[0]->level);
$lvlreach = $actlvl + 1;
$final = number_format(round(ScoreLevelCalculator ($level,$data[0]->total_score : 0)));
}
elseif ($_POST['calct'] = 'cl') {
$final = number_format(round(ScoreLevelCalculator ($_POST["leveltoreach"],0)));
}
?>
<!DOCTYPE html>
<html>
<head>
<title>How much score do you need for the next level on osu!?</title>
<link href="style.css" rel="stylesheet" type="text/css">
<title>osu! level calculator</title>
<link href="stylev2.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container"><div class="text"> <div class="title">How much score do you need for the next level on osu!?</div><br><div align="center" class="divisor"></div><br>
<div align="center" id="select"><a href="/">home</a> <a href="classic.php">classic</a> <a href="http://osu.ppy.sh/forum/t/199230/start=0">topic</a></div>
<h1>osu! level calculator</h1>
<?
require 'form.html';
?></div></div><br><?
View
@@ -23,7 +23,7 @@ h1 {
.txt {
text-transform: uppercase;
opacity: 0.7;
margin-left: 55px;
margin-left: 70px;
padding-top: 10px;
font-size: 15pt;
}
@@ -49,4 +49,23 @@ h1 {
button, input {
outline: none;
padding: 3px 4px;
}
button {
background: #f7f7f7;
cursor: pointer;
border: 0;
font-family: "Segoe UI Light";
text-transform: uppercase;
height: 40px;
width: 100px;
font-size: 15pt
}
.submit {
background: #f7f7f7;
font-family: "Segoe UI Light";
font-size: 15pt;
width: 400px;
border: 0;
}

0 comments on commit 79c0211

Please sign in to comment.