• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NathanGibbs3 / BASE / 590

pending completion
590

push

travis-ci-com

NathanGibbs3
20230420 Fix CI build breakage. 2

2755 of 16977 relevant lines covered (16.23%)

21.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/base_graph_form.php
1
<?php
2
/*******************************************************************************
3
** Basic Analysis and Security Engine (BASE)
4
** Copyright (C) 2004 BASE Project Team
5
** Copyright (C) 2000 Carnegie Mellon University
6
**
7
** (see the file 'base_main.php' for license details)
8
**
9
** Project Leads: Kevin Johnson <kjohnson@secureideas.net>
10
**                Sean Muller <samwise_diver@users.sourceforge.net>
11
** Built upon work by Roman Danyliw <rdd@cert.org>, <roman@danyliw.com>
12
**
13
** Purpose: Displays form for graphing
14
********************************************************************************
15
** Authors:
16
********************************************************************************
17
** Kevin Johnson <kjohnson@secureideas.net
18
**
19
********************************************************************************
20
*/
21

22
// Issue #5
23
if (
×
24
        !isset($BASE_path)
25
        || ( getenv('TRAVIS') && version_compare(PHP_VERSION, '5.3.0', '<') )
×
26
){
27
        if ( !isset($BASE_path) ){
×
28
                // Testing via php -f CLI on local system.
29
                // Default $BASE_path.
30
                $BASE_path = dirname(__FILE__);
×
31
        }
32
        // Code Coverage for PHP 5.2x on CI.
33
        // Default a bunch of things to fix issue #5.
34
        include_once("base_conf.php");
×
35
        include_once("$BASE_path/includes/base_constants.inc.php");
×
36
        include("$BASE_path/includes/base_include.inc.php");
×
37
        include_once("$BASE_path/base_db_common.php");
×
38
        $db = NewBASEDBConnection($DBlib_path, $DBtype);
×
39
        $db->baseDBConnect(
×
40
                $db_connect_method, $alert_dbname, $alert_host, $alert_port,
41
                $alert_user, $alert_password
42
        );
43
        $data_source = '';
×
44
        $chart_interval ='';
×
45
        $chart_begin_hour = '';
×
46
        $chart_begin_day = '';
×
47
        $chart_begin_month = '';
×
48
        $chart_begin_year = '';
×
49
        $chart_end_hour = '';
×
50
        $chart_end_day = '';
×
51
        $chart_end_month = '';
×
52
        $chart_end_year = '';
×
53
        $user_chart_title = '';
×
54
        $chart_type = 4; // CHARTTYPE_MONTH
×
55
        // Deafaults from base_graph_main.php
56
        $height            = 800;
×
57
        $width             = 600;
×
58
        $element_start     = 0;
×
59
        $min_size          = 0;
×
60
        $rotate_xaxis_lbl  = 0;
×
61
        $xaxis_label_inc   = 1;
×
62
        $xaxis_grid        = 0;
×
63
        $yaxis_grid        = 1;
×
64
        $yaxis_scale       = 0;
×
65
        $chart_style       = 'bar';
×
66
}
67
include_once ("$BASE_path/base_graph_common.php");
×
68

69
  echo '<FORM ACTION="base_graph_main.php" METHOD="post">';
×
70

71
  echo '<TABLE WIDTH="100%" BORDER="2" class="query" cellpadding="20" summary="Outer table">
×
72
          <TR>
73
           <TD COLSPAN=2>';
74
  echo '<TABLE WIDTH="100%" BORDER="1" SUMMARY="1st inner table"><TR>';
×
75
  //  echo '<B>'._CHARTTYPE.'</B>&nbsp;
76
  echo '<TD><B>What do you want to know:</B></TD><TD>
×
77
        <SELECT NAME="chart_type">
78
         <OPTION VALUE=" "  '. chk_select($chart_type, " ").'>'._CHARTTYPES.'
×
79
         <OPTION VALUE="' . CHARTTYPE_HOUR . '" ' . chk_select($chart_type, CHARTTYPE_HOUR).'>'._CHRTTYPEHOUR.'
×
80
         <OPTION VALUE="' . CHARTTYPE_DAY . '" ' . chk_select($chart_type, CHARTTYPE_DAY).'>'._CHRTTYPEDAY.'
×
81
         <!--<OPTION VALUE="' . CHARTTYPE_WEEK . '" ' . chk_select($chart_type, CHARTTYPE_WEEK).'>'._CHRTTYPEWEEK.'-->
×
82
         <OPTION VALUE="' . CHARTTYPE_MONTH . '" ' . chk_select($chart_type, CHARTTYPE_MONTH).'>'._CHRTTYPEMONTH.'
×
83
         <!--<OPTION VALUE="' . CHARTTYPE_YEAR . '" ' . chk_select($chart_type, CHARTTYPE_YEAR).'>'._CHRTTYPEYEAR.'-->
×
84
         <OPTION VALUE="' . CHARTTYPE_SRC_IP . '" ' . chk_select($chart_type, CHARTTYPE_SRC_IP).'>'._CHRTTYPESRCIP.'
×
85
         <OPTION VALUE="' . CHARTTYPE_DST_IP . '" ' . chk_select($chart_type, CHARTTYPE_DST_IP).'>'._CHRTTYPEDSTIP.'
×
86
         <OPTION VALUE="' . CHARTTYPE_SRC_TCP_PORT . '" ' . chk_select($chart_type, CHARTTYPE_SRC_TCP_PORT).'>'._CHRTTYPESRCPORT.'
×
87
         <OPTION VALUE="' . CHARTTYPE_DST_TCP_PORT . '" ' . chk_select($chart_type, CHARTTYPE_DST_TCP_PORT).'>'._CHRTTYPEDSTPORT.'
×
88
         <OPTION VALUE="' . CHARTTYPE_SRC_UDP_PORT . '" ' . chk_select($chart_type, CHARTTYPE_SRC_UDP_PORT).'>'._CHRTTYPESRCUDP.'
×
89
         <OPTION VALUE="' . CHARTTYPE_DST_UDP_PORT . '" ' . chk_select($chart_type, CHARTTYPE_DST_UDP_PORT).'>'._CHRTTYPEDSTUDP.'
×
90

91
         <OPTION VALUE="' . CHARTTYPE_SRC_COUNTRY . '" ' . chk_select($chart_type, CHARTTYPE_SRC_COUNTRY).'>'. 'Src. countries vs. number of alerts
×
92
         <OPTION VALUE="' . CHARTTYPE_SRC_COUNTRY_ON_MAP . '" ' . chk_select($chart_type, CHARTTYPE_SRC_COUNTRY_ON_MAP).'>'. 'Src. countries vs. number of alerts on a worldmap
×
93
         <OPTION VALUE="' . CHARTTYPE_DST_COUNTRY . '" ' . chk_select($chart_type, CHARTTYPE_DST_COUNTRY).'>'. 'Dst. countries vs. number of alerts
×
94
         <OPTION VALUE="' . CHARTTYPE_DST_COUNTRY_ON_MAP . '" ' . chk_select($chart_type, CHARTTYPE_DST_COUNTRY_ON_MAP).'>'. 'Dst. countries vs. number of alerts on a worldmap
×
95
         <OPTION VALUE="' . CHARTTYPE_SENSOR . '" ' . chk_select($chart_type, CHARTTYPE_SENSOR).'>'._CHRTTYPESENSOR.'
×
96
         <OPTION VALUE="' . CHARTTYPE_UNIQUE_SIGNATURE .'" ' . chk_select($chart_type, CHARTTYPE_UNIQUE_SIGNATURE).'>'. 'Unique alerts vs. number of alerts' . '
×
97
         <OPTION VALUE="' . CHARTTYPE_CLASSIFICATION . '" ' . chk_select($chart_type, CHARTTYPE_CLASSIFICATION).'>'._CHRTTYPESIG;
×
98
 
99

100
        echo '</SELECT>
×
101
              </TD></TR>';
102
  
103
  
104
  //echo '&nbsp;&nbsp;<B>'._PLOTTYPE.'</B> &nbsp;&nbsp;
105
  echo '<TR><TD><B>How should it be displayed?</B></TD><TD>As&nbsp;
×
106
            <INPUT TYPE="radio" NAME="chart_style"
107
                   VALUE="bar" '.chk_check($chart_style, "bar").'> '._TYPEBAR.' &nbsp;&nbsp;
×
108
            <INPUT TYPE="radio" NAME="chart_style"
109
                   VALUE="line" '.chk_check($chart_style, "line").'> '._TYPELINE.' &nbsp;&nbsp;
×
110
            <INPUT TYPE="radio" NAME="chart_style"
111
                   VALUE="pie" '.chk_check($chart_style, "pie").'> '._TYPEPIE.' ';
×
112
  echo '</TD></TR>';
×
113

114
  //  echo '&nbsp;&nbsp;<B>'._CHARTSIZE.'</B>
115
  echo '<TD><B>... with a size of:</B></TD><TD>(width x height)
×
116
        &nbsp;<INPUT TYPE="text" NAME="width" SIZE=4 VALUE="'.$width.'">
117
        &nbsp;<B>x</B>
118
        &nbsp;<INPUT TYPE="text" NAME="height" SIZE=4 VALUE="'.$height.'">
119
        &nbsp;&nbsp;<BR></TD></TR>';
120

121
// not implemented:
122
/*
123
  //echo '&nbsp;&nbsp;<B>'._PLOTMARGINS.'</B>
124
  echo '<TR><TD><B>... and with margins of:</B></TD><TD>(left x right x top x bottom)<BR>
125
        &nbsp;<INPUT TYPE="text" NAME="pmargin0" SIZE=4 VALUE="'.$pmargin0.'">
126
        &nbsp;<B>x</B>
127
        &nbsp;<INPUT TYPE="text" NAME="pmargin1" SIZE=4 VALUE="'.$pmargin1.'">
128
        &nbsp;<B>x</B>
129
        &nbsp;<INPUT TYPE="text" NAME="pmargin2" SIZE=4 VALUE="'.$pmargin2.'">
130
        &nbsp;<B>x</B>
131
        &nbsp;<INPUT TYPE="text" NAME="pmargin3" SIZE=4 VALUE="'.$pmargin3.'">
132
        &nbsp;&nbsp;<BR></TD></TR>';
133
*/
134

135

136
    echo '<TR><TD><B>Do you want to know<BR>the data just of a<BR>particular time frame?</B>&nbsp;(optional)</TD><TD>';
×
137
    echo '<b>'._CHRTBEGIN.'</B>&nbsp;
×
138
        <SELECT NAME="chart_begin_hour">
139
         <OPTION VALUE=" "  '.chk_select($chart_begin_hour, " ").'>'._CHARTHOUR."\n";
×
140
        for ( $i = 0; $i <= 23; $i++ )
×
141
            echo "<OPTION VALUE=\"$i\" ".chk_select($chart_begin_hour, $i)." >$i\n";
×
142

143
  echo '</SELECT>
×
144
        <SELECT NAME="chart_begin_day">
145
         <OPTION VALUE=" "  '.chk_select($chart_begin_day, " ").'>'._CHARTDAY."\n";
×
146
        for ( $i = 1; $i <= 31; $i++ )
×
147
            echo "<OPTION VALUE=\"$i\" ".chk_select($chart_begin_day, $i).">$i\n";
×
148

149
  echo '</SELECT>
×
150
        <SELECT NAME="chart_begin_month">
151
         <OPTION VALUE=" "  '.chk_select($chart_begin_month, " ").'>'._CHARTMONTH.'
×
152
         <OPTION VALUE="01" '.chk_select($chart_begin_month, "01").'>'._JANUARY.'
×
153
         <OPTION VALUE="02" '.chk_select($chart_begin_month, "02").'>'._FEBRUARY.'
×
154
         <OPTION VALUE="03" '.chk_select($chart_begin_month, "03").'>'._MARCH.'
×
155
         <OPTION VALUE="04" '.chk_select($chart_begin_month, "04").'>'._APRIL.'
×
156
         <OPTION VALUE="05" '.chk_select($chart_begin_month, "05").'>'._MAY.'
×
157
         <OPTION VALUE="06" '.chk_select($chart_begin_month, "06").'>'._JUNE.'
×
158
         <OPTION VALUE="07" '.chk_select($chart_begin_month, "07").'>'._JULY.'
×
159
         <OPTION VALUE="08" '.chk_select($chart_begin_month, "08").'>'._AUGUST.'
×
160
         <OPTION VALUE="09" '.chk_select($chart_begin_month, "09").'>'._SEPTEMBER.'
×
161
         <OPTION VALUE="10" '.chk_select($chart_begin_month, "10").'>'._OCTOBER.'
×
162
         <OPTION VALUE="11" '.chk_select($chart_begin_month, "11").'>'._NOVEMBER.'
×
163
         <OPTION VALUE="12" '.chk_select($chart_begin_month, "12").'>'._DECEMBER.'
×
164
        </SELECT>
165
        <SELECT NAME="chart_begin_year">'.
166
        dispYearOptions($chart_begin_year)
×
167
        .'</SELECT>';
168

169
  echo '<br><b>'._CHRTEND.'</B>&nbsp;&nbsp;&nbsp;&nbsp;
×
170
        <SELECT NAME="chart_end_hour">
171
         <OPTION VALUE=" "  '.chk_select($chart_end_hour, " ").'>'._CHARTHOUR."\n";
×
172
        for ( $i = 0; $i <= 23; $i++ )
×
173
           echo "<OPTION VALUE=$i ".chk_select($chart_end_hour, $i).">$i\n";
×
174

175
  echo '</SELECT>
×
176
        <SELECT NAME="chart_end_day">
177
         <OPTION VALUE=" "  '.chk_select($chart_end_day, " ").'>'._CHARTDAY."\n";
×
178
        for ( $i = 1; $i <= 31; $i++ )
×
179
           echo "<OPTION VALUE=$i ".chk_select($chart_end_day, $i).">$i\n";
×
180

181
  echo '</SELECT>
×
182
        <SELECT NAME="chart_end_month">
183
         <OPTION VALUE=" "  '.chk_select($chart_end_month, " ").'>'._CHARTMONTH.'
×
184
         <OPTION VALUE="01" '.chk_select($chart_end_month, "01").'>'._JANUARY.'
×
185
         <OPTION VALUE="02" '.chk_select($chart_end_month, "02").'>'._FEBRUARY.'
×
186
         <OPTION VALUE="03" '.chk_select($chart_end_month, "03").'>'._MARCH.'
×
187
         <OPTION VALUE="04" '.chk_select($chart_end_month, "04").'>'._APRIL.'
×
188
         <OPTION VALUE="05" '.chk_select($chart_end_month, "05").'>'._MAY.'
×
189
         <OPTION VALUE="06" '.chk_select($chart_end_month, "06").'>'._JUNE.'
×
190
         <OPTION VALUE="07" '.chk_select($chart_end_month, "07").'>'._JULY.'
×
191
         <OPTION VALUE="08" '.chk_select($chart_end_month, "08").'>'._AUGUST.'
×
192
         <OPTION VALUE="09" '.chk_select($chart_end_month, "09").'>'._SEPTEMBER.'
×
193
         <OPTION VALUE="10" '.chk_select($chart_end_month, "10").'>'._OCTOBER.'
×
194
         <OPTION VALUE="11" '.chk_select($chart_end_month, "11").'>'._NOVEMBER.'
×
195
         <OPTION VALUE="12" '.chk_select($chart_end_month, "12").'>'._DECEMBER.'
×
196
        </SELECT>
197
        <SELECT NAME="chart_end_year">'.
198
        dispYearOptions($chart_end_year)
×
199
        .'</SELECT></TD></TR>';
200
      
201
        echo '<TR><TD><B>'._CHARTTITLE.'</B></TD><TD>
×
202
                <INPUT TYPE="text" NAME="user_chart_title" SIZE="35" VALUE="'.$user_chart_title.'"></TD></TR>';
203
                
204
                
205
                
206
        
207
  //  echo '&nbsp;&nbsp;<b>'._CHARTPERIOD.'</B>&nbsp;
208
  echo '<TR><TD><B>How many columns or elements do you want to see?</B>&nbsp;</TD><TD>';
×
209
  echo '<SELECT NAME="chart_interval">'.
×
210
        '<OPTION VALUE="0"  '.chk_select($chart_interval, "0").'>{all of them}' . /* _PERIODNO. */
×
211
  '<OPTION VALUE="5"  '.chk_select($chart_interval, "5").'> 5 elements' .  
×
212
        '<OPTION VALUE="10" '.chk_select($chart_interval, "10").'>10 elements' . /* _PERIODWEEK. */
×
213
        '<OPTION VALUE="15" '.chk_select($chart_interval, "15").'>15 elements' . /* _PERIODDAY. */
214
        '<OPTION VALUE="20" '.chk_select($chart_interval, "20").'>20 elements' . /* _PERIOD168. */
215
  '<OPTION VALUE="25" '.chk_select($chart_interval, "25").'>25 elements' .
×
216
  '<OPTION VALUE="30" '.chk_select($chart_interval, "30").'>30 elements' .
×
217
        '</SELECT><BR></TD></TR>';
218

219
        echo '<TR><TD><B>... and starting from which element on?</B>&nbsp;</TD>' .
×
220
       '<TD>From element no.&nbsp;<INPUT TYPE="text" NAME="element_start" SIZE="10" VALUE="'.$element_start.'"></TD></TR>';
221

222

223
  // submit button
224
  echo '<TR align=middle><TD colspan="2">';
×
225
  echo '<BR><BR><div class="center"><INPUT TYPE="submit" NAME="submit" VALUE="'._GRAPHALERTS.'" align=center></div><BR><BR>';
×
226
        echo '</TR></TABLE>';
×
227

228

229

230

231

232
  echo '<TR><TD COLSPAN=2>
×
233
  <ul id="zMenu">
234
    <li>'._AXISCONTROLS.':<BR>';
235
  echo '<TABLE WIDTH="100%" BORDER="1" SUMMARY="2nd inner table">
×
236
        <TR>
237
         <TD ALIGN="CENTER" WIDTH="50%"><B>'._CHRTX.'</B></TD>
238
         <TD ALIGN="CENTER" WIDTH="50%"><B>'._CHRTY.'</B></TD>
239
        </TR>
240
        <TR>
241
         <TD>
242
           <B>'._CHRTDS.'</B> &nbsp;
243
           <SELECT NAME="data_source">
244
           <OPTION VALUE=" " '.chk_select($data_source, " ").'>{ data source (AG) }';
×
245

246
           $temp_sql = "SELECT ag_id, ag_name FROM acid_ag";
×
247
           $tmp_result = $db->baseExecute($temp_sql);
×
248
           if ( ( $tmp_result ) )
×
249
           {
250
              while ( $myrow = $tmp_result->baseFetchRow() )
×
251
                echo '<OPTION VALUE="'.$myrow[0].'" '.chk_select($data_source, $myrow[0]).'>'.
×
252
                     '['.$myrow[0].'] '.$myrow[1];
×
253

254
              $tmp_result->baseFreeRows();
×
255
           }
256

257
           echo '</SELECT><BR>'.
×
258
                 '<B>'._CHRTMINTRESH.':</B>
259
                 <INPUT TYPE="text" NAME="min_size" SIZE="5" VALUE='.$min_size.'>
260
                 &nbsp;&nbsp;
261
                 <BR>
262
                 <INPUT TYPE="checkbox" NAME="rotate_xaxis_lbl" VALUE="1" '.
263
                   chk_check($rotate_xaxis_lbl, "1").'>
×
264
                 &nbsp;
265
                 <B>'._CHRTROTAXISLABEL.'</B><BR>
266
                 <INPUT TYPE="checkbox" NAME="xaxis_grid" VALUE="1"  '.
267
                   chk_check($xaxis_grid, "1").'>
×
268
                  &nbsp;
269
                 <B>'._CHRTSHOWX.'</B><BR>
270
                 <!--
271
                 Disabled because it unexpectedly prevents displaying
272
                 the whole bar instead of just suppressing the label... 
273
                 -->
274
                 <!--
275
                 <B>'._CHRTDISPLABELX.'
276
                 <INPUT TYPE="text" NAME="xaxis_label_inc" SIZE=4 VALUE='.$xaxis_label_inc.'>
277
                 &nbsp; '._CHRTDATAPOINTS.'
278
                 -->
279
                 <INPUT TYPE="hidden" NAME="xaxis_label_inc" VALUE="1"><BR> 
280
         </TD>
281

282

283
         <TD VALIGN="top">
284
         <!--
285
         Logarithmic y-axis temporarily disabled, as the bars seem
286
         to be displayed in a wrong way, although the y-axis grid lines
287
         look correct
288
         -->
289
         <!--
290
           <INPUT TYPE="checkbox" NAME="yaxis_scale" VALUE="1" '.
291
             chk_check($yaxis_scale, "1").'>&nbsp;
×
292
           <B>'._CHRTYLOG.'</B>
293
           <BR>
294
         --> 
295
           <INPUT TYPE="hidden" NAME="yaxis_scale" VALUE="0">
296
         
297
           
298

299
           <INPUT TYPE="checkbox" NAME="yaxis_grid" VALUE="1"  '.
300
             chk_check($yaxis_grid, "1").'>&nbsp;
×
301
           <B>'._CHRTYGRID.'</B>
302
         </TD>
303
        </TR>
304
        </TABLE>
305
        </ul></li>
306

307
        </TD></TR>
308
     </TABLE>';
309

310
  echo '</FORM><P><HR>';
×
311
echo '
×
312
 <!-- ************ JavaScript for Hiding Details ******************** -->
313
 <script type="text/javascript">
314
// <![CDATA[
315
function loopElements(el,level){
316
        for(var i=0;i<el.childNodes.length;i++){
317
                //just want LI nodes:
318
                if(el.childNodes[i] && el.childNodes[i]["tagName"] && el.childNodes[i].tagName.toLowerCase() == "li"){
319
                        //give LI node a className
320
                        el.childNodes[i].className = "zMenu"+level
321
                        //Look for the A and if it has child elements (another UL tag)
322
                        childs = el.childNodes[i].childNodes
323
                        for(var j=0;j<childs.length;j++){
324
                                temp = childs[j]
325
                                if(temp && temp["tagName"]){
326
                                        if(temp.tagName.toLowerCase() == "a"){
327
                                                //found the A tag - set class
328
                                                temp.className = "zMenu"+level
329
                                                //adding click event
330
                                                temp.onclick=showHide;
331
                                        }else if(temp.tagName.toLowerCase() == "ul"){
332
                                                //Hide sublevels
333
                                                temp.style.display = "none"
334
                                                //Set class
335
                                                temp.className= "zMenu"+level
336
                                                //Recursive - calling self with new found element - go all the way through
337
                                                loopElements(temp,level +1)
338
                                        }
339
                                }
340
                        }
341
                }
342
        }
343
}
344

345
var menu = document.getElementById("zMenu") //get menu div
346
menu.className="zMenu"+0 //Set class to top level
347
loopElements(menu,0) //function call
348

349
function showHide(){
350
        //from the LI tag check for UL tags:
351
        el = this.parentNode
352
        //Loop for UL tags:
353
        for(var i=0;i<el.childNodes.length;i++){
354
                temp = el.childNodes[i]
355
                if(temp && temp["tagName"] && temp.tagName.toLowerCase() == "ul"){
356
                        //Check status:
357
                        if(temp.style.display=="none"){
358
                                temp.style.display = ""
359
                        }else{
360
                                temp.style.display = "none"
361
                        }
362
                }
363
        }
364
        return false
365
}
366
// ]]>
367
</script>
368
';
369
?>
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc