Kayıp şifre ve yeni aktivasyon kodu için görsel doğrulama

Eklenti geliştirme bölümü.

Kayıp şifre ve yeni aktivasyon kodu için görsel doğrulama

İleti purple 12.05.2006, 09:12

Şimdi burada anlatacağım geliştirme şifremi unuttum sayfası ve aktivasyon kodu göndertme sayfası için görsel doğrulama koymaya yarıyor. Bunu yapmamızın nedeni; admin olduğunuz için username ve email adresiniz user'lar tarafından biliniyordur çünkü public'dir veya bir başka kullanıcı email adresini göstermiş olabilir. Başkası sizi bu şekilde spam'e boğabilir. Gelin biz güvenliğimizi alalım ve görsel doğrulamalarımızı ilgili sayfalara monte edelim.

Kod: Tümünü seç
düzenlenicek dosyalar;
includes/usercp_sendpasswd.php,
includes/usercp_sendactivation.php,
templates/sizin_tema/profile_send_pass.tpl
templates/sizin_tema/profile_resendactivation.tpl
--------------- aç ---------------------------------------------------
includes/usercp_sendpasswd.php
--------------- bul --------------------------------------------------
if ( !$row['user_active'] )
         {
            message_die(GENERAL_MESSAGE, $lang['No_send_account_inactive']);
         }
--------------- sonrasına ekle -------------------------------------
//
         //Visual Confirmation
         //
         if ( $board_config['enable_confirm'] )
         {
            if ( empty($HTTP_POST_VARS['confirm_id']) || empty($HTTP_POST_VARS['confirm_code']) )
            {
               message_die(GENERAL_MESSAGE, $lang['Confirm_code_wrong']);
            }
            else
            {
               $confirm_id = htmlspecialchars($HTTP_POST_VARS['confirm_id']);
               if (!preg_match('/^[A-Za-z0-9]+$/', $confirm_id))
               {
                  $confirm_id = '';
               }

               $sql_vc = 'SELECT code
                        FROM ' . CONFIRM_TABLE . "
                           WHERE confirm_id = '$confirm_id'
                           AND session_id = '" . $userdata['session_id'] . "'";
               if (!($result_vc = $db->sql_query($sql_vc)))
               {
                  message_die(GENERAL_ERROR, 'Could not obtain confirmation code', __LINE__, __FILE__, $sql_vc);
               }

               if ($row_vc = $db->sql_fetchrow($result_vc))
               {
                  if ($row_vc['code'] != $HTTP_POST_VARS['confirm_code'])
                  {
                     message_die(GENERAL_MESSAGE, $lang['Confirm_code_wrong']);
                  }
                  else
                  {
                     $sql_vc = 'DELETE FROM ' . CONFIRM_TABLE . "
                              WHERE confirm_id = '$confirm_id'
                              AND session_id = '" . $userdata['session_id'] . "'";
                     if (!$db->sql_query($sql_vc))
                     {
                        message_die(GENERAL_ERROR, 'Could not delete confirmation code', __LINE__, __FILE__, $sql_vc);
                     }
                  }
               }
               else
               {
                  message_die(GENERAL_MESSAGE, $lang['Confirm_code_wrong']);
               }
               $db->sql_freeresult($result_vc);
            }
         }
         //
         //End of Visual Confirmation
         //
--------------------------- bul --------------------------------------------------------------------------
make_jumpbox('viewforum.'.$phpEx);
--------------------------- sonrasına ekle ------------------------------------------------------------
//
//Visual Confirmation
//
$confirm_image = '';
if ( $board_config['enable_confirm'] )
{
   $sql = 'SELECT session_id
            FROM ' . SESSIONS_TABLE;
   if (!($result = $db->sql_query($sql)))
   {
      message_die(GENERAL_ERROR, 'Could not select session data', '', __LINE__, __FILE__, $sql);
   }

   if ($row = $db->sql_fetchrow($result))
   {
      $confirm_sql = '';
      do
      {
         $confirm_sql .= (($confirm_sql != '') ? ', ' : '') . "'" . $row['session_id'] . "'";
      }
      while ($row = $db->sql_fetchrow($result));

      $sql = 'DELETE FROM ' .  CONFIRM_TABLE . "
               WHERE session_id NOT IN ($confirm_sql)";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Could not delete stale confirm data', '', __LINE__, __FILE__, $sql);
      }
   }
   $db->sql_freeresult($result);

   $sql = 'SELECT COUNT(session_id) AS attempts
      FROM ' . CONFIRM_TABLE . "
      WHERE session_id = '" . $userdata['session_id'] . "'";
   if (!($result = $db->sql_query($sql)))
   {
      message_die(GENERAL_ERROR, 'Could not obtain confirm code count', '', __LINE__, __FILE__, $sql);
   }

   if ($row = $db->sql_fetchrow($result))
   {
      if ($row['attempts'] > 3)
      {
         message_die(GENERAL_MESSAGE, $lang['Too_many_registers']);
      }
   }
   $db->sql_freeresult($result);
   
   // Generate the required confirmation code
   // NB 0 (zero) could get confused with O (the letter) so we make change it
   $code = dss_rand();
   $code = strtoupper(str_replace('0', 'o', substr($code, 6)));
   $confirm_id = md5(uniqid($user_ip));
   $sql = 'INSERT INTO ' . CONFIRM_TABLE . " (confirm_id, session_id, code)
      VALUES ('$confirm_id', '". $userdata['session_id'] . "', '$code')";
   if (!$db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql);
   }

   unset($code);
      
   $confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=6") . '" alt="" title="" />';
   $hidden_form_fields = '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';

   $template->assign_block_vars('switch_confirm', array());
}
//
//End of visual Confirmation
//
---------------------------------- bul ------------------------------------------------------------------
'L_EMAIL_ADDRESS' => $lang['Email_address'],
---------------------------------- sonrasına ekle -----------------------------------------------------
'L_CONFIRM_CODE_IMPAIRED'=> sprintf($lang['Confirm_code_impaired'], '<a href="mailto:' . $board_config['board_email'] . '">', '</a>'),
'L_CONFIRM_CODE' => $lang['Confirm_code'],
'L_CONFIRM_CODE_EXPLAIN' => $lang['Confirm_code_explain'],
---------------------------------- bul ---------------------------------------------------------------------
'S_HIDDEN_FIELDS' => '',
--------------------------------- bununla değiştir -----------------------------------------------------
'CONFIRM_IMG' => $confirm_image,
'S_HIDDEN_FIELDS' => $hidden_form_fields,
---------------------------------- aç --------------------------------------------------------------------
templates/sizin_tema/profile_send_pass.tpl
----------------------------- bul -----------------------------------------------
<tr>
     <td class="row1"><span class="gen">{L_EMAIL_ADDRESS}: *</span></td>
     <td class="row2">
      <input type="text" class="post" style="width: 200px" name="email" size="25" maxlength="255" value="{EMAIL}" />
     </td>
   </tr>
------------------------- sonrasına ekle -------------------------------------
<!-- Görsel Doğrulama -->
   <!-- BEGIN switch_confirm -->
   <tr>
     <td class="row1" colspan="2" align="center"><span class="gensmall">{L_CONFIRM_CODE_IMPAIRED}</span><br /><br />{CONFIRM_IMG}<br /><br /></td>
   </tr>
   <tr>
     <td class="row1"><span class="gen">{L_CONFIRM_CODE}: * </span><br /><span class="gensmall">{L_CONFIRM_CODE_EXPLAIN}</span></td>
     <td class="row2"><input type="text" class="post" style="width: 200px" name="confirm_code" size="7" maxlength="7" value="" /></td>
   </tr>
   <!-- END switch_confirm -->
------------------- aç -----------------------------------------------------------
includes/usercp_sendactivation.php
------------------ bul ------------------------------------------------
if ($row['user_active'] !== 1)
         {
            message_die(GENERAL_MESSAGE, $lang['olympus_login_No_send_account_active'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>'));
         }
------------------------- sonrasına ekle ---------------------------------------------------------
//
         //Visual Confirmation
         //
         if ( $board_config['enable_confirm'] )
         {
            if ( empty($HTTP_POST_VARS['confirm_id']) || empty($HTTP_POST_VARS['confirm_code']) )
            {
               message_die(GENERAL_MESSAGE, $lang['Confirm_code_wrong']);
            }
            else
            {
               $confirm_id = htmlspecialchars($HTTP_POST_VARS['confirm_id']);
               if (!preg_match('/^[A-Za-z0-9]+$/', $confirm_id))
               {
                  $confirm_id = '';
               }

               $sql_vc = 'SELECT code
                        FROM ' . CONFIRM_TABLE . "
                           WHERE confirm_id = '$confirm_id'
                           AND session_id = '" . $userdata['session_id'] . "'";
               if (!($result_vc = $db->sql_query($sql_vc)))
               {
                  message_die(GENERAL_ERROR, 'Could not obtain confirmation code', __LINE__, __FILE__, $sql_vc);
               }

               if ($row_vc = $db->sql_fetchrow($result_vc))
               {
                  if ($row_vc['code'] != $HTTP_POST_VARS['confirm_code'])
                  {
                     message_die(GENERAL_MESSAGE, $lang['Confirm_code_wrong']);
                  }
                  else
                  {
                     $sql_vc = 'DELETE FROM ' . CONFIRM_TABLE . "
                              WHERE confirm_id = '$confirm_id'
                              AND session_id = '" . $userdata['session_id'] . "'";
                     if (!$db->sql_query($sql_vc))
                     {
                        message_die(GENERAL_ERROR, 'Could not delete confirmation code', __LINE__, __FILE__, $sql_vc);
                     }
                  }
               }
               else
               {
                  message_die(GENERAL_MESSAGE, $lang['Confirm_code_wrong']);
               }
               $db->sql_freeresult($result_vc);
            }
         }
         //
         //End of Visual Confirmation
         //
--------------------------------------- bul --------------------------------------------------
make_jumpbox('viewforum.'.$phpEx);
--------------------------- sonrasına ekle ------------------------------------------------------------
//
//Visual Confirmation
//
$confirm_image = '';
if ( $board_config['enable_confirm'] )
{
   $sql = 'SELECT session_id
            FROM ' . SESSIONS_TABLE;
   if (!($result = $db->sql_query($sql)))
   {
      message_die(GENERAL_ERROR, 'Could not select session data', '', __LINE__, __FILE__, $sql);
   }

   if ($row = $db->sql_fetchrow($result))
   {
      $confirm_sql = '';
      do
      {
         $confirm_sql .= (($confirm_sql != '') ? ', ' : '') . "'" . $row['session_id'] . "'";
      }
      while ($row = $db->sql_fetchrow($result));

      $sql = 'DELETE FROM ' .  CONFIRM_TABLE . "
               WHERE session_id NOT IN ($confirm_sql)";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Could not delete stale confirm data', '', __LINE__, __FILE__, $sql);
      }
   }
   $db->sql_freeresult($result);

   $sql = 'SELECT COUNT(session_id) AS attempts
      FROM ' . CONFIRM_TABLE . "
      WHERE session_id = '" . $userdata['session_id'] . "'";
   if (!($result = $db->sql_query($sql)))
   {
      message_die(GENERAL_ERROR, 'Could not obtain confirm code count', '', __LINE__, __FILE__, $sql);
   }

   if ($row = $db->sql_fetchrow($result))
   {
      if ($row['attempts'] > 3)
      {
         message_die(GENERAL_MESSAGE, $lang['Too_many_registers']);
      }
   }
   $db->sql_freeresult($result);
   
   // Generate the required confirmation code
   // NB 0 (zero) could get confused with O (the letter) so we make change it
   $code = dss_rand();
   $code = strtoupper(str_replace('0', 'o', substr($code, 6)));
   $confirm_id = md5(uniqid($user_ip));
   $sql = 'INSERT INTO ' . CONFIRM_TABLE . " (confirm_id, session_id, code)
      VALUES ('$confirm_id', '". $userdata['session_id'] . "', '$code')";
   if (!$db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql);
   }

   unset($code);
      
   $confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&amp;id=$confirm_id&amp;c=6") . '" alt="" title="" />';
   $hidden_form_fields = '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';

   $template->assign_block_vars('switch_confirm', array());
}
//
//End of visual Confirmation
//
---------------------------------- bul ------------------------------------------------------------------
'L_EMAIL_ADDRESS' => $lang['Email_address'],
---------------------------------- sonrasına ekle -----------------------------------------------------
'L_CONFIRM_CODE_IMPAIRED'=> sprintf($lang['Confirm_code_impaired'], '<a href="mailto:' . $board_config['board_email'] . '">', '</a>'),
'L_CONFIRM_CODE' => $lang['Confirm_code'],
'L_CONFIRM_CODE_EXPLAIN' => $lang['Confirm_code_explain'],
---------------------------------- bul ---------------------------------------------------------------------
'S_HIDDEN_FIELDS' => '',
--------------------------------- bununla değiştir -----------------------------------------------------
'CONFIRM_IMG' => $confirm_image,
'S_HIDDEN_FIELDS' => $hidden_form_fields,
---------------------------------- aç --------------------------------------------------------------------
templates/sizin_tema/profile_resendactivation.tpl
----------------------------- bul -----------------------------------------------
<tr>
            <td class="row1">
                <span class="gen">
{L_EMAIL_ADDRESS}: *</span>
            </td>
            <td class="row2">
               <input type="text" class="post" style="width: 200px" name="email" size="25" maxlength="255" value="{EMAIL}"/>
            </td>
         </tr>
--------------------------------- sonrasına ekle ------------------------------
<!-- Görsel Doğrulama -->
   <!-- BEGIN switch_confirm -->
   <tr>
     <td class="row1" colspan="2" align="center"><span class="gensmall">{L_CONFIRM_CODE_IMPAIRED}</span><br /><br />{CONFIRM_IMG}<br /><br /></td>
   </tr>
   <tr>
     <td class="row1"><span class="gen">{L_CONFIRM_CODE}: * </span><br /><span class="gensmall">{L_CONFIRM_CODE_EXPLAIN}</span></td>
     <td class="row2"><input type="text" class="post" style="width: 200px" name="confirm_code" size="7" maxlength="7" value="" /></td>
   </tr>
   <!-- END switch_confirm -->
-------------------------- DOSYALARI KAYDET/KAPAT ---------------------------

Saygılar...
Kullanıcı avatarı
purple
Üye
Üye
 
İleti: 618
Kayıt: 06.03.2006, 22:40

İleti aman_adanali 05.06.2006, 08:35

sağ ol kardes tesekkurler
aman_adanali
Üye
Üye
 
İleti: 5
Kayıt: 20.04.2006, 14:29
Konum: Muğla


Eklenti Geliştirme



Kimler çevrimiçi

Bu forumu görüntüleyenler: Kayıtlı kullanıcı yok ve 0 misafir

cron