<?php

$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'dpsql.inc';
include_once 'common.inc';
// Initialize the graph before anything else.
// This makes use of the jpgraph cache if enabled.
// Last argument to init_simple_bar_graph is the cache timeout in minutes.
$graph = init_simple_bar_graph(640, 400, 58);
///////////////////////////////////////////////////
//Numbers of users logging on in each hour of the day, since the start of stats
//query db and put results into arrays
$result = mysql_query("\n    SELECT hour, AVG(L_hour)\n    FROM user_active_log\n    GROUP BY hour\n    ORDER BY hour\n");
list($datax, $datay) = dpsql_fetch_columns($result);
draw_simple_bar_graph($graph, $datax, $datay, 1, _('Average number of users newly logged in each hour'), _('Fresh Logons'));
// vim: sw=4 ts=4 expandtab
<?php

$relPath = "../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'Project.inc';
include_once '../../stats/jpgraph_files/common.inc';
require_login();
$projectid = validate_projectID("projectid", @$_GET["projectid"]);
// data for this graph is generated in show_wordcheck_page_stats.php
draw_simple_bar_graph(init_simple_bar_graph(600, 300, -1), $_SESSION["graph_pages_per_number_of_flags"][$projectid]["graph_x"], $_SESSION["graph_pages_per_number_of_flags"][$projectid]["graph_y"], ceil(count($_SESSION["graph_pages_per_number_of_flags"][$projectid]["graph_x"]) / 40), _("Number of flags on a page"), _("Pages with that many flags"));
// unsetting graph_pages_per_number_of_flags variable in the session
// to prevent it from getting large
// consider keeping this data if calling this
// image multiple times is needed in future code changes
unset($_SESSION["graph_pages_per_number_of_flags"][$projectid]);
// vim: sw=4 ts=4 expandtab
<?php

$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'page_tally.inc';
include_once 'common.inc';
// Initialize the graph before anything else.
// This makes use of the jpgraph cache if enabled.
// Last argument to init_simple_bar_graph is the cache timeout in minutes.
$graph = init_simple_bar_graph(640, 400, 900);
///////////////////////////////////////////////////
// For each month in which someone joined,
// get the number who joined,
// and the number of those who have proofread at least one page.
//
$result = mysql_query("\n    SELECT\n        FROM_UNIXTIME(date_created, '%Y-%m')\n          AS month,\n        COUNT(*)\n          AS num_who_joined,\n        SUM({$user_ELR_page_tally_column} > 0)\n          AS num_who_proofed\n    FROM users {$joined_with_user_ELR_page_tallies}\n    GROUP BY month\n    ORDER BY month\n");
// If there was a month when nobody joined,
// then the results will not include a row for that month.
// This may lead to a misleading graph,
// depending on its style.
while ($row = mysql_fetch_object($result)) {
    $datax[] = $row->month;
    $data1y[] = 100 * $row->num_who_proofed / $row->num_who_joined;
}
$x_text_tick_interval = calculate_text_tick_interval('monthly', count($datax));
draw_simple_bar_graph($graph, $datax, $data1y, $x_text_tick_interval, _('Percentage of New Users Who Went on to Proofread By Month'), _('% of newly Joined Users who Proofread'));
// vim: sw=4 ts=4 expandtab
        $column_name = 'L_hour';
        $cache_timeout = 58;
        break;
    case 'day':
        $title = _('Number of users newly logged in over 24 hours');
        $column_name = 'L_day';
        $cache_timeout = 58;
        break;
    case 'week':
        $title = _("Number of users newly logged in over 7 days");
        $column_name = 'L_week';
        $cache_timeout = 300;
        break;
    case 'fourweek':
        $title = _("Number of users newly logged in over 28 days");
        $column_name = 'L_4wks';
        $cache_timeout = 900;
        break;
    default:
        die("bad value for 'preceding'");
}
// Initialize the graph before making database call.
// This makes use of the jpgraph cache if enabled.
$graph = init_simple_bar_graph(640, 400, $cache_timeout);
///////////////////////////////////////////////////
//query db and put results into arrays
$result = mysql_query("\n    SELECT DATE_FORMAT(FROM_UNIXTIME(time_stamp),'{$date_format}'), {$column_name}\n    FROM user_active_log \n    WHERE time_stamp >= {$min_timestamp}\n    ORDER BY time_stamp\n");
list($datax, $datay) = dpsql_fetch_columns($result);
$x_text_tick_interval = calculate_text_tick_interval('hourly', count($datay));
draw_simple_bar_graph($graph, $datax, $datay, $x_text_tick_interval, $title, _('Fresh Logons'));
// vim: sw=4 ts=4 expandtab
$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'misc.inc';
include_once $relPath . 'page_tally.inc';
// $page_tally_names get_pages_per_day_for_past_n_days
include_once 'common.inc';
$valid_tally_names = array_keys($page_tally_names);
$tally_name = get_enumerated_param($_GET, 'tally_name', null, $valid_tally_names);
$holder_type = get_enumerated_param($_GET, 'holder_type', null, array('U', 'T'));
$holder_id = get_integer_param($_GET, 'holder_id', null, 0, null);
if (@$_GET['days_back'] == 'all') {
    $days_back = 'all';
} else {
    $days_back = get_integer_param($_GET, 'days_back', 30, 1, null);
}
// Initialize the graph before anything else.
// This makes use of the jpgraph cache if enabled.
// Last argument to init_simple_bar_graph is the cache timeout in minutes.
$graph = init_simple_bar_graph(600, 300, 60);
$pages_per_day = get_pages_per_day_for_past_n_days($tally_name, $holder_type, $holder_id, $days_back);
$datax = array_keys($pages_per_day);
$datay = array_values($pages_per_day);
$x_text_tick_interval = calculate_text_tick_interval('daily', count($datax));
if (empty($datax) || empty($datay)) {
    $specimen = $holder_type == 'U' ? 'user' : 'team';
    dpgraph_error("This {$specimen} has not completed any pages in this round.", 600, 300);
    die;
}
draw_simple_bar_graph($graph, $datax, $datay, $x_text_tick_interval, _('Pages Completed per Day'), _('Pages'));
// vim: sw=4 ts=4 expandtab
<?php

$relPath = "../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'Project.inc';
include_once '../../stats/jpgraph_files/common.inc';
require_login();
$projectid = validate_projectID("projectid", @$_GET["projectid"]);
// data for this graph is generated in show_wordcheck_page_stats.php
draw_simple_bar_graph(init_simple_bar_graph(600, 300, -1), $_SESSION["graph_flags_per_page"][$projectid]["graph_x"], $_SESSION["graph_flags_per_page"][$projectid]["graph_y"], ceil(count($_SESSION["graph_flags_per_page"][$projectid]["graph_x"]) / 40), _("Flagged words per page"), _("Flags"));
// unsetting graph_flags_per_page variable in the session
// to prevent it from getting large
// consider keeping this data if calling this
// image multiple times is needed in future code changes
unset($_SESSION["graph_flags_per_page"][$projectid]);
// vim: sw=4 ts=4 expandtab