cvs: docweb /scripts notes_stats.php notes_stats_output.php /www .cvsignore notes_stats.php

[email protected] ("Nuno Lopes")
Newsgroups php.doc.web
Message-ID <cvsnlopess1107516036@cvsserver>
nlopess		Fri Feb  4 06:20:36 2005 EDT

  Added files:                 
    /docweb/scripts	notes_stats_output.php 

  Removed files:               
    /docweb/www	notes_stats.php 

  Modified files:              
    /docweb/scripts	notes_stats.php 
    /docweb/www	.cvsignore 
  Log:
  generate the ouput of the notes stats in the cron job
  
http://cvs.php.net/diff.php/docweb/scripts/notes_stats.php?r1=1.4&r2=1.5&ty=u
Index: docweb/scripts/notes_stats.php
diff -u docweb/scripts/notes_stats.php:1.4 docweb/scripts/notes_stats.php:1.5
--- docweb/scripts/notes_stats.php:1.4	Fri Feb  4 06:05:58 2005
+++ docweb/scripts/notes_stats.php	Fri Feb  4 06:20:36 2005
@@ -17,7 +17,7 @@
 |          Vincent Gevers <[email protected]>                            |
 | Credits: Sean Coates <[email protected]>                                  |
 +----------------------------------------------------------------------+
-$Id: notes_stats.php,v 1.4 2005/02/04 11:05:58 nlopess Exp $
+$Id: notes_stats.php,v 1.5 2005/02/04 11:20:36 nlopess Exp $
 */
 
 require_once '../build-ops.php';
@@ -92,6 +92,18 @@
 sqlite_close($sqlite);
 
 
+/* write the output to the /www folder */
+ob_start();
+include './notes_stats_output.php';
+$output = ob_get_clean();
+
+$fp = fopen(PATH_ROOT . '/www/notes_stats.php', 'w');
+fputs($fp, $output);
+fclose($fp);
+
+/* end of the script */
+
+
 
 /* Open a connection to a NTTP server */
 function nntp_connect($server, $port = 119) {
http://cvs.php.net/diff.php/docweb/www/.cvsignore?r1=1.8&r2=1.9&ty=u
Index: docweb/www/.cvsignore
diff -u docweb/www/.cvsignore:1.8 docweb/www/.cvsignore:1.9
--- docweb/www/.cvsignore:1.8	Sat Jan 22 02:03:44 2005
+++ docweb/www/.cvsignore	Fri Feb  4 06:20:36 2005
@@ -1,2 +1,3 @@
 robots.txt
 orphan_notes.php
+notes_stats.php

http://cvs.php.net/co.php/docweb/scripts/notes_stats_output.php?r=1.1&p=1
Index: docweb/scripts/notes_stats_output.php
+++ docweb/scripts/notes_stats_output.php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
+----------------------------------------------------------------------+
| PHP Documentation Site Source Code                                   |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2005 The PHP Group                                |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license,       |
| that is bundled with this package in the file LICENSE, and is        |
| available at through the world-wide-web at                           |
| http://www.php.net/license/3_0.txt.                                  |
| If you did not receive a copy of the PHP license and are unable to   |
| obtain it through the world-wide-web, please send a note to          |
| [email protected] so we can mail you a copy immediately.               |
+----------------------------------------------------------------------+
| Authors: Vincent Gevers <[email protected]>                            |
+----------------------------------------------------------------------+
$Id: notes_stats_output.php,v 1.1 2005/02/04 11:20:36 nlopess Exp $
*/

echo "<?php require_once '../include/init.inc.php';";

$minact = 100;

$DBFile = SQLITE_DIR.'notes_stats.sqlite';

if (@filesize($DBFile) < 10) {
    echo site_header('Statistics not available');
    echo '<h2>Statistics not available</h2>';
    echo site_footer();
    exit;
}

$sqlite = sqlite_open($DBFile);

$info = sqlite_fetch_array(sqlite_query($sqlite, 'SELECT * FROM info'), SQLITE_ASSOC);

if ($info['last_article'] < 50000) {
    echo site_header('Statistics not available yet');
    echo '<h2>Statistics not available yet</h2>';
    echo site_footer();
    exit;
}

echo "echo site_header('Note Statistics for " . date('j F Y', $info['build_date']) . "'); ?>";

?>
<h3><strong><?php echo $info['last_article']; ?></strong> subjects parsed</h1>

<table border='0' cellspacing="10"><tr valign="top"><td valign="top">
<table border='0'>
    <tr>
        <th colspan="5" align="center">Total Editors Stats</th>
    </tr>
    <tr>
        <th>user</th>
        <th>deleted</th>
        <th>rejected</th>
        <th>modified</th>
        <th>total</th>
    </tr>
<?php

$array = sqlite_fetch_all(sqlite_query($sqlite, 'SELECT * FROM notes'), SQLITE_ASSOC);
$time  = time() - 60*60*24*180;

foreach($array as $row) {
    @++$data[$row['who']][$row['action']];
    @++$total[$row['who']];
    @++$manual[$row['manpage']];

    if ($row['time'] >= $time) {
        @++$data_new[$row['who']][$row['action']];
        @++$data_new[$row['who']]['total'];
    }

}

unset($data['']);
ksort($data);
ksort($data_new);

$bg = '#EBEBEB';
foreach ($data as $id => $c) {

    echo "<tr bgcolor=\"";
    $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB';
    echo "$bg\">\n\t<td>".$id."</td>\n\t<td>";
    echo isset($c['deleted']) ? $c['deleted'] : '0';
    echo "</td>\n\t<td>";
    echo isset($c['rejected']) ? $c['rejected'] : '0';
    echo "</td>\n\t<td>";
    echo isset($c['modified']) ? $c['modified'] : '0';
    echo "</td>\n\t<td>";
    echo $total[$id];
    echo "</td>\n</tr>\n";
}

unset($data);

?>
</table>

</td><td valign="top">
Last half year (with more than <?php echo $minact; ?> actions counted)
<table border='0'>
    <tr>
        <th colspan="5" align="center">Recent Editors stats</th>
    </tr>
    <tr>
        <th>user</th>
        <th>deleted</th>
        <th>rejected</th>
        <th>modified</th>
        <th>total</th>
    </tr>

<?php

$bg = '#EBEBEB';
foreach ($data_new as $id => $c) {

    if($c['total'] >= $minact) {    
        echo "<tr bgcolor=\"";
        $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB';
        echo "$bg\">\n\t<td>".$id."</td>\n\t<td>";
        echo isset($c['deleted']) ? $c['deleted'] : '0';
        echo "</td>\n\t<td>";
        echo isset($c['rejected']) ? $c['rejected'] : '0';
        echo "</td>\n\t<td>";
        echo isset($c['modified']) ? $c['modified'] : '0';
        echo "</td>\n\t<td>";
        echo $c['total'];
        echo "</td>\n</tr>\n";
    }

}

unset($data_new);

?>
</table>
</td><td valign="top">
<table border='0'>
    <tr>
        <th colspan="3" align="center">Editors top 15</th>
    </tr>
    <tr>
        <th>rank</th>
        <th>user</th>
        <th>total</th>
    </tr>
<?php
arsort($total);

$i = 0;
foreach($total as $id => $val) {
       
    ++$i;
    echo "<tr bgcolor=\"";
    $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB'; 
    echo "$bg\">\n\t".
    "<td>".$i."</td>\n\t".
    "<td>".$id."</td>\n\t".
    "<td>".$val."</td>\n".
    "</tr>\n";
    
    if ($i == 15)
        break;
}       

unset($total);
?>
</table>

<br />
<table border='0'>
    <tr>
        <th colspan="3" align="center">Manual pages most active top 20</th>
    </tr>
    <tr>
        <th>rank</th>
        <th>page</th>
        <th>total</th>
    </tr>
<?php
arsort($manual);

$i = 0;
foreach($manual as $id => $c) {
       
    ++$i;
    echo "<tr bgcolor=\"";
    $bg = ($bg == '#EBEBEB') ? '#BEBEBE' : '#EBEBEB'; 
    echo "$bg\">\n\t".
    "<td>".$i."</td>\n\t".
    "<td>".$id."</td>\n\t".
    "<td>".$c."</td>\n".
    "</tr>\n";
    
    if ($i == 20)
        break;
}       

?>
</table>

</td></tr></table>
<?php

echo 'Last updated ' . date('r', $info['build_date']) . "\n";

sqlite_close($sqlite);
echo '<?php echo site_footer(); ?>';

?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.