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
|
<?php
if(empty($pageOK)) {
header('location:index.php');
exit;
}
if(isset($_POST['search']) && $_POST['search_name'] != "Server Name")
{
$trouve = false;
$count = 0;
$champs_array = ReadAssetExtract();
$machine=$_POST['search_name'];
foreach($champs_array as $champs)
{
if (!empty($champs[8]))
{
$subject = $champs[8];
$pattern = "/^".$machine."/i";
If (preg_match($pattern, $subject))
{
//if (strcasecmp(trim($machine),trim($champs[8])) == 0)
//{
$count++;
$trouve = true;
$TableBody .= "
<tr>
<td>".$count."</td>
<td>".$champs[2]."</td>
<td>".$champs[4]."</td>
<td>".$champs[5]."</td>
<td>".$champs[8]."</td>
<td>".$champs[9]."</td>
<td>".$champs[11]."</td>
<td>".$champs[12]."</td>
<td>".$champs[14]."</td>
<td>".$champs[18]."</td>
<td>".$champs[19]."</td>
<td>".$champs[20]."</td>
<td>".$champs[22]."</td>
<td>".$champs[23]."</td>
<td>".$champs[25]."</td>
<td>".$champs[26]."</td>
<td>".$champs[27]."</td>
<td>".$champs[28]."</td>
</tr>";
$File .=
$count.";".
$champs[2].";".
$champs[4].";".
$champs[5].";".
$champs[8].";".
$champs[9].";".
$champs[11].";".
$champs[12].";".
$champs[14].";".
$champs[18].";".
$champs[19].";".
$champs[20].";".
$champs[22].";".
$champs[23].";".
$champs[25].";".
$champs[26].";".
$champs[27].";".
$champs[28]."\r\n";
$data = array($count, $champs[2], $champs[4], $champs[5], $champs[8], $champs[9], $champs[11], $champs[12], $champs[14], $champs[18], $champs[19], $champs[20], $champs[22], $champs[23], $champs[25], $champs[26], $champs[27], $champs[27]);
$TableBody = '<tr><td>' . implode('</td><td>', $data) . '</td></tr>';
$File = implode(';', $data);
}
}
}
If ($trouve == true)
{
echo $TableHeader.$TableBody.$TableBottom;
//$_SESSION['To Extract'] = $File;
echo $File;
echo "<form class='form_search' action='index.php?page=Search' method='post'>
<input class='bt bt_bleu' name = 'ExtractCSV' type='submit' value='Extract'>
</form>";
}
Else
{
echo $machine.' Not Found !!!';
}
}
if(isset($_POST['ExtractCSV']))
{
//$ExtractCSV = Extract_CSV();
$datetime = date("Y_m_d-H_i_s");
header("Content-Type: application/csv-tab-delimited-table");
header('Content-disposition: attachment; filename='.$datetime.'.csv');
echo $File;
}
?> |
Partager