Include onlinestats Include onlinestats
 

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]

Main Menu

Include onlinestats

Started by Senator, October 01, 2006, 11:07:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Senator

I use the plugin "onlinestats".

It works fine, but i've one problem with it.

After install the plugin i configure it in the config. Now its only vissable on the index.php

I want it make visable on displayimage.php with an php include.

Can someone tell me how to do that.

Sami

You can't ,it's coded to show only on index !
‍I don't answer to PM with support question
Please post your issue to related board

Paver

Here's one way you can do so. 

In themes/yourtheme/theme.php, add a customization for the pagefooter function as shown:
// Function for writing a pagefooter
function pagefooter()
{
    //global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;;
    global $template_footer;

    $custom_footer = cpg_get_custom_include($CONFIG['custom_footer_path']);

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
    cpg_debug_output();
    }

    // MOD - begin
    CPGPluginAPI::filter('plugin_block', array('','onlinestats'));
    // MOD - end

    $template_vars = array(
        '{CUSTOM_FOOTER}' => $custom_footer,
        '{VANITY}' => (defined('THEME_IS_XHTML10_TRANSITIONAL') && $CONFIG['vanity_block']) ? theme_vanity() : '',
    );

    echo template_eval($template_footer, $template_vars);
}


This is just the default pagefooter function (from themes/sample/theme.php) with one line added in (plus // MOD - begin and // MOD - end before & after it).

This will add 'onlinestats' to every page, including the index page, so you need to remove 'onlinestats' from 'the content of the main page' on the config panel, otherwise you'll see two blocks.

If you want the onlinestats block somewhere else, add the mod line shown above to another theme customization function.  You cannot do a PHP include anywhere and you cannot put it into an HTML file like template.html.  You must find a function in theme.php that will output where you want the block.

Sami

‍I don't answer to PM with support question
Please post your issue to related board

Senator

iám ussing the classic theme, and i've edit this theme.php

but there's nothing changing, and te onlinestats block is'nt vissable down of the page.

What do i wrong.

here is my theme.php

<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2006 Coppermine 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 as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.4
  $Source: /cvsroot/coppermine/stable/themes/classic/theme.php,v $
  $Revision: 1.15 $
  $Author: gaugau $
  $Date: 2006/02/24 13:32:45 $
**********************************************/

// ------------------------------------------------------------------------- //
// This theme has all CORE items removed                                     //
// ------------------------------------------------------------------------- //
define('THEME_IS_XHTML10_TRANSITIONAL',1);

// Added to display flim_strip
function theme_display_film_strip(&$thumb_list$nbThumb$album_name$aid$cat$pos$sort_options$mode 'thumb')
{
    global 
$CONFIG$THEME_DIR;
    global 
$template_film_strip$lang_film_strip;

    static 
$template '';
    static 
$thumb_cell '';
    static 
$empty_cell '';
    static 
$spacer '';

    if ((!
$template)) {
        
$template $template_film_strip;
        
$thumb_cell template_extract_block($template'thumb_cell');
        
$empty_cell template_extract_block($template'empty_cell');
    }

    
$cat_link is_numeric($aid) ? '' '&amp;cat=' $cat;

    
$thumbcols $CONFIG['thumbcols'];
    
$cell_width ceil(100 $CONFIG['max_film_strip_items']) . '%';

    
$i 0;
    
$thumb_strip '';
    foreach(
$thumb_list as $thumb) {
        
//modify $new_size for max dimension of thumbnails in filmstrip
        
$new_size 65;
        
preg_match('/(?<=width=")[0-9]*/',$thumb['image'],$matches,PREG_OFFSET_CAPTURE);
        
$srcWidth=$matches[0][0];
        
preg_match('/(?<=height=")[0-9]*/',$thumb['image'],$matches,PREG_OFFSET_CAPTURE);
        
$srcHeight=$matches[0][0];
        
$ratio max($srcWidth$srcHeight) / $new_size;
        
$ratio max($ratio1.0);
        
$destWidth = (int)($srcWidth $ratio);
        
$destHeight = (int)($srcHeight $ratio);
        
$thumb['image']=preg_replace('/width="[^"]*"/','width="'.$destWidth.'"',$thumb['image']);
        
$thumb['image']=preg_replace('/height="[^"]*"/','height="'.$destHeight.'"',$thumb['image']);
        
$i++;
        if (
$mode == 'thumb') {
            
$params = array('{CELL_WIDTH}' => $cell_width,
                
'{LINK_TGT}' => "displayimage.php?album=$aid$cat_link&amp;pos={$thumb['pos']}",
                
'{THUMB}' => $thumb['image'],
                
'{CAPTION}' => $thumb['caption'],
                
'{ADMIN_MENU}' => ''
                
);
        } else {
            
$params = array('{CELL_WIDTH}' => $cell_width,
                
'{LINK_TGT}' => "index.php?cat={$thumb['cat']}",
                
'{THUMB}' => $thumb['image'],
                
'{CAPTION}' => '',
                
'{ADMIN_MENU}' => ''
                
);
        }
        
$thumb_strip .= template_eval($thumb_cell$params);
    }

    if (
defined('THEME_HAS_FILM_STRIP_GRAPHICS')) {
        
$tile1 $THEME_DIR 'images/tile1.gif';
        
$tile2 $THEME_DIR 'images/tile2.gif';
    } elseif (
defined('THEME_HAS_FILM_STRIP_GRAPHIC')) {
        
$tile1=$tile2=$THEME_DIR 'images/tile.gif';
    } else {
        
$tile1=$tile2'images/tile.gif';
    }

    
$params = array('{THUMB_STRIP}' => $thumb_strip,
        
'{COLS}' => $i,
        
'{TILE1}' => $tile1,
        
'{TILE2}' => $tile2,
        );

    
ob_start();
    
starttable($CONFIG['picture_table_width']);
    echo 
template_eval($template$params);
    
endtable();
    
$film_strip ob_get_contents();
    
ob_end_clean();

    return 
$film_strip;
}
// Function for writing a pagefooter
function pagefooter()
{
    
//global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    
global $USER$USER_DATA$ALBUM_SET$CONFIG$time_start$query_stats$queries;;
    global 
$template_footer;

    
$custom_footer cpg_get_custom_include($CONFIG['custom_footer_path']);

    if (
$CONFIG['debug_mode']==|| ($CONFIG['debug_mode']==&& GALLERY_ADMIN_MODE)) {
    
cpg_debug_output();
    }

    
// MOD - begin
    
CPGPluginAPI::filter('plugin_block', array('','onlinestats'));
    
// MOD - end

    
$template_vars = array(
        
'{CUSTOM_FOOTER}' => $custom_footer,
        
'{VANITY}' => (defined('THEME_IS_XHTML10_TRANSITIONAL') && $CONFIG['vanity_block']) ? theme_vanity() : '',
    );

    echo 
template_eval($template_footer$template_vars);
}

?>

Senator

Can someone help me with this, iám traying it for weeks but can make ik work

Paver

Please provide a link to your site.  And put 'onlinestats' in your 'content of the main page' on the config panel so it shows up on the index page.  I want to see it running on the index page, and we'll try to figure out why it's not showing up on the other pages (and not showing up twice on the index page as I mentioned before).

Senator

#7
ok, it's configure in config.

you can see on my site
*** WARNING: not safe for work

Edit (by Paver): added warning above - please make sure to note links that are "not safe for work".

Paver

Ok, I think I figured it out.  There is a bug in version 1.2 of the 'onlinestats' plugin.  I noted it previously for another issue with multiple plugins.  This bug also causes the problem you note here - in other words, my code above does not work with version 1.2 of this plugin.  There is no version 1.3 available yet; I am planning to work on that when I have time.

So, there are two things you can do:
1. Apply the fix to the plugin noted in this post.
2. Adjust the code mod I gave above as shown:
    // MOD - begin
    global $matches;
    $matches = array('','onlinestats');
    CPGPluginAPI::filter('plugin_block', array('','onlinestats'));
    // MOD - end


Either solution should fix your problem.  You should apply the #1 solution at some point anyways, so I would suggest that one.  The #2 solution will work for both a fixed plugin and an unfixed plugin, although it might have some issues I haven't thought about. 

Sami

#1 solution works only if you have other block plugin such as CPGoCat
‍I don't answer to PM with support question
Please post your issue to related board

Paver

@Sami: Do you mean that you have to have another plugin installed as well?  In my test gallery, I installed only the 'onlinestats' plugin with the fix I applied (from the #1 solution), and then I can show the 'onlinestats' on every page, so it seems to work fine with only the one plugin installed.

I have also tried it with CPGOCat installed as well, and everything is still fine ('onlinestats' on every page).

What problem do you see?

Sami

I've got only header and footer if applied #1 fix and have only onlinestats plugin installed

[Edit]
Sorry it was my mistake,I should add $matches as a parameter for online_mainpage function ...
So it's okey and all was my side ...
‍I don't answer to PM with support question
Please post your issue to related board

Paver

Yes, the #1 solution (from the linked fix) is to add $matches to the function mainpage() parameter list and to remove it from the global variable list.  That's the way the 'plugin_block' filter is supposed to work - pass in the $matches variable and receive it back from the plugin function.

Sami

#13
@Senator: can we mark this thread as a "Solved"?
‍I don't answer to PM with support question
Please post your issue to related board

Senator

Yes, sorry for the delay.

Its works perfectly.

Thanks Paver.


Topic= Solved