diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 0fb4299fe2..afb49424e2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,18 +1,60 @@ -2007-04-22 slerena +2007-05-03 Sancho Lerena - * pandoradb.sql: Fixed small problem with tgrupos + * include/FreeSans.ttf: Added to repos, should be here to use in graphs. + * include/functions_db.php: Deleted noaccess include from + comprueba_login(). This should return value, not render pages or + exit. + + * include/config.inc.php: Modified some typos. + + * include/calendar.js: Added generic calendar javascript, to be + used on exportdata and incident management code. + + * include/languages/language_en.php: More strings. + + * install.php: In my render, box height is too low. PLEASE recheck + before changing this kind of properties because in other browsers + could have a bad render (Sophus!). + + * index.php: Added script call (need to be done on header). + + * operation/agentes/export_csv.php: Added new file to create a + standalone CSV on download icon / link. + + * operation/agentes/exportdata.php: New export data code, used + some code from Leando Doctors, and mixed with old code. Now have + three options to render export data. + + * operation/agentes/datos_agente_calendar.php: Deleted old code from Leandro. + + * operation/active_console/lib/extra_functions.php: Solved a lot + of warnings, but there are TONS of more warnings that need to be + corrected. + + * operation/active_console/lib/db_functions.php:Solved a lot of + warnings, but there are TONS of more warnings that need to be + corrected. + + * operation/active_console/index.php: Solved a lot of warnings, + but there are TONS of more warnings that need to be + corrected. This code DONT work if you are showing warning/notice + erros. This code is not ready for production usage, too buggy yet + :( + + * pandora_graphical_console_data.sql: Cleanup. + + * godmode/agentes/module_manager.php: Added wizard button. + + * pandora_graphical_console.sql: Cleanup. + + +2007-04-22 Sancho Lerena + + * pandoradb.sql: Fixed small problem with tgrupos 2007-05-01 Raul Mateos - * functions_db.php, language_en.php, estado_grupo.php - estado_agente.php configurar_grupo.php lista_grupos.php - modificar_server.php: New feature implemented: groups could be - configured to do not launch alerts (Disabled field). Any agent - inside this group does not fire alerts while disabled will be - activated. Useful for programmed non-service periods or programmed - shutdowns. - * images/bricks.png: Changed red colour to orange one. * include/pandora.css: Changed background colour for View Mode tab. @@ -44,7 +86,6 @@ * operation/modificar_agente.php: Deleted table and moved button to tr. ->>>>>>> .r446 2007-04-22 Sancho Lerena * functions_db.php, language_en.php, estado_grupo.php @@ -92,7 +133,6 @@ * godmode/menu.php: Fixed some navigation marks. ->>>>>>> .r441 2007-04-19 Sancho Lerena * pandora.css: added some classes for graphical input buttons. diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 8fd29a278b..968b135a70 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -398,9 +398,9 @@ if (isset($_POST["oid"])){ "; if ($update_module == "1"){ - echo ''; + echo ''; } else { - echo ''; + echo ''; } echo ""; diff --git a/pandora_console/include/FreeSans.ttf b/pandora_console/include/FreeSans.ttf new file mode 100644 index 0000000000..5909637eef Binary files /dev/null and b/pandora_console/include/FreeSans.ttf differ diff --git a/pandora_console/include/calendar.js b/pandora_console/include/calendar.js new file mode 100644 index 0000000000..f3f831d0cd --- /dev/null +++ b/pandora_console/include/calendar.js @@ -0,0 +1,1800 @@ +// ***************************************************************************** +// Simple Calendar Widget - Cross-Browser Javascript pop-up calendar. +// +// Copyright (C) 2005-2006 Anthony Garrett +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, it is available at +// the GNU web site (http://www.gnu.org/) or by writing to the +// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +// Boston, MA 02110-1301 USA +// +// ***************************************************************************** +// +// Contact: Sorry, I can't offer support for this but if you find a problem +// (or just want to tell me how useful you find it), please send +// me an email at scwfeedback@tarrget.info (Note the two Rs in +// tarrget). I will try to fix problems quickly but this is a +// spare time thing for me. +// +// Credits: I wrote this from scratch myself but I couldn't have done it +// without the superb "JavaScript The Definitive Guide" by David +// Flanagan (Pub. O'Reilly ISBN 0-596-00048-0). I also recognise +// a contribution from my experience with PopCalendar 4.1 by +// Liming(Victor) Weng. +// +// Link back: Please give me credit and link back to my page. To ensure that +// search engines give my page a higher ranking you can add the +// following HTML to any indexed page on your web site: +// +// +// Simple Calendar Widget by Anthony Garrett +// +// +// Features: Easily customised +// (output date format, colours, language, year range and +// week start day) +// Accepts a date as input +// (see comments below for formats). +// Cross-browser code tested against; +// Internet Explorer 6.0.28 Mozilla 1.7.1 +// Opera 7.52+ Firefox 0.9.1+ +// Konqueror 3.4.0 Flock 0.4.9 +// +// How to add the Calendar to your page: +// This script needs to be defined for your page so, immediately +// after the BODY tag add the following line; +// +// +// +// Your root directory of the web site should also contain an empty +// file called "scwblank.html". See +// http://www.tarrget.info/calendar/IEnightmare.html +// for a full explanation. +// +// How to use the Calendar once it is defined for your page: +// +// Simply choose an event to trigger the calendar (like an onClick +// or an onMouseOver) and an element to work on (for the calendar +// to take its initial date from and write its output date to) then +// write it like this; +// +// <>="scwShow(<>,this);" +// +// e.g. onClick="scwShow(scwID('myElement'),this);" +// or onMouseOver="scwShow(this,this);" +// +// NOTE: The "this" keyword causes the script to fail when the +// triggered calendar is using an anchor tag. The following +// syntax works; +// +// +// <> +// +// +// If you are using a text node then specify the text's parent node +// in the function call. The date should be the only text under that +// node; +// +// e.g.

<>

+// +// You can also disable days of the week by adding arguments to the +// call to scwShow. The values should be Sunday = 0 through to +// Saturday = 6. A call to scwShow with Friday and Monday disabled +// would look something like this; +// +// scwShow(<>,this,5,1); +// +// Finally you can use the following technique to run a function +// when the calendar closes: +// +// scwNextAction=<>.runsAfterSCW(this,<>); +// scwShow(<>,this <<,optional arguments above>>); +// +// Where <> is a function defined on the calling page +// and <> is the list of arguments being passed to that +// function. +// +// ------------------------------------------------------------------ +// Here's an extremely trivial but fully functioning example page +// showing two of the ways to trigger the calendar; +// +// +// Basic Example +// +// +//

06-Dec-2006

+// +//

+// +// 08-Dec-2006 +// +// +// +// +// ***************************************************************************** +// +// See http://www.tarrget.info/calendar/scw.htm for a complete version history +// +// Version Date By Description +// ======= ==== =============== =========== +// 3.58 2007-04-04 Anthony Garrett Resolved an error caused when the date +// range does not include the current year. +// Thanks to Steve Davis for letting me know. +// +// Fixed "Today" selector display which +// was incorrectly visible when year range +// ended last year. (Also the result of +// investigations based on Steve Davis' +// feedback). +// ***************************************************************************** + +// ************************************ +// Start of Simple Calendar Widget Code +// ************************************ + +// This date is used throughout to determine today's date. + + var scwDateNow = new Date(Date.parse(new Date().toDateString())); + +//****************************************************************************** +//------------------------------------------------------------------------------ +// Customisation section +//------------------------------------------------------------------------------ +//****************************************************************************** + + // Set the bounds for the calendar here... + // If you want the year to roll forward you can use something like this... + // var scwBaseYear = scwDateNow.getFullYear()-5; + // alternatively, hard code a date like this... + // var scwBaseYear = 1990; + + var scwBaseYear = scwDateNow.getFullYear()-5; + + // How many years do want to be valid and to show in the drop-down list? + + var scwDropDownYears = 10; + + // All language-dependent changes can be made here... + + // If you wish to work in a single language (other than English) then + // just replace the English (in the function scwSetLanguage below) with + // your own text. + + // Using multiple languages: + // In order to keep this script to a resonable size I have not included + // languages here. You can set language fields in a function that you + // should call scwSetLanguage the script will use your languages. + // I have included all the translations that have been sent to me in + // such a function on the demonstration page. + + var scwLanguage; + + function scwSetDefaultLanguage() + {try + {scwSetLanguage();} + catch (exception) + {// English + scwToday = 'Today:'; + scwDrag = 'click here to drag'; + scwArrMonthNames = ['Jan','Feb','Mar','Apr','May','Jun', + 'Jul','Aug','Sep','Oct','Nov','Dec']; + scwArrWeekInits = ['S','M','T','W','T','F','S']; + scwInvalidDateMsg = 'The entered date is invalid.\n'; + scwOutOfRangeMsg = 'The entered date is out of range.'; + scwDoesNotExistMsg = 'The entered date does not exist.'; + scwInvalidAlert = ['Invalid date (',') ignored.']; + scwDateDisablingError = ['Error ',' is not a Date object.']; + scwRangeDisablingError = ['Error ', + ' should consist of two elements.']; + } + } + + // Note: Always start the scwArrWeekInits array with your string for + // Sunday whatever scwWeekStart (below) is set to. + + // scwWeekStart determines the start of the week in the display + // Set it to: 0 (Zero) for Sunday, 1 (One) for Monday etc.. + + var scwWeekStart = 1; + + // The week start day for the display is taken as the week start + // for week numbering. This ensures that only one week number + // applies to one line of the calendar table. + // [ISO 8601 begins the week with Day 1 = Monday.] + + // If you want to see week numbering on the calendar, set + // this to true. If not, false. + + var scwWeekNumberDisplay = false; + + // Week numbering rules are generally based on a day in the week + // that determines the first week of the year. ISO 8601 uses + // Thursday (day four when Sunday is day zero). You can alter + // the base day here. + + // See http://www.cl.cam.ac.uk/~mgk25/iso-time.html for more information + + var scwWeekNumberBaseDay = 4; + + // Each of the calendar's alert message types can be disabled + // independently here. + + var scwShowInvalidDateMsg = true, + scwShowOutOfRangeMsg = true, + scwShowDoesNotExistMsg = true, + scwShowInvalidAlert = true, + scwShowDateDisablingError = true, + scwShowRangeDisablingError = true; + + // Set the allowed input date delimiters here... + // E.g. To set the rising slash, hyphen, full-stop (aka stop or point), + // comma and space as delimiters use + // var scwArrDelimiters = ['/','-','.',',',' ']; + + var scwArrDelimiters = ['/','-','.',',',' ']; + + // Set the format for the displayed 'Today' date and for the output + // date here. + // + // The format is described using delimiters of your choice (as set + // in scwArrDelimiters above) and case insensitive letters D, M and Y. + // + // Definition Returns + // ---------- ------- + // D date in the month without zero filling + // DD date in the month left zero filled + // M month number without zero filling + // MM month number left zero filled + // MMM month string from scwArrMonthNames + // YY year number in two digits + // YYYY year number in four digits + + // Displayed "Today" date format + + //var scwDateDisplayFormat = 'dd-mm-yy'; // e.g. 'MMM-DD-YYYY' for the US + var scwDateDisplayFormat = 'yyyy-mm-dd'; // e.g. 'MMM-DD-YYYY' for the US + + // Output date format + + //var scwDateOutputFormat = 'DD MMM, YYYY'; // e.g. 'MMM-DD-YYYY' for the US + var scwDateOutputFormat = 'YYYY-MM-DD'; // e.g. 'MMM-DD-YYYY' for the US + + // The input date is fully parsed so a format is not required, + // but there is no way to differentiate the sequence reliably. + // + // e.g. Is 05/08/03 5th August 2003, + // 8th May 2003 or even + // 3rd August 2005? + // + // So, you have to state how the code should interpret input dates. + // + // The sequence should always contain one D, one M and one Y only, + // in any order. + + //var scwDateInputSequence = 'DMY'; // e.g. 'MDY' for the US + var scwDateInputSequence = 'YMD'; // e.g. 'MDY' for the US + + // Note: Because the user may select a date then trigger the + // calendar again to select another, it is necessary to + // have the input date sequence in the same order as the + // output display format. To allow the flexibility of having + // a full input date and a partial (e.g. only Month and Year) + // output, the input sequence is set separately. + // + // The same reason determines that the delimiters used should + // be in scwArrDelimiters. + + // scwZindex controls how the pop-up calendar interacts with the rest + // of the page. It is usually adequate to leave it as 1 (One) but I + // have made it available here to help anyone who needs to alter the + // level in order to ensure that the calendar displays correctly in + // relation to all other elements on the page. + + var scwZindex = 1; + + // Personally I like the fact that entering 31-Sep-2005 displays + // 1-Oct-2005, however you may want that to be an error. If so, + // set scwBlnStrict = true. That will cause an error message to + // display and the selected month is displayed without a selected + // day. Thanks to Brad Allan for his feedback prompting this feature. + + var scwBlnStrict = false; + + // If you wish to disable any displayed day, e.g. Every Monday, + // you can do it by setting the following array. The array elements + // match the displayed cells. + // + // You could put something like the following in your calling page + // to disable all weekend days; + // + // for (var i=0;i' + + '.scw {padding:1px;vertical-align:middle;}' + + 'iframe.scw {position:absolute;z-index:' + scwZindex + + ';top:0px;left:0px;visibility:hidden;' + + 'width:1px;height:1px;}' + + 'table.scw {padding:0px;visibility:hidden;' + + 'position:absolute;cursor:default;' + + 'width:200px;top:0px;left:0px;' + + 'z-index:' + (scwZindex+1) + + ';text-align:center;}' + + '' ); + + // This style sheet can be extracted from the script and edited into regular + // CSS (by removing all occurrences of + and '). That can be used as the + // basis for themes. Classes are described in comments within the style + // sheet. + + document.writeln( + '' + ); + +//****************************************************************************** +//------------------------------------------------------------------------------ +// End of customisation section +//------------------------------------------------------------------------------ +//****************************************************************************** + +// Variables required by both scwShow and scwShowMonth + + var scwTargetEle, + scwTriggerEle, + scwMonthSum = 0, + scwBlnFullInputDate = false, + scwPassEnabledDay = new Array(), + scwSeedDate = new Date(), + scwParmActiveToday = true, + scwWeekStart = scwWeekStart%7, + scwToday, + scwDrag, + scwArrMonthNames, + scwArrWeekInits, + scwInvalidDateMsg, + scwOutOfRangeMsg, + scwDoesNotExistMsg, + scwInvalidAlert, + scwDateDisablingError, + scwRangeDisablingError; + + // Add a method to format a date into the required pattern + + Date.prototype.scwFormat = + function(scwFormat) + {var charCount = 0, + codeChar = '', + result = ''; + + for (var i=0;i<=scwFormat.length;i++) + {if (i 0) {result += codeChar;} + } + + if (i 0) + {scwTriggerEle.scwTextNode = scwChildNodes[i]; + scwTriggerEle.scwLength = scwChildNodes[i].nodeValue.length; + break; + } + } + } + else + {var scwDateValue = scwEle.value.replace(/^\s+/,'').replace(/\s+$/,'');} + + // Set the language-dependent elements + + scwSetDefaultLanguage(); + + scwID('scwDragText').innerHTML = scwDrag; + + scwID('scwMonths').options.length = 0; + for (var i=0;iscwSeedDate + ) + {scwSeedDate = new Date(scwBaseYear + + Math.floor(scwDropDownYears / 2), 5, 1); + } + } + else + {function scwInputFormat() + {var scwArrSeed = new Array(), + scwArrInput = scwDateValue. + split(new RegExp('[\\'+scwArrDelimiters. + join('\\')+']+','g')); + + // "Escape" all the user defined date delimiters above - + // several delimiters will need it and it does no harm for + // the others. + + // Strip any empty array elements (caused by delimiters) + // from the beginning or end of the array. They will + // still appear in the output string if in the output + // format. + + if (scwArrInput[0]!=null) + {if (scwArrInput[0].length==0) scwArrInput.splice(0,1); + + if (scwArrInput[scwArrInput.length-1].length==0) + scwArrInput.splice(scwArrInput.length-1,1); + } + + scwBlnFullInputDate = false; + + switch (scwArrInput.length) + {case 1: + {// Year only entry + scwArrSeed[0] = parseInt(scwArrInput[0],10); // Year + scwArrSeed[1] = '6'; // Month + scwArrSeed[2] = 1; // Day + break; + } + case 2: + {// Year and Month entry + scwArrSeed[0] = + parseInt(scwArrInput[scwDateInputSequence. + replace(/D/i,''). + search(/Y/i)],10); // Year + scwArrSeed[1] = scwArrInput[scwDateInputSequence. + replace(/D/i,''). + search(/M/i)]; // Month + scwArrSeed[2] = 1; // Day + break; + } + case 3: + {// Day Month and Year entry + + scwArrSeed[0] = + parseInt(scwArrInput[scwDateInputSequence. + search(/Y/i)],10); // Year + scwArrSeed[1] = scwArrInput[scwDateInputSequence. + search(/M/i)]; // Month + scwArrSeed[2] = + parseInt(scwArrInput[scwDateInputSequence. + search(/D/i)],10); // Day + + scwBlnFullInputDate = true; + break; + } + default: + {// A stuff-up has led to more than three elements in + // the date. + scwArrSeed[0] = 0; // Year + scwArrSeed[1] = 0; // Month + scwArrSeed[2] = 0; // Day + } + } + + // These regular expressions validate the input date format + // to the following rules; + // Day 1-31 (optional zero on single digits) + // Month 1-12 (optional zero on single digits) + // or case insensitive name + // Year One, Two or four digits + + // Months names are as set in the language-dependent + // definitions and delimiters are set just below there + + var scwExpValDay = new RegExp('^(0?[1-9]|[1-2][0-9]|3[0-1])$'), + scwExpValMonth = new RegExp('^(0?[1-9]|1[0-2]|' + + scwArrMonthNames.join('|') + + ')$','i'), + scwExpValYear = new RegExp('^([0-9]{1,2}|[0-9]{4})$'); + + // Apply validation and report failures + + if (scwExpValYear.exec(scwArrSeed[0]) == null || + scwExpValMonth.exec(scwArrSeed[1]) == null || + scwExpValDay.exec(scwArrSeed[2]) == null + ) + {if (scwShowInvalidDateMsg) + alert(scwInvalidDateMsg + + scwInvalidAlert[0] + scwDateValue + + scwInvalidAlert[1]); + scwBlnFullInputDate = false; + scwArrSeed[0] = scwBaseYear + + Math.floor(scwDropDownYears/2); // Year + scwArrSeed[1] = '6'; // Month + scwArrSeed[2] = 1; // Day + } + + // Return the Year in scwArrSeed[0] + // Month in scwArrSeed[1] + // Day in scwArrSeed[2] + + return scwArrSeed; + } + + // Parse the string into an array using the allowed delimiters + + scwArrSeedDate = scwInputFormat(); + + // So now we have the Year, Month and Day in an array. + + // If the year is one or two digits then the routine assumes a + // year belongs in the 21st Century unless it is less than 50 + // in which case it assumes the 20th Century is intended. + + if (scwArrSeedDate[0]<100) + scwArrSeedDate[0] += (scwArrSeedDate[0]>50)?1900:2000; + + // Check whether the month is in digits or an abbreviation + + if (scwArrSeedDate[1].search(/\d+/)!=0) + {month = scwArrMonthNames.join('|').toUpperCase(). + search(scwArrSeedDate[1].substr(0,3). + toUpperCase()); + scwArrSeedDate[1] = Math.floor(month/4)+1; + } + + scwSeedDate = new Date(scwArrSeedDate[0], + scwArrSeedDate[1]-1, + scwArrSeedDate[2]); + } + + // Test that we have arrived at a valid date + + if (isNaN(scwSeedDate)) + {if (scwShowInvalidDateMsg) + alert( scwInvalidDateMsg + + scwInvalidAlert[0] + scwDateValue + + scwInvalidAlert[1]); + scwSeedDate = new Date(scwBaseYear + + Math.floor(scwDropDownYears/2),5,1); + scwBlnFullInputDate=false; + } + else + {// Test that the date is within range, + // if not then set date to a sensible date in range. + + if ((new Date(scwBaseYear,0,1)) > scwSeedDate) + {if (scwBlnStrict && scwShowOutOfRangeMsg) + alert(scwOutOfRangeMsg); + scwSeedDate = new Date(scwBaseYear,0,1); + scwBlnFullInputDate=false; + } + else + {if ((new Date(scwBaseYear+scwDropDownYears,0,0))< + scwSeedDate) + {if (scwBlnStrict && scwShowOutOfRangeMsg) + alert(scwOutOfRangeMsg); + scwSeedDate = new Date(scwBaseYear + + Math.floor(scwDropDownYears)-1, + 11,1); + scwBlnFullInputDate=false; + } + else + {if (scwBlnStrict && scwBlnFullInputDate && + (scwSeedDate.getDate() != scwArrSeedDate[2] || + (scwSeedDate.getMonth()+1) != scwArrSeedDate[1] || + scwSeedDate.getFullYear() != scwArrSeedDate[0] + ) + ) + {if (scwShowDoesNotExistMsg) alert(scwDoesNotExistMsg); + scwSeedDate = new Date(scwSeedDate.getFullYear(), + scwSeedDate.getMonth()-1,1); + scwBlnFullInputDate=false; + } + } + } + } + + // Test the disabled dates for validity + // Give error message if not valid. + + for (var i=0;i scwDisabledDates[i][1]) + ) + {scwDisabledDates[i].reverse();} + } + else + {if (scwShowRangeDisablingError) + alert( scwDateDisablingError[0] + + scwDisabledDates[i] + + scwDateDisablingError[1]); + } + } + } + + // Calculate the number of months that the entered (or + // defaulted) month is after the start of the allowed + // date range. + + scwMonthSum = 12*(scwSeedDate.getFullYear()-scwBaseYear)+ + scwSeedDate.getMonth(); + + // Set the drop down boxes. + + scwID('scwYears' ).options.selectedIndex = Math.floor(scwMonthSum/12); + scwID('scwMonths').options.selectedIndex = (scwMonthSum%12); + + // Opera has a bug with this method of setting the selected index. + // It requires the following work-around to force SELECTs to display + // correctly. + + if (window.opera) + {scwID('scwMonths').style.display = 'none'; + scwID('scwMonths').style.display = 'block'; + scwID('scwYears' ).style.display = 'none'; + scwID('scwYears' ).style.display = 'block'; + } + + // The bug is apparently known and "fixed for future versions" + // but they say they aren't going to put the fix into the 9.x + // series. + + // Check whether or not dragging is allowed and display drag handle + // if necessary + + scwID('scwDrag').style.display= + (scwAllowDrag) + ?((scwID('scwIFrame'))?'block':'table-row') + :'none'; + + // Display the month + + scwShowMonth(0); + + // Position the calendar box + + // The object sniffing for Opera allows for the fact that Opera + // is the only major browser that correctly reports the position + // of an element in a scrollable DIV. This is because IE and + // Firefox omit the DIV from the offsetParent tree. + + scwTargetEle=scwEle; + + var offsetTop =parseInt(scwEle.offsetTop ,10) + + parseInt(scwEle.offsetHeight,10), + offsetLeft=parseInt(scwEle.offsetLeft,10); + + if (!window.opera) + {while (scwEle.tagName!='BODY' && scwEle.tagName!='HTML') + {offsetTop -=parseInt(scwEle.scrollTop, 10); + offsetLeft-=parseInt(scwEle.scrollLeft,10); + scwEle=scwEle.parentNode; + } + scwEle=scwTargetEle; + } + + do {scwEle=scwEle.offsetParent; + offsetTop +=parseInt(scwEle.offsetTop, 10); + offsetLeft+=parseInt(scwEle.offsetLeft,10); + } + while (scwEle.tagName!='BODY' && scwEle.tagName!='HTML'); + + scwID('scw').style.top =offsetTop +'px'; + scwID('scw').style.left=offsetLeft+'px'; + + if (scwID('scwIframe')) + {scwID('scwIframe').style.top=offsetTop +'px'; + scwID('scwIframe').style.left=offsetLeft+'px'; + scwID('scwIframe').style.width=(scwID('scw').offsetWidth-2)+'px'; + scwID('scwIframe').style.height=(scwID('scw').offsetHeight-2)+'px'; + scwID('scwIframe').style.visibility='visible'; + } + + // Show it on the page + + scwID('scw').style.visibility='visible'; + + // Ensure that Opera actually displays the value that is selected! + + scwID('scwYears' ).options.selectedIndex = scwID('scwYears' ).options.selectedIndex; + scwID('scwMonths').options.selectedIndex = scwID('scwMonths').options.selectedIndex; + + var el = (scwSourceEle.parentNode) + ?scwSourceEle.parentNode + :scwSourceEle; + + if (typeof event=='undefined') + {el.addEventListener('click', + scwStopPropagation, + false); + } + else {if (el.attachEvent) + {el.attachEvent('onclick',scwStopPropagation);} + else {event.cancelBubble = true;} + } + } + + function scwHide() + {scwID('scw').style.visibility='hidden'; + if (scwID('scwIframe')) + {scwID('scwIframe').style.visibility='hidden';} + + if (typeof scwNextAction!='undefined' && scwNextAction!=null) + {scwNextActionReturn = scwNextAction(); + // Explicit null set to prevent closure causing memory leak + scwNextAction = null; + } + } + + function scwCancel(scwEvt) + {if (scwClickToHide) scwHide(); + scwStopPropagation(scwEvt); + } + + function scwStopPropagation(scwEvt) + {if (scwEvt.stopPropagation) + scwEvt.stopPropagation(); // Capture phase + else scwEvt.cancelBubble = true; // Bubbling phase + } + + function scwBeginDrag(event) + {var elementToDrag = scwID('scw'); + + var deltaX = event.clientX, + deltaY = event.clientY, + offsetEle = elementToDrag; + + do {deltaX -= parseInt(offsetEle.offsetLeft,10); + deltaY -= parseInt(offsetEle.offsetTop ,10); + offsetEle = offsetEle.offsetParent; + } + while (offsetEle.tagName!='BODY' && + offsetEle.tagName!='HTML'); + + if (document.addEventListener) + {document.addEventListener('mousemove', + moveHandler, + true); // Capture phase + document.addEventListener('mouseup', + upHandler, + true); // Capture phase + } + else {elementToDrag.attachEvent('onmousemove', + moveHandler); // Bubbling phase + elementToDrag.attachEvent('onmouseup', + upHandler); // Bubbling phase + elementToDrag.setCapture(); + } + + scwStopPropagation(event); + + function moveHandler(scwEvt) + {if (!scwEvt) scwEvt = window.event; + + elementToDrag.style.left = (scwEvt.clientX - deltaX) + 'px'; + elementToDrag.style.top = (scwEvt.clientY - deltaY) + 'px'; + + if (scwID('scwIframe')) + {scwID('scwIframe').style.left = + (scwEvt.clientX - deltaX) + 'px'; + scwID('scwIframe').style.top = + (scwEvt.clientY - deltaY) + 'px'; + } + + scwStopPropagation(scwEvt); + } + + function upHandler(scwEvt) + {if (!scwEvt) scwEvt = window.event; + + if (document.removeEventListener) + {document.removeEventListener('mousemove', + moveHandler, + true); // Capture phase + document.removeEventListener('mouseup', + upHandler, + true); // Capture phase + } + else {elementToDrag.detachEvent('onmouseup', + upHandler); // Bubbling phase + elementToDrag.detachEvent('onmousemove', + moveHandler); // Bubbling phase + elementToDrag.releaseCapture(); + } + + scwStopPropagation(scwEvt); + } + } + + function scwShowMonth(scwBias) + {// Set the selectable Month and Year + // May be called: from the left and right arrows + // (shift month -1 and +1 respectively) + // from the month selection list + // from the year selection list + // from the showCal routine + // (which initiates the display). + + var scwShowDate = new Date(Date.parse(new Date().toDateString())), + scwStartDate = new Date(); + + // Set the time to the middle of the day so that the handful of + // regions that have daylight saving shifts that change the day + // of the month (i.e. turn the clock back at midnight or forward + // at 23:00) do not mess up the date display in the calendar. + + scwShowDate.setHours(12); + + scwSelYears = scwID('scwYears'); + scwSelMonths = scwID('scwMonths'); + + if (scwSelYears.options.selectedIndex>-1) + {scwMonthSum=12*(scwSelYears.options.selectedIndex)+scwBias; + if (scwSelMonths.options.selectedIndex>-1) + {scwMonthSum+=scwSelMonths.options.selectedIndex;} + } + else + {if (scwSelMonths.options.selectedIndex>-1) + {scwMonthSum+=scwSelMonths.options.selectedIndex;} + } + + scwShowDate.setFullYear(scwBaseYear + Math.floor(scwMonthSum/12), + (scwMonthSum%12), + 1); + + // If the Week numbers are displayed, shift the week day names + // to the right. + scwID('scwWeek_').style.display= + (scwWeekNumberDisplay) + ?((scwID('scwIFrame'))?'block':'table-cell') + :'none'; + + if ((12*parseInt((scwShowDate.getFullYear()-scwBaseYear),10)) + + parseInt(scwShowDate.getMonth(),10) < (12*scwDropDownYears) && + (12*parseInt((scwShowDate.getFullYear()-scwBaseYear),10)) + + parseInt(scwShowDate.getMonth(),10) > -1) + {scwSelYears.options.selectedIndex=Math.floor(scwMonthSum/12); + scwSelMonths.options.selectedIndex=(scwMonthSum%12); + + scwCurMonth = scwShowDate.getMonth(); + + scwShowDate.setDate((((scwShowDate. + getDay()-scwWeekStart)<0)?-6:1)+ + scwWeekStart-scwShowDate.getDay()); + + // This statement moved by Michael Cerveny to make version 3.55 + var scwCompareDateValue = new Date(scwShowDate.getFullYear(), + scwShowDate.getMonth(), + scwShowDate.getDate()).valueOf(); + + scwStartDate = new Date(scwShowDate); + + if (scwID('scwFoot')) + {var scwFoot = scwID('scwFoot'); + + function scwFootOutput() {scwSetOutput(scwDateNow);} + + if (scwDisabledDates.length==0) + {if (scwActiveToday && scwParmActiveToday) + {scwFoot.onclick = scwFootOutput; + scwFoot.className = 'scwFoot'; + + if (scwID('scwIFrame')) + {scwFoot.onmouseover = scwChangeClass; + scwFoot.onmouseout = scwChangeClass; + } + + } + else + {scwFoot.onclick = null; + scwFoot.className = 'scwFootDisabled'; + + if (scwID('scwIFrame')) + {scwFoot.onmouseover = null; + scwFoot.onmouseout = null; + } + + if (document.addEventListener) + {scwFoot.addEventListener('click', + scwStopPropagation, + false); + } + else {scwFoot.attachEvent('onclick', + scwStopPropagation);} + } + } + else + {for (var k=0;k= scwDisabledDates[k][0]. + valueOf() && + scwDateNow.valueOf() <= scwDisabledDates[k][1]. + valueOf() + ) + ) + ) + ) + {scwFoot.onclick = null; + scwFoot.className = 'scwFootDisabled'; + + if (scwID('scwIFrame')) + {scwFoot.onmouseover = null; + scwFoot.onmouseout = null; + } + + if (document.addEventListener) + {scwFoot.addEventListener('click', + scwStopPropagation, + false); + } + else {scwFoot.attachEvent('onclick', + scwStopPropagation); + } + break; + } + else + {scwFoot.onclick=scwFootOutput; + scwFoot.className='scwFoot'; + + if (scwID('scwIFrame')) + {scwFoot.onmouseover = scwChangeClass; + scwFoot.onmouseout = scwChangeClass; + } + } + } + } + } + + function scwSetOutput(scwOutputDate) + {if (typeof scwTargetEle.value == 'undefined') + {scwTriggerEle.scwTextNode. + replaceData(0,scwTriggerEle.scwLength, + scwOutputDate.scwFormat(scwDateOutputFormat)); + } + else + {scwTargetEle.value = + scwOutputDate.scwFormat(scwDateOutputFormat); + } + scwHide(); + } + + function scwCellOutput(scwEvt) + {var scwEle = scwEventTrigger(scwEvt), + scwOutputDate = new Date(scwStartDate); + + if (scwEle.nodeType==3) scwEle=scwEle.parentNode; + + scwOutputDate.setDate(scwStartDate.getDate() + + parseInt(scwEle.id.substr(8),10)); + + scwSetOutput(scwOutputDate); + } + + function scwChangeClass(scwEvt) + {var scwEle = scwEventTrigger(scwEvt); + + if (scwEle.nodeType==3) scwEle=scwEle.parentNode; + + switch (scwEle.className) + {case 'scwCells': + scwEle.className = 'scwCellsHover'; + break; + case 'scwCellsHover': + scwEle.className = 'scwCells'; + break; + case 'scwCellsExMonth': + scwEle.className = 'scwCellsExMonthHover'; + break; + case 'scwCellsExMonthHover': + scwEle.className = 'scwCellsExMonth'; + break; + case 'scwCellsWeekend': + scwEle.className = 'scwCellsWeekendHover'; + break; + case 'scwCellsWeekendHover': + scwEle.className = 'scwCellsWeekend'; + break; + case 'scwFoot': + scwEle.className = 'scwFootHover'; + break; + case 'scwFootHover': + scwEle.className = 'scwFoot'; + break; + case 'scwInputDate': + scwEle.className = 'scwInputDateHover'; + break; + case 'scwInputDateHover': + scwEle.className = 'scwInputDate'; + } + + return true; + } + + function scwEventTrigger(scwEvt) + {if (!scwEvt) scwEvt = event; + return scwEvt.target||scwEvt.srcElement; + } + + function scwWeekNumber(scwInDate) + {// The base day in the week of the input date + var scwInDateWeekBase = new Date(scwInDate); + + scwInDateWeekBase.setDate(scwInDateWeekBase.getDate() + - scwInDateWeekBase.getDay() + + scwWeekNumberBaseDay + + ((scwInDate.getDay()> + scwWeekNumberBaseDay)?7:0)); + + // The first Base Day in the year + var scwFirstBaseDay = + new Date(scwInDateWeekBase.getFullYear(),0,1) + + scwFirstBaseDay.setDate(scwFirstBaseDay.getDate() + - scwFirstBaseDay.getDay() + + scwWeekNumberBaseDay + ); + + if (scwFirstBaseDay < + new Date(scwInDateWeekBase.getFullYear(),0,1)) + {scwFirstBaseDay.setDate(scwFirstBaseDay.getDate()+7);} + + // Start of Week 01 + var scwStartWeekOne = new Date(scwFirstBaseDay + - scwWeekNumberBaseDay + + scwInDate.getDay()); + + if (scwStartWeekOne > scwFirstBaseDay) + {scwStartWeekOne.setDate(scwStartWeekOne.getDate()-7);} + + // Subtract the date of the current week from the date of the + // first week of the year to get the number of weeks in + // milliseconds. Divide by the number of milliseconds + // in a week then round to no decimals in order to remove + // the effect of daylight saving. Add one to make the first + // week, week 1. Place a string zero on the front so that + // week numbers are zero filled. + + var scwWeekNo = + '0' + (Math.round((scwInDateWeekBase - + scwFirstBaseDay)/604800000,0) + 1); + + // Return the last two characters in the week number string + + return scwWeekNo.substring(scwWeekNo.length-2, + scwWeekNo.length); + } + + // Treewalk to display the dates. + // I tried to use getElementsByName but IE refused to cooperate + // so I resorted to this method which works for all tested + // browsers. + + var scwCells = scwID('scwCells'); + + for (i=0;i + (new Date(scwBaseYear+ + scwDropDownYears,0,0, + scwShowDate.getHours())) + ) + ) || + (scwOutOfMonthDisable && + (scwShowDate < + (new Date(scwShowDate.getFullYear(), + scwCurMonth,1, + scwShowDate.getHours())) + || + scwShowDate > + (new Date(scwShowDate.getFullYear(), + scwCurMonth+1,0, + scwShowDate.getHours())) + ) + ) + )?true:false; + + scwCell.style.visibility = + (scwOutOfMonthHide && + (scwShowDate < + (new Date(scwShowDate.getFullYear(), + scwCurMonth,1, + scwShowDate.getHours())) + || + scwShowDate > + (new Date(scwShowDate.getFullYear(), + scwCurMonth+1,0, + scwShowDate.getHours())) + ) + )?'hidden':''; + + for (var k=0;k= + scwDisabledDates[k][0].valueOf() + && + scwCompareDateValue <= + scwDisabledDates[k][1].valueOf() + ) + {scwDisabled = true;} + } + } + + if (scwDisabled || + !scwEnabledDay[j-1+(7*((i*scwCells. + childNodes. + length)/6))] || + !scwPassEnabledDay[(j-1+(7*(i*scwCells. + childNodes. + length/6)))%7] + ) + {scwRows.childNodes[j].onclick = null; + + if (scwID('scwIFrame')) + {scwRows.childNodes[j].onmouseover = null; + scwRows.childNodes[j].onmouseout = null; + } + + scwCell.className= + (scwShowDate.getMonth()!=scwCurMonth) + ?'scwCellsExMonthDisabled' + :(scwBlnFullInputDate && + scwShowDate.toDateString()== + scwSeedDate.toDateString()) + ?'scwInputDateDisabled' + :(scwShowDate.getDay()%6==0) + ?'scwCellsWeekendDisabled' + :'scwCellsDisabled'; + + scwCell.style.borderColor = + (scwFormatTodayCell && scwShowDate.toDateString()==scwDateNow.toDateString()) + ?scwTodayCellBorderColour + :(scwCell.currentStyle) + ?scwCell.currentStyle['backgroundColor'] + :(window.getComputedStyle) + ?document.defaultView.getComputedStyle(scwCell,null).getPropertyValue('background-color') + :''; + } + else + {scwRows.childNodes[j].onclick=scwCellOutput; + + if (scwID('scwIFrame')) + {scwRows.childNodes[j].onmouseover = + scwChangeClass; + scwRows.childNodes[j].onmouseout = + scwChangeClass; + } + + scwCell.className= + (scwShowDate.getMonth()!=scwCurMonth) + ?'scwCellsExMonth' + :(scwBlnFullInputDate && + scwShowDate.toDateString()== + scwSeedDate.toDateString()) + ?'scwInputDate' + :(scwShowDate.getDay()%6==0) + ?'scwCellsWeekend' + :'scwCells'; + + scwCell.style.borderColor = + (scwFormatTodayCell && scwShowDate.toDateString() == scwDateNow.toDateString()) + ?scwTodayCellBorderColour + :(scwCell.currentStyle) + ?scwCell.currentStyle['backgroundColor'] + :(window.getComputedStyle) + ?document.defaultView.getComputedStyle(scwCell,null).getPropertyValue('background-color') + :''; + } + + scwShowDate.setDate(scwShowDate.getDate()+1); + scwCompareDateValue = new Date(scwShowDate.getFullYear(), + scwShowDate.getMonth(), + scwShowDate.getDate()).valueOf(); + } + } + } + } + } + // Force a re-draw to prevent Opera's poor dynamic rendering + // from leaving garbage in the calendar when the displayed + // month is changed. + scwID('scw').style.visibility='hidden'; + scwID('scw').style.visibility='visible'; + } + +// ************************* +// End of Function Library +// ************************* +// *************************** +// Start of Calendar structure +// *************************** + + document.write( + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "
" + + "
" + + "" + + "" + + ""); + + for (i=0;i<7;i++) + document.write( ""); + + document.write("" + + "" + + ""); + + for (i=0;i<6;i++) + {document.write( + "" + + ""); + for (j=0;j<7;j++) + {document.write( + ""); + } + + document.write( + ""); + } + + document.write( + ""); + + if ((new Date(scwBaseYear + scwDropDownYears, 0, 0)) > scwDateNow && + (new Date(scwBaseYear, 0, 0)) < scwDateNow) + {document.write( + "" + + "" + + "" + + "" + + ""); + } + + document.write( + "
" + + "
" + + "
"); + + if (document.addEventListener) + {scwID('scw' ).addEventListener('click',scwCancel,false); + scwID('scwHeadLeft' ).addEventListener('click',scwStopPropagation,false); + scwID('scwMonths' ).addEventListener('click',scwStopPropagation,false); + scwID('scwMonths' ).addEventListener('change',scwStopPropagation,false); + scwID('scwYears' ).addEventListener('click',scwStopPropagation,false); + scwID('scwYears' ).addEventListener('change',scwStopPropagation,false); + scwID('scwHeadRight').addEventListener('click',scwStopPropagation,false); + } + else {scwID('scw' ).attachEvent('onclick',scwCancel); + scwID('scwHeadLeft' ).attachEvent('onclick',scwStopPropagation); + scwID('scwMonths' ).attachEvent('onclick',scwStopPropagation); + scwID('scwMonths' ).attachEvent('onchange',scwStopPropagation); + scwID('scwYears' ).attachEvent('onclick',scwStopPropagation); + scwID('scwYears' ).attachEvent('onchange',scwStopPropagation); + scwID('scwHeadRight').attachEvent('onclick',scwStopPropagation); + } + +// *************************** +// End of Calendar structure +// *************************** +// **************************************** +// Start of document level event definition +// **************************************** + + if (document.addEventListener) + {document.addEventListener('click',scwHide, false);} + else {document.attachEvent('onclick',scwHide);} + +// **************************************** +// End of document level event definition +// **************************************** +// ************************************ +// End of Simple Calendar Widget Code +// ************************************ \ No newline at end of file diff --git a/pandora_console/include/config.inc.php b/pandora_console/include/config.inc.php index f5c7adf35f..8ecac9e55b 100644 --- a/pandora_console/include/config.inc.php +++ b/pandora_console/include/config.inc.php @@ -30,10 +30,10 @@ $pandora_version="v1.3 devel"; //$dbhost="localhost"; // MySQL Host // This is used for reporting, please add "/" character at the end -//$config_homedir = "/var/www/babel_console/"; +//$config_homedir = "/var/www/pandora_console/"; // Do not display any ERROR -//error_reporting(0); +//error_reporting(0); // Need to use active console at this moment // Display ALL errors error_reporting(E_ALL); diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 2187135b7d..f66f6f5fd4 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -638,7 +638,6 @@ function comprueba_login() { return 0 ; } } - require("general/noaccess.php"); return 1; } @@ -1069,5 +1068,19 @@ function give_agent_id_from_module_id ($id_module){ return $pro; } +// --------------------------------------------------------------- +// Generic access to a field ($field) given a table +// --------------------------------------------------------------- + +function give_db_value ($field, $table, $field_search, $condition_value){ + global $config; + $query = "SELECT $field FROM $table WHERE $field_search = '$condition_value' "; + $resq1 = mysql_query($query); + if ($rowdup = mysql_fetch_array($resq1)) + $pro = $rowdup[0]; + else + $pro = ""; + return $pro; +} ?> diff --git a/pandora_console/include/languages/language_en.php b/pandora_console/include/languages/language_en.php index 0c429641b2..244038f9b5 100644 --- a/pandora_console/include/languages/language_en.php +++ b/pandora_console/include/languages/language_en.php @@ -768,8 +768,21 @@ $lang_label["text"]="Text"; $lang_label["delete_data_above"]="Delete data above"; $lang_label["enabled"]="Enabled"; +// 3 may 2007 +$lang_label["csv"] = "Standalone CSV ascii file"; +$lang_label["average_per_hourday"] = "Average per hour/day"; +$lang_label["datatable"] = "Data table"; +$lang_label["export_type"] = "Export type"; - +$lang_label["sunday"]="Sunday"; +$lang_label["monday"]="Monday"; +$lang_label["tuesday"]="Tuesday"; +$lang_label["wednesday"]="Wednesday"; +$lang_label["thurdsday"]="Thurdsday"; +$lang_label["friday"]="Friday"; +$lang_label["saturday"]="Saturday"; +$lang_label["hr"]="Hr"; +$lang_label["get_file"]="Download file"; global $lang_label; global $help_label; ?> diff --git a/pandora_console/include/languages/language_es_es.php b/pandora_console/include/languages/language_es_es.php index 3bc1c7bfb6..f801472d6b 100644 --- a/pandora_console/include/languages/language_es_es.php +++ b/pandora_console/include/languages/language_es_es.php @@ -296,8 +296,8 @@ $lang_label["add"]="Añadir"; $lang_label["db_purge_event"]="Limpieza de la Base de Datos de eventos"; $lang_label["db_event"]="BBDD de eventos"; $lang_label["max_min"]="Máx/Mín"; -$lang_label["max"]="Máximo"; -$lang_label["min"]="Mínimo"; +$lang_label["max"]="M�ximo"; +$lang_label["min"]="M�nimo"; $lang_label["med"]="Media"; $lang_label["month_graph"]="Gráfico mensual"; $lang_label["week_graph"]="Gráfico semanal"; @@ -356,8 +356,8 @@ $lang_label["manage_config"]="Gestionar conf."; $lang_label["config_manage"]="Gestión de Configuraciones"; $lang_label["get_info"]="Obtener info."; -$lang_label["are_you_sure"]="¿Está usted seguro?"; -$lang_label["users_msg"]="Los perfiles de usuario en Pandora definen qué usuarios pueden acceder a Pandora y que puede hacer cada uno. Los grupos definen elementos en común, cada usuario puede pertenecer a uno o más grupos, y tiene asignado un perfil a cada grupo que pertenezca. Un perfil es una lista de lo que puede y no puede hacer cada grupo, como por ejemplo «ver incidentes» o «gestionar bases de datos». Abajo se muestra una lista de los perfiles disponibles (definidos por los administradores locales de Pandora)"; +$lang_label["are_you_sure"]="�Está usted seguro?"; +$lang_label["users_msg"]="Los perfiles de usuario en Pandora definen qué usuarios pueden acceder a Pandora y que puede hacer cada uno. Los grupos definen elementos en común, cada usuario puede pertenecer a uno o más grupos, y tiene asignado un perfil a cada grupo que pertenezca. Un perfil es una lista de lo que puede y no puede hacer cada grupo, como por ejemplo �ver incidentes� o �gestionar bases de datos�. Abajo se muestra una lista de los perfiles disponibles (definidos por los administradores locales de Pandora)"; $help_label["users_msg1"]="Este usuario es especial y tiene permiso para todo, pasando por encima de los privilegios asignados mediante grupos/perfiles"; $help_label["users_msg2"]="Este usuario tiene permisos segregados para ver datos en los agente de su grupo, crear incidentes dentro de aquellos grupos sobre los que tenga acceso y añadir notas en incidentes propios o de terceros"; @@ -454,7 +454,7 @@ $lang_label["inagent"]=" en el agente "; $lang_label["you_must_select_modules"]="Se deben seleccionar módulos y/o alertas como objeto de la copia"; $lang_label["packets_by_date"]="Paquetes por rangos de fecha"; $lang_label["packets_by_agent"]="Paquetes por agente"; -$lang_label["modules_per_agent"]="Módulos por agente"; // Graphic title, dont use tildes +$lang_label["modules_per_agent"]="M�dulos por agente"; // Graphic title, dont use tildes $lang_label["event_total"]="Eventos totales"; $lang_label["events_per_user"]="Eventos por usuario"; $lang_label["events_per_group"]="Eventos por grupo"; @@ -537,7 +537,7 @@ $lang_label["validate"]="Validar"; $lang_label["incident_user"]="Autores de los incidentes"; $lang_label["incident_source"]="Origenes de los incidentes"; $lang_label["incident_group"]="Grupos de los incidentes"; -$lang_label["users_statistics"]="Estadísticas de actividad de los usuarios"; +$lang_label["users_statistics"]="Estad�sticas de actividad de los usuarios"; $lang_label["update_user_ok"]="Usuario actualizado correctamente"; $lang_label["agent_detail"]="Detalle agente"; @@ -665,6 +665,7 @@ $lang_label["no_rtask"]="No hay ninguna tarea de reconocimiento configurada"; //3 Apr 2007 $lang_label["no_netprofiles"]="No hay ningún perfil de red definido"; + global $lang_label; global $help_label; ?> diff --git a/pandora_console/index.php b/pandora_console/index.php index eaf6bdc1a5..83378b32f8 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -5,11 +5,11 @@ // Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com // Main PHP/SQL code development and project architecture and management // Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com -// CSS and some PHP additions +// CSS and some PHP code additions // Copyright (c) 2006-2007 Jonathan Barajas, jonathan.barajas[AT]gmail[DOT]com // Javascript Active Console code. // Copyright (c) 2006 Jose Navarro -// Additions to Pandora FMS 1.2 graph code and new XML reporting template management +// Additions to code for Pandora FMS 1.2 graph code and new XML reporting template managemement // Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es // // This program is free software; you can redistribute it and/or @@ -25,9 +25,7 @@ // Pandora FMS 1.x uses icons from famfamfam, licensed under CC Atr. 2.5 // Silk icon set 1.3 (cc) Mark James, http://www.famfamfam.com/lab/icons/silk/ - // Pandora FMS 1.x uses Pear Image::Graph code - // Pandora FMS shares much of it's code with project Babel Enterprise, also a // FreeSoftware Project coded by some of the people who makes Pandora FMS @@ -94,6 +92,7 @@ if (isset ($_GET["refr"])){ +

Pandora FMS console installation wizard. Step #3 of 4

-
+

Environment and database setup

diff --git a/pandora_console/operation/active_console/index.php b/pandora_console/operation/active_console/index.php index 45df2e3188..4f2ecb78fc 100644 --- a/pandora_console/operation/active_console/index.php +++ b/pandora_console/operation/active_console/index.php @@ -20,6 +20,10 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require("../../include/config.php"); +// If you activate error reporting, Active Console don't work +// because it has MANY warnings and other kind of errors + +error_reporting(0); global $dbname; global $dbuser; global $dbpassword; @@ -44,7 +48,8 @@ session_start(); "); } ?> @@ -256,7 +261,7 @@ while ($vista=mysql_fetch_array($vistas)){ //recorremos las vistas y creamos un // Creamos las instancias de los objetos (que se corresponderan con los ids de los divs html) $i=1; -//global $aObjetos; + $aObjetos = array(); //mysql_data_seek($objetos,0); $objetos = dameObjetosVista($vista["idVista"]); @@ -301,53 +306,22 @@ while ($vista=mysql_fetch_array($vistas)){ //recorremos las vistas y creamos un $i=$i+1; } - -// echo "var jg_doc = new jsGraphics(); -// -// jg_doc.setColor('#ff0000'); // red -// jg_doc.drawLine(10, 113, 220, 55); // co-ordinates related to 'myCanvas' -// jg_doc.setColor('#0000ff'); // blue -// jg_doc.fillRect(110, 120, 30, 60); -// jg_doc.paint(); -// "; - - } -//$objetos = dameObjetos(); -// echo "var aObjeto_count = 0;"; -// echo "aObjeto_count=1;"; -//echo "aObjeto = new Array(), aObjeto_count =".mysql_num_rows($objetos).";"; - - - - - - echo " - - -var tpg2; - - tpg2 = new xTabPanelGroup('tpg2', 1000, 1000, 25, 'tabPanel', 'tabGroup', 'tabDefault', 'tabSelected'); - - -tpg2.select(parseInt(vistaActiva)+1); - - FormSetup(); - + var tpg2; + tpg2 = new xTabPanelGroup('tpg2', 1000, 1000, 25, 'tabPanel', 'tabGroup', 'tabDefault', 'tabSelected'); + tpg2.select(parseInt(vistaActiva)+1); + FormSetup(); } "; - - $vista_activa=obtenerVistaActiva(); // Obtenemos la acción a realizar mediante los parametros GET y el nombre "action" - // Una vez aparecido el formulario añadimos a la base de datos, los valores recogidos -if ($_GET["action"]=="addagent") -{ +if ($_GET["action"]=="addagent"){ + $aSub[0]=$_POST["vista_MG"]; // Crear el objeto en forma de vista y que se cree una vista con los grupos de modulos que lo forman $aSub[1]=$_POST["vista_M"]; // Crear el objeto en forma de vista y que se cree una vista con los modulos que lo forman @@ -1250,7 +1224,7 @@ $perfil = obtenerPerfilActivo(); // Obtenemos las vistas asignadas al perfil especial activo con id igual a 2 y creamos un array JavaScript que contendrá las Vistas $vistas = dameVistasPerfilActivas($perfil); // mysql_data_seek($vistas,0); -while ($vista=mysql_fetch_array($vistas)){ +if ($vista=mysql_fetch_array($vistas)){ $datos_vista=dameVista($vista["idVista"]); $estado_vista=dameEstadoVista($vista["idVista"]); $css_estado_vista=""; diff --git a/pandora_console/operation/active_console/lib/db_functions.php b/pandora_console/operation/active_console/lib/db_functions.php index da52748e27..e243724f21 100644 --- a/pandora_console/operation/active_console/lib/db_functions.php +++ b/pandora_console/operation/active_console/lib/db_functions.php @@ -1,271 +1,138 @@ +// Additions to code for Pandora FMS 1.2 graph code and new XML reporting template managemement +// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es +// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -include "../../include/config.php"; - -//abrir y seleccionar la base de datos de pandora - -function opendb() -{ - global $dbname, $dbuser, $dbpassword, $dbhost; - - $link = mysql_pconnect($dbhost,$dbuser,$dbpassword); - if (!$link) { - die('Could not connect: ' . mysql_error()); - } - if (!mysql_select_db($dbname, $link)) { - echo 'Could not select database'; - exit; - } -} - -//cerrar la base de datos -function closedb() -{ -// mysql_close(); - -} +require "/var/www/pandora_console/include/config.php"; // retorna el array con los agentes existente en la base de datos function dameAgentes(){ - - - opendb(); - $query1="SELECT * FROM tagente;"; $resq1=mysql_query($query1); - - closedb(); - return $resq1; - } // retorna el array con los modulos asignados a un agente que es identificado por su id_agente como parametro function dameModulos($id_agente){ - - - opendb(); - $query1="SELECT * FROM tagente_modulo where id_agente=".$id_agente.";"; $resq1=mysql_query($query1); - - closedb(); - return $resq1; - } // retorna el array con los grupos de agentes existente en la base de datos function dameGruposAgentes(){ - - - opendb(); - $query1="SELECT * FROM tgrupo;"; $resq1=mysql_query($query1); - - closedb(); - return $resq1; - } -// retorna el array con los grupos de agentes que contengan algún agente, devuelve -1 si no hay grupo de agentes con agentes -function dameGruposAgentesConAgentes() -{ - - opendb(); - +// retorna el array con los grupos de agentes que contengan algún agente, +// devuelve -1 si no hay grupo de agentes con agentes +function dameGruposAgentesConAgentes(){ $query1="SELECT * FROM tgrupo where id_grupo in (select id_grupo from tagente group by id_grupo);"; $resq1=mysql_query($query1); - -// echo "-------------------".$resq1; if ($resq1) - { return $resq1; - }else - { + else return -1; - } -closedb(); } // retorna el array con los agentes pertenecientes al grupo de agentes identificado por su id -function dameAgentesDelGrupAogentes($id_grupo) -{ - - opendb(); - +function dameAgentesDelGrupAogentes($id_grupo){ $query1="SELECT * FROM tagente where id_grupo='".$id_grupo."'"; $resq1=mysql_query($query1); - - closedb(); - return $resq1; - } // retorna el array con los grupos existentes en la bd con nombre que se le pasa como parametro function dameGrupoAgente($id_grupo){ - - - opendb(); - $query1="SELECT * FROM tgrupo where id_grupo=".$id_grupo.";"; $resq1=mysql_query($query1); $row_grupo=mysql_fetch_array($resq1); - - closedb(); - return $row_grupo; - } // retorna el id_agent pasandole como argumento el nombre del agente -function dameIdAgente($nombre) -{ - opendb(); - +function dameIdAgente($nombre){ $query_agent="SELECT id_agente FROM tagente where nombre='".$nombre."';"; $resq1_agent=mysql_query($query_agent); $row_agent=mysql_fetch_array($resq1_agent); - - closedb(); - return $row_agent["id_agente"]; } // retorna el id_agent_modulo pasandole como argumento el id del agente y el nombre del modulo -function dameIdModulo($id_agente,$nombre) -{ - opendb(); - +function dameIdModulo($id_agente,$nombre){ $query_agent="SELECT id_agente_modulo FROM tagente_modulo where nombre='".$nombre."' and id_agente='".$id_agente."';"; $resq1_agent=mysql_query($query_agent); - $row_agent=mysql_fetch_array($resq1_agent); - - closedb(); - + $row_agent=mysql_fetch_array($resq1_agent); return $row_agent["id_agente_modulo"]; } // retorna el id_grupo pasandole como argumento el nombre del grupo -function dameIdGrupoAgente($nombre) -{ - opendb(); - +function dameIdGrupoAgente($nombre){ $query_agent="SELECT id_grupo FROM tgrupo where nombre='".$nombre."';"; $resq1_agent=mysql_query($query_agent); $row_agent=mysql_fetch_array($resq1_agent); - - closedb(); - return $row_agent["id_grupo"]; } // retorna el id_grupo_modulo pasandole como argumento el nombre del grupo_modulo -function dameIdGrupoModulo($nombre) -{ - opendb(); - +function dameIdGrupoModulo($nombre){ $query_agent="SELECT id_mg FROM tmodule_group where name='".$nombre."';"; $resq1_agent=mysql_query($query_agent); $row_agent=mysql_fetch_array($resq1_agent); - - closedb(); - return $row_agent["id_mg"]; } // devuelve los grupos de modulos existentes para el agente identificado con su id y que se pasa como parametro -function dameGruposModuloDelAgente($id_agente) -{ - opendb(); - +function dameGruposModuloDelAgente($id_agente){ $query1="SELECT TMG.name, TMG.id_mg FROM tmodule_group TMG, tagente_modulo TAM WHERE TMG.id_mg = TAM.id_module_group AND TAM.id_module_group >0 AND TAM.id_agente=".$id_agente." group by TMG.id_mg"; - $resq1=mysql_query($query1); - - closedb(); - return $resq1; } // devuelve los modulos del agente identificado por su que no pertenecen a ningun grupo de modulos -function dameModulosSinGrupo($id_agente) -{ - opendb(); - +function dameModulosSinGrupo($id_agente){ $query1="SELECT * from tagente_modulo where id_agente='".$id_agente."' and id_module_group=0"; - $resq1=mysql_query($query1); - - closedb(); - return $resq1; } // Funcion que devuelve los modulos de un determinado grupo de modulos y de un agente -function dameModulosDelGrupoModulosAgente($id_agente,$id_mg) -{ - opendb(); - +function dameModulosDelGrupoModulosAgente($id_agente,$id_mg){ $query1="Select * from tagente_modulo where id_agente=".$id_agente." and id_module_group=".$id_mg.";"; - $resq1=mysql_query($query1); - - closedb(); - return $resq1; - - } // devuleve los modulos de un agente determinado y de un grupo de modulos determinado (recive el id_agente y el id del grupo de modulos) -function dameModulosGrupo($id_mg,$id_agente) -{ - opendb(); - +function dameModulosGrupo($id_mg,$id_agente){ $query1="Select * from tagente_modulo where id_agente=".$id_agente." and id_module_group=".$id_mg.""; $resq1=mysql_query($query1); - - closedb(); - return $resq1; - } // inserta un objeto pasandole: nombre de la imagen, tipo del objeto, posicion left, posicion top, id tipo del objeto -function addObject($nom_img, $tipo, $left, $top, $id_tipo) -{ - +function addObject($nom_img, $tipo, $left, $top, $id_tipo){ if ($tipo=="GA") //como el grupo ya tiene una imagen asignada, la aprovechamos { $grupoAgente=dameGrupoAgente($id_tipo); $nom_img=$grupoAgente["icon"]; } - - opendb(); $query1="INSERT INTO objeto_consola (`nom_img`,`tipo`,`left`,`top`,`id_tipo`) VALUES ('".$nom_img."', '".$tipo."', $left, $top, $id_tipo);"; $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); @@ -273,31 +140,19 @@ function addObject($nom_img, $tipo, $left, $top, $id_tipo) $resq2=mysql_query($query2) or die('Error, insert query failed'.$query2. mysql_error()); $rowidObjeto=mysql_fetch_array($resq2); - closedb(); return $rowidObjeto; } // retorna el array con los objetos existentes en la base de datos function dameObjetos(){ - - - opendb(); - $query1="SELECT * FROM objeto_consola;"; $resq1=mysql_query($query1); - - closedb(); - return $resq1; - } // guardamos una vista nueva pasandole su nombre y una descripcion. Devuelve el id adjudicado a la nueva vista. -function guardarNuevaVista($nombre, $descripcion,$idPerfil) -{ - +function guardarNuevaVista($nombre, $descripcion,$idPerfil){ - opendb(); $query1="INSERT INTO vistas_consola (`nombre`,`descripcion`) VALUES ('".$nombre."', '".$descripcion."');"; $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); @@ -306,9 +161,6 @@ function guardarNuevaVista($nombre, $descripcion,$idPerfil) // Insertamos la nueva vista al perfil activo (id=2) $query2="INSERT INTO perfil_vista (`idPerfil`,`idVista`) VALUES ('".$idPerfil."', '".$idVista."');"; $resq2=mysql_query($query2) or die('Error, insert query failed'.$query2. mysql_error()); - - closedb(); - return $idVista; } @@ -320,144 +172,86 @@ function guardarNuevaVista($nombre, $descripcion,$idPerfil) // $idVista: id de la vista a la que pertenece // Devuelve -1 si la vista que será representada por el objeto no tiene ya un objeto vista de la vista donde insertaremos el objeto. -function nuevoObjEnVista($nom_img,$tipo,$left,$top,$id_tipo,$idVista) -{ - opendb(); - +function nuevoObjEnVista($nom_img,$tipo,$left,$top,$id_tipo,$idVista){ $objVista=true; - if ($tipo == "V") // Comprobamos que la vista que será representada por el objeto no tiene ya un objeto vista de la vista donde insertaremos el objeto. :-s - { + if ($tipo == "V"){ // Comprobamos que la vista que será representada por el objeto no tiene ya un objeto vista de la vista donde insertaremos el objeto. :-s $objs = dameObjetosVista($id_tipo); while ($objeto=mysql_fetch_array($objs)){ - if ($objeto["id_tipo"]==$idVista) - { + if ($objeto["id_tipo"]==$idVista){ $objVista=false; } - } - } - if ($objVista) - { + if ($objVista){ $query1="INSERT INTO objeto_consola (`nom_img`,`tipo`,`left`,`top`,`id_tipo`,`idVista`) VALUES ('".$nom_img."', '".$tipo."', '".$left."', '".$top."', '".$id_tipo."', '".$idVista."');"; $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); - }else - { - return -1; - } - - closedb(); - + } else + return -1; + } // Crea un nuevo objeto a partir de uno ya existente (util para copiar objeto de una vista a otra) function copiaObjEnNuevaVista($idVista,$idObjeto) { - opendb(); - $queryObj="SELECT * FROM objeto_consola where id_objeto=".$idObjeto.";"; $resqObj=mysql_query($queryObj); $obj=mysql_fetch_array($resqObj); $query1="INSERT INTO objeto_consola (`nom_img`,`tipo`,`left`,`top`,`id_tipo`,`idVista`) VALUES ('".$obj["nom_img"]."', '".$obj["tipo"]."', '".$obj["left"]."', '".$obj["top"]."', '".$obj["id_tipo"]."', '".$idVista."');"; $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); - - closedb(); - } // retorna el array con las vistas existentes en la base de datos function dameVistas(){ - - - opendb(); - $queryVista="SELECT * FROM vistas_consola;"; $resqVista=mysql_query($queryVista); - - closedb(); - return $resqVista; - } // retorna el array con los ids de los objetos que pertenecen a la vista pasada como parametro function dameObjetosVista($id_vista){ - - - opendb(); - $queryObj="SELECT * FROM objeto_consola where idVista=".$id_vista." order by idVista, id_objeto;"; $resqObj=mysql_query($queryObj); - - closedb(); - return $resqObj; - } // se devuelve la vista que es referencia por su id que se pasa como parametro function dameVista($idVista) { - opendb(); - $query_vista="SELECT * FROM vistas_consola where idVista='".$idVista."';"; $resq1_vista=mysql_query($query_vista); $vista=mysql_fetch_array($resq1_vista); - - closedb(); - return $vista; } // se retorna el objeto que es referenciado por su idObjeto function dameObjeto($idObjeto) { - opendb(); - $query_objeto="SELECT * FROM objeto_consola where id_objeto='".$idObjeto."';"; $resq1_objeto=mysql_query($query_objeto); $objeto=mysql_fetch_array($resq1_objeto); - - closedb(); - return $objeto; } // Funcion que edita un objeto (de momento solo la imagen) function editarObjeto($idObjeto,$nom_img) { - opendb(); - $query_objeto="UPDATE objeto_consola set nom_img='".$nom_img."' where id_objeto='".$idObjeto."';"; mysql_query($query_objeto) or die("Failed Query of " . $query_objeto);; - - - closedb(); - } // Funcion que elimina un objeto function eliminarObjeto($idObjeto) { - opendb(); - $query_objeto="DELETE from objeto_consola where id_objeto='".$idObjeto."';"; mysql_query($query_objeto) or die("Failed Query of " . $query_objeto); - - - closedb(); - } // retorna el nombre del objeto referenciado por su tipo y por su y por su id de tipo function dameNombreObjeto($idTipo,$tipo) { - $nombre=""; - opendb(); - switch ($tipo) { case "A": //agente $query_objeto="SELECT * FROM tagente where id_agente='".$idTipo."';"; @@ -490,201 +284,74 @@ function dameNombreObjeto($idTipo,$tipo) $nombre=$objeto["nombre"]; break; } - - - - closedb(); - return $nombre; } //Inserta un nuevo perfil en la base de datos y retorna su id function guardarNuevoPefil ($nombre,$descripcion) { - opendb(); + $query1="INSERT INTO perfil (`nombre`,`descripcion`) VALUES ('".$nombre."', '".$descripcion."');"; $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); - $idPerfil=mysql_insert_id(); - // Creamos una vista para el perfil $query3="INSERT INTO vistas_consola (`nombre`,`descripcion`) VALUES ('default', 'default');"; $resq3=mysql_query($query3) or die('Error, insert query failed'.$query3. mysql_error()); - $idVista=mysql_insert_id(); - - $query2="INSERT INTO perfil_vista (`idPerfil`,`idVista`) VALUES ('".$idPerfil."', '".$idVista."');"; $resq2=mysql_query($query2) or die('Error, insert query failed'.$query1. mysql_error()); - closedb(); - return $idPerfil; } // retorna el array con las vistas existentes para el perfil especificado mediante parametro function dameVistasPerfil($idPerfil){ - - - opendb(); - $queryVista="SELECT * FROM perfil_vista where idPerfil=".$idPerfil.";"; $resqVista=mysql_query($queryVista); - - closedb(); - return $resqVista; - } // retorna el array con las vistas existentes para el perfil especificado mediante parametro y tienen su campo activa = 1 function dameVistasPerfilActivas($idPerfil){ - - - opendb(); - $queryVista="SELECT * FROM perfil_vista where idPerfil=".$idPerfil." and activa=1;"; $resqVista=mysql_query($queryVista); - - closedb(); - return $resqVista; - } -// // Esta funcion intenta obtener el id del perfil que esta cargado actualmente -// function obtenerPerfilActivo() -// { -// opendb(); -// -// $queryVista="SELECT * FROM perfil_vista where idPerfil=2;"; -// $resqVista=mysql_query($queryVista); -// $perfil_vista=mysql_fetch_array($resqVista); -// -// $queryVista2="SELECT * FROM perfil_vista where idPerfil<>'2' and idVista='".$perfil_vista['idVista']."';"; -// $resqVista2=mysql_query($queryVista2); -// $perfil=mysql_fetch_array($resqVista2); -// -// closedb(); -// -// return $perfil['idPerfil']; -// -// } - // Retorna un array con todos los Perfiles excepto los especiales Default(id=1) y PerfilActivo(id=2) - function damePerfiles(){ - opendb(); - $query1="SELECT * FROM perfil;"; $resq1=mysql_query($query1); - - closedb(); - return $resq1; - } // se devuelve el perfil referenciado por su id que se pasa como parametro -function damePerfil($idPerfil) -{ - opendb(); - +function damePerfil($idPerfil){ $query_perfil="SELECT * FROM perfil where idPerfil=".$idPerfil.";"; $resq1_perfil=mysql_query($query_perfil); $perfil=mysql_fetch_array($resq1_perfil); - - closedb(); - return $perfil; } // Devuelve un perfil cualquiera (Utilizado a la hora de borrar el perfil que esta en curso, con esto se carga otro perfil existente) function damePerfilCualquiera(){ - opendb(); - $query1="SELECT * FROM perfil;"; $resq1=mysql_query($query1); $perfil=mysql_fetch_array($resq1); - - closedb(); - return $perfil; - } // Devuelve una vista cualquiera de las que estan visibles (Utilizado a la hora de cerrar una Vista que esta en curso, con esto se carga otra Vista existente) function dameVistaCualquiera($idPerfil){ - opendb(); - $query1="SELECT * FROM perfil_vista where idPerfil=".$idPerfil." and activa='1';"; $resq1=mysql_query($query1); $vista=mysql_fetch_array($resq1); - - closedb(); - return $vista; - } -// // Existe un perfil especial (id = 2) que es el perfil activo. Así cuando se abre un perfil, se carga en el perfil activo y se representa. Esta funcion borra lo que haya en el perfil activo, y carga el nuevo perfil a representar. -// function cargarPerfil($idPerfil) -// { -// -// opendb(); -// -// // Borramos todo lo que haya cargado en el perfil activo -// $deleteQuery="Delete from perfil_vista where idPerfil=2"; -// $resqDelete=mysql_query($deleteQuery); -// -// // Recogemos las vistas del nuevo Perfil -// $queryPerfil="SELECT * FROM perfil_vista where idPerfil=".$idPerfil.";"; -// $resqPerfil=mysql_query($queryPerfil); -// -// // Cargamos en el perfil activo las vistas del nuevo Perfil -// while ($perfil_vista=mysql_fetch_array($resqPerfil)){ -// -// $query1="INSERT INTO perfil_vista (`idPerfil`,`idVista`) VALUES ('2', '".$perfil_vista["idVista"]."');"; -// $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); -// -// } -// -// -// closedb(); -// -// } - -// // Recupera todas las vistas del perfil activo (id=2) y las añade al perfil que se le pasa como parametro -// function guardarPerfil($idPerfil) -// { -// opendb(); -// -// // Recogemos las vistas del Perfil Activo -// $queryPerfil="SELECT * FROM perfil_vista where idPerfil=2;"; -// $resqPerfil=mysql_query($queryPerfil); -// -// // Borramos todo lo que habia en el antiguo perfil -// $deleteQuery="Delete from perfil_vista where idPerfil=".$idPerfil; -// $resqDelete=mysql_query($deleteQuery); -// -// // Cargamos en el Perfil que queremos guardar, todas las vistas que existian en el activo -// while ($perfil_vista=mysql_fetch_array($resqPerfil)){ -// -// $query1="INSERT INTO perfil_vista (`idPerfil`,`idVista`) VALUES ('".$idPerfil."', '".$perfil_vista["idVista"]."');"; -// $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); -// -// } -// -// closedb(); -// -// } - // Funcion que elimina una vista y todos sus objetos. Devuelve el codigo de error 1 si es la ultima vista, no borrandola. -function eliminarVista($idVista) -{ - opendb(); - +function eliminarVista($idVista){ // comprobamos que no es la ultima vista existente en el perfil // $queryCheck="SELECT * FROM perfil_vista where idPerfil=(Select idPerfil from perfil_vista where idVista=".$idVista.") ;"; $queryCheck="SELECT pv.* FROM perfil_vista pv , perfil_vista pv2 where pv.idPerfil=pv2.idPerfil and pv2.idVista='".$idVista."'"; @@ -713,51 +380,35 @@ function eliminarVista($idVista) mysql_query($query_vista) or die("Failed Query of " . $query_vista); - }else return 1; // ERROR: solo queda una vista y no se puede borrar - - - - closedb(); - + } else + return 1; // ERROR: solo queda una vista y no se puede borrar } // Retorna los valores de la consola para el usuario pasado como parametro -function dameEstadoConsola($usuario) -{ - opendb(); +function dameEstadoConsola($usuario){ $query1="SELECT * FROM estado_consola where id_usuario='".$usuario."';"; $resq1=mysql_query($query1); - - closedb(); - return mysql_fetch_array($resq1); - } // Funcion que edita una Vista (id de la vista , nombre , descripcion) -function editarVista($idVista,$nombre,$descripcion) -{ - opendb(); +function editarVista($idVista,$nombre,$descripcion){ $query_vista="UPDATE vistas_consola set nombre='".$nombre."' , descripcion='".$descripcion."' where idVista='".$idVista."';"; mysql_query($query_vista) or die("Failed Query of " . $query_vista);; - - - closedb(); - } // Funcion que edita un Perfil (id del Perfil , nombre , descripcion) function editarPerfil($idPerfil,$nombre,$descripcion) { - opendb(); + $query_perfil="UPDATE perfil set Nombre='".$nombre."' , Descripcion='".$descripcion."' where idPerfil='".$idPerfil."';"; mysql_query($query_perfil) or die("Failed Query of " . $query_perfil);; - closedb(); + } @@ -766,7 +417,7 @@ function editarPerfil($idPerfil,$nombre,$descripcion) function eliminarPerfil($idPerfil) { - opendb(); + $queryCheck="SELECT * FROM perfil ;"; $numPerfilesexe=mysql_query($queryCheck); @@ -811,7 +462,7 @@ function eliminarPerfil($idPerfil) return $idPerfil; }else return -1; - closedb(); + } @@ -819,13 +470,13 @@ function eliminarPerfil($idPerfil) function activarVista($idVista) { - opendb(); + $query_vista="UPDATE perfil_vista set activa=1 where idVista=".$idVista.";"; mysql_query($query_vista) or die("Failed Query of " . $query_vista);; - closedb(); + } @@ -833,20 +484,20 @@ function activarVista($idVista) function desactivarVista($idVista) { - opendb(); + $query_vista="UPDATE perfil_vista set activa = 0 where idVista='".$idVista."';"; mysql_query($query_vista) or die("Failed Query of " . $query_vista);; - closedb(); + } // Funcion que devuelve 1 si es la ultima vista activa del perfil, o devuelve 0 si no lo es function es_ultimaVistaActiva($idPerfil) { - opendb(); + $queryCheck="SELECT * FROM perfil_vista where idPerfil=".$idPerfil." and activa=1 ;"; $numVistasexe=mysql_query($queryCheck); @@ -861,7 +512,7 @@ function es_ultimaVistaActiva($idPerfil) function esVistaActiva($idVista,$idPerfil) { - opendb(); + $queryCheck="SELECT * FROM perfil_vista where idVista='".$idVista."' and idPerfil=".$idPerfil.";"; $vista_exe=mysql_query($queryCheck); @@ -875,24 +526,24 @@ function esVistaActiva($idVista,$idPerfil) function crearRelacionObjetos($idObjeto1, $idObjeto2) { - opendb(); + $query1="INSERT INTO relacion_objetos (`idObjeto1`,`idObjeto2`) VALUES ('".$idObjeto1."', '".$idObjeto2."');"; $resq1=mysql_query($query1) or die('Error, insert query failed'.$query1. mysql_error()); - closedb(); + } //Devuelve todas las relaciones del objeto pasado como parametro y que sea el Objeto 1 de la relacion, si no tiene ninguna relación, devuelve -1 function dameRelacionesObjeto($idObjeto) { - opendb(); + $query1="SELECT * FROM relacion_objetos where idObjeto1='".$idObjeto."' or idObjeto2='".$idObjeto."';"; $resq1=mysql_query($query1); - closedb(); + $numRelaciones = mysql_num_rows($resq1); if ($numRelaciones > 0) @@ -905,11 +556,11 @@ function dameRelacionesObjeto($idObjeto) //Funcion que devuelve 1 si el objeto pertence a la vista y 0 si no function esObjetoDeVista($idObjeto,$idVista) { - opendb(); + $query1="SELECT * FROM objeto_consola where id_objeto='".$idObjeto."' and idVista='".$idVista."';"; $resq1=mysql_query($query1); - closedb(); + $objVista = mysql_num_rows($resq1); if ($objVista > 0) @@ -921,12 +572,12 @@ function esObjetoDeVista($idObjeto,$idVista) // Funcion que devuelve las relaciones entre objetos de la vista que se le pasa como parametro. function dameRelacionesVista($idVista) { - opendb(); + $query1="Select idObjeto1, idObjeto2 from relacion_objetos, objeto_consola where idVista='".$idVista."' and idObjeto1 = id_objeto ;"; $resq1=mysql_query($query1); - closedb(); + return $resq1; @@ -935,11 +586,11 @@ function dameRelacionesVista($idVista) // Funcion que elimina una relacion entre dos objetos function eliminarRelacion($obj1, $obj2) { - opendb(); + $query_relacion="DELETE from relacion_objetos where idObjeto1='".$obj1."' and idObjeto2='".$obj2."';"; mysql_query($query_relacion) or die("Failed Query of " . $query_relacion); - closedb(); + } @@ -949,7 +600,7 @@ function dameEstadoObjeto($idObjeto) $estado=-1000; - opendb(); + $query="Select * from objeto_consola where id_objeto='".$idObjeto."';"; $objetoexe=mysql_query($query) or die("Failed Query of " . $query); @@ -1024,7 +675,7 @@ function dameEstadoObjeto($idObjeto) } - closedb(); + // mensaje($estado); @@ -1142,7 +793,7 @@ function dameEstadoGrupoAgentes($idGrupoAgente) //Funcion que devuelve el estado de una vista 0=MAL, 1=BIEN, 2=CAMBIANDO, -1=DESCONECTADO function dameEstadoVista($idVista) { - opendb(); + $estado=1; $query="Select * from objeto_consola where idVista='".$idVista."';"; $resq1=mysql_query($query); @@ -1183,7 +834,7 @@ function dameEstadoVista($idVista) return $estado; - closedb(); + } @@ -1192,7 +843,7 @@ function comprobarAlertaObjeto($idObjeto) $alerta=0; - opendb(); + $query="Select * from objeto_consola where id_objeto='".$idObjeto."';"; $objetoexe=mysql_query($query) or die("Failed Query of " . $query); @@ -1218,7 +869,7 @@ function comprobarAlertaObjeto($idObjeto) } - closedb(); + return $alerta; @@ -1329,13 +980,13 @@ function comprobarAlertaVista($idVista) function guardarPosicion($idObjeto,$left,$top) { - opendb(); + $query_objeto="UPDATE `objeto_consola` SET `left` = '".$left."', `top` = '".$top."' WHERE `id_objeto` = ".$idObjeto." LIMIT 1;"; mysql_query($query_objeto) or die("Failed Query of " . $query_objeto);; - closedb(); + } @@ -1345,7 +996,7 @@ function guardarPosicion($idObjeto,$left,$top) function crearRelacionEstado($idObjeto, $expresion) { - opendb(); + $query1="INSERT INTO relacion_estado (`id_objeto`,`relacion`) VALUES ('".$idObjeto."', '".$expresion."');"; $resq1=mysql_query($query1); @@ -1354,7 +1005,7 @@ function crearRelacionEstado($idObjeto, $expresion) return -1; } - closedb(); + } @@ -1406,12 +1057,12 @@ function dameEstadoEditadoObjeto ($idObjeto, $expresion) // Funcion que devuelve las relaciones de estado existentes en una vista function dameRelacionesEstadoVista($idVista) { - opendb(); + $query1="Select rs.id_objeto from relacion_estado rs, objeto_consola oc where idVista='".$idVista."' and rs.id_objeto = oc.id_objeto ;"; $resq1=mysql_query($query1); - closedb(); + return $resq1; @@ -1534,9 +1185,7 @@ function comprobarConexionAgente($idTipo) return $conectado; } -function comprobarConexionGrupoAgentes($id_grupo) -{ - +function comprobarConexionGrupoAgentes($id_grupo){ $query2="SELECT * FROM tagente_modulo WHERE id_agente in (select id_agente from tagente where id_grupo='".$id_grupo."') "; $modulos=mysql_query($query2); while ($modulo=mysql_fetch_array($modulos)) @@ -1550,13 +1199,10 @@ function comprobarConexionGrupoAgentes($id_grupo) } return 0; - } - -function comprobarConexionVista($idVista) -{ +function comprobarConexionVista($idVista){ $query="Select * from objeto_consola where idVista='".$idVista."';"; $resq1=mysql_query($query); while ($objeto_vista=mysql_fetch_array($resq1)) @@ -1583,31 +1229,19 @@ function comprobarConexionVista($idVista) } // Funcion que devuelve el ultimo valor recogido por el modulo -function ultimoValorModulo($idModulo) -{ - +function ultimoValorModulo($idModulo){ $query="Select * from tagente_datos where id_agente_modulo='".$idModulo."' order by timestamp desc limit 1;"; $resq1=mysql_query($query); $modulo=mysql_fetch_array($resq1); return $modulo["datos"]; - } // Funcion que sustituye el actual icono de un objeto Modulo por su grafica -function setImagenGrafica($idModulo) -{ - - opendb(); - +function setImagenGrafica($idModulo){ $query_objeto="UPDATE objeto_consola SET nom_img='grafica' WHERE id_objeto='".$idModulo."';"; mysql_query($query_objeto) or die("Failed Query of " . $query_objeto);; - - - closedb(); - - } ?> \ No newline at end of file diff --git a/pandora_console/operation/active_console/lib/extra_functions.php b/pandora_console/operation/active_console/lib/extra_functions.php index a33138a07a..ea2e885edf 100644 --- a/pandora_console/operation/active_console/lib/extra_functions.php +++ b/pandora_console/operation/active_console/lib/extra_functions.php @@ -1,29 +1,26 @@ +// Additions to code for Pandora FMS 1.2 graph code and new XML reporting template managemement +// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es +// $graphURL="http://".$_SERVER['SERVER_NAME']."/reporting/fgraph.php"; function obtenerVistaActiva() -{ - +{ // Obtenemos la cookie estado y consultamos cual es la vista activa - $cookieVista = $_COOKIE["estado"]; + if (isset($_COOKIE["estado"])) + $cookieVista = $_COOKIE["estado"]; + else + $cookieVista = null; if ($cookieVista != null) { @@ -75,41 +72,29 @@ function obtenerVistaActiva() } -function obtenerPerfilActivo() -{ - - +function obtenerPerfilActivo(){ // Obtenemos la cookie estado y consultamos cual es la vista activa - $cookiePerfil = $_COOKIE["estado"]; + if (isset($_COOKIE["estado"])) + $cookiePerfil = $_COOKIE["estado"]; + else + $cookiePerfil = null; - if ($cookiePerfil != null) - { + if ($cookiePerfil != null){ $params = explode("&" ,$cookiePerfil); - for ($i=0; $i\" - + \"
\" - - - - "; + + \"
\" "; } } - return $resultado; - } // Devuelve codigo html que crea una caja de texto con un checkbox. Este checkbox será utilizado cuando se desean añadir un elemento y que automaticamente cree una vista con los subelementos de los que esta compuesto -function dameCheckboxAutoVistas($tipo) -{ -$result=""; - - switch ($tipo) { - case "A": //agente - $result=" + \"
\""; - $result.=" + \"

\""; - break; - case "GA": //Grupo Agentes - $result=" + \"

\""; - $result.=" + \"
\""; - $result.=" + \"

\""; - break; - case "M": //Modulo -// - break; - case "GM": //Grupo Modulos - $result=" + \"

\""; - break; - case "V": //Vista -// - break; - } - - -return $result; - +function dameCheckboxAutoVistas($tipo){ + $result=""; + switch ($tipo) { + case "A": //agente + $result=" + \"
\""; + $result.=" + \"

\""; + break; + case "GA": //Grupo Agentes + $result=" + \"

\""; + $result.=" + \"
\""; + $result.=" + \"

\""; + break; + case "M": //Modulo + break; + case "GM": //Grupo Modulos + $result=" + \"

\""; + break; + case "V": //Vista + break; + } + return $result; } -// function representaEnCaja($datos) -// { -// $resultado=""; -// -// $resultado = "+ \"\" -// + \"
\""; -// -// return $resultado; -// } -// -function mensaje($msj) -{ -echo "alert('".$msj."');"; +function mensaje($msj){ + echo "alert('".$msj."');"; } // Funcion que devuelve la imagen de la gráfica que lo representa -function dameGrafica($idModulo) -{ +function dameGrafica($idModulo){ global $graphURL; $origin = time() -3600; return "$graphURL?tipo=sparse&id=$idModulo&color=40d840&periodo=60&intervalo=12&label=Hourly%20graph&tipo=sparse&id=$idModulo&refresh=30&zoom=100&draw_events=1&origin=$origin"; diff --git a/pandora_console/operation/agentes/datos_agente_calendar.php b/pandora_console/operation/agentes/datos_agente_calendar.php deleted file mode 100644 index 97ac07b75f..0000000000 --- a/pandora_console/operation/agentes/datos_agente_calendar.php +++ /dev/null @@ -1,270 +0,0 @@ -=".$fecha_inicio." - AND 'timestamp' <=".$fecha_fin; - $resq1=mysql_query($query1); - return($resq1); - } - -function generar_tabla_de_promedios_de_datos_no_string ($id_de_mi_agente, $id_de_mi_mod,$fecha_inicio,$fecha_fin) -// Genera una tabla con los promedios de los datos de un módulo no-string -{ - $dias_de_la_semana=array ("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"); - $nombre_modulo=dame_nombre_modulo_agentemodulo($id_de_mi_mod); - echo "
Módulo: ".$nombre_modulo."
"; - - // Encabezado de la tabla - echo " - - - - - - "; - for ($dia=0;$dia<7;++$dia) - echo " - "; - echo - ""; - - for ($hora=0;$hora<24;++$hora) - { - echo" - - "; - for ($dia=1;$dia<8;++$dia) - echo ""; - echo - ""; - } - echo "
HoraDía
".$dias_de_la_semana[$dia]."
".$hora." h.".dame_promedio_de_un_modulo_no_string_de_un_agente_para_una_hora_det_de_un_dia_de_la_semana_en_un_rango_de_fechas_det($id_de_mi_agente, $id_de_mi_mod, $hora, $dia, $fecha_inicio, $fecha_fin)."
"; -} - - -/************** Main program *******************************/ - - -// Load global vars -require("include/config.php"); - -if (comprueba_login() != 0) { - echo "NO PERM"; - exit; -} - -$id_user = $_SESSION["id_usuario"]; -if ( (give_acl($id_user, 0, "AR")==0) AND (give_acl($id_user, 0, "AW")==0) ){ - echo "NO PERM"; - exit; -} - -if ((isset($_GET["operacion"])) AND (! isset($_POST["update_agent"]))){ - if (isset ($_POST["copiar"])){ - // Option A: Print exported data - // Export main button - echo "

".$lang_label["ag_title"]."

"; - - // echo "

".$lang_label["export_title"]." ".$lang_label["help"]."

"; - - if (isset ($_POST["origen_modulo"])){ - $origen = $_POST["origen"]; - - /* Comentado sólo para propósitos de prueba (Si no, no anda) - if (give_acl($id_user,dame_id_grupo($origen),"AR")!=1) - { - audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Export Data"); - require ("general/noaccess.php"); - } - */ - - $origen_modulo = $_POST["origen_modulo"]; - $from_date =$_POST["from_date"]; - $to_date=$_POST["to_date"]; - - // Imprime encabezado - echo $lang_label["db_agent_bra"]."".dame_nombre_agente($origen)."".$lang_label["from2"]."".$from_date."".$lang_label["to2"]."".$to_date."
"; - - // Esto podría reutilizarse - echo "
"; - - - // For each module - for ($a=0;$a ". generar_tabla_de_promedios_de_datos_no_string ($origen,$id_modulo,$from_date,$to_date); - } - } - } // End Option A -} else { -// Option B: Print Form -// Form view - ?> -

-

 

-
-
".$lang_label["module"]."".$lang_label["data"]."Timestamp
- - -


- -   

"; - - echo "".$lang_label["modules"]."

"; - echo "


- - -
".$lang_label["from"]."  

"; - - //print calendar and links for next and previous months - echo " - - - -
«".generate_calendar($year, $month, $days_f, 3, NULL, $locale)."»
- -

".$lang_label["to"]."    

"; - - //print calendar and links for next and previous months - echo " - - - -
«".generate_calendar($year, $month, $days_t, 3, NULL, $locale)."»
- -
- -
"; -} - - -?> - - diff --git a/pandora_console/operation/agentes/export_csv.php b/pandora_console/operation/agentes/export_csv.php new file mode 100644 index 0000000000..a63e294265 --- /dev/null +++ b/pandora_console/operation/agentes/export_csv.php @@ -0,0 +1,84 @@ + +// Additions to code for Pandora FMS 1.2 graph code and new XML reporting template managemement +// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2 +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +include ("../../include/config.php"); +include ("../../include/functions.php"); +include ("../../include/functions_db.php"); + +session_start(); + +$id_user = $_SESSION["id_usuario"]; +if ( (give_acl($id_user, 0, "AR")==0) AND (give_acl($id_user, 0, "AW")==0) ){ + require ("../../general/noaccess.php"); + exit; +} + +if ( isset ($_GET["agentmodule"]) && isset ($_GET["agent"]) ){ + $id_agentmodule = $_GET["agentmodule"]; + $id_agent = $_GET["agent"]; + $agentmodule_name = dame_nombre_modulo_agentemodulo($id_agentmodule); + if (give_acl($id_user,dame_id_grupo($id_agent),"AR")!=1) { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Export Data"); + require ("../../general/noaccess.php"); + exit; + } + + $now = date("Y/m/d H:i:s"); + + // Show contentype header + Header("Content-type: text/txt"); + header('Content-Disposition: attachment; filename="pandora_export_'.$agentmodule_name.'.txt"'); + + if (isset($_GET["from_date"])) + $from_date = $_GET["from_date"]; + else + $from_date = $now; + + if (isset($_GET["to_date"])) + $to_date = $_GET["to_date"]; + else + $to_date = $now; + + // Make the query + $sql1="SELECT * FROM tdatos WHERE id_agente = $id_agent AND id_agente_modulo = $id_agentmodule"; + $tipo = dame_nombre_tipo_modulo(dame_id_tipo_modulo_agentemodulo($id_agentmodule)); + if ($tipo == "generic_data_string") + $sql1='SELECT * FROM tagente_datos_string WHERE timestamp > "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_agentmodule.' ORDER BY timestamp DESC'; + else + $sql1='SELECT * FROM tagente_datos WHERE timestamp > "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_agentmodule.' ORDER BY timestamp DESC'; + $result1=mysql_query($sql1); + + // Render data + while ($row=mysql_fetch_array($result1)){ + echo $agentmodule_name; + echo ","; + echo $row["datos"]; + echo ","; + echo $row["timestamp"]; + echo chr(13); + } +} +?> + diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php index e092ca508a..5c899e5c28 100644 --- a/pandora_console/operation/agentes/exportdata.php +++ b/pandora_console/operation/agentes/exportdata.php @@ -1,10 +1,17 @@ +// Additions to code for Pandora FMS 1.2 graph code and new XML reporting template managemement // Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es // // This program is free software; you can redistribute it and/or @@ -18,90 +25,234 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +function give_average_from_module ($id_agente, $id_agente_modulo, $hour, $day, $start_date, $end_date){ +// Return average value from an agentmodule, for a specific hour of specific day of week, +// Only valid for non-string kind of data. + require ("include/config.php"); + $query1 = "SELECT AVG(datos) + FROM tagente_datos + WHERE id_agente_modulo = ". $id_agente_modulo." + AND HOUR(timestamp) = ".$hour." + AND WEEKDAY(timestamp) = ".$day." + AND timestamp >= '$start_date' + AND timestamp <= '$end_date'"; + + if (($resq1 = mysql_query($query1)) AND ($row=mysql_fetch_array($resq1))) + return $row[0]; + else + return 0; +} + +function generate_average_table ($id_de_mi_agente, $id_agente_modulo, $fecha_inicio, $fecha_fin){ +// Genera una tabla con los promedios de los datos de un módulo no-string + require ("include/config.php"); + require ("include/languages/language_".$language_code.".php"); + $dias_de_la_semana = array ($lang_label["sunday"],$lang_label["monday"],$lang_label["tuesday"],$lang_label["wednesday"],$lang_label["thurdsday"],$lang_label["friday"],$lang_label["saturday"]); + $nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo); + + // Table header + echo ""; + echo ""; + echo ""; + echo ""; + for ($dia=0;$dia<7;++$dia) + echo ""; + echo ""; + $color = 0; + for ($hora=0;$hora<24;++$hora){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } else { + $tdcolor = "datos2"; + $color = 1; + } + echo ""; + for ($dia=0; $dia<7; ++$dia){ + echo ""; + } + echo ""; + } + echo "
".$lang_label["hour"]."".$lang_label["day"]."
".$dias_de_la_semana[$dia]."
$hora ".$lang_label["hr"].""; + echo format_numeric (give_average_from_module ($id_de_mi_agente, $id_agente_modulo, $hora, $dia, $fecha_inicio, $fecha_fin)); + echo "
"; +} + +// ---------------------------------- +// Main code +// ---------------------------------- + // Load global vars require("include/config.php"); -$id_user = ""; -if (comprueba_login() == 0) - $id_user = $_SESSION["id_usuario"]; -if (give_acl($id_user, 0, "AR")!=1) { - audit_db ($id_user, $REMOTE_ADDR, "ACL Violation", - "Trying to access Agent Data Export view (Grouped)"); +// Security checks +if (comprueba_login() != 0) { require ("general/noaccess.php"); exit; } + +$id_user = $_SESSION["id_usuario"]; +if ( (give_acl($id_user, 0, "AR")==0) AND (give_acl($id_user, 0, "AW")==0) ){ + require ("general/noaccess.php"); + exit; +} + +if ((isset($_POST["export"])) AND (! isset($_POST["update_agent"]))){ + + if (isset($_POST["export_type"])) + $export_type = $_POST["export_type"]; + else + $export_type = 3; // Standard table; + + if ($export_type == 1) { // CSV + echo "

".$lang_label["export_title"]." ".$lang_label["help"]."

"; + + if (isset ($_POST["origen_modulo"])){ + $origen = $_POST["origen"]; + if (give_acl($id_user, dame_id_grupo($origen), "AR")!=1) { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Export Data"); + require ("general/noaccess.php"); + } + $origen_modulo = $_POST["origen_modulo"]; + $id_agentemodulo = $origen_modulo[0]; + $start_date =$_POST["start_date"]; + $end_date=$_POST["end_date"]; + $start_time =$_POST["start_time"]; + $end_time=$_POST["end_time"]; + $from_date = $start_date." ".$start_time; + $to_date = $end_date." ".$end_time; + + $agentmodule_name = dame_nombre_modulo_agentemodulo($origen_modulo[0]); + echo $lang_label["db_agent_bra"]. "" . dame_nombre_agente($origen). "- $agentmodule_name". $lang_label["from2"]. "". $from_date. "". $lang_label["to2"]. "". $to_date. "
"; + + echo " ".$lang_label["get_file"]." pandora_export_$agentmodule_name.txt"; + } else + echo "".$lang_label["no_sel_mod"].""; + } + + if ($export_type == 2){ // Avarage day/hour matrix + if (isset ($_POST["origen_modulo"])){ + $origen = $_POST["origen"]; + $origen_modulo = $_POST["origen_modulo"]; + $start_date =$_POST["start_date"]; + $end_date=$_POST["end_date"]; + $start_time =$_POST["start_time"]; + $end_time=$_POST["end_time"]; + $agentmodule_name = dame_nombre_modulo_agentemodulo($origen_modulo[0]); + $from_date = $start_date." ".$start_time; + $to_date = $end_date." ".$end_time; + + // Header + echo "

".$lang_label["export_title"]." ".$lang_label["help"]."

"; + echo $lang_label["db_agent_bra"]. "" . dame_nombre_agente($origen). "- $agentmodule_name". $lang_label["from2"]. "". $from_date. "". $lang_label["to2"]. "". $to_date. "
"; + echo "
"; + + // For each module + for ($a=0;$a ". generate_average_table ($origen,$id_modulo,$from_date,$to_date); + } + } + } -if ((isset($_GET["operacion"])) AND (! isset($_POST["update_agent"]))){ - if (isset ($_POST["copiar"])){ // Export main button - echo "

".$lang_label["ag_title"]."

"; + if ($export_type == 3) { // Standard table echo "

".$lang_label["export_title"]." ".$lang_label["help"]."

"; if (isset ($_POST["origen_modulo"])){ - if (isset ($_POST["csv"])) // CSV version - $csv = 1; - else - $csv = 0; $origen = $_POST["origen"]; if (give_acl($id_user,dame_id_grupo($origen),"AR")!=1) { audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Export Data"); require ("general/noaccess.php"); } $origen_modulo = $_POST["origen_modulo"]; - $from_date =$_POST["from_date"]; - $to_date=$_POST["to_date"]; - echo $lang_label["db_agent_bra"]."".dame_nombre_agente($origen)."".$lang_label["from2"]."".$from_date."".$lang_label["to2"]."".$to_date."
"; - if ($csv == 0){ - echo "
"; - $separador_1 = " -
".$lang_label["module"]."".$lang_label["data"]."Timestamp
"; - $separador_2 = ""; - $separador_3= ""; - } else { - $separador_1 = "
'"; - $separador_2 = "','"; - $separador_3 = "'"; - } + $agentmodule_name = dame_nombre_modulo_agentemodulo($origen_modulo[0]); + $start_date =$_POST["start_date"]; + $end_date=$_POST["end_date"]; + $start_time =$_POST["start_time"]; + $end_time=$_POST["end_time"]; + + $from_date = $start_date." ".$start_time; + $to_date = $end_date." ".$end_time; - for ($a=0;$a " . dame_nombre_agente($origen). "- $agentmodule_name". $lang_label["from2"]. "". $from_date. "". $lang_label["to2"]. "". $to_date. "
"; + + echo "
"; + echo ""; + + // Begin the render ! + for ($a=0; $a "; } } - if ($csv == 0) { - echo ""; - } echo "
".$lang_label["module"]."".$lang_label["data"]."Timestamp"; + echo $agentmodule_name; + echo ""; echo $row["datos"]; - echo $separador_2; + echo ""; echo $row["timestamp"]; - echo $separador_3; + echo "
"; } else echo "".$lang_label["no_sel_mod"].""; - } -} else { // Form view - ?> -

-

 

- - - - - - -


- '; + echo ''; + echo "'; + echo " - - -
".$lang_label["source_agent"]."

"; + echo "
"; + + + // Show combo with agents + echo '  

"; + echo "   "; + echo "

"; + + echo '
"; echo "".$lang_label["modules"]."

"; - echo "
"; + + // Combo with modules + echo "

- -
"; + echo "".$lang_label["begin_date"].""; + echo ""; + echo " "; + echo ""; + - require ("include/calendar.php"); //Including calendar - $result=mysql_query("SELECT token, value FROM tconfig"); - $row=mysql_fetch_array($result); - if ($row["token"]=="language_code") $locale=$row["value"]; //language of calendar. + echo "
"; + echo "".$lang_label["end_date"].""; + + echo ""; + echo " "; + echo ""; - $time = time(); + echo "
"; + echo "".$lang_label["export_type"].""; + echo ""; + // Combo for data export type + echo ""; + echo "
"; + // Submit button - if (isset($_GET["month"])) $month = $_GET["month"]; - else $month = date('n', $time); - if (isset($_GET["year"])) $year = $_GET["year"]; - else $year = date('Y', $time); + echo '      '; + echo ""; + echo "
"; + echo ""; + echo "
"; + echo ""; - //preparate months (the next month to december is january and back) - $first_of_month = gmmktime(0,0,0,$month,1,$year); - list($month, $year) = explode(',',gmstrftime('%m,%Y',$first_of_month)); - $month_a = ($month-1); - $month_d = ($month+1); - if ($month_d==13) {$year_d = $year; $year_a = $year;} - else { - if ($month==12) $year_d = $year+1; - else $year_d = $year; - if ($month==0) $year_a = $year-1; - else $year_a = $year; - } - - if (isset($_GET["date_from"])) $date_from=$_GET["date_from"]; - else - {if (isset($_POST["from_date"])) $date_from=$_POST["from_date"]; - else $date_from=$m; - } - - if (isset($_GET["date_to"])) $date_to=$_GET["date_to"]; - else - {if (isset($_POST["to_date"])) $date_to=$_POST["to_date"]; - else $date_to=$ahora; - } - - $days_f = array(); - $days_t = array(); - $days_in_month=gmdate('t',$first_of_month); - //create links for days in every calendar: - for ($day_f=1; $day_f<=$days_in_month; $day_f++){ - $days_f[$day_f]=array('index.php?sec=estado&sec2=operation/agentes/exportdata&date_from='.$year.'-'.$month.'-'.date('d',mktime(0, 0, 0, $month, $day_f, $year)).' 00:00:00&date_to='.$date_to.'&year='.$year.'&month='.$month); - } - for ($day_t=1; $day_t<=$days_in_month; $day_t++){ - $days_t[$day_t]=array('index.php?sec=estado&sec2=operation/agentes/exportdata&date_from='.$date_from.'&date_to='.$year.'-'.$month.'-'.date('d',mktime(0, 0, 0, $month, $day_t, $year)).' 00:00:00'.'&year='.$year.'&month='.$month); - } - if (isset($date_from) && isset($date_to)) - {$date="&date_from=".$date_from."&date_to=".$date_to;} - ?> - -
-   

-
«".generate_calendar($year, $month, $days_f, 3, NULL, $locale)."»
- "; ?> -

    

-
«".generate_calendar($year, $month, $days_t, 3, NULL, $locale)."»
- "; ?> -

- -
- "> -
- - \ No newline at end of file +?> diff --git a/pandora_console/pandora_graphical_console.sql b/pandora_console/pandora_graphical_console.sql index 70e77fcd47..b3507ed3ea 100644 --- a/pandora_console/pandora_graphical_console.sql +++ b/pandora_console/pandora_graphical_console.sql @@ -1,25 +1,4 @@ --- MySQL dump 10.10 --- --- Host: localhost Database: pandora --- ------------------------------------------------------ --- Server version 5.0.24a-Debian_9-log -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `estado_consola` --- - -DROP TABLE IF EXISTS `estado_consola`; CREATE TABLE `estado_consola` ( `id_usuario` varchar(50) NOT NULL, `idPerfilActivo` int(5) NOT NULL, @@ -29,11 +8,7 @@ CREATE TABLE `estado_consola` ( PRIMARY KEY (`id_usuario`) ) ENGINE=MyISAM ; --- --- Table structure for table `objeto_consola` --- -DROP TABLE IF EXISTS `objeto_consola`; CREATE TABLE `objeto_consola` ( `id_objeto` int(5) NOT NULL auto_increment, `nom_img` varchar(50) NOT NULL, @@ -43,25 +18,16 @@ CREATE TABLE `objeto_consola` ( `id_tipo` varchar(20) NOT NULL, `idVista` int(5) NOT NULL, PRIMARY KEY (`id_objeto`) -) ENGINE=MyISAM AUTO_INCREMENT=2 ; +) ENGINE=MyISAM; --- --- Table structure for table `perfil` --- -DROP TABLE IF EXISTS `perfil`; CREATE TABLE `perfil` ( `idPerfil` int(5) NOT NULL auto_increment, `Nombre` varchar(50) NOT NULL, `Descripcion` varchar(250) NOT NULL, PRIMARY KEY (`idPerfil`) -) ENGINE=MyISAM AUTO_INCREMENT=2 ; +) ENGINE=MyISAM; --- --- Table structure for table `perfil_vista` --- - -DROP TABLE IF EXISTS `perfil_vista`; CREATE TABLE `perfil_vista` ( `idPerfil` int(5) NOT NULL, `idVista` int(5) NOT NULL, @@ -69,46 +35,21 @@ CREATE TABLE `perfil_vista` ( PRIMARY KEY (`idPerfil`,`idVista`) ) ENGINE=MyISAM ; --- --- Table structure for table `relacion_estado` --- - -DROP TABLE IF EXISTS `relacion_estado`; CREATE TABLE `relacion_estado` ( `id_objeto` int(5) NOT NULL, `relacion` varchar(50) NOT NULL, PRIMARY KEY (`id_objeto`) ) ENGINE=MyISAM ; --- --- Table structure for table `relacion_objetos` --- - -DROP TABLE IF EXISTS `relacion_objetos`; CREATE TABLE `relacion_objetos` ( `idObjeto1` int(5) NOT NULL, `idObjeto2` int(5) NOT NULL, PRIMARY KEY (`idObjeto1`,`idObjeto2`) ) ENGINE=MyISAM ; --- --- Table structure for table `vistas_consola` --- - -DROP TABLE IF EXISTS `vistas_consola`; CREATE TABLE `vistas_consola` ( `idVista` int(5) NOT NULL auto_increment, `nombre` varchar(50) NOT NULL, `descripcion` varchar(250) NOT NULL, PRIMARY KEY (`idVista`) -) ENGINE=MyISAM AUTO_INCREMENT=1 ; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - +) ENGINE=MyISAM; diff --git a/pandora_console/pandora_graphical_console_data.sql b/pandora_console/pandora_graphical_console_data.sql index aae77e21d8..bf2a5c8d63 100644 --- a/pandora_console/pandora_graphical_console_data.sql +++ b/pandora_console/pandora_graphical_console_data.sql @@ -1,100 +1,8 @@ --- MySQL dump 10.10 --- --- Host: localhost Database: pandora --- ------------------------------------------------------ --- Server version 5.0.24a-Debian_9-log -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Dumping data for table `estado_consola` --- - - -/*!40000 ALTER TABLE `estado_consola` DISABLE KEYS */; -LOCK TABLES `estado_consola` WRITE; INSERT INTO `estado_consola` VALUES ('admin',1,1,100,100); -UNLOCK TABLES; -/*!40000 ALTER TABLE `estado_consola` ENABLE KEYS */; --- --- Dumping data for table `objeto_consola` --- - - -/*!40000 ALTER TABLE `objeto_consola` DISABLE KEYS */; -LOCK TABLES `objeto_consola` WRITE; -UNLOCK TABLES; -/*!40000 ALTER TABLE `objeto_consola` ENABLE KEYS */; - --- --- Dumping data for table `perfil` --- - - -/*!40000 ALTER TABLE `perfil` DISABLE KEYS */; -LOCK TABLES `perfil` WRITE; INSERT INTO `perfil` VALUES (1,'perfil por defecto','perfil por defecto'); -UNLOCK TABLES; -/*!40000 ALTER TABLE `perfil` ENABLE KEYS */; --- --- Dumping data for table `perfil_vista` --- - - -/*!40000 ALTER TABLE `perfil_vista` DISABLE KEYS */; -LOCK TABLES `perfil_vista` WRITE; INSERT INTO `perfil_vista` VALUES (1,1,1); -UNLOCK TABLES; -/*!40000 ALTER TABLE `perfil_vista` ENABLE KEYS */; --- --- Dumping data for table `relacion_estado` --- - - -/*!40000 ALTER TABLE `relacion_estado` DISABLE KEYS */; -LOCK TABLES `relacion_estado` WRITE; -UNLOCK TABLES; -/*!40000 ALTER TABLE `relacion_estado` ENABLE KEYS */; - --- --- Dumping data for table `relacion_objetos` --- - - -/*!40000 ALTER TABLE `relacion_objetos` DISABLE KEYS */; -LOCK TABLES `relacion_objetos` WRITE; -UNLOCK TABLES; -/*!40000 ALTER TABLE `relacion_objetos` ENABLE KEYS */; - --- --- Dumping data for table `vistas_consola` --- - - -/*!40000 ALTER TABLE `vistas_consola` DISABLE KEYS */; -LOCK TABLES `vistas_consola` WRITE; INSERT INTO `vistas_consola` VALUES (1,'Main Board',''); -UNLOCK TABLES; -/*!40000 ALTER TABLE `vistas_consola` ENABLE KEYS */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -