function display_graph($d) { $total_pages = 0; if ($d == 0) { $graph = init_pie_graph(660, 400, 5); $title = _("Net pages saved so far today"); for ($rn = 1; $rn <= MAX_NUM_PAGE_EDITING_ROUNDS; $rn++) { $round = get_Round_for_round_number($rn); $site_stats = get_site_page_tally_summary($round->id); $data[] = $pages = $site_stats->curr_day_actual; $labels[] = "{$round->id} ({$pages})"; $total_pages += $pages; } } else { $graph = init_pie_graph(660, 400, 60); $title = sprintf(_("Net pages saved in preceding %s days"), $d); $now = time(); for ($rn = 1; $rn <= MAX_NUM_PAGE_EDITING_ROUNDS; $rn++) { $round = get_Round_for_round_number($rn); $tallyboard = new TallyBoard($round->id, 'S'); $data[] = $pages = $tallyboard->get_delta_sum(1, $now - 60 * 60 * 24 * $d, $now); $labels[] = "{$round->id} ({$pages})"; $total_pages += $pages; } } if ($total_pages == 0) { dpgraph_error(_("No pages saved in specified range")); } draw_pie_graph($graph, $labels, $data, $title); }
function show_all_time_total() { global $tally_name; $sub_title = _("Total Pages Proofread Since Statistics Were Kept"); echo "<h3>{$sub_title}</h3>\n"; $site_tallyboard = new TallyBoard($tally_name, 'S'); $holder_id = 1; echo number_format($site_tallyboard->get_current_tally($holder_id)); echo "<br>\n"; echo "<br>\n"; }
$req_team_id = get_integer_param($_GET, 'id', null, 0, null); //Try our best to make sure no browser caches the page header("Content-Type: text/xml"); header("Expires: Sat, 1 Jan 2000 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); $result = select_from_teams("id = {$req_team_id}"); $curTeam = mysql_fetch_assoc($result); $team_id = $curTeam['id']; //Team info portion of $data $result = mysql_query("SELECT COUNT(id) AS totalTeams FROM user_teams"); $totalTeams = mysql_result($result, 0, "totalTeams"); $data = "<teaminfo id='{$team_id}'>\n <teamname>" . xmlencode($curTeam['teamname']) . "</teamname>\n <datecreated>" . date("m/d/Y", $curTeam['created']) . "</datecreated>\n <createdby>" . xmlencode($curTeam['createdby']) . "</createdby>\n <leader>" . xmlencode(get_username_for_uid($curTeam['owner'])) . "</leader>\n <description>" . xmlencode($curTeam['team_info']) . "</description>\n <website>" . xmlencode($curTeam['webpage']) . "</website>\n <forums>" . xmlencode(get_url_to_view_topic($curTeam['topic_id'])) . "</forums>\n <totalmembers>" . $curTeam['member_count'] . "</totalmembers>\n <currentmembers>" . $curTeam['active_members'] . "</currentmembers>\n <retiredmembers>" . ($curTeam['member_count'] - $curTeam['active_members']) . "</retiredmembers>"; foreach ($page_tally_names as $tally_name => $tally_title) { $teams_tallyboard = new TallyBoard($tally_name, 'T'); $pageCount = $teams_tallyboard->get_current_tally($team_id); $pageCountRank = $teams_tallyboard->get_rank($team_id); $avg_pages_per_day = get_daily_average($curTeam['created'], $pageCount); list($bestDayCount, $bestDayTimestamp) = $teams_tallyboard->get_info_re_largest_delta($team_id); $bestDayTime = date("M. jS, Y", $bestDayTimestamp - 1); $data .= "\n <roundinfo id='{$tally_name}'>\n <totalpages>{$pageCount}</totalpages>\n <rank>" . $pageCountRank . "/" . $totalTeams . "</rank>\n <avgpagesday>" . number_format($avg_pages_per_day, 1) . "</avgpagesday>\n <mostpagesday>" . $bestDayCount . " (" . $bestDayTime . ")</mostpagesday>\n </roundinfo>"; } $data .= "\n </teaminfo>\n"; //Team members portion of $data $data .= "<teammembers>"; $mbrQuery = mysql_query("\n SELECT username, date_created, u_id, u_privacy\n FROM users\n WHERE {$team_id} IN (team_1, team_2, team_3)\n ORDER BY username ASC\n"); while ($curMbr = mysql_fetch_assoc($mbrQuery)) { if ($curMbr['u_privacy'] == PRIVACY_PUBLIC) { $data .= "<member id=\"" . $curMbr['u_id'] . "\">\n <username>" . xmlencode($curMbr['username']) . "</username>\n <datejoined>" . date("m/d/Y", $curMbr['date_created']) . "</datejoined>\n </member>\n "; }
include_once $relPath . 'prefs_options.inc'; // PRIVACY_* include_once $relPath . 'theme.inc'; include_once $relPath . 'user_is.inc'; include_once $relPath . 'page_tally.inc'; require_login(); $valid_tally_names = array_keys($page_tally_names); $tally_name = get_enumerated_param($_GET, 'tally_name', null, $valid_tally_names); $title = sprintf(_('Top 100 Proofreaders for Round %s'), $tally_name); output_header($title); echo "<br><h2>{$title}</h2>\n"; echo "<br>\n"; echo "<br>\n"; // the $sql_anonymous = mysql_real_escape_string(_("Anonymous")); if (isset($GLOBALS['pguser'])) { // hide names of users who don't want even logged on people to see their names $proofreader_expr = "IF(u_privacy = " . PRIVACY_ANONYMOUS . ",'{$sql_anonymous}', username)"; } else { // hide names of users who don't want unlogged on people to see their names $proofreader_expr = "IF(u_privacy != " . PRIVACY_PUBLIC . ",'{$sql_anonymous}', username)"; } $subtitle = sprintf(_('Users with the Highest Number of Pages Saved-as-Done in Round %s'), $tally_name); echo "<h3>{$subtitle}</h3>\n"; $users_tallyboard = new TallyBoard($tally_name, 'U'); list($joined_with_user_page_tallies, $user_page_tally_column) = $users_tallyboard->get_sql_joinery_for_current_tallies('users.u_id'); $sql_upt_column_name = mysql_real_escape_string(sprintf(_("%s Pages Completed"), $tally_name)); dpsql_dump_themed_query("\n SELECT\n {$proofreader_expr} AS '" . mysql_real_escape_string(_("Proofreader")) . "',\n {$user_page_tally_column} AS '{$sql_upt_column_name}'\n FROM users {$joined_with_user_page_tallies}\n WHERE {$user_page_tally_column} > 0\n ORDER BY 2 DESC, 1 ASC\n LIMIT 100\n ", 1, DPSQL_SHOW_RANK); echo "<br>\n"; echo "<br>\n"; // vim: sw=4 ts=4 expandtab
function get_page_rows($mentoring_round) { global $pguser; $pages = array(); $mentored_round = $mentoring_round->mentee_round; $projects = get_mentoring_projects($mentoring_round); $mentoring_user_column = $mentoring_round->user_column_name; $mentored_user_column = $mentored_round->user_column_name; $mentored_time_column = $mentored_round->time_column_name; $round_tallyboard = new TallyBoard($mentored_round->id, 'U'); list($join_clause, $count_column) = $round_tallyboard->get_sql_joinery_for_current_tallies('u.u_id'); foreach ($projects as $project) { $sql = "SELECT\n p.projectid,\n p.nameofwork AS title,\n p.authorsname AS author,\n pg.fileid,\n pg.image,\n u.u_privacy AS privacy,\n u.u_id,\n {$count_column} AS total_count,\n pg.{$mentored_user_column} AS mentored_username,\n pg.{$mentored_time_column} AS unixtime,\n pg.{$mentoring_user_column} AS mentor_username,\n FROM_UNIXTIME(pg.{$mentored_time_column}) AS time1,\n pg.state AS page_state\n FROM\n projects AS p,\n {$project->projectid} AS pg\n JOIN users AS u ON pg.{$mentored_user_column} = u.username\n {$join_clause}\n WHERE \n p.projectid = '{$project->projectid}'\n AND ( pg.state = '{$mentoring_round->page_avail_state}'\n OR (\n pg.{$mentoring_user_column} = '{$pguser}'\n AND pg.state IN ( '{$mentoring_round->page_out_state}',\n '{$mentoring_round->page_temp_state}'\n )\n )\n )\n ORDER BY\n mentored_username,\n unixtime"; $rows = _sql_rows($sql); $pages = $pages + $rows; } return $pages; }
$graph = new Graph($width, $height, get_image_cache_filename(), $cache_timeout); // Pull all interested phases, primarily all the rounds and PP $interested_phases = array_keys($Round_for_round_id_); // Pull the stats data out of the database $stats = get_round_backlog_stats($interested_phases); // get the total of all phases $stats_total = array_sum($stats); // If this is a new system there won't be any stats so don't divide by zero if ($stats_total == 0) { dpgraph_error(_("No pages found.")); } // Get page saveAsDone trend information $holder_id = 1; $today = getdate(); foreach ($stats as $phase => $pages) { $tallyboard = new TallyBoard($phase, 'S'); $pages_last_week = $tallyboard->get_delta_sum($holder_id, mktime(0, 0, 0, $today['mon'], $today['mday'] - 7, $today['year']), mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year'])); $avg_pages_per_day[$phase] = $pages_last_week / 7; // calculate the number of days to complete at the current rate if ($avg_pages_per_day[$phase]) { $stats[$phase] = $pages / $avg_pages_per_day[$phase]; } else { $stats[$phase] = 0; } } // calculate the goal percent as 100 / number_of_phases $goal_percent = ceil(100 / count($stats)); // colors $barColors = array(); $barColorDefault = "#EEEEEE"; $barColorAboveGoal = "#FF484F";
$forum_profile = get_forum_user_details($username); //Try our best to make sure no browser caches the page header("Content-Type: text/xml"); header("Expires: Sat, 1 Jan 2000 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); echo "<?xml version=\"1.0\" encoding=\"{$charset}\" ?>\n"; echo "<memberstats xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"memberstats.xsd\">\n"; $now = time(); $daysInExistence = floor(($now - $user->date_created) / 86400); //User info if ($user->u_privacy == PRIVACY_PUBLIC) { echo "\n <userinfo id='{$user->u_id}'>\n <username>" . xmlencode($user->username) . "</username>\n <datejoined>" . date("m/d/Y", $user->date_created) . "</datejoined>\n <lastlogin>" . date("m/d/Y", $user->last_login) . "</lastlogin>\n <location>" . xmlencode($forum_profile['from']) . "</location>\n <occupation>" . xmlencode($forum_profile['occ']) . "</occupation>\n <interests>" . xmlencode($forum_profile['interests']) . "</interests>\n <website>" . xmlencode($forum_profile['website']) . "</website>"; foreach ($page_tally_names as $tally_name => $tally_title) { $tallyboard = new TallyBoard($tally_name, 'U'); $current_page_tally = $tallyboard->get_current_tally($user->u_id); $currentRank = $tallyboard->get_rank($user->u_id); list($bestDayCount, $bestDayTimestamp) = $tallyboard->get_info_re_largest_delta($user->u_id); $bestDayTime = date("M. jS, Y", $bestDayTimestamp - 1); if ($daysInExistence > 0) { $daily_Average = $current_page_tally / $daysInExistence; } else { $daily_Average = 0; } echo "\n <roundinfo id='{$tally_name}'>\n <pagescompleted>{$current_page_tally}</pagescompleted>\n <overallrank>{$currentRank}</overallrank>\n <bestdayever>\n <pages>{$bestDayCount}</pages>\n <date>{$bestDayTime}</date>\n </bestdayever>\n <dailyaverage>" . number_format($daily_Average) . "</dailyaverage>\n </roundinfo>"; } echo "\n </userinfo>"; //Team info $result = select_from_teams("id IN ({$user->team_1}, {$user->team_2}, {$user->team_3})"); echo "\n <teaminfo>";
function page_summary_sql($mentored_round, $projectid) { global $code_url; $round_tallyboard = new TallyBoard($mentored_round->id, 'U'); list($joined_with_user_page_tallies, $user_page_tally_column) = $round_tallyboard->get_sql_joinery_for_current_tallies('u.u_id'); return "\n SELECT\n CASE WHEN u.u_privacy = " . PRIVACY_ANONYMOUS . " THEN 'Anonymous'\n ELSE CONCAT('<a href=\"" . $code_url . "/stats/members/mdetail.php?&id=',u.u_id,\n '\">',u.username,'</a>')\n END AS '" . mysql_real_escape_string(_("Proofreader")) . "',\n COUNT(1) AS '" . mysql_real_escape_string(_("Pages this project")) . "',\n {$user_page_tally_column} AS '" . mysql_real_escape_string(sprintf(_("Total %s Pages"), $mentored_round->id)) . "',\n DATE_FORMAT(FROM_UNIXTIME(u.date_created),'%M-%d-%y') AS '" . mysql_real_escape_string(_("Joined")) . "'\n FROM {$projectid} AS p\n INNER JOIN users AS u ON p.{$mentored_round->user_column_name} = u.username\n {$joined_with_user_page_tallies}\n GROUP BY p.{$mentored_round->user_column_name}"; }