Rotating banner script

PHP coding talk.

Moderator: Moderators

Rotating banner script

Postby kvfb97 on Tue May 24, 2005 9:36 am

Hi,

I just created a rotating banner script for phpBB. It all seems to work fine. But It only works on certain pages, e.g. index.php, but doesnt work on alot of other pages, e.g. viewtopic.php.

Here is my page header (banner code on line 81):
Code: Select all
<?php
/***************************************************************************
*                              page_header.php
*                            -------------------
*   begin                : Saturday, Feb 13, 2001
*   copyright            : (C) 2001 The phpBB Group
*   email                : support@phpbb.com
*
*   $Id: page_header.php,v 1.106.2.23 2004/07/11 16:46:19 acydburn Exp $
*
*
***************************************************************************/

/***************************************************************************
*
*   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.
*
***************************************************************************/

if ( !defined('IN_PHPBB') )
{
   die("Hacking attempt");
}

define('HEADER_INC', TRUE);

//
// gzip_compression
//
$do_gzip_compress = FALSE;
if ( $board_config['gzip_compress'] )
{
   $phpver = phpversion();

   $useragent = (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : getenv('HTTP_USER_AGENT');

   if ( $phpver >= '4.0.4pl1' && ( strstr($useragent,'compatible') || strstr($useragent,'Gecko') ) )
   {
      if ( extension_loaded('zlib') )
      {
         ob_start('ob_gzhandler');
      }
   }
   else if ( $phpver > '4.0' )
   {
      if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') )
      {
         if ( extension_loaded('zlib') )
         {
            $do_gzip_compress = TRUE;
            ob_start();
            ob_implicit_flush(0);

            header('Content-Encoding: gzip');
         }
      }
   }
}

//
// Smartor's Visit Counter MOD
//
$visit_counter = $board_config['visit_counter'];

if( $userdata['session_start'] >= (time() - 1) )
{
   $sql = "UPDATE " . CONFIG_TABLE . "
         SET config_value = '" . ($visit_counter + 1) . "'
         WHERE config_name = 'visit_counter'";
   if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not update counter information', '', __LINE__, __FILE__, $sql);
   }

   $visit_counter++;
}

// banner

$codes = array(
    "<img src=templates/ca_aphrodite/images/logo1.jpg>",
    "<img src=templates/ca_aphrodite/images/logo2.jpg>",
    "<img src=templates/ca_aphrodite/images/logo3.jpg>",
    "<img src=templates/ca_aphrodite/images/logo7.jpg>",
    "<img src=templates/ca_aphrodite/images/logo8.jpg>",
    "<img src=templates/ca_aphrodite/images/logo9.jpg>"
);

shuffle($codes);

$number=1;

while(list(, $code) = each($codes)) {
   if ($i>=$number) {
      break;
      }
   
   $template->assign_block_vars('topbanner', array(
      'BANNERIMAGE' => $code)
   );
   
   $i++;
}

// radio stats

include('config_radio.php');

$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
   if(!$scfp) {
      $scsuccs=1;
   }
   if($scsuccs!=1){
      fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
      while(!feof($scfp)) {
         $page .= fgets($scfp, 1000);
      }

$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS");
$y=0;
   while($loop[$y]!=''){
      $pageed = ereg_replace(".*<$loop[$y]>", "", $page);
      $scphp = strtolower($loop[$y]);
      $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
         if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
            $$scphp = urldecode($$scphp);
            $y++;
         }

$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
  $t=$r-1;
  $playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
  $playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
  $song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
  $song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
  $song[$t] = urldecode($song[$t]);
  $dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
  $dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info

fclose($scfp);
}

//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
$radio = '<tr>
<td colspan="3" class="forum-buttons2" valign="middle">
<font color="#FF1010">'.$servertitle.'</font> is now playing <font color="#FF1010">'.$song[0].'</font> on Loyalist Bears Radio
</td>
</tr>';
}
if($streamstatus == "0")
{
//you may edit the html below, make sure to keep variable intact
$radio = '';
}

$template->assign_block_vars('radio', array(
   'STATS' => $radio)
);

// Get teams (top 5)

$query="SELECT * FROM `phpbb_table` ORDER BY pts DESC Limit 0,5";

$result=mysql_query($query);

while ($row = mysql_fetch_assoc($result)) {
   {
      $id = $row['id'];
      $team = $row['team'];
      $gd = $row['gd'];
      $p = $row['p'];
      $pts = $row['pts'];

      $ia++;

      $template->assign_block_vars('tablespltop5', array(
         'ID' => $ia,
         'TEAM' => $team,
         'GD' => $gd,
         'P' => $p,
         'PTS' => $pts)
         );
      
   }
}

// Get teams

$query="SELECT * FROM `phpbb_table` ORDER BY pts DESC";

$result=mysql_query($query);

while ($row = mysql_fetch_assoc($result)) {
   {
      $id = $row['id'];
      $team = $row['team'];
      $gd = $row['gd'];
      $p = $row['p'];
      $pts = $row['pts'];

      $ib++;

      $template->assign_block_vars('tablespl', array(
         'ID' => $ib,
         'TEAM' => $team,
         'GD' => $gd,
         'P' => $p,
         'PTS' => $pts)
         );
      
   }
}

// Get teams
$sql = 'SELECT *, (ties + (wins * 3)) AS win_loss_percentage FROM ' . FSPORTS_TEAMS_TABLE . ' ORDER BY win_loss_percentage DESC';
// $sql = "SELECT * FROM " . FSPORTS_TEAMS_TABLE . " ORDER BY wins DESC;";
   if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, 'Error in getting percentages', '', __LINE__, __FILE__, $sql);
      }

$i=1;

while ( $row = $db->sql_fetchrow($result) )
   {
      $teamnameperc = $row['teamname'];
      $pts = ($row['wins'] * 3) + $row['ties'];
      $p = $row['wins'] + $row['losses'] + $row['ties'];
      $percentage_wins = $row['wins'];
      $percentage_losses = $row['losses'];
      $percentage_ties = $row['ties'];
      $win_loss_percentage = $row['win_loss_percentage'];
      settype($win_loss_percentage, string);
      $win_loss_percentage = substr($win_loss_percentage, 0, 4);
       
      $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
      $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

      $template->assign_block_vars('table', array(
         'ROW_NUMBER' => $i,
         'ROW_COLOR' => '#' . $row_color,
         'ROW_CLASS' => $row_class,
         'TEAMNAME' => $teamnameperc,
         'WINS' => $percentage_wins,
         'TIES' => $percentage_ties,
         'PTS' => $pts,
         'P' => $p,
         'LOSSES' => $percentage_losses,
         'PERCENTAGE' => $win_loss_percentage)
         );

         $i++;
   }

///
/// End win-loss percentage table
///

//
// Parse and show the overall header.
//
$template->set_filenames(array(
   'overall_header' => ( empty($gen_simple_header) ) ? 'overall_header.tpl' : 'simple_header.tpl')
);

//
   // Start Live Statistics Mod
   //
   
   $today_registered_users = 0;
   $yesterday_registered_users = 0;

   $today_time = time();
   $yesterday_time = $today_time - 86400;

   $day = create_date('d', $yesterday_time, $userdata['user_timezone']);
   $month = create_date('m', $yesterday_time, $userdata['user_timezone']);
   $year = create_date('Y', $yesterday_time, $userdata['user_timezone']);

   $y_day_from = strtotime($year.'-'.$month.'-'.$day.' 00:00:00');

   $day = create_date('d', $today_time, $userdata['user_timezone']);
   $month = create_date('m', $today_time, $userdata['user_timezone']);
   $year = create_date('Y', $today_time, $userdata['user_timezone']);

   $t_day_from = strtotime($year.'-'.$month.'-'.$day.' 00:00:00');

   $sql = "SELECT count(distinct user_id) as total_users FROM " . USERS_TABLE . "
   WHERE user_regdate >= $y_day_from
      AND user_regdate < $t_day_from
      AND user_id <> " . ANONYMOUS;
   if ( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, 'Could not get yesterday registered users', '', __LINE__, __FILE__, $sql);
   }

   while ( $row = $db->sql_fetchrow($result) )
   {
      $yesterday_registered_users = $row['total_users'];
   }

   $db->sql_freeresult($result);

   $sql = "SELECT count(distinct user_id) as total_users FROM " . USERS_TABLE . "
      WHERE user_regdate >= $t_day_from
      AND user_id <> " . ANONYMOUS;
   if ( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, 'Could not get today registered users', '', __LINE__, __FILE__, $sql);
   }

   while ( $row = $db->sql_fetchrow($result) )
   {
      $today_registered_users = $row['total_users'];
   }

   $db->sql_freeresult($result);
      
   //
   // End Live Statistics Mod
   //

//
// Generate logged in/logged out status
//
if ( $userdata['session_logged_in'] )
{
   $u_login_logout = 'login.'.$phpEx.'?logout=true&amp;sid=' . $userdata['session_id'];
   $l_login_logout = $lang['Logout'] . ' [ ' . $userdata['username'] . ' ]';
}
else
{
   $u_login_logout = 'login.'.$phpEx;
   $l_login_logout = $lang['Login'];
}

$s_last_visit = ( $userdata['session_logged_in'] ) ? create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']) : '';

//
// Get basic (usernames + totals) online
// situation
//
$logged_visible_online = 0;
$logged_hidden_online = 0;
$guests_online = 0;
$online_userlist = '';
$l_online_users = '';

if (defined('SHOW_ONLINE'))
{

   $user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
   $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip, s.is_robot
      FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
      WHERE u.user_id = s.session_user_id
         AND s.session_time >= ".( time() - 300 ) . "
         $user_forum_sql
      ORDER BY u.username ASC, s.session_ip ASC";
   if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);
   }

   $userlist_ary = array();
   $userlist_visible = array();

   $prev_user_id = 0;
   $prev_user_ip = $prev_session_ip = '';

   while( $row = $db->sql_fetchrow($result) )
   {
      // User is logged in and therefor not a guest
      if ( $row['session_logged_in'] )
      {
         // Skip multiple sessions for one user
         if ( $row['user_id'] != $prev_user_id )
         {
            $style_color = '';
            if ( $row['user_level'] == ADMIN )
            {
               $row['username'] = '<b>' . $row['username'] . '</b>';
               $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
            }
            else if ( $row['user_level'] == MOD )
            {
               $row['username'] = '<b>' . $row['username'] . '</b>';
               $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
            }

#======================================================================= |
#==== Start: == Activity Mod Plus ====================================== |
#==== v1.0.9 =========================================================== |
#====
            if ($row['user_session_page'] == PAGE_ACTIVITY || $row['user_session_page'] == PAGE_PLAYING_GAMES)
               {
            $row['username'] = '<b>'. $row['username'] .'</b>';
            $style_color = 'style="color:#'. str_replace('#', '', $board_config['ina_online_list_color']) .'"';
               }
#====
#==== Author: aUsTiN [austin@phpbb-amod.com] [http://phpbb-amod.com] === |
#==== End: ==== Activity Mod Plus ====================================== |   
#======================================================================= |

            if ( $row['user_allow_viewonline'] )
            {
               $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
               $logged_visible_online++;
            }
            else
            {
               $user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
               $logged_hidden_online++;
            }

            if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
            {
               $online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
            }
         }

         $prev_user_id = $row['user_id'];
      }
      else
      {
         // Skip multiple sessions for one user
         if ( $row['session_ip'] != $prev_session_ip )
         {
            if( $row['is_robot'] )
            {
               $online_userlist = $row['is_robot'] . (($online_userlist!='') ? ', ' : '') . $online_userlist;
            }
         }
      }

      $prev_session_ip = $row['session_ip'];
   }
   $db->sql_freeresult($result);

   if ( empty($online_userlist) )
   {
      $online_userlist = $lang['None'];
   }
   $online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist;

   $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;

   if ( $total_online_users > $board_config['record_online_users'])
   {
      $board_config['record_online_users'] = $total_online_users;
      $board_config['record_online_date'] = time();

      $sql = "UPDATE " . CONFIG_TABLE . "
         SET config_value = '$total_online_users'
         WHERE config_name = 'record_online_users'";
      if ( !$db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql);
      }

      $sql = "UPDATE " . CONFIG_TABLE . "
         SET config_value = '" . $board_config['record_online_date'] . "'
         WHERE config_name = 'record_online_date'";
      if ( !$db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql);
      }
   }

   if ( $total_online_users == 0 )
   {
      $l_t_user_s = $lang['Online_users_zero_total'];
   }
   else if ( $total_online_users == 1 )
   {
      $l_t_user_s = $lang['Online_user_total'];
   }
   else
   {
      $l_t_user_s = $lang['Online_users_total'];
   }

   if ( $logged_visible_online == 0 )
   {
      $l_r_user_s = $lang['Reg_users_zero_total'];
   }
   else if ( $logged_visible_online == 1 )
   {
      $l_r_user_s = $lang['Reg_user_total'];
   }
   else
   {
      $l_r_user_s = $lang['Reg_users_total'];
   }

   if ( $logged_hidden_online == 0 )
   {
      $l_h_user_s = $lang['Hidden_users_zero_total'];
   }
   else if ( $logged_hidden_online == 1 )
   {
      $l_h_user_s = $lang['Hidden_user_total'];
   }
   else
   {
      $l_h_user_s = $lang['Hidden_users_total'];
   }

   if ( $guests_online == 0 )
   {
      $l_g_user_s = $lang['Guest_users_zero_total'];
   }
   else if ( $guests_online == 1 )
   {
      $l_g_user_s = $lang['Guest_user_total'];
   }
   else
   {
      $l_g_user_s = $lang['Guest_users_total'];
   }

   $l_online_users = sprintf($l_t_user_s, $total_online_users);
   $l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
   $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
   $l_online_users .= sprintf($l_g_user_s, $guests_online);
}

//
// Obtain number of new private messages
// if user is logged in
//
if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) )
{
   if ( $userdata['user_new_privmsg'] )
   {
      $l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
      $l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);

      if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
      {
         $sql = "UPDATE " . USERS_TABLE . "
            SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
            WHERE user_id = " . $userdata['user_id'];
         if ( !$db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql);
         }

         $s_privmsg_new = 1;
         $icon_pm = $images['pm_new_msg'];
      }
      else
      {
         $s_privmsg_new = 0;
         $icon_pm = $images['pm_new_msg'];
      }
   }
   else
   {
      $l_privmsgs_text = $lang['No_new_pm'];

      $s_privmsg_new = 0;
      $icon_pm = $images['pm_no_new_msg'];
   }

   if ( $userdata['user_unread_privmsg'] )
   {
      $l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
      $l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
   }
   else
   {
      $l_privmsgs_text_unread = $lang['No_unread_pm'];
   }
}
else
{
   $icon_pm = $images['pm_no_new_msg'];
   $l_privmsgs_text = $lang['Login_check_pm'];
   $l_privmsgs_text_unread = '';
   $s_privmsg_new = 0;
}

//
// Generate HTML required for Mozilla Navigation bar
//
if (!isset($nav_links))
{
   $nav_links = array();
}

$nav_links_html = '';
$nav_link_proto = '<link rel="%s" href="%s" title="%s" />' . "\n";
while( list($nav_item, $nav_array) = @each($nav_links) )
{
   if ( !empty($nav_array['url']) )
   {
      $nav_links_html .= sprintf($nav_link_proto, $nav_item, append_sid($nav_array['url']), $nav_array['title']);
   }
   else
   {
      // We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
      while( list(,$nested_array) = each($nav_array) )
      {
         $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']);
      }
   }
}

// Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility
$l_timezone = explode('.', $board_config['board_timezone']);
$l_timezone = (count($l_timezone) > 1 && $l_timezone[count($l_timezone)-1] != 0) ? $lang[sprintf('%.1f', $board_config['board_timezone'])] : $lang[number_format($board_config['board_timezone'])];
//
// The following assigns all _common_ variables that may be used at any point
// in a template.
//
$template->assign_vars(array(
   'SITENAME' => $board_config['sitename'],
   'SITE_DESCRIPTION' => $board_config['site_desc'],
   'PAGE_TITLE' => $page_title,
   'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit),
   'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($board_config['default_dateformat'], time(), $board_config['board_timezone'])),
   'TOTAL_USERS_ONLINE' => $l_online_users,
   'LOGGED_IN_USER_LIST' => $online_userlist,
   'RECORD_USERS' => sprintf($lang['Record_online_users'], $board_config['record_online_users'], create_date($board_config['default_dateformat'], $board_config['record_online_date'], $board_config['board_timezone'])),
   'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
   'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
   'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new,

   'PRIVMSG_IMG' => $icon_pm,

   'L_USERNAME' => $lang['Username'],
   'L_PASSWORD' => $lang['Password'],
   'L_LOGIN_LOGOUT' => $l_login_logout,
   'L_LOGIN' => $lang['Login'],
   'L_LOG_ME_IN' => $lang['Log_me_in'],
   'L_AUTO_LOGIN' => $lang['Log_me_in'],
   'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']),
   'L_REGISTER' => $lang['Register'],
   'L_PROFILE' => $lang['Profile'],
   'L_SEARCH' => $lang['Search'],
   'L_PRIVATEMSGS' => $lang['Private_Messages'],
   'L_WHO_IS_ONLINE' => $lang['Who_is_Online'],
   'L_MEMBERLIST' => $lang['Memberlist'],
   'L_FAQ' => $lang['FAQ'],
   
   'L_TEAMNAME' => $lang['Teamname'],
   'L_WINS' => $lang['Wins'],
   'L_TIES' => $lang['ties'],
   'L_LOSSES' => $lang['Losses'],
   'L_PERCENTAGE' => $lang['FS_Percentage'],
   'L_GAMETIME' => $lang['gametime'],
   'L_HOMETEAM' => $lang['hometeam'],
   'L_AWAYTEAM' => $lang['awayteam'],
   'L_FSPORTSUSERNAME' => $lang['fsportsusername'],
   'L_POINTS' => $lang['points'],
   'L_POINTDIFF' => $lang['pointdiff'],
   'L_LEADERBOARD' => $lang['leaderboard_header'],
   'L_UPCOMING_GAMES' => $lang['upcoming_games_header'],
   'L_TEAM_WINNING_PERC' => $lang['teamwinperc_header'],
   'U_FSPORTS' => append_sid('fsports.'.$phpEx),
   'L_FSPORTS' => $lang['fsports'],
   'L_PREDICTIONSFOR' => $lang['predictionsfor'],
   'L_AWAYSCORE' => $lang['awayscore'],
   'L_HOMESCORE' => $lang['homescore'],
   'L_PASTGAMES' => $lang['pastgamesheader'],
   
   'L_USERGROUPS' => $lang['Usergroups'],
      
   'L_SEARCH_NEW' => $lang['Search_new'],
   'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'],
   'L_SEARCH_SELF' => $lang['Search_your_posts'],
   'L_WHOSONLINE_ADMIN' => sprintf($lang['Admin_online_color'], '<span style="color:#' . $theme['fontcolor3'] . '">', '</span>'),
   'L_WHOSONLINE_MOD' => sprintf($lang['Mod_online_color'], '<span style="color:#' . $theme['fontcolor2'] . '">', '</span>'),

   // Live Statistics Mod
   'TODAY_USERS' => $today_registered_users,
    'YESTERDAY_USERS' => $yesterday_registered_users,
    'GUESTS_ONLINE' => $guests_online,
    'REGGED_ONLINE' => $logged_visible_online,
    'U_SEND_PASSWORD' => append_sid("profile.$phpEx?mode=sendpassword"),
    // End Live Statistics Mod
   
    'NHOME' => $board_config['nextmatchhome'],
    'NAWAY' => $board_config['nextmatchaway'],
    'NDATE' => $board_config['nextmatchdate'],
    'NLEAGUE' => $board_config['nextmatchleague'],
   
    'LHOME' => $board_config['lastmatchhome'],
    'LHOMES' => $board_config['lastmatchhomescore'],
    'LAWAY' => $board_config['lastmatchaway'],
    'LAWAYS' => $board_config['lastmatchawayscore'],
    'LDATE' => $board_config['lastmatchdate'],
    'LLEAGUE' => $board_config['lastmatchleague'],
   
    'L_NEWS' => $lang['News'],
   
    'U_NEWS' => append_sid($board_config['news_base_url'] . $board_config['news_index_file']),
   
// Live Statistics Mod
      'L_LIVE_STATISTICS' => $lang['Live_Statistics'],
      'L_MEMBERS' => $lang['Live_Members'],
      'L_LATEST' => $lang['Live_Latest'],
      'L_NEW_TODAY' => $lang['Live_New_Today'],
      'L_NEW_YESTERDAY' => $lang['Live_New_Yesterday'],
      'L_MEMBERS_OVERALL' => $lang['Live_Overall'],
      'L_ONLINE_NOW' => $lang['Live_Online_Now'],
      'L_GUESTS' => $lang['Live_Guests'],
      'L_STATS' => $lang['Live_Stats'],
      'L_USER_RECORD' => $lang['Live_User_Record'],
      'L_TOTAL_POSTS' => $lang['Live_Total_Posts'],
      'L_ONLINE_MEMBERS' => $lang['Live_Online_Members'],
      'L_REMEMBER_ME' => $lang['Remember_me'],
      'L_SEND_PASSWORD' => $lang['Forgotten_password'],

   'U_SEARCH_UNANSWERED' => append_sid('search.'.$phpEx.'?search_id=unanswered'),
   'U_SEARCH_SELF' => append_sid('search.'.$phpEx.'?search_id=egosearch'),
   'U_SEARCH_NEW' => append_sid('search.'.$phpEx.'?search_id=newposts'),
   'U_INDEX' => append_sid('index.'.$phpEx),
   'U_REGISTER' => append_sid('profile.'.$phpEx.'?mode=register'),
   'U_PROFILE' => append_sid('profile.'.$phpEx.'?mode=editprofile'),
   'U_PRIVATEMSGS' => append_sid('privmsg.'.$phpEx.'?folder=inbox'),
   'U_PRIVATEMSGS_POPUP' => append_sid('privmsg.'.$phpEx.'?mode=newpm'),
   'U_SEARCH' => append_sid('search.'.$phpEx),
   'U_MEMBERLIST' => append_sid('memberlist.'.$phpEx),
   'U_MODCP' => append_sid('modcp.'.$phpEx),
   'U_FAQ' => append_sid('faq.'.$phpEx),
   'U_VIEWONLINE' => append_sid('viewonline.'.$phpEx),
   'U_LOGIN_LOGOUT' => append_sid($u_login_logout),
   'U_GROUP_CP' => append_sid('groupcp.'.$phpEx),
   
   #======================================================================= |
#==== Start: == Activity Mod Plus ====================================== |
#==== v1.0.9 =========================================================== |
#====
   'L_WHOSONLINE_GAMES'   => '<a href="'. append_sid('activity.'. $phpEx) .'"><font color="#'. str_replace('#', '', $board_config['ina_online_list_color']) .'">'. $board_config['ina_online_list_text'] .'</font></a>',
   'U_ACTIVITY'          => append_sid('activity.'.$phpEx),
   'L_ACTIVITY'          => $lang['Activity'],   
#====
#==== Author: aUsTiN [austin@phpbb-amod.com] [http://phpbb-amod.com] === |
#==== End: ==== Activity Mod Plus ====================================== |   
#======================================================================= |

'L_TOPLIST' => $lang['Toplist'],
'U_TOPLIST' => append_sid('toplist.'.$phpEx),

// :)

   'L_LOYALISTHISTORY' => $lang['LoyalistHistory'],
   'U_LOYALISTHISTORY' => append_sid('loaylisthistory.'.$phpEx),
   'L_DISASTER' => $lang['Disaster'],
   'U_DISASTER' => append_sid('disaster.'.$phpEx),
   'L_MAIN' => $lang['main'],
   'U_MAIN' => append_sid('main.'.$phpEx),
   'L_LOYALISINFO' => $lang['loyalistinfo'],
   'U_LOYALISTINFO' => append_sid('loyalistinfo.'.$phpEx),
   'L_FLUTENOTES' => $lang['flutenotes'],
   'U_FLUTENOTES' => append_sid('flutenotes.'.$phpEx),
   'L_HONNORSR' => $lang['honnorsr'],
   'U_HONNORSR' => append_sid('honnorsr.'.$phpEx),
   'L_TABLE' => $lang['table'],
   'U_TABLE' => append_sid('table.'.$phpEx),
   'L_DOWNLOADS' => $lang['downloads'],
   'U_DOWNLOADS' => append_sid('downloads.'.$phpEx),
   'L_LINKS' => $lang['links'],
   'U_LINKS' => append_sid('links.'.$phpEx),
   'L_ADVERT' => $lang['advert'],
   'U_ADVERT' => append_sid('advert.'.$phpEx),
   
   'L_KB' => $lang['KB_title'],
   'U_KB' => append_sid('kb.'.$phpEx),
         
   'L_CHAT' => $lang['Chat_Room'],
   'U_CHAT' => append_sid('chat.'.$phpEx),

   'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
   'S_CONTENT_ENCODING' => $lang['ENCODING'],
   'S_CONTENT_DIR_LEFT' => $lang['LEFT'],
   'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'],
   'S_TIMEZONE' => sprintf($lang['All_times'], $l_timezone),
   'S_LOGIN_ACTION' => append_sid('login.'.$phpEx),

   'T_HEAD_STYLESHEET' => $theme['head_stylesheet'],
   'T_BODY_BACKGROUND' => $theme['body_background'],
   'T_BODY_BGCOLOR' => '#'.$theme['body_bgcolor'],
   'T_BODY_TEXT' => '#'.$theme['body_text'],
   'T_BODY_LINK' => '#'.$theme['body_link'],
   'T_BODY_VLINK' => '#'.$theme['body_vlink'],
   'T_BODY_ALINK' => '#'.$theme['body_alink'],
   'T_BODY_HLINK' => '#'.$theme['body_hlink'],
   'T_TR_COLOR1' => '#'.$theme['tr_color1'],
   'T_TR_COLOR2' => '#'.$theme['tr_color2'],
   'T_TR_COLOR3' => '#'.$theme['tr_color3'],
   'T_TR_CLASS1' => $theme['tr_class1'],
   'T_TR_CLASS2' => $theme['tr_class2'],
   'T_TR_CLASS3' => $theme['tr_class3'],
   'T_TH_COLOR1' => '#'.$theme['th_color1'],
   'T_TH_COLOR2' => '#'.$theme['th_color2'],
   'T_TH_COLOR3' => '#'.$theme['th_color3'],
   'T_TH_CLASS1' => $theme['th_class1'],
   'T_TH_CLASS2' => $theme['th_class2'],
   'T_TH_CLASS3' => $theme['th_class3'],
   'T_TD_COLOR1' => '#'.$theme['td_color1'],
   'T_TD_COLOR2' => '#'.$theme['td_color2'],
   'T_TD_COLOR3' => '#'.$theme['td_color3'],
   'T_TD_CLASS1' => $theme['td_class1'],
   'T_TD_CLASS2' => $theme['td_class2'],
   'T_TD_CLASS3' => $theme['td_class3'],
   'T_FONTFACE1' => $theme['fontface1'],
   'T_FONTFACE2' => $theme['fontface2'],
   'T_FONTFACE3' => $theme['fontface3'],
   'T_FONTSIZE1' => $theme['fontsize1'],
   'T_FONTSIZE2' => $theme['fontsize2'],
   'T_FONTSIZE3' => $theme['fontsize3'],
   'T_FONTCOLOR1' => '#'.$theme['fontcolor1'],
   'T_FONTCOLOR2' => '#'.$theme['fontcolor2'],
   'T_FONTCOLOR3' => '#'.$theme['fontcolor3'],
   'T_SPAN_CLASS1' => $theme['span_class1'],
   'T_SPAN_CLASS2' => $theme['span_class2'],
   'T_SPAN_CLASS3' => $theme['span_class3'],

'VISIT_COUNTER' => sprintf($lang['Visit_counter'], $visit_counter),

   'NAV_LINKS' => $nav_links_html)
   


);

//
// Login box?
//
if ( !$userdata['session_logged_in'] )
{
   $template->assign_block_vars('switch_user_logged_out', array());
}
else
{
   $template->assign_block_vars('switch_user_logged_in', array());

   if ( !empty($userdata['user_popup_pm']) )
   {
      $template->assign_block_vars('switch_enable_pm_popup', array());
   }
}

// Add no-cache control for cookies if they are set
//$c_no_cache = (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data'])) ? 'no-cache="set-cookie", ' : '';

// Work around for "current" Apache 2 + PHP module which seems to not
// cope with private cache control setting
if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2'))
{
   header ('Cache-Control: no-cache, pre-check=0, post-check=0');
}
else
{
   header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header ('Expires: 0');
header ('Pragma: no-cache');

$template->pparse('overall_header');

?>


And my overall_header.tpl file:
Code: Select all
<?php 

ob_start(); 

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="Author" content="http://www.phpbbstyles.com" />
{META}
{NAV_LINKS}
<title>{SITENAME} :: {PAGE_TITLE}</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">

<link rel="stylesheet" href="templates/ca_aphrodite/style.css" type="text/css" />
<script language="javascript" type="text/javascript" src="templates/ca_aphrodite/scripts.js"></script>
{CA_INLINE_CSS}
<!-- IE conditional comments: http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp -->
<!--[if IE]>
<style type="text/css">
/* IE hack to emulate the :hover & :focus pseudo-classes
   Add the selectors below that required the extra attributes */
.row1h, .row1h-new { behavior: url("templates/ca_aphrodite/pseudo-hover.htc"); }
</style>
<![endif]-->
<SCRIPT LANGUAGE="Javascript">
var win = null;
function Gk_PopTart(mypage,myname,w,h,scroll)
{
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings = 'height=500,width=750,top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes';
  win = window.open(mypage,myname,settings);
}
</SCRIPT>
<script>
function hidestatus(){
window.status=''
return true
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover=hidestatus
document.onmouseout=hidestatus
</script>
</head>
<body onload="PreloadFlag = true;">
<a name="top"></a>
<table cellspacing="0" width="100%" id="forum">
<tr>
   <td class="forum-header" align="left" colspan="2">
   
<!-- BEGIN topbanner -->
{topbanner.BANNERIMAGE}
<!-- END topbanner -->
   
   </td>
   <td align="center" class="forum-header header-search" valign="center">
      {VISIT_COUNTER}
   </td>
</tr>
<tr>
   <td colspan="3" class="forum-buttons" valign="middle">
            <!-- BEGIN switch_user_logged_out -->
            <a href="{U_REGISTER}">{L_REGISTER}</a> •
            <!-- END switch_user_logged_out -->
            <!-- BEGIN switch_user_logged_in -->
            <a href="{U_PROFILE}">{L_PROFILE}</a> •
            <a href="{U_PRIVATEMSGS}">{L_PRIVATEMSGS}</a> •
            <!-- END switch_user_logged_in -->
            <a href="{U_SEARCH}">{L_SEARCH}</a> •
            <a href="{U_FAQ}">{L_FAQ}</a> •
            <a href="{U_MEMBERLIST}">{L_MEMBERLIST}</a> •
            <a href="{U_GROUP_CP}">{L_USERGROUPS}</a> •
            <a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a>
      </td>
</tr>

<!-- BEGIN radio -->
{radio.STATS}
<!-- END radio -->

<tr>
   <td colspan="2" id="content" width="100%" valign="top">

   <!-- BEGIN switch_user_logged_in -->
   <div class="popup{PRIVMSG_IMG}"><a href="{U_PRIVATEMSGS}">{PRIVATE_MESSAGE_INFO}</a></div>
   <!-- END switch_user_logged_in -->
   
<table class="forumline" width="100%" cellspacing="0">
<tr>
   <td class="row-header"><span>Rangers FC - Scottish Champions 2004/2005</span></td>
</tr>
<tr>
   <td class="row1g gen">
      <img src="http://news.bbc.co.uk/media/images/41173000/jpg/_41173699_rangers.jpg" />&nbsp;<img src="http://news.bbc.co.uk/media/images/41173000/jpg/_41173689_fans.jpg" />
   </td>
</tr>
<tr>
   <td class="cat"><span class="redtext"><b>Dry Your Eyes m8 <img src="images/smiles/eusa_whistle.gif" /> - Follow... Follow...</b></span></td>
</tr>
</table>
   
<?php 

$temppage = ob_get_contents(); 
ob_end_clean(); 

global $HTTP_GET_VARS, $HTTP_SERVER_VARS; 

if ( !isset($HTTP_GET_VARS['dlcode']) && (!strpos('viewtopic.', $HTTP_SERVER_VARS['REQUEST_URI']) || !strpos('privmsgs.', $HTTP_SERVER_VARS['REQUEST_URI'])) ) 

   print($temppage); 

?>


Hope you can help.

Thanks
Robert

//EDIT - http://www.loyalistbears.co.uk - My site with the error.
Tip: Don't argue with idiots, they'll drag you down to their level and beat you with experience.
User avatar
kvfb97
Registered User
Registered User
 
Posts: 1774
Joined: Mon Aug 02, 2004 8:18 am
Location: Northern Ireland, UK

Postby UseLess on Tue May 24, 2005 11:14 am

Greetings,

Try this;

changes for 'page_header.php'

Code: Select all
// banner 
$codes = array( 
   "<img src=templates/ca_aphrodite/images/logo1.jpg>", 
   "<img src=templates/ca_aphrodite/images/logo2.jpg>", 
   "<img src=templates/ca_aphrodite/images/logo3.jpg>", 
   "<img src=templates/ca_aphrodite/images/logo7.jpg>", 
   "<img src=templates/ca_aphrodite/images/logo8.jpg>", 
   "<img src=templates/ca_aphrodite/images/logo9.jpg>" 
); 

$template->assign_vars(array( 
   'BANNERIMAGE' => $codes[mt_rand(0,count($codes)-1)]
));


changes for 'overall_header.tpl';

[code start="57"]<td class="forum-header" align="left" colspan="2">
{BANNERIMAGE}
</td>[/code]
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby kvfb97 on Tue May 24, 2005 12:25 pm

Perfect! Thanks
Tip: Don't argue with idiots, they'll drag you down to their level and beat you with experience.
User avatar
kvfb97
Registered User
Registered User
 
Posts: 1774
Joined: Mon Aug 02, 2004 8:18 am
Location: Northern Ireland, UK

Postby UseLess on Tue May 24, 2005 12:44 pm

Greetings,

You welcome.

There is another change you could make to the script and that is to get the list of files automatically that way if ever you change or add logos you don't need to edit the file.

I'm sure there's a script kicking around this site somewhere to do just that...
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby kvfb97 on Tue May 24, 2005 1:18 pm

[quote user="UseLess" post="36168"]Greetings,

You welcome.

There is another change you could make to the script and that is to get the list of files automatically that way if ever you change or add logos you don't need to edit the file.

I'm sure there's a script kicking around this site somewhere to do just that...[/quote]

I could do that. Just link it up to the ACP and the DB. But too complicated, easier to just edit the file lol
Tip: Don't argue with idiots, they'll drag you down to their level and beat you with experience.
User avatar
kvfb97
Registered User
Registered User
 
Posts: 1774
Joined: Mon Aug 02, 2004 8:18 am
Location: Northern Ireland, UK

Postby UseLess on Tue May 24, 2005 2:08 pm

Greetings,

No I think you misunderstand what I was getting at, so consider this;

domain.co.uk/forum/images/banners contains the banners you want to rotate through

alter page header so that is does an auto dir on the above folder and gets the filenames into an array, you then just choose a random one... therefore no need to add anything to the ACP, and also no need to edit anything once the alterations are made. All you then have to do is dump images into the directory and the script handles them.

i.e. replace this;

Code: Select all
// banner   
$codes = array(   
  "<img src=templates/ca_aphrodite/images/logo1.jpg>",   
  "<img src=templates/ca_aphrodite/images/logo2.jpg>",   
  "<img src=templates/ca_aphrodite/images/logo3.jpg>",   
  "<img src=templates/ca_aphrodite/images/logo7.jpg>",   
  "<img src=templates/ca_aphrodite/images/logo8.jpg>",   
  "<img src=templates/ca_aphrodite/images/logo9.jpg>"   
);   

$template->assign_vars(array(   
   'BANNERIMAGE' => $codes[mt_rand(0,count($codes)-1)] 
));


with this;

Code: Select all
// Banner
//
// Path to banner image dir which is relative to the forum root...
// i.e. http://www.loyalistbears.co.uk/phpbb13/images/banners/
//
$banner_filedir = 'images/banners/';
$banner_files = array();

$allowed_ext = array('gif', 'png', 'jpg', 'jpeg');

$dir = @opendir($banner_filedir); 

while(($file = @readdir($dir)) !== false) 

   $fileinfo = pathinfo($file);
   $file_ext = strtolower($fileinfo['extension']);

   if($file !== '.' && $file !== '..' && !is_dir($file) && in_array($file_ext, $allowed_ext) ) 
   { 
      $banner_files[] = $file;
   } 

@closedir($dir);

$template->assign_vars(array(   
   'BANNERIMAGE' => $banner_files[mt_rand(0,count($banner_files)-1)] 
));
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby kvfb97 on Tue May 24, 2005 2:18 pm

Aha. I get you now. And its alot handier. Thank you very much!

but one slight problem... you forgot to add the img tag... i added it but i think you can tidy it up a bit? am i right..?

Code: Select all
// Banner 
// 
// Path to banner image dir which is relative to the forum root... 
// i.e. http://www.loyalistbears.co.uk/phpbb13/images/banners/ 
// 
$banner_filedir = 'images/banners/'; 
$banner_files = array(); 

$allowed_ext = array('gif', 'png', 'jpg', 'jpeg'); 

$dir = @opendir($banner_filedir);   

while(($file = @readdir($dir)) !== false)   
{   
   $fileinfo = pathinfo($file); 
   $file_ext = strtolower($fileinfo['extension']); 

   if($file !== '.' && $file !== '..' && !is_dir($file) && in_array($file_ext, $allowed_ext) )   
   {   
       $banner_files[] = $file; 
   }   
}   
@closedir($dir); 

$template->assign_vars(array(     
  'BANNERIMAGE' => '<img src='.$banner_filedir.$banner_files[mt_rand(0,count($banner_files)-1)].' />')
);


Thanks for your great help btw!
Tip: Don't argue with idiots, they'll drag you down to their level and beat you with experience.
User avatar
kvfb97
Registered User
Registered User
 
Posts: 1774
Joined: Mon Aug 02, 2004 8:18 am
Location: Northern Ireland, UK

Postby UseLess on Tue May 24, 2005 2:37 pm

Greetings,

Yep, busy cooking and waiting rather impatiently for my apple crumble to be cooked... ;)

Anyway try this;

Code: Select all
// Banner
//
// Path to banner image dir which is relative to the forum root...
// i.e. http://www.loyalistbears.co.uk/phpbb13/images/banners/
//
$banner_filedir = 'images/banners/';
$banner_files = array();

$allowed_ext = array('gif', 'png', 'jpg', 'jpeg');

$dir = @opendir($banner_filedir); 

while(($file = @readdir($dir)) !== false) 

   $fileinfo = pathinfo($file);
   $file_ext = strtolower($fileinfo['extension']);

   if($file !== '.' && $file !== '..' && !is_dir($file) && in_array($file_ext, $allowed_ext) ) 
   { 
      $banner_files[] = $banner_filedir . $file;
   } 

@closedir($dir);

$template->assign_vars(array(   
   'BANNERIMAGE' => '<img src="' . $banner_files[mt_rand(0,count($banner_files)-1)] . '" border="0" />'; 
));
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby kvfb97 on Tue May 24, 2005 2:53 pm

Thanks m8 :D

Ill let you get back to your cooking ;)
Tip: Don't argue with idiots, they'll drag you down to their level and beat you with experience.
User avatar
kvfb97
Registered User
Registered User
 
Posts: 1774
Joined: Mon Aug 02, 2004 8:18 am
Location: Northern Ireland, UK

Postby beasty1711 on Fri Jan 06, 2006 9:46 am

hi,
sorry to dig up an old thread, but i'm trying to get this banner thing to work...

Ive put all of useless's code into page_header.php and created the banners folder with an image in it it..
but nothing gets displayed on my page..

is there some other code that i need to put in somewhere?
cheers

Pete
beasty1711
Registered User
Registered User
 
Posts: 1
Joined: Fri Jan 06, 2006 9:30 am

Postby kvfb97 on Fri Jan 06, 2006 10:27 am

In overall_header.tpl, you need to add {BANNERIMAGE} where the image is in the header.
Tip: Don't argue with idiots, they'll drag you down to their level and beat you with experience.
User avatar
kvfb97
Registered User
Registered User
 
Posts: 1774
Joined: Mon Aug 02, 2004 8:18 am
Location: Northern Ireland, UK

Help for putting ads on a forum!

Postby almiso on Sat Jan 21, 2006 3:19 pm

How is this script exactly work and how would you go about of installing this script of a server!

Almiso
I don't know how to give up!
almiso
Registered User
Registered User
 
Posts: 1
Joined: Sat Jan 21, 2006 3:05 pm
Location: Canada

Postby kvfb97 on Sat Jan 21, 2006 3:36 pm

Do this:
Code: Select all
#
#-----[ OPEN ]------------------------------------------------------------
#
includes/page_header.php

#
#-----[ FIND ]------------------------------------------------------------
#
define('HEADER_INC', TRUE);

#
#-----[ AFTER, ADD ]------------------------------------------------------------
#
// Banner
//
// Path to banner image dir which is relative to the forum root...
// i.e. http://www.loyalistbears.co.uk/phpbb13/images/banners/
//
$banner_filedir = 'images/banners/';
$banner_files = array();

$allowed_ext = array('gif', 'png', 'jpg', 'jpeg');

$dir = @opendir($banner_filedir); 

while(($file = @readdir($dir)) !== false) 

   $fileinfo = pathinfo($file);
   $file_ext = strtolower($fileinfo['extension']);

   if($file !== '.' && $file !== '..' && !is_dir($file) && in_array($file_ext, $allowed_ext) ) 
   { 
      $banner_files[] = $banner_filedir . $file;
   } 

@closedir($dir);

$template->assign_vars(array(   
   'BANNERIMAGE' => '<img src="' . $banner_files[mt_rand(0,count($banner_files)-1)] . '" border="0" />'; 
));

#
#-----[ OPEN ]------------------------------------------------------------
# Apply this to all your styles
templates/ca_aphrodite/overall_header.tpl

#
#-----[ FIND ]------------------------------------------------------------
# Some templates may be different
<img src="templates/ca_aphrodite/images/logo.gif" height="63" alt="{L_INDEX}" />

#
#-----[ REPLACE WITH ]------------------------------------------------------------
#
{BANNERIMAGE}
Tip: Don't argue with idiots, they'll drag you down to their level and beat you with experience.
User avatar
kvfb97
Registered User
Registered User
 
Posts: 1774
Joined: Mon Aug 02, 2004 8:18 am
Location: Northern Ireland, UK

Postby CrashDaddy on Sat Mar 31, 2007 3:28 pm

Thank you very much, kvfb97! Your instructions are succinct and easy to implement. Best of all it works! Image
CrashDaddy
Registered User
Registered User
 
Posts: 3
Joined: Sat Mar 31, 2007 3:20 pm

Postby CrashDaddy on Sat Mar 31, 2007 3:31 pm

What's up with my sig?
CrashDaddy
Registered User
Registered User
 
Posts: 3
Joined: Sat Mar 31, 2007 3:20 pm

Next

Return to PHP Programming

Who is online

Users browsing this forum: No registered users and 1 guest