Problem in sending PM to a user with "'" in the ni

Makes it posble for admin to specify witch type of users may mass PM any usergroup
Also PM users can be a list of usernames, so PM can be sendt to any number of users

Moderator: Moderators

Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

Problem in sending PM to a user with "'" in the ni

Postby LuVi on Thu 31. Jul, 2003 10:44

Hallo,
i've installed this mod, and i use without problems, great job.
I received a pm from a user whose nickname is "Cuore T'Oro", with quote "'".

When i try to reply, the system gives me a "not existing user Cuore T\'Oro"

I found in the mod these lines:

Code: Select all
while ( !empty($to_username_array[$n]) )
{
   $to_username_array[$n] = trim ($to_username_array[$n]);
   $to_usernames .=  (($to_usernames) ? "," : "" ) . "'" . $to_username_array[$n++]."'";
}

         $sql = "SELECT username, user_id, user_notify_pm, user_email, user_lang, user_active
            FROM " . USERS_TABLE . "
            WHERE username IN (" . str_replace("\'", "''", $to_usernames) . ")
               AND user_id <> " . ANONYMOUS." ORDER BY username ASC" ;
         if( !($result2 = $db->sql_query($sql)) )
         
{
   message_die(GENERAL_ERROR, 'Could not obtain users PM information', '', __LINE__, __FILE__, $sql);
}

// verify all names are found
$to_users = $db->sql_fetchrowset($result2);
$db->sql_rowseek(0,$result2);
$n=0;
while ( $to_username_array[$n] && !$error)
{
   if (strcasecmp($to_users[$n]['username'],$to_username_array[$n]))
   {
      $error = TRUE;
      $error_msg .= $lang['No_such_user']." '".$to_username_array[$n]."'";
   }
   $n++;
}


I think there is something wrong here.

What should i do to send pm to users with quotes (previously, with no modded privmsg.php i do)?

Thanks. :)

LuVi
LuVi
Poster
Poster
 
Posts: 11
Joined: Thu 24. Jul, 2003 16:22
Location: Rome, Italy

Postby LuVi on Thu 31. Jul, 2003 10:59

Mmmhhh... i tried to put:

str_replace("\'", "'",

Into:

if (strcasecmp($to_users[$n]['username'],$to_username_array[$n]))

So:

Code: Select all
if (strcasecmp($to_users[$n]['username'],str_replace("\'", "'", $to_username_array[$n])))


It seems to function... but i don't know why.... the SELECT statement replaces "\'" with "''"...

LuVi
LuVi
Poster
Poster
 
Posts: 11
Joined: Thu 24. Jul, 2003 16:22
Location: Rome, Italy

Postby Niels on Sat 23. Aug, 2003 00:04

you are rigth, there seam to be a bug.

I can verify that your way of solving this is correct, the select does NOT, change the name, only witch names should be selected

this code should be used, so the eror message also is correct
Code: Select all
if (strcasecmp($to_users[$n]['username'],str_replace("\'", "'", $to_username_array[$n])))
   {
      $error = TRUE;
      $error_msg .= $lang['No_such_user']." '".str_replace("\'", "'", $to_username_array[$n])."'";


thanks for reporting this isue.
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46


Return to Custom mass PM [2.0.6/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron