[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <? 2 //==================================================================================== 3 // OCS INVENTORY REPORTS 4 // Copyleft Pierre LEMMET 2005 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/20/2006 12 13 if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { 14 $fd = fopen($_FILES['userfile']['tmp_name'], "r"); 15 $contents = fread($fd, filesize ($_FILES['userfile']['tmp_name'])); 16 fclose($fd); 17 18 $result = post_it($contents, "http://".LOCAL_SERVER."/ocsinventory"); 19 20 if (isset($result["errno"])) { 21 $errno = $result["errno"]; 22 $errstr = $result["errstr"]; 23 echo "<br><center><b><font color='red'> ".$l->g(344)." $errno / $errstr</font></b></center>"; 24 }else { 25 if( ! strstr ( $result[0], "200") ) 26 echo "<br><center><b><font color='red'> ".$l->g(344)." ".$result[0]."</font></b></center>"; 27 else { 28 echo "<br><center><b><font color='green'>".$l->g(287)." OK</font></b></center>"; 29 } 30 } 31 } 32 ?> 33 34 <FORM ENCTYPE="multipart/form-data" ACTION="?multi=13" METHOD="POST"> 35 <br> 36 <table border=1 class= "Fenetre" WIDTH = '52%' ALIGN = 'Center' CELLPADDING='5'> 37 <th height=30px class="Fenetre" colspan=2> 38 <b><?echo $l->g(288);?></b> 39 </th> 40 <tr bgcolor='#F2F2F2'><td><?echo $l->g(137);?></td> 41 <td><INPUT NAME="userfile" size='80' TYPE="file"></td></tr> 42 <tr bgcolor='white'> 43 <td colspan=2 align=right><INPUT TYPE="submit" VALUE="<?echo $l->g(13);?>"></td> 44 </tr> 45 </table> 46 </FORM> 47 <? 48 49 function post_it($datastream, $url) { 50 51 $url = preg_replace("@^http://@i", "", $url); 52 $host = substr($url, 0, strpos($url, "/")); 53 $uri = strstr($url, "/"); 54 $reqbody = $datastream; 55 56 $contentlength = strlen($reqbody); 57 $reqheader = "POST $uri HTTP/1.1\r\n". 58 "Host: $host\n". "User-Agent: OCS_local_".GUI_VER."\r\n". 59 "Content-type: application/x-compress\r\n". 60 "Content-Length: $contentlength\r\n\r\n". 61 "$reqbody\r\n"; 62 63 $socket = fsockopen($host, 80, $errno, $errstr); 64 65 if (!$socket) { 66 $result["errno"] = $errno; 67 $result["errstr"] = $errstr; 68 return $result; 69 } 70 fputs($socket, $reqheader); 71 72 while (!feof($socket)) { 73 $result[] = fgets($socket, 4096); 74 } 75 76 fclose($socket); 77 return $result; 78 } 79 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |