From 47107c52cb50b980f07acb0c458ac6f422e3a07d Mon Sep 17 00:00:00 2001 From: hakasenyang Date: Sat, 10 Dec 2016 17:17:54 +0900 Subject: [PATCH] Add function --- include.php | 8 ++++++-- include/check.php | 42 ++++++++++++++++++++++++++++++++++++++++++ include/db.php | 2 +- include/index.php | 1 + include/webparser.php | 4 ++-- test.php | 5 +++++ 6 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 include/check.php create mode 100644 include/index.php create mode 100644 test.php diff --git a/include.php b/include.php index d2350bf..7943914 100644 --- a/include.php +++ b/include.php @@ -1,6 +1,10 @@ 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, 'Play Count: ', ''); + return $this->PlayCount; + } + } diff --git a/include/db.php b/include/db.php index b25cf5b..188d659 100644 --- a/include/db.php +++ b/include/db.php @@ -19,4 +19,4 @@ { // ... } - } \ No newline at end of file + } diff --git a/include/index.php b/include/index.php new file mode 100644 index 0000000..68300b8 --- /dev/null +++ b/include/index.php @@ -0,0 +1 @@ +It works! diff --git a/include/webparser.php b/include/webparser.php index c8899a9..b3575ab 100644 --- a/include/webparser.php +++ b/include/webparser.php @@ -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; } - } \ No newline at end of file + } diff --git a/test.php b/test.php new file mode 100644 index 0000000..70e73f0 --- /dev/null +++ b/test.php @@ -0,0 +1,5 @@ +CheckUser('Angelsim'); + echo '
'; + echo $Check->CheckPlayCount();