Okay, so I'm attempting to build a Signature Bar script for UnSyntax Software from the code Kerm posted in http://www.cemetech.net/forum/viewtopic.php?t=1040&start=300. However, I've run into a couple snags: I can't get the script to work properly and I don't know what exactly I'd need to put in .htaccess.

The code generates the image fine, but it doesn't generate user info from the ?uid=[#] in the URL. Am I missing something? Is this just not standard phpBB2 code?
Code:
<?
define('IN_PHPBB', true);

 $site_root_path = '../';
$phpbb_root_path2 = '';
$phpbb_root_path = $site_root_path . $phpbb_root_path2;
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.php');

$userdata = session_pagestart($user_ip, PAGE_VIEWONLINE);
init_userprefs($userdata);

$uid = preg_replace('/[^\d]/','',$_GET['uid']);
$sql = "SELECT * FROM forum_users WHERE user_id = '" . $uid . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);

$badge = imagecreatefrompng("unssbadge.png");
$red = imagecolorallocate($badge, 128, 0, 0);
$green = imagecolorallocate($badge, 0, 128, 0);
$black = imagecolorallocate($badge, 0, 0, 0);

if (isset($row['user_custom_title']) && $row['user_custom_title'] != NULL) { $title = $row['user_custom_title'];
} else if ($row['user_rank'] != 0 && $row['user_rank'] != NULL && isset($row['user_rank'])) {
   $sql = "SELECT rank_title FROM forum_ranks WHERE rank_id = '" . $row['user_rank'] . "'";
   $result = $db->sql_query($sql);
   $row2 = $db->sql_fetchrow($result);
   $title = $row2[0];
} else {
   $sql = "SELECT * FROM forum_ranks WHERE rank_special <> '1'";
   $result = $db->sql_query($sql);
   while ($row2 = $db->sql_fetchrow($result))
   {
      if ($row2['rank_min'] < $row['user_posts']) { $title = $row2['rank_title']; }
   }
}
$fitten = time() - 300;
$sql = "SELECT * FROM forum_sessions WHERE session_user_id = '" . $row['user_id'] . "' AND session_time > '$fitten'";
$result = $db->sql_query($sql);

////////////////////////////////////////

if ($db->sql_numrows($result) == 0)
{
   imagestring ($badge, 2, 5, 26, 'OFFLINE', $red);
} else {
   imagestring ($badge, 2, 5, 26, 'ONLINE', $green);
}
imagestring ($badge, 3, 5, 5, $row['username'], $black);

header("Content-type: image/png");
$width = 350;
$height = 38;
imagepng($badge);
imagedestroy($badge);

?>
As for .htaccess, I know I'd have to use a RewriteRule but I don't exactly understand how it works and Google isn't helping me much.
Chances are your users table isn't forum_users - it might be phpbb_users, phpbb2_users, or something else.
Oh, yeah. Duh..
I swear, every single time I try to learn by modifying others' code, I do this same thing!
(That is, if they've given it out for others to use and learn with Wink )

Thanks Kerm. I don't think I'd survive my level of newbish obliviousness without you or the rest of Cemetech Laughing
KeithJohansen wrote:
Oh, yeah. Duh..
I swear, every single time I try to learn by modifying others' code, I do this same thing!
(That is, if they've given it out for others to use and learn with Wink )

Thanks Kerm. I don't think I'd survive my level of newbish obliviousness without you or the rest of Cemetech 0x5
Haha, no problem. Did that fix it for you? Also, is the htaccess redirect still not working for you?
Yeah, fixed it perfect Very Happy
And I haven't even finished the actual Sig Bar yet, so I haven't taken a crack at the .htaccess. I'll probably need a little help with it too.
you had another thread here the other day with a .htaccess question, I would refer to that. I have an example of one of my redirects in there.
Yes, I know. And I remember how to do a simple
Code:
Redirect [url] [url]
What I don't know is how to do this for a redirect of ../phpbb/Signature/[UID].png to ../phpbb/Signature/userbadge.php?uid=[UID]. Or would I have to rewrite the URL with RewriteRule instead (which I don't quite understand either)?
KeithJohansen wrote:
Yes, I know. And I remember how to do a simple
Code:
Redirect [url] [url]
What I don't know is how to do this for a redirect of ../phpbb/Signature/[UID].png to ../phpbb/Signature/userbadge.php?uid=[UID]. Or would I have to rewrite the URL with RewriteRule instead (which I don't quite understand either)?
I gave the exact example of how I d it for this site in that thread. I'd recommend referring to it.
>< I didn't even see that. Wow, I really am newbishly oblivious
Thanks yet again Kerm and Rivereye. Smile

[edit]
Okay, still having a little trouble with the .htaccess.
Code:
RewriteEngine On
RewriteRule ^Signature/([0-9]+).png Signature/userbadge.php?uid=$1


I get a "404 Not Found" error with "The requested URL /phpbb/Signature/2.png was not found on this server."
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteRule
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement