Русское сообщество fluxbb

Быстрый лёгкий надёжный форумный движок

Вы не вошли.

Объявление

Вы можете внести свой вклад в содержание сайта. Жертвователи попадут в почетную группу "Спонсоры". Поддержать сайт.

#1 2008-11-19 11:47:25

flashcat
Гость

Password Protected

Доброго времени суток всем, нашёл полезный мод но возникли вопросы.
http://www.punres.org/viewtopic.php?id=744
Отличный мод кому надо создавать форумы с паролем, не создавая отдельные группы которые могут читать форум, а давать привилегии пользователям из любой группы пароль к форуму за какие либо заслуги)))

У меня всё отлично работает кроме как у группы модераторов при вводе паролья  вылазит вот такая ошибка:

File: /home/..../..../...../viewforum.php
Line: 319

PunBB reported: Unable to fetch topic list 

Database reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 50' at line 1 (Errno: 1064)

читал на punres.org там написано типа значит такие таблицы были в _forums, всё удалял ставил заново ничего не помогло, выяснил что проблема где то примерно вот в этом коде:

}
    else
    {  
    if(isset($_POST['check_pass']))
        {
            $check = $db->query("SELECT password FROM ". $db->prefix ."forums WHERE `password` = '{$_POST['pass']}' AND `id` = '$id'") or error(mysql_error());
            if($db->num_rows($check) < 1)
            {
                message($lang_common['No Forum Auth']);
            }
        }
        else
        {
            echo "Protected: {$cur_forum['protected']}";
            message($lang_common['Password Protected'] .'
                 <form method="post" action="viewforum.php?id='. $id .'">
                 Password: <input type="password" name="pass"><br />
                 <input type="submit" name="check_pass">
                 </form>');
        }
    }

Строка на которую ссылается на ошибку:

316:}
317:
318:
319:$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
320:
321:// If there are topics in this forum.

На punres.org что возможно, в таблице уже были добавлены строки мода ранее, удалял все переустанавливал не помогло. Да и уверен что их там раньше не было.
Вот пытался сам разобраться, но как понимаете не смог, подскажите пожалуйста как это исправить.
Буду очень благодарен за помощь, у меня просто много групп на форуме мне мод очень бы помог.

Редактировался flashcat (2008-11-20 07:12:52)

#2 2008-11-19 18:17:58

hcs
Гость

Re: Password Protected

Cтрока где вызывается ошибочный запрос одна,а код показан непонятно какой и непонятно откуда. Какое он имеет отношение к ошибке?

flashcat пишет:

выяснил что проблема где то примерно вот в этом коде

Как ты это выяснил?

#3 2008-11-20 07:12:13

flashcat
Гость

Re: Password Protected

hcs пишет:

Как ты это выяснил?

Код показан из редми файла. добавляться в viewforum.php

#
#---------[ 9. FIND (line: 251) ]---------------------------------------------------------
#

    <?php
    
    
#
#---------[ 10. AFTER ADD ]-------------------------------------------------
#КОД который показан

Я пробывал его менять на punres.org  есть еще одна версия подобного мода но тогда появлялась другая ошибка тогда всем пользователям при входе в любой форум надо было вводить свой пароль. Уж не знаю каким чудом это работало ну я пришол к выводу что проблема где то там, я могу и ошибаться.

Добавлено спустя     1 минуту   53 секунды:
может надо в строку 319: что то дописать или еще куда то, но я не могу сам сообразить(((

Редактировался flashcat (2008-11-20 07:18:16)

#4 2008-11-20 15:42:02

hcs
Гость

Re: Password Protected

Ну во первых надо включить show_queryes, воспроизвести ошибку и  получить ошибочный запрос. Потом открыть код, где формируется этот query

#5 2008-11-20 17:25:53

flashcat
Гость

Re: Password Protected

Вот он мне выдал но не могу что понять ((( надо в этот запрос вписать чтоль типа f.protected, f.password, такого???

File: /home/..../..../...../viewforum.php

Line: 319

PunBB reported: Unable to fetch topic list 

Database reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 50' at line 1 (Errno: 1064) 

Failed query: SELECT p.poster_id AS has_posted, t.id, t.subject, t.description, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, 
t.moved_to, t.question, t.question, lt.log_time, lf.mark_read, t.icon_topic 
FROM pun_topics AS t LEFT JOIN pun_posts AS p ON t.id=p.topic_id AND p.poster_id=4792 LEFT JOIN pun_log_topics AS lt ON lt.user_id=4792 AND lt.topic_id=t.id LEFT JOIN
 pun_log_forums AS lf ON lf.forum_id=t.forum_id AND lf.user_id=4792 WHERE t.forum_id=42 GROUP BY t.id ORDER BY sticky DESC, last_post DESC LIMIT , 50

Редактировался flashcat (2008-11-20 17:29:08)

#6 2008-11-20 17:49:58

hcs
Гость

Re: Password Protected

LIMIT неправильный, найди строками (10-50 строк или больше) выше:

// Determine the topic offset (based on $_GET['p'])
$num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);

и покажи кусок кода оттуда до 319

#7 2008-11-20 18:11:20

flashcat
Гость

Re: Password Protected

Вот если я что то опять натупил))) txt шник  http://thugzfam1ly.com/0/viewforum.php.txt всего viewforum.php

// Determine the topic offset (based on $_GET['p'])
$num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);

$p = (!isset($_GET['p']) || !is_numeric($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
$start_from = $pun_user['disp_topics'] * ($p - 1);

// Generate paging links
if ($_GET['action'] == 'all') $p = ($num_pages + 1);
$paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'viewforum.php?id='.$id);
if ($_GET['action'] == 'all') $pun_user['disp_topics'] = $cur_forum['num_topics'];


$page_title = pun_htmlspecialchars($pun_config['o_board_title'].' / '.$cur_forum['forum_name']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
// Load userstats module
require PUN_ROOT.'userstats_track.php';


/////////////////////////////////////sub forums/////////////////////////////////////////
# Option Note: if you do not want the subforums displaying at the top
# when you go into the main forum topic 
# then in the following $sub_forum_result query change  
# - ORDER BY disp_position')        -  to
# - ORDER BY disp_position', true)  -  (without the dashes)
#
$subforum_result = $db->query('SELECT f.forum_desc, f.forum_name, f.id, f.last_post, f.last_post_id, f.last_poster, f.moderators, f.num_posts, f.num_topics, f.redirect_url, p.poster_id AS last_poster_id FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'posts AS p ON (p.id=f.last_post_id) WHERE parent_forum_id='.$id.' ORDER BY disp_position') or error('Unable to fetch sub forum info',__FILE__,__LINE__,$db->error());
if($db->num_rows($subforum_result))
{
?>
<div class="linkst">
    <div class="inbox">
        <ul><li><a href="forums.php"><?php echo $lang_common['Index'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>

<div id="vf1" class="blocktable">
    <h2><span>Sub forums</span></h2>
    <div class="box">
        <div class="inbox">
            <table cellspacing="0">
            <thead>
                <tr>
                    <th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
                    <th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
                    <th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
                    <th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
                </tr>
            </thead>
            <tbody>
<?php

while($cur_subforum = $db->fetch_assoc($subforum_result))
{
    $item_status = '';
    $icon_text = $lang_common['Normal icon'];
    $icon_type = 'icon';

    // Are there new posts?
    if (!$pun_user['is_guest'] && $cur_subforum['last_post'] > $pun_user['last_visit'])
    {
        $item_status = 'inew';
        $icon_text = $lang_common['New icon'];
        $icon_type = 'icon inew';
    }

    // Is this a redirect forum?
    if ($cur_forum['redirect_url'] != '')
    {
        $forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_subforum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_subforum['redirect_url']).'">'.pun_htmlspecialchars($cur_subforum['forum_name']).'</a></h3>';
        $num_topics = $num_posts = '&nbsp;';
        $item_status = 'iredirect';
        $icon_text = $lang_common['Redirect icon'];
        $icon_type = 'icon';
    }
    else
    {
        $forum_field = '<h3><a href="viewforum.php?id='.$cur_subforum['id'].'">'.pun_htmlspecialchars($cur_subforum['forum_name']).'</a></h3>';
        $num_topics = $cur_subforum['num_topics'];
        $num_posts = $cur_subforum['num_posts'];
    }

    if ($cur_subforum['forum_desc'] != '')
        $forum_field .= "\n\t\t\t\t\t\t\t\t".$cur_subforum['forum_desc'];


    // If there is a last_post/last_poster.
    if ($cur_subforum['last_post'] != '')
    $last_post = '<a href="viewtopic.php?pid='.$cur_subforum['last_post_id'].'#p'.$cur_subforum['last_post_id'].'">'.format_time($cur_subforum['last_post']).'</a><br /> <span class="byuser">'.$lang_common['by'].' <a href="profile.php?id='.$cur_subforum['last_poster_id'].'">'.pun_htmlspecialchars($cur_subforum['last_poster']).'</a></span>';
    else
        $last_post = '&nbsp;';

    if ($cur_subforum['moderators'] != '')
    {
        $mods_array = unserialize($cur_subforum['moderators']);
        $moderators = array();

        while (list($mod_username, $mod_id) = @each($mods_array))
            $moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>';

        $moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n";
    }
?>
                <tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
                    <td class="tcl">
                        <div class="intd">
                            <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div>
                            <div class="tclcon">
                                <?php echo $forum_field;
                                if ($cur_subforum['moderators'] != '') {
                                    echo "\n".$moderators;
                                }
                                ?>
                            </div>
                        </div>
                    </td>
                    <td class="tc2"><?php echo $num_topics ?></td>
                    <td class="tc3"><?php echo $num_posts ?></td>
                    <td class="tcr"><?php echo $last_post ?></td>
                </tr>
<?php
    }
?>
            </tbody>
            </table>
        </div>
    </div>
</div>
<?php
}
//////////////////////////////////////end sub forums///////////////////////////////////////////////////////////////////////////////////////////
?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
<?php
    }
    else
    {  
    if(isset($_POST['check_pass']))
        {
            $check = $db->query("SELECT password FROM ". $db->prefix ."forums WHERE `password` = '{$_POST['pass']}' AND `id` = '$id'") or error(mysql_error());
            if($db->num_rows($check) < 1)
            {
                message($lang_common['No Forum Auth']);
            }
        }
        else
        {
            echo "Protected: {$cur_forum['protected']}";
            message($lang_common['Password Protected'] .'
                 <form method="post" action="viewforum.php?id='. $id .'">
                 Password: <input type="password" name="pass"><br />
                 <input type="submit" name="check_pass">
                 </form>');
        }
    }
    
echo $post_link;
if($cur_forum['parent_forum'])
    echo "\t\t".'<ul><li><a href="forums.php">'.$lang_common['Index'].'</a>&nbsp;</li><li>&raquo;&nbsp;<a href="viewforum.php?id='.$cur_forum['parent_forum_id'].'">'.pun_htmlspecialchars($cur_forum['parent_forum']).'</a>&nbsp;</li><li>&raquo;&nbsp;'.pun_htmlspecialchars($cur_forum['forum_name']).'</li></ul>';
else
    echo "\t\t".'<ul><li><a href="forums.php">'.$lang_common['Index'].' </a>&nbsp;</li><li>&raquo;&nbsp;'.pun_htmlspecialchars($cur_forum['forum_name']).'</li></ul>';

?>
    <div class="clearer"></div>
    </div>
</div>

<div id="vf" class="blocktable">
    <h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span> | <span><a href="rss.php?cid=<?php echo $cur_forum['cid'] ?>">RSS Feed</a></span></h2>
    <div class="box">
        <div class="inbox">
            <table cellspacing="0">
            <thead>
                <tr>
                    <th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th>
                    <th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th>
                    <th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th>
                    <th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
                </tr>
            </thead>
            <tbody>
<?php
    


// Fetch list of topics to display on this page
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
{
    // Without "the dot"
    $sql = 'SELECT t.id, t.poster, t.subject, description, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, question, question, lt.log_time, lf.mark_read, icon_topic FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'log_topics AS lt ON lt.user_id='.$pun_user['id'].' AND lt.topic_id=t.id LEFT JOIN '.$db->prefix.'log_forums AS lf ON lf.forum_id=t.forum_id AND lf.user_id='.$pun_user['id'].'  WHERE t.forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
    // With "the dot"
    switch ($db_type)
    {
        case 'mysql':
        case 'mysqli':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.description, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, t.question, lt.log_time, lf.mark_read, t.icon_topic FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].'  LEFT JOIN '.$db->prefix.'log_topics AS lt ON lt.user_id='.$pun_user['id'].' AND lt.topic_id=t.id   LEFT JOIN '.$db->prefix.'log_forums AS lf ON lf.forum_id=t.forum_id AND lf.user_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

        case 'sqlite':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.description, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, t.question, t.icon_topic FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
            break;

        default:
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.description, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, t.question, t.icon_topic FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

    }
}


$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

#8 2008-11-20 18:18:27

hcs
Гость

Re: Password Protected

Еще включи pun_debug, нотисы и снова воспроизведи ошибку

#9 2008-11-20 18:41:38

flashcat
Гость

Re: Password Protected

Вот всё что включено:// Enable DEBUG mode by removing // from the following line
define('PUN_DEBUG', 1);

// This displays all executed queries in the page footer.
// DO NOT enable this in a production environment!
define('PUN_SHOW_QUERIES', 1);

и нотисы  имеешь ввиду: // Make sure PHP reports all errors except E_NOTICE. PunBB supports E_ALL, but a lot of scripts it may interact with, do not.
error_reporting(E_ALL ^ E_NOTICE);

 тоже самое что в посте #5 Сегодня 17:25 - то есть получается они были включены

Редактировался flashcat (2008-11-20 18:54:43)

#10 2008-11-21 14:35:11

hcs
Гость

Re: Password Protected

Замени (временно) это:

// Make sure PHP reports all errors except E_NOTICE. PunBB supports E_ALL, but a lot of scripts it may interact with, do not.
error_reporting(E_ALL ^ E_NOTICE);

на это:

error_reporting(E_ALL);
ini_set('display_errors', 1);

#11 2008-11-22 12:52:30

flashcat
Гость

Re: Password Protected

Заменил вот что выдалось.

/viewforum.php
Line: 319

PunBB reported: Unable to fetch topic list 

Database reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 50' at line 1 (Errno: 1064) 

Failed query: SELECT p.poster_id AS has_posted, t.id, t.subject, t.description, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.question, t.question, lt.log_time, lf.mark_read, t.icon_topic FROM pun_topics AS t LEFT JOIN pun_posts AS p ON t.id=p.topic_id AND p.poster_id=4792 LEFT JOIN pun_log_topics AS lt ON lt.user_id=4792 AND lt.topic_id=t.id LEFT JOIN pun_log_forums AS lf ON lf.forum_id=t.forum_id AND lf.user_id=4792 WHERE t.forum_id=42 GROUP BY t.id ORDER BY sticky DESC, last_post DESC LIMIT , 50

#12 2008-11-22 13:22:37

hcs
Гость

Re: Password Protected

Странно.
Вобщем куда-то теряется значение $start_from.
покажи файл userstats_track.php

#13 2008-11-22 13:40:11

flashcat
Гость

Re: Password Protected

hcs пишет:

покажи файл userstats_track.php

вот хм странно может я не туда что то добавил
http://thugzfam1ly.com/0/userstats_track.php.txt

Подвал доски

Под управлением FluxBB. Хостинг Hostens