News:

CPG Release 1.6.29
During HTML5 upload, keep pseudo blank code 200 messages from triggering error condition
added Russian language
correct failure to use theme menu icons in album manager
minor vulnerabilities mitigation

Main Menu

Coppermine page titler

Started by sengsara, October 03, 2003, 12:43:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sengsara

OK guys, here's what i did. I create a file, named it cpgtitler.php and put this inside.

<?php

$usr 
"'s Gallery";

if&
#40;$album==lastup&#41; $ttrail="| Last Uploads";
elseif&#40;$album==lastcom&#41; $ttrail="| Last Comments";
elseif&#40;$album==topn&#41; $ttrail="| Top Viewed";
elseif&#40;$album==toprated&#41; $ttrail="| Top Rated";
elseif&#40;$album==search&#41; $ttrail="| Search Results";
elseif&#40;$album==random&#41; $ttrail="| Random Picture";

if&#40;$file==thumbnails&#41; &#123; //filename thumbnail
  
  
if&#40;is_numeric&#40;$album&#41;&#41; &#123;
    
    
$sql "SELECT title FROM cpg_albums WHERE aid='$album'"
    
$result $db->sql_query&#40;$sql&#41;; 
    
$row $db->sql_fetchrow&#40;$result&#41;; 
    
$albumname $row[title&#93;; 
    
    
$pagetitle "| Gallery | View Album | $albumname";
    
  &
#125; else &#123; //meta album
    
    
if&#40;$cat&#41; &#123; //have category
      
      
if&#40;$cat<0&#41; &#123;
        
        
$sql "SELECT title FROM cpg_albums WHERE aid='".&#40;-$cat&#41;."'"; 
        
$result $db->sql_query&#40;$sql&#41;; 
        
$row $db->sql_fetchrow&#40;$result&#41;; 
        
$albumname $row[title&#93;; 
        
      
&#125; elseif&#40;$cat<10000&#41; &#123;
        
        
$sql "SELECT namee FROM cpg_categories WHERE cid='$cat'"
        
$result $db->sql_query&#40;$sql&#41;; 
        
$row $db->sql_fetchrow&#40;$result&#41;; 
        
$albumname $row[namee&#93;; 
       
      
&#125; else &#123;
        
        
$sql "SELECT username FROM ".$prefix."_users WHERE user_id='".&#40;$cat-10000&#41;."'"; 
        
$result $db->sql_query&#40;$sql&#41;; 
        
$row $db->sql_fetchrow&#40;$result&#41;; 
        
$albumname $row['username'&#93;;
        
$albumname "$albumname$usr";
        
      &
#125;
      
      
$pagetitle "| Gallery | $albumname $ttrail";
    
    &
#125; else &#123; //no category
      
      
$pagetitle "| Gallery $ttrail";
      
      if&
#40;$search&#41; $pagetitle = "| Gallery $ttrail&#58; $search";
    
    
&#125;
    
  
&#125; // end album selection
    
&#125; elseif&#40;$file==displayimage&#41; &#123; //filename displayimage
  
  
if&#40;is_numeric&#40;$album&#41;&#41; &#123; 
    
    
$sql "SELECT title FROM cpg_albums WHERE aid='$album'"
    
$result $db->sql_query&#40;$sql&#41;; 
    
$row $db->sql_fetchrow&#40;$result&#41;;
    
$albumname $row[title&#93;; 
    
    
if&#40;$slideshow&#41; &#123;
      
      
$pagetitle "| Gallery | $albumname | Viewing Slideshow";
      
    &
#125; else &#123;
      
      
$pagetitle "| Gallery | $albumname | Viewing Picture";

    &
#125;
    
  
&#125; else &#123; //meta album
    
    
if&#40;$pos<0&#41; &#123;
    
      
$sql "SELECT filename, title FROM cpg_pictures WHERE pid='".&#40;-$pos&#41;."'"; 
      
$result $db->sql_query&#40;$sql&#41;; 
      
$row $db->sql_fetchrow&#40;$result&#41;; 
      
$pictitle $row[title&#93;; 
      
$picfilename $row[filename&#93;; 
      
      
if&#40;!$pictitle&#41; &#123;
        
        
$pagetitle "| Gallery $ttrail | $picfilename";
        
      &
#125; else &#123;
        
        
$pagetitle "| Gallery $ttrail | $pictitle";
          
      &
#125;
      
    
&#125; else &#123; //positive pos
      
      
if&#40;$cat&#41; &#123;
        
        
if&#40;$cat<0&#41; &#123;
          
          
$sql "SELECT title FROM cpg_albums WHERE aid='".&#40;-$cat&#41;."'"; 
          
$result $db->sql_query&#40;$sql&#41;; 
          
$row $db->sql_fetchrow&#40;$result&#41;; 
          
$albumname $row[title&#93;; 
          
          
$pagetitle "| Gallery | $albumname $ttrail | Viewing Picture";
          
        &
#125;
      
      
&#125; else &#123;
        
        
$pagetitle "| Gallery $ttrail | Viewing Picture";
        
      &
#125;
      
    
&#125;
    
  
&#125;
  
&#125; elseif&#40;$file==search&#41; &#123;
  
  
$pagetitle "| Gallery | Picture Search";
  
&
#125; elseif&#40;$file==upload&#41; &#123;
  
  
$pagetitle "| Gallery | Picture Upload";
  
&
#125; else &#123;

  
if&#40;$cat&#41; &#123; //have category
    
    
if&#40;$cat<0&#41; &#123;
      
      
$sql "SELECT title FROM cpg_albums WHERE aid='".&#40;-$cat&#41;."'"; 
      
$result $db->sql_query&#40;$sql&#41;; 
      
$row $db->sql_fetchrow&#40;$result&#41;; 
      
$albumname $row[title&#93;; 
      
    
&#125; elseif&#40;$cat<10000&#41; &#123;
      
      
$sql "SELECT namee FROM cpg_categories WHERE cid='$cat'"
      
$result $db->sql_query&#40;$sql&#41;; 
      
$row $db->sql_fetchrow&#40;$result&#41;; 
      
$albumname $row[namee&#93;; 
     
    
&#125; else &#123;
      
      
$sql "SELECT username FROM ".$prefix."_users WHERE user_id='".&#40;$cat-10000&#41;."'"; 
      
$result $db->sql_query&#40;$sql&#41;; 
      
$row $db->sql_fetchrow&#40;$result&#41;; 
      
$albumname $row['username'&#93;;
      
$albumname "$albumname$usr";
      
    &
#125;
      
    
$pagetitle "| Gallery | $albumname $ttrail";
    
  &
#125; else &#123; //no category
    
    
$pagetitle "| Picture Gallery";
    
  &
#125;
  
&#125; 

?>


I upload it to my coppermine folder and then replace this line
$pagetitle = "- Coppermine";
with
include("modules/coppermine/cpgtitler.php");
inside some files such as index.php, upload.php, displayimage.php, search.php and thumbnails.php.

It works fine for me, but I think it needs lots of fixes and improvements.
For example the default/user sort prevented me to display the picture title/filename. My code can only display it if you click the image from the random page. I know the Dev. Team will solve this in a just a few seconds,.

So pleeeeeaaaase help me improve it and if possible put it in the future release.  :oops:

Wow! I never thought my post could be this long. Sorry... :oops:
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fbatamweb.net%2F4leechers%2Fsengsaraatgmail.gif&hash=5023c7ba1bc4142435e406735fee30bc611c5a03)

sengsara

Just to let you know. The code above is based on a hack inside tha file nukebb.php (BBToNuke 2.0.5?). below is the credit line inside that file:

// The following code block inserts forum thread titles in the html title bar
// The code was supplied by members at nuke cops: http://www.nukecops.com/postt4466.html
// With special thanks to Curt and georgiaguy for this forums hack.


I am not the original author, I only make it to work with Coppermine 1.1D.
Those guys deserved the credits.
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fbatamweb.net%2F4leechers%2Fsengsaraatgmail.gif&hash=5023c7ba1bc4142435e406735fee30bc611c5a03)

gtroll

The basic idea might be theirs but the codes all yours  :D I am working to include the language variables and will include this as a option in CPG 1.2nuke

sengsara

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fbatamweb.net%2F4leechers%2Fsengsaraatgmail.gif&hash=5023c7ba1bc4142435e406735fee30bc611c5a03)

gtroll

Here is my code for the CPG nice titles thing, there are a couple of bugs (no $picname or $pictitle displayed) but this should work in 1.1d otherwise...
If someone can can hack the sql statement$sql = "SELECT filename, title FROM cpg_pictures WHERE pid=$pid";
               
that controls that to make this code work correctly I'll give you 3 :idea: :idea: :idea: brownie points :P  but really i'm sure it can be done with an inner or left join but right now it escapes me!
I took all the English out of the display except for the few variables in lang_pagetitle_php which will be added to the language files in the final version. I used the table name nuke_users for readabilty so change that is that's not the name of your table
<?php 
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.0 nuke  DEVEL                                //
// ------------------------------------------------------------------------- //
// Copyright &#40;C&#41; 2002,2003 Gregory DEMAR <gdemar@wanadoo.fr>                 //
// http&#58;//www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by gtroll                                                                     //
// &#40;http&#58;//coppermine.sf.net/team/&#41;                                          //
// ------------------------------------------------------------------------- //
// 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         //
// &#40;at your option&#41; any later version.                                       //
// ------------------------------------------------------------------------- //
// define language array
$lang_pagetitle_php = array&#40;'divider' => '>',
    
'viewing' => 'Viewing Photo',
    
'usr' => "'s Photo Gallery",
    
'photogallery' => 'Photo Gallery',
    &
#41;;
// Process language selection
global $currentlang$language;
if &
#40;file_exists&#40;"modules/coppermine/lang/$currentlang.php"&#41;&#41; &#123;
    
$USER['lang'&#93; = $currentlang;
&#125; else &#123;
    
$USER['lang'&#93; = $language;
&#125; 

if &#40;!file_exists&#40;"modules/coppermine/lang/&#123;$USER['lang'&#93;&#125;.php"&#41;&#41; &#123;
    
if &#40;!file_exists&#40;"modules/coppermine/lang/&#123;$CONFIG['lang'&#93;&#125;.php"&#41;&#41; &#123;
        
$CONFIG['lang'&#93; = 'english';
    
&#125; 
&#125; else &#123;
    
$CONFIG['lang'&#93; = $USER['lang'&#93;;
&#125; 
include "modules/coppermine/lang/&#123;$CONFIG['lang'&#93;&#125;.php"//sengsara
// define variables
$pos = isset&#40;$HTTP_GET_VARS[pos&#93;&#41; ? &#40;int&#41;$HTTP_GET_VARS[pos&#93; &#58; 0;
$humanpos $pos 1;
$cat = isset&#40;$HTTP_GET_VARS[cat&#93;&#41; ? &#40;int&#41;$HTTP_GET_VARS[cat&#93; &#58; 0;
$album = isset&#40;$HTTP_GET_VARS[album&#93;&#41; ? $HTTP_GET_VARS[album&#93; &#58; '';
$file = isset&#40;$HTTP_GET_VARS[file&#93;&#41; ? $HTTP_GET_VARS[file&#93; &#58; '';

switch &#40;$album&#41; &#123;
    
case 'lastup'&#58;
        
$ttrail "$lang_pagetitle_php[divider&#93; $lang_meta_album_names[lastup&#93; "//Last Uploads
        
break;
    case 
'lastcom'&#58;
        
$ttrail "$lang_pagetitle_php[divider&#93; $lang_meta_album_names[lastcom&#93; "//Last Comments
        
break;
    case 
'topn'&#58;
        
$ttrail "$lang_pagetitle_php[divider&#93; $lang_meta_album_names[topn&#93; "//Top Viewed
        
break;
    case 
'toprated'&#58;
        
$ttrail "$lang_pagetitle_php[divider&#93; $lang_meta_album_names[toprated&#93; "//Top Rated
        
break;
    case 
'search'&#58;
        
$ttrail "$lang_pagetitle_php[divider&#93; $lang_meta_album_names[search&#93; "//Search Results';
        
break;
    case 
'random'&#58;
        
$ttrail "$lang_pagetitle_php[divider&#93; $lang_meta_album_names[random&#93; "//Random Picture
        
break;
    default&
#58;
        
$ttrail '';
        break;
&
#125; //end sorted galleries
switch &#40;$file&#41; &#123;
    
case 'thumbnails'&#58; // filename thumbnail
        
if &#40;is_numeric&#40;$album&#41;&#41; &#123; //regular album
            
$sql "SELECT title FROM cpg_albums WHERE aid='$album'";
            
$result $db->sql_query&#40;$sql&#41;;
            
$row $db->sql_fetchrow&#40;$result&#41;;
            
$albumname $row[title&#93;;
            
$pagetitle "$lang_pagetitle_php[photogallery&#93; $lang_pagetitle_php[divider&#93; $albumname $ttrail"
        &
#125; else &#123; // meta album
            
if &#40;isset&#40;$HTTP_GET_VARS['cat'&#93;&#41; && $HTTP_GET_VARS['cat'&#93; != 0&#41; &#123; // have category
                
if &#40;$cat < 0&#41; &#123;
                    
$sql "SELECT title FROM cpg_albums WHERE aid='" . &#40;- $HTTP_GET_VARS[cat&#93;&#41; . "'";
                    
$result $db->sql_query&#40;$sql&#41;;
                    
$row $db->sql_fetchrow&#40;$result&#41;;
                    
$albumname $row[title&#93;;
                
&#125; elseif &#40;$cat < 10000&#41; &#123;
                    
$sql "SELECT owner_id FROM cpg_categories WHERE cid='$cat'";
                    
$result $db->sql_query&#40;$sql&#41;;
                    
$row $db->sql_fetchrow&#40;$result&#41;;
                    
$albumname $row[owner_id&#93;;
                
&#125; else &#123;
                    
$sql "SELECT username FROM nuke_users WHERE user_id='" . &#40;$cat-10000&#41; . "'";
                    
$result $db->sql_query&#40;$sql&#41;;
                    
$row $db->sql_fetchrow&#40;$result&#41;;
                    
$albumname $row['username'&#93;;
                    
$albumname "$albumname$lang_pagetitle_php[usr&#93;";
                &
#125; 
            
&#125; else &#123;
                
$pagetitle "$lang_cat_list[pictures&#93; $ttrail";
                if &
#40;$HTTP_GET_VARS[search&#93;&#41; $pagetitle = "$lang_cat_list[pictures&#93; $ttrail&#58; $search";
            
&#125; 
        
&#125; // end album selection
        
break;
    case 
'displayimage'&#58; // filename displayimage
        
if &#40;is_numeric&#40;$album&#41;&#41; &#123; // regular album
            
$sql "SELECT title FROM cpg_albums WHERE aid='$album'";
            
$result $db->sql_query&#40;$sql&#41;;
            
$row $db->sql_fetchrow&#40;$result&#41;;
            
$albumname $row[title&#93;;
            
if &#40;$slideshow&#41; &#123;
                
$pagetitle "$albumname $lang_pagetitle_php[photogallery&#93; Slideshow";
            &
#125; else &#123; // Viewing Normal Picture
                
$sql "SELECT filename, title FROM cpg_pictures WHERE pid=$pid";
                
$result $db->sql_query&#40;$sql&#41;;
                
$row $db->sql_fetchrow&#40;$result&#41;;
                
$pictitle $row[title&#93;;
                
$picfilename $row[filename&#93;;
                
$humanpos $pos 1;
                if &
#40;$pictitle != ''&#41; &#123;
                    
$pagetitle "$albumname $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $lang_pagetitle_php[divider&#93; $pictitle $ttrail";
                &
#125; elseif &#40;$picname != ''&#41; &#123;
                    
$pagetitle "$albumname $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $lang_pagetitle_php[divider&#93; $picname $ttrail";
                &
#125; else &#123;
                    
$pagetitle "$albumname $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $lang_pagetitle_php[divider&#93; $humanpos $ttrail";
                &
#125; 
            
&#125; 
        
&#125; else &#123; // meta album
            
if &#40;$pos < 0&#41; &#123; // neg pos
                
$sql "SELECT filename, title FROM cpg_pictures WHERE pid='" . &#40;- $pos&#41; . "'";
                
$result $db->sql_query&#40;$sql&#41;;
                
$row $db->sql_fetchrow&#40;$result&#41;;
                
$pictitle $row[title&#93;;
                
$picfilename $row[filename&#93;;
                
$humanpos $pos 1;
                if &
#40;$pictitle != ''&#41; &#123;
                    
$pagetitle "$albumname $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $lang_pagetitle_php[divider&#93; $pictitle $ttrail";
                &
#125; elseif &#40;$picname != ''&#41; &#123;
                    
$pagetitle "$albumname $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $lang_pagetitle_php[divider&#93; $picname $ttrail";
                &
#125; else &#123;
                    
$pagetitle "$albumname $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $lang_pagetitle_php[divider&#93; $humanpos $ttrail";
                &
#125; //end neg pos 
            
&#125; else &#123; // positive pos
                
if &#40;$cat&#41; &#123;
                    
if &#40;$cat < 0&#41; &#123; // if less 0
                        
$sql "SELECT title FROM cpg_albums WHERE aid='" . &#40;- $cat&#41; . "'";
                        
$result $db->sql_query&#40;$sql&#41;;
                        
$row $db->sql_fetchrow&#40;$result&#41;;
                        
$albumname $row[title&#93;;
                        
$pagetitle "$albumname $ttrail $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $humanpos $ttrail";
                    &
#125; 
                
&#125; else &#123;
                    
$pagetitle "$lang_pagetitle_php[photogallery&#93; $ttrail $lang_pagetitle_php[divider&#93; $lang_pagetitle_php[viewing&#93; $humanpos $ttrail";
                &
#125; 
            
&#125; // end positive pos
        
&#125; //end meta album 
        
break;
    case 
'search'&#58;
        
$pagetitle "$lang_pagetitle_php[photogallery&#93; $lang_pagetitle_php[divider&#93; $lang_search_php[0&#93;";
        break;
    case 
'upload' &#58;
        
$pagetitle "$lang_pagetitle_php[photogallery&#93; $lang_pagetitle_php[divider&#93; $lang_main_menu[upload_pic_lnk&#93;";
        break;
    case 
'displayimagepopup' &#58;
        
$pagetitle "$lang_pagetitle_php[photogallery&#93; $lang_pagetitle_php[divider&#93; $lang_main_menu[upload_pic_lnk&#93;";
        break;
    case 
'ecard' &#58;
        
$pagetitle "$lang_pagetitle_php[photogallery&#93; $lang_pagetitle_php[divider&#93; $lang_ecard_php[title&#93;";
        break;
    case 
'editpics' &#58;
        
$pagetitle "$lang_editpics_php[edit_pics&#93;";
        break;
    case 
'groupmgr' &#58;
        
$pagetitle "$lang_groupmgr_php[title&#93;";
        break;
    case 
'reviewcom' &#58;
        
$pagetitle "$lang_reviewcom_php[title&#93;";
        break;
    case 
'searchnew' &#58;
        
$pagetitle "$lang_search_new_php[page_title&#93;";
        break;
    case 
'upload' &#58;
        
$pagetitle "$lang_upload_php[title&#93;";
        break;
    default&
#58;
        
$pagetitle "$lang_pagetitle_php[photogallery&#93; ";
        break;
&
#125; //end switch 
switch &#40;$cat&#41; &#123; // have category
    
case &#40;$cat < 0&#41;&#58;
        
$sql "SELECT title FROM cpg_albums WHERE aid='" . &#40;- $cat&#41; . "'";
        
$result $db->sql_query&#40;$sql&#41;;
        
$row $db->sql_fetchrow&#40;$result&#41;;
        
$albumname $row[title&#93;;
                
break;
    case &
#40;&#40;$cat > 0&#41;&&&#40;$cat < 10000&#41;&#41; &#58;
        
$sql "SELECT namee FROM cpg_categories WHERE cid='$cat'";
        
$result $db->sql_query&#40;$sql&#41;;
        
$row $db->sql_fetchrow&#40;$result&#41;;
        
$albumname $row[namee&#93;;
                
break;
        case &
#40;$cat > 10000&#41; &#58;// cat is between 1 and 9999 user gallery
        
$sql "SELECT username FROM nuke_users WHERE user_id='" . &#40;$cat-10000&#41; . "'";
        
$result $db->sql_query&#40;$sql&#41;;
        
$row $db->sql_fetchrow&#40;$result&#41;;
        
$albumname $row['username'&#93;;
        
$albumname "$albumname$lang_pagetitle_php[usr&#93;";
                break;
&
#125; //end category switch cases         

    
if &#40;$cat!=0&#41;$pagetitle = "$lang_pagetitle_php[photogallery&#93; $lang_pagetitle_php[divider&#93; $albumname $ttrail";

?>

Save file as pagetitle.inc.php in modules/coppermine/include

I upload it to my coppermine folder and then global find and replace this line

$pagetitle = "- Coppermine";

with

// $pagetitle = "- Coppermine";
include("modules/coppermine/include/pagetitle.inc.php");


i

sengsara

Way to go, gtroll!
Now it's language aware and we can even specify the divider.

What I did is only for the page that can be spidered. Now I think it covers all pages, right?

Great!
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fbatamweb.net%2F4leechers%2Fsengsaraatgmail.gif&hash=5023c7ba1bc4142435e406735fee30bc611c5a03)