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: Coppermine page titler  (Read 8509 times)

0 Members and 1 Guest are viewing this topic.

sengsara

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • http://batamweb.net
Coppermine page titler
« on: October 03, 2003, 12:43:35 pm »

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

Code: [Select]
<?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
Code: [Select]
$pagetitle = "- Coppermine";
with
Code: [Select]
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:
Logged
(http://batamweb.net/4leechers/sengsaraatgmail.gif)

sengsara

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • http://batamweb.net
Nice Title Hack for phpnuke6.5+
« Reply #1 on: October 07, 2003, 11:36:26 am »

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:

Code: [Select]
// 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.
Logged
(http://batamweb.net/4leechers/sengsaraatgmail.gif)

gtroll

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 618
    • CPG-Nuke
Nice Title Hack for phpnuke6.5+
« Reply #2 on: October 07, 2003, 12:26:15 pm »

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

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • http://batamweb.net
Nice Title Hack for phpnuke6.5+
« Reply #3 on: October 07, 2003, 12:29:42 pm »

Cool!
Logged
(http://batamweb.net/4leechers/sengsaraatgmail.gif)

gtroll

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 618
    • CPG-Nuke
CPG nice titles hack 6.5+
« Reply #4 on: October 08, 2003, 02:14:26 pm »

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
Code: [Select]
$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
Code: [Select]
<?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
Code: [Select]

$pagetitle = "- Coppermine";

with
Code: [Select]

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


i

sengsara

  • Translator
  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 87
    • http://batamweb.net
Nice Title Hack for phpnuke6.5+
« Reply #5 on: October 09, 2003, 05:14:38 am »

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!
Logged
(http://batamweb.net/4leechers/sengsaraatgmail.gif)
Pages: [1]   Go Up
 

Page created in 0.033 seconds with 19 queries.