Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Anycontent.php with search function  (Read 3514 times)

0 Members and 1 Guest are viewing this topic.

mooxe

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Anycontent.php with search function
« on: September 10, 2008, 05:53:30 am »

Howdy,

I want to enable a quick search within the anycontent.php. Is this wise for php code, I am not sure... anyways... I have done it by cutting out all the stuff I dont want from search.php. I cannot get the names of the checkboxes to show up, how do I fix this? The link is http://www.combatgallery.com/ or a screenshot in case it gets fixed...

http://www.closecombatseries.net/screenshots/public/cpgerrorb735e4822085e12.jpg [Edit GauGau] Replaced hotlinked image with attachment [/Edit]




Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2008 Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.
  
  ********************************************
  Coppermine version: 1.4.18
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.4.x/anycontent.php $
  $Revision: 4380 $
  $Author: gaugau $
  $Date: 2008-04-12 12:00:19 +0200 (Sa, 12 Apr 2008) $
**********************************************/

/**
* Coppermine Photo Gallery 1.4.14 anycontent.php
*
* This file file gets included in the index.php if you set the option in admin
* can be used to display any content from any program, it is always to be edited
* according to tastes and then used
*
* @copyright 2002,2007 Gregory DEMAR, Coppermine Dev Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License V3
* @package Coppermine
* @version $Id: anycontent.php 4380 2008-04-12 10:00:19Z gaugau $
*/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

starttable("100%""Welcome to the Combat Gallery!");

?>

<tr>
  <td class="tableb" >
The Combat Gallery is a new project which intends to create, over time, one of the largest depositories of photos from World War 2. The gallery is planned to be a simple, browsable and highly searchable. The site will also be kept free of cluttered ads, news feeds, polls and anything else that detracts from viewing the galleries. Currently the majority of the photos are from World War 2, as the site grows and evolves we will be adding more categories. The pictures are collected in many ways such as auctions, photo albums and through internet searching. Photos can also be added by you, which go through a approval process to ensure proper descriptions and no duplicates.<br /><br />

The first goal is to specialize in large albums of specific battles. This will be the main effort of the gallery over the next few years.  Secondary goal is to showcase personal photo albums of the veterans who served. Finally, any photos that are collected which cannot be identified to a specific battle will be inserted into the generalized albums such as armament, vehicles, infantry and home front etc etc. If you have images you'd like to submit or if you'd like to help out on this project please email the <a href="mailto:mooxe@closecombatseries.net">Webmaster</a>.</td>
</tr>

<?php


define
('SEARCH_PHP'true);


echo <<< EOT

<form method="post" action="thumbnails.php" name="searchcpg">
EOT;

starttable('100%'$lang_search_php['title']);

$ip GALLERY_ADMIN_MODE '
        <tr>
                <td>
                        <input type="checkbox" name="pic_raw_ip" class="checkbox" id="pic_raw_ip" /><label for="pic_raw_ip" class="clickable_option">'
.$lang_search_php['ip_address'].'</label>
                </td>
        </tr>' 
:
        
'<tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
        </tr>'
;

$customs '';

$result cpg_db_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']} WHERE name LIKE 'user_field%_name' AND value <> '' ORDER BY name ASC");

while (
$row mysql_fetch_assoc($result)){
        
$name str_replace(array('_field''_name'), ''$row['name']);
        
$customs .= <<< EOT
             <tr>
                        <td><input type="checkbox" name="
$name" id="$name" class="checkbox" /><label for="$name" class="clickable_option">{$row['value']}</label></td>
                </tr>
EOT;
}
echo <<< EOT
        <tr>
            <td class="tableb" align="center" >
                <input type="text" style="width: 80%" name="search" maxlength="255" value="" class="textinput" />
                <input type="submit" value="
{$lang_search_php['submit_search']}" class="button" />
                <input type="hidden" name="album" value="search" />
            </td>
        </tr>
                <tr>


  <table align="center">
                                        <tr>
                                          <td><input type="checkbox" name="filename" id="filename" class="checkbox" checked="checked"/>
                                          <label for="filename" class="clickable_option">
{$lang_adv_opts['filename']}</label></td>
                                                <td><input type="checkbox" name="title" id="title" class="checkbox" checked="checked" />
                                                <label for="title" class="clickable_option">
{$lang_adv_opts['title']}</label></td>
                                                <td><span class="clickable_option">
                                                  <input type="checkbox" name="caption" id="caption" class="checkbox" checked="checked" />
{$lang_adv_opts['caption']}</span></td>
                                                <td><input type="checkbox" name="keywords" id="keywords" class="checkbox" checked="checked" />
                                                  <label for="keywords" class="clickable_option">
{$lang_adv_opts['keywords']}</label></td>
                                          <td><label for="keywords" class="clickable_option">
                                            <select name="type" class="listbox">
                                              <option value="AND" selected="selected">
{$lang_search_php['all_words']}</option>
                                              <option value="OR">
{$lang_search_php['any_words']}</option>
                                            </select>
                                          </label></td>
                                        </tr>
                                                
                                </table>




                        </td>
                </tr>
EOT;


endtable();
echo 
'</form>';

echo <<< EOT
      <script language="javascript" type="text/javascript">
      <!--
      document.searchcpg.search.focus();
      -->
      </script>
EOT;


ob_end_flush();
?>


<?php
endtable
();

?>

« Last Edit: September 10, 2008, 07:36:04 am by Joachim Müller »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Anycontent.php with search function
« Reply #1 on: September 10, 2008, 07:33:26 am »

Add your search box to the template.html file of your theme - that would be wiser. No need for custom queries - just add the HTML output of the regular search box. The line
Code: [Select]
$ip = GALLERY_ADMIN_MODE ? 'is nonsene imo.
Logged

mooxe

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Anycontent.php with search function
« Reply #2 on: September 10, 2008, 07:38:08 am »

Thanks I'll try that.


(I am PHP cut-paste-reload-repeat programmer)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Anycontent.php with search function
« Reply #3 on: September 10, 2008, 07:49:40 am »

This is the HTML you need to paste in:
Code: [Select]
<form method="post" action="thumbnails.php" name="searchcpg">
<!-- Start standard table -->
<table align="center" width="60%" cellspacing="1" cellpadding="0" class="maintable">
        <tr>
                <td class="tableh1" colspan="1">Search the file collection</td>

        </tr>
        <tr>
            <td class="tableb" align="center" >
                <input type="text" style="width: 80%" name="search" maxlength="255" value="" class="textinput" />
                <input type="submit" value="search" class="button" />
                <input type="hidden" name="album" value="search" />
            </td>
        </tr>
                <tr>

                        <td class="tableb">
                                <table align="center" width="60%">
                                        <tr>
                                                <td>Search in:</td>
                                                <td align="center">Age:</td>
                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="title" id="title" class="checkbox" checked="checked" /><label for="title" class="clickable_option">Title</label></td>

                                                <td align="right">Newer than <input type="text" name="newer_than" size="3" maxlength="4" class="textinput" /> days</td>
                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="caption" id="caption" class="checkbox" checked="checked" /><label for="caption" class="clickable_option">Caption</label></td>
                                                <td align="right">Older than <input type="text" name="older_than" size="3" maxlength="4" class="textinput" /> days</td>

                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="keywords" id="keywords" class="checkbox" checked="checked" /><label for="keywords" class="clickable_option">Keywords</label></td>
                                                <td>&nbsp;</td>

                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="owner_name" id="owner_name" class="checkbox" /><label for="owner_name" class="clickable_option">Owner name</label></td>

                                                <td align="right"><select name="type" class="listbox">
                                                        <option value="AND" selected="selected">Match all words (AND)</option>
                                                        <option value="OR">Match any words (OR)</option></select>
                                                </td>
                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="filename" id="filename" class="checkbox" /><label for="filename" class="clickable_option">Filename</label></td>

                                                <td>&nbsp;</td>
                                        </tr>
                                                                <tr>
                        <td><input type="checkbox" name="user1" id="user1" class="checkbox" /><label for="user1" class="clickable_option">Custom field for image description 1</label></td>
                </tr>
                                                <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>

        </tr>
                                </table>
                        </td>
                </tr></table>
<!-- End standard table -->
</form>
If you're feeling adventurous, replace the hard-coded text with the corresponding language file strings. If you're feeling even more adventurous, add an if/then switch that hides the search form output on the actual search page (search.php). If you don't want the options to show, change the type for the corresponding field from checkbox to hidden. Has been discussed often already, please use the search.
Logged

mooxe

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Anycontent.php with search function
« Reply #4 on: September 10, 2008, 07:53:32 am »

Thanks Joachim.... I ended up with this before you posted what you had... A bit messy but was getting there.

Code: [Select]
<form method="post" action="thumbnails.php" name="searchcpg">
  <tr>
    <td class="tableb" align="center" ><input type="text" style="width: 80%" name="search" maxlength="255" value="" class="textinput" />
      <input type="submit" value="{$lang_search_php['submit_search']}" class="button" />
      <input type="hidden" name="album" value="search" />
    </td>
  </tr>
  <tr>
    <table align="center">
      <tr>
        <td><input type="checkbox" name="filename" id="filename" class="checkbox" checked="checked"/>
          <label for="filename" class="clickable_option">{$lang_adv_opts['filename']}</label></td>
        <td><input type="checkbox" name="title" id="title" class="checkbox" checked="checked" />
          <label for="title" class="clickable_option">{$lang_adv_opts['title']}</label></td>
        <td><span class="clickable_option">
          <input type="checkbox" name="caption" id="caption" class="checkbox" checked="checked" />
          {$lang_adv_opts['caption']}</span></td>
        <td><input type="checkbox" name="keywords" id="keywords" class="checkbox" checked="checked" />
          <label for="keywords" class="clickable_option">{$lang_adv_opts['keywords']}</label></td>
        <td><label for="keywords" class="clickable_option">
          <select name="type" class="listbox">
            <option value="AND" selected="selected">{$lang_search_php['all_words']}</option>
            <option value="OR">{$lang_search_php['any_words']}</option>
          </select>
          </label></td>
      </tr>
    </table>
    </td>
  </tr>
 
</form>
Logged

mooxe

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Anycontent.php with search function
« Reply #5 on: September 10, 2008, 07:57:31 am »

Ok now I remember why I didnt want to use template.html. My search query on the mainpage was just for quickie search, a user lands on my page and is looking for something right away, he can do it through anycontent.php. I dont want the seach on the top of every page. Using your same code I should be able to just put that in anycontent.php anyways and it would just what I planned.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Anycontent.php with search function
« Reply #6 on: September 10, 2008, 07:59:28 am »

Yes: if you plan to apply a condition (e.g. only displaying the search form on particular pages or for particular users), your code can't go into template.html, but needs to go into a PHP-driven page. It's a matter of taste wether to use anycontent.php or theme.php.
Issue solved?
Logged

mooxe

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Anycontent.php with search function
« Reply #7 on: September 10, 2008, 01:47:27 pm »

Yes issue solved, thank you!
Logged
Pages: [1]   Go Up
 

Page created in 0.028 seconds with 20 queries.