PunBB + PE

это не просто форум

30.10.2008 17:27:15 #1: niikto ↓ 

Administrator
MArt Keepers
bmw-club
jaga-jaga
Откуда: Омск
Здесь с: 25.03.2007
Сообщений: 177
Вебсайт

ошибка при попытке подписаться на тему (добавить её в избранное)

An error was encountered
File: /home/.../public_html/samovarchik/misc.php
Line: 406

PunBB reported: Unable to fetch topic info

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 'AND t.moved_to IS NULL' at line 1 (Errno: 1064)

Неактивен

 

20.11.2009 23:25:29 #2: fourent ↓ 

Участник
Здесь с: 30.01.2009
Сообщений: 14

Re: ошибка при попытке подписаться на тему (добавить её в избранное)

Так как всё-таки лечить?

Неактивен

 

07.12.2009 08:31:35 #3: artoodetoo ↓ 

Administrator
MArt Keepers
bmw-club
Откуда: Россия
Здесь с: 14.03.2007
Сообщений: 715
Вебсайт

Re: ошибка при попытке подписаться на тему (добавить её в избранное)

Здесь ошибка не возникает. Смогу ответить если кто-то приведет мне кусок кода где возникает ошибка ИЗ СВОЕЙ ВЕРСИИ.
Подозреваю, что дело в неинициализированной переменной.

Неактивен

 

09.12.2009 19:23:46 #4: fourent ↓ 

Участник
Здесь с: 30.01.2009
Сообщений: 14

Re: ошибка при попытке подписаться на тему (добавить её в избранное)

Как указывает niikto, ошибка возникает в файле misc.php
Умнее ничего не придумал, как заслать его сюда


Вложения
  • misc.php.zip

Отредактированно fourent (09.12.2009 19:24:16)

Неактивен

 

11.12.2009 10:46:34 #5: artoodetoo ↓ 

Administrator
MArt Keepers
bmw-club
Откуда: Россия
Здесь с: 14.03.2007
Сообщений: 715
Вебсайт

Re: ошибка при попытке подписаться на тему (добавить её в избранное)

Выяснил: да, подписка содержит ошибку. Я дал возможность подписываться сразу на список тем через запятую, но недоделал.
Вот исправление. В misc.php найти фрагмент
else if (isset($_GET['subscribe']))
и заменить всё до следующего else if на

Код:

else if (isset($_GET['subscribe']))
{
    if ($pun_user['is_guest'] || $pun_config['o_subscriptions'] != '1')
        message($lang_common['No permission']);

    // Accept comma-separated id list
    $topic_ids = (strpos($_GET['subscribe'], ',') !== false) ? explode(',', $_GET['subscribe']) : array($_GET['subscribe']);
    $topic_ids = array_map('intval', $topic_ids);
    if (count($topic_ids) < 1)
        message($lang_common['Bad request']);

    // Make sure the user can view the topic
    foreach ($topic_ids as $topic_id)
    {
        $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id=1) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$topic_id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
        if (!$db->num_rows($result))
            message($lang_common['Bad request']);

        $result = $db->query('SELECT topic_id FROM '.$db->prefix.'subscriptions WHERE user_id='.$pun_user['id'].' AND topic_id IN('.implode(',',$topic_ids).')') or error('Unable to fetch subscription info', __FILE__, __LINE__, $db->error());
        if ($db->num_rows($result))
            message($lang_misc['Already subscribed']);

        $db->query('INSERT INTO '.$db->prefix.'subscriptions (user_id, topic_id) VALUES('.$pun_user['id'].' ,'.$topic_id.')') or error('Unable to add subscription', __FILE__, __LINE__, $db->error());
    }

    // Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to given topic after that)
    $redirect_url = (isset($_SERVER['HTTP_REFERER']) && preg_match('#^'.preg_quote($base_url).'/(.*?)\.php#i', $_SERVER['HTTP_REFERER'])) ? htmlspecialchars($_SERVER['HTTP_REFERER']) : ($base_url.'/viewtopic.php?id='.$topic_ids[0]);
    redirect($redirect_url, $lang_misc['Subscribe redirect']);
}

Неактивен

 

14.12.2009 01:15:21 #6: fourent ↓ 

Участник
Здесь с: 30.01.2009
Сообщений: 14

Re: ошибка при попытке подписаться на тему (добавить её в избранное)

Ага, спасибо, вот теперь порядок.

Неактивен

 

Board footer

Powered by PunBB + PE

Valid XHTML Valid CSS

[ Generated in 0.023 seconds, 9 queries executed ]