diff --git a/web/public_php/stats/stats.php b/web/public_php/stats/stats.php
new file mode 100644
index 000000000..1e4e4efd7
--- /dev/null
+++ b/web/public_php/stats/stats.php
@@ -0,0 +1,403 @@
+
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+ include_once('../login/config.php');
+
+ // LOG database
+ $StatsDBHost = $DBHost;
+ $StatsDBUserName = $DBUserName;
+ $StatsDBPassword = $DBPassword;
+ $StatsDBName = "stats";
+
+ error_reporting(E_ERROR | E_PARSE);
+ set_error_handler('err_callback');
+
+ // global var
+ $link = NULL;
+ $page_max = 100;
+ $dev_ip="192.168.1.169"; //ip where sql error are displayed
+ $private_network = "/192\.168\.1\./i"; //ip where the cmd=log&msg=dump function works
+ $page_name = "stats.php";
+
+
+
+ //get the ip of the viewer
+ function getIp()
+ {
+ if (getenv("HTTP_CLIENT_IP"))
+ {
+ $ip = getenv("HTTP_CLIENT_IP");
+ }
+ elseif(getenv("HTTP_X_FORWARDED_FOR"))
+ {
+ $ip = getenv("HTTP_X_FORWARDED_FOR");
+ }
+ else
+ {
+ $ip = getenv("REMOTE_ADDR");
+ }
+ return $ip;
+ }
+
+
+ // if the player ip is the dev ip then the sql error is explain
+ function die2($debug_str)
+ {
+ global $private_network;
+ if ( preg_match($private_network, getIp()) )
+ {
+ die($debug_str);
+ }
+ else
+ {
+ die("GENERIC_ERROR");
+ }
+ }
+
+ // get head or post infos return default if no valuees
+ function getPost($value, $default=NULL)
+ {
+ if ( isSet($_GET[$value]) ) { return $_GET[$value]; }
+ if ( isSet($_POST[$value]) ) { return $_POST[$value]; }
+
+ return $default;
+ }
+
+ // log error in bdd
+ function debug($str)
+ {
+ global $StatsDBHost;
+ global $StatsDBUserName;
+ global $StatsDBPassword;
+ global $StatsDBName;
+ global $link;
+
+ $newConnection = 0;
+
+ if ($link == NULL)
+ {
+ $link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." Can't connect to database host:$StatsDBHost user:$StatsDBUserName");
+ $newConnection = 1;
+
+ mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." Can't access to the table dbname:$StatsDBName");
+ }
+
+
+ $str = str_replace("'", "", $str);
+ $str = str_replace( '"', "", $str);
+
+
+ $query= "INSERT INTO `log` ( `log` )"
+ . "VALUES ("
+ . "'$str'"
+ . ")";
+
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ if ($newConnection == 1)
+ {
+ mysql_close($link);
+ $link = NULL;
+ }
+
+ }
+ function err_callback($errno, $errmsg, $filename, $linenum, $vars)
+ {
+ debug("$filename $linenum $errmsg");
+ }
+
+
+// debug( getenv("QUERY_STRING") );
+
+ // extract the cmd
+ $cmd = getPost("cmd" ,"log");
+ if ($cmd == "")
+ {
+ echo "0:Missing cmd";
+ die2();
+ }
+
+ // check for 'clear password' tag
+ switch ($cmd)
+ {
+ // log <=> display php page
+ case "log":
+ $date = date('Y-m-d H:i:s', time());
+ $ip = getIp();
+ $log = getenv("QUERY_STRING");
+ $link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." Can't connect to database host:$StatsDBHost user:$StatsDBUserName");
+ mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." Can't access to the table dbname:$StatsDBName");
+
+
+ $msg = getPost("msg", "");
+ switch ($msg)
+ {
+ //display php infos
+
+
+
+ case "start_download":
+
+ $query = "SELECT max(`session_id`) as `res` from `sessions`";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ $session_id = 1000;
+ if( mysql_num_rows($result) != 0)
+ {
+ $row = mysql_fetch_array($result);
+ $session_id = $row["res"] + 1;
+ }
+
+ $now = date("Y-m-d H:i:s", time());
+ $server = getPost("server", "");
+ $application = getPost("application", "");
+ $version = getPost("version", "");
+ $lang = getPost("lang","");
+ $type = getPost("application", "");
+ $package = getPost("package", "");
+ $protocol = getPost("protocol", "");
+ $size_download =getPost("size_download", "");
+ $size_install = getPost("size_install", "");
+ $user_id = getPost("user_id", "0");
+ $previous_download = getPost("previous_download", "0");
+
+
+ $query= "INSERT INTO `sessions` ( `session_id`, `user_id` , `server`, `application`, `ip` , `lang`, `type`, `package`, `protocol`, `size_download`, `size_install`, `start_download`, `stop_download`, `previous_download` )"
+
+ . "VALUES ("
+ . "'$session_id', '$user_id' ,'$server', '$application', '$ip', '$lang', '$type', '$package', '$protocol', '$size_download', '$size_install', '$now', '$now', '$previous_download'"
+ . ")";
+
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+
+
+ $query= "UPDATE `install_users` set install_count = install_count + 1, state='DU_DL', last_install='$now' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+
+ echo "".$session_id."";
+ break;
+
+ case "stop_download":
+
+ $session_id =getPost("session_id", "0");
+ $now = date("Y-m-d H:i:s", time());
+ $query = "UPDATE `sessions` SET `stop_download` = '$now', `percent_download` ='100' WHERE `session_id` = '$session_id' LIMIT 1";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_IN' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+
+ break;
+ // update the percent of download
+ case "update_download":
+
+ $session_id =getPost("session_id", "0");
+ $percent = getPost("percent", "0");
+ $now = date("Y-m-d H:i:s", time());
+ $query = "UPDATE `sessions` SET `percent_download` ='$percent', `stop_download` = '$now' WHERE `session_id` = '$session_id' LIMIT 1";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ // update the percent of finish
+ case "update_install":
+
+ $now = date("Y-m-d H:i:s", time());
+ $session_id =getPost("session_id", "0");
+ $percent = getPost("percent", "0");
+ $query = "UPDATE `sessions` SET `percent_install` ='$percent', `stop_download` = '$now' WHERE `session_id` = '$session_id' LIMIT 1";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+
+
+ case "no_install":
+
+ $session_id = getPost("session_id", "0");
+ $now = date("Y-m-d H:i:s", time());
+ $query = "UPDATE `sessions` SET `size_download` = '0', `start_install` = '$now', `stop_install` = '$now', `percent_install` ='100' WHERE `session_id` = '$session_id' LIMIT 1";
+ echo $query;
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ // install is finished
+ case "stop_install":
+ $session_id = getPost("session_id", "0");
+ $now = date("Y-m-d H:i:s", time());
+ $query = "UPDATE `sessions` SET `stop_install` = '$now', `stop_download` = '$now', `percent_install` ='100' WHERE `session_id` = '$session_id' LIMIT 1";
+ echo $query;
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_FI' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+ // addd user info to database
+ case "start_install":
+ $session_id = getPost("session_id", "");
+ $now = date("Y-m-d H:i:s", time());
+ $query = "UPDATE `sessions` SET `start_install` = '$now', `stop_download` = '$now' WHERE `session_id` = '$session_id' LIMIT 1";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+
+
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_IN' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ case "login_step_video_mode_setup":
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_VMS' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ case "login_step_video_mode_setup_high_color":
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_VMSHS' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ case "login_step_login_screen":
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_AL' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ case "login_step_post_login":
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_PL' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ case "login_step_character_selection":
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_CS' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+ case "login_step_game_entry":
+ $user_id = getPost("user_id", "0");
+ $query= "UPDATE `install_users` set state='DU_AG' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ break;
+
+
+ case "login_step_game_exit":
+ $user_id = getPost("user_id", "0");
+ $play_time = getPost("play_time", "0");
+ // manualy estimate the duration of the previous session
+ {
+ $query = "SELECT `state` from install_users where `user_id` = '$user_id'";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ $state = "AG";
+ if( mysql_num_rows($result) > 0)
+ {
+ $row = mysql_fetch_array($result);
+ $state = $row["state"];
+ }
+
+ if ($state == "DU_P1")
+ {
+ $play_time = $play_time + 30 *60;
+ }
+ else if ($state == "DU_P2")
+ {
+ $play_time = $play_time + 60* 60;
+ }
+ else if ($state == "DU_P3")
+ {
+ $play_time = $play_time + 2*60* 60; // P3 will stat P3
+ }
+ }
+
+
+ if ($play_time > 2*60*60) // time played > 2 h
+ {
+ $query= "UPDATE `install_users` set state='DU_P3' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ }
+ else if ($play_time > 60*60) // time played > 2 h
+ {
+ $query= "UPDATE `install_users` set state='DU_P2' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ }
+ else if ($play_time > 30*60) // time played > 30 m
+ {
+ $query= "UPDATE `install_users` set state='DU_P1' where user_id='$user_id';";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ }
+ break;
+
+ // addd user info to database
+ case "init":
+ $query = "SELECT max(`user_id`) as max_id from `install_users`";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ $user_id = 1;
+ if( mysql_num_rows($result) != 0)
+ {
+ $row = mysql_fetch_array($result);
+ $user_id = $row["max_id"] + 1;
+ }
+
+ $install_id = getPost("install_id", "0");
+ $os = getPost("os", "Unknown");
+ $proc = getPost("proc", "Unknown");
+ $memory = getPost("memory", "Unknown");
+ $video_card = getPost("video_card", "Unknown");
+ $driver_version = getPost("driver_version", "Unknown");
+
+ $query = "INSERT INTO `install_users` SET `user_id` = '$user_id', `install_id`='$install_id', `os`='$os', `proc`='$proc', `memory`='$memory', `video_card`='$video_card', `driver_version`='$driver_version', `last_install`='".date('Y-m-d H:i:s', time()) . "', `first_install`=`last_install`";
+
+
+
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ echo "$user_id";
+ break;
+
+ // first log if empyt user_id is return then must init
+ case "login":
+ $install_id = getPost("install_id", "0");
+ $query = "SELECT `user_id` from install_users where `install_id` = '$install_id'";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." Can't execute the query: ".$query);
+ if( mysql_num_rows($result) == 0)
+ {
+ echo "";
+ break;
+ }
+ $row = mysql_fetch_array($result);
+ $user_id = $row["user_id"];
+ echo "$user_id";
+ break;
+
+
+
+
+ default:
+ echo "unknown command: $msg $log";
+ }
+
+
+ mysql_close($link);
+ unset($link);
+
+ break;
+
+ default:
+ echo "0:Unknown command";
+ die2();
+ }
+
+
+?>
diff --git a/web/public_php/stats_query/stats_query.php b/web/public_php/stats_query/stats_query.php
new file mode 100644
index 000000000..2f10df25f
--- /dev/null
+++ b/web/public_php/stats_query/stats_query.php
@@ -0,0 +1,939 @@
+
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+ include_once('../login/config.php');
+
+ // LOG database
+ $StatsDBHost = $DBHost;
+ $StatsDBUserName = $DBUserName;
+ $StatsDBPassword = $DBPassword;
+ $StatsDBName = "stats";
+
+ error_reporting(E_ERROR | E_PARSE);
+ set_error_handler('err_callback');
+
+ // for error handling, buffer all output
+
+ $link = NULL;
+ $page_name="stats_query.php";
+ $page_max = 50;
+ $dev_ip="192.168.1.169"; //ip WHERE sql error are displayed
+// $private_network = "/192\.168\.1\./i"; //ip WHERE the cmd=view function works
+
+
+ function toHMS($time)
+ {
+ $ret = "";
+ if ($time <= 0) { return "0 s";}
+ if ($time > 60*60*24)
+ {
+ $days = floor($time / (60*60*24));
+ $time = floor($time - $days * 60*60*24);
+ if ($days != 0) {
+ $ret = $ret . $days . "d ";
+ }
+ }
+
+ if ($time > 60*60)
+ {
+ $hours = floor($time / (60*60));
+ $time = floor($time - $hours * 60*60);
+ if ($hours != 0) {
+ $ret = $ret . $hours . "h ";
+ }
+ }
+
+ if ($time > 60)
+ {
+ $mins = floor($time / 60);
+ $time = floor($time - $mins * 60);
+ if ($mins != 0) {
+ $ret = $ret . $mins . "m ";
+ }
+ }
+ if ($time != 0) {
+ $ret = $ret . $time . "s ";
+ }
+ return $ret;
+ }
+
+ //get the ip of the viewer
+ function getIp()
+ {
+ if (getenv("HTTP_CLIENT_IP"))
+ {
+ $ip = getenv("HTTP_CLIENT_IP");
+ }
+ elseif(getenv("HTTP_X_FORWARDED_FOR"))
+ {
+ $ip = getenv("HTTP_X_FORWARDED_FOR");
+ }
+ else
+ {
+ $ip = getenv("REMOTE_ADDR");
+ }
+ return $ip;
+ }
+
+
+ // if the player ip is the dev ip then the sql error is explain
+ function die2($debug_str)
+ {
+// global $private_network;
+// if ( preg_match($private_network, getIp()) )
+// {
+ die($debug_str);
+// }
+// else
+// {
+// die("GENERIC_ERROR");
+// }
+ }
+
+ // get head or post infos return default if no valuees
+ function getPost($value, $default=NULL)
+ {
+ if ( isSet($_GET[$value]) ) { return $_GET[$value]; }
+ if ( isSet($_POST[$value]) ) { return $_POST[$value]; }
+ return $default;
+ }
+
+ $cmd = getPost("cmd", "view");
+
+ $show_dl=getPost("show_dl", "1");
+ $show_ddl=getPost("show_ddl", "1");
+ $show_du=getPost("show_du", "1");
+ $show_hdu=getPost("show_hdu", "1");
+ $show_hdu2=getPost("show_hdu2", "1");
+ $show_hddetails=getPost("show_hddetails", "0");
+
+ function getHref()
+ {
+
+ global $show_dl;
+ global $show_ddl;
+ global $show_du;
+ global $show_hdu;
+ global $show_hdu2;
+ global $selected;
+ global $page_name;
+ global $display;
+ global $show_hddetails;
+ return "$page_name?cmd=view&show_dl=$show_dl&show_ddl=$show_ddl&show_du=$show_du&show_hdu=$show_hdu&show_hdu2=$show_hdu2&selected=$selected&display=$display&show_hddetails=$show_hddetails";
+ }
+
+
+ // do a simple sql query return the result of the query
+ function getSimpleQueryResult($query, &$link)
+ {
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: $query
".mysql_error()."
");
+
+ if ( ($row = mysql_fetch_array($result)) )
+ {
+ return $row["ret"];
+
+ }
+ return "";
+ }
+
+ // log error in bdd
+ function debug($str)
+ {
+ global $StatsDBHost;
+ global $StatsDBUserName;
+ global $StatsDBPassword;
+ global $StatsDBName;
+ global $link;
+
+ $newConnection = 0;
+
+ if ($link == NULL)
+ {
+ $link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." can't connect to database host:$StatsDBHost user:$StatsDBUserName");
+ $newConnection = 1;
+
+ mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." can't access to the table dbname:$StatsDBName");
+ }
+
+
+ $str = str_replace("'", "", $str);
+ $str = str_replace( '"', "", $str);
+
+
+ $query= "INSERT INTO `log` ( `log` )"
+ . "VALUES ("
+ . "'$str'"
+ . ")";
+
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+ if ($newConnection == 1)
+ {
+ mysql_close($link);
+ $link = NULL;
+ }
+
+ }
+ function err_callback($errno, $errmsg, $filename, $linenum, $vars)
+ {
+ echo "error: line $linenum, $errmsg
";
+ // debug($errmsg);
+ }
+
+ //extract infos FROM sessions
+ function getStats($mode, $day, &$link)
+ {
+
+ $day2 = date('Y-m-d', $day);
+ $day_first = date('Y-m-d H:i:s', strtotime( date('Y-m-d', $day) ) );
+ $day_last = date('Y-m-d H:i:s', strtotime(date('Y-m-d', $day + 3600*24)) - 1);
+ $condition1 = "install_users.first_install >= '$day_first' AND install_users.first_install <= '$day_last' ";
+ $condition2 = "`sessions`.`start_download` >= '$day_first' AND `sessions`.`start_download` <= '$day_last' ";
+
+ if (!isSet($condition))
+ {
+ $condition = "1";
+ }
+ $ret = array();
+
+ if ($mode == 2)
+ {
+
+ // false = not optimized
+ if (true)
+ {
+ //true == optimized: Request is optimized we use one query instead of many
+ $query = "SELECT "
+ ."SUM(IF(install_users.state = 'DU_P3', 1, 0)) AS DU_P3, "
+ ."SUM(IF(install_users.state = 'DU_P2', 1, 0)) AS DU_P2, "
+ ."SUM(IF(install_users.state = 'DU_P1', 1, 0)) AS DU_P1, "
+ ."SUM(IF(install_users.state = 'DU_AG', 1, 0)) AS DU_AG, "
+ ."SUM(IF(install_users.state = 'DU_CS', 1, 0)) AS DU_CS, "
+ ."SUM(IF(install_users.state IN ('DU_AL', 'DU_PL' ), 1, 0)) AS DU_AL, "
+ ."SUM(IF(install_users.state IN ('DU_FI', 'DU_VMS', 'DU_VMSHS' ), 1, 0)) AS DU_FI,"
+ ."SUM(IF(install_users.state = 'DU_IN', 1, 0)) AS DU_IN, "
+ ."SUM(IF(install_users.state = 'DU_DL', 1, 0)) AS DU_DL "
+ ."FROM install_users "
+ ."WHERE $condition1 "
+ ."AND install_users.user_id "
+ ."IN ( SELECT sessions.user_id FROM sessions WHERE $condition2 )";
+
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+ if ( ($row = mysql_fetch_array($result)) )
+ {
+
+ $ret["DU_P3"] = $row["DU_P3"];
+ $ret["DU_P2"] = $row["DU_P2"] + $ret["DU_P3"];
+ $ret["DU_P1"] = $row["DU_P1"] + $ret["DU_P2"];
+ $ret["DU_AG"] = $row["DU_AG"] + $ret["DU_P1"];
+ $ret["DU_CS"] = $row["DU_CS"] + $ret["DU_AG"];
+ $ret["DU_AL"] = $row["DU_AL"] + $ret["DU_CS"];
+ $ret["DU_FI"] = $row["DU_FI"] + $ret["DU_AL"];
+ $ret["DU_IN"] = $row["DU_IN"] + $ret["DU_FI"];
+ $ret["DU_DL"] = $row["DU_DL"] + $ret["DU_IN"];
+ }
+
+ } else {
+
+ $ret["DU_P3"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_P3'", $link) ;
+ $ret["DU_P2"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_P2'", $link) + $ret['DU_P3'];
+ $ret["DU_P1"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_P1'", $link) + $ret['DU_P2'];
+ $ret["DU_AG"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_AG'", $link) + $ret['DU_P1'];
+ $ret["DU_CS"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`= 'DU_CS'", $link) + $ret['DU_AG'];
+ $ret["DU_AL"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state` IN ('DU_AL', 'DU_PL' ) ", $link) + $ret['DU_CS'];
+ $ret["DU_FI"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state` IN ('DU_FI', 'DU_VMS', 'DU_VMSHS' )", $link) + $ret['DU_AL'];
+ $ret["DU_IN"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_IN'", $link) + $ret['DU_FI'];
+ $ret["DU_DL"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(`sessions`.`user_id`)) AS ret FROM `sessions`, `install_users` WHERE $condition1 AND `install_users`.`user_id`=`sessions`.`user_id` AND `install_users`.`state`='DU_DL'", $link) + $ret['DU_IN'];
+ }
+ }
+
+ $ret["all_session"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2", $link);
+
+ if ($mode == 1)
+ {
+
+ $ret["distinct_user"] = getSimpleQueryResult("SELECT COUNT(DISTINCT(sessions.user_id)) AS ret FROM `sessions` WHERE $condition2 ORDER BY sessions.user_id", $link);
+ //true == optimized: Request is optimized we use one query instead of many
+ if (true)
+ {
+ $query = "SELECT"
+ . " COUNT(session_id) AS all_session,"
+ . " SUM(IF(sessions.previous_download IN ('0', '0.00B', '0.000B'), 1, 0)) AS clean_start,"
+ . " SUM(IF(sessions.percent_download = '100', 1, 0)) AS download_finished,"
+ . " SUM(IF(sessions.percent_install = '100', 1, 0)) AS install_finished,"
+ . " SUM(IF(sessions.package = 'full', 1, 0)) AS download_full,"
+ . " SUM(IF(sessions.lang = 'fr', 1, 0)) AS fr,"
+ . " SUM(IF(sessions.lang = 'en', 1, 0)) AS en,"
+ . " SUM(IF(sessions.lang = 'de', 1, 0)) AS de"
+ . " FROM sessions"
+ . " WHERE $condition2";
+
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+ if ( ($row = mysql_fetch_array($result) ) )
+ {
+ $ret["all_session"] = $row["all_session"];
+ $ret["clean_start"] = $row["clean_start"];
+ $ret["download_finished"] = $row["download_finished"];
+ $ret["install_finished"] = $row["install_finished"];
+ $ret["download_full"] = $row["download_full"];
+ $ret["fr"] = $row["fr"];
+ $ret["en"] = $row["en"];
+ $ret["de"] = $row["de"];
+ }
+
+
+ } else {
+ $ret["clean_start"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND previous_download IN ('0', '0.000b', '0.00B')", $link);
+ $ret["download_finished"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `percent_download` = '100'", $link);
+ $ret["install_finished"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `percent_install` = '100' ", $link);
+ $ret["download_full"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `package` = 'full'", $link);
+ $ret["fr"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `lang` = 'fr'", $link);
+ $ret["en"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `lang` = 'en'", $link);
+ $ret["de"] = getSimpleQueryResult("SELECT COUNT(`session_id`) AS ret FROM `sessions` WHERE $condition2 AND `lang` = 'de'", $link);
+ }
+ $ret["restart"] = $ret['all_session'] - $ret['clean_start'];
+
+ }
+ return $ret;
+
+ }
+
+
+
+ // display download infos
+ // condition is the condition for displaying users (time condition)
+ // max_reslut is the number of result that could be displayed
+ function displayDownload($link)
+ {
+ global $show_dl;
+ global $selected;
+
+ $date = getdate($selected);
+ $date_first = date('Y-m-d H:i:s', strtotime( date('Y-m-1', $selected) ) );
+ $date_first_int = strtotime($date_first);
+ $date_last = date('Y-m-d H:i:s', strtotime(date('Y-m-1', $selected + 31*24*3600)) - 1);
+ $date_last_int = strtotime($date_last);
+ $nbday = round( ($date_last_int +1 - $date_first_int ) / (24*3600));
+
+ //display sumary infos (if title clicked make apears or disapears the menu)
+ $old_value = $show_dl;
+ $show_dl = !$show_dl;
+ echo '
';
+ $show_dl = $old_value;
+
+ if ($show_dl == 1)
+ {
+
+
+ echo ''."\n";
+ echo "\n"
+ . "week day | \n"
+ . "".$date['month']. " ".$date['year']." | \n"
+ . "distinct users(today) | \n"
+ . "first start | \n"
+ . "restart | \n"
+ . "total download | \n"
+ . "download finished | \n"
+ . "install finished | \n"
+ . "full version | \n"
+ . "fr | \n"
+ . "en | \n"
+ . "de | \n"
+ . "
\n";
+
+
+ // for each day of the month with download display infos
+ for ($i = 0; $i < $nbday; $i++)
+ {
+ $day = $date_first_int + $i*24*3600;
+
+ if ($day >= time())// + 24*3600)
+ {
+ break;
+ }
+ $day_first = date('Y-m-d H:i:s', strtotime( date('Y-m-d', $day) ) );
+ $day_last = date('Y-m-d H:i:s', strtotime(date('Y-m-d', $day + 3600*24)) - 1);
+
+ $res = getStats(1, $day, $link);
+ $date_today = getdate($day);
+ // display only if active download
+ if ($res['all_session'] != 0 )
+ {
+
+ echo "\n"
+
+ . "".$date_today['weekday']." | ";
+
+
+ if (date('Y-m-d', $day)==date('Y-m-d', $selected))
+ {
+ echo "".($i+1)." | ";
+ }
+ else
+ {
+ echo "".($i+1)." | ";
+ }
+
+ echo "".$res['distinct_user']." | "
+ //. "".$res['all_session']." | "
+ . "".$res['clean_start']." | "
+ . "".$res['restart']." | "
+ . "".($res['restart'] + $res['clean_start'])." (". $res['clean_start']. "+" . $res['restart'] .") | "
+
+ . "".$res['download_finished']." | "
+ . "".$res['install_finished']." | "
+ . "".$res['download_full']." | "
+ . "".$res['fr']." | "
+ . "".$res['en']." | "
+ . "".$res['de']." | "
+ . "
\n";
+ }
+
+ }
+ echo "
";
+
+ //display next mont, prev month link
+ echo ''." < last month". ' ';
+ echo ", ";
+ echo ''."next month >". ' ';
+ }
+ }
+
+ function displayDistinctUsers($link)
+ {
+ global $show_du;
+ global $selected;
+
+ $date = getdate($selected);
+ $date_first = date('Y-m-d H:i:s', strtotime( date('Y-m-1', $selected) ) );
+ $date_first_int = strtotime($date_first);
+ $date_last = date('Y-m-d H:i:s', strtotime(date('Y-m-1', $selected + 31*24*3600)) - 1);
+ $date_last_int = strtotime($date_last);
+ $nbday = round( ($date_last_int +1 - $date_first_int ) / (24*3600));
+
+ // when click on title, the content apears or disapers
+ $old_value = $show_du;
+ $show_du = !$show_du;
+ echo '';
+ $show_du = $old_value;
+
+ if ($show_du == 1)
+ {
+ echo ''."\n";
+ echo "\n"
+ . "week day | \n"
+ . "".$date['month']. " ".$date['year']." | \n"
+ . "started dl | \n"
+ . "finished dl | \n"
+ . "finished inst | \n"
+ . "arrive login | \n"
+ . "arrive char sel | \n"
+ . "arrive in game | \n"
+ . "play 30 min | \n"
+ . "play 1hr | \n"
+ . "play 2hr | \n"
+ . "
\n";
+ for ($i = 0; $i < $nbday; $i++)
+ {
+
+ $day = $date_first_int + $i*24*3600;
+ if ($day >= time())// + 24*3600)
+ {
+ break;
+ }
+// $row = getStats("`sessions`.`start_download` >= '$day_first' AND `sessions`.`start_download` <= '$day_last' ", $link);
+ $row = getStats(2, $day, $link);
+
+ $date_today = getdate($day);
+ if ($row['all_session'] != 0)
+ {
+ echo "";
+
+ echo "".$date_today['weekday']." | ";
+ if (date('Y-m-d', $day)==date('Y-m-d', $selected))
+ {
+ echo "".($i+1)." | ";
+ }
+ else
+ {
+ echo "".($i+1)." | ";
+ }
+
+ echo "".$row["DU_DL"]." | \n";
+ echo "".$row["DU_IN"]." | \n";
+ echo "".$row["DU_FI"]." | \n";
+ echo "".$row["DU_AL"]." | \n";
+ echo "".$row["DU_CS"]." | \n";
+ echo "".$row["DU_AG"]." | \n";
+ echo "".$row["DU_P1"]." | \n";
+ echo "".$row["DU_P2"]." | \n";
+ echo "".$row["DU_P3"]." | \n";
+ echo "
\n";
+ }
+
+ }
+
+ echo "
\n";
+ echo ''." < last month". ' ';
+ echo ", ";
+ echo ''."next month >". ' ';
+
+ }
+ }
+
+ function displayDownloadDetails($condition, $link)
+ {
+ global $page_max;
+ global $show_ddl;
+ global $page_download;
+ global $page_users;
+ global $page_users2;
+ global $selected;
+
+
+ $query = "SELECT COUNT(`session_id`) AS max"
+ . " FROM `sessions`"
+ . " WHERE $condition";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+ $max_result = 0;
+ if ( ($row = mysql_fetch_array($result)) ) { $max_result = $row["max"];}
+
+ //display sumary infos (if title clicked make apears or disapears the menu)
+ $old_value = $show_ddl;
+ $show_ddl = !$show_ddl;
+ echo '';
+ $show_ddl = $old_value;
+ if ($show_ddl == 1)
+ {
+ echo ''."\n";
+ echo "\n"
+ . "user_id | \n"
+ . "ip | \n"
+ . "lang | \n"
+ . "sku | \n"
+ . "protocol | \n"
+ . "sz dl | \n"
+ . "sz inst | \n"
+ . "start | \n"
+ . "start inst | \n"
+ . "finish | \n"
+ . "time | \n"
+ . "% dl | \n"
+ . "% inst | \n"
+ . "prev dl | \n"
+ . "
\n";
+
+ $query = "SELECT COUNT(`session_id`) AS max FROM `sessions` WHERE $condition";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+ $max_result=0;
+ if ( ($row = mysql_fetch_array($result)) ) { $max_result = $row["max"]; }
+
+
+
+ $query = "SELECT `session_id` , `user_id` , `server` , `application` , `version` , `ip` , `lang` , `type` , `package` , `protocol` , `size_download` , `size_install` , `start_download` , `stop_download` , `start_install` , `stop_install` , `percent_download` , `percent_install` , `previous_download`"
+ . " FROM `sessions`"
+ . " WHERE $condition"
+ . " ORDER by `user_id` desc, `start_download` desc"
+ . " LIMIT ".($page_download * $page_max)." , ".$page_max;
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+
+ while ( ($row = mysql_fetch_array($result)) )
+ {
+ echo "";
+ echo ""
+ .$row["user_id"]
+ ." | \n";
+ echo "".$row["ip"]." | \n";
+ echo "".$row["lang"]." | \n";
+ echo "".$row["package"]." | \n";
+ echo "".$row["protocol"]." | \n";
+ echo "".$row["size_download"]." | \n";
+ echo "".$row["size_install"]." | \n";
+ echo "".$row["start_download"]." | \n";
+ echo "".$row["start_install"]." | \n";
+ echo "".$row["stop_install"]." | \n";
+ echo "" . toHMS(strtotime($row["stop_download"]) - strtotime($row["start_download"]) ) ." | \n";
+ echo "".$row["percent_download"]." | \n";
+ echo "".$row["percent_install"]." | \n";
+ echo "".$row["previous_download"]." | \n";
+ echo "
\n";
+ }
+ echo "
\n";
+
+ for ($i = 1 ;$i < ($max_result / $page_max)+1; $i = $i+1)
+ {
+ if ($page_download + 1 == $i)
+ {
+ echo ($i)." ";
+ }
+ else
+ {
+ echo ''.($i). ' ';
+ }
+ }
+
+ }
+ }
+
+ function lastSession($id, $condition, $link)
+ {
+ $query = "SELECT install_users.user_id, sessions.session_id, sessions.stop_download, sessions.start_download, sessions.percent_download, sessions.percent_install "
+ . " FROM install_users, sessions "
+ . " WHERE install_users.user_id='" . $id . "' AND install_users.user_id = sessions.user_id AND $condition"
+ . " ORDER BY sessions.session_id DESC";
+
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+ if ( ($row = mysql_fetch_array($result)) )
+ {
+ $ret["session_id"] = $row["session_id"];
+ $ret["time"] = strtotime($row["stop_download"]) - strtotime($row["start_download"]) ;
+ $ret["percent"] = $row["percent_download"] . "/". $row["percent_install"];
+ return $ret;
+ }
+ $ret["time"] = "?";
+ $ret["percent"] = "?";
+ return $ret;
+ }
+
+
+
+ // display infos on user hardware
+ // condition is the condition for displaying users (time condition)
+ function displayHardwareNewUserImpl($install_state, $title, $condition, $condition2, $link)
+ {
+
+ global $page_max;
+ global $page_users;
+ global $page_users2;
+ global $selected;
+ global $show_hdu;
+ global $show_hdu2;
+ global $show_hddetails;
+
+
+// $query = "SELECT COUNT(install_users.user_id) AS max FROM install_users WHERE $condition2 AND install_users.user_id in (SELECT DISTINCT(sessions.user_id) from sessions where $condition)";
+ $query = "SELECT COUNT(DISTINCT(sessions.user_id)) AS max FROM `install_users`,`sessions` WHERE $condition2 AND install_users.user_id = sessions.user_id AND $condition";
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+ $max_result = 0;
+ if ( ($row = mysql_fetch_array($result)) ) { $max_result = $row["max"];}
+
+ if ($install_state==1)
+ {
+ $old_value = $show_hdu;
+ $show_hdu = 1-$show_hdu;
+ echo '';
+ $show_hdu = $old_value;
+ $nbpages = $page_users;
+ }
+ else
+ {
+ $old_value = $show_hdu2;
+ $show_hdu2 = 1-$show_hdu2;
+ echo '';
+ $show_hdu2 = $old_value;
+ $nbpages = $page_users2;
+ }
+
+ // Show / Hide os column
+ {
+ $old_value = $show_hddetails;
+ $show_hddetails = 1 - $show_hddetails;
+ if ($show_hddetails == 1)
+ {
+ echo '';
+ }
+ else
+ {
+ echo '';
+ }
+ $show_hddetails = $old_value;
+ }
+
+
+ //display sumary infos (if title clicked make apears or disapears the menu)
+
+ if (($install_state==1 && $show_hdu == 1) || ($install_state==2 && $show_hdu2 == 1) )
+ {
+
+
+ echo ''."\n";
+ echo "\n"
+ . "user_id | \n";
+ if ($show_hddetails == 0)
+ {
+
+ echo "first_install | \n"
+ . "last_install | \n"
+ . "install_count | \n"
+ . "install time | \n"
+ . "last install time | \n";
+ }
+ if ($install_state) { echo "last install state | \n"; }
+ echo "memory | \n";
+ if ($show_hddetails == 1)
+ {
+ echo "os | \n"
+ . "proc | \n"
+
+ . "video_card | \n"
+ . "driver_version | \n";
+ }
+
+ echo "current state | \n"
+ . "
\n";
+
+ $query = "SELECT `install_users`.`user_id` , `install_users`.`first_install`, `install_users`.`last_install`, `install_users`.`install_count`, `install_users`.`os` , `install_users`.`proc` , `install_users`.`memory` , `install_users`.`video_card` , `install_users`.`driver_version`, `install_users`.`state`, "
+ ."SUM( IF(sessions.stop_download >sessions.start_download, UNIX_TIMESTAMP(sessions.stop_download) - UNIX_TIMESTAMP(sessions.start_download) , 0))AS waiting_time, count(sessions.session_id) AS install_count2"
+ . " FROM `install_users`, `sessions`"
+ . " WHERE `sessions`.`user_id` = `install_users`.`user_id` AND $condition AND $condition2"
+ . " GROUP by `sessions`.`user_id`"
+ . " ORDER by `sessions`.`user_id` desc"
+ . " LIMIT ".($nbpages * $page_max)." , ".$page_max;
+ $result = mysql_query ($query, $link) or die2 (__FILE__. " " .__LINE__." can't execute the query: ".$query);
+
+
+ while ( ($row = mysql_fetch_array($result)) )
+ {
+ $ret = lastSession($row["user_id"], $condition, $link);
+ echo "";
+ echo "".$row["user_id"]." | \n";
+ if ($show_hddetails == 0)
+ {
+ echo "".$row["first_install"]." | \n";
+ echo "".$row["last_install"]." | \n";
+ echo "".$row["install_count2"]." | \n";
+ echo "".toHMS($row["waiting_time"])." | \n";
+ echo "".toHMS($ret["time"])." | \n";
+ }
+ if ($install_state) { echo "".$ret["percent"]." | \n"; }
+ echo "".$row["memory"]." | \n";
+ if ($show_hddetails == 1)
+ {
+ echo "".$row["os"]." | \n";
+ echo "".$row["proc"]." | \n";
+
+ echo "".$row["video_card"]." | \n";
+ echo "".$row["driver_version"]." | \n";
+ }
+ echo "".$row["state"]." | \n";
+ echo "
\n";
+ }
+ echo "
\n";
+
+ }
+ if (($install_state==1 && $show_hdu == 1) || ($install_state==2 && $show_hdu2 == 1) )
+ {
+ for ($i = 1 ;$i < ($max_result / $page_max)+1; $i = $i+1)
+ {
+ if ($nbpages + 1 == $i)
+ {
+ echo ($i)." ";
+ }
+ else
+ {
+ if ($install_state==1)
+ {
+ echo ''.($i). ' ';
+ }
+ else
+ {
+ echo ''.($i). ' ';
+ }
+ }
+ }
+ }
+ }
+
+ function displayHardwareNewUser($condition, $link)
+ {
+
+ global $display;
+ if ($display == 4)
+ {
+ displayHardwareNewUserImpl(1, "unfinished Install", $condition, " install_users.state IN ('DU_DL', 'DU_IN')", $link);
+ }
+ if ($display == 5)
+ {
+ displayHardwareNewUserImpl(2, "finished Install", $condition, " NOT (install_users.state IN ('DU_DL', 'DU_IN') )", $link);
+ }
+
+
+
+ }
+
+
+
+ // extract the cmd
+
+ if ($cmd == "")
+ {
+ echo "0:missing cmd";
+ die2();
+ }
+
+ // check for 'clear password' tag
+ switch ($cmd)
+ {
+ // log <=> display php pabe
+ case "view":
+ $dt = gettimeofday();
+ $date = date('Y-m-d H:i:s', time());
+ $ip = getIp();
+ $log = getenv("query_string");
+ $link = mysql_connect($StatsDBHost, $StatsDBUserName, $StatsDBPassword) or die2 (__FILE__. " " .__LINE__." can't connect to database host:$StatsDBHost user:$StatsDBUserName");
+ mysql_select_db ($StatsDBName, $link) or die2 (__FILE__. " " .__LINE__." can't access to the table dbname:$StatsDBName");
+
+
+ //verify passwd AND ip is private
+// if (preg_match($private_network, getIp()) )
+ {
+ //xhtml header + style
+ echo ''."\n";
+
+
+ echo "\n";
+ echo "\n";
+ echo "\n";
+
+ //display summary stat by day for current month
+
+ $selected = getPost("selected", strtotime(date('Y-m-d', time())));
+ $page_download = getPost("page_download", "1");
+ $page_download = $page_download -1;
+ if ($page_download < 0) { $page_download = 0;}
+ $page_users = getPost("page_users", "1");
+ $page_users = $page_users -1;
+ $page_users2 = getPost("page_users2", "1");
+ $page_users2 = $page_users2 -1;
+ if ($page_users < 0) { $page_users = 0;}
+ if ($page_users2 < 0) { $page_users2 = 0;}
+
+
+ $date_first = date('Y-m-d H:i:s', strtotime( date('Y-m-1', $selected) ) );
+ $date_first_int = strtotime($date_first);
+ $date_last = date('Y-m-d H:i:s', strtotime(date('Y-m-1', $selected + 31*24*3600)) - 1);
+ $date_last_int = strtotime($date_last);
+ $nbday = round( ($date_last_int +1 - $date_first_int ) / (24*3600));
+
+ $display = getPost("display", "0");
+
+ $date = getdate($selected);
+ // display server time
+ echo "server time: ".date("Y-m-d H:i:s", time())."
\n";
+
+
+
+ // display title
+ echo ''.$date['weekday'].' '.$date['mday'].' '.$date['month'].' '.$date['year'].'
';
+
+ echo '';
+ echo '';
+ echo '';
+ echo '';
+ echo '';
+
+ echo "
";
+ /*
+ to add display function copy a display* function (add a global variable to indicates if the content must be display
+ add this variable to the getHref function
+ */
+ if ($display==1)
+ {
+ displayDownload($link);
+ }
+ if ($display ==2)
+ {
+ displayDistinctUsers($link);
+ }
+
+ //display current session
+
+ $current_day = date("Y-m-d", $selected);
+ $next_day = date("Y-m-d", $selected + 24*3600);
+ $condition = "`sessions`.`start_download` >= '$current_day' AND `sessions`.`start_download` < '$next_day'";
+ if ($display == 3)
+ {
+ displayDownloadDetails($condition, $link);
+ }
+ $condition2 = "`install_users`.`first_install` >= '$current_day' AND `install_users`.`first_install` < '$next_day'";
+ displayHardwareNewUser($condition2, $link);
+
+ $dt2= gettimeofday();
+ echo "
computed in " . ( $dt2["sec"] - $dt["sec"] + ($dt2["usec"] - $dt["usec"]) / 1000000 ). "s";
+ echo "\n