差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
dokuwiki:pageviewranking [2006/11/15] admindokuwiki:pageviewranking [不明な日付] (現在) – 外部編集 (不明な日付) 127.0.0.1
行 1: 行 1:
 +====== 記事アクセスランキング ======
 +monobookプラグインで、PageViewCountでカウントしたデータに基づいて、アクセスランキングを表示。
 +  * ファイルが存在しないものはランキングから外します。
 +  * アクセス権がないものもランキングから外します。
  
 +  - lib/tpl/monobook/do_ranking.phpを作成。<code php>
 +<div class="page"><h1>アクセスランキング</h1>
 +<table class="inline">
 +<tr><th>#</th><th>タイトル</th><th>閲覧数</th></tr>
 +<?php
 +if ($numOfPosts == 0) {$numOfPosts = 100;}
 +global $ID;
 +$pvc_server=$conf['auth']['mysql']['server'];
 +$pvc_user=$conf['auth']['mysql']['user'];
 +$pvc_password=$conf['auth']['mysql']['password'];
 +$pvc_database=$conf['auth']['mysql']['database'];
 +$pvc_table="pageview";
 +$pvc_ip = $_SERVER['REMOTE_ADDR'];
 +
 +$con = @mysql_connect ($pvc_server, $pvc_user, $pvc_password);
 +if ($con) {
 +  $res=mysql_select_db($pvc_database, $con);
 +  if ($res) {
 +    $query = "SELECT id, views FROM $pvc_table ORDER by views DESC LIMIT 0,".$numOfPosts;
 +    $res = @mysql_query($query, $con);
 +    $num = 1;
 +    while($row = mysql_fetch_object($res)) {
 +      $itemid = $row->id;
 +      if (!$itemid) {continue;}
 +      if (isHiddenPage($itemid) || auth_quickaclcheck($itemid) < AUTH_READ) {continue;}
 +      if (!file_exists(wikiFN($itemid))) {@mysql_query("DELETE FROM $pvc_table WHERE id='$itemid'");continue;}
 +      $views = $row->views;
 +      $permanent = DOKU_URL.$itemid;
 +      print '<tr><td class="rightalign">'.$num.'</td><td><a href="'. $permanent.'">';
 +      tpl_pagetitle($itemid,$ret);
 +      print '</a></td><td class="rightalign">'.$views."</td></tr>\n";
 +      $num++;
 +    }
 +  }
 +}
 +?>
 +</table>
 +</div>
 +</code>※UTF-8で保存。
 +  - lib/tpl/monobook/main.phpにリンクを追加。<code php>
 + else if ($_REQUEST['mbdo'] == 'media')
 + @include(dirname(__FILE__).'/do_media.php');
 +</code>の後ろに<code php>
 + else if ($_REQUEST['mbdo'] == 'ranking')
 + @include(dirname(__FILE__).'/do_ranking.php');
 +</code>を追加。
 +  - lib/tpl/monobook/user/pref.phpにツールボックスの項目を追加<code php>
 +    $monobook['toolbox']['ranking']['href'] = DOKU_BASE."doku.php?mbdo=ranking";
 +    $monobook['toolbox']['ranking']['text'] = 'アクセスランキング';
 +    $monobook['toolbox']['ranking']['rel'] = "nofollow";
 +</code>※UTF-8で保存。