CPGの改造

Coppermine Photo Galleryは写真を管理するウェブアプリケーションです。

ブログとの連携

ブログと組み合わせると便利なのですが、写真のリンクソースを表示させる改造をします。

  • editOnePic.php

    // If this is the users gallery icon then check it

    と書いてある行の前に下記のソースを挿入。<code php>$homepage = $CONFIG['site_url'];

print «<EOT <tr> <td class=“tableb” style=“white-space: nowrap;”>リンクのソース</td> <td width=“100%” class=“tableb” valign=“top” colspan=“2” > <input type=“text” style=“width: 100%” name=“user4” maxlength=“255” value='<a href=“$homepage$thumb_link”><img src=“$homepage$thumb_url” class=“image” border=“0” alt=“{$CURRENT_PIC['title']}”/></a>' class=“textinput” /> </td> </tr> EOT;</code>これをUTF-8で保存。

  • editpics.php<code php>function form_options()

{

global $CURRENT_PIC, $lang_editpics_php;
$isgalleryicon_selected = …
$isgalleryicon_disabled = …</code>の後に下記のソースを挿入<code php>       $thumb_url = get_pic_url($CURRENT_PIC, 'thumb');
   $thumb_link = 'displayimage.php?&amp;pos='.(-$CURRENT_PIC['pid']);

$homepage = $CONFIG['site_url'];

print «<EOT <tr> <td class=“tableb” style=“white-space: nowrap;”>リンクのソース</td> <td width=“100%” class=“tableb” valign=“top” colspan=“2” > <input type=“text” style=“width: 100%” name=“user4” maxlength=“255” value='<a href=“$homepage$thumb_link”><img src=“$homepage$thumb_url” class=“image” border=“0” alt=“{$CURRENT_PIC['title']}”/></a>' class=“textinput” /> </td> </tr> EOT;</code>globalを追加

    global $CONFIG;

xreaのデータベース対策

include/function.inc.php

function cpg_db_connect()
{
    global $CONFIG;
    $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], 
       $CONFIG['dbpass']);
    if (!$result) {
            return false;
    }
 
   mysql_query("SET NAMES utf8", $result);
 
   if (!mysql_select_db($CONFIG['dbname']))
           return false;
   return $result;
}

キーワードのデリミタを適切にする

キーワードは、半角スペースで区切ります。 全角で入力してしまった場合、一括で置換しましょう。

UPDATE cpg132_pictures SET keywords=REPLACE(keywords,' ',' ')

CPGのコメントスパム対策

Coppermine Photo Galleryは写真を管理するウェブアプリケーションです。 このコメントスパム対策をします。 元の記事は http://coppermine-gallery.net/forum/index.php?topic=33827.0

ダウンロード

設定

db_input.phpを開く

  • 最初の方に

    include 'Akismet.class.php';

    を加える。

  • $insert = cpg_db_queryを含む行が2つありますが、その最初の方の行の前に<code php>$WordPressAPIKey = 'your Akismet API key goes here';

$MyBlogURL = 'http://www.example.com/coppermine_root_dir/'; $name = $msg_author; $comment = $msg_body;

$akismet = new Akismet($MyBlogURL ,$WordPressAPIKey); $akismet→setCommentAuthor($name); $akismet→setCommentAuthorEmail($email); $akismet→setCommentAuthorURL($url); $akismet→setCommentContent($comment); $akismet→setPermalink('http://www.example.com/blog/alex/someurl/');

if($akismet→isCommentSpam()) // store the comment but mark it as spam (in case of a mis-diagnosis) cpg_die(ERROR, $lang_errors['perm_denied'], FILE, LINE); else</code>を挿入する。

  • このelseの後ろで、

    $insert = cpg_db_query("INSERT INTO {$CONFIG

    という行が実行される。