[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-ocs/sources/www/ -> tele_package.php (source)

   1  <?
   2  //====================================================================================
   3  // OCS INVENTORY REPORTS
   4  // Copyleft Pierre LEMMET 2006
   5  // Web: http://ocsinventory.sourceforge.net
   6  //
   7  // This code is open source and may be copied and modified as long as the source
   8  // code is always made freely available.
   9  // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
  10  //====================================================================================
  11  //Modified on 08/01/2006
  12  ?>
  13  <script language='javascript'>
  14  
  15  	function active(id, sens) {
  16          //document.write( id );
  17          var mstyle = document.getElementById(id).style.display    = (sens!=0?"block" :"none");
  18          if( id == 'EXECUTE_div' && sens ) {
  19              document.getElementById("filetext").innerHTML = "<? echo htmlentities($l->g(550)); ?>";
  20          }
  21          else if( ! sens ) {
  22              document.getElementById("filetext").innerHTML = "<? echo htmlentities($l->g(549)); ?>";
  23          }
  24      }
  25  	function checkAll() {
  26          if ( document.getElementById('nom').value =="" || ( document.getElementById('command').value =="" && document.getElementById('path').value =="" && document.getElementById('nme').value =="" )
  27          || ( document.getElementById('NOTIFY_USER').value =="1" && (document.getElementById('NOTIFY_TEXT').value =="" || document.getElementById('NOTIFY_COUNTDOWN').value =="") )
  28          )
  29                      alert("<? echo $l->g(239); ?>");
  30          else if( isNaN(document.getElementById('NOTIFY_COUNTDOWN').value) )  {
  31                  alert("<? echo $l->g(459); ?>");
  32          }
  33          else document.getElementById('pack').submit();
  34      }
  35  
  36  </script>
  37  
  38  <?
  39      set_time_limit(0);
  40      printEnTete($l->g(434));
  41  
  42      if( isset($_POST["nom"]) ) {
  43      
  44          $verifN = "SELECT fileid FROM download_available WHERE name='".$_POST["nom"]."'";
  45          $resN = mysql_query( $verifN, $_SESSION["readServer"] ) or die(mysql_error());
  46          
  47          if( mysql_num_rows( $resN ) == 0 ) {
  48                      
  49              $fSize = @filesize( $_FILES["fichier"]["tmp_name"]);
  50      
  51              if( $fSize <= 0 && ! $_POST["command"]) {
  52                  echo "<script language='javascript'>alert(\"".$l->g(436)." ".$_FILES["fichier"]["name"]."\");history.go(-1);</script>";
  53                  die("<script language='javascript'>wait(0);</script>");    
  54              }
  55              
  56              foreach( $_POST as $key=>$val ) {
  57                  $_POST[ $key ] = stripslashes( $val );
  58                  $_SESSION[ "down_" . $key ] = stripslashes( $val );
  59              }
  60                  
  61              foreach( $_FILES["fichier"] as $key=>$val )
  62                  $_SESSION[ "down_" . $key ] = $val;
  63              
  64              if( $fSize ) {
  65                  $size = $_FILES["fichier"]["size"];
  66                  $id = time();
  67          
  68                  if( $_POST["digest_algo"] == "SHA1" )
  69                      $digest = sha1_file($_FILES["fichier"]["tmp_name"],true);
  70                  else
  71                      $digest = md5_file($_FILES["fichier"]["tmp_name"]);
  72                      
  73                  if( $_POST["digest_encod"] == "Base64" )
  74                      $digest = base64_encode( $digest );
  75                      
  76                  $digName = $_POST["digest_algo"]. " / ".$_POST["digest_encod"];
  77                  
  78                  if( ! @mkdir( $_SERVER["DOCUMENT_ROOT"]."/download/".$id)) {
  79                      echo "<center><font color='red'><b>ERROR: can't write in ".$_SERVER["DOCUMENT_ROOT"]."/download/ folder, please refresh when corrected</b></font></center>";
  80                      die("<script language='javascript'>wait(0);</script>");
  81                  }
  82                  //TODO: catcher
  83                  copy( $_FILES["fichier"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"]."/download/".$id."/tmp" );
  84              
  85                  ?>
  86                  <script type="text/javascript" src="js/range.js"></script>
  87                  <script type="text/javascript" src="js/timer.js"></script>
  88                  <script type="text/javascript" src="js/slider.js"></script>
  89                  <link type="text/css" rel="StyleSheet" href="css/winclassic.css" />
  90          
  91                  <br>
  92                  <form name='frag' action='index.php?multi=20' method='post'>
  93                  <table BGCOLOR='#C7D9F5' BORDER='0' WIDTH = '600px' ALIGN = 'Center' CELLPADDING='0' BORDERCOLOR='#9894B5'>
  94                  <tr height='30px'><td align='center' colspan='10'><b><? echo $l->g(435); ?> [<? echo $_POST["nom"]; ?>]</b></td></tr>
  95                  <tr height='30px' bgcolor='white'><td><? echo $l->g(446); ?>:</td><td><? echo $_FILES["fichier"]["name"]; ?></td></tr> 
  96                  <tr height='30px' bgcolor='white'><td><? echo $l->g(460); ?>:</td><td><? echo $id; ?></td></tr>
  97                  <tr height='30px' bgcolor='white'><td><? echo $l->g(461); ?> <b><? echo $digName; ?></b>:</td><td><? echo $digest; ?></td></tr>
  98                  <tr height='30px' bgcolor='white'><td><? echo $l->g(462); ?>:</td><td><? echo round($size/1024); ?> <? echo $l->g(516); ?></td></tr>
  99                  <tr height='30px' bgcolor='white'><td><? echo $l->g(463); ?>:</td><td>
 100                  <table><tr><td width='30%'>    
 101                  <span id='tailleFrag' name='tailleFrag'><? echo round($size/1024); ?></span> <? echo $l->g(516); ?>
 102                  </td>
 103                  <? if( round($size) > 1024 ) { ?>
 104                          <td>
 105                          <div class="slider" id="slider-1" tabIndex="1">
 106                          <input class="slider-input" id="slider-input-1" name="slider-input-1"/>
 107                          </div>
 108                          </td>
 109                  <?}?>
 110                  </tr></table></td></tr>
 111                  <tr height='30px' bgcolor='white'><td><? echo $l->g(464); ?>:</td><td>
 112                      <input id='nbfrags' name='nbfrags' value='1' size='5' readonly></td></tr>
 113                  <tr height='30px' bgcolor='white'><td align='right' colspan='10'><input type='submit'>
 114                  <input type='hidden' name='id' value='<? echo $id; ?>'>
 115                  <input type='hidden' name='digest' value='<? echo $digest; ?>'>
 116                  </td></tr>
 117                  </table>        
 118                  </form>
 119                  <? if( round($size) > 1024 ) { ?>
 120                      <script type="text/javascript">
 121                      
 122                      var s = new Slider(document.getElementById("slider-1"),
 123                                         document.getElementById("slider-input-1"));
 124                      var siz = <? echo round($size); ?>;
 125                      var vmin = 1024;
 126                      
 127                      s.setMaximum( siz );                
 128                      s.setValue( siz );
 129                      
 130                      s.setMinimum(vmin);                        
 131                      s.onchange = function () {
 132                          document.getElementById('tailleFrag').innerHTML = Math.ceil((s.getValue())/1024);
 133                          document.getElementById('nbfrags').value = Math.ceil( siz / (Math.ceil(s.getValue())) );                
 134                      }    
 135                      </script>
 136                      <?
 137                  }
 138                  die("<script language='javascript'>wait(0);</script>");            
 139                  }
 140                  else {
 141                      $id = time();
 142                      if( ! @mkdir( $_SERVER["DOCUMENT_ROOT"]."/download/".$id)) {
 143                          echo "<center><font color='red'><b>ERROR: can't write in ".$_SERVER["DOCUMENT_ROOT"]."/download/ folder, please refresh when corrected</b></font></center>";
 144                          die("<script language='javascript'>wait(0);</script>");
 145                      }
 146                      ?>
 147                      <form name='frag' id='frag' action='index.php?multi=20' method='post'>
 148                          <input type='hidden' id='nbfrags' name='nbfrags' value='0'>            
 149                          <input type='hidden' name='id' value='<? echo $id; ?>'>
 150                      </form>
 151                      <script language='javascript'>document.getElementById("frag").submit();</script>
 152                      <?
 153                      flush();
 154                      die("<script language='javascript'>wait(0);</script>");
 155                  }
 156              }
 157              else {
 158                  echo "<br><center><font color='red'><b>".$l->g(551)."</b></font></center>";
 159              }
 160      }
 161      else if( isset( $_POST["nbfrags"] ) ) {
 162          
 163          //fragmenter
 164          $fname = $_SERVER["DOCUMENT_ROOT"]."/download/".$_POST["id"]."/tmp";
 165          if( $size = @filesize( $fname )) {
 166              $handle = fopen ( $fname, "rb");
 167              
 168              $read = 0;
 169              for( $i=1; $i<$_POST["nbfrags"]; $i++ ) {
 170                  $contents = fread ($handle, $size / $_POST["nbfrags"] );
 171                  $read += strlen( $contents );
 172                  $handfrag = fopen( $_SERVER["DOCUMENT_ROOT"]."/download/".$_POST["id"]."/".$_POST["id"]."-".$i, "w+b" );
 173                  fwrite( $handfrag, $contents );
 174                  fclose( $handfrag );
 175                  //echo "FRAG ".$i." lu ".strlen( $contents ). " (en tout " .$read.")<br>";
 176              }    
 177              
 178              $contents = fread ($handle, $size - $read);
 179              $read += strlen( $contents );
 180              $handfrag = fopen( $_SERVER["DOCUMENT_ROOT"]."/download/".$_POST["id"]."/".$_POST["id"]."-".$i, "w+b" );
 181              fwrite( $handfrag, $contents );
 182              fclose( $handfrag );
 183              fclose ($handle);
 184      
 185              unlink( $_SERVER["DOCUMENT_ROOT"]."/download/".$_POST["id"]."/tmp" );
 186          }
 187          
 188          //creation info
 189          $info = "<DOWNLOAD ID=\"".htmlentities($_POST["id"])."\" ".
 190          "PRI=\"".htmlentities($_SESSION["down_priority"])."\" ".
 191          "ACT=\"".htmlentities($_SESSION["down_action"])."\" ".
 192          "DIGEST=\"".htmlentities($_POST["digest"])."\" ".        
 193          "PROTO=\"".    htmlentities($_SESSION["down_proto"])."\" ".
 194          "FRAGS=\"".htmlentities($_POST["nbfrags"])."\" ".
 195          "DIGEST_ALGO=\"".htmlentities($_SESSION["down_digest_algo"])."\" ".
 196          "DIGEST_ENCODE=\"".htmlentities($_SESSION["down_digest_encod"])."\" ".
 197          "PATH=\"".htmlentities($_SESSION["down_path"])."\" ".
 198          "NAME=\"".htmlentities($_SESSION["down_nme"])."\" ".
 199          "COMMAND=\"".htmlentities($_SESSION["down_command"])."\" ".
 200          "NOTIFY_USER=\"".htmlentities($_SESSION["down_NOTIFY_USER"])."\" ".
 201          "NOTIFY_TEXT=\"".htmlentities($_SESSION["down_NOTIFY_TEXT"])."\" ".
 202          "NOTIFY_COUNTDOWN=\"".htmlentities($_SESSION["down_NOTIFY_COUNTDOWN"])."\" ".
 203          "NOTIFY_CAN_ABORT=\"".htmlentities($_SESSION["down_NOTIFY_CAN_ABORT"])."\" ".
 204          "NOTIFY_CAN_DELAY=\"".htmlentities($_SESSION["down_NOTIFY_CAN_DELAY"])."\" ".
 205          "NEED_DONE_ACTION=\"".htmlentities($_SESSION["down_NEED_DONE_ACTION"])."\" ".        
 206          "GARDEFOU=\"rien\" />\n";
 207          
 208          $handinfo = fopen( $_SERVER["DOCUMENT_ROOT"]."/download/".$_POST["id"]."/info", "w+" );
 209          fwrite( $handinfo, $info );
 210          fclose( $handinfo );
 211          
 212          mysql_query( "DELETE FROM download_available WHERE FILEID='".$_POST["id"]."'", $_SESSION["writeServer"]);
 213          $req = "INSERT INTO download_available(FILEID, NAME, PRIORITY, FRAGMENTS, SIZE, OSNAME, COMMENT) VALUES
 214          ( '".$_POST["id"]."', '".addslashes($_SESSION["down_nom"])."','".$_SESSION["down_priority"]."', '".$_POST["nbfrags"]."',
 215          '".$size."', '".$_SESSION["down_os"]."', '' )";
 216          
 217          mysql_query( $req, $_SESSION["writeServer"] );
 218          echo mysql_error();
 219          echo "<br><center><b><font color='green'>".$l->g(437)." ".$_SERVER["DOCUMENT_ROOT"]."/download/".$_POST["id"]."</font></b></center><br>";
 220  
 221          unset( $_POST["nbfrags"] );    
 222          //vider session
 223          //die();
 224      }
 225  ?>
 226  
 227  <link type="text/css" rel="StyleSheet" href="css/winclassic.css" />
 228  <br><p class='text'>
 229  <table BGCOLOR='#C7D9F5' BORDER='0' WIDTH = '600px' ALIGN = 'Center' CELLPADDING='0' BORDERCOLOR='#9894B5'>
 230  <form id='pack' name='pack' action='index.php?multi=20' method='post' enctype='multipart/form-data'>
 231      <tr height='30px'><td colspan='10' align='center'><b><? echo $l->g(438); ?></b></td></tr>
 232      <tr height='30px' bgcolor='white'><td><? echo $l->g(49); ?>:</td><td colspan='2'><input id='nom' name='nom'></td></tr>
 233      <tr height='30px' bgcolor='white'><td><? echo $l->g(25); ?>:</td><td colspan='2'><select id='os' name='os'><option>WINDOWS</option><option>LINUX</option></select></td></tr>
 234      <tr height='30px' bgcolor='white'><td><? echo $l->g(439); ?>:</td><td colspan='2'><select id='proto' name='proto'><option>HTTP</option></select></td></tr>
 235      <tr height='30px' bgcolor='white'><td><? echo $l->g(440); ?>:</td><td colspan='2'><select  id='priority' name='priority'>
 236      <option>0</option><option>1</option><option>2</option><option>3</option><option>4</option><option selected>5</option><option>6</option><option>7</option><option>8</option><option>9</option></select></td></tr>
 237      
 238      
 239      <tr height='30px' bgcolor='white'><td><span id='filetext'><? echo $l->g(549); ?></span>:</td><td colspan='2'><input id='fichier' name='fichier' type='file' accept='archive/zip'></td></tr>
 240      <tr height='30px' bgcolor='white'><td><? echo $l->g(443); ?>:</td><td><select id='action' name='action' OnChange='active("EXECUTE_div", false);active("STORE_div", false);active("LAUNCH_div", false);active(this.value + "_div", true);'>
 241      <option value='STORE' selected><? echo $l->g(457); ?></option>
 242      <option value='EXECUTE'><? echo $l->g(456); ?></option>
 243      <option value='LAUNCH'><? echo $l->g(458); ?></option>
 244      </select></td>
 245          <td width='43%' align='right'>
 246          <div id='EXECUTE_div' style='display:none'><? echo $l->g(444); ?>: <input id='command' name='command'></div>
 247          <div id='STORE_div' style='display:block'><? echo $l->g(445); ?>: <input id='path' name='path'></div>
 248          <div id='LAUNCH_div' style='display:none'><? echo $l->g(446); ?>: <input id='nme' name='nme'></div></td>
 249      </tr>
 250      <tr height='30px' BGCOLOR='#C7D9F5'><td align='center' colspan='10'><b><? echo $l->g(447); ?></b></td></tr>
 251      <tr height='30px' bgcolor='white'><td><? echo $l->g(448); ?>:</td><td colspan='2'><select id='NOTIFY_USER' name='NOTIFY_USER' OnChange='active("d1", this.value);'><option value='0'><? echo $l->g(454); ?></option><option value='1'><? echo $l->g(455); ?></option></select></td></tr>
 252      <tr><td colspan='10' align='right'>
 253      <span id='d1' style='display:none'>
 254      <table width='80%'>
 255      <tr height='30px' bgcolor='white'><td><? echo $l->g(449); ?>:</span></td><td colspan='2'><input id='NOTIFY_TEXT' name='NOTIFY_TEXT'></div></td></tr>
 256      <tr height='30px' bgcolor='white'><td><? echo $l->g(450); ?>:</td><td colspan='2'><input id='NOTIFY_COUNTDOWN' name='NOTIFY_COUNTDOWN' size='4'>&nbsp;&nbsp;&nbsp;<? echo $l->g(511); ?></td></tr>
 257      <tr height='30px' bgcolor='white'><td><? echo $l->g(451); ?>:</td><td colspan='2'><select id='NOTIFY_CAN_ABORT' name='NOTIFY_CAN_ABORT'><option value='0'><? echo $l->g(454); ?></option><option value='1'><? echo $l->g(455); ?></option></td></tr>
 258      <tr height='30px' bgcolor='white'><td><? echo $l->g(452); ?>:</td><td colspan='2'><select id='NOTIFY_CAN_DELAY' name='NOTIFY_CAN_DELAY'><option value='0'><? echo $l->g(454); ?></option><option value='1'><? echo $l->g(455); ?></option></td></tr>
 259      </table>
 260      <br>
 261      </span>
 262      </td></tr>
 263      <tr height='30px' bgcolor='white'><td><? echo $l->g(453); ?>:</td><td colspan='2'><select name='NOTIFY_CAN_DELAY' name='NEED_DONE_ACTION'><option value='0'><? echo $l->g(454); ?></option><option value='1'><? echo $l->g(455); ?></option></td></tr>
 264      <tr height='30px' bgcolor='white'><td align='right' colspan='10'>                
 265      <input type='hidden' id='digest_algo' name='digest_algo' value='MD5'>
 266      <input type='hidden' id='digest_encod' name='digest_encod' value='Hexa'>
 267      <input type='button' name='send' OnClick='checkAll()' value='<? echo $l->g(13); ?>'></td></tr>
 268  </form>
 269  </table></p>
 270  
 271  


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1