Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
session_start();
|
||||
// http://zovguran.net/Unalike/async/
|
||||
|
||||
$unalike = json_decode(file_get_contents("../unalike.json"), true);
|
||||
// if (!empty($unalike))
|
||||
// {
|
||||
// $requests = json_decode(file_get_contents("../requests.json"), true);
|
||||
// if (!empty($requests))
|
||||
// {
|
||||
// $unalike["busy"] = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $unalike["busy"] = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($unalike);
|
||||
@@ -0,0 +1,18 @@
|
||||
<div class="background-color card-osu card-osu-topless">
|
||||
<div class="card-title">
|
||||
<h3 class="cover-image song-info" style="padding:30px 50px;background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('[[ COVER_IMAGE ]]');background-size:cover;">
|
||||
[[ SONG_INFO ]]
|
||||
</h3>
|
||||
</div>
|
||||
<div style="margin-top:25px;">
|
||||
<div style="display:flex;flex-flow: row wrap;justify-content:flex-end;">
|
||||
<p style="flex: 1 0 auto;min-width:200px;">[[ STATE ]]</p>
|
||||
<button onclick="hiddenFunctionClick(this, 'action/?invite&target=[[ CHANNEL ]]', 1)" class="button-osu button-osu-management button-positive" style="margin:0 10px 0 0;flex:0 0 0;min-width:140px;" putDisabledHere>
|
||||
<div class="button-symbol">📤</div>
|
||||
<div class="button-label">Invite</div>
|
||||
</button>
|
||||
<button onclick="hiddenFunctionClick(this, 'action/?close&target=[[ CHANNEL ]]', 3)" class="button-osu button-osu-round button-negative" style="flex: 0 0 0;" putDisabledHere>❌</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>[[ PLAYERS ]]</div>
|
||||
</div>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
session_start();
|
||||
// http://zovguran.net/Unalike/async/
|
||||
|
||||
$relative_prefix = "../../lobbies/";
|
||||
$original_suffix = ".json";
|
||||
$users_suffix = $original_suffix;
|
||||
|
||||
$absolute_prefix = "/Unalike/lobbies/";
|
||||
|
||||
$call_prefix = "";
|
||||
$call_suffix = "";
|
||||
|
||||
$recent_count = 6;
|
||||
|
||||
$selected_match = false;
|
||||
|
||||
$output = array();
|
||||
|
||||
|
||||
$all_lobbies = glob($relative_prefix . "*" . $original_suffix);
|
||||
natsort($all_lobbies);
|
||||
$all_lobbies = array_reverse($all_lobbies);
|
||||
$recent_lobbies = array_slice($all_lobbies, 0, $recent_count);
|
||||
|
||||
|
||||
foreach ($recent_lobbies as $relative_file)
|
||||
{
|
||||
$json = json_decode(file_get_contents($relative_file), true);
|
||||
if (!empty($json))
|
||||
{
|
||||
$output[] = $json;
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($output);
|
||||
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
session_start();
|
||||
// http://zovguran.net/Unalike/async/
|
||||
|
||||
$api_url = "http://localhost:80/Unalike/API";
|
||||
|
||||
$users_prefix = "../../users/";
|
||||
|
||||
$relative_prefix = "../../matches/";
|
||||
$original_suffix = ".json";
|
||||
$users_suffix = $original_suffix;
|
||||
|
||||
$absolute_prefix = "/Unalike/matches/";
|
||||
|
||||
$call_prefix = "";
|
||||
$call_suffix = "";
|
||||
|
||||
$recent_count = 6;
|
||||
|
||||
$selected_match = false;
|
||||
|
||||
$output = array();
|
||||
|
||||
if (!empty($_GET["select"]) && file_exists($relative_prefix . $_GET["select"] . $original_suffix))
|
||||
{
|
||||
$selected_match = $relative_prefix . $_GET["select"] . $original_suffix;
|
||||
}
|
||||
|
||||
if (!empty($selected_match))
|
||||
{
|
||||
if (file_exists($selected_match))
|
||||
{
|
||||
$output = json_decode(file_get_contents($selected_match), true);
|
||||
if (!empty($output) && !empty($output["games"]) && !empty($output["games"][0]["scores"]))
|
||||
{
|
||||
foreach ($output["games"][0]["scores"] as $key => $score)
|
||||
{
|
||||
if (!empty($score["user_id"]))
|
||||
{
|
||||
$username = "Guest";
|
||||
if (file_exists($users_prefix . $score["user_id"] . $users_suffix))
|
||||
{
|
||||
$user = json_decode(file_get_contents($users_prefix . $score["user_id"] . $users_suffix), true);
|
||||
if (!empty($user) && !empty($user["username"]))
|
||||
{
|
||||
$username = $user["username"];
|
||||
}
|
||||
}
|
||||
else if (!empty($_SESSION["unalike-osu-id"]) && !empty($_SESSION["unalike-osu-username"]) && !empty($_SESSION["unalike-granted"]) && $_SESSION["unalike-granted"] === true)
|
||||
{
|
||||
$caller = str_replace(" ", "_", $_SESSION["unalike-osu-username"]);
|
||||
$url = $api_url . "/" . $caller . "/u/" . $score["user_id"];
|
||||
$raw = file_get_contents($url);
|
||||
$user = json_decode($raw, true);
|
||||
if (!empty($user) && !empty($user["username"]))
|
||||
{
|
||||
$username = $user["username"];
|
||||
}
|
||||
}
|
||||
$output["games"][0]["scores"][$key]["username"] = $username;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$all_matches = glob($relative_prefix . "*" . $original_suffix);
|
||||
natsort($all_matches);
|
||||
$all_matches = array_reverse($all_matches);
|
||||
$recent_matches = array_slice($all_matches, 0, $recent_count);
|
||||
|
||||
$link_to_file = false;
|
||||
|
||||
foreach ($recent_matches as $relative_file)
|
||||
{
|
||||
if ($link_to_file)
|
||||
{
|
||||
$output[] = str_replace($relative_prefix, $absolute_prefix, $relative_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
$output[] = str_replace($original_suffix, $call_suffix, str_replace($relative_prefix, $call_prefix, $relative_file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["render"]))
|
||||
{
|
||||
$needed_beatmaps = array();
|
||||
foreach ($output["games"][0]["scores"] as $score)
|
||||
{
|
||||
$needed_beatmaps[] = $score["beatmap_id"];
|
||||
}
|
||||
|
||||
$needed_beatmaps = array_unique($needed_beatmaps);
|
||||
|
||||
$userid = 0;
|
||||
$beatmaps = array();
|
||||
if (!empty($_SESSION["unalike-osu-id"]) && !empty($_SESSION["unalike-osu-username"]) && !empty($_SESSION["unalike-granted"]) && $_SESSION["unalike-granted"] === true)
|
||||
{
|
||||
$caller = str_replace(" ", "_", $_SESSION["unalike-osu-username"]);
|
||||
$userid = $_SESSION["unalike-osu-id"];
|
||||
|
||||
foreach ($needed_beatmaps as $beatmap_id)
|
||||
{
|
||||
$url = $api_url . "/" . $caller . "/b/" . $beatmap_id;
|
||||
$raw = file_get_contents($url);
|
||||
$beatmaps[$beatmap_id] = json_decode($raw, true);
|
||||
$beatmaps[$beatmap_id] = json_decode($raw, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($needed_beatmaps as $beatmap_id)
|
||||
{
|
||||
$beatmaps[$beatmap_id] = array( // dummy
|
||||
"id" => $beatmap_id,
|
||||
"url" => "login/",
|
||||
"beatmapset" => [
|
||||
"title" => "Results",
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$sample_beatmap = array_key_first($beatmaps);
|
||||
|
||||
$match_template = file_get_contents("match_template.html");
|
||||
$score_template = file_get_contents("score_template.html");
|
||||
|
||||
$scores = "";
|
||||
|
||||
foreach ($output["games"][0]["scores"] as $score)
|
||||
{
|
||||
$name = $score["username"];
|
||||
if ($userid == $score["user_id"])
|
||||
{
|
||||
$name = '<span class="positive-color">' . $name . '</span>';
|
||||
}
|
||||
$beatmap_id = $score["beatmap_id"];
|
||||
|
||||
$all_objects = 0;
|
||||
if (!empty($beatmaps[$beatmap_id]["count_circles"])) $all_objects += $beatmaps[$beatmap_id]["count_circles"];
|
||||
if (!empty($beatmaps[$beatmap_id]["count_sliders"]) && $score["game"]["mode"] != "taiko") $all_objects += $beatmaps[$beatmap_id]["count_sliders"];
|
||||
if (!empty($beatmaps[$beatmap_id]["count_spinners"]) && $score["game"]["mode"] != "taiko") $all_objects += $beatmaps[$beatmap_id]["count_spinners"];
|
||||
|
||||
$maxcombo = $score["maxcombo"];
|
||||
if (!empty($beatmaps[$beatmap_id]["max_combo"]))
|
||||
{
|
||||
if (isset($beatmaps[$beatmap_id]["convert"]) && $beatmaps[$beatmap_id]["convert"] != true)
|
||||
{
|
||||
$maxcombo .= "/" . $beatmaps[$beatmap_id]["max_combo"];
|
||||
}
|
||||
}
|
||||
|
||||
$stars = 0;
|
||||
if (!empty($beatmaps[$beatmap_id]["difficulty_rating"]))
|
||||
{
|
||||
$stars = number_format($beatmaps[$beatmap_id]["difficulty_rating"], 2, '.', '');
|
||||
}
|
||||
|
||||
$version = "";
|
||||
if (!empty($beatmaps[$beatmap_id]["version"]))
|
||||
{
|
||||
$version = $beatmaps[$beatmap_id]["version"];
|
||||
}
|
||||
|
||||
$accuracy = number_format($score["accuracy"], 2, '.', '');
|
||||
$status = '';
|
||||
if ($all_objects > $score["all_notes"])
|
||||
{
|
||||
$status = '<span class="negative-color">QUIT</span>';
|
||||
}
|
||||
else if ($score["pass"] != 1)
|
||||
{
|
||||
$status = '<span class="negative-color">FAILED</span>';
|
||||
}
|
||||
else if (!empty($beatmaps[$beatmap_id]["max_combo"]) && $score["maxcombo"] >= $beatmaps[$beatmap_id]["max_combo"])
|
||||
{
|
||||
$status = '<span class="positive-color">FC</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// $status = '<span class="positive-color">PASS</span>';
|
||||
}
|
||||
|
||||
$mode_text = "?";
|
||||
if ($score["game"]["mode"] == "osu")
|
||||
{
|
||||
// $mode_text = "standard";
|
||||
$mode_text = "osu";
|
||||
}
|
||||
else if ($score["game"]["mode"] == "taiko")
|
||||
{
|
||||
$mode_text = "taiko";
|
||||
}
|
||||
else if ($score["game"]["mode"] == "mania")
|
||||
{
|
||||
$mode_text = "mania";
|
||||
}
|
||||
else if ($score["game"]["mode"] == "fruits")
|
||||
{
|
||||
$mode_text = "catch";
|
||||
}
|
||||
// $mode_text = "osu!" . $mode_text;
|
||||
|
||||
$score_replaced = str_replace(
|
||||
[
|
||||
"[[ PLACE ]]",
|
||||
"[[ NAME ]]",
|
||||
"[[ STATUS ]]",
|
||||
"[[ ACCURACY ]]",
|
||||
"[[ MODE ]]",
|
||||
"[[ MAXCOMBO ]]",
|
||||
"[[ STARS ]]",
|
||||
"[[ VERSION ]]",
|
||||
],
|
||||
[
|
||||
$score["place"],
|
||||
$name,
|
||||
$status,
|
||||
$accuracy,
|
||||
$mode_text,
|
||||
$maxcombo,
|
||||
$stars,
|
||||
$version,
|
||||
],
|
||||
$score_template);
|
||||
|
||||
$scores .= $score_replaced;
|
||||
}
|
||||
|
||||
$cover = "/Unalike/img/covers/c4.jpg";
|
||||
if (!empty($beatmaps[$sample_beatmap]["beatmapset"]["covers"]["cover@2x"]))
|
||||
{
|
||||
$cover = $beatmaps[$sample_beatmap]["beatmapset"]["covers"]["cover@2x"];
|
||||
}
|
||||
else if (!empty($beatmaps[$sample_beatmap]["beatmapset"]["covers"]["cover"]))
|
||||
{
|
||||
$cover = $beatmaps[$sample_beatmap]["beatmapset"]["covers"]["cover"];
|
||||
}
|
||||
|
||||
$artist_components = array();
|
||||
if (!empty($beatmaps[$sample_beatmap]["beatmapset"]["artist"]))
|
||||
{
|
||||
$artist_components[] = $beatmaps[$sample_beatmap]["beatmapset"]["artist"];
|
||||
}
|
||||
if (!empty($beatmaps[$sample_beatmap]["beatmapset"]["creator"]))
|
||||
{
|
||||
$artist_components[] = $beatmaps[$sample_beatmap]["beatmapset"]["creator"];
|
||||
}
|
||||
|
||||
$artist = "";
|
||||
if (!empty($artist_components))
|
||||
{
|
||||
$artist = implode(" // ", $artist_components);
|
||||
}
|
||||
|
||||
$response = str_replace(
|
||||
[
|
||||
"[[ LINK ]]",
|
||||
"[[ TITLE ]]",
|
||||
"[[ ARTIST ]]",
|
||||
"[[ COVER_IMAGE ]]",
|
||||
"[[ SCORES ]]",
|
||||
],
|
||||
[
|
||||
$beatmaps[$sample_beatmap]["url"],
|
||||
$beatmaps[$sample_beatmap]["beatmapset"]["title"],
|
||||
$artist,
|
||||
$cover,
|
||||
$scores,
|
||||
],
|
||||
$match_template);
|
||||
|
||||
echo $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($output);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<div class="card-title">
|
||||
<h3 class="cover-image song-info" style="padding:30px 50px;background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('[[ COVER_IMAGE ]]');background-size:cover;">
|
||||
<a href="[[ LINK ]]" class="link-osu" style="text-decoration:inherit;color:inherit;">
|
||||
<div>
|
||||
<span class="song-title">[[ TITLE ]]</span><br>
|
||||
<span class="song-artist">[[ ARTIST ]]</span>
|
||||
</div>
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div style="margin-top:25px;"><table class="scores">[[ SCORES ]]</table></div>
|
||||
@@ -0,0 +1,12 @@
|
||||
<tr>
|
||||
<td class="rowspan score-place" rowspan="2">#[[ PLACE ]]</td>
|
||||
<td class="rowspan score-name" rowspan="2">[[ NAME ]]</td>
|
||||
<td class="rowspan score-accuracy" rowspan="2">
|
||||
<span class="score-status">[[ STATUS ]]</span>
|
||||
<span>[[ ACCURACY ]]%</span>
|
||||
</td>
|
||||
<td class="row-upper">[[ MODE ]] [[ MAXCOMBO ]]x</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row-lower">[[ STARS ]]★ [[ VERSION ]]</td>
|
||||
</tr>
|
||||
Reference in New Issue
Block a user