[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/swftools/shared/1pixelout/upgrade/ -> index.php (source)

   1  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   2  <html xmlns="http://www.w3.org/1999/xhtml">
   3  <head>
   4  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
   5  <title>1 Pixel Out Audio Player Upgrade wizard</title>
   6  <script type="text/javascript">
   7  self.focus();
   8  </script>
   9  <style type="text/css">
  10  body {
  11      margin:0;
  12      padding:0 0 0 211px;
  13      font:70% "Trebuchet MS", Verdana, Helvetica, sans-serif;
  14      background:#357DCE url(background.jpg) no-repeat top left;
  15  }
  16  #main {

  17      margin-left:1px;
  18      padding:20px;
  19      background:#fff;
  20      height:196px;
  21  }
  22  h1 {
  23      margin:0 0 2em 0;
  24      font-size:1.2em;
  25  }
  26  ul {
  27      list-style-type:none;
  28      margin:0;
  29      padding:0;
  30      border-top:1px solid #ddd;
  31  }
  32  ul li {
  33      padding:0.5em 0;
  34      color:#ccc;
  35      border-bottom:1px solid #ddd;
  36  }
  37  ul li.doing {
  38      color:#000;
  39  }
  40  ul li.done {
  41      background:url(tick.gif) no-repeat center right;
  42      padding-right:20px;
  43      color:#000;
  44  }
  45  ul li.error {
  46      background:url(error.gif) no-repeat center right;
  47      padding-right:20px;
  48      color:#c30;
  49      font-weight:bold;
  50  }
  51  ul li#step4.done { font-weight:bold; }
  52  p#error { display:none; }
  53  form {
  54      margin:0;
  55      padding:0;
  56      float:right;
  57  }
  58  form input {
  59      font:1em Verdana, Helvetica, sans-serif;
  60      margin:8px 8px 8px 0;
  61  }
  62  </style>
  63  </head>
  64  
  65  <body>
  66  
  67  <div id="main">
  68  
  69  <?php if( !isset( $_POST["upgrade"] ) ) { ?>
  70  
  71  <h1>Welcome to the 1 Pixel Out Audio Player plugin upgrade wizard</h1>
  72  <p>This tool will download and install the latest version of the <strong>Audio Player</strong>. Be aware that upgrading
  73  the plugin will overwrite the current version of <strong>Audio Player</strong>. To continue click <strong>Upgrade</strong>.</p>
  74  
  75  <?php } else { ?>
  76  
  77  <h1>Upgrading Audio Player plugin</h1>
  78  
  79  <ul>
  80      <li id="step1" class="doing">Downloading archive...</li>
  81      <li id="step2">Extracting archive...</li>
  82      <li id="step3">Deleting archive...</li>
  83      <li id="step4">Upgrade complete!</li>
  84  </ul>
  85  
  86  <p id="error">Failed to download update. Please try again later.</p>
  87  
  88  <?php } ?>
  89  
  90  </div>
  91  <form action="index.php" method="post">
  92  <?php if( !isset( $_POST["upgrade"] ) ) { ?>
  93      <input type="submit" name="upgrade" value="Upgrade &raquo;" />
  94      <input type="button" name="close" onclick="self.close()" value="Cancel" />
  95  <?php } else { ?>
  96      <input type="button" name="close" onclick="self.close()" value="Finish" />
  97  <?php } ?>
  98  </form>
  99  
 100  <?php
 101  
 102  if( isset( $_POST["upgrade"] ) ) {
 103  
 104  ob_flush();
 105  flush();
 106  
 107  $ap_archiveURL = "http://www.1pixelout.net/download/audio-player2.zip";
 108  $target = fopen( "audio-player.zip", "wb" );
 109  $filecontents = "";
 110  
 111  if( function_exists( "curl_init" ) ) {
 112      $source = curl_init();
 113      curl_setopt( $source, CURLOPT_URL, $ap_archiveURL );
 114      curl_setopt( $source, CURLOPT_CONNECTTIMEOUT, 10 );
 115      curl_setopt( $source, CURLOPT_FAILONERROR, 1 );
 116      curl_setopt( $source, CURLOPT_RETURNTRANSFER, 1 );
 117      $filecontents = curl_exec( $source );
 118      if( curl_errno( $source ) > 0 ) {
 119          $filecontents = "error";
 120      } else curl_close( $source );
 121  } else if( ini_get( "allow_url_fopen" ) ) {
 122      if( $source = @fopen( $ap_archiveURL, "rb" ) ) {
 123          while( !feof( $source ) ) {
 124              $filecontents .= fread( $source, 8192 );
 125          }
 126          fclose($source);
 127      } else $filecontents = "error";
 128  }
 129  
 130  if( $filecontents == "error" ) { ?>
 131  
 132  <script type="text/javascript">
 133  document.getElementById( "step1" ).className = "error";
 134  document.getElementById( "error" ).style.display = "block";
 135  </script>
 136  
 137  <?php } else {
 138  
 139  fwrite( $target, $filecontents );
 140  fclose( $target );
 141  
 142  ?>
 143  
 144  <script type="text/javascript">
 145  document.getElementById( "step1" ).className = "done";
 146  document.getElementById( "step2" ).className = "doing";
 147  </script>
 148  
 149  <?php
 150  
 151  ob_flush();
 152  flush();
 153  
 154  if($zip = zip_open(dirname(__FILE__) . "/audio-player.zip")) {
 155      while($zip_entry = zip_read($zip)) {
 156          if (zip_entry_open($zip, $zip_entry, "r")) {
 157              $file = zip_entry_name($zip_entry);
 158              
 159              $dirpath = "";
 160              
 161              foreach( explode("/", dirname($file)) as $dir ) {
 162                  $dirpath .= $dir . "/";
 163                  if( !file_exists("../../" . $dirpath ) ) mkdir("../../" . $dirpath );
 164              }
 165              
 166              $stream = fopen("../../" . $file, "w");
 167              fwrite($stream, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
 168              fclose($stream);
 169              
 170              zip_entry_close($zip_entry);
 171          }
 172          
 173      }
 174      
 175      zip_close($zip);
 176  }
 177  
 178  ?>
 179  
 180  <script type="text/javascript">
 181  document.getElementById( "step2" ).className = "done";
 182  document.getElementById( "step3" ).className = "doing";
 183  </script>
 184  
 185  <?php
 186  
 187  ob_flush();
 188  flush();
 189  
 190  unlink(dirname(__FILE__) . "/audio-player.zip");
 191  
 192  ?>
 193  
 194  <script type="text/javascript">
 195  document.getElementById( "step3" ).className = "done";
 196  document.getElementById( "step4" ).className = "done";
 197  </script>
 198  
 199  <?php
 200  
 201  ob_flush();
 202  flush();
 203  
 204  }
 205  
 206  }
 207  
 208  ?>
 209  
 210  </body>
 211  </html>
 212  
 213  <?php ob_flush(); ?>


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7