Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2009, 08:32 AM
MyPornLife.info MyPornLife.info is offline
 
Join Date: Apr 2009
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default getting username, title, ranks from user id (need php code)

hey im making a page.
I'll provide it a user id & i want it to show that
- user name (with proper HTML markup)
- user title (custom title if that user use one)
- ranks


i mean i'll type the link like this:
http://DOMAIN/PATH/MYFILE.php?u=6 (here 6 is the user id)

it'll show me those info of user-6

plz give me the php code for such a file...

thank you.
Reply With Quote
  #2  
Old 10-08-2009, 02:02 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Look up the function fetch_userinfo (do a search in your files for it, I can't remember which file it is in).
Reply With Quote
  #3  
Old 10-08-2009, 03:09 PM
MyPornLife.info MyPornLife.info is offline
 
Join Date: Apr 2009
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i looked in function.php file & found some code...based on those i wrote these code

PHP Code:
$userid $_REQUEST['u'];

$userinfo $db->query_read("SELECT username, usertitle, usergroupid FROM " TABLE_PREFIX "user WHERE userid=$userid");
$userinfo $vbulletin->db->fetch_array($userinfo);

$usergroup $userinfo['usergroupid'];

$username $userinfo['username'];
$musername $vbulletin->usergroupcache["$usergroup"]['opentag'] . $username $vbulletin->usergroupcache["$usergroup"]['closetag'];

$usertitle $userinfo['usertitle']; 
so it can show username (with html mark) by $musername & that user's title (or custom title) by $usertitle

but what about Ranks


plz help me about RANKS
Reply With Quote
  #4  
Old 10-08-2009, 03:24 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You might want to familiarize yourself with the vBulletin API. In the functions, you will find fetch_rank.
Reply With Quote
  #5  
Old 10-08-2009, 03:55 PM
Brother Malachi Brother Malachi is offline
 
Join Date: Jun 2008
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Isn't his SQL query open to injection attacks?
Unless vB's query_read() function protects against it.
Reply With Quote
  #6  
Old 10-08-2009, 04:38 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Like I told him, he should use the existing functions. And yes, he should use the input cleaner also.
Reply With Quote
  #7  
Old 10-08-2009, 11:04 PM
MyPornLife.info MyPornLife.info is offline
 
Join Date: Apr 2009
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

guys english plz im not an advance vb coder.

1st of all what is "SQL query open to injection attacks". how can i solve it?

lynne u told about existing functions !

could u guys plz, plz & plz post some PHP code here as an example? plz stop telling look here or there...find it....its really not an easy thing for a novice coder
Reply With Quote
  #8  
Old 10-09-2009, 12:08 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The existing php code is in the vbulletin files. Did you try a search in the files for fetch_userinfo? It shows up many times and you can see the use of it. These are some excepts from a page I use:

First the cleaner is used on the userid that is passed from the form:
PHP Code:
$vbulletin->input->clean_array_gpc('r', array(
    
'f'    => TYPE_UINT,
    
'do'  => TYPE_STR,
    
'u'    => TYPE_UINT,
)); 
then the userinfo is obtained a few lines after and I grab the username (and other stuff later):
PHP Code:
      $userinfo fetch_userinfo($vbulletin->GPC['u']);
        
$username $userinfo['username']; 
Take a look at the function itself to see all the info obtained in the query - in includes/functions.php

There are articles you can read on the user of the vbulletin cleaner and on writing secure code.
Reply With Quote
  #9  
Old 10-09-2009, 12:56 AM
MyPornLife.info MyPornLife.info is offline
 
Join Date: Apr 2009
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you Lynne. thank you very much.
especially for
PHP Code:
fetch_userinfo($vbulletin->GPC['u']); 
but still cant do it for Rank
i tried something like this
PHP Code:
require_once('./includes/functions_ranks.php');

$vbulletin->input->clean_array_gpc('r', array(
    
'f'    => TYPE_UINT,
    
'do'  => TYPE_STR,
    
'u'    => TYPE_UINT,
)); 

$rank fetch_rank($vbulletin->GPC['u']);
$rank $rank['rankimg'];

echo 
$rank
showing nothing


can u plz help me....plz
Reply With Quote
  #10  
Old 10-09-2009, 01:01 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you look the function up in the API like I suggested? The API will tell you what file it is in. Or, do a search in the files for the function to find what file it is in and then make sure you either include the file in your code, or copy/paste the function into your code.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:03 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04299 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete