1#!/usr/local/bin/php -q
2<?php
3
4mysql_connect("localhost","nobody","")
5  or die("unable to connect to server");
6mysql_select_db("phpmasterdb")
7  or die("unable to select database");
8
9$query = "SELECT COUNT(*) AS count,sect FROM note"
10       . " GROUP BY sect ORDER BY count DESC LIMIT 20";
11
12$res = mysql_query($query)
13  or die("query to get top 20 pages failed");
14
15$body = "Notes  |  Page\n"
16      . "-------+---------------------------------------------------------\n";
17
18$top20 = 0;
19while ($row = mysql_fetch_array($res,MYSQL_ASSOC)) {
20  $body .= sprintf("%5d  | http://php.net/manual/en/%s.php\n", $row['count'], $row['sect']);
21  $top20 += $row['count'];
22}
23
24$query = "SELECT COUNT(*) FROM note";
25
26$res = mysql_query($query)
27  or die("query to get total count of notes failed");
28
29$total = mysql_result($res,0);
30
31$body = "Following are the top 20 pages of the manual, sorted by the number\n"
32      . "of user notes contributed. These sections could use a polish, those\n"
33      . sprintf("notes represent %.1f%% of the %d total user notes.\n\n", ($top20 / $total)*100, $total)
34      . $body;
35
36mail("phpdoc@lists.php.net, php-notes@lists.php.net","Notes Status, $total total",$body,"From: phpdoc@lists.php.net", "-fnoreply@php.net");
37