PDA

View Full Version : Get User Id in Media Gallery


hazem_aliraqi
02-11-2016, 05:34 PM
Get User Id in Media Gallery



the next page like page 2


media.php?do=main&type=2&userid=$userid&page=2

the mod in this thread


https://vborg.vbsupport.ru/showthread.php?threadid=319444


the query in media.php

if ($type == 2 && $userid > 0)
{
$pagenav = construct_page_nav($pagenumber, $perpage, $records, 'media.php?' . $vbulletin->session->vars['sessionurl'] . 'do=main&type=2&userid=$userid');
$items = $vbulletin->db->query_read("
SELECT *
FROM `" . TABLE_PREFIX . "mediagallery_items`
WHERE userid=$userid AND approved=1 AND hidden=0
ORDER BY postdate DESC
LIMIT " . ($limitlower-1) . ", $perpage");
}


where is the problem ?

Dave
02-11-2016, 06:03 PM
You mean that $userid is literally displayed in the URL?
It's because the variable is not being escaped in the construct_page_nav function.

This should work:
$pagenav = construct_page_nav($pagenumber, $perpage, $records, 'media.php?' . $vbulletin->session->vars['sessionurl'] . 'do=main&type=2&userid=' . $userid);
//

squidsk
02-11-2016, 08:13 PM
You are seeing that because you've got that part of the string in single quotes, if you put it in double quotes you would get the id showing correctly.

hazem_aliraqi
02-13-2016, 08:15 AM
You mean that $userid is literally displayed in the URL?
It's because the variable is not being escaped in the construct_page_nav function.

This should work:
$pagenav = construct_page_nav($pagenumber, $perpage, $records, 'media.php?' . $vbulletin->session->vars['sessionurl'] . 'do=main&type=2&userid=' . $userid);
//




It works successfully

thank you Dave :)