Advertisement
Yambam

builder.php

Sep 21st, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Builder (auto-launcher)</title>
  5.         <script>
  6.             refresher = window.setTimeout(function() {
  7.                 window.location.reload();
  8.             },10000);
  9.         </script>
  10.         <style>
  11.             @import 'https://fonts.googleapis.com/css?family=Open+Sans';
  12.            
  13.             body {
  14.                 font-family: Open Sans;
  15.             }
  16.            
  17.             td {
  18.                 padding: .3em;
  19.             }
  20.            
  21.             a {
  22.                 text-decoration: none;
  23.             }
  24.            
  25.             a:hover, a:active, a:focus {
  26.                 text-decoration: underline;
  27.             }
  28.         </style>
  29.     </head>
  30.     <body>
  31.         <table style="width: 50%; min-width: 700px; margin: 0 auto;">
  32.         <col width="30%" />
  33. <?php
  34.     $files = array();
  35.     if ($handle = opendir('build')) {
  36.         while (false !== ($file = readdir($handle))) {
  37.             if ($file != "." && $file != "..") {
  38.                $files[filemtime('build/'.$file)] = $file;
  39.             }
  40.         }
  41.         closedir($handle);
  42.  
  43.         // sort
  44.         ksort($files);
  45.         // find the last modification
  46.         $reallyLastModified = end($files);
  47.  
  48.         foreach($files as $file) {
  49.             $lastModified = date('d F Y, H:i:s',filemtime('build/'.$file));
  50.             $mtime = date("Y-m-d H:i:s",filemtime('build/'.$file));
  51.             $ip = $_SERVER['REMOTE_ADDR'];
  52.             if (in_array(substr($file,-4,4),array('.apk','.exe','.plist'))) {
  53.                 if ($file == $reallyLastModified) {
  54.                     $style = 'background-color: rgba(128,128,128,.2)';
  55.                     //$sha1 = sha1('build/'.$file);
  56.                     if(strpos(@file_get_contents('builder.log'),strval($mtime)."    $file   $ip\r\n")!==false) {
  57.                         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>";
  58.                         continue;
  59.                     } else {
  60.                         file_put_contents('builder.log',strval($mtime)."    $file   $ip\r\n",FILE_APPEND);
  61. ?>
  62.         <script>
  63.             window.setTimeout(function() {
  64.                 window.location.replace('http://imanuelhab.mooo.com/<?php echo 'build/'.$file; ?>');
  65.                 window.clearTimeout(refresher);
  66.             },5000);
  67.         </script>
  68. <?php
  69.                     }
  70.                 } else {
  71.                     $style = '';
  72.                 }
  73.                 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>";
  74.             }
  75.         }
  76.     }
  77. ?>
  78.         </table>
  79.     </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement