BanGuest

kakadu

No avatar

2009-01-04 18:13

Hello I need a help,

I have two shops (QC 2.2):
1) on my domain - shop with normal prices
2) on subdomain - same shop, with about same products, but only better prices, for bigger customers.

On this subdomen I have installed BanGuest plugin, and i need to ban all IP adresses,
except IP adress that have these bigger customers

» Quick.Cart v2.x

kakadu

beholder

Avatar: beholder

2009-01-05 02:04

try this in the plugin, I have reversed the algorithm - if IP or host is there, it is allowed, otherwise not:


/**
* Check if user is allowed to enter
* @return void
* @param array  $aBan
*/
function checkBanGuests$aBan null ){
  global 
$tpl;
  if( isset( 
$aBan ) && is_array$aBan ) ){
    
$iCount =           count$aBan );
    
$sCurrentIp =       $_SERVER['REMOTE_ADDR'];
    
$sCurrentHost =     gethostbyaddr$sCurrentIp );
    for( 
$i 0$i $iCount$i++ ){
      if( 
throwStrLen$aBan[$i] ) <= || ( !ereg$aBan[$i], $sCurrentIp ) && !eregi$aBan[$i], $sCurrentHost ) ) ){
        echo 
$tpl->tbHtml'banGuests.tpl''BAN_INFO' );
        exit;
      }  
    } 
// end for
  
}
// end function checkBanGuests



Hopefully this works, it is not tested. If not, let me know here.

kakadu

No avatar

2009-01-05 02:18

It does not work, i put my ip adress to file banGuestConfig, but i can not have permission to view the page, i am banned.

kakadu

treewood (OpenSolution)

Avatar: treewood

2009-01-05 08:06

kakadu - did you add function to plugins/actions_client.php? add this checkBanGuests( Array( 'Your_IP_HERE' ) ); to this file

beholder

Avatar: beholder

2009-01-05 16:57

I don't know what could be wrong, kakadu, if you need further help, send me your ftp access to the e-mail on this site: http://www.tigerware.sk/easyplugins/

kakadu

No avatar

2009-01-05 19:12

Hello i add function to plugins/actions_client.php checkBanGuests( Array( 'Your_IP_HERE' ) ); now its working, but only with one IP adress if i put there more than 1 ip adress it will banned me and second ip too. I am a beginer in php i put there the code of these files i have installed, maybe that i do something wrong.

plugins/actions_client.php

<?php
require DIR_PLUGINS.'lastProduct/actions_client.php';
require 
DIR_PLUGINS.'sendOrderToClient/actions_client.php';
checkBanGuests$aBan );
checkBanGuests( Array( '85.248.66.207' ) );
checkBanGuests( Array( '78.99.151.225' ) );
?>



plugins/banGuests/banGuestsConfig.php (must be ip adresses there too? if i put it there it dont work anyway)

<?php
/*
* example
* $aBan[] = '192.168.0.1';
* $aBan[] = 'example.domain.com';
*/

/*
* Write below Ip addresses or hosts 
*/

?>



plugins/plugins.php

<?php
require DIR_PLUGINS.'banGuests/banGuests.php';
?>



Thank you very much for your helping me.

kakadu

beholder

Avatar: beholder

2009-01-06 15:59

OMG, you do have to get better PHP education :-)

in actions_client.php you put in only: checkBanGuests( $aBan );
not those with IP specified in parentheses

then in banguestsconfig.php you should have following:


<?php
$aBan
[] = 'xx.xx.xx.xx';
$aBan[] = 'www.blahblah.com';
?>



this should work, if not, you could have messed up something and we should check it directly (or stop asking for help, it's impossible to foresee what could have been messed up).

kakadu

No avatar

2009-01-06 18:31

I was doing this in first time, but if i put to the file banguestsconfig.php more than 1 ip adress it ban me and second ip too.there

plugins/actions_client.php

<?php
require DIR_PLUGINS.'lastProduct/actions_client.php';
require 
DIR_PLUGINS.'sendOrderToClient/actions_client.php';
checkBanGuests$aBan );
?>



banguestsconfig.php - working with one IP (in this case is this ip allowed)

<?php
$aBan
[] = '85.248.66.207';
?>



banguestsconfig.php - doesnt work with 2 IP adresses - in this case is all ip adresess banned

<?php
$aBan
[] = '85.248.66.207';
$aBan[] = '93.174.93.10';
?>

kakadu

beholder

Avatar: beholder

2009-01-14 17:07

Allright, there was a logical mistake in the algorithm, this is the right content for plugins/banGuests/banGuests.php


<?php
require DIR_PLUGINS.'banGuests/banGuestsConfig.php';

/**
* Check if user is allowed to enter
* @return void
* @param array  $aBan
*/
function checkBanGuests$aBan null ){
  global 
$tpl;
  if( isset( 
$aBan ) && is_array$aBan ) ){
    
$bLetGo false;
    
$iCount =           count$aBan );
    
$sCurrentIp =       $_SERVER['REMOTE_ADDR'];
    
$sCurrentHost =     gethostbyaddr$sCurrentIp );
    for( 
$i 0$i $iCount$i++ ){
      if( 
throwStrLen$aBan[$i] ) > && ( ereg$aBan[$i], $sCurrentIp ) || eregi$aBan[$i], $sCurrentHost ) ) ){
        
$bLetGo true;
        break;
        }  
    } 
// end for
    
if ($bLetGo == false) {
                echo 
$tpl->tbHtml'banGuests.tpl''BAN_INFO' );
                exit;
                }
  }
// end function checkBanGuests
?>

q900761

Avatar: q900761

2009-01-18 22:37

There is also easier option:
in your server catalogs (not quick.cart catalogs) are catalog admin.

You must make into this folder .htaccess file where you must write:
AuthName "My admin!"
AuthType Basic
order deny,allow
deny from all
allow from 123.123.123.123
allow from adsl123.estpak.ee



Thats all!

q900761

Avatar: q900761

2009-01-18 22:38

PS! allow from ips are examples

kamilk

No avatar

2009-12-03 11:27

Używam tej funkcji i zauważyłem ciekawą rzecz. Chodzi o to, że dajmy na to lista adresów dozwolonych wygląda tak:


<?php
$aBan
[] = '192.168.1.101';
$aBan[] = '192.168.1.102';
$aBan[] = '192.168.1.103';
?>


Ja dysponuję adresem 192.168.1.103 i wchodzę na stronę, ale jeśli listę zapiszę w ten sposób


<?php
$aBan
[] = '192.168.1.101';
$aBan[] = '192.168.1.102';
$aBan[] = '192.168.1.10';
?>



To również mam dostęp do strony. Wygląda na to, że mają dostęp wszyscy z puli 192.168.1.100 - 192.168.1.109. Co ciekawe jak się usunie dwie ostatnie liczby z adresu to jest oto samo. Tak samo się dzieje jak usuwa się liczby na początku adresu.

Stronkę testuję na serwerze zainstalowanym lokalnie na kompie, może to ma związek z ustawieniami serwera??

Ja zmieniłem sobie warunek if z:

if( throwStrLen$aBan[$i] ) > && ( ereg$aBan[$i], $sCurrentIp ) || eregi$aBan[$i], $sCurrentHost ) ) ){


na:

if( throwStrLen$aBan[$i] ) > && ( ( $aBan[$i] == $sCurrentIp ) || eregi$aBan[$i], $sCurrentHost ) ) ){


i problem się rozwiązał.

Back to top
about us | contact