| :: |
| Author |
Message |
HB. PR0

Joined: 26 Oct 2006 Posts: 62
|
Posted: Tue Apr 17, 2007 4:34 pm Post subject: mod Rewrite and phpbb fetchall (display poll) |
|
|
Hello,
I ran a search on using the keyword "fetchall" and came up with a somewhat close result. I currently have mod rewrite installed on my forum, and now I have started to create a website around my forum. I'm using phpbb fetchall to pull certain data from the forum, and display on my home page. I'm trying to pull the Polls data but the fetchall script uses the standard phpbb urls while of course mod Rewrite changes them. I believe this is why I'm getting a blank area where the poll should be, but on another test site using a vanilla phpbb forum the poll displays. I would be thankful for your help, here is the code from the poll section
| Code: |
<!-- POLL -->
<?php if (isset($poll)) { ?>
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" height="28"><span class="cattitle"><?php echo $lang['Poll_question']; ?></span></td>
</tr>
<tr>
<td class="row1" align="center" width="100%">
<?php if (!$poll) { ?>
<span class="gensmall"><b>No poll at the moment.</b></span>
<?php } else { ?>
<span class="gensmall"><b><?php echo $poll['vote_text']; ?></b></span>
</font>
<form method="post" action="<?php echo append_sid($phpbb_root_path . 'posting.php?t=' . $poll['topic_id']); ?>">
<table>
<?php for ($i = 0; $i < count($poll['options']); $i++) { ?>
<tr>
<td>
<input type="radio" name="vote_id" value="<?php echo $poll['options'][$i]['vote_option_id']; ?>">
</td>
<td>
<span class="gensmall"><?php echo $poll['options'][$i]['vote_option_text']; ?></span>
</td>
<td nowrap="nowrap">
<span class="gensmall">[ <?php echo $poll['options'][$i]['vote_result']; ?> ]</span>
</td>
</tr>
<?php } ?>
</table>
<?php if ($userdata['session_logged_in']) { ?>
<input type="submit" class="mainoption" name="submit" value="<?php echo $lang['Submit_vote']; ?>">
<input type="hidden" name="topic_id" value="<?php echo $poll['topic_id']; ?>">
<input type="hidden" name="mode" value="vote">
<?php } else { ?>
<span class="gensmall"><?php echo $lang['Rules_vote_cannot']; ?></span>
<?php } ?>
<br />
<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id'] . '&vote=viewresult'); ?>"><?php echo $lang['View_results']; ?></a></span>
</form>
<?php } ?>
</td>
</tr>
</table>
<br />
<?php } ?>
<!-- POLL --> |
|
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
Posted: Wed Apr 18, 2007 7:50 pm Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
This mods dos not output a topic link, but a view poll result link.
You could mod it slightly to output the topic title instead, would not make big difference for user who would still be able to view the poll results from the topic.
And then have the link rewritten, but, from the piece of code you posted, I cannot tell if the topic title is available for url injection.
The link as is is using $lang['View_results'] instead.
So we need to find out where the SQL query is performed to build the $poll array, and make sure topic title is queried from here and then do the rewrite trick.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
HB. PR0

Joined: 26 Oct 2006 Posts: 62
|
Posted: Wed Apr 18, 2007 9:33 pm Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
Ok thanks for the reply, here is a copy of the entire mod, well at least the portal.php. I'm just taking bits and pieces from it for example the profile section, the login section, and the poll. I later intend on adding the smartor album snipt of code, but I don't think I have mod-rewrite setup for the album.
[mod]Was not in this one, could you preferably post links to ZIP archive instead, to much code kills code [/mod] |
|
|
| Back to top |
|
 |
HB. PR0

Joined: 26 Oct 2006 Posts: 62
|
Posted: Wed Apr 18, 2007 9:34 pm Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
Here is the poll.php, but I don't think you'll need it.
| Code: | <?php
###############################################################################
## ##
## phpBB Fetch All - A modification to phpBB that displays data from the ##
## forum on any page of a website. ##
## ------------------------------------------------------------------------- ##
## This module contains functions for fetching poll related data. ##
## ##
###############################################################################
## ##
## Authors: Volker 'Ca5ey' Rattel <webmaster@phpbbfetchall.com> ##
## http://www.phpbbfetchall.com/ ##
## ##
## This file is free software; you can redistribute it and/or modify it ##
## under the terms of the GNU General Public License as published by the ##
## Free Software Foundation; either version 2, or (at your option) any later ##
## version. ##
## ##
## This file is distributed in the hope that it will be useful, but WITHOUT ##
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ##
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for ##
## more details. ##
## ##
###############################################################################
###############################################################################
## NO CHANGES NEEDED BELOW
###############################################################################
//
// prevent hacking attempt
//
if (!defined('IN_PHPBB'))
{
die('hacking attempt');
}
###############################################################################
## ##
## phpbb_fetch_poll() ##
## ------------------------------------------------------------------------- ##
## Fetches a poll and the vote results. You can specify the forum from which ##
## the poll will be fetched. If auth_check is enabled the the poll will be ##
## checked against the user permissions. ##
## ##
## PARAMETER ##
## ##
## forum_id ##
## ##
## this can be either null to fetch the latest poll from the whole ##
## board like ##
## ##
## $poll = phpbb_fetch_poll(); ##
## ##
## or you can specify a single forum with ##
## ##
## $poll = phpbb_fetch_poll(1); ##
## ##
## or - finally - you can specify a list of forums with ##
## ##
## $poll = phpbb_fetch_poll(array(1, 2, 3)); ##
## ##
## EXAMPLE ##
## ##
## $poll = phpbb_fetch_poll(); ##
## ##
## if ($poll) ##
## { ##
## echo $poll['vote_text']; ##
## echo '<form method="post" action="' . $phpbb_root_path; ##
## echo 'posting.php?t=' . $poll['topic_id'] . '">'; ##
## for ($i = 0; $i < count($poll['options']); $i++) ##
## { ##
## echo '<input type="radio" name="vote_id" value="'; ##
## echo $poll['options'][$i]['vote_option_id'] . '">'; ##
## echo $poll['options'][$i]['vote_option_text']; ##
## echo '<br>'; ##
## } ##
## echo '<input type="hidden" name="topic_id" value="'; ##
## echo $poll['topic_id'] . '">'; ##
## echo '<input type="hidden" name="mode" value="vote">'; ##
## echo '<input type="submit" name="submit" value="Vote">'; ##
## } ##
## ##
###############################################################################
function phpbb_fetch_poll($forum_id = null)
{
global $CFG;
//
// create a list of forums with read permission
// (only takes action when auth_check is enabled)
//
phpbb_get_auth_list();
//
// determine the forum list based on the user input
// and/or permissions (depends on auth check)
//
$forum_list = phpbb_get_forum_list($forum_id);
//
// if read permissions do not allow us to fetch anything
// we return nicely
//
if (!$forum_list and $CFG['auth_check'])
{
return;
}
$sql = 'SELECT f.*, p.*, pt.*, t.*, u.*, vd.*
FROM ' . TOPICS_TABLE . ' AS t,
' . USERS_TABLE . ' AS u,
' . POSTS_TEXT_TABLE . ' AS pt,
' . POSTS_TABLE . ' AS p,
' . FORUMS_TABLE . ' AS f,
' . VOTE_DESC_TABLE . ' AS vd
WHERE t.topic_poster = u.user_id
AND t.topic_first_post_id = pt.post_id
AND t.topic_first_post_id = p.post_id
AND t.topic_status <> 1
AND t.topic_status <> 2
AND t.topic_vote = 1
AND t.forum_id = f.forum_id
AND t.topic_id = vd.topic_id';
if ($forum_list)
{
$sql .= '
AND t.forum_id IN (' . $forum_list . ')';
}
$sql .= '
ORDER BY p.post_time DESC
LIMIT 0,1';
$result = phpbb_fetch_row($sql);
if ($result)
{
$sql = 'SELECT *
FROM ' . VOTE_RESULTS_TABLE . '
WHERE vote_id = ' . $result['vote_id'] . '
ORDER BY vote_option_id';
$result['options'] = phpbb_fetch_rows($sql);
}
return $result;
} // end func phpbb_fetch_poll
###############################################################################
## ##
## phpbb_fetch_poll_bt() ##
## ------------------------------------------------------------------------- ##
## Fetches a poll and the vote results. You can specify the topic id from ##
## which the poll will be fetched. Thanks to abravorus. ##
## ##
## PARAMETER ##
## ##
## topic_id ##
## ##
## a single topic id ##
## ##
## EXAMPLE ##
## ##
## $poll = phpbb_fetch_poll_bt(1); ##
## ##
## if ($poll) ##
## { ##
## echo $poll['vote_text']; ##
## echo '<form method="post" action="' . $phpbb_root_path; ##
## echo 'posting.php?t=' . $poll['topic_id'] . '">'; ##
## for ($i = 0; $i < count($poll['options']); $i++) ##
## { ##
## echo '<input type="radio" name="vote_id" value="'; ##
## echo $poll['options'][$i]['vote_option_id'] . '">'; ##
## echo $poll['options'][$i]['vote_option_text']; ##
## echo '<br>'; ##
## } ##
## echo '<input type="hidden" name="topic_id" value="'; ##
## echo $poll['topic_id'] . '">'; ##
## echo '<input type="hidden" name="mode" value="vote">'; ##
## echo '<input type="submit" name="submit" value="Vote">'; ##
## } ##
## ##
###############################################################################
function phpbb_fetch_poll_bt($topic_id = null)
{
global $CFG;
if (!isset($topic_id))
{
return;
}
$sql = 'SELECT f.*, p.*, pt.*, t.*, u.*, vd.*
FROM ' . TOPICS_TABLE . ' AS t,
' . USERS_TABLE . ' AS u,
' . POSTS_TEXT_TABLE . ' AS pt,
' . POSTS_TABLE . ' AS p,
' . FORUMS_TABLE . ' AS f,
' . VOTE_DESC_TABLE . ' AS vd
WHERE vd.topic_id = ' . $topic_id . '
AND t.topic_poster = u.user_id
AND t.topic_first_post_id = pt.post_id
AND t.topic_first_post_id = p.post_id
AND t.topic_status <> 1
AND t.topic_status <> 2
AND t.topic_vote = 1
AND t.forum_id = f.forum_id
AND t.topic_id = vd.topic_id';
$sql .= '
ORDER BY p.post_time DESC
LIMIT 0,1';
$result = phpbb_fetch_row($sql);
if ($result)
{
//
// perform an auth check if requested
//
if ($CFG['auth_check'])
{
phpbb_get_auth_list();
if (!in_array($result['forum_id'], $CFG['auth_list']))
{
return;
}
}
$sql = 'SELECT *
FROM ' . VOTE_RESULTS_TABLE . '
WHERE vote_id = ' . $result['vote_id'] . '
ORDER BY vote_option_id';
$result['options'] = phpbb_fetch_rows($sql);
}
return $result;
} // end func phpbb_fetch_poll_bt
###############################################################################
## ##
## phpbb_fetch_poll_voters() ##
## ------------------------------------------------------------------------- ##
## Fetches all users who voted for the given poll. ##
## ##
## PARAMETER ##
## ##
## vote_id ##
## ##
## a single vote id ##
## ##
## EXAMPLE ##
## ##
## $voted = false; ##
## $poll = phpbb_fetch_poll(); ##
## $voters = phpbb_fetch_poll_voters($poll['vote_id']); ##
## ##
## for ($i = 0; $i < count($voters); $i++) ##
## { ##
## if ($voters[$i]['vote_user_id'] == $userdata['user_id']) ##
## { ##
## $voted = true; ##
## } ##
## } ##
## ##
## echo $voted ? 'true' : 'false'; ##
## ##
###############################################################################
function phpbb_fetch_poll_voters($vote_id = null)
{
if ($vote_id and !intval($vote_id))
{
phpbb_raise_error('Vote ID must be a numeric value.',
__FILE__, __LINE__);
}
$sql = 'SELECT * FROM ' . VOTE_USERS_TABLE . '
WHERE vote_id = ' . $vote_id . '
ORDER BY vote_user_id';
$result = phpbb_fetch_rows($sql);
return $result;
} // end func phpbb_fetch_poll_voters
?>
|
|
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
Posted: Thu Apr 19, 2007 8:15 am Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
All right, so it's doable
In you first code snipet, the one outputting links, find :
| Code: | | <span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id'] . '&vote=viewresult'); ?>"><?php echo $lang['View_results']; ?></a></span> |
Replace with :
| Code: | <?php
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$phpbb_seo->seo_url['topic'][$poll['topic_id']] = $phpbb_seo->format_url($poll['topic_id']);
// www.phpBB-SEO.com SEO TOOLKIT END
?>
<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id']); ?>"><?php echo $poll['topic_title']; ?></a></span> |
Should do it.
If not, we'll grab title from the poll function, since they are grabbed from there.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
HB. PR0

Joined: 26 Oct 2006 Posts: 62
|
Posted: Thu Apr 19, 2007 9:44 am Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
| hmmm...maybe we can try your second method, the poll still is not displaying. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
HB. PR0

Joined: 26 Oct 2006 Posts: 62
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
Posted: Fri Apr 20, 2007 7:59 am Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
So you're using CH, so it must be because you're not using 0.2.x phpBB SEO mod rewrite isn't it.
So try first to only replace :
| Code: | <span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id'] . '&vote=viewresult'); ?>"><?php echo $lang['View_results']; ?></a></span>
|
with :
| Code: |
<span class="gensmall"><a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $poll['topic_id']); ?>"><?php echo $poll['topic_title']; ?></a></span> |
to see how it goes.
Then, with the 0.0.x versions of the phpBB SEO mod rewrite, the trick should be more like adding like before :
Instead of :
| Code: | // www.phpBB-SEO.com SEO TOOLKIT BEGIN
$phpbb_seo->seo_url['topic'][$poll['topic_id']] = $phpbb_seo->format_url($poll['topic_id']);
// www.phpBB-SEO.com SEO TOOLKIT END |
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Last edited by dcz on Mon Apr 23, 2007 10:39 am; edited 1 time in total |
|
| Back to top |
|
 |
HB. PR0

Joined: 26 Oct 2006 Posts: 62
|
Posted: Sun Apr 22, 2007 3:28 am Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
| ok, I just tried those methods, and they didn't work. So I installed the same older version of CH to see if the conflict lies within the mod, and yes it does. So I'll have to seek the answer over at their forum. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
HB. PR0

Joined: 26 Oct 2006 Posts: 62
|
Posted: Tue Apr 24, 2007 6:44 am Post subject: Re: mod Rewrite and phpbb fetchall (display poll) |
|
|
| So far your CH rewrite appears to be working fine on my board, but I am using a older version of CH. |
|
|
| Back to top |
|
 |
|
|