コード例 #1
0
 /** Get the actual report.
  * Classes must override this, but must call the parent's method with what
  * would otherwise be their return value and return that instead.
  * @param $child_html The child method's return value
  * @return A html fragment
  */
 public function getReportUI($child_html = null)
 {
     $db = AbstractDb::getObject();
     $html = '';
     $graph = StatisticGraph::getObject('ConnectionsPerHour');
     $html .= $graph->getReportUI($this->stats);
     $graph = StatisticGraph::getObject('VisitsPerWeekday');
     $html .= $graph->getReportUI($this->stats);
     $graph = StatisticGraph::getObject('VisitsPerMonth');
     $html .= $graph->getReportUI($this->stats);
     return parent::getReportUI($html);
 }
コード例 #2
0
 /** Constructor, must be called by subclasses */
 protected function __construct()
 {
     parent::__construct();
 }
コード例 #3
0
 /** Get the actual report.
  * Classes can (but don't have to) override this, but must call the parent's
  * method with what would otherwise be their return value and return that
  * instead.
  * @param $statistics_object Mandatory to give the report it's context
  * @param $child_html The child method's return value
  * @return A html fragment
  */
 public function getReportUI(Statistics $statistics_object, $child_html = null)
 {
     $html = '';
     $html .= _("Note:  A visit is like counting connections, but only counting one connection per day for each user at a single node");
     return parent::getReportUI($statistics_object, $html);
 }
コード例 #4
0
 /** Get the actual report.
  * Classes must override this, but must call the parent's method with what
  * would otherwise be their return value and return that instead.
  * @param $child_html The child method's return value
  * @return A html fragment
  */
 public function getReportUI($child_html = null)
 {
     $db = AbstractDb::getObject();
     $html = '';
     /* Monthly registration graph */
     $graph = StatisticGraph::getObject('RegistrationsPerMonth');
     $html .= $graph->getReportUI($this->stats);
     /* End Monthly registration graph */
     /* Cumulative registration graph */
     $graph = StatisticGraph::getObject('RegistrationsCumulative');
     $html .= $graph->getReportUI($this->stats);
     /* End cumulative registration graph */
     /* First connection per node */
     $html .= "<fieldset>";
     $html .= "<legend>" . _("First connection per node") . "</legend>";
     $node_usage_stats = null;
     $distinguish_users_by = $this->stats->getDistinguishUsersBy();
     /* The following query will retreive the list of the REAL first connection of each user, no matter where or when.*/
     $sql_real_first_connections = $this->stats->getSqlRealFirstConnectionsQuery('connections.conn_id', false);
     //$db->execSql($sql_real_first_connections, $tmp, true);
     $real_first_connections_table_name = "real_first_conn_table_name_" . session_id();
     $real_first_connections_table_sql = "CREATE TABLE  {$real_first_connections_table_name} AS ({$sql_real_first_connections});\n";
     //$real_first_connections_table_sql .= "CREATE INDEX {$real_first_connections_table_name}_idx ON $real_first_connections_table_name (conn_id); \n";
     $db->execSqlUpdate($real_first_connections_table_sql, false);
     /* Now retrieves the oldest connection matching the report restriction, and only keep it if it's really the user's first connection */
     $candidate_connections_sql = $this->stats->getSqlCandidateConnectionsQuery("DISTINCT ON(connections.{$distinguish_users_by}) connections.{$distinguish_users_by}, conn_id, connections.node_id, nodes.name,timestamp_in ");
     //$db->execSql($candidate_connections_sql, $tmp, true);
     $first_connection_table_sql = "{$candidate_connections_sql} ORDER BY connections.{$distinguish_users_by}, timestamp_in\n";
     //$db->execSql($first_connection_table_sql, $node_usage_stats, true);
     $first_connection_table_name = "first_connection_table_name_" . session_id();
     $registration_node_table_sql = "CREATE TEMP TABLE  {$first_connection_table_name} AS ({$first_connection_table_sql});\n  \n";
     //$registration_node_table_sql .= "CREATE INDEX {$first_connection_table_name}_idx ON $first_connection_table_name (node_id)";
     $db->execSqlUpdate($registration_node_table_sql, false);
     $registration_node_table_sql = "SELECT COUNT ({$first_connection_table_name}.{$distinguish_users_by}) AS total_first_connections, node_id, name FROM {$first_connection_table_name} JOIN {$real_first_connections_table_name} ON ({$first_connection_table_name}.conn_id={$real_first_connections_table_name}.conn_id) GROUP BY node_id, name ORDER BY total_first_connections DESC;";
     $db->execSql($registration_node_table_sql, $node_usage_stats, false);
     $registration_node_table_sql = "DROP TABLE {$first_connection_table_name};";
     $db->execSqlUpdate($registration_node_table_sql, false);
     $real_first_connections_table_sql = "DROP TABLE {$real_first_connections_table_name};";
     $db->execSqlUpdate($real_first_connections_table_sql, false);
     if ($node_usage_stats) {
         $html .= "<table>";
         $html .= "<thead>";
         $html .= "<tr>";
         $html .= "  <th>" . _("Node") . "</th>";
         $html .= "  <th>" . _("# of new user first connection") . "</th>";
         $html .= "</tr>";
         $html .= "</thead>";
         $total = 0;
         $even = 0;
         foreach ($node_usage_stats as $row) {
             $html .= $even ? "<tr>\n" : "<tr class='odd'>\n";
             if ($even == 0) {
                 $even = 1;
             } else {
                 $even = 0;
             }
             $html .= "  <td>{$row['name']}</td>\n";
             $html .= "  <td>" . $row['total_first_connections'] . "</td>";
             $html .= "</tr>";
             $total += $row['total_first_connections'];
         }
         $html .= "<tfoot>";
         $html .= "<tr>";
         $html .= "  <th>" . _("Total") . ":</th>";
         $html .= "  <th>" . $total . "</th>";
         $html .= "</tr>";
         $html .= "<tr>";
         $html .= "  <td colspan=2>" . _("Note:  This is actually a list of how many new user's first connection occured at each hotspot, taking report restrictions into account.  It includes non-validated users who successfully connected.") . "</td>";
         $html .= "</tr>";
         $html .= "</tfoot>";
         $html .= "</table>";
     } else {
         $html .= _("No information found matching the report configuration");
     }
     /* End first connection per node */
     return parent::getReportUI($html);
 }
コード例 #5
0
 /** Get the actual report.
  * Classes  can (but don't have to) override this, but must call the parent's method with what
  * would otherwise be their return value and return that instead.
  * @param $statistics_object Mandatory to give the report it's context
  * @param $child_html The child method's return value
  * @return A html fragment
  */
 public function getReportUI(Statistics $statistics_object, $child_html = null)
 {
     $session = Session::getObject();
     $session->set('current_statistics_object', $statistics_object);
     self::$stats = $statistics_object;
     /* Update it in case someone whants to use it right now */
     $html = '';
     $html .= "<fieldset>";
     $html .= "<legend>" . $this->getGraphName() . "</legend>";
     $errormsg = '';
     if ($this->isAvailable($errormsg)) {
         $html .= "<div><img src='stats_show_graph.php?graph_class=" . get_class($this) . "'></div>";
     } else {
         $html .= $errormsg;
     }
     $html .= $child_html;
     $html .= "</fieldset>";
     return $html;
 }
コード例 #6
0
     $statistics_object->setSelectedNetworks(array($network->getId() => $network));
     if ($verbose) {
         print "Processing node {$node->getId()} ... mem used: " . memory_get_usage() . "\n";
     }
     //Make sure folder exists
     if (!is_dir($node->getPublicStatsDir())) {
         mkdir($node->getPublicStatsDir(), 0775);
     }
     //Write the index file header
     $index = fopen($node->getPublicStatsDir() . $node->getPublicStatsFile(), "w");
     fwrite($index, "" . '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . "\n" . "<html>\n<head>\n" . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . "\n" . '<meta http-equiv="Pragma" content="no-cache">' . "\n" . "<title>Statistics for {$node->getName()}</title>\n" . '<link rel="stylesheet" type="text/css"  href="/media/public_stats/stylesheet.css">' . "\n" . '<link rel="stylesheet" type="text/css" media="print"    href="/media/base_theme/printer.css">' . "\n" . "</head>\n<body>\n" . "<h1>Statistics for {$node->getName()}</h1>\n");
     //Generate reports
     //        if ($verbose)
     //            print $statistics_object->getSqlCandidateConnectionsQuery("DEBUG Node {$node->getId()}", false);
     $graphclass = "VisitsPerMonth";
     $report = StatisticGraph::getObject($graphclass);
     $reportimg = "VisitsPerMonth.png";
     $report->showImageData('', array('filename' => $node->getPublicStatsDir() . $reportimg));
     unset($report);
     fwrite($index, "" . "<div>\n" . "<h2>" . "Number of individual user visits per month" . "</h2>\n" . "<img src='{$reportimg}' alt='{$graphclass}' /><br />\n" . "Note:  A visit is like counting connections, but only counting one connection per day for each user at a single node" . "</div>\n<br />\n");
     //Write the index file footer
     fwrite($index, "</body>\n");
     fclose($index);
     unset($index);
 } else {
     //Clear the folder
     rm_rf_dir($node->getPublicStatsDir());
 }
 Node::freeObject($node->getId());
 //    Network::freeObject($network->getId());
 unset($node);