Bibby wrote:

I modified these files, and it works well now:

include/functions.php
lang/English/common.php

My forum uses 'English' as default language, but main users are chinese, it works well.

Great, thankyou Bibby!

Can I do this in post.php to create a 'Submit and Suscribe' button?

<input type="submit" name="submit" value="<?php echo $lang_common['Submit AND Subscribe'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="s" onClick=document.thisform.subscribe.value=1/><input type="submit" name="preview" value="<?php echo $lang_post['Preview'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" />

I added the onclick handler: onClick=document.thisform.subscribe.value=1

When I select Russian language in my profile, many of the words come up as question marks: ?????

I checked the page encoding and it's set to charset=windows-1251

Where do I set this variable to utf-8? I see it's pun_char_encoding in main.tpl, but I cannot find a reference to that elsewhere.

We've made the online list available to users.

I think that it's quite frustrating for them to navigate using this list and hitting an Admin page restricted to them after reading juicy Admin titles.

What variables do I need to check to see if the member is permitted to read the thread before displaying the name of the thread?

TIA

Figured it out folks.

$pun_user['g_pm_limit'] is ignored for administrators.

Log-in as a regular member to check it.

Why does $pun_user['g_pm_limit'] return a 20, when I have 63 messages and have set permissions for 500 PMs?

I would like to display how much PM space the member has left.

I must be looking at the wrong variable.

Also, many thanks for answering my previous questions. I would not have figured out the buffering/unbuffering of queries was my problem!

elbekko wrote:

You need to change the post fetch query, not your own. Make sure it's buffered.

Thank you very much!

It works perfectly.

Are there any drawbacks to having the main query buffered?

Thanks. I changed the query in viewtopic.php to:

$r2 = $db->query('SELECT trade_ref FROM '.$db->prefix.'trader WHERE id='.$cur_post['poster_id'], true) or error('Unable to fetch username', __FILE__, __LINE__, $db->error());
    
$number_of_ratings=$db->num_rows($r2);

Same result: only first post is displayed, and instead of num_rows=1, num_rows=0.

:puzzled:

Thanks elbekko

This would mean I would have to create a new $db function in mysql.php since it looks like the current function is always set to false?

    function query($sql, $unbuffered = false)
    {
        if (defined('PUN_SHOW_QUERIES'))
            $q_start = get_microtime();

        if ($unbuffered)
            $this->query_result = @mysql_unbuffered_query($sql, $this->link_id);
        else
            $this->query_result = @mysql_query($sql, $this->link_id);

        if ($this->query_result)
        {
            if (defined('PUN_SHOW_QUERIES'))
                $this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));

            ++$this->num_queries;

            return $this->query_result;
        }
        else
        {
            if (defined('PUN_SHOW_QUERIES'))
                $this->saved_queries[] = array($sql, 0);

            return false;
        }

Thanks deadram

I tried that, but it has no effect.

I'm not sure it would have any effect since the $result above mine has finished executing?

Somehow the $db call stops the loop... tearing my hair out!

I'm trying to pull a number from another table from within viewtopic.php and display them next to the user's name in each post.

So I insert my code after checking if the user is a member at around line 200:

if ($cur_post['poster_id'] > 1) {

    //
    // show trader feedback
    //
   
    $number_of_ratings=0;   
   
    // get total feedback for user and display it
   
    $result = $db->query('SELECT trade_ref FROM '.$db->prefix.'traderfeedback WHERE id='.$cur_post['poster_id']) or error('Unable to fetch feedback', __FILE__, __LINE__, $db->error());
   
        $number_of_ratings=$db->num_rows($result);
       
        $feedback="Trader Rating (<a href='trader.php?action=view&id=".$cur_post['poster_id']."'>".$number_of_ratings."</a>)";
   
    //
    // end trader feedback
    //

.
.
.

For some reason the db query I inserted seems to end the loop.

Only 1 post is ever displayed, even though there may be many.

Any guidance much appreciated.

Phew -- trader mod completed.

I'm now trying to figure out how to display the rating next to each username in viewtopic.php

Right after around line 200:

if ($cur_post['poster_id'] > 1) {

I added my code which retrieves the rating for the individual user and adds up all the rows using a $db->num_rows statement. I can't figure out why only one post is ever displayed when the db is queried within the squiggly bracket.

It seems like a database query resets the counter for the loop around all posts.


My modified code within viewtopic.php

// If the poster is a registered user.
    if ($cur_post['poster_id'] > 1)
    {
    

    //
    // show trader feedback
    //
    
    $number_of_ratings=0;    
    
    // get total feedback for user and display it
    
    $result = $db->query('SELECT trade_ref FROM '.$db->prefix.'traderfeedback WHERE id='.$cur_post['poster_id']) or error('Unable to fetch feedback', __FILE__, __LINE__, $db->error());
    
        $number_of_ratings=$db->num_rows($result);
        
        $feedback="Trader Rating (<a href='trader.php?action=view&id=".$cur_post['poster_id']."'>".$number_of_ratings."</a>)";
    
    //
    // end trader feedback
    //
    
        $username = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['username']).'</a>';
        $user_title = get_title($cur_post);

Thanks -- what's the established way to santize the id variable before doing the select?

I looked through mysql.php and didn't see a loop to retrieve more than one row. How do pun modules usually do this? Using a loop outside mysql.php functions?

Does common.php load all the database functions?

I ask because $username is empty after the db is queried, and I was wondering if $db->prefix was set in common.php.

I have:

<?php
 
define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';

$do_action=$_GET['action'];
$user_id=$_GET['id'];
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / New page 1';
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';

// troubleshooting - check variables
 echo $do_action;
 echo $user_id;
 
if ($do_action == 'view')
    {
            $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE id='.$user_id) or error('Unable to fetch username', __FILE__, __LINE__, $db->error());
            
            echo $result;
        list($username) = $db->fetch_row($result);
        
    //    $page_title = 'Trader Feedback Rating for '.$username;
        //require PUN_ROOT.'header.php';
    
    echo "Trader feedback for ".$username;
    
    }
 
?>
        <div class="block">
            <h2><span>Trader Feedback</span></h2>
            <div class="box">
                <div class="inbox">
                    <p>
                    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent augue. Nulla facilisi. Fusce bibendum accumsan erat. Quisque sollicitudin mattis neque. Sed dapibus. Integer a lectus eu sem consequat pellentesque. Morbi rhoncus nulla. Duis adipiscing interdum velit. Fusce ante. Ut vitae enim sit amet magna sodales hendrerit. In sed tortor at sapien convallis eleifend. Proin mauris. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut metus. Cras ac arcu et arcu porttitor blandit. Nam vitae lectus eget mauris sollicitudin placerat. Suspendisse vestibulum. Donec varius libero. Duis velit tellus, euismod vitae, consequat sed, consectetuer ut, purus.
                    </p>
                    <p>
                Trader feedback for <? echo $username; ?>
                    </p>
                </div>
            </div>
        </div>
<?php
 
require PUN_ROOT.'footer.php';
pogenwurst wrote:
idn wrote:

The wiki is not that helpful.

Really? Did you happen to find this: http://wiki.punres.org/Miniportal#New_page_template ?

Yikes!

I stand corrected.

Thanks very much. This is EXACTLY what I was looking for.

Thanks - that link is a big help.

I now see that I have access to many of the user variables once common.php is loaded.

When I try to load header.php with a require, it doesn't seem to load the CSS and HTML header. Do I have to define a new file somewhere? Or perhaps I need to define something else?

The wiki is not that helpful.

I'm taking on the task of writing a trader rating / feedback module for punbb.

How should I authenticate the user?

Would this sequence still be current?

- Fetch the serialized array from the cookie.
- SELECT * FROM users WHERE username=username_from_cookie AND password=hash_from_cookie
- If I get a row back, I know the user is logged in. Otherwise the username and/or password in the cookie is incorrect.

(From http://punbb.org/forums/viewtopic.php?pid=10048)

18

(0 replies, posted in Feature requests)

We're looking for something like the vB iTrader mod found here: http://www.vbulletin.org/forum/showthre … amp;page=2

Has anyone made something like this?

It's not a Karma or a Points mod, but something a little more detailed, like the eBay feedback system.

TIA

Thanks  vnpenguin.

So it looks like I'll need to upgrade MySQL to 4.1 or better in order for this to work.

I'm still puzzled as to why I can't search for, say, Russian keywords that appear in this forum's Russian section.

I should also say I'm running MySQL 4.0.27, but that doesn't explain why I can't search for cyrillic keywords in punbb.org forums.

It seems that I cannot search for unicode terms in other character sets. I always receive no results, while the terms are certainly there.

For instance, in your Russian section, when I search for any terms I see in that area, such as ?????, I also receive no results.

Does searching in unicode work?

Thanks.