Advertisement:

Author Topic: Janela flutuante para autenticação [SMF 2.0.x]  (Read 4483 times)

Offline Costa

  • SMF Hero
  • ******
  • Posts: 3,045
  • Gender: Male
  • Do NOT feed the trolls...
Janela flutuante para autenticação [SMF 2.0.x]
« on: February 20, 2013, 06:08:44 PM »
Tópico Original | Mais truques e dicas | Costa Web

Este truque irá criar uma janela flutuante para fazer autenticação. Não é complicado e é uma alternativa à opção de ter a autenticção rápida em todas as páginas.



./Themes/default/index.template.php
Code: (encontra) [Select]
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
elseif (!empty($context['show_login_bar']))
{
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div class="info">', sprintf($txt['welcome_guest'], $txt['guest_title']), '</div>
<input type="text" name="user" size="10" class="input_text" />
<input type="password" name="passwrd" size="10" class="input_password" />
<select name="cookielength">
<option value="60">', $txt['one_hour'], '</option>
<option value="1440">', $txt['one_day'], '</option>
<option value="10080">', $txt['one_week'], '</option>
<option value="43200">', $txt['one_month'], '</option>
<option value="-1" selected="selected">', $txt['forever'], '</option>
</select>
<input type="submit" value="', $txt['login'], '" class="button_submit" /><br />
<div class="info">', $txt['quick_login_dec'], '</div>';

if (!empty($modSettings['enableOpenID']))
echo '
<br /><input type="text" name="openid_identifier" id="openid_url" size="25" class="input_text openid_login" />';

echo '
<input type="hidden" name="hash_passwrd" value="" />
</form>';
}
Code: (substitui por) [Select]
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
if (!empty($context['user']['is_guest']))
{
    echo '<div id="janela-login">';
        echo '
               <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
                   <h2>', $txt['login'], '</h2>
                   <div class="campo"><span class="etiqueta">', $txt['username'], ':</span><input type="text" name="user" size="10" class="input_text" /></div>
                   <div class="campo"><span class="etiqueta">', $txt['password'], ':</span><input type="password" name="passwrd" size="10" class="input_password" /></div>
                   <div class="campo">
                       <span class="etiqueta">Duração:</span><select name="cookielength">
                           <option value="60">', $txt['one_hour'], '</option>
                           <option value="1440">', $txt['one_day'], '</option>
                           <option value="10080">', $txt['one_week'], '</option>
                           <option value="43200">', $txt['one_month'], '</option>
                           <option value="-1" selected="selected">', $txt['forever'], '</option>
                       </select>
                   </div>
                   <div class="campo button"><input type="submit" value="', $txt['login'], '" class="button_submit" /></div>
                   <div class="info">', sprintf($txt['welcome_guest'], $txt['guest_title']), '</div>';
 
        if (!empty($modSettings['enableOpenID']))
            echo '
                   <br /><input type="text" name="openid_identifier" id="openid_url" size="25" class="input_text openid_login" />';
 
        echo '
                   <input type="hidden" name="hash_passwrd" value="" />
               </form>';
    echo '</div>';
}

./Themes/default/css/index.css
Code: (adicionar no fim) [Select]

#janela-login{
    background: #fff;
    border: 3px solid black;
    padding: 10px;
    position: fixed;
    right: 70px;
    top: 200px;
    width: 300px;
}
#janela-login h2{
    border-bottom: 1px solid black;
    text-align: center;
}
#janela-login .campo{
    margin-top: 10px;
}
#janela-login .campo input{
    width: 150px;
}
#janela-login .button{
    text-align: center;
}
#janela-login .button input{
    width: 150px;
}
 
#janela-login .etiqueta{
    display: inline-block;
    margin-right: 30px;
    text-align: right;
    width: 90px;
}
#janela-login .info{
    border-top: 1px solid black;
    margin-top: 10px;
}
« Last Edit: February 26, 2013, 06:14:44 PM by Costa »
Hugo "Costa" Fernandes
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."