\n";
/* ************** Hottest of all time *************************/
$list_length = 15;
$sql = "SELECT b.title, a.nid, b.created AS min_time, CASE WHEN a.totalcount > 0 THEN a.totalcount ELSE 1 END AS rec_cnt FROM node_counter a LEFT JOIN node b ON a.nid = b.nid ORDER BY rec_cnt DESC LIMIT $list_length";
$all_nodes = array();
$result = db_query($sql);
$i=0;
$max_time_all = 19000101;
$min_time_all = 99991231;
$max_rec_cnt_all = 0;
$min_rec_cnt_all = 999999999;
$rec_cnt_all = 0;
while ($mynode = db_fetch_object($result)) {
$i += 1;
$all_nodes[$i] = array(
'title' => $mynode->title,
'path' => ('/node/'.$mynode->nid),
'min_time' => format_date($mynode->min_time,'custom', 'Ymd')+0,
'rec_cnt' => $mynode->rec_cnt
);
$rec_cnt_all += $mynode->rec_cnt;
if ( $all_nodes[$i]['min_time'] > $max_time_all ) $max_time_all = $all_nodes[$i]['min_time'];
if ( $all_nodes[$i]['min_time'] < $min_time_all ) $min_time_all = $all_nodes[$i]['min_time'];
if ( $all_nodes[$i]['rec_cnt'] > $max_rec_cnt_all ) $max_rec_cnt_all = $all_nodes[$i]['rec_cnt'];
if ( $all_nodes[$i]['rec_cnt'] < $min_rec_cnt_all ) $min_rec_cnt_all = $all_nodes[$i]['rec_cnt'];
}
$a_x = 0; $a_y = 0;
$d_x = 500; $d_y = 500;
$ratio = 0.4;
//$output .= " rec_cnt_all = $rec_cnt_all \n";
//$output .= " max_time_all = $max_time_all \n";
//$output .= " min_time_all = $min_time_all \n";
//$output .= " max_rec_cnt_all = $max_rec_cnt_all \n";
//$output .= " min_rec_cnt_all = $min_rec_cnt_all \n";
$output .= "
\n";
$sum_rec_cnt = 0;
$myitems = array();
$i=1;
foreach ($all_nodes as $mynode) {
$myitems[$i] = $mynode;
$i += 1;
$sum_rec_cnt += $mynode['rec_cnt'];
if ( ($sum_rec_cnt+$mynode['rec_cnt'])/$rec_cnt_all > $ratio ) {
if ( $d_y-$a_y <= $d_x-$a_x ) {
// drawing area
$width = round( ($sum_rec_cnt/$rec_cnt_all) * ($d_x-$a_x) );
$pos=$a_y;
foreach($myitems as $node) {
$output .= "
\n";
$pos += round(($node['rec_cnt']/$sum_rec_cnt)*($d_y-$a_y));
}
// set the target area
$a_x += $width;
}
else {
// drawing area
$width = round( ($sum_rec_cnt/$rec_cnt_all) * ($d_y-$a_y) );
$pos=$a_x;
foreach($myitems as $node) {
$output .= "
\n";
$pos += round(($node['rec_cnt']/$sum_rec_cnt)*($d_x-$a_x));
}
// set the target area
$a_y += $width;
}
// reset algorithm
$i = 1;
$rec_cnt_all -= $sum_rec_cnt;
$sum_rec_cnt = 0;
unset($myitems);
$myitems = array();
}
}
$output .= "
\n";
/* ************** Hottest of today *************************/
$list_length = 15;
$sql = "SELECT b.title, a.nid, b.created AS min_time, CASE WHEN a.daycount > 0 THEN a.daycount ELSE 1 END AS rec_cnt FROM node_counter a LEFT JOIN node b ON a.nid = b.nid ORDER BY rec_cnt DESC LIMIT $list_length";
$all_nodes = array();
$result = db_query($sql);
$i=0;
$max_time_all = 19000101;
$min_time_all = 99991231;
$max_rec_cnt_all = 0;
$min_rec_cnt_all = 999999999;
$rec_cnt_all = 0;
while ($mynode = db_fetch_object($result)) {
$i += 1;
$all_nodes[$i] = array(
'title' => $mynode->title,
'path' => ('/node/'.$mynode->nid),
'min_time' => format_date($mynode->min_time,'custom', 'Ymd')+0,
'rec_cnt' => $mynode->rec_cnt
);
$rec_cnt_all += $mynode->rec_cnt;
if ( $all_nodes[$i]['min_time'] > $max_time_all ) $max_time_all = $all_nodes[$i]['min_time'];
if ( $all_nodes[$i]['min_time'] < $min_time_all ) $min_time_all = $all_nodes[$i]['min_time'];
if ( $all_nodes[$i]['rec_cnt'] > $max_rec_cnt_all ) $max_rec_cnt_all = $all_nodes[$i]['rec_cnt'];
if ( $all_nodes[$i]['rec_cnt'] < $min_rec_cnt_all ) $min_rec_cnt_all = $all_nodes[$i]['rec_cnt'];
}
$a_x = 0; $a_y = 0;
$d_x = 500; $d_y = 500;
$ratio = 0.4;
//$output .= " rec_cnt_all = $rec_cnt_all \n";
//$output .= " max_time_all = $max_time_all \n";
//$output .= " min_time_all = $min_time_all \n";
//$output .= " max_rec_cnt_all = $max_rec_cnt_all \n";
//$output .= " min_rec_cnt_all = $min_rec_cnt_all \n";
$output .= "
\n";
$sum_rec_cnt = 0;
$myitems = array();
$i=1;
foreach ($all_nodes as $mynode) {
$myitems[$i] = $mynode;
$i += 1;
$sum_rec_cnt += $mynode['rec_cnt'];
if ( ($sum_rec_cnt+$mynode['rec_cnt'])/$rec_cnt_all > $ratio ) {
if ( $d_y-$a_y <= $d_x-$a_x ) {
// drawing area
$width = round( ($sum_rec_cnt/$rec_cnt_all) * ($d_x-$a_x) );
$pos=$a_y;
foreach($myitems as $node) {
$output .= "
\n";
$pos += round(($node['rec_cnt']/$sum_rec_cnt)*($d_y-$a_y));
}
// set the target area
$a_x += $width;
}
else {
// drawing area
$width = round( ($sum_rec_cnt/$rec_cnt_all) * ($d_y-$a_y) );
$pos=$a_x;
foreach($myitems as $node) {
$output .= "
\n";
$pos += round(($node['rec_cnt']/$sum_rec_cnt)*($d_x-$a_x));
}
// set the target area
$a_y += $width;
}
// reset algorithm
$i = 1;
$rec_cnt_all -= $sum_rec_cnt;
$sum_rec_cnt = 0;
unset($myitems);
$myitems = array();
}
}
$output .= "
\n";
/* ************** Hottest of last week *************************/
$list_length = 15;
$sql = "SELECT title, path, MAX(timestamp) AS min_time, COUNT(*) AS rec_cnt FROM accesslog WHERE path LIKE '%book/%' OR path LIKE '%node/%' OR path LIKE '%image/%' GROUP BY title, path ORDER BY rec_cnt DESC LIMIT $list_length";
$all_nodes = array();
$result = db_query($sql);
$i=0;
$max_time_all = 19000101;
$min_time_all = 99991231;
$max_rec_cnt_all = 0;
$min_rec_cnt_all = 999999999;
$rec_cnt_all = 0;
while ($mynode = db_fetch_object($result)) {
$i += 1;
$all_nodes[$i] = array(
'title' => $mynode->title,
'path' => $mynode->path,
'min_time' => format_date($mynode->min_time,'custom', 'Ymd')+0,
'rec_cnt' => $mynode->rec_cnt
);
$rec_cnt_all += $mynode->rec_cnt;
if ( $all_nodes[$i]['min_time'] > $max_time_all ) $max_time_all = $all_nodes[$i]['min_time'];
if ( $all_nodes[$i]['min_time'] < $min_time_all ) $min_time_all = $all_nodes[$i]['min_time'];
if ( $all_nodes[$i]['rec_cnt'] > $max_rec_cnt_all ) $max_rec_cnt_all = $all_nodes[$i]['rec_cnt'];
if ( $all_nodes[$i]['rec_cnt'] < $min_rec_cnt_all ) $min_rec_cnt_all = $all_nodes[$i]['rec_cnt'];
}
$a_x = 0; $a_y = 0;
$d_x = 500; $d_y = 500;
$ratio = 0.4;
//$output .= " rec_cnt_all = $rec_cnt_all \n";
//$output .= " max_time_all = $max_time_all \n";
//$output .= " min_time_all = $min_time_all \n";
//$output .= " max_rec_cnt_all = $max_rec_cnt_all \n";
//$output .= " min_rec_cnt_all = $min_rec_cnt_all \n";
$output .= "
\n";
$sum_rec_cnt = 0;
$myitems = array();
$i=1;
foreach ($all_nodes as $mynode) {
$myitems[$i] = $mynode;
$i += 1;
$sum_rec_cnt += $mynode['rec_cnt'];
if ( ($sum_rec_cnt+$mynode['rec_cnt'])/$rec_cnt_all > $ratio ) {
if ( $d_y-$a_y <= $d_x-$a_x ) {
// drawing area
$width = round( ($sum_rec_cnt/$rec_cnt_all) * ($d_x-$a_x) );
$pos=$a_y;
foreach($myitems as $node) {
$output .= "
\n";
$pos += round(($node['rec_cnt']/$sum_rec_cnt)*($d_y-$a_y));
}
// set the target area
$a_x += $width;
}
else {
// drawing area
$width = round( ($sum_rec_cnt/$rec_cnt_all) * ($d_y-$a_y) );
$pos=$a_x;
foreach($myitems as $node) {
$output .= "
\n";
$pos += round(($node['rec_cnt']/$sum_rec_cnt)*($d_x-$a_x));
}
// set the target area
$a_y += $width;
}
// reset algorithm
$i = 1;
$rec_cnt_all -= $sum_rec_cnt;
$sum_rec_cnt = 0;
unset($myitems);
$myitems = array();
}
}
$output .= "
\n";
/* ******* end of container ************ */
$output .= "