diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a5efc0233d..0a97411511 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2014-08-18 Miguel de Dios + + * include/functions_ui.php, operation/search_helps.php, + operation/search_results.php, operation/search_helps.getdata.php, + general/pandora_help.php: added feature to search into the help + files, it is in the search bar header. + + * operation/search_main.php: fixed the search any term of several + words separated with whitespaces. + 2014-08-18 Alejandro Gallardo * pandoradb.sql, diff --git a/pandora_console/general/pandora_help.php b/pandora_console/general/pandora_help.php index 6a937f6a1e..0af67fe402 100644 --- a/pandora_console/general/pandora_help.php +++ b/pandora_console/general/pandora_help.php @@ -38,6 +38,7 @@ if (! isset($_SESSION['id_usuario'])) { } $user_language = get_user_language ($_SESSION['id_usuario']); + if (file_exists ('../include/languages/'.$user_language.'.mo')) { $l10n = new gettext_reader (new CachedFileReader ('../include/languages/'.$user_language.'.mo')); $l10n->load_tables(); @@ -45,6 +46,7 @@ if (file_exists ('../include/languages/'.$user_language.'.mo')) { /* Possible file locations */ $safe_language = safe_url_extraclean ($user_language, "en"); + $safe_id = safe_url_extraclean ($id, ""); $files = array ($config["homedir"]."/include/help/".$safe_language."/help_".$safe_id.".php", $config["homedir"].ENTERPRISE_DIR."/include/help/".$safe_language."/help_".$safe_id.".php", diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 399ede8e40..1aadf3096f 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1013,7 +1013,7 @@ function ui_print_help_icon ($help_id, $return = false, $home_url = '', $image = $output = html_print_image ($image, true, array ("class" => "img_help", "title" => __('Help'), - "onclick" => "open_help ('".$help_id."','".$home_url."')")); + "onclick" => "open_help ('" . $help_id . "','" . $home_url . "')")); if (!$return) echo $output; diff --git a/pandora_console/operation/search_helps.getdata.php b/pandora_console/operation/search_helps.getdata.php new file mode 100644 index 0000000000..b2194a6ce2 --- /dev/null +++ b/pandora_console/operation/search_helps.getdata.php @@ -0,0 +1,87 @@ +(.*)<\/h1>/im', $content, $matchs); + $title = null; + if (!empty($matchs)) { + $title = $matchs[1]; + } + + + + //The name is the equal to the file + $content = strip_tags($content); + + $count = preg_match_all("/" . $keywords . "/im", $content, $m); + + if ($count != 0) { + //Search in the file + if (!empty($title)) { + $helps[$title] = array( + 'id' => $help_id, + 'count' => $count); + } + else { + $helps[] = array( + 'id' => $help_id, + 'count' => $count); + } + } + } + } + + + if (empty($helps)) { + $helps = false; + $totalHelps = 0; + } + else { + $totalHelps = count($helps); + } + } + else { + $totalHelps = 0; + } +} +?> diff --git a/pandora_console/operation/search_helps.php b/pandora_console/operation/search_helps.php new file mode 100644 index 0000000000..84b08e9960 --- /dev/null +++ b/pandora_console/operation/search_helps.php @@ -0,0 +1,61 @@ +
" . __("Zero results found.") . + sprintf(__('You can find more help in the Pandora\'s wiki'), + "http://wiki.pandorafms.com/index.php?search=" . $config['search_keywords']) . + "
\n"; +} +else { + $table->width = "98%"; + $table->class = "databox"; + + $table->size = array(); + $table->size[0] = "95%"; + $table->size[1] = "5%"; + + $table->head = array (); + $table->head[0] = __('Name'); + $table->head[1] = __('Matches'); + + $table->align = array (); + $table->align[1] = "center"; + + $table->data = array (); + foreach ($helps as $iterator => $help) { + if (is_numeric($iterator)) { + $name = $help['id']; + } + else { + $name = $iterator; + } + + $table->data[] = array( + "" . $name . "", + $help['count'] + ); + } + + echo "
"; + html_print_table ($table); + unset($table); +} +?> diff --git a/pandora_console/operation/search_main.php b/pandora_console/operation/search_main.php index b2fad8c33e..32248844a2 100644 --- a/pandora_console/operation/search_main.php +++ b/pandora_console/operation/search_main.php @@ -23,6 +23,7 @@ $searchGraphs = check_acl($config["id_user"], 0, "RR"); $searchMaps = check_acl($config["id_user"], 0, "RR"); $searchReports = check_acl ($config["id_user"], 0, "RR"); $searchUsers = check_acl($config['id_user'], 0, "UM"); +$searchHelps = true; echo '
'; @@ -45,35 +46,39 @@ $table->style[9] = 'font-weight: bold; text-align: center;'; $table->style[10] = 'font-weight: bold; text-align: center;'; $table->style[11] = 'font-weight: bold; text-align: center;'; $table->style[13] = 'font-weight: bold; text-align: center;'; +$table->style[15] = 'font-weight: bold; text-align: center;'; $table->data[0][0] = html_print_image ("images/agent.png", true, array ("title" => __('Agents found'))); -$table->data[0][1] = "" . +$table->data[0][1] = "" . sprintf(__("%s Found"), $totalAgents) . ""; $table->data[0][2] = html_print_image ("images/module.png", true, array ("title" => __('Modules found'))); -$table->data[0][3] = "" . +$table->data[0][3] = "" . sprintf(__("%s Found"), $totalModules) . ""; $table->data[0][4] = html_print_image ("images/bell.png", true, array ("title" => __('Alerts found'))); -$table->data[0][5] = "" . +$table->data[0][5] = "" . sprintf(__("%s Found"), $totalAlerts) . ""; $table->data[0][6] = html_print_image ("images/input_user.png", true, array ("title" => __('Users found'))); -$table->data[0][7] = "" . +$table->data[0][7] = "" . sprintf(__("%s Found"), $totalUsers) . ""; $table->data[0][8] = html_print_image ("images/chart_curve.png", true, array ("title" => __('Graphs found'))); -$table->data[0][9] = "" . +$table->data[0][9] = "" . sprintf(__("%s Found"), $totalGraphs) . ""; $table->data[0][10] = html_print_image ("images/reporting.png", true, array ("title" => __('Reports found'))); -$table->data[0][11] = "" . +$table->data[0][11] = "" . sprintf(__("%s Found"), $totalReports) . ""; $table->data[0][12] = html_print_image ("images/visual_console_green.png", true, array ("title" => __('Maps found'))); -$table->data[0][13] = "" . +$table->data[0][13] = "" . sprintf(__("%s Found"), $totalMaps) . ""; +$table->data[0][14] = html_print_image ("images/help.png", true, array ("title" => __('Helps found'))); +$table->data[0][15] = "" . + sprintf(__("%s Found"), $totalHelps) . ""; html_print_table($table); if ($searchAgents && $totalAgents > 0) { echo $list_agents; - echo "" . + echo "" . sprintf(__('Show %s of %s. View all matches'), $count_agents_main, $totalAgents) . ""; diff --git a/pandora_console/operation/search_results.php b/pandora_console/operation/search_results.php index 0a417b412b..d8b7899792 100644 --- a/pandora_console/operation/search_results.php +++ b/pandora_console/operation/search_results.php @@ -24,6 +24,7 @@ $searchAgents = $searchAlerts = $searchModules = check_acl($config['id_user'], 0 $searchUsers = check_acl($config['id_user'], 0, "UM"); $searchMaps = $searchReports = $searchGraphs = check_acl($config["id_user"], 0, "IR"); $searchMain = true; +$searchHelps = true; $arrayKeywords = explode(' ', $config['search_keywords']); @@ -32,7 +33,7 @@ foreach ($arrayKeywords as $keyword) { // Remember, $keyword is already pass a safeinput filter. array_push($temp, "%" . $keyword . "%"); } -$stringSearchSQL = implode(" ",$temp); +$stringSearchSQL = implode(" ", $temp); if ($config['search_category'] == "all") $searchTab = "main"; @@ -136,6 +137,16 @@ else { $modules_tab = ''; } +if ($searchHelps) { + $helps_tab = array('text' => "" + . html_print_image ("images/help_w.png", true, + array ("title" => __('Helps'))) . "", + 'active' => $searchTab == "helps"); +} +else { + $helps_tab = ''; +} + $onheader = array('main' => $main_tab, 'agents' => $agents_tab, 'modules' => $modules_tab, @@ -143,9 +154,12 @@ $onheader = array('main' => $main_tab, 'users' => $users_tab, 'graphs' => $graphs_tab, 'reports' => $reports_tab, - 'maps' => $maps_tab); + 'maps' => $maps_tab, + 'helps' => $helps_tab); -ui_print_page_header (__("Search").": \"".$config['search_keywords']."\"", "images/zoom_mc.png", false, "", false, $onheader); +ui_print_page_header (__("Search") . + ": \"" . $config['search_keywords'] . "\"", + "images/zoom_mc.png", false, "", false, $onheader); $only_count = false; switch ($searchTab) { @@ -160,6 +174,7 @@ switch ($searchTab) { require_once('search_reports.getdata.php'); require_once('search_maps.getdata.php'); require_once('search_modules.getdata.php'); + require_once('search_helps.getdata.php'); require_once('search_main.php'); break; @@ -191,5 +206,9 @@ switch ($searchTab) { require_once('search_modules.getdata.php'); require_once('search_modules.php'); break; + case 'helps': + require_once('search_helps.getdata.php'); + require_once('search_helps.php'); + break; } ?>