$values = look_config_default_values(array('IPDISCOVER_IPD_DIR')); $fname = $values['tvalue']['IPDISCOVER_IPD_DIR']; $file_name = $fname . "/ipd/" . $pas . ".ipd"; //reset cache? if (isset($protectedPost['reset']) and $protectedPost['reset'] != '') { unlink($file_name); reloadform_closeme('', true); } else { $fp = @fopen($file_name, "r"); if (!$fp) { runCommand("-cache -net=" . $pas, $fname); } @fclose($fp); $tabBalises = array($l->g(34) => "IP", $l->g(95) => "MAC", $l->g(49) => "NAME", $l->g(232) => "DATE", $l->g(66) => "TYPE"); $ret = array(); $ret = parse_xml_file($file_name, $tabBalises, "HOST"); if ($ret != array()) { $sql = "select "; $i = 0; while ($ret[$i]) { foreach ($ret[$i] as $key => $value) { $sql .= "'" . $value . "' as " . $key . ","; } $sql = substr($sql, 0, -1) . " union select "; $i++; } $sql = substr($sql, 0, -13); $default_fields = $tabBalises; $list_col_cant_del = $default_fields; $tab_options['NO_NAME']['NAME'] = 1; $result_exist = tab_req($table_name, $tabBalises, $default_fields, $list_col_cant_del, $sql, $form_name, 80, $tab_options);
function search_bugs($pattern, $search_options) { # A poor-man's (*very* poor!) full text search. Not terribly efficient, but at most, we're scanning 2-3MBs... global $debug_g, $xml_array_g; # Sanitize search string & block cross-site scripting $pattern = trim(eregi_replace('([^ .#&$=0-9a-z_-]+)', ' ', $pattern)); $pattern = eregi_replace('[ ]+', ' ', $pattern); if (!$pattern) { die('<br /><br /><center><h3>No search terms were supplied. Enter a keyword or phrase, e.g., "blue screen".'); } if (!$search_options) { die("<br /><br /><center><h3>No search fields specified. You must choose at least one field (i.e., Summaries)."); } parse_xml_file(CT_XML_BUGS_FILE, CT_DROP_HISTORY, "ID", CT_ASCENDING); # Alias for generic data array by reference for speed, so do not call not parse_xml again $bug_array =& $xml_array_g; if ($search_options['phrase']) { $needles[] = $pattern; $title = "Issues Containing: <em>"{$pattern}"</em>"; } else { $needles = explode(" ", $pattern); $title = "Issues Containing: "; for ($j = 0; $j < sizeof($needles); $j++) { if ($j) { $title .= " or <em>"{$needles[$j]}"</em>"; } else { $title .= "<em>"{$needles[$j]}"</em>"; } } } $title .= " (Detailed View Below)"; $hits = array(); $max_ceiling_hit = FALSE; foreach ($bug_array as $bug) { if (isset($bug["Delete_Bug"])) { continue; } $haystack = ''; if (isset($search_options['summary'])) { $haystack = $bug["Summary"]; } if (isset($search_options['description'])) { $haystack .= " " . $bug["Description"]; } if (isset($search_options['comment'])) { $haystack .= " " . $bug["Developer_Comment"]; } $haystack = trim($haystack); foreach ($needles as $needle) { if (stristr($haystack, $needle)) { $hits[] = $bug; break; } } if (sizeof($hits) == CT_MAX_SEARCH_RESULTS) { $max_ceiling_hit = TRUE; $title .= "<br /><em>Note: Too many hits for this search term. Showing first " . CT_MAX_SEARCH_RESULTS . " results.</em>"; break; } } if ($hits) { # Sort hits by ID usort($hits, create_function('$a,$b', 'return strcasecmp($a["ID"],$b["ID"]);')); draw_table($hits, $title, '', $project_table); print "<center><span class='txtSmall'>Reports</span></center><hr class='hrBlack' width='80%'><br />\n"; foreach ($hits as $hit) { draw_read_only_table($hit); print "<br /> __________________________________________ <br /><br />\n"; } } else { print "<br /><br /><center><span class='txtSmall'>Search Results: <em>No matches found</em></span></center>\n"; } }