Advertisement
Yambam

Builder (auto-launcher)

Sep 26th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.62 KB | None | 0 0
  1. <?php
  2.     $host = "localhost"; //Add your SQL Server host here
  3.     $user = "root"; //SQL Username
  4.     $pass = @file_get_contents('/home/pi/.mysql_passwd'); //SQL Password
  5.     $dbname = "bezoekers_imanuel"; //SQL Database Name
  6.     $con = mysqli_connect($host,$user,$pass,$dbname);
  7.     if (mysqli_connect_errno($con)) {
  8.         echo "Error: " . mysqli_connect_error();
  9.     }
  10. ?>
  11. <!DOCTYPE html>
  12. <html>
  13.     <head>
  14.         <title>Builder (auto-launcher)</title>
  15.         <script>
  16.             refresher = window.setTimeout(function() {
  17.                 window.location.reload();
  18.             },10000);
  19.         </script>
  20.         <style>
  21.             @import 'https://fonts.googleapis.com/css?family=Open+Sans';
  22.            
  23.             body {
  24.                 font-family: Open Sans;
  25.             }
  26.            
  27.             td {
  28.                 padding: .3em;
  29.             }
  30.            
  31.             a {
  32.                 text-decoration: none;
  33.             }
  34.            
  35.             a:hover, a:active, a:focus {
  36.                 text-decoration: underline;
  37.             }
  38.         </style>
  39.     </head>
  40.     <body>
  41.         <table style="width: 50%; min-width: 700px; margin: 0 auto;">
  42.         <col width="30%" />
  43. <?php
  44.     $files = array();
  45.     if ($handle = opendir('build')) {
  46.         while (false !== ($file = readdir($handle))) {
  47.             if ($file != "." && $file != "..") {
  48.                $files[filemtime('build/'.$file)] = $file;
  49.             }
  50.         }
  51.         closedir($handle);
  52.  
  53.         // sort
  54.         ksort($files);
  55.         // find the last modification
  56.         $reallyLastModified = end($files);
  57.        
  58.         $fileTypes = array('.apk','.exe','.zip');
  59.         $fileTypesDefault = true;
  60.        
  61.         if (isset($_GET['apk'])) {
  62.             if ($fileTypesDefault) {
  63.                 $fileTypes = array();
  64.             }
  65.             $fileTypes[] = '.apk';
  66.             $fileTypesDefault = false;
  67.         }
  68.        
  69.         if (isset($_GET['exe'])) {
  70.             if ($fileTypesDefault) {
  71.                 $fileTypes = array();
  72.             }
  73.             $fileTypes[] = '.apk';
  74.             $fileTypesDefault = false;
  75.         }
  76.        
  77.         if (isset($_GET['zip'])) {
  78.             if ($fileTypesDefault) {
  79.                 $fileTypes = array();
  80.             }
  81.             $fileTypes[] = '.apk';
  82.             $fileTypesDefault = false;
  83.         }
  84.        
  85.         if (isset($_GET['gmz'])) {
  86.             if ($fileTypesDefault) {
  87.                 $fileTypes = array();
  88.             }
  89.             $fileTypes[] = '.gmz';
  90.             $fileTypesDefault = false;
  91.         }
  92.  
  93.         foreach($files as $file) {
  94.             $lastModified = date('d F Y, H:i:s',filemtime('build/'.$file));
  95.             $mtime = date("Y-m-d H:i:s",filemtime('build/'.$file));
  96.             if (in_array(substr($file,-4,4),$fileTypes)&&(isset($_GET['debug'])||!stristr($file,'debug'))) {
  97.                 if ($file == $reallyLastModified) {
  98.                     $style = 'background-color: rgba(128,128,128,.2)';
  99.                     $sha1 = mysqli_escape_string($con,sha1('build/'.$file));
  100.                     $file_sql = mysqli_escape_string($con,$file);
  101.                     $ip = mysqli_escape_string($con,$_SERVER['REMOTE_ADDR']);
  102.                     $result = mysqli_query($con,"SELECT * FROM builder WHERE mtime = '$mtime' AND filename = '$file_sql' AND ip = '$ip'");
  103.                     if (mysqli_num_rows($result)) {
  104.                         echo "<tr style=\"background-color: rgba(255,0,0,.2)\"><!--<td><input type=\"checkbox\" name=\"box[]\"></td>--><td><a href=\"build/$file\" target=\"_blank\">$file</a></td><td>$lastModified</td></tr>\r\n";
  105.                         continue;
  106.                     } else {
  107.                         $result = mysqli_query($con,"INSERT INTO builder (mtime,filename,ip) VALUES ('$mtime','$file_sql','$ip')");
  108. ?>
  109.         <script>
  110.             window.setTimeout(function() {
  111.                 window.location.replace('http://imanuelhab.mooo.com/<?php echo 'build/'.$file; ?>');
  112.                 window.clearTimeout(refresher);
  113.             },5000);
  114.         </script>
  115. <?php
  116.                         echo "<audio src=\"sounds/VANESSA.wav\" autoplay=\"\">Your browser does not support the <code>audio</code> element.</audio>\r\n";
  117.                     }
  118.                 } else {
  119.                     $style = '';
  120.                 }
  121.                 echo "<tr style=\"$style\"><!--<td><input type=\"checkbox\" name=\"box[]\"></td>--><td><a href=\"build/$file\" target=\"_blank\">$file</a></td><td>$lastModified</td></tr>\r\n";
  122.             }
  123.         }
  124.     }
  125. ?>
  126.         </table>
  127.     </body>
  128. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement