Uutiset:

Wondering if this will always be free?  See why free is better.

Main Menu
Advertisement:

SSI Functions on SMF 2.0. Beta 4.

Aloittaja Jim R, helmikuu 03, 2009, 03:15:22 AP

« edellinen - seuraava »

Jim R

I'll post this here to keep it in the same topic:

Going from 1.1.4 to 2.0 Beta 4, I'm having some SSI issues.  The issue appears to be with how the database is queried.  The function in question originally was a Mod back around 1.1.2, but it carried through 1.1.4.  Now it's not working.


Here is the error I'm getting now:

Fatal error: Call to undefined function db_query() in /home/jwrbloom/public_html/indianaselect/smf/SSI.php on line 1999


I have line 1999 marked pretty well down below.


// Show the latest news, MULTIPLE BOARDS....

function ssi_boardNewsMulti($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')
{
global $scripturl, $db_prefix, $txt;
global $settings, $modSettings, $context;

loadLanguage('Stats');

// Must be integers....
if ($limit === null)
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
else
$limit = (int) $limit;

if ($start === null)
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
else
$start = (int) $start;

if ($board === null && isset($_GET['board']))
$board = (int) $_GET['board'];

if ($length === null)
$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
else
$length = (int) $length;

// Make sure guests can see this board.

>>>LINE 1999-------
               $request = db_query("

SELECT ID_BOARD
FROM {$db_prefix}boards
WHERE " . ($board === null ? '' : "ID_BOARD IN (" . (is_array($board) ? implode(', ', $board) : $board) . ")
AND ") . "FIND_IN_SET(-1, memberGroups)", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
{
if ($output_method == 'echo')
die($txt['smf_news_error2']);
else
return array();
}
$boards = array();
while ($board = mysql_fetch_assoc($request))
$boards[] = $board['ID_BOARD'];
mysql_free_result($request);


Jim R

It appears it will do it multiple times.  Here is the Function/mod in its entirety:



// Show the latest news, MULTIPLE BOARDS....
function ssi_boardNewsMulti($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')
{
global $scripturl, $db_prefix, $txt;
global $settings, $modSettings, $context;

loadLanguage('Stats');

// Must be integers....
if ($limit === null)
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
else
$limit = (int) $limit;

if ($start === null)
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
else
$start = (int) $start;

if ($board === null && isset($_GET['board']))
$board = (int) $_GET['board'];

if ($length === null)
$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
else
$length = (int) $length;

// Make sure guests can see this board.
$request = db_query("
SELECT ID_BOARD
FROM {$db_prefix}boards
WHERE " . ($board === null ? '' : "ID_BOARD IN (" . (is_array($board) ? implode(', ', $board) : $board) . ")
AND ") . "FIND_IN_SET(-1, memberGroups)", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
{
if ($output_method == 'echo')
die($txt['smf_news_error2']);
else
return array();
}
$boards = array();
while ($board = mysql_fetch_assoc($request))
$boards[] = $board['ID_BOARD'];
mysql_free_result($request);

// Load the message icons - the usual suspects.
$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find the post ids.
$request = db_query("
SELECT ID_FIRST_MSG
FROM {$db_prefix}topics
WHERE ID_BOARD IN (" . implode(', ', $boards) . ")
ORDER BY ID_FIRST_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
$posts[] = $row['ID_FIRST_MSG'];
mysql_free_result($request);

if (empty($posts))
return array();


// Find the posts.
$request = db_query("
SELECT
    m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
    t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked,
      b.name AS bName, b.ID_BOARD AS ID_BOARD
FROM
  ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
  LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
  LEFT JOIN {$db_prefix}boards AS b ON (m.ID_BOARD = b.ID_BOARD)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
    AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT " . count($posts), __FILE__, __LINE__);
$return = array();
while ($row = mysql_fetch_assoc($request))
{
// If we want to limit the length of the post.
if (!empty($length) && strlen($row['body']) > $length)
{
$row['body'] = substr($row['body'], 0, $length);

// The first space or line break. (<br />, etc.)
$cutoff = max(strrpos($row['body'], ' '), strrpos($row['body'], '<'));

if ($cutoff !== false)
$row['body'] = substr($row['body'], 0, $cutoff);
$row['body'] .= '...';
}

$row['body'] = parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']);

// Check that this message icon is there...
if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

censorText($row['subject']);
censorText($row['body']);

$return[] = array(
'board' => $row['bName'],
'id' => $row['ID_TOPIC'],
'message_id' => $row['ID_MSG'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'subject' => $row['subject'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'body' => $row['body'],
'href2' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] .' Reports</a>',
'href' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0"',
'link' => $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['smf_news_1'] : $txt['smf_news_2']) . '</a>',
'replies' => $row['numReplies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'],
'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a>',
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => !empty($row['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] : '',
'link' => !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName']
),
'locked' => !empty($row['locked']),
'is_last' => false
);
}
mysql_free_result($request);

if (empty($return))
return $return;

$return[count($return) - 1]['is_last'] = true;

if ($output_method != 'echo')
return $return;

foreach ($return as $news)
{
echo '
<div>
<a href="', $news['href'], '">', $news['icon'], '</a> <b>', $news['subject'], '</b>
<div class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '</div>

<div class="post" style="padding: 2ex 0;">', $news['body'], '</div>

', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '
</div>';

if (!$news['is_last'])
echo '
<hr style="margin: 2ex 0;" width="100%" />';
}
}



greyknight17

Topic split to avoid confusion. Your issue here seems to be a little different than the other poster's problem.

Are you using SMF 2.0 beta now? If so, you need to have an updated SSI.php file as the queries definitely has changed.

Jim R

I am using 2.0 Beta 4.  I posted another post within the Mod topic for ssi_boardNews Multi boards.  There is a manual install for 2.0 Beta 4, but the directions include code for the old query code, so it doesn't work.


greyknight17

Have you tried using a newer SSI.php file (from the 2.0 download files) to see if it helps? You can rename the original SSI.php file you have instead of replacing it.

Jim R

I just used the SSI.php file which came with 2.0 Beta 4 download, then copied over the ssi_boardNews function, which I had renamed as ssi_multiBoard.  The way it queries the database is different.  I can't get it to work.

Rumbaar

The $db queries were changed in 2.0 from 1.1.x

1.1
$request = db_query("
2.0
$request = $smcFunc['db_query']('substring', '

You'll need to get the mod author to update their mod to the 2.0 syntax.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Advertisement: