mirror of
https://github.com/hakasenyang/osu-tournament-php
synced 2026-08-22 03:03:07 +09:00
Add files
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'include/db.php';
|
||||||
|
require_once 'include/webparser.php';
|
||||||
|
|
||||||
|
$Parser = new OsuTournament\Parser();
|
||||||
|
$DB = new OsuTournament\DB('127.0.0.1', 'example', 'example', 'example');
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
namespace OsuTournament;
|
||||||
|
/**
|
||||||
|
* Osu Tournament for PHP
|
||||||
|
* In production.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DB {
|
||||||
|
public $mysql;
|
||||||
|
public function __construct($ip, $dbid, $dbpw, $dbnm)
|
||||||
|
{
|
||||||
|
$this->mysql = new mysqli($ip, $dbid, $dbpw, $dbnm);
|
||||||
|
}
|
||||||
|
public function Query($query)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
public function Insert($query)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class Parser {
|
namespace OsuTournament;
|
||||||
|
class Parser
|
||||||
|
{
|
||||||
private $httph = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36';
|
private $httph = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36';
|
||||||
public function splits($data, $first, $end, $num = 1)
|
public function splits($data, $first, $end, $num = 1)
|
||||||
{
|
{
|
||||||
@@ -8,20 +10,18 @@
|
|||||||
$temp = $temp[0];
|
$temp = $temp[0];
|
||||||
return $temp;
|
return $temp;
|
||||||
}
|
}
|
||||||
public function WEBParsing($url, $cookie=NULL, $headershow=TRUE, $postparam=NULL, $otherheader=NULL)
|
public function WEBParsing($url, $cookie = NULL, $headershow = TRUE, $postparam = NULL, $otherheader = NULL)
|
||||||
{
|
{
|
||||||
$uri = parse_url($url);
|
|
||||||
if (!isset($uri['port'])) $uri['port'] = 80;
|
|
||||||
if (!isset($uri['path'])) $uri['path'] = "/";
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
$opts = array(CURLOPT_RETURNTRANSFER => true,
|
$opts = array(
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_URL => $url,
|
CURLOPT_URL => $url,
|
||||||
CURLOPT_TIMEOUT => 10,
|
CURLOPT_TIMEOUT => 10,
|
||||||
CURLOPT_CONNECTTIMEOUT => 5,
|
CURLOPT_CONNECTTIMEOUT => 5,
|
||||||
CURLOPT_SSL_VERIFYPEER => FALSE,
|
CURLOPT_SSL_VERIFYPEER => FALSE,
|
||||||
CURLOPT_HEADER => $headershow,
|
CURLOPT_HEADER => $headershow,
|
||||||
CURLOPT_USERAGENT => $this->httph
|
CURLOPT_USERAGENT => $this->httph
|
||||||
);
|
);
|
||||||
curl_setopt_array($ch, $opts);
|
curl_setopt_array($ch, $opts);
|
||||||
if ($otherheader) curl_setopt($ch, CURLOPT_HTTPHEADER, $otherheader);
|
if ($otherheader) curl_setopt($ch, CURLOPT_HTTPHEADER, $otherheader);
|
||||||
if ($cookie) curl_setopt($ch, CURLOPT_COOKIE, $cookie);
|
if ($cookie) curl_setopt($ch, CURLOPT_COOKIE, $cookie);
|
||||||
Reference in New Issue
Block a user