Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Page voter.inc.php:
- <!DOCTYPE html>
- <html lang="en">
- <body class="home">
- <?php
- $titre="Voter";
- $active = "4";
- include('./include/class/vote.class.php');
- $serveur= new vote($bdd);
- $infoServeur = $serveur->getServeur();
- $rang = $serveur->getRang();
- $getid = filter_input(INPUT_GET, 'id');
- ?>
- <header id="head" style="background:#181015 url(../assets/images/image.png) no-repeat; background-size: cover; min-height:20px; text-align: center; padding-top:60px; color:white; font-family:'Open sans', Helvetica, Arial; font-weight:300;">
- <div class="container">
- <div class="row">
- <h1 class="lead">Voter</h1><br>
- </div>
- </div>
- </header>
- <?php
- if(isset($_SESSION['utilisateur']['id']))
- {
- if($serveur->traitementVote($getid)[0] > 0)
- {?>
- <section>
- <div class="container">
- <div class="boutique-corps">
- <div id="myTabContent" class="tab-content">
- <center> <h2>Classement</h2></center><br>
- <?php
- $vote = $serveur->getSiteVote();
- foreach($vote as $infoVote){
- ?>
- <div class="col-md-3 col-sm-6 highlight">
- <div class="h-caption"><h4><img class="reseaux_social" src="<?php echo $infoVote["lien_image"]; ?>"><br><br><?php echo $infoVote["nom"]; ?> <br> Vote toutes les <?php echo $infoVote["temps"]; ?> heures. </h4></div>
- <div class="h-body text-center">
- <p> <a style="margin-top: 10px;" href="recompense_vote&<?php echo $getid; ?>&<?php echo $infoVote["id"]; ?>" onClick="window.open('<?php echo $infoVote["lien_vote"]; ?>'); start();" class="btn btn-action btn-lg">Voter</a> </p>
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- <br>
- </section>
- <?php
- }else{
- ?>
- <section>
- <div class="container">
- <div class="boutique-corps">
- <div id="myTabContent" class="tab-content">
- <center> <h2>Classement</h2></center><br>
- <div class="panel panel-primary filterable">
- <div class="panel-heading">
- <h4 class="panel-title"><center>Classement 50 meilleures voteur !</center></h4>
- </div>
- <table class="table">
- <thead>
- <tr class="filters">
- <th>Rang</th>
- <th>Pseudo</th>
- <th>Fonction</th>
- <th>Nombre de votes</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $i=1;
- foreach($rang as $rangVote){
- echo' <tr>
- <td>'.$i.'</td>
- <td>'.$rangVote["pseudo"].'</td>
- <td>'.$rangVote["fonction"].'</td>
- <td>'.$rangVote["nombre_vote"].'</td>
- </tr>';
- $i++;
- }
- ?>
- </tbody>
- </table>
- </div>
- <?php
- foreach($infoServeur as $serveurinfo){
- ?>
- <div class="col-md-3 col-sm-6 highlight">
- <div class="h-caption"><h4><img class="reseaux_social" src="../assets/images/image1.png"><br><br><?php echo $serveurinfo["nom"]; ?></h4></div>
- <div class="h-body text-center">
- <p>Cliquer ici pour voter sur ce serveur!<br> <a style="margin-top: 10px;" href="vote&<?php echo $serveurinfo["id"]; ?>" class="btn btn-action btn-lg">ICI</a></p>
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- </div>
- <br>
- </section>
- <?php
- }
- ?>
- </body>
- <?php
- }else{
- echo'<br>';
- $erreur="Erreur: Vous n'êtes connecté";
- }
- if(isset($erreur))
- {
- $show->showError("<center>".$erreur."</center>");
- }
- ?>
- <?php
- if(isset($success))
- {
- $show->showSuccess("<center>".$success."</center>");
- }
- ?>
- </html>
- //page recompense_vote.inc.php:
- <!DOCTYPE html>
- <html lang="en">
- <body class="home">
- <?php
- $titre="Voter";
- $active = "4";
- include('./include/class/vote.class.php');
- $serveur= new vote($bdd);
- $getid_serveur = filter_input(INPUT_GET, 'id_serveur');
- $getid_lien_vote = filter_input(INPUT_GET, 'id_lien_vote');
- ?>
- <header id="head" style="background:#181015 url(../assets/images/image.png) no-repeat; background-size: cover; min-height:20px; text-align: center; padding-top:60px; color:white; font-family:'Open sans', Helvetica, Arial; font-weight:300;">
- <div class="container">
- <div class="row">
- <h1 class="lead">Vérification Vote</h1><br>
- </div>
- </div>
- </header>
- <section>
- <div class="inner-page-banner padd parallax-banner">
- <div class="container">
- </div>
- </div>
- <div class="container">
- <div class="boutique-corps">
- <div id="myTabContent" class="tab-content">
- <?php
- //Verification vote site: serveurs-minecraft.org
- $ip= $serveur->get_ip();
- $infoServeur2 = $serveur->SelectionSiteVote($getid_lien_vote);
- if($infoServeur2['liensitevote'] == "serveurs-minecraft.org")
- {
- if($serveur->Verif_date(time(), $_SESSION['utilisateur']['pseudo'], $infoServeur2['liensitevote']) == "ok")
- {
- $identifiant_serveur= str_replace('http://www.serveurs-minecraft.org/vote.php?id=', '', $infoServeur2['lien_vote']);
- $VefiVote = $serveur->VerificationVote($ip,$identifiant_serveur);
- if( $VefiVote == 1)
- {
- $historique_vote = $serveur-> historique_vote($infoServeur2['liensitevote']);
- if($historique_vote == "1")
- {
- $recompense_vote = $serveur-> recompense_vote($infoServeur2['id']);
- $rcon[$infoServeur2['rang']]->connect();
- $max = sizeof($recompense_vote);
- for($i=0;$i<$max;$i++)
- {
- $rcon[$infoServeur2['rang']]->sendCommand($recompense_vote[''.$i.'']);
- }
- }else{
- $erreur="Erreur, veuillez contacter l'administrateur du site web";
- }
- }else{
- echo "Erreur de vote si vous avez bien voter attendez la page va se rafraichir";
- //rafraichir page
- header("refresh:5");
- }
- }else{
- echo "Erreur: Vous avez voter il y a moins de 24h";
- }
- //Verification vote site: serveursminecraft.org
- }else if ($infoServeur2['liensitevote'] == "serveursminecraft.org"){
- if($serveur->Verif_date(time(), $_SESSION['utilisateur']['pseudo'], $infoServeur2['liensitevote']) == "ok")
- {
- $id_server = str_replace('https://www.serveursminecraft.org/serveur.php?id=', '', $infoServeur2['lien_vote']);
- $peutVoter = $serveur->peutVoter($id_server, $ip);
- if($peutVoter == 1){
- echo"Vous n'avez pas voter aujourd'hui, si vous venez de voter attendez la page va se rafraichir";
- //rafraichir page
- header("refresh:5");
- }else if($peutVoter > 86100)
- {
- $historique_vote = $serveur-> historique_vote($infoServeur2['liensitevote']);
- if($historique_vote == "1")
- {
- $recompense_vote = $serveur-> recompense_vote($infoServeur2['id']);
- $rcon[$infoServeur2['rang']]->connect();
- $max = sizeof($recompense_vote);
- for($i=0;$i<$max;$i++)
- {
- $rcon[$infoServeur2['rang']]->sendCommand($recompense_vote[''.$i.'']);
- }
- }else{
- $erreur="Erreur, veuillez contacter l'administrateur du site web";
- }
- }else{
- echo"Vous avez déja voter aujourd'hui veuillez attendre ".$peutVoter/64 ." Minutes";
- }
- }
- }else{
- echo "Erreur: Vous avez voter il y a moins de 24h";
- }
- ?>
- </div>
- </div>
- <br>
- </section>
- </body>
- </html>
- //connection au serveur minecraft (rcon.class.action.php)
- <?php
- require_once("rcon.class.php");
- class connection_rcon
- {
- private $bdd; //bdd = database handler.
- public function __construct($database)
- {
- $this->bdd = $database;
- }
- public function creationConnectionServeur()
- {
- $rcon_connection= array(array());
- $query = $this->bdd->prepare("SELECT * FROM connection");
- $query->execute();
- $i=1;
- while($row = $query->fetch()) {
- $host = $row['ip_serveur']; // Server host name or IP
- $port = $row['port_rcon']; // Port rcon is listening on
- $password = $row['mot_de_passe']; // rcon.password setting set in server.properties
- $timeout = 3; // How long to timeout.
- ${"connection_rcon" . $i} = new Rcon($host, $port, $password, $timeout);
- $rcon_connection[]= ${"connection_rcon" . $i};
- $i++;
- }
- $query->closeCursor();
- return $rcon_connection;
- }
- }
- ?>
- //class vote.class.php
- <?php
- class vote
- {
- private $bdd; //bdd = database handler.
- public function __construct($database)
- {
- $this->bdd = $database;
- }
- public function getServeur()
- {
- $query = $this->bdd->prepare('SELECT * FROM `connection`');
- try
- {
- $query->execute();
- }
- catch(PDOException $e)
- {
- die($e->getMessage());
- }
- return $query->fetchAll();
- }
- public function getRang()
- {
- $query = $this->bdd->prepare('SELECT * FROM `membres` ORDER BY nombre_vote DESC LIMIT 50');
- try
- {
- $query->execute();
- }
- catch(PDOException $e)
- {
- die($e->getMessage());
- }
- return $query->fetchAll();
- }
- public function traitementVote($id)
- {
- $query = $this->bdd->prepare("SELECT COUNT(id) FROM connection WHERE id = ?");
- $query->bindValue(1, $id);
- try
- {
- $query->execute();
- return $query->fetch();
- }
- catch(PDOException $e)
- {
- die($e->getMessage());
- }
- }
- public function getSiteVote()
- {
- $query = $this->bdd->prepare('SELECT * FROM `vote`');
- try
- {
- $query->execute();
- }
- catch(PDOException $e)
- {
- die($e->getMessage());
- }
- return $query->fetchAll();
- }
- public function get_ip() {
- // IP si internet partagé
- if (isset($_SERVER['HTTP_CLIENT_IP'])) {
- return $_SERVER['HTTP_CLIENT_IP'];
- }
- // IP derrière un proxy
- elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- return $_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- // Sinon : IP normale
- else {
- return (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '');
- }
- }
- public function VerificationVote($ip,$identifiant_serveur)
- {
- $is_valid_vote = file_get_contents('http://www.serveurs-minecraft.org/api/is_valid_vote.php?id='.$identifiant_serveur.'&ip='.$ip.'&duration=5');
- return $is_valid_vote;
- }
- public function SelectionSiteVote($id)
- {
- $query = $this->bdd->prepare('SELECT * FROM `vote` WHERE id = ?');
- $query->bindValue(1, $id);
- try
- {
- $query->execute();
- }
- catch(PDOException $e)
- {
- die($e->getMessage());
- }
- return $query->fetch();
- }
- public function Verif_date($date_actuel, $pseudo, $site_vote)
- {
- $query = $this->bdd->prepare('SELECT * FROM `historique_vote` WHERE site_vote = ? pseudo = ?');
- $query->bindValue(1, $site_vote);
- $query->bindValue(2, $pseudo);
- $query->execute();
- $resultats = $query->fetch(PDO::FETCH_OBJ);
- if($date_actuel - $resultats['heure_dernier_vote'] >= 24*3600)
- {
- $temps= "ok";
- }else{
- $temps= "erreur";
- }
- return $temps;
- }
- public function recompense_vote($serveur_id)
- {
- $query = $this->bdd->prepare('SELECT * FROM `recompense_vote` WHERE id_serveur = ?');
- $query->bindValue(1, $serveur_id);
- $query->execute();
- $resultats = $query->fetchAll(PDO::FETCH_OBJ);
- foreach($resultats as $vote){
- $resultGain = $vote['pourcentage_chance']*100/mt_rand(1,100);
- if($resultGain>=100){ #>= 100 car le résultat peut être plus fort que 100 avec le calcul actuel
- $commande1=str_replace('<!pseudo!>', '$_SESSION[\'utilisateur\'][\'id\']', $vote['commande']);
- $commande2= str_replace('<!nom_recompense!>', '$vote[\'nom\']', $commande1);
- $commande_a_executer = explode(";", $commande2);
- }
- }
- return $commande_a_executer;
- }
- public function historique_vote($nom_site_vote)
- {
- $query = $this->bdd->prepare('INSERT INTO `historique_vote` WHERE id_serveur = ?');
- $query = $this->bdd->prepare('INSERT INTO `historique_vote`(`id`, `pseudo`, `site_vote`, `heure_dernier_vote`) VALUES (?, ?, ?, ?) ');
- $query->bindValue(1, null);
- $query->bindValue(2, $_SESSION['utilisateur']['pseudo']);
- $query->bindValue(3, $nom_site_vote);
- $query->bindValue(4,time());
- try
- {
- $query->execute();
- $ajout_historique= "1";
- }
- catch(PDOException $e)
- {
- $ajout_historique= "0";
- die($e->getMessage());
- }
- return $ajout_historique;
- }
- public function peutVoter($id_serveur, $adress_ip)
- {
- $api_adress = "https://www.serveursminecraft.org/sm_api/peutVoter.php?id=".$id_serveur."&ip=".$adress_ip;
- $api_result = @file_get_contents($api_adress);
- if($api_result == "true")
- return true;
- else
- return $api_result; // la variable donne le nombre de seconde restant.
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement