mirror of
https://github.com/hakasenyang/osu-tournament-php
synced 2026-08-22 03:03:07 +09:00
Add function
This commit is contained in:
+6
-2
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
require_once 'include/db.php';
|
||||
require_once 'include/webparser.php';
|
||||
require_once 'include/check.php';
|
||||
|
||||
$Parser = new OsuTournament\Parser();
|
||||
$DB = new OsuTournament\DB('127.0.0.1', 'example', 'example', 'example');
|
||||
$Check = new OsuTournament\Check();
|
||||
/**
|
||||
* In production DB.
|
||||
*/
|
||||
// $DB = new OsuTournament\DB('127.0.0.1', 'example', 'example', 'example');
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace OsuTournament;
|
||||
class Check
|
||||
{
|
||||
/**
|
||||
* [$Parser Load parser class]
|
||||
* @var [class]
|
||||
*/
|
||||
private $Parser;
|
||||
/**
|
||||
* [$OsuID transfer osu! ID to UserID]
|
||||
* [$PlayCount User Playcount]
|
||||
* [$Performance User Performance]
|
||||
* [$Rank User Ranking]
|
||||
* [$Occupation Check user occupation]
|
||||
* @var [string]
|
||||
*/
|
||||
private $OsuID, $PlayCount, $Performance, $Rank, $Occupation;
|
||||
/**
|
||||
* Other data
|
||||
* In production.
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->Parser = new Parser();
|
||||
}
|
||||
public function CheckUser($osuid)
|
||||
{
|
||||
// Transfer osu! ID to Num
|
||||
$data = $this->Parser->WEBParsing('https://osu.ppy.sh/u/'.$osuid);
|
||||
$this->OsuID = $this->Parser->splits($data, 'var userId = ', ';');
|
||||
if(!isset($this->OsuID)) return 0;
|
||||
return $this->OsuID;
|
||||
}
|
||||
public function CheckPlayCount()
|
||||
{
|
||||
$data = $this->Parser->WEBParsing('https://osu.ppy.sh/pages/include/profile-general.php?u='. $this->OsuID .'&m=0');
|
||||
$this->PlayCount = $this->Parser->splits($data, '<b>Play Count</b>: ', '</div>');
|
||||
return $this->PlayCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
It works!
|
||||
@@ -34,7 +34,7 @@
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($curl_errno > 0)
|
||||
return 0;
|
||||
$this->ErrorEcho(14, 'Connect Error!!!');
|
||||
return ($data) ? $data : false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user