<?php $current_year = date("Y"); $last_year = date("Y")-1; ?> <h4>Abstract views and document downloads by country (derived from IP address of query)</h4> <p>Most viewed eprints: [<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;range=4w">Past four weeks</a>] [<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;year=<?php print $current_year; ?>">This year</a>] [<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date;year=<?php print $last_year; ?>">Last year</a>] [<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=show_detail_date">All years</a>] <br />Repository-wide statistics: [<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=cumulative_usage;range=all">by Year/month</a>] [<a href="<?php print $_SERVER['PHP_SELF']; ?>?action=cumulative_usage_country">by Country</a>] </p> <?php $max_width=500; if (! isset($GLOBALS["db_values"]["0"]["country_downloads"])) { print "<table>\n"; print '<tr><td align="left" width="200"><font color="#ff0000"><b>No statistics available.</b></font></td></tr>'; print "\n"; } else { // Compute the longest bar $max_count = $GLOBALS["db_values"]["0"]["country_downloads"]; for ($rs=0; $rs<count($GLOBALS["db_values"]); $rs++) { if ($GLOBALS["db_values"][$rs]["country_abstracts"] > $max_count) { $max_count = $GLOBALS["db_values"][$rs]["country_abstracts"]; } } print "<table>\n"; print '<tr><th colspan="2" align="left" bgcolor="#cccccc">Country</th> <th bgcolor="#66ddee">Abstracts</th> <th bgcolor="#4477dd"><font color="#ffffff">Downloads</font></th> <th bgcolor="#cccccc"> </th></tr>'; for ($rs=0;$rs<count($GLOBALS["db_values"]);$rs++) { if ($GLOBALS["db_values"][$rs]["country_name"]=='') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; } if ($GLOBALS["db_values"][$rs]["country_name"]=='N/A') { $GLOBALS["db_values"][$rs]["country_name"]='unknown'; } print '<tr><td>'; // select a flag $ccode = strtolower($GLOBALS["db_values"][$rs]["country_code"]); $c_flag = 'flags18x14/' . $ccode . '.png'; if (file_exists($c_flag)) { print '<img src="'. $c_flag . '" width="18" height="14" alt="'. $ccode . '">'; } else { print '<img src="flags18x14/unknown.png" width="18" height="14" alt="' . $ccode . '">'; }; print '</td><td><font face="Arial, Helvetica, sans-serif" size="-1">' . $GLOBALS["db_values"][$rs]["country_name"]. '</font></td><td align="right"><font face="Arial, Helvetica, sans-serif" size="-1">'. $GLOBALS["db_values"][$rs]["country_abstracts"]. '</font></td><td align="right"><font face="Arial, Helvetica, sans-serif" size="-1">' . $GLOBALS["db_values"][$rs]["country_downloads"]. '</font></td>'; $cur_count = $GLOBALS["db_values"][$rs]["country_abstracts"]; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<td align="left"><img src="bars/hh.png" alt="views" height="9" width="'. $col_width . '"><br />'; $cur_count = $GLOBALS["db_values"][$rs]["country_downloads"]; $col_width = (int) ($cur_count/$max_count * $max_width); $col_width = max($col_width,1); $col_width .= "px"; print '<img src="bars/hp.png" alt="views" height="9" width="'. $col_width . '"></td></tr>'; } } // of else print "</table>\n"; ?>