1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
<?php
session_start();
/*
echo "
<html><head>
<link rel='stylesheet' type='text/css' href='../../style.css' />
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>Extractions structures</title>";
*/
include_once("../../config_db.php");
require("../../fonctions.inc.php");
//ob_start();
if((isset($_SESSION['account'])) AND (isset($_SESSION['password'])))
{
//On recupere tous les noms de structure
$sql_trouve_struct = "SELECT structure FROM chimiotheque WHERE qui='".$_SESSION['account']."';";
$req_trouve_struct = mysql_query($sql_trouve_struct);
$i = 0;
while($data = mysql_fetch_assoc($req_trouve_struct))
{
if($data['structure'] != "")
{
$data['structure'] = preg_replace('/\.cdx/','.mol',$data['structure']); // au cas où fichier cdx
$i++;
$tab[$i] = $data['structure'];
}
}
exec("ls *.png > mesPNG.txt");
$f2read = "mesPNG.txt";
$new_tab = openfile($f2read,$tab);
ZipThisFiles($new_tab);
}
function openfile($f2read,$tab)
{
$handle = @fopen($f2read, "r");
if ($handle)
{
$i= 0;
while (!feof($handle))
{
$buffer = stream_get_line($handle, 1024, "\n");
foreach($tab as $value)
{
if(preg_match("|".$value.".*|",$buffer)!=0)
{
$new_tab[$i] = $buffer;
$i++;
}
}
}
fclose($handle);
unlink($f2read);
}
return($new_tab);
}
function ZipThisFiles($new_tab)
{
//$outputDir="./tmp/"; //Replace "/" with the name of the desired output directory.
$zipName="MesStructuresPNG.zip";
include_once("../../zip/CreateZipFile.inc.php");
$createZipFile=new CreateZipFile;
//$fileToZip = $new_tab[1];
$count=count($new_tab);
for ($i=0;$i<$count;$i++)
{
$fileToZip=trim($new_tab[$i]);
$OpenFile = fopen($fileToZip, "rb");
$fileContents = fread($OpenFile,filesize($fileToZip));
fclose($OpenFile);
//$fileContents=file_get_contents($fileToZip);
$createZipFile->addFile($fileContents,$fileToZip);
}
$rand=rand(0,999);
$zipName=$rand."_".$zipName;
$fd=fopen($zipName, "wb");
$out=fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);
//soucis de header...
ob_start();
$createZipFile->forceDownload($zipName);
ob_end_clean();
/*
print "<!--
<script language=\"JavaScript\" type=\"text/javascript\">
function deleteZIP()
{
alert(\"bye\");
Set fso = CreateObject(\"Scripting.FileSystemObject\");
fso.DeleteFile(\"".$zipName."\");
}
</script>
-->";
*/
/*
print "</head>
<body><center>
<div class=\"container\">
<table id=\"table1\">";
*/
//print_r('<a href="'.$zipName.'"><font color="blue">Récupérer le zip des images (structures)</font></a>');
//exec("sleep 30;rm -f $zipName");
//sleep(30);
@unlink($zipName);
}
//echo "</table></div><br /><br />";
//echo "<a href = '../../index.php' onClick=\"deleteZIP();\"><img src='../../img/chemastech-as_pique.jpg'></a>";
//echo "<a href = '../../index.php'><img src='../../img/chemastech-as_pique.jpg'></a>";
//echo "</body></html>";
?> |
Partager