Skip to content

Instantly share code, notes, and snippets.

@fey

fey/parser.php Secret

Created Aug 29, 2018
Embed
What would you like to do?
мой первый говнокод
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Population</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4">
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";
$dbtable = "";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
require_once 'simple_html_dom.php';
$html = file_get_html('https://valkyrie-wow.org/realms/'); //работает и с https://
$population = $html->find('div.cols-col-25', 0)->next_sibling ()->find('.realm-body', 0)->children(1)->plaintext;
$population = preg_replace("/[^0-9]/", '', $population);
echo $population, '</br>';
//ADDING NEW ENTRIES
$sql = "INSERT INTO serverINFO (population, timestamp)
VALUES ($population, now())";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully", "</br>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$sql = "SELECT id, population, timestamp FROM serverINFO";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo '<table class="table table-striped table-bordered table-hover">';
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<td>'. $row["timestamp"]. "</td><td>" .$row["population"]."</td></tr>";
}
echo '</table>';
} else {
echo "0 results";
}
mysqli_close($conn);
$conn->close();
?>
</div></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment