From 8ea18761c9a02709b560cbdca158ebccb0a0fc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Sat, 21 Jan 2012 23:47:39 +0100 Subject: bug 1004: convert line breaks from Windows to UNIX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Tänzer --- www/stats.php | 536 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 268 insertions(+), 268 deletions(-) (limited to 'www/stats.php') diff --git a/www/stats.php b/www/stats.php index 93f693e..2fb3fb9 100644 --- a/www/stats.php +++ b/www/stats.php @@ -1,268 +1,268 @@ - 0) { - $ar = mysql_fetch_assoc($res); - $stats = unserialize($ar['cache']); - $stats['timestamp'] = $ar['timestamp']; - if ($ar['timestamp'] + MAX_CACHE_TTL < time()) - { - $stats=getDataFromLive(); - updateCache($stats); - } - return $stats; - } - $stats=getDataFromLive(); - updateCache($stats); - return $stats; - } - - /** - * get statistics data from live tables, takes a long time so please try to use the - * cache - * @return array - */ - function getDataFromLive() { - $stats = array(); - $stats['verified_users'] = number_format(tc(mysql_query("select count(`id`) as `count` from `users` where `verified`=1"))); - $stats['verified_emails'] = number_format(tc(mysql_query("select count(`id`) as `count` from `email` where `hash`='' and `deleted`=0"))); - $stats['verified_domains'] = number_format(tc(mysql_query("select count(`id`) as `count` from `domains` where `hash`='' and `deleted`=0"))); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts`")); - $stats['verified_certificates'] = number_format($certs); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `revoked`=0 and `expire`>NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `revoked`=0 and `expire`>NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `expire`<=NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `revoked`=0 and `expire`>NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `revoked`=0 and `expire`>NOW()")); - $stats['valid_certificates'] = number_format($certs); - $stats['assurances_made'] = number_format(tc(mysql_query("select count(`id`) as `count` from `notary`"))); - $stats['users_1to49'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) > 0 and sum(`points`) < 50"))); - $stats['users_50to99'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) >= 50 and sum(`points`) < 100"))); - $stats['assurer_candidates'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ". - "not exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ". - "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100"))); - $stats['aussurers_with_test'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ". - "exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ". - "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100"))); - $stats['points_issued'] = number_format(tc(mysql_query("select sum(`points`) as `count` from `notary`"))); - - $totalusers=0; - $totassurers=0; - $totalcerts=0; - for($i = 0; $i < 12; $i++) { - $tmp_arr = array(); - $tmp_arr['date'] = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y"))); - $date = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y"))); - $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$date%' and `verified`=1")); - $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$date%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100")); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `created` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `created` like '$date%'")); - $totalcerts += $certs; - - $tmp_arr['new_users'] = number_format($users); - $tmp_arr['new_assurers'] = number_format($assurers); - $tmp_arr['new_certificates'] = number_format($certs); - - $stats['growth_last_12m'][] = $tmp_arr; - } - $stats['growth_last_12m_total'] = array('new_users' => number_format($totalusers), - 'new_assurers' => number_format($totassurers), - 'new_certificates' => number_format($totalcerts)); - - $totalcerts = 0; - $totalusers = 0; - $totassurers = 0; - for($i = date("Y"); $i >= 2002; $i--) { - $tmp_arr = array(); - $tmp_arr['date'] = $i; - $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$i%' and `verified`=1")); - $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$i%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100")); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `created` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `created` like '$i%'")); - $totalcerts += $certs; - - $tmp_arr['new_users'] = number_format($users); - $tmp_arr['new_assurers'] = number_format($assurers); - $tmp_arr['new_certificates'] = number_format($certs); - - $stats['growth_last_years'][] = $tmp_arr; - } - $stats['growth_last_years_total'] = array('new_users' => number_format($totalusers), - 'new_assurers' => number_format($totassurers), - 'new_certificates' => number_format($totalcerts)); - - return $stats; - } - - $stats = getData(); -?> -

CAcert.org

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CAcert.org
:
:
:
:
:
:
:
:
:
:
:
-
- - - - - - - - - - - - - - - - - - - - -
CAcert.org
- - - -
N/A
-
- - - - - - - - - - - - - - - - - - - - -
CAcert.org
- - - -
N/A
-
- -
- - - + 0) { + $ar = mysql_fetch_assoc($res); + $stats = unserialize($ar['cache']); + $stats['timestamp'] = $ar['timestamp']; + if ($ar['timestamp'] + MAX_CACHE_TTL < time()) + { + $stats=getDataFromLive(); + updateCache($stats); + } + return $stats; + } + $stats=getDataFromLive(); + updateCache($stats); + return $stats; + } + + /** + * get statistics data from live tables, takes a long time so please try to use the + * cache + * @return array + */ + function getDataFromLive() { + $stats = array(); + $stats['verified_users'] = number_format(tc(mysql_query("select count(`id`) as `count` from `users` where `verified`=1"))); + $stats['verified_emails'] = number_format(tc(mysql_query("select count(`id`) as `count` from `email` where `hash`='' and `deleted`=0"))); + $stats['verified_domains'] = number_format(tc(mysql_query("select count(`id`) as `count` from `domains` where `hash`='' and `deleted`=0"))); + $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts`")); + $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts`")); + $certs += tc(mysql_query("select count(`id`) as `count` from `gpg`")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts`")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts`")); + $stats['verified_certificates'] = number_format($certs); + $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `revoked`=0 and `expire`>NOW()")); + $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `revoked`=0 and `expire`>NOW()")); + $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `expire`<=NOW()")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `revoked`=0 and `expire`>NOW()")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `revoked`=0 and `expire`>NOW()")); + $stats['valid_certificates'] = number_format($certs); + $stats['assurances_made'] = number_format(tc(mysql_query("select count(`id`) as `count` from `notary`"))); + $stats['users_1to49'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) > 0 and sum(`points`) < 50"))); + $stats['users_50to99'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) >= 50 and sum(`points`) < 100"))); + $stats['assurer_candidates'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ". + "not exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ". + "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100"))); + $stats['aussurers_with_test'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ". + "exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ". + "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100"))); + $stats['points_issued'] = number_format(tc(mysql_query("select sum(`points`) as `count` from `notary`"))); + + $totalusers=0; + $totassurers=0; + $totalcerts=0; + for($i = 0; $i < 12; $i++) { + $tmp_arr = array(); + $tmp_arr['date'] = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y"))); + $date = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y"))); + $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$date%' and `verified`=1")); + $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$date%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100")); + $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$date%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$date%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$date%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `created` like '$date%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `created` like '$date%'")); + $totalcerts += $certs; + + $tmp_arr['new_users'] = number_format($users); + $tmp_arr['new_assurers'] = number_format($assurers); + $tmp_arr['new_certificates'] = number_format($certs); + + $stats['growth_last_12m'][] = $tmp_arr; + } + $stats['growth_last_12m_total'] = array('new_users' => number_format($totalusers), + 'new_assurers' => number_format($totassurers), + 'new_certificates' => number_format($totalcerts)); + + $totalcerts = 0; + $totalusers = 0; + $totassurers = 0; + for($i = date("Y"); $i >= 2002; $i--) { + $tmp_arr = array(); + $tmp_arr['date'] = $i; + $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$i%' and `verified`=1")); + $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$i%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100")); + $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$i%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$i%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$i%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `created` like '$i%'")); + $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `created` like '$i%'")); + $totalcerts += $certs; + + $tmp_arr['new_users'] = number_format($users); + $tmp_arr['new_assurers'] = number_format($assurers); + $tmp_arr['new_certificates'] = number_format($certs); + + $stats['growth_last_years'][] = $tmp_arr; + } + $stats['growth_last_years_total'] = array('new_users' => number_format($totalusers), + 'new_assurers' => number_format($totassurers), + 'new_certificates' => number_format($totalcerts)); + + return $stats; + } + + $stats = getData(); +?> +

CAcert.org

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CAcert.org
:
:
:
:
:
:
:
:
:
:
:
+
+ + + + + + + + + + + + + + + + + + + + +
CAcert.org
+ + + +
N/A
+
+ + + + + + + + + + + + + + + + + + + + +
CAcert.org
+ + + +
N/A
+
+ +
+ + + -- cgit v1.2.1 From 9d08d01161831ca095ab408f8055d76af1d4a85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Sun, 22 Jan 2012 04:56:30 +0100 Subject: bug 1004: split off statistic calculation into a cron script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also includes minor improvements and bug fixes. Signed-off-by: Michael Tänzer --- www/stats.php | 136 ++++++---------------------------------------------------- 1 file changed, 14 insertions(+), 122 deletions(-) (limited to 'www/stats.php') diff --git a/www/stats.php b/www/stats.php index 2fb3fb9..45ba38b 100644 --- a/www/stats.php +++ b/www/stats.php @@ -15,28 +15,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - define('MAX_CACHE_TTL', 36000); loadem("index"); showheader(_("Welcome to CAcert.org")); - function tc($sql) - { - $row = mysql_fetch_assoc($sql); - return($row['count']); - } - - /** - * writes new data to cache, create cache or update existing cache, set current - * time stamp - * @return boolean - */ - function updateCache($stats) { - $sql = 'insert into statscache (timestamp, cache) values ("' . time() . '", ' . - '"' . mysql_real_escape_string(serialize($stats)) . '")'; - mysql_query($sql); - } - /** * get statistics data from current cache, return result of getDataFromLive if no cache file exists * @return array @@ -48,106 +30,18 @@ $ar = mysql_fetch_assoc($res); $stats = unserialize($ar['cache']); $stats['timestamp'] = $ar['timestamp']; - if ($ar['timestamp'] + MAX_CACHE_TTL < time()) - { - $stats=getDataFromLive(); - updateCache($stats); - } return $stats; } - $stats=getDataFromLive(); - updateCache($stats); - return $stats; - } - - /** - * get statistics data from live tables, takes a long time so please try to use the - * cache - * @return array - */ - function getDataFromLive() { - $stats = array(); - $stats['verified_users'] = number_format(tc(mysql_query("select count(`id`) as `count` from `users` where `verified`=1"))); - $stats['verified_emails'] = number_format(tc(mysql_query("select count(`id`) as `count` from `email` where `hash`='' and `deleted`=0"))); - $stats['verified_domains'] = number_format(tc(mysql_query("select count(`id`) as `count` from `domains` where `hash`='' and `deleted`=0"))); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts`")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts`")); - $stats['verified_certificates'] = number_format($certs); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `revoked`=0 and `expire`>NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `revoked`=0 and `expire`>NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `expire`<=NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `revoked`=0 and `expire`>NOW()")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `revoked`=0 and `expire`>NOW()")); - $stats['valid_certificates'] = number_format($certs); - $stats['assurances_made'] = number_format(tc(mysql_query("select count(`id`) as `count` from `notary`"))); - $stats['users_1to49'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) > 0 and sum(`points`) < 50"))); - $stats['users_50to99'] = number_format(mysql_num_rows(mysql_query("select `to` from `notary` group by `to` having sum(`points`) >= 50 and sum(`points`) < 100"))); - $stats['assurer_candidates'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ". - "not exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ". - "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100"))); - $stats['aussurers_with_test'] = number_format(tc(mysql_query("select count(*) as `count` from `users` where ". - "exists(select 1 from `cats_passed` as `cp`, `cats_variant` as `cv` where `cp`.`user_id`=`users`.`id` and `cp`.`variant_id`=`cv`.`id` and `cv`.`type_id`=1) and ". - "(select sum(`points`) from `notary` where `to`=`users`.`id`) >= 100"))); - $stats['points_issued'] = number_format(tc(mysql_query("select sum(`points`) as `count` from `notary`"))); - - $totalusers=0; - $totassurers=0; - $totalcerts=0; - for($i = 0; $i < 12; $i++) { - $tmp_arr = array(); - $tmp_arr['date'] = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y"))); - $date = date("Y-m", mktime(0,0,0,date("m") - $i,1,date("Y"))); - $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$date%' and `verified`=1")); - $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$date%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100")); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `created` like '$date%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `created` like '$date%'")); - $totalcerts += $certs; - - $tmp_arr['new_users'] = number_format($users); - $tmp_arr['new_assurers'] = number_format($assurers); - $tmp_arr['new_certificates'] = number_format($certs); - - $stats['growth_last_12m'][] = $tmp_arr; - } - $stats['growth_last_12m_total'] = array('new_users' => number_format($totalusers), - 'new_assurers' => number_format($totassurers), - 'new_certificates' => number_format($totalcerts)); - - $totalcerts = 0; - $totalusers = 0; - $totassurers = 0; - for($i = date("Y"); $i >= 2002; $i--) { - $tmp_arr = array(); - $tmp_arr['date'] = $i; - $totalusers += $users = tc(mysql_query("select count(`id`) as `count` from `users` where `created` like '$i%' and `verified`=1")); - $totassurers += $assurers = mysql_num_rows(mysql_query("select `to` from `notary` where `when` like '$i%' and `method`!='Administrative Increase' group by `to` having sum(`points`) >= 100")); - $certs = tc(mysql_query("select count(`id`) as `count` from `domaincerts` where `created` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `emailcerts` where `created` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `gpg` where `issued` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgdomaincerts` where `created` like '$i%'")); - $certs += tc(mysql_query("select count(`id`) as `count` from `orgemailcerts` where `created` like '$i%'")); - $totalcerts += $certs; - - $tmp_arr['new_users'] = number_format($users); - $tmp_arr['new_assurers'] = number_format($assurers); - $tmp_arr['new_certificates'] = number_format($certs); - - $stats['growth_last_years'][] = $tmp_arr; - } - $stats['growth_last_years_total'] = array('new_users' => number_format($totalusers), - 'new_assurers' => number_format($totassurers), - 'new_certificates' => number_format($totalcerts)); - - return $stats; + + return null; } $stats = getData(); + if ($stats === null) { + echo '

', _("Error while retrieving the statistics!"), '

'; + showfooter(); + die(); + } ?>

CAcert.org

@@ -222,7 +116,7 @@ - N/A + @@ -250,19 +144,17 @@ - N/A +
- -
- + +
+
+ -- cgit v1.2.1 From 1a4fb2fe639c0f973560f2fa088e10ae1d3aa1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Sun, 22 Jan 2012 05:03:01 +0100 Subject: bug 1004: make script executable and quote identifiers in SQL query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Tänzer --- www/stats.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'www/stats.php') diff --git a/www/stats.php b/www/stats.php index 45ba38b..1599e17 100644 --- a/www/stats.php +++ b/www/stats.php @@ -24,7 +24,7 @@ * @return array */ function getData() { - $sql = 'select * from statscache order by timestamp desc limit 1'; + $sql = 'select * from `statscache` order by `timestamp` desc limit 1'; $res = mysql_query($sql); if ($res && mysql_numrows($res) > 0) { $ar = mysql_fetch_assoc($res); -- cgit v1.2.1