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: include php code(I know it's been asked but I have searched and still need help)  (Read 3549 times)

0 Members and 1 Guest are viewing this topic.

MeTaL_oRgY

  • Coppermine newbie
  • Offline Offline
  • Posts: 5

Ok, I need to include a file (stats.php) so I can show stats of my visits, counter, etc. on my Coppermine Gallery, I've managed to do it, yeah, the stats.php file gets included.. but NOT where I want it to be!!!!... look:

www.cemete.ifobos.com/album

it appears AT THE VERY TOP, when it should be included on the left menu, where it says '{STATS}', like here... so how to fix it??? here are the changes I did to the theme.php file:

Code: [Select]
function theme_main_menu()
{
    global $AUTHORIZED, $CONFIG, $album, $actual_cat, $cat, $REFERER, $HTTP_SERVER_VARS;
    global $lang_main_menu, $template_main_menu;

    static $main_menu = '';

    if ($main_menu != '') return $main_menu;

    $album_l = isset($album) ? "?album=$album" : '';
    $cat_l = (isset($actual_cat))? "?cat=$actual_cat" : (isset($cat) ? "?cat=$cat" : '');
    $cat_l2 = isset($cat) ? "&cat=$cat" : '';
    $my_gallery_id = FIRST_USER_CAT + USER_ID;

    if (USER_ID) {
        template_extract_block($template_main_menu, 'login');
    } else {
        template_extract_block($template_main_menu, 'logout');
        template_extract_block($template_main_menu, 'my_profile');
    }

    if (GALLERY_ADMIN_MODE || USER_ADMIN_MODE) {
        template_extract_block($template_main_menu, 'enter_admin_mode');
    } elseif (USER_CAN_CREATE_ALBUMS || USER_IS_ADMIN) {
        template_extract_block($template_main_menu, 'leave_admin_mode');
    }

    if (!USER_CAN_CREATE_ALBUMS && !USER_IS_ADMIN) {
        template_extract_block($template_main_menu, 'enter_admin_mode');
        template_extract_block($template_main_menu, 'leave_admin_mode');
    }

    if (!USER_CAN_CREATE_ALBUMS) {
        template_extract_block($template_main_menu, 'my_gallery');
    }

    if (USER_CAN_CREATE_ALBUMS) {
        template_extract_block($template_main_menu, 'my_profile');
    }

    if (!USER_CAN_UPLOAD_PICTURES) {
        template_extract_block($template_main_menu, 'upload_pic');
    }

    if (USER_ID || !$CONFIG['allow_user_registration']) {
        template_extract_block($template_main_menu, 'register');
    }

    if (!USER_ID || !$CONFIG['allow_memberlist']) {
        template_extract_block($template_main_menu, 'allow_memberlist');
    }

    if (!$CONFIG['display_faq']) {
        template_extract_block($template_main_menu, 'faq');
    }

   if(!$stats){
      include('../stats.php');
   }

    $param = array('{ALB_LIST_TGT}' => "index.php$cat_l",
        '{ALB_LIST_TITLE}' => $lang_main_menu['alb_list_title'],
        '{ALB_LIST_LNK}' => $lang_main_menu['alb_list_lnk'],
        '{MY_GAL_TGT}' => "index.php?cat=$my_gallery_id",
        '{MY_GAL_TITLE}' => $lang_main_menu['my_gal_title'],
        '{MY_GAL_LNK}' => $lang_main_menu['my_gal_lnk'],
        '{MEMBERLIST_TGT}' => "usermgr.php",
        '{MEMBERLIST_TITLE}' => $lang_main_menu['memberlist_title'],
        '{MEMBERLIST_LNK}' => $lang_main_menu['memberlist_lnk'],
        '{MY_PROF_TGT}' => "profile.php?op=edit_profile",
        '{MY_PROF_LNK}' => $lang_main_menu['my_prof_lnk'],
        '{FAQ_TGT}' => "faq.php",
        '{FAQ_TITLE}' => $lang_main_menu['faq_title'],
        '{FAQ_LNK}' => $lang_main_menu['faq_lnk'],
        '{ADM_MODE_TGT}' => "admin.php?admin_mode=1&referer=$REFERER",
        '{ADM_MODE_TITLE}' => $lang_main_menu['adm_mode_title'],
        '{ADM_MODE_LNK}' => $lang_main_menu['adm_mode_lnk'],
        '{USR_MODE_TGT}' => "admin.php?admin_mode=0&referer=$REFERER",
        '{USR_MODE_TITLE}' => $lang_main_menu['usr_mode_title'],
        '{USR_MODE_LNK}' => $lang_main_menu['usr_mode_lnk'],
        '{UPL_PIC_TGT}' => "upload.php",
        '{UPL_PIC_TITLE}' => $lang_main_menu['upload_pic_title'],
        '{UPL_PIC_LNK}' => $lang_main_menu['upload_pic_lnk'],
        '{REGISTER_TGT}' => "register.php",
        '{STATS}' => $stats,
        '{REGISTER_TITLE}' => $lang_main_menu['register_title'],
        '{REGISTER_LNK}' => $lang_main_menu['register_lnk'],
        '{LOGIN_TGT}' => "login.php?referer=$REFERER",
        '{LOGIN_LNK}' => $lang_main_menu['login_lnk'],
        '{LOGOUT_TGT}' => "logout.php?referer=$REFERER",
        '{LOGOUT_LNK}' => $lang_main_menu['logout_lnk'] . " [" . USER_NAME . "]",
        '{LASTUP_TGT}' => "thumbnails.php?album=lastup$cat_l2",
        '{LASTUP_LNK}' => $lang_main_menu['lastup_lnk'],
        '{LASTCOM_TGT}' => "thumbnails.php?album=lastcom$cat_l2",
        '{LASTCOM_LNK}' => $lang_main_menu['lastcom_lnk'],
        '{TOPN_TGT}' => "thumbnails.php?album=topn$cat_l2",
        '{TOPN_LNK}' => $lang_main_menu['topn_lnk'],
        '{TOPRATED_TGT}' => "thumbnails.php?album=toprated$cat_l2",
        '{TOPRATED_LNK}' => $lang_main_menu['toprated_lnk'],
        '{FAV_TGT}' => "thumbnails.php?album=favpics",
        '{FAV_LNK}' => $lang_main_menu['fav_lnk'],
        '{SEARCH_TGT}' => "search.php",
        '{SEARCH_LNK}' => $lang_main_menu['search_lnk'],
        );

I added the if stats bla bla bla part and then a '{STATS}' value.. still, no result.. plz help T_T.. (YES; I've searched, but I could just find headers faqs..... )
« Last Edit: October 20, 2004, 08:14:21 am by GauGau »
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website

First, does your stats.php file have any echo or print statements?  If so it won't work correctly.  Second, does stats.php dump all the HTML code into the variable $stats?  Third, doesn't look like you added {STATS} to any of the HTML in theme.php.  You need to add HTML to $template_main_menu, since that's where you're trying to add your stats to.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

MeTaL_oRgY

  • Coppermine newbie
  • Offline Offline
  • Posts: 5

well, now it doesn't appear on the top of the page, and the {STATS} from the template is gone, which probably means that it IS including the file... but now, another problem.... it DO has echo statements... here's stats.php:

Code: [Select]
<?php
    $dbhost
="localhost";
    
$dbusuario="xxxxxx";
    
$dbpassword="xxxxxx";
    
$db="xxxxxx";

    
$conexion mysql_connect($dbhost,$dbusuario,$dbpassword);
    
mysql_select_db($db$conexion);

    
$tiempo=5;

    global 
$REMOTE_ADDR;
    
$ahora time();
    
$limite $ahora-$tiempo*60;
    
mysql_query("DELETE FROM visitantes_activos WHERE fecha < "$limite);

    
$a=mysql_query("select * from visitas");
    
$b=mysql_fetch_row($a);
    if (!
$b[0]) { mysql_query("INSERT INTO visitas values ('$h[0]','0','0','0')"); $b[3]=0; }
    
$b[3]++;
    
mysql_query("UPDATE visitas set impresiones='$b[3]'");

    
$a mysql_query("SELECT * FROM visitantes_activos where ip = '"$REMOTE_ADDR ."'");
    
$b mysql_fetch_row($a);

    if (
$b[0]) {
           
mysql_query("UPDATE visitantes_activos SET fecha = '$ahora' where ip = '"$REMOTE_ADDR ."'");
    }
    else {
        
mysql_query("INSERT INTO visitantes_activos values ('"$REMOTE_ADDR ."','$ahora')");

        
$c mysql_query("SELECT totales FROM visitas");
        
$d mysql_fetch_row($c);
        
$g mysql_query("SELECT curdate()");
        
$h mysql_fetch_row($g);

        
$d[0]++;
        
mysql_query("UPDATE visitas SET totales = '$d[0]'");

        
$i mysql_query("SELECT fecha,hoy FROM visitas");
        
$j mysql_fetch_row($i);

        if (
$h[0]==$j[0]) {
            
$j[1]++;
        }

        else {
            
$j[1]=1;
            
mysql_query("UPDATE visitas SET fecha = '$h[0]'");
        }
        
mysql_query("UPDATE visitas set hoy='$j[1]'");
    }
    
$z mysql_query("SELECT totales,hoy,impresiones FROM visitas");
    
$visitas mysql_fetch_row($z);

    
$x $a=mysql_query("SELECT COUNT(*) FROM visitantes_activos");
    
$activos mysql_fetch_row($x);

    echo 
"<b>Visitas:</b> $visitas[0]<br />";
    echo 
"<b>Hoy:</b> $visitas[1]<br />";
    echo 
"<b>Online:</b> $activos[0]<br />";
    echo 
"<b>Impresiones:</b> $visitas[2]";
?>

is there another way of printing em withouth using echo? or how do I add em... BTW, the way I fixed the problem is:

Added a {stats} here:

Code: [Select]
    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{STATS}' => $stats,
        );

And added this

Code: [Select]
   if($stats){
      include('../stats.php');
   }

to function theme_main_menu()

is this wrong?... how can I include it.. someone plz help :(!
Logged

MeTaL_oRgY

  • Coppermine newbie
  • Offline Offline
  • Posts: 5

Neeeverr mind.. I gived up and used an iframe....
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 20 queries.