Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //FetchVotes.php (c) by Benni1000 | use only on minecraft-server.eu
- //Configuration///////////////////////////////////////////
- $link = "http://minecraft-server.eu/?go=server&id=xxx"; //Your Server id
- $expireTime = 5; //Expire Time in Minutes
- $msg = "Votes: "; //Message, you can leave it empty
- $file = "votes.vdb"; //File name (file will be created)
- /////////////////////////////////////////////////////////
- //functions
- function fetchVotes($link) {
- $votes1 = explode("<td colspan=1>",file_get_contents($link));
- $votes2 = explode("</td>",$votes1[1]);
- return $votes2[0];
- }
- function writeVotes($file,$link,$expireTime) {
- if(file_exists($file)) {
- unlink($file);
- }
- $handle = fopen($file,"w");
- fwrite($handle,strtotime('+'.$expireTime.' minutes').",".fetchVotes($link)) or die("Critical IO Error!");
- fclose($handle);
- }
- //Main
- if(!file_exists($file)) {
- writeVotes($file,$link,$expireTime);
- }
- $handle = fopen($file,"r");
- $exploded = explode(",",fread($handle, filesize($file)));
- $Votes = $exploded[1];
- $Date = $exploded[0];
- if(strtotime("now") > $Date) {
- writeVotes($file,$link,$expireTime);
- $handle = fopen($file,"r");
- $exploded = explode(",",fread($handle, filesize($file)));
- echo $msg.$exploded[1];
- }
- else {
- echo $msg.$Votes;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement