if (!$statement->execute()) { throw new PDOException(); } $result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($result as $item) { foreach ($types as $type) { switch ($type) { case 'hostname': $founds = common_host($conf, $item['item'], $vocables); $type = 'hostname'; break; case 'network': $founds = common_network($conf, $item['item'], $vocables); $type = 'network'; break; case 'routeur': $founds = common_routeur($conf, $item['item'], $vocables); $type = 'routeur'; break; default: $results = 0; break; } foreach ($founds as $found) { if (count($found['factors']) > 0) { $results[] = array('type' => $type, 'factors' => $found['factors'], 'type_of_checker' => $found['type_of_checker']); } } } send_alert($conf, $item['item'], $results, $vocables, $pdo); }
} return $final_types; } /* * Main code * which choose type of common factor and return * values which has problems */ $md5 = trim(htmlspecialchars($_REQUEST['md5'])); $types = choosen_common_factor($conf['type_common_factor_for_alert']); $results = array(); foreach ($types as $type) { switch ($type) { case 'hostname': $results = common_host($conf, $md5); $nb_all = $results['nb_all']; $results['hostnames'] = $results['hostnames']; $results['nb_all'] = $nb_all; break; case 'network': $results['networks'] = common_network($conf, $md5); break; case 'routeur': $results['routeurs'] = common_routeur($conf, $md5); break; default: $results = 0; break; } } echo json_encode($results);