vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   getting username, title, ranks from user id (need php code) (https://vborg.vbsupport.ru/showthread.php?t=224810)

MyPornLife.info 10-08-2009 08:32 AM

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. :)

Lynne 10-08-2009 02:02 PM

Look up the function fetch_userinfo (do a search in your files for it, I can't remember which file it is in).

MyPornLife.info 10-08-2009 03:09 PM

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

Lynne 10-08-2009 03:24 PM

You might want to familiarize yourself with the vBulletin API. In the functions, you will find fetch_rank.

Brother Malachi 10-08-2009 03:55 PM

Isn't his SQL query open to injection attacks?
Unless vB's query_read() function protects against it.

Lynne 10-08-2009 04:38 PM

Like I told him, he should use the existing functions. And yes, he should use the input cleaner also.

MyPornLife.info 10-08-2009 11:04 PM

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

Lynne 10-09-2009 12:08 AM

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.

MyPornLife.info 10-09-2009 12:56 AM

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

Lynne 10-09-2009 01:01 AM

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.


All times are GMT. The time now is 11:21 PM.

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.01184 seconds
  • Memory Usage 1,755KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete