//====================================================================================
// OCS INVENTORY REPORTS
// Copyleft Pierre LEMMET 2006
// Web: http://ocsinventory.sourceforge.net
//
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
//====================================================================================
//Modified on 08/01/2006
PrintEnTete($l->g(465));
if( isset( $_POST["actpack"] )) {
$proto = array("http://", "https://");
$rien = array("", "");
$sub = array( $_POST["https"], $_POST["frag"] );
$_POST["https"] = str_replace($proto, $rien, $_POST["https"]);
$_POST["frag"] = str_replace($proto, $rien, $_POST["frag"]);
$opensslOk = function_exists("openssl_open");
if( $opensslOk )
$httpsOk = @fopen("https://".$_POST["https"]."/".$_POST["actpack"]."/info", "r");
// checking if this package contains fragments
$reqFrags = "SELECT fragments FROM download_available WHERE fileid='".$_POST["actpack"]."'";
$resFrags = mysql_query( $reqFrags, $_SESSION["readServer"] );
$valFrags = mysql_fetch_array( $resFrags );
$fragAvail = ($valFrags["fragments"] > 0) ;
if( $fragAvail )
$fragOk = @fopen("http://".$_POST["frag"]."/".$_POST["actpack"]."/".$_POST["actpack"]."-1", "r");
else
$fragOk = true;
if( !isset($_POST["conf"] )) {
if( ! $opensslOk )
echo "
WARNING: OpenSSL for PHP is not properly installed.
Your https server validity was not checked !";
if( ! $httpsOk && $opensslOk ) echo "
".$l->g(466)." https://".$_POST["https"]."/".$_POST["actpack"]."/";
if( $httpsOk ) fclose( $httpsOk );
if( ! $fragOk ) echo "
".$l->g(467)." http://".$_POST["frag"]."/".$_POST["actpack"]."/";
else if( $fragAvail ) fclose( $fragOk );
}
if( (! $fragOk || ! $httpsOk || ! $opensslOk) && !isset($_POST["conf"]) ) {?>
echo $l->g(468);?>
}
else {
$req = "INSERT INTO download_enable(FILEID, INFO_LOC, PACK_LOC, CERT_FILE, CERT_PATH ) VALUES
( '".$_POST["actpack"]."', '".$_POST["https"]."', '".$_POST["frag"]."', 'INSTALL_PATH/cacert.pem','INSTALL_PATH')";
mysql_query( $req, $_SESSION["writeServer"]);
echo "".$l->g(469)."
";
}
}
else if( isset( $_GET["actpack"] )) {?>
}
else if( isset( $_GET["suppack"] )) {
@mysql_query("DELETE FROM download_available WHERE FILEID='".$_GET["suppack"]."'", $_SESSION["writeServer"]) or die(mysql_error());
if( ! recursive_remove_directory( $_SERVER["DOCUMENT_ROOT"]."/download/".$_GET["suppack"] )) {
echo "
".$l->g(472)." ".$_SERVER["DOCUMENT_ROOT"]."/download/".$_GET["suppack"]."";
}
}
$lbl = "pack";
$sql = "";
$whereId = "d.FILEID";
$linkId = "d.FILEID";
$select = array( "d.FILEID"=>"Timestamp", "NAME"=>$l->g(49), "PRIORITY"=>$l->g(440), "FRAGMENTS"=>$l->g(464), "SIZE"=>$l->g(462), "OSNAME"=>$l->g(25));
$selectPrelim = array("d.FILEID"=>"d.FILEID");
$from = "download_available d";
$fromPrelim = "";
$group = "";
$order = "";
$countId = "d.FILEID";
$requete = new Req($lbl,$whereId,$linkId,$sql,$select,$selectPrelim,$from,$fromPrelim,$group,$order,$countId,true);
ShowResults($requete,true,false,false,false,false,true);
function recursive_remove_directory($directory, $empty=FALSE) {
if(substr($directory,-1) == '/')
$directory = substr($directory,0,-1);
if(!file_exists($directory) || !is_dir($directory))
return FALSE;
elseif(is_readable($directory)) {
$handle = opendir($directory);
while (FALSE !== ($item = readdir($handle))) {
if($item != '.' && $item != '..') {
$path = $directory.'/'.$item;
if(is_dir($path))
recursive_remove_directory($path);
else
unlink($path);
}
}
closedir($handle);
if($empty == FALSE) {
if(!rmdir($directory))
return FALSE;
}
}
return TRUE;
}
?>
echo $l->g(476);?>
echo $l->g(475);?>: