The important links that require SID like logout and other things are still getting the SID, which is good and as expected. However, I installed SocialNet 0.5.2, it's still early in its lifecycle, so I am making code modifications to it to get it to work the way I need to to.
The original 0.5.2 code isn't compatible with mod SEO, that much I've figured out, so I've started to make the required modifications to the mod. The biggest issue is that the newsfeed, a.k.a. "Wall" in that weird things are happening to URLs passed through via the append_sid function.
1) Any URL that is PhPBB native, i.e. has ucp or other original PhPBB scripts in it gets a full absolute path, i.e. the full board URL is appended in front of it. But anything not of PhPBB origin, like external page scripts or in this case, the mainpage.php script of the mod, append_sid returns a relative path, i.e. ./phpbbdir. So when I use a mod_rewrite to make the /phpbbdir/mainpage.php the home page via
- Code: Select all
RewriteRule ^/?$ /cafe/mainpage.php [QSA,L,NC]
all the relative links of course break. For now, I have the work around to have hard wired my board URLs where ever there is a problem. This is a very unsatisfactory answer, and requires too much maintenance. Any clue why this is happening?
2) Several critical URLs aren't getting an SID when they really need one. For example,
- Code: Select all
'U_LOGIN_LOGOUT' => append_sid("{$phpbb_root_path}ucp.{$phpEx}?mode=logout&redirect={$phpbb_root_path}mainpage.{$phpEx}"), 'S_SN_MP_' . strtoupper($mode) => true,
does not return any SID, the SID is stripped.
So what is the code I need to add so that the mod SEO doesn't strip the SID from this URL?
3) The other issue is that the newsfeed spews out the old style URLs rather than the SEO rewritten URLs. I've started to make changes and inserting the proper code there, but this is less critical because I hide the newsfeed from bots since there is nothing of value for the bots to index there. But I still would like coding advice there too so I can learn.
I figured out what to add for the topics retrieval code, but not for the latest posts.
Here's what the function looks like (it is a function, so I need to add the seo global variables.
- Code: Select all
global $db, $auth, $template, $user, $config;
global $phpbb_root_path, $phpEx;
global $bbcode_bitfield, $phpbb_seo;
$a_f_auth_read = $auth->acl_getf('f_read');
$a_f_read = array();
if (!empty($a_f_auth_read))
{
foreach ($a_f_auth_read as $i_f_id => $a_auth)
{
if ($a_auth['f_read'] == 1)
{
$a_f_read[] = $i_f_id;
}
}
}
// First we fill in the list of top posts that need to be on the front page
$last_posts = 'SELECT p.post_id, p.topic_id, p.post_time, p.forum_id, t.topic_title, f.forum_name
FROM ' . POSTS_TABLE . ' p
LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id
LEFT JOIN ' . FORUMS_TABLE . ' f ON p.forum_id = f.forum_id
WHERE p.post_approved = 1
AND ' . $db->sql_in_set('p.forum_id', $a_f_read, false, true) . '
ORDER BY p.post_id DESC';
$last_posts_result = $db->sql_query_limit($last_posts, $config['mp_num_last_posts']);
$last_posts_rowset = $db->sql_fetchrowset($last_posts_result);
$db->sql_freeresult($last_posts_result);
for ($i = 0; isset($last_posts_rowset[$i]); $i++) //while ($last_posts_row = $db->sql_fetchrow($last_posts_result))
{
$last_posts_row = $last_posts_rowset[$i];
$template->assign_block_vars('last_posts', array('TOPIC_TITLE' => $last_posts_row['topic_title'],
'POST_LINK' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=" . $last_posts_row['topic_id'] . "&p=" . $last_posts_row['post_id'] . "#p" . $last_posts_row['post_id']),
'TOPIC_FORUM' => $last_posts_row['forum_name'],
'TOPIC_FORUM_LINK' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=" . $last_posts_row['forum_id']),
'POST_TIME' => snFunctions::time_ago($last_posts_row['post_time']),
));
}
// then we fill in the last five topics
$last_topics = 'SELECT t.*, p.*, f.forum_name
FROM ' . TOPICS_TABLE . ' t
LEFT JOIN ' . POSTS_TABLE . ' p ON p.post_id = t.topic_first_post_id
LEFT JOIN ' . FORUMS_TABLE . ' f ON f.forum_id = t.forum_id
WHERE t.topic_approved = 1
AND ' . $db->sql_in_set('p.forum_id', $a_f_read, false, true) . '
ORDER BY p.post_id DESC';
$last_topics_result = $db->sql_query_limit($last_topics, 5);
$last_topics_rowset = $db->sql_fetchrowset($last_topics_result);
$db->sql_freeresult($last_topics_result);
for ($i = 0; isset($last_topics_rowset[$i]); $i++) //
{
$last_topics_row = $last_topics_rowset[$i];
$topic_text = nl2br($last_topics_row['post_text']);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($topic_text, $last_topics_row['bbcode_uid'], $last_topics_row['bbcode_bitfield']);
$topic_text = smiley_text($topic_text);
// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
// need to properly initialize $phpbb_seo
if (!empty($last_topics_row['topic_url'])) {
$phpbb_seo->prepare_iurl($last_topics_row, 'topic', '');
} else {
if ($phpbb_seo->modrtype > 2) {
$last_topics_row['topic_title'] = censor_text($last_topics_row['topic_title']);
}
$cur_forum_id = (int) $last_topics_row['forum_id'];
$parent_forum = $last_topics_row['topic_type'] == POST_GLOBAL ? $phpbb_seo->seo_static['global_announce'] : (!empty($phpbb_seo->seo_url['forum'][$cur_forum_id]) ? $phpbb_seo->seo_url['forum'][$cur_forum_id] : false);
if ($parent_forum) {
$phpbb_seo->prepare_iurl($last_topics_row, 'topic', $parent_forum);
}
}
// http://www.phpBB-SEO.com SEO TOOLKIT END
// need to force URL to have the right URL and not a relative path
$topic_url = 'http://myboard.com/phpbb/'.$last_topics_row['topic_url'].$last_topics_row['topic_id'].'.html';
$template->assign_block_vars('last_topics', array(
'TOPIC_TITLE' => $last_topics_row['topic_title'],
// force url once again, how annoying
'TOPIC_POSTER' => "<a href=\"http://myboard.com/phpbb/".$last_topics_row['topic_first_poster_name']."/\">".$last_topics_row['topic_first_poster_name']."</a>",
'TOPIC_URL' => $topic_url,
'TOPIC_FORUM' => $last_topics_row['forum_name'],
'TOPIC_FORUM_LINK' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=" . $last_topics_row['forum_id']),
'POST_TIME' => snFunctions::time_ago($last_topics_row['post_time']),
'TOPIC_TEXT' => $topic_text,
// share icons
'SHARE_HEADER' => 'Share this topic:',
'SHARE_URL' => urlencode($topic_url),
'SHARE_TITLE' => urlencode($last_topics_row['topic_title']),
'SHARE_SUMMARY' => urlencode(substr($last_topics_row['post_text'], 0, 150)),
'SHARE_URL_RAW' => $topic_url,
'SHARE_TITLE_RAW' => $last_topics_row['topic_title'],
));
}
Again, in this code I am having to force the URLs to be absolute paths, which is very annoying.
Thanks for any insights you can offer.

English |
French
