codes****@googl*****
codes****@googl*****
2008年 9月 9日 (火) 23:37:03 JST
Author: mystralkk Date: Tue Sep 9 07:30:07 2008 New Revision: 457 Added: trunk/plugins/dataproxy/ trunk/plugins/dataproxy/INSTALL trunk/plugins/dataproxy/INSTALL_ja trunk/plugins/dataproxy/admin/ trunk/plugins/dataproxy/admin/dataproxy_api_ja.html (contents, props changed) trunk/plugins/dataproxy/admin/images/ trunk/plugins/dataproxy/admin/images/Thumbs.db (contents, props changed) trunk/plugins/dataproxy/admin/images/dataproxy.gif (contents, props changed) trunk/plugins/dataproxy/admin/index.php (contents, props changed) trunk/plugins/dataproxy/admin/install.html (contents, props changed) trunk/plugins/dataproxy/admin/install.php (contents, props changed) trunk/plugins/dataproxy/admin/install_ja.html (contents, props changed) trunk/plugins/dataproxy/config.php (contents, props changed) trunk/plugins/dataproxy/dataproxy.php (contents, props changed) trunk/plugins/dataproxy/drivers/ trunk/plugins/dataproxy/drivers/article.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/calendar.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/comments.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/dokuwiki.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/faqman.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/filemgmt.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/forum.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/links.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/mediagallery.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/polls.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/staticpages.class.php (contents, props changed) trunk/plugins/dataproxy/drivers/trackback.class.php (contents, props changed) trunk/plugins/dataproxy/functions.inc (contents, props changed) trunk/plugins/dataproxy/language/ trunk/plugins/dataproxy/language/english.php (contents, props changed) trunk/plugins/dataproxy/language/english_utf-8.php (contents, props changed) trunk/plugins/dataproxy/language/japanese.php (contents, props changed) trunk/plugins/dataproxy/language/japanese_utf-8.php (contents, props changed) trunk/plugins/dataproxy/templates/ trunk/plugins/dataproxy/templates/admin.thtml (contents, props changed) Log: dataproxyプラグイン-1.1.0をコミット。 Added: trunk/plugins/dataproxy/INSTALL ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/INSTALL Tue Sep 9 07:30:07 2008 @@ -0,0 +1 @@ +See admin/install.html for installation. Added: trunk/plugins/dataproxy/INSTALL_ja ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/INSTALL_ja Tue Sep 9 07:30:07 2008 @@ -0,0 +1 @@ +admin/install_ja.htmlをご覧ください。 Added: trunk/plugins/dataproxy/admin/dataproxy_api_ja.html ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/admin/dataproxy_api_ja.html Tue Sep 9 07:30:07 2008 @@ -0,0 +1,264 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html lang="ja"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title>Geeklog DataproxyプラグインのAPI</title> + <style type="text/css"> + <!--> + body { + color: black; + background-color: white; + line-height: 1.5em; + width: 780px; + margin: 10px auto 10px; + } + .caution { + padding: 10px; + font-weight: bold; + border: solid 1px black; + color: black; + background-color: yellow; + } + .code { + padding: 10px; + border: solid 1px black; + background-color: #ccffff; + } + table { + border: solid 1px black; + border-collapse: collapse; + padding: 3px; + } + th { + border: solid 1px black; + text-align: center; + } + td { + border: solid 1px black; + padding: 3px; + } + <! --> + </style> +</head> + +<body> + <h1>Geeklog Dataproxyプラグインの<acronym title="Application Program Interface">API</acronym></h1> + <table> + <tr> + <th>制作者</th> + <td>mystral-kk - geeklog AT mystral-kk DOT net</td> + </tr> + <tr> + <th>バージョン</th> + <td>1.0.3</td> + </tr> + <tr> + <th>公開日</th> + <td>2007-12-26</td> + </tr> + </table> + + <h2>1. 概要</h2> + <p>Dataproxyプラグインは,Geeklogのコンテンツ取得代行・キャッシュ管理を行 うプラグインです(<strong>バージョン1.0では,キャッシュ管理機能は実装されて いません</strong>)。通常,各プラグインが管理するデータを取得するには,それ ぞれSQLを組み立て,権限チェックを追加するなどの手順を踏む必要があります が,Dataproxyプラグインを使用すれば,簡単な手順と統一されたインターフェース でコンテンツを取り出すことができます。</p> + + <p class="caution">ご注意:Dataproxyプラグインはまだ開発初期の段階のた め,下記のAPIは変更される可能性があります。</p> + + <h2><a name="datasource"></a>2. データソース・カテゴリ・アイテム</h2> + <p>Dataproxyプラグインでは,コンテンツを提供する機能・プラグインを <strong>データソース</strong>として位置づけています。現時点でサポートされて いるデータソースは次の通りです。article, comments, trackbackは常に利用できま す。</p> + <ul> + <li>article(記事)</li> + <li>comments(コメント)</li> + <li>trackback(トラックバック)</li> + <li>staticpages(静的ページプラグイン)</li> + <li>calendar(カレンダプラグイン)</li> + <li>links(リンクプラグイン)</li> + <li>polls(アンケートプラグイン)</li> + <li>dokuwiki(DokuWikiプラグイン)</li> + <li>forum(掲示板プラグイン)</li> + <li>filemgmt(ファイル管理プラグイン)</li> + <li>faqman(FAQプラグイン)</li> + <li>mediagallery(メディアギャラリプラグイン)</li> + </ul> + + <p>また,各データソースは階層的な<strong>カテゴリ</strong>を持っています (staticpagesなどにはありません)。各階層にある具体的なコンテンツを <strong>アイテム</strong>と呼びます。</p> + + <h2>3. Dataproxyプラグインの利用法</h2> + <p>Dataproxyプラグインがインストールされ,有効になっていれば,次の1行を記 述するだけでDataproxyプラグインが提供するAPIを利用できます。</p> + <div class="code">$dataproxy =& new Dataproxy($uid);</div> + <p>PHP5の場合は,次のコードを推奨します。</p> + <div class="code">$dataproxy = new Dataproxy($uid);</div> + <p>$uidはデータを取得するユーザのID($_USER['uid'])です。デフォルト値は 1(ゲストユーザの扱い)です。全データを取得する必要がある場合は,0を指定しま す。</p> + + <h2>4. Dataproxyクラス</h2> + + <p>Dataproxyクラスは実際にデータを取得するDataproxyDriverクラスの生成・管 理を担当します。現在有効になっているプラグインを認識し,必要な DataproxyDriverクラスのインスタンスを作成します。</p> + + <h3>4.1 Dataproxyクラス - 公開メソッド</h3> + <div class="code">setUid($uid)</div> + <p>Dataproxyプラグインを使用するユーザIDをセットします。ユーザIDは Dataproxyクラスのインスタンスを作成するときに指定するので,ふつう,このメソ ッドを呼び出す必要はありません。</p> + + <div class="code">getUid()</div> + <p>Dataproxyプラグインを使用しているユーザのIDを返します。</p> + + <div class="code">setEncoding($encoding)</div> + <p>Dataproxyプラグインの内部エンコーディングを指定します。内部エンコーディ ングはDataproxyクラスのインスタンスを作成するときに指定するので,ふつう,こ のメソッドを呼び出す必要はありません。</p> + + <div class="code">getEncoding()</div> + <p>Dataproxyプラグインの内部エンコーディングを返します。</p> + + <div class="code">setOptions($options)</div> + <p>Dataproxyプラグインに与えるオプションを連想配列の形式で指定します。オプ ションはDataproxyクラスのインスタンスを作成するときに指定するので,ふつ う,このメソッドを呼び出す必要はありません。</p> + + <div class="code">getOptions()</div> + <p>Dataproxyプラグインに与えられているオプションを連想配列の形式で返しま す。</p> + + <div class="code">getAllSupportedDriverNames()</div> + <p>Dataproxyプラグインでサポートされている<a href="#datasource">データソー ス</a>名の配列を返します。</p> + + <div class="code">getAllDriverNames()</div> + <p>Dataproxyプラグインで現在有効になっているデータソース名の配列を返しま す。サポートされている<a href="#datasource">データソース</a>については,上記 をご覧ください。</p> + + <div class="code">escape($str)</div> + <p>文字列をHTMLとして出力できるようエスケープします。</p> + + <h3>4.2 Dataproxyクラス - 公開メンバー</h3> + <p>以下のメンバーは,データソースオブジェクト(:DataproxyDriverクラス)へ のリファレンスになっています。 + <ul> + <li>article</li> + <li>comments</li> + <li>trackback</li> + <li>staticpages</li> + <li>calendar</li> + <li>links</li> + <li>polls</li> + <li>dokuwiki</li> + <li>forum</li> + <li>filemgmt</li> + <li>faqman</li> + <li>mediagallery</li> + </ul> + + <h2>5. DataproxyDriverクラス</h2> + + <p>DataproxyDriverクラスは各コンテンツのデータ・メタデータを実際に取り出す データソースドライバの親クラスです。Dataproxyクラスが管理しますので,ユーザ がデータソースドライバをインスタンス化する必要はありません。</p> + + <h3>5.1 DataproxyDriverクラス - 公開メソッド</h3> + <div class="code">getDriverName()</div> + <p>データソースドライバ名を返します。</p> + + <div class="code">getAllSupportedDriverNames()</div> + <p>Dataproxyプラグインでサポートされている<a href="#datasource">データソー ス</a>名の配列を返します。サポートされているデータソースに関しては上記をご覧 ください。</p> + + <div class="code">getAllDriverNames()</div> + <p>Dataproxyプラグインで現在有効になっているデータソース名の配列を返しま す。</p> + + <div class="code">getEntryPoint()</div> + <p>各プラグインのユーザに見えるトップページのURIを返します。staticpagesプ ラグインなどのようにトップページがない場合は,falseを返します。</p> + + <div class="code">getChildCategories($pid = false, $all_langs = false)</div> + <p>親カテゴリ$pidの下にあるすべての子カテゴリのメタデータを配列で返しま す。配列の要素は以下のようになっています。ルートカテゴリの場合は,$pidに falseを指定して呼び出します。多言語機能を有効にしたサイトで$all_langsに trueを指定すると,カレントユーザの言語IDを無視します。Googleサイトマップなど を作成する場合に有効です。</p> + <ul> + <li>id - カテゴリID(string)</li> + <li>pid - 親カテゴリのID(string)</li> + <li>title - カテゴリのタイトル(string)</li> + <li>uri - カテゴリのURI(string)</li> + <li>date - カテゴリの作成(更新)日(int: Unix timestamp, ない場合は false)</li> + <li>image_uri - カテゴリの画像のURI(string, ない場合はfalse)</li> + </ul> + + <div class="code">getAllCategories($all_langs = false)</div> + <p>データソースが持つすべてのカテゴリのメタデータを配列で返します。配列の 要素は,getChildCategories()と同じです。多言語機能を有効にしたサイトで $all_langsにtrueを指定すると,カレントユーザの言語IDを無視します。Googleサイ トマップなどを作成する場合に有効です。</p> + + <div class="code">getItems($category, $all_langs = false)</div> + <p>親カテゴリ$pidの下にあるすべてのアイテムのメタデータを配列で返します。 配列の要素は以下のようになっています。ルートカテゴリの場合は,$pidにfalseを 指定して呼び出します。多言語機能を有効にしたサイトで$all_langsにtrueを指定す ると,カレントユーザの言語IDを無視します。Googleサイトマップなどを作成する場 合に有効です。</p> + <ul> + <li>id - アイテムID(string)</li> + <li>pid - 親カテゴリのID(string)</li> + <li>title - アイテムのタイトル(string)</li> + <li>uri - アイテムのURI(string)</li> + <li>date - アイテムの作成(更新)日(int: Unix timestamp, ない場合は false)</li> + <li>image_uri - アイテムの画像のURI(string, ない場合はfalse)</li> + </ul> + + <div class="code">getItemById($id, $all_langs = false)</div> + <p>$idで指定されたIDを持つアイテム1個分のメタデータと生データを配列で返し ます。配列の要素は以下のようになっています。</p> + <ul> + <li>id - アイテムID(string)</li> + <li>pid - 親カテゴリのID(string)</li> + <li>title - アイテムのタイトル(string)</li> + <li>uri - アイテムのURI(string)</li> + <li>date - アイテムの作成(更新)日(int: Unix timestamp, ない場合は false)</li> + <li>image_uri - カテゴリの画像のURI(string, ない場合はfalse)</li> + <li>raw_data - データベースから取り出した生のデータ(ただ し,stripslashes()は適用済み)</li> + </ul> + + <div class="code">getAllItems($all_langs = false)</div> + <p>データソースが持つすべてのアイテムのメタデータを配列で返します。配列の 要素は,getItems()と同じです。多言語機能を有効にしたサイトで$all_langsに trueを指定すると,カレントユーザの言語IDを無視します。Googleサイトマップなど を作成する場合に有効です。</p> + + <div class="code">escape($str)</div> + <p>文字列をHTMLとして出力できるようエスケープします。</p> + + <div class="code">toUtf8($str)</div> + <p>$strをUTF-8に変換します。</p> + + <div class="code">cleanUrl($url)</div> + <p>与えられたURIから<acronym title="Cross Site Scripting">XSS</acronym>の 可能性のあるコードを取り除きます。</p> + + <h2>6. Dataproxyプラグイン利用のコーディング例</h2> + <p>例1. 記事のメタデータを全て(カレントユーザの言語のみ)取り出す</p> + <div class="code"> + $dataproxy =& new Dataproxy;<br> + $item_metadata = $dataproxy->article->getAllItems(); + </div> + + <p>例1. 記事のメタデータを全て(すべての言語)取り出す。</p> + <div class="code"> + $dataproxy =& new Dataproxy;<br> + $item_metadata = $dataproxy->article->getAllItems(true); + </div> + + <p>例2. 静的ページのメタデータを全て取り出す</p> + <div class="code"> + $dataproxy =& new Dataproxy;<br> + $item_metadata = $dataproxy->staticpages->getAllItems(); + </div> + + <p>例3. 'foo'カテゴリの記事のメタデータを全て取り出す</p> + <div class="code"> + $dataproxy =& new Dataproxy;<br> + $item_metadata = $dataproxy->article->getItems('foo'); + </div> + + <p>例4. 記事IDが'bar'の記事のデータを取り出す</p> + <div class="code"> + $dataproxy =& new Dataproxy;<br> + $item = $dataproxy->article->getItem('bar'); + </div> + + <p>例5. 全データソースのアイテムのメタデータを全て取り出す</p> + <div class="code"> + $items = array ();<br> + $dataproxy =& new Dataproxy;<br> + $drivers = $dataproxy->getAllDriverNames();<br> + <br> + foreach ($drivers as $driver) {<br> + $items[] = $dataproxy->$driver->getAllItems();<br> + } + </div> + + <h2>7. APIの変更履歴</h2> + <table> + <tr> + <th width="100">バージョン</th><th>公開日</th><th>変更点</th> + </tr> + <tr> + <td style="text-align: center;">1.0.0</td><td>2007-11-04</td><td>初期 バージョン</td> + </tr> + <tr> + <td style="text-align: center;">1.0.3</td><td>2007-12-26</td><td>getChildCategories(), getAllCategories(), getAllCategoriesAsLinks(), getItemById(), getItems(), getItemsAsLinks), getAllItems()で,$all_langsパラメータ(オプション)を追加 した。</td> + </tr> + </table> + +</body> +</html> Added: trunk/plugins/dataproxy/admin/images/Thumbs.db ============================================================================== Binary file. No diff available. Added: trunk/plugins/dataproxy/admin/images/dataproxy.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/dataproxy/admin/index.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/admin/index.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,75 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | public_html/admin/plugins/dataproxy/index.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +require_once '../../../lib-common.php'; + +/** +* Only let admin users access this page +*/ +if (!SEC_hasRights('dataproxy.admin')) { + // Someone is trying to illegally access this page + COM_errorLog( "Someone has tried to illegally access the dataproxy Admin page. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$_SERVER['REMOTE_ADDR']}", 1 ); + $display = COM_siteHeader() + . COM_startBlock(DPXY_str('access_denied')) + . DPXY_str('access_denied_msg') + . COM_endBlock() + . COM_siteFooter(); + echo $display; + exit; +} + +/** +* Main +*/ +if (!defined('XHTML')) { + define('XHTML', ''); +} + +$display = COM_siteHeader(); +$T = new Template($_CONF['path'] . 'plugins/dataproxy/templates'); +$T->set_file('admin', 'admin.thtml'); +$T->set_var('xhtml', XHTML); +$T->set_var('site_url', $_CONF['site_url']); +$T->set_var('site_admin_url', $_CONF['site_admin_url']); + $T->set_var('icon_url', $_CONF['site_admin_url'] . '/plugins/dataproxy/images/dataproxy.gif'); +$T->set_var('header', DPXY_str('admin')); +$T->set_var('plugin', 'dataproxy'); + +// put your code here + + +$T->parse('output', 'admin'); +$display .= $T->finish($T->get_var('output')) + . COM_siteFooter(); + +echo $display; Added: trunk/plugins/dataproxy/admin/install.html ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/admin/install.html Tue Sep 9 07:30:07 2008 @@ -0,0 +1,109 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title>Install/Uninstall instruction for the Geeklog dataproxy plugin</title> + <style type="text/css"> + <!--> + body { + color: black; + background-color: white; + line-height: 1.5em; + } + .geeklog { + background-color: yellow; + } + .public { + background-color: #99ff00; + } + .admin { + background-color: aqua; + } + .fix { + color: white; + background-color: red; + font-weight: bold; + } + .new { + color: white; + background-color: green; + font-weight: bold; + } + <! --> + </style> +</head> + +<body> + <h1>Install/Uninstall instruction for the Geeklog dataproxy plugin</h1> + + <p>In the following descriptions</p> + <ul> + <li><span class="geeklog"><geeklog_dir></span> is the directory where the system config.php file resides</li> + <li><span class="public"><public_html></span> is the directory where the lib-common.php file resides</li> + <li><span class="admin"><admin></span> is the directory where the administration files reside (usually, under <span class="public"><public_html></span>)</li> + </ul> + + <h2>INSTALL:</h2> + + <ol> + <li>Back up your Geeklog Database. The dataproxy plugin adds tables to your Geeklog database. You can do this with the built in admin backup facility.</li> + <li>Uncompress the dataproxy plugin archive while in the <span class="geeklog"><geeklog_dir></span>/plugins directory. The archive will create a directory called dataproxy in the plugins directory.</li> + <li>Create the admin directory. Under your <span class="admin"><admin></span>/plugins/ directory create a directory called dataproxy.</li> + <li>Change to your <span class="geeklog"><geeklog_dir></span>/plugins/dataproxy/ directory. Copy the files in the admin directory to the <span class="admin"><admin></span>/plugins/dataproxy/ directory your created in step 3. </li> + <li>Log in to your Geeklog as a root user and run install.php in your <span class="admin"><admin></span>/plugins/dataproxy/ directory. The install page will tell you if the install was successful or not. If not, examine Geeklog system errorlog for possible problems. The dataproxy plugin should now be installed and functioning. Clicking on the dataproxy Icon will take you to the admin page.</li> + <li>Set up security. On install only the root users have access to dataproxy administration and Viewing. You can delegate control for either of these functions through the user and group editors.</li> + </ol> + + <h2>UNINSTALL:</h2> + + <ol> + <li>Run the install.php page in your <span class="admin"><admin></span>/plugins/dataproxy directory. This will remove all the data from your database.</li> + <li>Delete the two plugin directories created in the install process: <span class="geeklog"><geeklog-dir></span>/plugins/dataproxy/ and <span class="admin"><admin></span>/plugins/dataproxy/</li> + </ol> + + <h2>HISTORY</h2> + <table border="1"> + <tr> + <th>Version</th> + <th>Date</th> + <th>Description</th> + </tr> + <tr> + <td align="right">1.1.0</td> + <td>2008-08-15</td> + <td> + <span class="New">New</span> Upgraded to work well with Geeklog-1.5.0. + </td> + </tr> + <tr> + <td align="right">1.0.4</td> + <td>2008-05-22</td> + <td> + <span class="fix">Fixed</span> the wrong GET parameter in static pages when URL rewrite is off.<br> + <span class="fix">Fixed</span> to refer to $_SP_CONF['sort_by'] in deciding the order of static pages. + </td> + </tr> + <tr> + <td align="right">1.0.3</td> + <td>2007-12-26</td> + <td><span class="fix">Fixed</span> to better support multilingual stories.</td> + </tr> + <tr> + <td align="right">1.0.2</td> + <td>2007-12-25</td> + <td><span class="fix">Fixed</span> not to deal with formmail (staticpages).</td> + </tr> + <tr> + <td align="right">1.0.1</td> + <td>2007-11-10</td> + <td><span class="fix">Fixed</span> a missing bracket in drivers/mediagallery.class.php.<br></td> + </tr> + <tr> + <td align="right">1.0</td> + <td>2007-11-04</td> + <td>Initial version</td> + </tr> + </table> +</body> +</html> Added: trunk/plugins/dataproxy/admin/install.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/admin/install.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,221 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | public_html/admin/plugins/dataproxy/install.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +require_once '../../../lib-common.php'; +require_once $_CONF['path'] . 'plugins/dataproxy/config.php'; +require_once $_CONF['path'] . 'plugins/dataproxy/functions.inc'; + +$pi_name = 'dataproxy'; // Plugin name Must be 15 chars or less +$pi_version = $_DPXY_CONF['pi_version']; // Plugin Version +$gl_version = $_DPXY_CONF['gl_version']; // GL Version plugin for +$pi_url = $_DPXY_CONF['pi_url']; // Plugin Homepage + +// $NEWTABLE contains table name(s) and sql to create it(them) +// Fill it in and you are ready to go. +// Note: you must put the table names in the uninstall routine in functions.inc +// and in the $_TABLES array in config.php. +// Note: Be sure to replace table1, table2 with the actual names of your tables. +// and the table definition with the definition of your table + +$NEWTABLE = array (); +$NEWTABLE['dpxy_notify'] = "CREATE TABLE {$_TABLES['dpxy_notify']} (" + . "id int(10) NOT NULL AUTO_INCREMENT," + . "callback_name VARCHAR(30) NOT NULL DEFAULT ''," + . "type VARCHAR(255) NOT NULL DEFAULT ''," + . "KEY id(id)" + . ")"; + +/** +* Default data +*/ +$DEFVALUES = array (); + +/** +* Security Feature(s) to add +*/ +$NEWFEATURE = array (); +$NEWFEATURE['dataproxy.admin'] = 'dataproxy Admin'; + +/** +* Only let Root users access this page +*/ +if (!SEC_inGroup('Root')) { + // Someone is trying to illegally access this page + COM_errorLog("Someone has tried to illegally access the dataproxy install/uninstall page. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$_SERVER['REMOTE_ADDR']}", 1); + $display = COM_siteHeader() + . COM_startBlock(DPXY_str('access_denied')) + . DPXY_str('access_denied_msg') + . COM_endBlock() + . COM_siteFooter(); + echo $display; + exit; +} + +/** +* Puts the datastructures for this plugin into the Geeklog database +* +* Note: Corresponding uninstall routine is in functions.inc +* +* @return boolean True if successful False otherwise +*/ +function plugin_install_dataproxy() { + global $pi_name, $pi_version, $gl_version, $pi_url, $NEWTABLE, $DEFVALUES, + $NEWFEATURE, $_TABLES, $_CONF; + + COM_errorLog("Attempting to install the {$pi_name} Plugin", 1); + + // Create the Plugins Tables + + foreach ($NEWTABLE as $table => $sql) { + COM_errorLog("Creating {$table} table", 1); + DB_query($sql, 1); + if (DB_error()) { + COM_errorLog("Error Creating {$table} table", 1); + plugin_uninstall_dataproxy(); + return false; + } + COM_errorLog("Success - Created {$table} table", 1); + } + + // Insert Default Data + + foreach ($DEFVALUES as $table => $sqls) { + COM_errorLog("Inserting default data into {$table} table", 1); + + foreach ($sqls as $sql) { + DB_query($sql, 1); + if (DB_error()) { + COM_errorLog("Error inserting default data into {$table} table", 1); + plugin_uninstall_dataproxy(); + return false; + } + } + + COM_errorLog("Success - inserting data into {$table} table", 1); + } + + // Create the plugin admin security group + + COM_errorLog("Attempting to create {$pi_name} admin group", 1); + DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) " + . "VALUES ('{$pi_name} Admin', 'Users in this group can administer the {$pi_name} plugin')", 1); + if (DB_error()) { + plugin_uninstall_dataproxy(); + return false; + } + COM_errorLog('...success', 1); + $group_id = DB_insertId(); + + // Save the grp id for later uninstall + COM_errorLog('About to save group_id to vars table for use during uninstall', 1); + DB_query("INSERT INTO {$_TABLES['vars']} VALUES ('{$pi_name}_gid', '{$group_id}')", 1); + if (DB_error()) { + plugin_uninstall_dataproxy(); + return false; + } + COM_errorLog('...success', 1); + + // Add plugin Features + + foreach ($NEWFEATURE as $feature => $desc) { + COM_errorLog("Adding {$feature} feature", 1); + DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) " + . "VALUES ('{$feature}','{$desc}')", 1); + if (DB_error()) { + COM_errorLog("Failure adding {$feature} feature", 1); + plugin_uninstall_dataproxy(); + return false; + } + $feat_id = DB_insertId(); + COM_errorLog('Success', 1); + COM_errorLog("Adding {$feature} feature to admin group", 1); + DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ('{$feat_id}', '{$group_id}')"); + if (DB_error()) { + COM_errorLog("Failure adding {$feature} feature to admin group", 1); + plugin_uninstall_dataproxy(); + return false; + } + COM_errorLog("Success", 1); + } + + /** + * OK, now give Root users access to this plugin now! + * NOTE: Root group should always be 1 + */ + COM_errorLog("Attempting to give all users in Root group access to {$pi_name} admin group", 1); + DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES ('{$group_id}', NULL, 1)"); + if (DB_error()) { + plugin_uninstall_dataproxy(); + return false; + } + + // Register the plugin with Geeklog + + COM_errorLog("Registering {$pi_name} plugin with Geeklog", 1); + DB_delete($_TABLES['plugins'], 'pi_name', 'dataproxy'); + DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) " + . "VALUES ('{$pi_name}', '{$pi_version}', '{$gl_version}', '{$pi_url}', 1)"); + if (DB_error()) { + plugin_uninstall_dataproxy(); + return false; + } + + COM_errorLog("Succesfully installed the {$pi_name} Plugin!", 1); + return true; +} + +/** +* Main Function +*/ +$action = COM_applyFilter($_GET['action']); +if ($action == 'install') { + if (plugin_install_dataproxy()) { + $msg = 44; + } else { + $msg = 72; + } + // Redirects to the plugin editor + echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=' . $msg); + exit; +} else if ($action == "uninstall") { + if (plugin_uninstall_dataproxy('installed') === true) { + $msg = 45; + } else { + $msg = 73; + } + // Redirects to the plugin editor + echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=' . $msg); + exit; +} + +echo COM_refresh($_CONF['site_admin_url'] . '/plugins.php'); Added: trunk/plugins/dataproxy/admin/install_ja.html ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/admin/install_ja.html Tue Sep 9 07:30:07 2008 @@ -0,0 +1,113 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html lang="ja"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title>Geeklog dataproxy プラグインのインストール/アンインストール</title> + <style type="text/css"> + <!--> + body { + color: black; + background-color: white; + line-height: 1.5em; + } + .geeklog { + background-color: yellow; + } + .public { + background-color: #99ff00; + } + .admin { + background-color: aqua; + } + li { + padding: 5px 5px 10px 5px; + } + .fix { + color: white; + background-color: red; + font-weight: bold; + } + .new { + color: white; + background-color: green; + font-weight: bold; + } + <! --> + </style> +</head> + +<body> + <h1>Geeklog dataproxy プラグインのインストール/アンインストール</h1> + + <h2>インストール:</h2> + + <p>以下の説明で,</p> + <ul> + <li><span class="geeklog"><geeklog_dir></span>は,システムの config.php が存在するディレクトリ</li> + <li><span class="public"><public_html></span>は,lib-common.php が 存在するディレクトリ</li> + <li><span class="admin"><admin></span>は,管理者用ファイルが存在す るディレクトリ(ふつうは,<span class="public"><public_html></span>デ ィレクトリの下)</li> + </ul> + <p>を表しています。</p> + + <ol> + <li>dataproxy プラグインはテーブルを追加するので,管理者メニューの「DBの バックアップ」やphpMyAdminを使用して,事前にGeeklogのデータベースをバックア ップしておきます。</li> + <li>dataproxyプラグインのアーカイブを<span class="geeklog"><geeklog_dir></span>/pluginsディレクトリに展開します。 dataproxyという名前のディレクトリができます。</li> + <li>adminディレクトリを作ります。<span class="admin"><admin></span>/plugins/ ディレクトリの下にも dataproxyと いう名前のディレクトリを作ります。</li> + <li><span class="geeklog"><geeklog_dir></span>/plugins/dataproxy/ ディレクトリに移動します。adminディレクトリの内容を,3.で作成した <span class="admin"><admin></span>/plugins/dataproxy/ ディレクトリにコピーし ます。</li> + <li>Rootユーザーとしてログインし,プラグインエディタからインストールを実 行します。失敗した場合には,エラーログ(error.log)を調べます。この時点 で,dataproxy プラグインはインストールされ,機能しているはずです。dataproxy アイコンをクリックすると,管理機能ページへジャンプするでしょう。</li> + <li>セキュリティを設定します。インストール直後には,dataproxyプラグインの 管理権限を持っているのは,Rootユーザーだけです。ユーザーエディタやグループエ ディタを使用して,管理権限を他の人やグループに委譲することができます</li> + </ol> + + <h2>アンインストール:</h2> + + <ol> + <li>プラグインエディタから,dataproxy プラグインをアンインストールしま す。このとき,dataproxyプラグインが使用していたテーブルは破棄され,その中に 記録されていたデータも削除されます。</li> + <li>インストールの過程で作成した2つのディレクトリ(<span class="geeklog"><geeklog-dir></span>/plugins/dataproxy/ と<span class="admin"><admin></span>/plugins/dataproxy/ を削除します。</li> + </ol> + + <h2>改訂歴</h2> + <table border="1"> + <tr> + <th>バージョン</th> + <th>公開日</th> + <th>内容</th> + </tr> + <tr> + <td align="right">1.1.0</td> + <td>2008-08-15</td> + <td> + <span class="new">新規</span> Geeklog-1.5.0に対応。 + </td> + </tr> + <tr> + <td align="right">1.0.4</td> + <td>2008-05-22</td> + <td> + <span class="fix">修正</span> 静的ページでURLリライトがオフの場合のパラ メータを修正。<br> + <span class="fix">修正</span> 静的ページを表示する順序を $_SP_CONF['sort_by']を参照するように修正。 + </td> + </tr> + <tr> + <td align="right">1.0.3</td> + <td>2007-12-26</td> + <td><span class="fix">修正</span> 多言語機能の扱いを改善。。</td> + </tr> + <tr> + <td align="right">1.0.2</td> + <td>2007-12-25</td> + <td><span class="fix">修正</span> formmail(静的ページ)を処理しないよう 修正。</td> + </tr> + <tr> + <td align="right">1.0.1</td> + <td>2007-11-10</td> + <td><span class="fix">修正</span> drivers/mediagallery.class.phpのカッコ 閉じ忘れを修正。</td> + </tr> + <tr> + <td align="right">1.0</td> + <td>2007-11-04</td> + <td>初期公開バージョン。</td> + </tr> + </table> +</body> +</html> Added: trunk/plugins/dataproxy/config.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/config.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,50 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/config.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +global $_DB_table_prefix, $_TABLES; + +// set Plugin Table Prefix the Same as Geeklogs + +$_DPXY_table_prefix = $_DB_table_prefix; + +// Add to $_TABLES array the tables your plugin uses + +$_TABLES['dpxy_notify'] = $_DPXY_table_prefix . 'dpxy_notify'; + +$_DPXY_CONF = array(); + +// Plugin info + +$_DPXY_CONF['pi_version'] = '1.1.0'; // Plugin Version +$_DPXY_CONF['gl_version'] = '1.4.0'; // GL Version plugin for +$_DPXY_CONF['pi_url'] = 'http://mystral-kk.net/'; // Plugin Homepage Added: trunk/plugins/dataproxy/dataproxy.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/dataproxy.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,553 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/dataproxy.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +/** +* @class DataproxyDriver +* @description the parent class of all classes to retrieve data from plugins +*/ +class DataproxyDriver +{ + + /** + * @access private + * + */ + var $driver_name; + var $uid; + var $encoding; + var $options; + var $parent; + + /** + * Constructor + * + * @param $parent ref. to an object + * @param $uid int 0 (= Root), 1(= anon), user id + * @param $encoding string encoding of the content + * @param $options array + */ + function DataproxyDriver(&$parent, $uid = 1, $encoding = 'utf-8', + $options = array()) + { + $this->parent = $parent; + $this->_setUid($uid); + $this->_setEncoding($encoding); + $this->_setOptions($options); + } + + function getDriverName() + { + return $this->driver_name; + } + + function _setUid($uid) + { + $this->uid = $uid; + } + + function _setEncoding($encoding) + { + $this->encoding = $encoding; + } + + function _setOptions($options) + { + $this->options = $options; + } + + function getAllDriverNames() + { + return $this->parent->getAllDriverNames(); + } + + function getAllSupportedDriverNames() + { + return $this->parent->getAllSupportedDriverNames(); + } + + /** + * Returns the location of index.php of each plugin + * + * @note MUST BE OVERRIDDEN IN CHILD CLASSES WHEN THERE IS AN ENTRY POINT + * + * @return mixed uri(string) / false(no entrance) + */ + function getEntryPoint() + { + return false; + } + + /** + * Returns meta data of child categories + * + * @note MUST BE OVERRIDDEN IN CHILD CLASSES + * + * @param $pid int/string/boolean: id of the parent category. False + * means the top category (with no parent) + * @param $all_langs boolean: true = all languages, true = current language + * @return array( + * 'id' => $id (string), + * 'pid' => $pid (string: id of its parent) + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getChildCategories($pid = false, $all_langs = false) + { + return array(); + } + + /** + * @param $pid int/string/boolean: id of the parent category. False + * means the top category (with no parent) + * @param $all_langs boolean: true = all languages, true = current language + * @return array( + * 'id' => $id (string), + * 'pid' => $pid (string: id of its parent) + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function _getChildCategoriesRecursive($pid = false, $all_langs = false) + { + $retval = array(); + + $entries = $this->getChildCategories($pid, $all_langs); + if (is_array($entries) AND count($entries) > 0) { + foreach ($entries as $entry) { + $retval[] = $entry; + $retval = array_merge($retval, $this->getChildCategories($entry['id'], $all_langs)); + } + } + + return $retval; + } + + /** + * @param $all_langs boolean: true = all languages, true = current language + * @return array( + * 'id' => $id (string), + * 'pid' => $pid (string: id of its parent) + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getAllCategories($all_langs = false) + { + return $this->_getChildCategoriesRecursive(false, $all_langs); + } + + /** + * @param $all_langs boolean: true = all languages, true = current language + */ + function getAllCategoriesAsLinks($all_langs = false) + { + $retval = array(); + + $entries = $this->getAllCategories($all_langs); + if (is_array($entries) AND count($entries) > 0) { + foreach ($entries as $entry) { + $link = ''; + if ($entry['date'] !== false) { + $link .= date($this->date_format, $entry['date']); + } + $link .= '<a href="' . $entry['uri'] . '">' + . $this->escape($entry['title']) . '</a>' . LB; + $retval[] = $link; + } + } + + return $retval; + } + + /** + * Returns the info of the corresponding item + * + * @note MUST BE OVERRIDDEN IN CHILD CLASSES + * + * @param $all_langs boolean: true = all languages, true = current language + * @return array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * 'raw_data' => raw data of the item (stripslashed) + *) + */ + function getItemById($id, $all_langs = false) + { + return array(); + } + + /** + * Returns meta data of items under a given category + * + * @note MUST BE OVERRIDDEN IN CHILD CLASSES + * + * @param $all_langs boolean: true = all languages, true = current language + * + * @return array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + *) + */ + function getItems($category, $all_langs = false) + { + return array(); + } + + /** + * @param $all_langs boolean: true = all languages, true = current language + */ + function getItemsAsLinks($category = '', $all_langs = false) + { + $retval = array(); + $entries = $this->getItems($category, $all_langs); + if (is_array($entries) AND count($entries) > 0) { + foreach ($entries as $entry) { + $link = ''; + if ($entry['date'] !== false) { + $link .= date($this->options['date_format'], $entry['date']); + } + $link .= '<a href="' . $entry['uri'] . '">' + . $this->escape($entry['title']) . '</a>' . LB; + $retval[] = $link; + } + } + + return $retval; + } + + /** + * @param $all_langs boolean: true = all languages, true = current language + */ + function getAllItems($all_langs = false) + { + $retval = $this->getItems(false, $all_langs); + $cats = $this->getAllCategories($all_langs); + if (is_array($cats) AND count($cats > 0)) { + foreach ($cats as $cat) { + $retval = array_merge($retval, $this->getItems($cat['id'], $all_langs)); + } + } + + return $retval; + } + + /** + * Escapes a string for display + * + * @param $str string: a string to escape + * @return string: an escaped string + */ + function escape($str) + { + $str = html_entity_decode($str, ENT_QUOTES, $this->encoding); + return htmlentities($str, ENT_QUOTES, $this->encoding); + } + + /** + * Converts a string into UTF-8 if necessary + */ + function toUtf8($str) + { + if (strcasecmp($this->encoding, 'utf-8') != 0) { + if (function_exists('mb_convert_encoding')) { + $str = mb_convert_encoding($str, 'utf-8', $this->encoding); + } else if (function_exists('iconv')) { + $str = iconv($this->encoding, 'utf-8', $str); + } else if (strcasecmp($this->encoding, 'iso-8859-1') == 0 + AND function_exists('utf8_encode')) { + $str = utf8_encode($str); + } else { + COM_errorLog('Dataproxy: Error! No way to convert data into UTF-8.'); + } + } + + return $str; + } + + /** + * Cleans a URL + * + * @note This function removes the strings 'JavaScript:', '<script>', + * '</script>', or 'document.write' in a given URL. This might be + * a bit too strict. + */ + function cleanUrl($url) + { + /** + * Decodes HTML entities + */ + + // %dd --> chr(0xdd) + $url = preg_replace('/%([\dA-F]{2})/ie', "chr(hexdec('\\1'))", $url); + + // \xdd --> chr(0xdd) + $url = preg_replace('/\\\\x([\dA-F]{2})/ie', "chr(hexdec('\\1'))", $url); + + // \udddd --> chr(0xdddd) + $url = preg_replace('/\\\\u([\dA-F]{4})/ie', "chr(hexdec('\\1'))", $url); + + // &[lL][tT](;) --> & + $search = array('/<?/i', '/>?/i', '/"?/i', '/»?/i'); + $replace = array('<', '>', '"', "'"); + $url = preg_replace($search, $replace, $url); + + // &#\d{1,7}(;) --> d + $url = preg_replace('/&#(\d{1,7});?/e', "chr('\\1')", $url); + + // &#x[0-9a-fA-F]{1,7}(;) --> d + $url = preg_replace('/&#x([\dA-F]{1,7});?/ie', "chr(hexdec('\\1'))", $url); + + /** + * Starts cleaning + */ + + // Removes control codes + $url = preg_replace('/[\x00-\x20\x7F\xAD]/', '', $url); + + // '+' --> ' ' + $url = str_replace('+', ' ', $url); + + // Removes 'JavaScript:' + $url = preg_replace('/J\s*A\s*V\s*A\s*S\s*C\s*R\s*I\s*P\s*T\s*/i', '', $url); + + /** + * Maybe, the follwoing three functions are not necessary to sanitize + * URLs + */ + // Removes '<script>' + $url = preg_replace('/<SCRIPT[^>]*>/i', '', $url); + + // Removes '</script>' + $url = preg_replace('/<\/SCRIPT>/i', '', $url); + + // Removes 'document.write' + $url = preg_replace('/DOCUMENT\.WRITE/i', '', $url); + + return $url; + } +} + +/** +* @class Dataproxy +*/ +class Dataproxy +{ + var $uid; + var $encoding; + var $options; + + /** + * Dataproxy drivers are loaded in the following order + * + * @caution NEW DRIVERS must be added to the following list + * + */ + var $supported_drivers = array( + 'article', 'comments', 'trackback', + 'staticpages', 'calendar', 'links', 'polls', + 'dokuwiki', 'forum', 'filemgmt', 'faqman', 'mediagallery', + ); + + /** + * References to each loaded driver + */ + var $article; + var $comments; + var $trackback; + var $staticpages; + var $calendar; + var $links; + var $polls; + var $dokuwiki; + var $forum; + var $filemgmt; + var $faqman; + var $mediagallery; + + /** + * References to the loaded drivers (the same as the above, but in an array + * e.g. $drivers['article'] = the reference to the article object + */ + var $drivers = array(); + + /** + * Constructor + * + * @param $uid int 0 (= Root), 1(= anon), user id + * @param $encoding string encoding of the content + * @param $options array + */ + function Dataproxy($uid = 1, $encoding = '', $options = array()) + { + global $_CONF, $_PLUGINS, $LANG_CHARSET, $_DPXY_CONF; + + if (count($options) == 0) { + $options = $_DPXY_CONF; + } + if (empty($encoding)) { + if (isset($LANG_CHARSET)) { + $encoding = $LANG_CHARSET; + } else if (isset($_CONF['default_charset'])) { + $encoding = $_CONF['default_charset']; + } else { + $encoding = 'iso-8859-1'; + } + } + + // Initializes settings + $this->setUid($uid); + $this->setEncoding($encoding); + $this->setOptions($options); + + // Loads drivers whose driver exists and plugin is enabled + $base_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'drivers'; + $enabled_plugins = array_merge( + $_PLUGINS, array('article', 'comments', 'trackback') + ); + + foreach ($this->supported_drivers as $driver) { + $path = $base_path . DIRECTORY_SEPARATOR . $driver . '.class.php'; + clearstatcache(); + if (is_file($path) AND in_array($driver, $enabled_plugins)) { + require_once $path; + $class_name = 'Dataproxy_' . $driver; + $obj = new $class_name( + $this, $this->uid, $this->encoding, $this->options + ); + $this->$driver = $obj; + $this->drivers[$driver] = $obj; + } + } + } + + function setUid($uid) + { + $this->uid = $uid; + + if (count($this->drivers) > 0) { + foreach ($this->drivers as $driver) { + $driver->setUid($uid); + } + } + } + + function getUid() + { + return $this->uid; + } + + function setEncoding($encoding) + { + $this->encoding = $encoding; + + if (count($this->drivers) > 0) { + foreach ($this->drivers as $driver) { + $driver->setEncoding($encoding); + } + } + } + + function getEncoding() + { + return $this->encoding; + } + + function setOptions($options) + { + $this->options = $options; + + if (count($this->drivers) > 0) { + foreach ($this->drivers as $driver) { + $driver->setOptions($options); + } + } + } + + function getOptions() + { + return $this->options; + } + + +# /** +# * Returns the reference to the given driver +# */ +# function &getDriver($driver_name) { +# if (array_key_exists($driver_name, $this->drivers)) { +# return $this->drivers[$driver_name]; +# } else { +# trigger_error('Unknown driver: ' . $driver_name . '.', E_USER_ERROR); +# } +# } + + /** + * Returns an array of all loaded driver names + */ + function getAllDriverNames() + { + return array_keys($this->drivers); + } + + /** + * Returns an array of all supported driver names + */ + function getAllSupportedDriverNames() + { + return $this->supported_drivers; + } + + /** + * Escapes a string for display + * + * @param $str string: a string to escape + * @return string: an escaped string + */ + function escape($str) + { + $str = html_entity_decode($str, ENT_QUOTES, $this->encoding); + return htmlentities($str, ENT_QUOTES, $this->encoding); + } +} Added: trunk/plugins/dataproxy/drivers/article.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/article.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,203 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/article.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_article extends DataproxyDriver +{ + var $driver_name = 'article'; + + function getChildCategories($pid = false, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + if ($pid !== false) { + return $retval; + } + + $where = false; + + $sql = "SELECT tid, topic, imageurl FROM {$_TABLES['topics']} "; + if ($this->uid > 1) { + $tids = DB_getItem( + $_TABLES['userindex'], 'tids', "uid = '" . $this->uid . "'" + ); + if (!empty($tids)) { + $sql .= ($where === true) ? ' AND' : ' WHERE'; + $sql .= "(tid NOT IN ('" + . str_replace(' ', "','", addslashes($tids)) . "'))"; + $where = true; + } + } + + // Adds permission check. When uid is 0, then it means access as Root + if ($this->uid > 0) { + if ($where === true) { + $sql .= COM_getPermSQL('AND', $this->uid); + } else { + $sql .= COM_getPermSQL('WHERE', $this->uid); + } + } + + // Adds lang id. When uid is 0, then it means access as Root + if (($this->uid > 0) AND function_exists('COM_getLangSQL') + AND $all_langs === false) { + $where = (strpos($sql, 'WHERE') !== false) ? true : false; + if ($where === true) { + $sql .= COM_getLangSQL('tid', 'AND'); + } else { + $sql .= COM_getLangSQL('tid', 'WHERE'); + } + } + + if ($_CONF['sortmethod'] == 'alpha') { + $sql .= ' ORDER BY topic ASC'; + } else { + $sql .= ' ORDER BY sortnum'; + } + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + $entry['id'] = stripslashes($A['tid']); + $entry['title'] = stripslashes($A['topic']); + $entry['uri'] = $_CONF['site_url'] . '/index.php?topic=' . $entry['id']; + $entry['date'] = false; + $entry['image_uri'] = stripslashes($A['imageurl']); + $retval[] = $entry; + } + + return $retval; + } + + /** + * @param $all_langs boolean: true = all languages, true = current language + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['stories']} " + . "WHERE (sid ='" . addslashes($id) . "') " + . "AND (draft_flag = 0) AND (date <= NOW()) "; + if ($this->uid > 0) { + $sql .= COM_getTopicSql('AND', $this->uid); + $sql .= COM_getPermSql('AND', $this->uid); + if (function_exists('COM_getLangSQL') AND ($all_langs === false)) { + $sql .= COM_getLangSQL('sid', 'AND'); + } + } + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retval['id'] = $id; + $retval['title'] = $A['title']; + $retval['uri'] = COM_buildUrl( + $_CONF['site_url'] . '/article.php?story=' . $id + ); + $retval['date'] = strtotime($A['date']); + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($tid, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT sid, title, UNIX_TIMESTAMP(date) AS day " + . "FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) " + . "AND (tid = '" . addslashes($tid) . "') "; + if ($this->uid > 0) { + $sql .= COM_getTopicSql('AND', $this->uid) + . COM_getPermSql('AND', $this->uid); + if (function_exists('COM_getLangSQL') AND ($all_langs === false)) { + $sql .= COM_getLangSQL('sid', 'AND'); + } + } + $sql .= " ORDER BY date DESC"; + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + $entries = array(); + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + $entry['id'] = stripslashes($A['sid']); + $entry['title'] = stripslashes($A['title']); + $entry['uri'] = COM_buildUrl( + $_CONF['site_url'] . '/article.php?story=' + . stripslashes($A['sid']) + ); + $entry['date'] = $A['day']; + $entry['imageurl'] = false; + $retval[] = $entry; + } + + return $retval; + } +} Added: trunk/plugins/dataproxy/drivers/calendar.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/calendar.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,165 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/calendar.class..php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_calendar extends DataproxyDriver +{ + var $driver_name = 'calendar'; + + /** + * Returns the location of index.php of each plugin + */ + function getEntryPoint() { + global $_CONF; + + return $_CONF['site_url'] . '/calendar/index.php'; + } + + function getChildCategories($pid, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + if ($pid !== false) { + return $entries; + } + + $sql = "SELECT DISTINCT event_type FROM {$_TABLES['events']} " + . "ORDER BY event_type"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = stripslashes($A['event_type']); + $entry['pid'] = false; + $entry['title'] = $entry['id']; + $entry['uri'] = false; + $entry['date'] = false; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + + return $entries; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + $sql = "SELECT * " + . "FROM {$_TABLES['events']} " + . "WHERE (eid = '" . addslashes($id) . "') "; + if ($this->uid > 0) { + $sql .= COM_getPermSql('AND', $this->uid); + } + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result == 1)) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + $retval['id'] = $id; + $retval['title'] = $A['title']; + $retval['uri'] = $_CONF['site_url'] + . '/calendar/event.php?eid=' . $id; + $retval['date'] = strtotime($A['datestart']) + strtotime($A['timestart']); + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * @param $all_langs boolean: true = all languages, true = current language + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category = '', $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + $sql = "SELECT eid, title, UNIX_TIMESTAMP(datestart) AS day1, UNIX_TIMESTAMP(timestart) AS day2 " + . "FROM {$_TABLES['events']} " + . "WHERE (event_type = '" . addslashes($category) . "') "; + if ($this->uid > 0) { + $sql .= COM_getPermSql('AND', $this->uid); + } + $sql .= " ORDER BY day1 DESC, day2 DESC"; + + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = $A['eid']; + $entry['title'] = stripslashes( $A['title'] ); + $entry['uri'] = $_CONF['site_url'] . '/calendar/event.php?eid=' + . $entry['id']; + $entry['date'] = (int) $A['day1'] + (int) $A['day2']; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/comments.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/comments.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,152 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/comments.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_comments extends DataproxyDriver +{ + var $driver_name = 'comments'; + + function getChildCategories($pid = false, $all_langs = false) { + global $_CONF, $_TABLES, $LANG_SMAP; + + $entries = array(); + + if ($pid !== false) { + return $entries; + } + + $supported_drivers = $this->getAllDriverNames(); + $sql = "SELECT DISTINCT type FROM {$_TABLES['comments']} " + . "ORDER BY type"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + if (in_array(stripslashes($A['type']), $supported_drivers)) { + $entry = array(); + $entry['id'] = stripslashes($A['type']); + $entry['pid'] = false; + $entry['title'] = $entry['id']; + $entry['uri'] = false; + $entry['date'] = false; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + } + + return $entries; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['comments']} " + . "WHERE (cid = '" . addslashes($id) . "') "; + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + $retval['id'] = $id; + $retval['title'] = $A['title']; + $retval['uri'] = $_CONF['site_url'] + . '/comment.php?mode=view&cid=' . $id; + $retval['date'] = strtotime($A['date']); + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * @param $all_langs boolean: true = all languages, true = current language + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category, $all_langs = false) { + global $_CONF, $_TABLES; + + $entries = array(); + if (!in_array($category, $this->getAllDriverNames())) { + return $entries; + } + + $sql = "SELECT cid, title, UNIX_TIMESTAMP(date) AS day " + . "FROM {$_TABLES['comments']} " + . "WHERE (type = '" . addslashes($category) . "') " + . "ORDER BY day DESC"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = $A['cid']; + $entry['title'] = stripslashes($A['title']); + $entry['uri'] = $_CONF['site_url'] . '/comment.php?mode=view&cid=' + . $entry['id']; + $entry['date'] = $A['day']; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/dokuwiki.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/dokuwiki.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,167 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/dokuwiki.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_dokuwiki extends DataproxyDriver +{ + var $driver_name = 'dokuwiki'; + + /** + * Returns the location of index.php of each plugin + */ + function getEntryPoint() { + global $_CONF; + + return $_CONF['site_url'] . '/dokuwiki/doku.php'; + } + + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES, $_DW_CONF; + + $retval = array(); + + $base_path = $_CONF['path_html'] . substr($_DW_CONF['public_dir'], 1); + if (!file_exists($base_path)) { + COM_errorLog("Dataproxy: can't find DokuWiki directory."); + return $retval; + } + + require_once $base_path . 'conf/dokuwiki.php'; + $data_path = realpath($base_path . $conf['savedir'] . '/pages'); + if ($data_path === false) { + COM_errorLog("Dataproxy: can't find DokuWiki's data directory."); + return $retval; + } + + $full_path = $data_path . DIRECTORY_SEPARATOR . urlencode($id) . '.txt'; + if (is_file($full_path)) { + $retval['id'] = $id; + $retval['title'] = $id; + $retval['uri'] = $_CONF['site_url'] . $_DW_CONF['public_dir'] + . 'doku.php?id=' . urlencode($id); + clearstatcache(); + $retval['date'] = filemtime($full_path); + $retval['image_uri'] = false; + $retval['raw_data'] = @file_get_contents($full_path); + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category, $all_langs = false) + { + global $_CONF, $_TABLES, $_DW_CONF; + + // Collect all Dokuwiki entries since Dokuwiki does no access control. + $base_path = $_CONF['path_html'] . substr($_DW_CONF['public_dir'], 1); + clearstatcache(); + if (!file_exists($base_path)) { + COM_errorLog("Dataproxy: can't find DokuWiki's directory."); + return false; + } + + require_once $base_path . 'conf/dokuwiki.php'; + $data_path = realpath($base_path . $conf['savedir'] . '/pages'); + if ($data_path === false) { + COM_errorLog("Dataproxy: can't find DokuWiki's data directory."); + return $retval; + } + + $dh = @opendir($data_path); + if ($dh === false) { + return $retval; + } + + $entries = array(); + + while (($entry_name = readdir($dh)) !== false) { + $full_path = $data_path . DIRECTORY_SEPARATOR . $entry_name; + clearstatcache(); + if (is_file($full_path) + AND preg_match("/^(.*)(\.txt)$/i", $entry_name, $match)) { + $entry = array(); + + $entry['id'] = $match[1]; + $entry['title'] = urldecode($entry['id']); + switch ($conf['userewrite']) { + case 1: // URL rewrite - .htaccess + COM_errorLog('Dataproxy: dokuwiki URL rewrite rule is not defined. File: ' . __FILE__ . ' line: ' . __LINE__); + /* fall through to case 0: */ + + case 0: // URL rewrite - off + $entry['uri'] = $_CONF['site_url'] . $_DW_CONF['public_dir'] + . 'doku.php?id=' . $entry['id']; + break; + + case 2: // URL rewrite - internal + $entry['uri'] = $_CONF['site_url'] . $_DW_CONF['public_dir'] + . 'doku.php/' . $entry['id']; + break; + + default: + break; + } + + clearstatcache(); + $entry['date'] = filemtime($full_path); + $entry['image_uri'] = false; + + $entries[] = $entry; + } + } + + closedir($dh); + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/faqman.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/faqman.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,159 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/faqman.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_faqman extends DataproxyDriver +{ + var $driver_name = 'faqman'; + + /* + * Returns the location of index.php of each plugin + */ + function getEntryPoint() + { + global $_CONF; + + return $_CONF['site_url'] . '/faqman/index.php'; + } + + function getChildCategories($pid = false, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + if ($pid !== false) { + return $entries; + } + + $sql = "SELECT catID, name FROM {$_TABLES['faq_categories']} " + . "ORDER BY catID"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = $A['catID']; + $entry['pid'] = false; + $entry['title'] = stripslashes($A['name']); + $entry['uri'] = $_CONF['site_url'] . '/faqman/index.php?op=cat&c=' + . $entry['id']; + $entry['date'] = false; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + + return $entries; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['faq_topics']} " + . "WHERE (topicID = '" . addslashes($id) . "') "; + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + $retval['id'] = $id; + $retval['title'] = $A['question']; + $retval['uri'] = $_CONF['site_url'] + . '/faqman/index.php?op=view&t=' . $id; + $retval['date'] = false; + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($cid, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + $sql = "SELECT topicID, question " + . "FROM {$_TABLES['faq_topics']} " + . "WHERE (catID = '" . addslashes($cid) . "') " + . "ORDER BY topicID"; + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = stripslashes($A['topicID']); + $entry['title'] = stripslashes($A['question']); + $entry['uri'] = $_CONF['site_url'] . '/faqman/index.php?op=view&t=' + . $entry['id']; + $entry['date'] = false; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/filemgmt.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/filemgmt.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,190 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/filemgmt.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_filemgmt extends DataproxyDriver +{ + var $driver_name = 'filemgmt'; + + /* + * Returns the location of index.php of each plugin + */ + function getEntryPoint() { + global $_CONF; + + return $_CONF['site_url'] . '/filemgmt/index.php'; + } + + /** + * @param $pid int/string/boolean id of the parent category + * @param $current_groups array ids of groups the current user belongs to + * @return array( + * 'id' => $id (string), + * 'pid' => $pid (string: id of its parent) + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getChildCategories($pid = false, $all_langs = false) + { + global $_CONF, $_TABLES, $_FM_TABLES; + + $entries = array(); + + if ($pid === false) { + $pid = 0; + } + + $sql = "SELECT * FROM {$_FM_TABLES['filemgmt_cat']} " + . "WHERE (pid = '" . addslashes($pid) . "') "; + if ($this->uid > 0) { + $current_groups = SEC_getUserGroups($this->uid); + $sql .= "AND (grp_access IN (" . implode(',', $current_groups) . ")) "; + } + $sql .= "ORDER BY cid"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = (int) $A['cid']; + $entry['pid'] = (int) $A['pid']; + $entry['title'] = stripslashes($A['title']); + $entry['uri'] = $_CONF['site_url'] . '/filemgmt/viewcat.php?cid=' + . $entry['id']; + $entry['date'] = false; + $entry['image_uri'] = $A['imgurl']; + + $entries[] = $entry; + } + + return $entries; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES, $_FM_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_FM_TABLES['filemgmt_filedetail']} AS f " + . "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} AS c " + . "ON f.cid = c.cid " + . "WHERE (f.lid = '" . addslashes($id) . "') "; + if ($this->uid > 0) { + $sql .= "AND (c.grp_access IN (" + . implode(',', SEC_getUserGroups($this->uid)) . "))"; + } + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retval['id'] = $id; + $retval['title'] = $A['title']; + $retval['uri'] = $_CONF['site_url'] + . '/filemgmt/index.php?id=' . $id; + $retval['date'] = (int) $A['date']; + $retval['image_uri'] = $A['logourl']; + if (empty($retval['image_uri'])) { + $retval['image_uri'] = false; + } + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($cid, $all_langs = false) + { + global $_CONF, $_TABLES, $_FM_TABLES; + + $entries = array(); + + $sql = "SELECT lid, f.title, logourl, date " + . "FROM {$_FM_TABLES['filemgmt_filedetail']} AS f " + . "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} AS c " + . "ON f.cid = c.cid " + . "WHERE (f.cid = '" . addslashes($cid) . "') "; + if ($this->uid > 0) { + $sql .= "AND (c.grp_access IN (" + . implode(',', SEC_getUserGroups($this->uid)) . "))"; + } + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = $A['lid']; + $entry['title'] = stripslashes($A['title']); + $entry['uri'] = $_CONF['site_url'] . '/filemgmt/index.php?id=' + . $entry['id']; + $entry['date'] = $A['date']; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/forum.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/forum.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,164 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/forum.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_forum extends DataproxyDriver { + var $driver_name = 'forum'; + + /* + * Returns the location of index.php of each plugin + */ + function getEntryPoint() + { + global $_CONF; + + return $_CONF['site_url'] . '/forum/index.php'; + } + + function getChildCategories($pid = false, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + if ($pid !== false) { + return $entries; + } + + $sql = "SELECT forum_id, forum_name FROM {$_TABLES['gf_forums']} " + . "WHERE (is_hidden = '0') "; + if ($this->uid > 0) { + $current_groups = SEC_getUserGroups( $this->uid ); + $sql .= "AND (grp_id IN (" . implode(',', $current_groups) . ")) "; + } + $sql .= "ORDER BY forum_order"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = (int) $A['forum_id']; + $entry['pid'] = false; + $entry['title'] = stripslashes($A['forum_name']); + $entry['uri'] = $_CONF['site_url'] . '/forum/index.php?forum=' + . $entry['id']; + $entry['date'] = false; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + + return $entries; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['gf_topic']} " + . "WHERE (id = '" . addslashes($id) . "')"; + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retval['id'] = $id; + $retval['title'] = $A['subject']; + $retval['uri'] = $_CONF['site_url'] + . '/forum/viewtopic.php?showtopic=' . $id; + $retval['date'] = (int) $A['date']; + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($forum_id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + $sql = "SELECT id, subject, lastupdated FROM {$_TABLES['gf_topic']} " + . "WHERE (pid = 0) AND (forum = '" . addslashes($forum_id) ."') " + . "ORDER BY lastupdated DESC"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = $A['id']; + $entry['title'] = stripslashes($A['subject']); + $entry['uri'] = $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' + . $entry['id']; + $entry['date'] = $A['lastupdated']; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/links.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/links.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,237 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/links.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +/** +* Links plugin supports URL rwrite in individual links but doesn't do so in +* categories, e.g.: +* +* link (off) http://www.example.com/links/portal.php?what=link&item=geeklog.net +* (on) http://www.example.com/links/portal.php/link/geeklog.net +* category (off) http://www.example.com/links/index.php?category=geeklog-site +* (on) http://www.example.com/links/index.php?category=geeklog-site +*/ + +class Dataproxy_links extends DataproxyDriver +{ + var $driver_name = 'links'; + + /* + * Returns the location of index.php of each plugin + */ + function getEntryPoint() + { + global $_CONF; + + return $_CONF['site_url'] . '/links/index.php'; + } + + /** + * @param $pid int/string/boolean id of the parent category. False means + * the top category (with no parent) + * @return array( + * 'id' => $id (string), + * 'pid' => $pid (string: id of its parent) + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getChildCategories($pid = false, $all_langs = false) + { + global $_CONF, $_TABLES; + + if (version_compare(VERSION, '1.5.0') < 0) { + $entries = array(); + if ($pid !== false) { + return $entries; + } + + $sql = "SELECT DISTINCT category " + . "FROM {$_TABLES['links']} "; + if ($this->uid > 0) { + $sql .= COM_getPermSQL('WHERE', $this->uid); + } + $sql .= " ORDER BY category"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = stripslashes($A['category']); + $entry['pid'] = false; + $entry['title'] = $entry['id']; + $entry['uri'] = $_CONF['site_url'] . '/links/index.php?category=' + . urlencode($this->toUtf8($entry['id'])); + $entry['date'] = false; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } else { // for GL-1.5.0+ + $entries = array(); + $sql = "SELECT * " + . "FROM {$_TABLES['linkcategories']} "; + if ($pid === false) { + $pid = 'site'; + } + $sql .= "WHERE (pid = '" . addslashes($pid) . "') "; + + if ($this->uid > 0) { + $sql .= COM_getPermSQL('AND', $this->uid); + } + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + $A = array_map('stripslashes', $A); + + $entry['id'] = $A['cid']; + $entry['pid'] = $A['pid']; + $entry['title'] = $A['category']; + $entry['uri'] = $_CONF['site_url'] . '/links/index.php?category=' + . urlencode($this->toUtf8($entry['id'])); + $entry['date'] = strtotime($A['modified']); + $entry['image_uri'] = false; + $entry['raw_data'] = $A; + $entries[] = $entry; + } + return $entries; + } + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['links']} " + . "WHERE (lid ='" . addslashes($id) . "') "; + if ($this->uid > 0) { + $sql .= COM_getPermSQL('AND', $this->uid); + } + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retval['id'] = $id; + $retval['title'] = $A['title']; + $retval['uri'] = COM_buildURL( + $_CONF['site_url'] . '/links/portal.php?what=link&item=' + . urlencode($this->toUtf8($entry['id'])) + ); // GL uses urlencode() + $retval['date'] = strtotime($A['date']); + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + if (version_compare(VERSION, '1.5.0') < 0) { + $sql = "SELECT lid, title, UNIX_TIMESTAMP(date) AS date_u " + . "FROM {$_TABLES['links']} " + . "WHERE (category ='" . addslashes($category) . "') "; + } else { // for GL-1.5.0+ + $sql = "SELECT lid, title, UNIX_TIMESTAMP(date) AS date_u " + . "FROM {$_TABLES['links']} " + . "WHERE (cid ='" . addslashes($category) . "') "; + } + + if ($this->uid > 0) { + $sql .= COM_getPermSQL('AND', $this->uid); + } + $sql .= "ORDER BY date_u DESC"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + $A = array_map('stripslashes', $A); + + $entry['id'] = $A['lid']; + $entry['title'] = $A['title']; + $entry['uri'] = COM_buildURL( + $_CONF['site_url'] . '/links/portal.php?what=link&item=' + . urlencode($this->toUtf8($entry['id'])) + ); + // GL uses urlencode() + $entry['date'] = $A['date_u']; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/mediagallery.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/mediagallery.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,231 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/mediagallery.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_mediagallery extends DataproxyDriver +{ + var $driver_name = 'mediagallery'; + + function isLoginRequired() { + global $_CONF, $_TABLES, $_MG_CONF; + + static $retval = null; + + if (is_null($retval)) { + $sql = "SELECT config_value " + . "FROM {$_TABLES['mg_config']} " + . "WHERE (config_name = 'loginrequired')"; + + $result = DB_query($sql); + if (DB_error()) { + $retval = true; // just to be on the safe side + } else { + $A = DB_fetchArray($result, false); + $retval = ((int) $A['config_value'] != 0); + } + } + + return $retval; + } + + /* + * Returns the location of index.php of each plugin + */ + function getEntryPoint() + { + global $_CONF, $_MG_CONF; + + return $_MG_CONF['site_url'] . '/index.php'; + } + + /** + * @param $pid int/string/boolean id of the parent category. False means + * the top category (with no parent) + * @return array( + * 'id' => $id (string), + * 'pid' => $pid (string: id of its parent) + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getChildCategories($pid = false) + { + global $_CONF, $_TABLES, $_MG_CONF; + + $entries = array(); + + if (($this->uid == 1) AND ($this->isLoginRequired() === true)) { + return $entries; + } + + if ($pid === false) { + $pid = 0; + } + + $sql = "SELECT album_id, album_title, album_parent, last_update " + . "FROM {$_TABLES['mg_albums']} " + . "WHERE (album_parent = '" . addslashes($pid) . "') "; + + if ($this->uid > 0) { + $sql .= COM_getPermSQL('AND ', $this->uid) + . " AND (hidden = '0') "; + } + $sql .= " ORDER BY album_order"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result)) !== false) { + $entry = array(); + + $entry['id'] = $A['album_id']; + $entry['pid'] = $A['album_parent']; + $entry['title'] = stripslashes($A['album_title']); + $entry['uri'] = $_MG_CONF['site_url'] . '/album.php?aid=' + . $entry['id']; + $entry['date'] = $A['last_update']; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES, $_MG_CONF; + + $retval = array(); + + if (($this->uid == 1) AND ($this->isLoginRequired() === true)) { + return $retval; + } + + $sql = "SELECT * " + . "FROM {$_TABLES['mg_media']} " + . "WHERE (media_id ='" . addslashes($id) . "') "; + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retval['id'] = $id; + $retval['title'] = $A['media_title']; + $retval['uri'] = $_MG_CONF['site_url'] . '/media.php?s=' + . urlencode($id); + $retval['date'] = $A['media_time']; + $retval['image_uri'] = $retval['uri']; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category, $all_langs = false) + { + global $_CONF, $_TABLES, $_MG_CONF; + + $entries = array(); + + if (($this->uid == 1) AND ($this->isLoginRequired() === true)) { + return $entries; + } + + $sql = "SELECT media_id " + . "FROM {$_TABLES['mg_media_albums']} " + . "WHERE (album_id ='" . addslashes($category) . "') " + . "ORDER BY media_order"; + + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + $media_ids = array(); + + while (($A = DB_fetchArray($result, false)) !== false) { + $media_ids[] = "'" . $A['media_id'] . "'"; + } + + if (count($media_ids) == 0) { + return $entries; + } + + $sql = "SELECT media_id, media_title, media_time " + . "FROM {$_TABLES['mg_media']} " + . "WHERE (media_id IN (" . implode(',', $media_ids) . "))"; + + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + $entry['id'] = stripslashes($A['media_id']); + $entry['title'] = stripslashes($A['media_title']); + $entry['uri'] = $_MG_CONF['site_url'] . '/media.php?s=' + . urlencode($entry['id']); + $entry['date'] = $A['media_time']; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/polls.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/polls.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,130 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/polls.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_polls extends DataproxyDriver +{ + var $driver_name = 'polls'; + + /* + * Returns the location of index.php of each plugin + */ + function getEntryPoint() + { + global $_CONF; + + return $_CONF['site_url'] . '/polls/index.php'; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['pollquestions']} " + . "WHERE (qid = '" . addslashes($id) . "') "; + if ($this->uid > 0) { + $sql .= COM_getPermSQL('AND', $this->uid); + } + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retva['id'] = $id; + $retval['title'] = $A['question']; + $retval['uri'] = $_CONF['site_url'] + . '/polls/index.php?qid=' . urlencode($id) . '&aid=-1'; + $retval['date'] = strtotime($A['date']); + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + $sql = "SELECT qid, question, UNIX_TIMESTAMP(date) AS day " + . "FROM {$_TABLES['pollquestions']} "; + if ($this->uid > 0) { + $sql .= COM_getPermSQL('WHERE', $this->uid); + } + $sql .= " ORDER BY qid"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + $entry['id'] = $A['qid']; + $entry['title'] = stripslashes($A['question']); + $entry['uri'] = $_CONF['site_url'] . '/polls/index.php?qid=' + . urlencode($entry['id']) . '&aid=-1'; + $entry['date'] = $A['day']; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/staticpages.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/staticpages.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,137 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/staticpages.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_staticpages extends DataproxyDriver +{ + var $driver_name = 'staticpages'; + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['staticpage']} " + . "WHERE (sp_id = '" . addslashes($id) . "') "; + if ($this->uid > 0) { + $sql .= COM_getPermSql('AND', $this->uid); + } + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retval['id'] = $id; + $retval['title'] = $A['sp_title']; + $retval['uri'] = COM_buildURL( + $_CONF['site_url'] . '/staticpages/index.php?page=' + . rawurlencode($id) + ); + $retval['date'] = strtotime($A['sp_date']); + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * @note This function ignores static pages which are displayed in the + * center blok. + * @refer $_SP_CONF['sort_by'] + * + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category, $all_langs = false) + { + global $_CONF, $_TABLES, $_SP_CONF; + + $entries = array(); + + $sql = "SELECT sp_id, sp_title, UNIX_TIMESTAMP(sp_date) AS day " + . "FROM {$_TABLES['staticpage']} " + . "WHERE (sp_centerblock != '1') "; + if ($this->uid > 0) { + $sql .= COM_getPermSql('AND', $this->uid); + } + + if (in_array($_SP_CONF['sort_by'], array('id', 'title', 'date'))) { + $crit = $_SP_CONF['sort_by']; + } else { + $crit = 'id'; + } + $crit = 'sp_' . $crit; + $sql .= " ORDER BY " . $crit; + + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + $entry['id'] = stripslashes($A['sp_id']); + $entry['title'] = stripslashes($A['sp_title']); + $entry['uri'] = COM_buildURL( + $_CONF['site_url'] . '/staticpages/index.php?page=' + . rawurlencode($entry['id']) + ); + $entry['date'] = $A['day']; + $entry['image_uri'] = false; + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/drivers/trackback.class.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/drivers/trackback.class.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,154 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/drivers/trackback.class.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +class Dataproxy_trackback extends DataproxyDriver +{ + var $driver_name = 'trackback'; + + function getChildCategories($pid = false, $all_langs = false) + { + global $_CONF, $_TABLES, $LANG_SMAP; + + $entries = array(); + + if ($pid !== false) { + return $entries; + } + + $supported_drivers = $this->getAllDriverNames(); + $sql = "SELECT DISTINCT type FROM {$_TABLES['trackback']} " + . "ORDER BY type"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + if (in_array(stripslashes($A['type']), $supported_drivers)) { + $entry = array(); + $entry['id'] = stripslashes($A['type']); + $entry['pid'] = false; + $entry['title'] = $entry['id']; + $entry['uri'] = false; + $entry['date'] = false; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + } + + return $entries; + } + + /** + * Returns array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string), + * 'raw_data' => raw data of the item (stripslashed) + * ) + */ + function getItemById($id, $all_langs = false) + { + global $_CONF, $_TABLES; + + $retval = array(); + + $sql = "SELECT * " + . "FROM {$_TABLES['trackback']} " + . "WHERE (cid = '" . addslashes($id) . "') "; + $result = DB_query($sql); + if (DB_error()) { + return $retval; + } + + if (DB_numRows($result) == 1) { + $A = DB_fetchArray($result, false); + $A = array_map('stripslashes', $A); + + $retval['id'] = $id; + $retval['title'] = $A['title']; + $retval['uri'] = $A['url']; // maybe needs cleaning + $retval['date'] = strtotime($A['date']); + $retval['image_uri'] = false; + $retval['raw_data'] = $A; + } + + return $retval; + } + + /** + * Returns an array of ( + * 'id' => $id (string), + * 'title' => $title (string), + * 'uri' => $uri (string), + * 'date' => $date (int: Unix timestamp), + * 'image_uri' => $image_uri (string) + * ) + */ + function getItems($category, $all_langs = false) + { + global $_CONF, $_TABLES; + + $entries = array(); + + if (!in_array($category, $this->getAllDriverNames())) { + return $entries; + } + + $sql = "SELECT cid, title, url, UNIX_TIMESTAMP(date) AS day " + . "FROM {$_TABLES['trackback']} " + . "WHERE (type = '" . addslashes($category) . "') " + . "ORDER BY day DESC"; + $result = DB_query($sql); + if (DB_error()) { + return $entries; + } + + while (($A = DB_fetchArray($result, false)) !== false) { + $entry = array(); + + $entry['id'] = $A['cid']; + $entry['title'] = stripslashes($A['title']); + $entry['uri'] = $this->cleanUrl($A['url']); + $entry['date'] = $A['day']; + $entry['image_uri'] = false; + + $entries[] = $entry; + } + + return $entries; + } +} Added: trunk/plugins/dataproxy/functions.inc ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/functions.inc Tue Sep 9 07:30:07 2008 @@ -0,0 +1,310 @@ +<?php +// +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/functions.inc | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +//define( 'DATAPROXY_DEBUG', true ); + +/** +* Language file Include +*/ +$langfile = $_CONF['path'] . 'plugins/dataproxy/language/' . $_CONF['language'] . '.php'; +clearstatcache(); +if (file_exists($langfile)) { + include_once $langfile; +} else { + include_once $_CONF['path'] . 'plugins/dataproxy/language/english.php'; +} + +/** +* Include dataproxy config file +*/ +require_once $_CONF['path'] . 'plugins/dataproxy/config.php'; +require_once $_CONF['path'] . 'plugins/dataproxy/dataproxy.php'; + +// +---------------------------------------------------------------------------+ +// | Geeklog Plugin API Implementations | +// +---------------------------------------------------------------------------+ + +/** +* Returns the items for this plugin that should appear on the main menu +* +* @return array Associative array of menu items to be added to menu +*/ +function plugin_getmenuitems_dataproxy() { + return array(); +} + +/** +* Check to see if this Plugin uses comments +* +* @return boolean true or false +*/ +function plugin_commentsupport_dataproxy() { + return false; +} + +/** +* Shows the statistics for the plugin on stats.php. If $showsitestats is 1 +* then we are to only print the overall stats in the 'site statistics' box +* otherwise we show the detailed stats for the plugin +* +* @param int showsitestate Flag to let us know which stats to get +* @return string returns formatted HTML to insert in stats page +*/ +function plugin_showstats_dataproxy($showsitestats) { + $retval = ''; + return $retval; +} + +/** +* This will put an option for the plugin in the command and control block on +* moderation.php +* +* @return array Array containing (plugin name, admin url, url of plugin icon) +* +*/ +function plugin_cclabel_dataproxy() { + global $_CONF; + + $pi_name = DPXY_str('menu_label'); + $admin_url = $_CONF['site_admin_url'] . '/plugins/dataproxy/index.php'; + $icon_url = $_CONF['site_admin_url'] . '/plugins/dataproxy/images/dataproxy.gif'; + + return array($pi_name, $admin_url, $icon_url); +} + +/** +* Returns the administrative option for this plugin +* +* Adds the plugin to the Admin menu +* +* Universal Plugin: Modify/Uncomment use it +* +* @return array Array containing (plugin name, plugin admin url, # of items in plugin or '') +*/ +function plugin_getadminoption_dataproxy() { + global $_CONF, $_TABLES; + + if (SEC_hasRights('dataproxy.admin')) { + $pi_name = DPXY_str('menu_label'); + $admin_url = $_CONF['site_admin_url'] . '/plugins/dataproxy/index.php'; + $num_items = ''; +// $num_items = DB_count($_TABLES['table1']); + return array($pi_name, $admin_url, $num_items); + } +} + +/** +* Returns the version for this plugin +* +* @return string VersionNo +*/ +function plugin_chkVersion_dataproxy() { + global $_DPXY_CONF; + + return $_DPXY_CONF['pi_version']; +} + +/** +* Returns the user option for this plugin +* +* @return array Array containing (plugin name, plugin user url, 0) +*/ +function plugin_getuseroption_dataproxy() { + return array(); +} + +/** +* Upgrade the plugin +* +* @return boolean true (= success) +* +*/ +function plugin_upgrade_dataproxy() { + global $_CONF, $_TABLES, $_DPXY_CONF; + + $result = DB_query("SELECT pi_version FROM {$_TABLES['plugins']} WHERE (pi_name = 'dataproxy')"); + $A = DB_fetchArray($result, false); + $pi_version = $A['pi_version']; // Version info stored in database + + // Do upgrading + +// switch ($pi_version) { +// case '': +// break; +// +// case '': +// break; +// +// } + + // Update plugin info + + $result = DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = \"{$_DPXY_CONF['pi_version']}\" WHERE (pi_name = 'dataproxy')"); + COM_errorLog(ucfirst("dataproxy") . " plugin was successfully updated to version {$_DPXY_CONF['pi_version']}."); + + return true; +} + +/** +* Removes the datastructures for this plugin from the Geeklog database. +* +* @param string $installCheck Default is blank but if set, check if +* plugin is disabled first +* @return boolean True if successful false otherwise +* +*/ +function plugin_uninstall_dataproxy($installCheck = '') { + global $_TABLES, $LANG_DPXY; + + // $FEATURES and $TABLES have to be changed accodrding to your plugin + $pi_name = 'dataproxy'; + $FEATURES = array('dataproxy.admin'); + $TABLES = array('dpxy_notify'); + + // Check and see if plugin is still enabled - if so display warning and exit + if (($installCheck != '') + AND DB_getItem($_TABLES['plugins'], 'pi_enabled', 'pi_name = "' . $pi_name . '"')) { + COM_errorLog("Plugin is installed and enabled. Disable first if you want to de-install it", 1); + $display .= COM_startBlock(DPXY_str('warning')) + . DPXY_str('enabled') + . COM_endBlock(); + echo $display; + return false; + } + + // Ok to proceed and delete plugin + + // Unregister the plugin with Geeklog + COM_errorLog('Attempting to unregister the dataproxy plugin from Geeklog', 1); + DB_query("DELETE FROM {$_TABLES['plugins']} WHERE (pi_name = 'dataproxy')", 1); + + // Drop dataproxy tables + foreach ($TABLES as $table) { + $t = $_TABLES[$table]; + COM_errorLog("Removing Table {$t}", 1); + DB_query("DROP TABLE {$t}", 1); + } + + // Remove Security for this plugin + $grp_id = DB_getItem($_TABLES['vars'], 'value', "name = '{$pi_name}_gid'"); + + COM_errorLog("Removing {$pi_name} Admin Group", 1); + DB_query("DELETE FROM {$_TABLES['groups']} WHERE (grp_id = '{$grp_id}')", 1); + DB_query("DELETE FROM {$_TABLES['vars']} WHERE (name = '{$pi_name}_gid')"); + COM_errorLog("Removing root users from admin of {$pi_name}"); + DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE (ug_main_grp_id = '{$grp_id}')", 1); + + // Remove all the associated features -- access rights + foreach ($FEATURES as $feature) { + COM_errorLog("Removing {$feature} feature and rights to it", 1); + $feat_id = DB_getItem($_TABLES['features'], 'ft_id', "(ft_name = '{$feature}')"); + DB_query("DELETE FROM {$_TABLES['access']} WHERE (acc_ft_id = '{$feat_id}')", 1); + DB_query("DELETE FROM {$_TABLES['features']} WHERE (ft_id = '{$feat_id}')", 1); + } + + COM_errorLog('...success', 1); + return true; +} + +/** +* Returns the current encoding +*/ +function DPXY_encoding() { + global $_CONF, $LANG_CHARSET; + + static $encoding = null; + + if ($encoding === null) { + if (isset($LANG_CHARSET)) { + $encoding = $LANG_CHARSET; + } else if (isset($_CONF['default_charset'])) { + $encoding = $_CONF['default_charset']; + } else { + $encoding = 'iso-8859-1'; + } + } + + return $encoding; +} + +/** +* Returns a string escaped for output +*/ +function DPXY_esc() { + $str = html_entity_decode($str, ENT_QUOTES, DPXY_encoding()); + return htmlentities($str, ENT_QUOTES, DPXY_encoding()); +} + +/** +* Returns a lang var, escaped if necessary +*/ +function DPXY_str($index, $noesc = false) { + global $LANG_DPXY; + + if (isset($LANG_DPXY[$index])) { + if ($noesc) { + return $LANG_DPXY[$index]; + } else { + return DPXY_esc($LANG_DPXY[$index]); + } + } else { + COM_errorLog('DPXY_str: undefined index "' . $index . '".'); + return '(undefined)'; + } +} + +/** +* This function is called when an item is about to be saved. Currently, only +* 'article' seems to be supported. +* +* @param $type string type of the item, e.g. 'article' +* @param $id string unique ID of the item +*/ +function plugin_itemsaved_dataproxy($id, $type) { + + if (defined('DATAPROXY_DEBUG')) { + COM_errorLog("plugin_itemsaved_dataproxy('{$id}', '{$type}')"); + } + + return false; +} + +/** +* The interval between runs is determined by $_CONF['cron_schedule_interval'] +* +*/ +function plugin_runScheduledTask_dataproxy() { + if (defined('DATAPROXY_DEBUG')) { + COM_errorLog('plugin_runScheduledTask_dataproxy:'); + } +} Added: trunk/plugins/dataproxy/language/english.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/language/english.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,46 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/language/english.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------| +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA| +// | | +// +---------------------------------------------------------------------------| + +$LANG_CHARSET = 'iso-8859-1'; + +$LANG_DPXY = array( + 'plugin' => 'dataproxy Plugin', + 'access_denied' => 'Access Denied', + 'access_denied_msg' => 'Only Root Users have Access to this Page. Your user name and IP have been recorded.', + 'admin' => 'dataproxy Plugin Admin', + 'install_header' => 'Install/Uninstall the dataproxy Plugin', + 'install_success' => 'Installation Successful', + 'install_fail' => 'Installation Failed -- See your error log to find out why.', + 'uninstall_success' => 'Uninstallation Successful', + 'uninstall_fail' => 'Uninstallation Failed -- See your error log to find out why.', + 'menu_label' => 'DataProxy', +); Added: trunk/plugins/dataproxy/language/english_utf-8.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/language/english_utf-8.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,46 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/language/english_utf-8.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------| +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA| +// | | +// +---------------------------------------------------------------------------| + +$LANG_CHARSET = 'utf-8'; + +$LANG_DPXY = array( + 'plugin' => 'dataproxy Plugin', + 'access_denied' => 'Access Denied', + 'access_denied_msg' => 'Only Root Users have Access to this Page. Your user name and IP have been recorded.', + 'admin' => 'dataproxy Plugin Admin', + 'install_header' => 'Install/Uninstall the dataproxy Plugin', + 'install_success' => 'Installation Successful', + 'install_fail' => 'Installation Failed -- See your error log to find out why.', + 'uninstall_success' => 'Uninstallation Successful', + 'uninstall_fail' => 'Uninstallation Failed -- See your error log to find out why.', + 'menu_label' => 'DataProxy', +); Added: trunk/plugins/dataproxy/language/japanese.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/language/japanese.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,45 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/language/japanese.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------| +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA| +// | | +// +---------------------------------------------------------------------------| + +$LANG_CHARSET = 'euc-jp'; + +$LANG_DPXY = array( + 'plugin' => 'dataproxy�ץ饰����', + 'access_denied' => '���������ϵ��ݤ���ޤ�����', + 'access_denied_msg' => '���Υڡ����˥��������Ǥ���Τϡ�Root�桼������Ǥ������ʤ��Υ桼��̾��IP���ɥ쥹�ϵ�Ͽ����ޤ�����', + 'admin' => 'dataproxy�ץ饰�������', + 'install_success' => 'dataproxy�ץ饰����Υ��ȡ�������ޤ�����', + 'install_fail' => 'dataproxy�ץ饰����Υ��ȡ���˼��Ԥ��ޤ������ܺ٤ϥ��顼��(error.log)����������', + 'uninstall_success' => 'dataproxy�ץ饰����ϥ��ȡ��뤵��ޤ�����', + 'uninstall_fail' => 'dataproxy�ץ饰����Υ��ȡ���˼��Ԥ��ޤ������ܺ٤ϥ��顼��(error.log)����������', + 'menu_label' => '�ǡ����ץ�����', +); Added: trunk/plugins/dataproxy/language/japanese_utf-8.php ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/language/japanese_utf-8.php Tue Sep 9 07:30:07 2008 @@ -0,0 +1,45 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Data Proxy Plugin for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | geeklog/plugins/dataproxy/language/japanese_utf-8.php | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2007-2008 mystral-kk - geeklog AT mystral-kk DOT net | +// | | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - twill****@users***** | +// | Blaine Lang - langm****@sympa***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------| +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA| +// | | +// +---------------------------------------------------------------------------| + +$LANG_CHARSET = 'utf-8'; + +$LANG_DPXY = array( + 'plugin' => 'dataproxyプラグイン', + 'access_denied' => 'アクセスは拒否されました。', + 'access_denied_msg' => 'このページにアクセスできるのは,Rootユーザだけで す。あなたのユーザ名とIPアドレスは記録されました。', + 'admin' => 'dataproxyプラグイン管理', + 'install_success' => 'dataproxyプラグインのインストールに成功しまし た。', + 'install_fail' => 'dataproxyプラグインのインストールに失敗しました。詳細 はエラーログ(error.log)をご覧ください。', + 'uninstall_success' => 'dataproxyプラグインはアンインストールされまし た。', + 'uninstall_fail' => 'dataproxyプラグインのアンインストールに失敗しまし た。詳細はエラーログ(error.log)をご覧ください。', + 'menu_label' => 'データプロクシー', +); Added: trunk/plugins/dataproxy/templates/admin.thtml ============================================================================== --- (empty file) +++ trunk/plugins/dataproxy/templates/admin.thtml Tue Sep 9 07:30:07 2008 @@ -0,0 +1 @@ +<h2>{header}</h2>