[ Príspevkov: 2 ] 
AutorSpráva
Offline

Prevádzkovateľ fóra
Prevádzkovateľ fóra
Visual Confirmation for Guests

Registrovaný: 01.05.05
Príspevky: 13350
Témy: 1496 | 1496
Bydlisko: Bratislava
NapísalOffline : 14.10.2006 14:48 | Visual Confirmation for Guests

Kód:
##############################################################
## MOD Title: Visual Confirmation for Guests
## MOD Author: Kanuck < aaron@kanuck.net > (Aaron Adams) http://kanuck.net/
## MOD Description: Adds visual confirmation for guest posts, eliminating spam.
## MOD Version: 1.0.1
##
## Installation Level: Easy
## Installation Time: 3 Minutes
## Files To Edit: posting.php, templates/subSilver/posting_body.tpl
## Included Files: n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes: None
##
##############################################################
## MOD History:
##
##   2005-02-18 - Version 1.0.1
##      - It works now. No more parse errors.
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#

posting.php

#
#-----[ FIND ]------------------------------------------
#

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 
#
#-----[ AFTER, ADD ]------------------------------------------
#

/*

   png visual confirmation system : (c) phpBB Group, 2003 : All Rights Reserved

*/

#
#-----[ FIND ]------------------------------------------
#

      case 'editpost':
      case 'newtopic':
      case 'reply':
      
#
#-----[ AFTER, ADD ]------------------------------------------
#

         if ( $board_config['enable_confirm'] && !$userdata['session_logged_in'] )
         {
            if ( empty($HTTP_POST_VARS['confirm_id']) || empty($HTTP_POST_VARS['confirm_code']) )
            {
               $error = TRUE;
               $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $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 = 'SELECT code
                  FROM ' . CONFIRM_TABLE . "
                  WHERE confirm_id = '$confirm_id'
                     AND session_id = '" . $userdata['session_id'] . "'";
               if (!($result = $db->sql_query($sql)))
               {
                  message_die(GENERAL_ERROR, 'Could not obtain confirmation code', __LINE__, __FILE__, $sql);
               }
      
               if ($row = $db->sql_fetchrow($result))
               {
                  if ($row['code'] != $HTTP_POST_VARS['confirm_code'])
                  {
                     $error = TRUE;
                     $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
                  }
                  else
                  {
                     $sql = 'DELETE FROM ' . CONFIRM_TABLE . "
                        WHERE confirm_id = '$confirm_id'
                           AND session_id = '" . $userdata['session_id'] . "'";
                     if (!$db->sql_query($sql))
                     {
                        message_die(GENERAL_ERROR, 'Could not delete confirmation code', __LINE__, __FILE__, $sql);
                     }
                  }
               }
               else
               {      
                  $error = TRUE;
                  $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
               }
               $db->sql_freeresult($result);
            }
         }

#
#-----[ FIND ]------------------------------------------
#

// Generate smilies listing for page output
generate_smilies('inline', PAGE_POSTING);

#
#-----[ BEFORE, ADD ]------------------------------------------
#

//
// Visual confirmation for guests
//
$confirm_image = '';
if( !$userdata['session_logged_in'] && (!empty($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);
   
   $confirm_chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',  'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',  'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
   
   list($usec, $sec) = explode(' ', microtime());
   mt_srand($sec * $usec);
   
   $max_chars = count($confirm_chars) - 1;
   $code = '';
   for ($i = 0; $i < 6; $i++)
   {
      $code .= $confirm_chars[mt_rand(0, $max_chars)];
   }
   
   $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());
}

#
#-----[ FIND ]------------------------------------------
#

   'SMILIES_STATUS' => $smilies_status,

#
#-----[ AFTER, ADD ]------------------------------------------
#

   'CONFIRM_IMG' => $confirm_image,
   
#
#-----[ FIND ]------------------------------------------
#

   'L_DELETE_POST' => $lang['Delete_post'],

#
#-----[ AFTER, ADD ]------------------------------------------
#

   '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'],

#
#-----[ OPEN ]------------------------------------------
#

templates/subSilver/posting_body.tpl

#
#-----[ FIND ]------------------------------------------
#

   {POLLBOX}

#
#-----[ AFTER, ADD ]------------------------------------------
#

   <!-- Visual Confirmation -->
   <!-- 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="6" maxlength="6" value="" /></td>
   </tr>
   <!-- END switch_confirm -->

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM


_________________
Streacom DA2 | SilverStone Titanium SX800-LTI 800W | ASRock X299E-ITX/ac | Intel Core i9-9980XE & be quiet! Dark Rock TF | Kingston HyperX Impact 64 GB DDR4 2666 MHz | NVIDIA Titan RTX 24 GB | Intel SSD Optane 905P 480 GB NVMe U.2 & Intel SSD 750 1,2 TB NVMe U.2 & Intel SSD 660p 2 TB NVMe M.2 & Seagate BackUp Plus Portable 56 TB USB | 55" 4K OLED Dell Alienware AW5520QF & 24" LCD EIZO FlexScan EV2451 | Ergotron LX Wall Mount Keyboard Arm | Logitech Craft | Logitech G603 | Logitech F710 | Harman Kardon Sabre SB 35 & Sennheiser RS 175 | Microsoft Windows 7 Ultimate | APC Back-UPS ES 700 | Lenovo ThinkPad X250 | iPhone X 256 GB & Pitaka Aramid | SilverStone ML05B Milo | Corsair SF600 SFX 600W | ASRock X99E-ITX/ac | Intel Xeon E5-2683 v4 & NOCTUA NH-L12S | Kingston HyperX Savage 32 GB DDR4 2400 MHz | NVIDIA GeForce GT 710 1 GB | Intel SSD Optane Memory 32 GB NVMe M.2 & Intel SSD 730 240 GB SATA | Ubuntu Server
Offline

Užívateľ
Užívateľ
Visual Confirmation for Guests

Registrovaný: 24.08.05
Prihlásený: 23.06.08
Príspevky: 36
Témy: 3 | 3
Bydlisko: Hlučín
NapísalOffline : 20.03.2007 15:07 | Visual Confirmation for Guests

jen dodám, že tento mod nedoporučuji na větší fora, měl jsem ho a při velkém náporu spam botů začal zhazovat server
konkrétně by měl být problém v tomto:
Kód:
$confirm_image = '';
if( !$userdata['session_logged_in'] && (!empty($board_config['enable_confirm'])) )

podtym vyselectuje vsetky evidovane session_id,  a potom urobi dotaz

delete from ....confirm where session_id NOT IN (vsetky evidovane session_id ziskane v predoslom bode)

a na tom delete to cele visi. To je asi nejaka ochrana proti spamu. Kedy ste si to opravili tak ze proste pouzijete dotaz

select x.session_id from mark66_confirm x left join mark66_sessions y on (x.session_id=y.session_id) where y.session_id is null;

ktory Vam vypise session_id ktore mate zmazat z tej tabulky mark66_confirm,
tak je pokoj. Ono ked je v tom NOT IN moc hodnot tak to nerobi uz optimalne system.


_________________
admin jednoho nejmenovaného konkurečního počítačového fóra ;)
 [ Príspevkov: 2 ] 


Visual Confirmation for Guests



Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy.

Visual Confirmation for Guests

v Redakčné systémy

0

480

13.10.2006 9:07

JanoF

V tomto fóre nie sú ďalšie neprečítané témy.

PREKLAD: Advanced Visual Confirmation SK

v Redakčné systémy

0

2265

02.04.2007 16:10

JanoF

V tomto fóre nie sú ďalšie neprečítané témy.

Remove Signature From Guests

v Redakčné systémy

0

536

14.10.2006 15:03

JanoF

V tomto fóre nie sú ďalšie neprečítané témy.

CUSTOM CSS FOR MAIN CONTENT AREA ONLEY FOR MAIN PAGE

v HTML, XHTML, XML, CSS

6

555

29.10.2013 15:21

Beatdownhaus

V tomto fóre nie sú ďalšie neprečítané témy.

P: Server memory 4GB 2x 2GB dual-rank x4 DDR2 400 MHZ PC2-3200 REG ECC 4GB RAM DDR2 400 for Dell PE6850 FOR HP DL140 G2

v Predám

0

456

26.11.2014 9:14

sulino611

V tomto fóre nie sú ďalšie neprečítané témy.

Visual Basic

v Delphi, Visual Basic

3

738

10.08.2011 19:03

Fico

V tomto fóre nie sú ďalšie neprečítané témy.

Visual C

v Assembler, C, C++, Pascal, Java

9

431

18.03.2013 14:58

Spixy

V tomto fóre nie sú ďalšie neprečítané témy.

Visual PHP

v PHP, ASP

13

629

14.06.2018 12:58

void

V tomto fóre nie sú ďalšie neprečítané témy.

visual FOXpro

v Assembler, C, C++, Pascal, Java

1

1602

11.03.2006 13:20

p55p

V tomto fóre nie sú ďalšie neprečítané témy.

visual c++ verzie

v Assembler, C, C++, Pascal, Java

3

458

20.08.2012 20:17

Fico

V tomto fóre nie sú ďalšie neprečítané témy.

Reinštalácia Visual C++

v Ovládače

0

753

04.04.2020 20:44

StroWniss

V tomto fóre nie sú ďalšie neprečítané témy.

microsoft visual studio

v Operačné systémy Microsoft

2

1078

12.09.2009 17:57

crysa

V tomto fóre nie sú ďalšie neprečítané témy.

Visual Basic 2008

v Ostatné programy

2

768

06.04.2009 13:34

Ominous

V tomto fóre nie sú ďalšie neprečítané témy.

Visual studio code

v Assembler, C, C++, Pascal, Java

6

2315

16.02.2019 15:14

Miso122

V tomto fóre nie sú ďalšie neprečítané témy.

Microsoft visual C++

v Ovládače

5

768

11.12.2012 9:32

majky358

V tomto fóre nie sú ďalšie neprečítané témy.

Microsoft visual c++

v Assembler, C, C++, Pascal, Java

25

3337

20.08.2011 12:52

MAREK17



© 2005 - 2024 PCforum, edited by JanoF