51

Re: New frontpage index mod!

Bingiman, you have a completely empty else statement at the bottom of that script:

else
 {
    }

You may as well remove it 'cos it's doing nowt. smile If I can get that niggle with the truncation script sorted, I'll merge it into your script.

Re: New frontpage index mod!

Thanks for letting me know. I'll update my last post.

Re: New frontpage index mod!

MattF wrote:
soonotes wrote:

Are those spans in the $append? If so leave them open.

Have removed the append. smile Already have the read more setup where I'm trying to jemmy it, so that bit's unneeded. smile It's purely between the <p> </p> tags that it's adding the extras. I think it's the following where the problem is initially occuring:

if (preg_match_all ('/<([a-z\:\-]+)[ >]/', $string, $start_tags))

Now that I think about it I had the exact same issue. I don't know what caused it but what I did was start again with the unmodified function and make the changes I needed.

In other words, try it with the code I posted and you shouldn't have the issue. Then make your changes one at a time and see when the issue occurs.

54

Re: New frontpage index mod!

if someone see a fix for my file would you mind pointing out the error and reposting the fixed script?
that way we can track the progress of this file?


Thanks
Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

55 (edited by quaker 2007-06-19 14:15)

Re: New frontpage index mod!

new updated photos....
this is on my localhost and the forum width is 550px so that why it looks crunched.
this is for members and admin
http://nalan.org/badmin.png

this is for guest
http://nalan.org/bguest.png

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: New frontpage index mod!

You can add the following to your styleheet_cs.css file. This is for the news footer etc.

/* News Links on index page */
.news_subject {
    background-color: inherit;
    font-family: Tahoma, Verdana, "Lucida Sans Unicode", Arial, sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    text-decoration:none; 
    border-bottom:1px dotted #065C7C
}


a.news_subject:hover {
    background-color: inherit; 
    color: #000000;
    text-decoration: none;
    border-bottom:1px solid #065C7C
}

.news_footer {
    background-color: #DBE9EC;
    color: inherit;
    border-bottom: 1px solid #BBCEDE;
    border-right: 1px solid #BBCEDE;
}

57

Re: New frontpage index mod!

Here's a text truncate function:

<?php
function text_chop($text, $length) {
    if(strlen($text) > $length) {
        $text = substr($text, 0, $length)."...";  // instead of the ... you set an other ending message
    }
    return $text;
}
?>

How to use:

<?php
echo text_chop("here the message.",40); // message ends after 40 characters
?>

Re: New frontpage index mod!

Where in the script would the above be placed?

59

Re: New frontpage index mod!

ok ok i got the truncate working...haha... i had to find a javascript to handle it.. it is rough but works.... here is my code

<style>
.news_subject {
    background-color: inherit;
    font-family: Tahoma, Verdana, "Lucida Sans Unicode", Arial, sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    text-decoration:none; 
    border-bottom:1px dotted #065C7C
}


a.news_subject:hover {
    background-color: inherit; 
    color: #000000;
    text-decoration: none;
    border-bottom:1px solid #065C7C
}

.news_footer {
    background-color: #DBE9EC;
    color: inherit;
    border-bottom: 1px solid #BBCEDE;
    border-right: 1px solid #BBCEDE;
}
</style>

<?php
 
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);

define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

$newsid = '1'; //This is the forum the news is retrieved from
$newsdisplay = '5'; //This is how many news articles are displayed.

global $lang_common, $db, $pun_config, $pun_user, $db_prefix;
$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, p.poster AS username, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id='.$newsid.' AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$newsdisplay) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());


        if ($db->num_rows($result))
                    {
                            while($cur_post = $db->fetch_assoc($result))
                            {
                                    $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
?>
<script type="text/javascript">

var len = 200;
var p = document.getElementById('truncateMe');
if (p) {

  var trunc = p.innerHTML;
  if (trunc.length > len) {

    /* Truncate the content of the P, then go back to the end of the
       previous word to ensure that we don't truncate in the middle of
       a word */
    trunc = trunc.substring(0, len);
    trunc = trunc.replace(/\w+$/, '');

    /* Add an ellipses to the end and make it a link that expands
       the paragraph back to its original size */
    trunc += '<a href="#" ' +
      'onclick="this.parentNode.innerHTML=' +
      'unescape(\''+escape(p.innerHTML)+'\');return false;">' +
      '...<\/a>';
    p.innerHTML = trunc;
  }
}

</script>
    <div class="block">
       
<?php
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['username'].'\'s Avatar" alt="'.$cur_post['username'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['username'].'\'s Avatar" alt="'.$cur_post['username'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['username'].'\'s Avatar" alt="'.$cur_post['username'].'\'s Avatar" /></a>';
        }
        else
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img alt="" src="img/noimage.gif" /></a>';
    echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
<div class="box">
    <div class="inbox">
<ul><li>
<div style="padding-bottom: 6px;" ><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><strong><?php echo $cur_post['subject']; ?></strong></a></div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td style="border: 0px;" width="90%"id="truncateMe"><?php echo $cur_post['message']."\n" ?></td>
    <td align="right" style="border: 0px;" width="10%" valign="top"><?php echo $user_avatar ?></td>
  </tr>
</table>
<br />
<br />
<table class="news_footer" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td width="100%">
<?php


    echo "\t\t\t\t\t\t\t".'<span class="byuser" style="float:left">Posted on: '.format_time($cur_post['posted']).' by:<span class="byuser'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a href="profile.php?id='.$cur_post['poster_id'].'" class="username">'.pun_htmlspecialchars($cur_post['poster']).'</a> |  Views: '. $cur_post['num_views'].' |  Replies: '. $cur_post['num_replies'].'</span></span>'."\n";
        if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST)
    echo "\t\t\t\t\t\t\t".'<a style="text-decoration: none" href="viewtopic.php?id='.$cur_post['id'].'" class="username">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="float:right">'.'<a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['id'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['id'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['id'].'">'.$lang_topic['Quote'].'</a>'.' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">'.'Read More'.'</a></span>'."\n\n\n\n";
?>
        </td>
    </tr>
</table>
</ul>
        </div>
    </div>
</div>
<?
}
     }
else
{
    }
     ?>
<br />
<br />

<?php
require PUN_ROOT.'footer.php';
My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

60 (edited by bingiman 2007-06-19 18:34)

Re: New frontpage index mod!

Here again is my working copy:

<style>
.news_subject {
    background-color: inherit;
    font-family: Tahoma, Verdana, "Lucida Sans Unicode", Arial, sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    text-decoration:none; 
    border-bottom:1px dotted #065C7C
}


a.news_subject:hover {
    background-color: inherit; 
    color: #000000;
    text-decoration: none;
    border-bottom:1px solid #065C7C
}

.news_footer {
    background-color: #DBE9EC;
    color: inherit;
    border-bottom: 1px solid #BBCEDE;
    border-right: 1px solid #BBCEDE;
}
</style>
<?php
 
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);

define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

$newsid = '1'; //This is the forum the news is retrieved from
$newsdisplay = '5'; //This is how many news articles are displayed.

$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id='.$newsid.' AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$newsdisplay) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());


        if ($db->num_rows($result))
                    {
                            while($cur_post = $db->fetch_assoc($result))
                            {
                                    $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
?>
<script type="text/javascript">

var len = 890;
var p = document.getElementById('truncateMe');
if (p) {

  var trunc = p.innerHTML;
  if (trunc.length > len) {

    /* Truncate the content of the P, then go back to the end of the
       previous word to ensure that we don't truncate in the middle of
       a word */
    trunc = trunc.substring(0, len);
    trunc = trunc.replace(/\w+$/, '');

    /* Add an ellipses to the end and make it a link that expands
       the paragraph back to its original size */
    trunc += '<a href="#" ' +
      'onclick="this.parentNode.innerHTML=' +
      'unescape(\''+escape(p.innerHTML)+'\');return false;">' +
      '...<\/a>';
    p.innerHTML = trunc;
  }
}

</script>
    <div class="block">
       
<?php
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
        }
        else
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img alt="" src="img/noimage.gif" /></a>';
    echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
<div class="box">
    <div class="inbox">
<ul><li>
<div style="padding-bottom: 6px;" ><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><strong><?php echo $cur_post['subject']; ?></strong></a></div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td style="border: 0px; width: 90%;" valign="top" id="truncateMe"><?php echo $cur_post['message']."\n" ?></td>
    <td align="right" style="border: 0px; width: 10%;" valign="top"><?php echo $user_avatar ?></td>
  </tr>
</table>
<br />
<br />
<table class="news_footer" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td width="100%">
<?php


    echo "\t\t\t\t\t\t\t".'<span class="byuser" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="byuser'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a href="profile.php?id='.$cur_post['poster_id'].'" class="username">'.pun_htmlspecialchars($cur_post['poster']).'</a> |  Views: '. $cur_post['num_views'].' |  Replies: '. $cur_post['num_replies'].'</span></span>'."\n";
        if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST)
    echo "\t\t\t\t\t\t\t".'<a style="text-decoration: none" href="viewtopic.php?id='.$cur_post['id'].'" class="username">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="float:right">'.'<a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['id'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['id'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['id'].'">'.$lang_topic['Quote'].'</a>'.' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">'.'Read More'.'</a></span>'."\n\n\n\n";
?>
        </td>
    </tr>
</table>
</ul>
        </div>
    </div>
</div>
<?
}
     }

     ?>
<br />
<br />

<?php
require PUN_ROOT.'footer.php';

61

Re: New frontpage index mod!

FSX wrote:

Here's a text truncate function:

<?php
function text_chop($text, $length) {
    if(strlen($text) > $length) {
        $text = substr($text, 0, $length)."...";  // instead of the ... you set an other ending message
    }
    return $text;
}
?>

How to use:

<?php
echo text_chop("here the message.",40); // message ends after 40 characters
?>

That code will just chop regardless, with no care or thought about tags, which is the problem I'm trying to get rid of. big_smile

Re: New frontpage index mod!

MattF - Why not use the last script we posted. It works and truncates..

63

Re: New frontpage index mod!

mattf we tried that and got all kinds of error

so i got one that works good.


Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

64

Re: New frontpage index mod!

soonotes wrote:

Now that I think about it I had the exact same issue. I don't know what caused it but what I did was start again with the unmodified function and make the changes I needed.

In other words, try it with the code I posted and you shouldn't have the issue. Then make your changes one at a time and see when the issue occurs.

It is a very slightly altered, (just so it gets the relevant variables and no append), version of your code that I'm using, but I'll start afresh and see if it makes any difference. smile It works fine on every other type of tagging. It's just that one situation where you have '<tag color:', (and one assumes similar layout tags might cause it), where the problem lies. Like I say, I'll start afresh and see if that makes a difference though. smile Thanks again soonotes.

65 (edited by MattF 2007-06-19 18:48)

Re: New frontpage index mod!

bingiman wrote:

MattF - Why not use the last script we posted. It works and truncates..

Because I haven't seen it yet. big_smile Only just come back online. big_smile

Edit: Is that a Javascript truncation method? (I'm not quite back on the ball yet). big_smile

66

Re: New frontpage index mod!

mattf me and fsx worked on the issue with that code.. and got all kind of issue..
so i went and got a simpler javascript to do the function of truncate.

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

67 (edited by MattF 2007-06-19 18:53)

Re: New frontpage index mod!

quaker wrote:

mattf me and fsx worked on the issue with that code.. and got all kind of issue..
so i went and got a simpler javascript to do the function of truncate.

Q

Just edited my original reply to ask that question. smile What type of method does it use, though? From what little I know of java, that would seem that it makes a popup type text view? Or does it just link back to the thread?

68 (edited by quaker 2007-06-19 19:01)

Re: New frontpage index mod!

it set the amount of txt to view i removed some of the script to display read more below the txt area. and left it to the block at the bottom.


well the javascript over rides the echo to print all the txt. by setting that id=

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

69

Re: New frontpage index mod!

http://www.soxiam.com/Code/TruncateTextWithJavascript

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: New frontpage index mod!

Well, I've tested this truncation and it works to some degree. if however there are more than 2 posts on the frontpage then the 3rd post does not get truncated. I believe that this is because the id="truncateMe" is set in the <td field.

71

Re: New frontpage index mod!

i agree maybe if we throw in a div or a <p id=" was how it was suppose to be.

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: New frontpage index mod!

I tried that but had no success with that method.

73 (edited by quaker 2007-06-20 00:22)

Re: New frontpage index mod!

New code.... BING HELPED ME WITH THIS..
change this to set the max characters.
ops i forgot this..
add this to ur _css

.news_subject {
    background-color: inherit;
    font-family: Tahoma, Verdana, "Lucida Sans Unicode", Arial, sans-serif;
    font-size: 1.2em;
    font-weight: bold;
    text-decoration:none; 
    border-bottom:1px dotted #065C7C
}


a.news_subject:hover {
    background-color: inherit; 
    color: #000000;
    text-decoration: none;
    border-bottom:1px solid #065C7C
}

.news_footer {
    background-color: #DBE9EC;
    color: inherit;
    border-bottom: 1px solid #BBCEDE;
    border-right: 1px solid #BBCEDE;
}
td,th {
    color: #666666;
}

$max_subject_length=145

<?php
 
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);

define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

$newsid = '1'; //This is the forum the news is retrieved from
$newsdisplay = '5'; //This is how many news articles are displayed.

$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id='.$newsid.' AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$newsdisplay) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());


        if ($db->num_rows($result))
                    {
                            while($cur_post = $db->fetch_assoc($result))
                            {
                                    $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
?>

    <div class="block">
       
<?php
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' title="'.$cur_post['poster'].'\'s Avatar" alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
        }
        else
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img alt="" src="img/noimage.gif" /></a>';
    echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
<div class="box">
    <div class="inbox">
<ul><li>
<div style="padding-bottom: 6px;" ><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><strong><?php echo $cur_post['subject']; ?></strong></a></div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td style="border: 0px; width: 90%;" valign="top" ><?php echo $subject_truncated = pun_htmlspecialchars(trim(substr($cur_post['message'], 0, ($max_subject_length=145)))).'.....'."\n" ?></td>
    <td align="right" style="border: 0px; width: 10%;" valign="top"><?php echo $user_avatar ?></td>
  </tr>
</table>
<br />
<br />
<table class="news_footer" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td width="100%">
<?php


    echo "\t\t\t\t\t\t\t".'<span class="byuser" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="byuser'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a href="profile.php?id='.$cur_post['poster_id'].'" class="username">'.pun_htmlspecialchars($cur_post['poster']).'</a> |  Views: '. $cur_post['num_views'].' |  Replies: '. $cur_post['num_replies'].'</span></span>'."\n";
        if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST)
    echo "\t\t\t\t\t\t\t".'<a style="text-decoration: none" href="viewtopic.php?id='.$cur_post['id'].'" class="username">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="float:right">'.'<a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['id'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['id'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['id'].'">'.$lang_topic['Quote'].'</a>'.' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">'.'Read More'.'</a></span>'."\n\n\n\n";
?>
        </td>
    </tr>
</table>
</ul>
        </div>
    </div>
</div>
<?
}
     }

     ?>
<br />
<br />

<?php
require PUN_ROOT.'footer.php';
My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

74

Re: New frontpage index mod!

Well, the penny finally dropped about the regex. big_smile

if (preg_match_all('/<\/>([a-z]+)>/', $string, $end_tags))

The first '>' is totally irrelevant and useless. It can't match anything other than </>. That's the beastie that causes the problem. So that regex should be:

/<\/([a-z]+)>/

Re: New frontpage index mod!

Thank you MattF. Nice job, regex gives me headaches.