mirror of
https://github.com/hakasenyang/osu-tournament-php
synced 2026-08-22 03:03:07 +09:00
Support ripple server
This commit is contained in:
+59
-18
@@ -32,6 +32,16 @@
|
||||
* @var [int]
|
||||
*/
|
||||
private $mode;
|
||||
/**
|
||||
* [$server osu! server
|
||||
* 0 or osu = osu! Server
|
||||
* 1 or ripple = Ripple Server
|
||||
* other = return false
|
||||
*
|
||||
* using data : only use osu or ripple (string)]
|
||||
* @var [int or string]
|
||||
*/
|
||||
public $server;
|
||||
/**
|
||||
* Temp data
|
||||
* [$data_profile description]
|
||||
@@ -88,21 +98,48 @@
|
||||
* [CheckUser Get osu! UserID]
|
||||
* @param [string] $osuid [osu! ID]
|
||||
*/
|
||||
public function CheckUser($osuid, $mode)
|
||||
public function CheckUser($osuid, $mode, $server='osu')
|
||||
{
|
||||
$this->ResetObject();
|
||||
$this->SelectMode($mode);
|
||||
// Transfer osu! ID to Num
|
||||
switch($server)
|
||||
{
|
||||
case 'osu':
|
||||
case 1:
|
||||
$this->server = 'osu';
|
||||
$this->data_profile = $this->Parser->WEBParsing('https://osu.ppy.sh/u/' . $osuid);
|
||||
$this->OsuID = $this->Parser->splits($this->data_profile, 'var userId = ', ';');
|
||||
$this->RealID = $this->Parser->splits($this->data_profile, '<title>', '\'s profile</title>');
|
||||
break;
|
||||
case 'ripple':
|
||||
case 2:
|
||||
$this->server = 'ripple';
|
||||
$this->data_profile = $this->Parser->WEBParsing('https://ripple.moe/u/' . $osuid);
|
||||
$this->OsuID = $this->Parser->splits($this->data_profile, 'window.userID = \'', '\';');
|
||||
$this->RealID = $this->Parser->splits($this->data_profile, '<title>', ''s profile - Ripple');
|
||||
break;
|
||||
default:
|
||||
$this->ResetObject();
|
||||
return false;
|
||||
}
|
||||
if(empty($this->OsuID) || empty($this->RealID))
|
||||
{
|
||||
$this->ResetObject();
|
||||
return false;
|
||||
}
|
||||
|
||||
switch($this->server)
|
||||
{
|
||||
case 'osu':
|
||||
$this->Occupation = $this->Parser->splits($this->data_profile, '<div title=\'Occupation\'><i class=\'icon-pencil\'></i><div>', '</div></div>');
|
||||
break;
|
||||
case 'ripple':
|
||||
$this->Occupation = $this->Parser->splits($this->data_profile, '(aka <b>', '</b>)');
|
||||
break;
|
||||
default:
|
||||
$this->ResetObject();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->GetOccupation();
|
||||
$this->GetUserData();
|
||||
@@ -110,21 +147,7 @@
|
||||
return $this->OsuID;
|
||||
}
|
||||
/**
|
||||
* Not using this function.
|
||||
*/
|
||||
/*
|
||||
private function CheckOccupation()
|
||||
{
|
||||
if(empty($this->OsuID))
|
||||
throw new \Exception('Please, CheckUser(OsuID) first!');
|
||||
if(empty($this->Occupation_Set))
|
||||
$this->GetOccupation();
|
||||
|
||||
if ($this->Occupation_Set === $this->Occupation)
|
||||
return true;
|
||||
else
|
||||
return $this->Occupation;
|
||||
}
|
||||
* [GetOccupation Get user occupation data]
|
||||
*/
|
||||
private function GetOccupation()
|
||||
{
|
||||
@@ -138,11 +161,16 @@
|
||||
$this->Occupation_Set = substr(md5($this->RealID . $this->OsuID . date('Ymd') . $this->mode), 0, 20);
|
||||
return $this->Occupation_Set;
|
||||
}
|
||||
/**
|
||||
* [GetUserData Get user data!]
|
||||
*/
|
||||
private function GetUserData()
|
||||
{
|
||||
if(empty($this->OsuID))
|
||||
throw new \Exception('Please, CheckUser(OsuID) first!');
|
||||
|
||||
switch($this->server)
|
||||
{
|
||||
case 'osu':
|
||||
if(empty($this->data_userdata))
|
||||
$this->data_userdata = $this->Parser->WEBParsing('https://osu.ppy.sh/pages/include/profile-general.php?u=' . $this->OsuID . '&m=' . $this->mode);
|
||||
else
|
||||
@@ -159,7 +187,20 @@
|
||||
}
|
||||
else
|
||||
return false;
|
||||
break;
|
||||
case 'ripple':
|
||||
$this->Playcount = str_replace(',', NULL, $this->Parser->splits($this->data_profile, '<td class="right aligned">', '</td>', 6 + ($this->mode * 9)));
|
||||
$this->Performance = str_replace(',', NULL, $this->Parser->splits($this->data_profile, '<td class="right aligned">', '</td>', 3 + ($this->mode * 9)));
|
||||
$this->Rank = str_replace('#', NULL, $this->Parser->splits($this->data_profile, '<td class="right aligned">', '</td>', 1 + ($this->mode * 9)));
|
||||
break;
|
||||
default:
|
||||
$this->ResetObject();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* [ResetObject All reset using data]
|
||||
*/
|
||||
private function ResetObject()
|
||||
{
|
||||
foreach ($this as $key => $value)
|
||||
|
||||
@@ -25,19 +25,35 @@
|
||||
echo 'Performance : ' . $Check->Performance;
|
||||
echo '<br>';
|
||||
echo 'Ranking : ' . $Check->Rank;
|
||||
echo '<br>';
|
||||
echo 'Server : ';
|
||||
switch($Check->server)
|
||||
{
|
||||
case 'osu':
|
||||
echo 'osu!';
|
||||
break;
|
||||
case 'ripple':
|
||||
echo 'Ripple';
|
||||
break;
|
||||
default:
|
||||
echo 'No';
|
||||
}
|
||||
echo '<br><br>';
|
||||
}
|
||||
$Check->CheckUser(2558286, 0);
|
||||
$Check->CheckUser('Hakase', 0, 2);
|
||||
GetDataTest();
|
||||
|
||||
$Check->CheckUser('angelsIm', 0);
|
||||
$Check->CheckUser('Hakase', 1, 2);
|
||||
GetDataTest();
|
||||
|
||||
$Check->CheckUser('didisksks', 0);
|
||||
$Check->CheckUser(5173, 0, 2);
|
||||
GetDataTest();
|
||||
|
||||
$Check->CheckUser('aergn8i39jf', 1, 2);
|
||||
GetDataTest();
|
||||
|
||||
$Check->CheckUser('peppy', 0);
|
||||
GetDataTest();
|
||||
|
||||
$Check->CheckUser('banchobot', 0);
|
||||
$Check->CheckUser('aergn8i39jf', 1, 1);
|
||||
GetDataTest();
|
||||
Reference in New Issue
Block a user