diff --git a/include/check.php b/include/check.php
index 747a6af..f4f90c4 100644
--- a/include/check.php
+++ b/include/check.php
@@ -8,14 +8,19 @@
*/
private $Parser;
/**
+ * [$RealID transfer osu! UserID to ID]
* [$OsuID transfer osu! ID to UserID]
+ * @var [string]
+ */
+ public $RealID, $OsuID;
+ /**
* [$PlayCount User Playcount]
* [$Performance User Performance]
* [$Rank User Ranking]
* [$Occupation Check user occupation]
* @var [string]
*/
- private $OsuID, $PlayCount, $Performance, $Rank, $Occupation;
+ private $PlayCount, $Performance, $Rank, $Occupation;
/**
* [$mode osu! mode
* 0 = osu! standard (standard)
@@ -24,8 +29,10 @@
* 3 = osu!mania (mania)
* ]
* @var [int]
+ * [$occu User Occupation Data]
+ * @var [string]
*/
- private $mode;
+ private $mode, $occu;
/**
* [$data_profile description]
* [$data_userdata description]
@@ -51,7 +58,7 @@
* ]
* @var [int]
*/
- public function SelectMode($mode)
+ private function SelectMode($mode)
{
switch(strtolower($mode))
{
@@ -81,11 +88,17 @@
* [CheckUser Get osu! UserID]
* @param [string] $osuid [osu! ID]
*/
- public function CheckUser($osuid)
+ public function CheckUser($osuid, $mode)
{
+ if ($osuid !== $this->OsuID && $osuid !== $this->RealID)
+ $this->ResetObject();
+
+ $this->SelectMode($mode);
+
// Transfer osu! ID to Num
$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, '
', '\'s profile');
if(empty($this->OsuID))
return false;
@@ -94,22 +107,49 @@
}
public function CheckOccupation()
{
- /**
- * md5 = $OsuID|date('Ymd')|$mode
- * 20 string (substr)
- */
- $occu = substr(md5($this->OsuID.'|' . date('Ymd') . '|' . $this->mode), 0, 20);
- if ($occu === $this->Occupation)
+ if(empty($this->OsuID))
+ throw new \Exception('Please, CheckUser(OsuID) first!');
+ if(empty($this->occu))
+ $this->GetOccupation();
+
+ if ($this->occu === $this->Occupation)
return true;
else
- return $occu;
+ return $this->Occupation;
+ }
+ public function GetOccupation()
+ {
+ /**
+ * md5 = $RealID / $OsuID / date('Ymd') / $mode
+ * 20 string (substr)
+ */
+ if(empty($this->OsuID))
+ throw new \Exception('Please, CheckUser(OsuID) first!');
+ if(empty($this->occu))
+ $this->occu = substr(md5($this->RealID . $this->OsuID . date('Ymd') . $this->mode), 0, 20);
+ return $this->occu;
}
private function GetUserData()
{
if(empty($this->OsuID))
throw new \Exception('Please, CheckUser(OsuID) first!');
+
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
+ return true;
+
+ if (strpos($this->data_userdata, 'This user has not yet played any ranked maps in osu! mode.') === true)
+ return false;
+
+ if (strpos($this->data_userdata, 'This user has not played enough, or has not played recently.') === false)
+ {
+ $this->PlayCount = $this->Parser->splits($this->data_userdata, 'Play Count: ', '');
+ $this->Performance = str_replace(',', NULL, $this->Parser->splits($this->data_userdata, 'Performance: ', 'pp'));
+ $this->Rank = str_replace(',', NULL, $this->Parser->splits($this->data_userdata, 'pp (#', ')'));
+ }
+ else
+ return false;
}
/**
* [CheckPlayCount Get PlayCount]
@@ -117,23 +157,16 @@
public function CheckPlayCount()
{
$this->GetUserData();
- $this->PlayCount = $this->Parser->splits($this->data_userdata, 'Play Count: ', '');
return $this->PlayCount;
}
public function CheckPerformance()
{
$this->GetUserData();
- if (strpos($this->data_userdata, 'This user has not played enough, or has not played recently.'))
- return false;
- $this->Performance = str_replace(',', NULL, $this->Parser->splits($this->data_userdata, 'Performance: ', 'pp'));
return $this->Performance;
}
public function CheckRank()
{
$this->GetUserData();
- if (strpos($this->data_userdata, 'This user has not played enough, or has not played recently.'))
- return false;
- $this->Rank = str_replace(',', NULL, $this->Parser->splits($this->data_userdata, 'pp (#', ')'));
return $this->Rank;
}
public function ResetObject()
diff --git a/test.php b/test.php
index 1b8f401..017bb6e 100644
--- a/test.php
+++ b/test.php
@@ -1,20 +1,31 @@
SelectMode(0);
- echo $Check->CheckUser('peppy');
+ $Check->CheckUser(2558286, 0);
+ echo $Check->RealID . ' (' . $Check->OsuID . ')';
+ $occu = $Check->CheckOccupation();
+
if ($Check->CheckOccupation() === true)
echo '
You are applied!';
else
- echo '
Please change occupation to ' . $Check->CheckOccupation();
+ echo '
Please change occupation to ' . $Check->GetOccupation() . '
Your Occupation : ' . $occu;
echo '
';
+
+ if (empty($Check->CheckPerformance()))
+ echo 'Error
';
echo 'Performance : ' . $Check->CheckPerformance();
echo '
';
echo 'Ranking : ' . $Check->CheckRank();
+ echo '
';
- $Check->ResetObject();
+ $Check->CheckUser('Angelsim', 0);
+ echo $Check->RealID . ' (' . $Check->OsuID . ')';
+ $occu = $Check->CheckOccupation();
- echo $Check->CheckUser('ExampleToNotUser');
+ if ($Check->CheckOccupation() === true)
+ echo '
You are applied!';
+ else
+ echo '
Please change occupation to ' . $Check->GetOccupation() . '
Your Occupation : ' . $occu;
echo '
';
echo 'Performance : ' . $Check->CheckPerformance();
\ No newline at end of file