1

Topic: punBB announcements: only on home page

Is it possible to have the announcement displayed only on the "home" page of my forums?

I try this but when i change header.php code the announcement will not show anywhere.
I use cleane 1.1.4 punbb version

Thanks for any help

Re: punBB announcements: only on home page

It should work. Did you read the whole topic? The code I posted in the beginning of the topic was wrong.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3

Re: punBB announcements: only on home page

Rickard wrote:

It should work. Did you read the whole topic? The code I posted in the beginning of the topic was wrong.

Yes i read whole topic ,and use bouth code

First code announcement still display on all forum
Second announcement will not show anywhere

Re: punBB announcements: only on home page

Could you post your complete header.php?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5

Re: punBB announcements: only on home page

Rickard wrote:

Could you post your complete header.php?

why not if this help you

<?php
/***********************************************************************

  Copyright (C) 2002, 2003, 2004  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB 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.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU G>eneral Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/


// Send no-cache headers
//header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Expires: Thu, 21 Jul 1977 07:30:00 GMT');    // When yours truly first set eyes on this world! :)
header('Pragma: no-cache');


// Load the main template
$fp = fopen($pun_root.'include/template/main.tpl', 'r');
$tpl_main = trim(fread($fp, filesize($pun_root.'include/template/main.tpl')));
fclose($fp);


// START SUBST - <pun_content_direction>
$tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
// END SUBST - <pun_content_direction>


// START SUBST - <pun_char_encoding>
$tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);
// END SUBST - <pun_char_encoding>


// START SUBST - <pun_head>
ob_start();

if (isset($destination))
    echo '<meta http-equiv="refresh" content="'.$delay.';URL='.$destination.'">'."\n";
else if (isset($validate_form))
{
    // Output javascript(s)
    // With a quick and dirty hack to not disable submit buttons if user agent is Opera (since Opera
    // refused to re-enable the button if we submit and then go back to this page)

?>
<script type="text/javascript">
<!--
function process_form(theform)
{
<?php

    if (isset($element_names))
    {
        echo "\t".'var element_names = new Object()'."\n";

        while (list($elem_orig, $elem_trans) = @each($element_names))
            echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes($elem_trans).'"'."\n";

?>

    // Check for required elements
    if (document.images) {
        for (i = 0; i < theform.length; ++i) {
            if (theform.elements[i].name.substring(0, 4) == "req_") {
                if ((theform.elements[i].type=="text" || theform.elements[i].type=="textarea" || theform.elements[i].type=="password" || theform.elements[i].type=="file") && theform.elements[i].value=='') {
                    alert("\"" + element_names[theform.elements[i].name] + "\" <?php echo $lang_common['required field'] ?>")
                    return false
                }
            }
        }
    }

<?php

    }

    if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera'))
    {

?>
    // Disable any submit buttons we find
    if (document.all || document.getElementById) {
        for (i = 0; i < theform.length; ++i) {
            var elem = theform.elements[i]
            if (elem.type.toLowerCase() == "submit")
                elem.disabled = true
        }
        return true
    }

<?php

    }

?>
    return true
}
// -->
</script>
<?php

}

$style = (isset($cur_user)) ? $cur_user['style'] : $pun_config['o_default_style'];

?>
<title><?php echo $page_title ?></title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $style.'.css' ?>">
<?php

$tpl_temp = trim(ob_get_contents());
$tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <pun_head>


// START SUBST - <pun_body>
ob_start();

if (isset($form_name) && isset($focus_element))
    echo ' onLoad="document.getElementById(\''.$form_name.'\').'.$focus_element.'.focus()"';

$tpl_temp = ob_get_contents();
$tpl_main = str_replace('<pun_body>', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <pun_body>


// START SUBST - <pun_title>
$tpl_main = str_replace('<pun_title>', pun_htmlspecialchars($pun_config['o_board_title']), $tpl_main);
// END SUBST - <pun_title>


// START SUBST - <pun_desc>
$tpl_main = str_replace('<pun_desc>', $pun_config['o_board_desc'], $tpl_main);
// END SUBST - <pun_desc>


// START SUBST - <pun_navlinks>
$tpl_main = str_replace('<pun_navlinks>', generate_navlinks(), $tpl_main);
// END SUBST - <pun_navlinks>


// START SUBST - <pun_status>
if ($cookie['is_guest'])
    $tpl_temp = $lang_common['Not logged in'];
else
    $tpl_temp = $lang_common['Logged in as'].' <b>'.pun_htmlspecialchars($cur_user['username']).'</b>.<br>'.$lang_common['Last visit'].': '.format_time($cur_user['last_visit']);

if ($cur_user['status'] > PUN_USER)
{
    $result_header = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error());

    if ($db->result($result_header, 0))
        $tpl_temp .= '<br><a class="punhot" href="admin_reports.php">There are new reports</a>';

    if ($pun_config['o_maintenance'] == '1')
        $tpl_temp .= '<br><a class="punhot" href="admin_options.php#maintenance"><b>Maintenance mode is enabled!</b></a>';
}

$tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
// END SUBST - <pun_status>


// START SUBST - <pun_announcement>
if ($pun_config['o_announcement'] == '1' && basename($SERVER['SCRIPT_FILENAME']) == 'index.php')
{
    ob_start();

?>
<table class="punspacer" cellspacing="1" cellpadding="4"><tr><td> </td></tr></table>

<table class="punmain" cellspacing="1" cellpadding="4">
    <tr class="punhead">
        <td class="punhead"><?php echo $lang_common['Announcement'] ?></td>
    </tr>
    <tr>
        <td class="puncon2">
            <?php echo $pun_config['o_announcement_message'] ?><br><br>
        </td>
    </tr>
</table>
<?php

    $tpl_temp = trim(ob_get_contents());
    $tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main);
    ob_end_clean();
}
else
    $tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
// END SUBST - <pun_announcement>


// START SUBST - <pun_main>
ob_start();


define('PUN_HEADER', 1);

Re: punBB announcements: only on home page

It should be $_SERVER, not $SERVER. Do you have any idea how long it took me to notice that? :/

"Programming is like sex: one mistake and you have to support it for the rest of your life."

7

Re: punBB announcements: only on home page

Rickard wrote:

It should be $_SERVER, not $SERVER. Do you have any idea how long it took me to notice that? hmm

sorry my fault i change this and forget  ,but this not work anyway.

Re: punBB announcements: only on home page

Mac wrote:
Rickard wrote:

It should be $_SERVER, not $SERVER. Do you have any idea how long it took me to notice that? hmm

sorry my fault i change this and forget  ,but this not work anyway.

Hi
Strange ,i use Rickard guide few minutes ago and works fine click
but when i try this in my localhost (windows2003 +php4.3.7 and mysql MySQL 4.1 ) it's not work's tongue ,meyby there is some problem .

The best things in life are free*

* plus shipping and handling

[img]http://members.lycos.co.uk/maciekziolkowski/gmailsign.jpg[/img]

Re: punBB announcements: only on home page

Hmm, ok. What does this output:

dump($_SERVER, basename($SERVER['SCRIPT_FILENAME']));

"Programming is like sex: one mistake and you have to support it for the rest of your life."

10 (edited by Mac 2004-06-09 06:08)

Re: punBB announcements: only on home page

Rickard wrote:

Hmm, ok. What does this output:

dump($_SERVER, basename($SERVER['SCRIPT_FILENAME']));

all page look's like this

Array
(
    [ALLUSERSPROFILE] => E:\\Documents and Settings\\All Users
    [APP_POOL_ID] => DefaultAppPool
    [ClusterLog] => E:\\WINDOWS\\Cluster\\cluster.log
    [CommonProgramFiles] => E:\\Program Files\\Common Files
    [COMPUTERNAME] => MACIEJ-WXRSC38U
    [ComSpec] => E:\\WINDOWS\\system32\\cmd.exe
    [NUMBER_OF_PROCESSORS] => 1
    [OS] => Windows_NT
    [Path] => E:\\WINDOWS\\system32;E:\\WINDOWS;E:\\WINDOWS\\System32\\Wbem
    [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.VBS
    [PROCESSOR_ARCHITECTURE] => x86
    [PROCESSOR_IDENTIFIER] => x86 Family 15 Model 1 Stepping 3, GenuineIntel
    [PROCESSOR_LEVEL] => 15
    [PROCESSOR_REVISION] => 0103
    [ProgramFiles] => E:\\Program Files
    [SystemDrive] => E:
    [SystemRoot] => E:\\WINDOWS
    [TEMP] => E:\\WINDOWS\\TEMP
    [TMP] => E:\\WINDOWS\\TEMP
    [USERPROFILE] => E:\\Documents and Settings\\LocalService
    [windir] => E:\\WINDOWS
    [HTTP_CONNECTION] => Keep-Alive
    [HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_ACCEPT_LANGUAGE] => pl
    [HTTP_COOKIE] => punbb_cookie=a%3A2%3A%7Bi%3A0%3Bs%3A6%3A%22Mac%22%3Bi%3A1%3Bs%3A40%3A%228e7b0ae2d1e3faf46beaee01430f6fa4900dbc7f%22%3B%7D
    [HTTP_HOST] => localhost
    [HTTP_IF_MODIFIED_SINCE] => Wed, 09 Jun 2004 06:02:41 GMT
    [HTTP_REFERER] => http://localhost/test/admin_index.php
    [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)
    [AUTH_TYPE] => 
    [AUTH_PASSWORD] => 
    [AUTH_USER] => 
    [CERT_COOKIE] => 
    [CERT_FLAGS] => 
    [CERT_ISSUER] => 
    [CERT_SERIALNUMBER] => 
    [CERT_SUBJECT] => 
    [CONTENT_LENGTH] => 0
    [CONTENT_TYPE] => 
    [GATEWAY_INTERFACE] => CGI/1.1
    [HTTPS] => off
    [HTTPS_KEYSIZE] => 
    [HTTPS_SECRETKEYSIZE] => 
    [HTTPS_SERVER_ISSUER] => 
    [HTTPS_SERVER_SUBJECT] => 
    [INSTANCE_ID] => 1
    [LOCAL_ADDR] => 127.0.0.1
    [LOGON_USER] => 
    [PATH_INFO] => /test/index.php
    [PATH_TRANSLATED] => e:\\inetpub\\wwwroot\\test\\index.php
    [QUERY_STRING] => 
    [REMOTE_ADDR] => 127.0.0.1
    [REMOTE_HOST] => 127.0.0.1
    [REMOTE_USER] => 
    [REQUEST_METHOD] => GET
    [SCRIPT_NAME] => /test/index.php
    [SERVER_NAME] => localhost
    [SERVER_PORT] => 80
    [SERVER_PORT_SECURE] => 0
    [SERVER_PROTOCOL] => HTTP/1.1
    [SERVER_SOFTWARE] => Microsoft-IIS/6.0
    [UNMAPPED_REMOTE_USER] => 
    [PHP_SELF] => /test/index.php
    [argv] => Array
        (
        )

    [argc] => 0
)

 

Re: punBB announcements: only on home page

IIS6 is weird. Try this:

if ($pun_config['o_announcement'] == '1' && basename($_SERVER['SCRIPT_NAME']) == 'index.php')

"Programming is like sex: one mistake and you have to support it for the rest of your life."

12

Re: punBB announcements: only on home page

Rickard wrote:

IIS6 is weird. Try this:

if ($pun_config['o_announcement'] == '1' && basename($_SERVER['SCRIPT_NAME']) == 'index.php')

Work's great now smile thank you very much Rickard