<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */

function block_pagerank_stat($params) {
  global $dbConn;
  
  if (!$params['template']) {
    $params['template'] = 'block.pagerank_stat.html';
  }

  $tpl = new Template;

  $minimum_pr = 5;
  if (isset($params['minimum_pr'])) {
    $minimum_pr = $params['minimum_pr'];
  }

  $query = "select rank, count(rank) as total
            from idx_pagerank
            where rank >= '$minimum_pr'
            group by rank
            having total > 0
            order by rank desc";
  $result = $dbConn->Execute($query);
  while ($row = $result->FetchRow()) {
    $pageranks[] = $row;
  }
  $tpl->assign("pageranks", $pageranks);
  $tpl->display("blocks/" . $params['template']);
}

?>