Beispiel #1
0
function baw_display_overview($set)
{
    global $BAW_MES, $BAW_CURR, $BAW_CONF;
    $m = $BAW_MES;
    $m_name = $m[59 + $BAW_CURR['month']];
    if ($g = baw_data($BAW_CURR['site_name'], 'GENERAL', $BAW_CURR['yearmonth'])) {
        // we assumethat time exists when general exist
        $t = baw_data($BAW_CURR['site_name'], 'TIME', $BAW_CURR['yearmonth']);
        $o = baw_calc_monthdata($t, $g);
        $l = $g['LastUpdate'];
        $time = baw_time_format($l[0]);
        $BAW_CURR['thismonth']['hits'] = $o[1];
        $out = "<table class=\"datatable\">\n" . "    <tr>\n        <td><b>{$m[133]}</b></td><td colspan=\"5\">{$m_name} {$BAW_CURR['year']}</td>\n    </tr>\n" . "    <tr class=\"layout_index\">\n        <td><b>{$m[8]}</b></td><td colspan=\"5\">" . baw_time_format($g['FirstTime'][0]) . "</td>\n    </tr>\n" . "    <tr class=\"layout_index\">\n        <td><b>{$m[9]}</b></td><td colspan=\"5\">" . baw_time_format($g['LastTime'][0]) . "</td>\n    </tr>\n" . "    <tr>\n        <td>&nbsp;</td>\n" . "        <th class=\"layout_visitors\">{$m[11]}</th>\n" . "        <th class=\"layout_visits\">{$m[10]}</th>\n" . "        <th class=\"layout_pages\">{$m[56]}</th>\n" . "        <th class=\"layout_hits\">{$m[57]}</th>\n" . "        <th class=\"layout_bytes\">{$m[75]}</th>\n    </tr>\n" . "    <tr style=\"white-space:nowrap;\">\n        <td>{$m[160]}&nbsp;*</td>\n" . "        <td><b>" . baw_num_format($o[0]) . "</b>" . BR . "&nbsp;</td>\n" . "        <td><b>" . baw_num_format($o[1]) . "</b>" . BR . "(" . @baw_num_format($o[1] / $o[0], 2) . "&nbsp;{$m[52]})</td>\n" . "        <td><b>" . baw_num_format($o[2]) . "</b>" . BR . "(" . @baw_num_format($o[2] / $o[1], 2) . "&nbsp;{$m[27]}/{$m[12]})</td>\n" . "        <td><b>" . baw_num_format($o[3]) . "</b>" . BR . "(" . @baw_num_format($o[3] / $o[1], 2) . "&nbsp;{$m[57]}/{$m[12]})</td>\n" . "        <td><b>" . baw_byte_format($o[4]) . "</b>" . BR . "(" . @baw_byte_format($o[4] / $o[1], 2) . "/{$m[12]})</td>\n    </tr>\n" . "    <tr>\n        <td>{$m[161]}&nbsp;*</td>\n" . "        <td colspan=\"2\">&nbsp;</td>\n" . "        <td><b>" . baw_num_format($o[5]) . "</b></td>\n" . "        <td><b>" . baw_num_format($o[6]) . "</b></td>\n" . "        <td><b>" . baw_byte_format($o[7]) . "</b></td></tr>\n" . "    <tr>\n        <td colspan=\"6\">* {$m[159]}</td>\n    </tr>\n";
        if ($BAW_CONF['show_parser_stats']) {
            $out .= "    <tr>\n        <td colspan=\"6\"><b>{$m['data_file_stats']}</b></td>\n    </tr>\n" . "    <tr>\n" . "        <td>{$m[35]}:" . BR . "{$time}</td>\n" . "        <td>{$m['parsed_records']}" . BR . baw_num_format($l[1]) . "</td>\n" . "        <td>{$m['old_records']}" . BR . baw_num_format($l[2]) . "</td>\n" . "        <td>{$m['new_records']}" . BR . baw_num_format($l[3]) . "</td>\n" . "        <td>{$m['corrupted']}" . BR . baw_num_format($l[4]) . "</td>\n" . "        <td>{$m['dropped']}" . BR . baw_num_format($l[5]) . "</td>\n    </tr>\n";
        }
        $out .= "</table>\n\n";
    } else {
        $out = "{$m_name}-{$BAW_CURR['year']} has no data";
    }
    return $out;
}
Beispiel #2
0
function baw_debug($msg_code, $data = false, $always = false)
{
    global $BAW_CONF, $BAW_MES;
    $out = '';
    if ($BAW_CONF['debug'] || $always) {
        if (isset($BAW_MES[$msg_code])) {
            if ($data) {
                $out .= sprintf($BAW_MES[$msg_code], $data);
            } else {
                $out = $BAW_MES[$msg_code];
            }
        } else {
            $out = $msg_code;
        }
        $memory = baw_byte_format(memory_get_usage(), 4);
        $time = baw_ptime();
        echo "<div style=\"text-align:right\">{$out} | Memory used: {$memory} | Time: {$time}</div>\n";
    }
}
Beispiel #3
0
function baw_display_index($settings = array())
{
    global $BAW_CONF, $BAW_CONF_DIS, $BAW_CONF_DIS_DEF, $BAW_MES, $BAW_LIB;
    global $BAW_DFILES, $BAW_CURR, $BAW_D;
    // this comes second since site_name is unknown otherwise
    echo baw_site_header($BAW_CURR['site_name']);
    $content = "<div class=\"contentbox\">\n";
    $tmp = array();
    // temp array where we record which section has data to show/hide menu options
    // sort the charts according to order in config
    $BAW_CONF_DIS = baw_array_sorting($BAW_CONF_DIS, 'order', SORT_ASC);
    // ---------- CONTENT BOX --------------------------------------------------
    // this should be removed once we move to beta.
    if ($BAW_CURR['site_name'] == 'all_months') {
        $settings['section'] = "months";
        $section = $settings['section'];
        $function = "baw_display_{$section}";
        $temp_conf = $BAW_CONF_DIS[$section];
        $temp_conf['chart'] = true;
        $temp_conf['table'] = false;
        $temp_conf['name'] = $BAW_CONF_DIS_DEF[$section]['name'];
        baw_debug("Printing Stats for: " . $BAW_CONF_DIS_DEF[$section]['name']);
        $content .= $function($temp_conf);
    } else {
        if ($BAW_CURR['site_name'] == 'all_days') {
            $settings['section'] = "days";
            $section = $settings['section'];
            $function = "baw_display_{$section}";
            $temp_conf = $BAW_CONF_DIS[$section];
            $temp_conf['chart'] = true;
            $temp_conf['table'] = false;
            $temp_conf['name'] = $BAW_CONF_DIS_DEF[$section]['name'];
            baw_debug("Printing Stats for: " . $BAW_CONF_DIS_DEF[$section]['name']);
            $content .= $function($temp_conf);
        } else {
            if (isset($settings['section'])) {
                $section = $settings['section'];
                $function = "baw_display_{$section}";
                $temp_conf = $BAW_CONF_DIS[$section];
                $temp_conf['top_x'] = $BAW_CONF['maxlines'];
                $temp_conf['name'] = $BAW_CONF_DIS_DEF[$section]['name'];
                baw_debug("Printing Stats for: " . $BAW_CONF_DIS_DEF[$section]['name']);
                $content .= baw_section_header($section, $temp_conf['name'], false, 'menu_section') . $function($temp_conf) . baw_section_footer();
            } else {
                $content .= "\n<!-- CONTENT START ++++++++++++++++++++++++++++++++++++++ -->\n";
                if ($BAW_CONF['layout_type'] == 'horizontal') {
                    foreach ($BAW_LIB['item_groups'] as $group => $group_details) {
                        $group_items = $group_details['members'];
                        $menubuttons = "<div class=\"clearfix\">";
                        $stats_section = '';
                        $item_id = 0;
                        $count_members = count($group_details['members']);
                        foreach ($group_details['members'] as $item) {
                            $sect_data = $BAW_CONF_DIS[$item];
                            $sect_data['name'] = $item;
                            $function = "baw_display_{$item}";
                            if (function_exists($function)) {
                                baw_debug("Printing Stats for: {$function}");
                                $stats_html = $function($sect_data);
                                if ($sect_data['show'] == true && (strlen($stats_html) > 1 || !$BAW_CONF['hideempty'])) {
                                    $stats_section .= "\n<!-- ITEM {$BAW_CONF_DIS_DEF[$item]['name']} START ++++++++++++++++++++++++++++++++++++++ -->\n";
                                    $button_title = $BAW_CONF_DIS_DEF[$item]['name'];
                                    if ($item_id == 0) {
                                        $button_class = "menu_button_active";
                                    } else {
                                        $button_class = "menu_button_inactive";
                                    }
                                    $menubuttons .= "<div class=\"{$button_class}\" id=\"button_{$group}_{$item_id}\" onClick=\"toggleBox({$item_id}, '{$group}', {$count_members}, 'menu');\">{$button_title}</div>\n";
                                    if ($item == 'weekdays' && !isset($BAW_CURR['wdays']['count'])) {
                                        $setarr = array('collapse' => false, 'chart' => false, 'table' => false);
                                        baw_display_weekdays($setarr);
                                    }
                                    $title = $BAW_CONF_DIS_DEF[$item]['name'];
                                    $collapse = $sect_data['collapse'];
                                    $name = "{$group}_{$item_id}";
                                    $collapse = false;
                                    if ($item_id == 0) {
                                        $class = 'menu_section_active';
                                    } else {
                                        $class = 'menu_section_inactive';
                                    }
                                    $stats_section .= baw_section_header($name, $title, $collapse, $class) . $stats_html . baw_section_footer();
                                    $tmp[$item] = true;
                                    $stats_section .= "\n<!-- ITEM {$item} END ++++++++++++++++++++++++++++++++++++++ -->\n";
                                    $item_id++;
                                } else {
                                    $tmp[$item] = false;
                                }
                            }
                        }
                        if (strlen($stats_section) > 1) {
                            $content .= "\n<!-- GROUP {$group} START ++++++++++++++++++++++++++++++++++++++ -->\n";
                            $content .= baw_section_header($group, $group_details['title'], false, 'group_title');
                            $menubuttons .= "</div>";
                            $content .= $menubuttons . "\n{$stats_section}\n";
                            $content .= baw_section_footer();
                            $content .= "\n<!-- GROUP {$group} END ++++++++++++++++++++++++++++++++++++++ -->\n";
                            $tmp[$group] = true;
                        } else {
                            $tmp[$group] = false;
                        }
                    }
                } else {
                    foreach ($BAW_CONF_DIS as $section => $sect_data) {
                        $stats_html = '';
                        $content .= "\n<!-- ITEM {$section} START ++++++++++++++++++++++++++++++++++++++ -->\n";
                        $title = $BAW_CONF_DIS_DEF[$section]['name'];
                        $collapse = $sect_data['collapse'];
                        $name = $section;
                        $sect_data['name'] = $section;
                        $function = "baw_display_{$section}";
                        if ($sect_data['show'] == true && function_exists($function)) {
                            baw_debug("Printing Stats for: baw_display_{$section}");
                            $stats_html = $function($sect_data);
                            if (strlen($stats_html) > 1) {
                                $content .= baw_section_header($name, $title, $collapse, 'menu_section') . $stats_html . baw_section_footer();
                                $tmp[$section] = true;
                            } else {
                                $tmp[$section] = false;
                            }
                        }
                        $content .= "\n<!-- ITEM {$section} END ++++++++++++++++++++++++++++++++++++++ -->\n";
                    }
                }
                $content .= "\n<!-- CONTENT END ++++++++++++++++++++++++++++++++++++++ -->\n";
            }
        }
    }
    $content .= "</div>";
    baw_debug("Starting to build menu");
    // ---- MENU BOX -----------------------------------------------------------
    $menubox = "\n\n<!-- MENU START ++++++++++++++++++++++++++++++++++++++ -->\n" . "<div class=\"menubox\">\n" . baw_sites_dropdown();
    $qstrng = '';
    if (strlen($_SERVER['QUERY_STRING']) > 0) {
        $qstrng = '?' . $_SERVER['QUERY_STRING'];
    }
    $url = "{$BAW_CONF['site_url']}/index.php{$qstrng}";
    $menubox .= "    <ul class=\"menu\" >\n" . "        <li class=\"menu_even\">\n" . "            " . baw_create_link($BAW_MES[77], "{$url}#", array('class' => 'leftlink')) . "\n " . "        </li>\n";
    $c = 1;
    // top link was '0'
    if ($BAW_CURR['site_name'] == 'all_months' or $BAW_CURR['site_name'] == 'all_days') {
        $sites = array_keys($BAW_DFILES);
        foreach ($sites as $site) {
            $class = baw_even($c, 'menu_even', 'menu_odd');
            $menubox .= "        <li class=\"{$class}\">\n" . "            " . baw_create_link($site, "{$url}#site_{$site}") . "\n" . "        </li>\n";
            $c++;
        }
    } else {
        if ($BAW_CONF['layout_type'] == 'horizontal') {
            foreach ($BAW_LIB['item_groups'] as $group => $group_details) {
                if ($tmp[$group]) {
                    $class = baw_even($c, 'menu_even', 'menu_odd');
                    $name = $group_details['title'];
                    $menubox .= "        <li class=\"{$class}\">\n" . "            " . baw_create_link($name, "{$url}#h2_{$group}") . "\n" . "        </li>\n";
                    $c++;
                }
            }
        } else {
            if (isset($settings['section'])) {
                // we are doing a full list
                $url = str_replace('&action=get_fulltable&what=' . $settings['section'], '', $url);
                $menubox .= "        <li class=\"menu_odd\">\n" . baw_create_link($BAW_MES['back'], $url) . "\n" . "        </li>\n";
            } else {
                $count_sections = count($BAW_CONF_DIS);
                foreach ($BAW_CONF_DIS as $section => $sect_data) {
                    if ($sect_data['show'] && ($tmp[$section] || !$BAW_CONF['hideempty'])) {
                        $class = baw_even($c, 'menu_even', 'menu_odd');
                        $name = $BAW_CONF_DIS_DEF[$section]['name'];
                        $menubox .= "        <li class=\"{$class}\">\n" . "            " . baw_create_link($name, "{$url}#h2_{$section}", array('class' => 'leftlink')) . "\n" . baw_display_list_icons($section, array('info'), false) . "\n" . "        </li>\n";
                        $c++;
                    }
                }
            }
        }
    }
    $menubox .= "    </ul>\n";
    $menubox_end = "\n</div>\n<!-- MENU END - SITE/DATE MENU START ++++++++++++++++++++++++++++++++++++++ -->\n";
    baw_debug("Menu finished");
    $finaltime = baw_ptime();
    $out = $menubox . baw_display_version("<br" . XHTML . "> in {$finaltime}, max menory: " . baw_byte_format(memory_get_peak_usage(true))) . $menubox_end . $content . baw_site_footer();
    return $out;
}