PDA

View Full Version : adding new letters to memberlist.php


ohadpartuck
05-17-2012, 02:22 PM
hi.
I am trying to enable search by my own language letters in the http://www.s-maof.com/Forum/memberlist.php .
so i added this code to memberlist.php at line 504


The thing is that my letters are in hebrew.
The code seems to have problems with that
for ($i=128; $i < 154; $i++)
{
//$currentletter = $i;
$currentletter = chr($i);
$linkletter =& $currentletter;
$show['selectedletter'] = $selectedletter == $currentletter ? true : false;
$templater = vB_Template::create('memberlist_letter');
$templater->register('currentletter', $currentletter);
$templater->register('linkletter', $linkletter);
$templater->register('ltrurl', $ltrurl);
$templater->register('perpage', $perpage);
$templater->register('sortfield', $sortfield);
$templater->register('sortorder', $sortorder);
$templater->register('usergrouplink', $usergrouplink);
$letterbits .= $templater->render();
}

which is the same for the english letters but just different ascii values.
the thing is the code in line 350
$condition .= " AND username LIKE(\"" . $db->escape_string_like($ltr) . "%\")";

doesn't search for the right letter. This is a coding problem.
The advanced serach in my language works. I just don't know how does it do it..!

kh99
05-17-2012, 07:47 PM
This is stab in the dark, but try this (for the first few lines):


for ($i=1488; $i < 1514; $i++)
{
$currentletter = '&#' . intval($i) . ';';

ohadpartuck
05-20-2012, 06:16 AM
Hi kh99,
Thanks for the replay.
As I said, the letters are displayed properly,
but still there is the SQL Query problem in,
more specific in line 350 which looks for the letter wrongly
I have echoed what it gets for one of the letters
1=1 AND username LIKE("�%")
the condition code is
if ($ltr != '')
{
if ($ltr == '#')
{
$condition .= " AND username NOT REGEXP(\"^[a-zA-Z]\")";
}
else
{
$ltr = chr(intval(ord($ltr)));
//echo $ltr ."<BR/>";
echo $condition .= " AND username LIKE(\"" . $db->escape_string_like($ltr) . "%\")";
}
}

and the letter comes for the url address in line 103
$ltr = $vbulletin->input->clean_gpc('r', 'ltr', TYPE_NOHTML);

and of course as a result of that no results are returned..

kh99
05-20-2012, 12:51 PM
I realize that you were getting the letters displayed correctly. I don't know a whole lot about using different char encodings but it seems like the code you have is using extended ascii values which aren't always the same (your display changes didn't display hebrew characters when I tried it on my test server, but the code I posted above does). So my thought was that maybe if you instead used html entities for those characters then the search code might work. But like I said, it was just a guess.

ohadpartuck
05-20-2012, 01:29 PM
thanks kh99,
I figured it out.
I figured that I just have to look where is the advanced search's condition is (because there, it works),

and there was the solution to the problem:

instead of :
$ltr = chr(intval(ord($ltr)));
I use:
htmlspecialchars_uni($ltr);

and it works!!!!

check on that!