Esempio n. 1
0
function baw_raise_error($type, $data = array())
{
    global $BAW_MES, $BAW_CONF;
    $cd = count($data);
    if ($cd == 0) {
        $out = $BAW_MES[$type];
    } else {
        if ($cd == 1) {
            $out = sprintf($BAW_MES[$type], $data[0]);
        } else {
            if ($cd == 2) {
                $out = sprintf($BAW_MES[$type], $data[0], $data[1]);
            } else {
                if ($cd == 3) {
                    $out = sprintf($BAW_MES[$type], $data[0], $data[1], $data[2]);
                }
            }
        }
    }
    // this is here in case the error comes so early that display helpers was not included yet.
    if ($BAW_CONF['module'] == 'drupal') {
        drupal_set_message(t('The Betterawstats engine generated the error below. If it is a configuration error concerning AWStats locations (i.e. the AWstats data directory, library directory, or language direction), these must be set using the') . ' <a href="skins/default/admin/settings/bawstats">' . t('BAW Statistics') . '</a> ' . t('administration pages.'), 'error');
        drupal_set_message($out, 'warning');
    } else {
        include_once 'display_helpers.php';
        $out = baw_site_header() . "<div class=\"errorbox\"><h1>{$BAW_MES['baw_error']}</h1>{$out}</div></body></html>";
        return $out;
    }
}
Esempio n. 2
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;
}