Add function

This commit is contained in:
hakasenyang
2016-12-10 17:17:54 +09:00
parent 0707a6d6d5
commit 47107c52cb
6 changed files with 57 additions and 5 deletions
+6 -2
View File
@@ -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');
+42
View File
@@ -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;
}
}
+1
View File
@@ -0,0 +1 @@
It works!
+1 -1
View File
@@ -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;
}
}
+5
View File
@@ -0,0 +1,5 @@
<?php
require_once 'include.php';
echo $Check->CheckUser('Angelsim');
echo '<br>';
echo $Check->CheckPlayCount();