2010-03-18, 02:39 AM
2010-03-18, 02:47 AM
(2010-03-18, 01:30 AM)labrocca Wrote: [ -> ]Lines like this are written poorly.
$query2[$y] = $db->query("SELECT * FROM {$config['database']['table_prefix']}users WHERE username LIKE '%".$uinfo2[1][$y]."%' LIMIT 1");
Do this:
$query2[$y] = $db->simple_select("users", "username", "username LIKE '%".$uinfo2[1][$y]."%',array('limit' => 1));
That should work.
Really you shouldn't use LIKE imho. Basically if username doesn't exist then just display the regular code. A couple more things could be fine tuned on this plugin.
True, but simple_select escaped my mind when the base code was written. This was a modified version of my UInfo MyCode, so back then I was totally lost. And my use of LIKE is so you don't need to type out the entire username. Like if I'm lazy or something, I'd rather do [@labr] instead of [@labrocca]
2010-03-18, 03:15 AM
Quote:And my use of LIKE is so you don't need to type out the entire username.
That's a bad idea. What if there is a user labr?
I have 100,000 members at HF. Lots of names are similar.
2010-03-18, 03:21 AM
(2010-03-18, 03:15 AM)labrocca Wrote: [ -> ]Quote:And my use of LIKE is so you don't need to type out the entire username.
That's a bad idea. What if there is a user labr?
I have 100,000 members at HF. Lots of names are similar.
Eh ... Wiseass.
2010-03-18, 03:24 AM
A quick HF search for usernames lik labr gets me 5 results.
allabros
rahulabrol6
labrendant
Frankylabrule
blacklabrador88
Now what?
allabros
rahulabrol6
labrendant
Frankylabrule
blacklabrador88
Now what?
2010-03-18, 03:36 AM
(2010-03-18, 03:24 AM)labrocca Wrote: [ -> ]A quick HF search for usernames lik labr gets me 5 results.
allabros
rahulabrol6
labrendant
Frankylabrule
blacklabrador88
Now what?
Already got it to need the right username. Now if build_profile_link didn't return Guest if it doesn't exist, I could remove the need for the brackets.
Maybe I could cheapen it and replace "Guest" with the original username ... Of course, that causes a problem if someone registers that name.
2010-03-20, 02:54 PM
So now, I just need to work on the fact that it has it's own newline somewhere, and maybe work on removing the need for [@name]
2010-03-20, 06:28 PM
Really cool plugin! I just made some changes to use on my forum:
Just use @username & ta-da!
Works like a charm :p
Just use @username & ta-da!
$plugins->add_hook("parse_message", "twitter");
$plugins->add_hook("member_profile_start", "twitter_username_redirect");
function twitter(&$message2)
{
global $mybb, $db;
$message2 = preg_replace('/(^|[^a-z0-9_])@([a-z0-9_]+)/i', ' @<a href="member.php?action=profile&username=$2">$2</a>', $message2);
return $message2;
}
function twitter_username_redirect()
{
global $mybb, $db;
if(!empty($mybb->input['username']))
{
$q = $db->simple_select('users', 'uid', 'username = "' . $mybb->input['username'] . '"');
$result = $db->fetch_array($q);
$mybb->input['action'] = 'profile';
if(is_array($result))
{
//header('Location: member.php?action=profile&uid=' . $result['uid']);
$mybb->input['uid'] = $result['uid'];
}
else
{
// User not found
//header('Location: member.php?action=profile&uid=0');
$mybb->input['uid'] = 0;
}
}
}
Works like a charm :p
2010-03-24, 11:22 PM
Not bad, I'm still working on mine.
2010-06-04, 04:56 PM
Nice plugin!
I did something similar to this on my board, except it was the urls not the names. (http://www.example.com/@mykeled123)
I did something similar to this on my board, except it was the urls not the names. (http://www.example.com/@mykeled123)