There's a plugin avaliable for searching album titles and descriptions and I found it to be very useful...except in the case of one of my galleries which showed comic book scans. All the categories had real names but the albums were named Volume 1, Volume 2, etc. so couldn't be easily searched.
I couldn't quickly figure out how coppermine stores database names and passwords so I had to hard encode the information into the file. You'll have to change it as necessary to make this hack work.
I'm also assuming everyone has coppermine installed under the default prefix "cpg140_"
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.3.0 miniCMS //
// ------------------------------------------------------------------------- //
// Copyright (C) 2004 Tarique Sani <tarique@sanisoft.com>, //
// Amit Badkas <amit@sanisoft.com> //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// 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. //
// ------------------------------------------------------------------------- //
// ------------------------------------------------------------------------- //
// Search modification by Kum Sackey //
// ------------------------------------------------------------------------- //
define('IN_COPPERMINE', true);
define('EDITPICS_PHP', true);
require('include/init.inc.php');
pageheader("Category Search");
printf("<center>");
starttable("100%", "Category Search" , 3);
?>
<?php
#class='tableborder'
while (list($name, $value) = each($HTTP_GET_VARS)) {
# echo "$name = $value<br>\n";
if ($name == "query" ) $query = $value;
}
while (list($name, $value) = each($HTTP_GET_VARS)) {
echo "$name = $value<br>\n";
}
?>
<?php
# Connection Info
$host = "< your host >";
$dbName = "< your db name >";
$MysqlName = "< your msql name >";
$MysqlPW = "< your pwd >";
#Connect to Host
$link = mysql_connect($host,$MysqlName,$MysqlPW);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
#echo 'Connected successfully';
mysql_select_db("< your coppermine db>",$link);
$query = $_GET['query'];
$query_pieces = explode(" ", $query);
$query = "";
$c = 0;
$cd = 0;
while ($c < count($query_pieces) )
{
if ($query_pieces[$c] != "")
{
if (strlen($query_pieces[$c]) < 3)
{
$query_discard[$cd] = $query_pieces[$c];
$cd = $cd + 1;
}
else
{
$query .= '%'.$query_pieces[$c];
}
}
$c = $c + 1;
}
$query .= '%';
// echo $query;
if ($query != '%' )
{
$result = MySQL($dbName, "SELECT * FROM `cpg140_categories` WHERE `name` LIKE '$query'");
$result2 = MySQL($dbName, "SELECT * FROM `cpg140_albums` WHERE `title` LIKE '$query'");
}
?>
<tr>
<td class="tableb" > <div align="center">
<table width="75%" cellspacing="2" cellpadding="2">
<tr>
<td> <p>This tool searches category and album titles for all the whitespace
seperated words you input.</p>
<p>For a search word to be valid, it must contain at least three characters.</p>
<p>Enter search terms:</p>
<form name="form1" method="get" action="<?php echo $PHP_SELF?>" >
<p>
<input type="text" name="query">
<input type="submit" name="Submit" value="Submit">
</p>
</form></td>
</tr>
</table>
<p> </p>
<h2>Search Results</h2>
<?
if ($cd > 0)
{
echo 'The following search terms were discarded because they were too short: ';
$c = 0;
while ($c < ($cd - 1) )
{
echo $query_discard[$c].',';
$c = $c + 1;
}
echo $query_discard[$c];
echo '<br>';
}
?>
<?php if (MySQL_NUMROWS($result) + MySQL_NUMROWS($result2) == 0)
{ echo "No results found"; }
else
{
?>
<table width="75%" border="1" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2" class="tableh1">Categories</td>
</tr>
<?php
// Output Data into Table
while ($cat_list = mysql_fetch_array($result, MYSQL_ASSOC))
{
?>
<tr>
<td> <a href="<?php printf("index.php?cat=%u", $cat_list['cid']); ?> ">
<?php echo $cat_list['name']; ?> </a></td>
<td>
<?php if ($cat_list['description'] == "") { echo ' '; }else { echo $cat_list['description']; } ?>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="2" class="tableh1">Albums</td>
</tr>
<?php
// Output Data into Table
while ($alb_list = mysql_fetch_array($result2, MYSQL_ASSOC))
{
?>
<tr>
<td><a href="<?php printf("thumbnails.php?album=%u", $alb_list['aid']); ?> ">
<?php echo $alb_list['title']; ?> </a></td>
<td>
<?php if ($alb_list['description'] == "") { echo ' '; }else { echo $alb_list['description']; } ?>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</div></td>
</tr>
<?php
printf("</center>");
endtable();
?>