plugins/yubikey/usercp.php
changeset 35 03d6287d4a8b
parent 32 b00055a88867
child 37 5e946a3f405b
equal deleted inserted replaced
34:6e947fa21237 35:03d6287d4a8b
   103     $q = $db->sql_query('SELECT password FROM ' . table_prefix . "users WHERE user_id = {$session->user_id};");
   103     $q = $db->sql_query('SELECT password FROM ' . table_prefix . "users WHERE user_id = {$session->user_id};");
   104     if ( !$q )
   104     if ( !$q )
   105       $db->_die();
   105       $db->_die();
   106     list($password_hmac) = $db->fetchrow_num();
   106     list($password_hmac) = $db->fetchrow_num();
   107     
   107     
   108     $session->register_session($session->user_id, $session->username, $password_hmac, USER_LEVEL_MEMBER, false);
   108     @$session->register_session($session->user_id, $session->username, $password_hmac, USER_LEVEL_MEMBER, false);
   109     $session->logout(USER_LEVEL_CHPREF);
   109     $session->logout(USER_LEVEL_CHPREF);
   110     
   110     
   111     // redirect back to normal CP
   111     // redirect back to normal CP
   112     @ob_end_clean();
   112     // if OB-ing isn't enabled, require a JS redirect (hey, not many other options...)
   113     redirect(makeUrlNS('Special', 'Preferences'), $lang->get('yubiucp_msg_save_title'), $lang->get('yubiucp_msg_save_body'), 3);
   113     if ( @ob_get_contents() )
       
   114     {
       
   115       @ob_end_clean();
       
   116       redirect(makeUrlNS('Special', 'Preferences'), $lang->get('yubiucp_msg_save_title'), $lang->get('yubiucp_msg_save_body'), 3);
       
   117     }
       
   118     else
       
   119     {
       
   120       echo '<h3>' . $lang->get('yubiucp_msg_save_title') . '</h3>';
       
   121       echo '<p>' . $lang->get('yubiucp_msg_save_body') . '</p>';
       
   122       // not much choice here, i'm resorting to javascript because the user CP always
       
   123       // sends headers :-/
       
   124       echo '<script type="text/javascript">
       
   125         addOnloadHook(function()
       
   126         {' .
       
   127         // note: $_COOKIE['sid'] has just been assigned by $session->register_session() - so it's safe to use here.
       
   128         '
       
   129           createCookie(\'sid\', \'' . $_COOKIE['sid'] . '\');
       
   130           window.location = makeUrlNS(\'Special\', \'Preferences\');
       
   131         });
       
   132       </script>';
       
   133       return true;
       
   134     }
   114   }
   135   }
   115   else
   136   else
   116   {
   137   {
   117     // Fetch flags
   138     // Fetch flags
   118     $q = $db->sql_query('SELECT user_yubikey_flags FROM ' . table_prefix . "users WHERE user_id = {$session->user_id};");
   139     $q = $db->sql_query('SELECT user_yubikey_flags FROM ' . table_prefix . "users WHERE user_id = {$session->user_id};");