diff --git a/upload/blocks/notify.php b/upload/blocks/notify.php index bbbbf33..2abffd5 100644 --- a/upload/blocks/notify.php +++ b/upload/blocks/notify.php @@ -16,9 +16,9 @@ if(!isset($_SESSION['mcr_notify'])){ return ''; } $new_data = array( - "TYPE" => $this->db->HSC($_SESSION['notify_type']), - "TITLE" => $this->db->HSC($_SESSION['notify_title']), - "MESSAGE" => $this->db->HSC($_SESSION['notify_msg']) + "TYPE" => $this->db->HSC(@$_SESSION['notify_type']), + "TITLE" => $this->db->HSC(@$_SESSION['notify_title']), + "MESSAGE" => $this->db->HSC(@$_SESSION['notify_msg']) ); $result = $this->core->sp(MCR_THEME_PATH."blocks/notify/alert.html", $new_data); diff --git a/upload/configs/functions.php b/upload/configs/functions.php index ac25a65..671cc61 100644 --- a/upload/configs/functions.php +++ b/upload/configs/functions.php @@ -4,5 +4,7 @@ 'breadcrumbs' => true, 'close' => false, 'close_time' => 0, + 'ipreglimit' => 1, + 'whitelist' => '', ); ?> \ No newline at end of file diff --git a/upload/engine/core.class.php b/upload/engine/core.class.php index 8e7933a..42e3769 100644 --- a/upload/engine/core.class.php +++ b/upload/engine/core.class.php @@ -15,8 +15,6 @@ public $csrf_time = 3600; - public $csrf_disable = false; - public $captcha = array( 0 => "---", 1 => "ReCaptcha", @@ -306,12 +304,26 @@ return new bbcode($this); } + public function csrf_whitelist_add($ip='127.0.0.1'){ + $whitelist = explode(',',$this->cfg->func['whitelist']); + if(in_array($ip, $whitelist)){ return false; } + + $whitelist[] = $ip; + + $this->cfg->func['whitelist'] = implode(',', $whitelist); + + if(!$this->cfg->savecfg($this->cfg->func, 'functions.php', 'func')){ return false; } + + return true; + } + /** * Валидатор защиты от CSRF атаки * При ошибке возвращается на главную страницу с сообщение "Hacking Attempt!" */ public function csrf_check(){ - if($this->csrf_disable){ return; } + if(in_array($this->user->ip, explode(',', $this->cfg->func['whitelist']))){ return; } + if($_SERVER['REQUEST_METHOD']=='POST'){ if(!isset($_POST['mcr_secure'])){ $this->notify($this->lng['e_hack']); } diff --git a/upload/language/ru_RU/admin/settings.php b/upload/language/ru_RU/admin/settings.php index ced8e4f..9be0ed9 100644 --- a/upload/language/ru_RU/admin/settings.php +++ b/upload/language/ru_RU/admin/settings.php @@ -32,6 +32,7 @@ 'set_funt_bc' => 'Выводить хлебные крошки', 'set_funt_close' => 'Технические работы', 'set_funt_close_time' => 'Время до конца тех. работ', + 'set_funt_reglimit' => 'Максимальное кол-во регистраций с одного IP', 'set_mail_from' => 'От кого', 'set_mail_from_ph' => 'От кого было отправлено сообщение', 'set_mail_from_name' => 'Имя отправителя', diff --git a/upload/language/ru_RU/register.php b/upload/language/ru_RU/register.php index 76da150..59c88c4 100644 --- a/upload/language/ru_RU/register.php +++ b/upload/language/ru_RU/register.php @@ -12,6 +12,7 @@ 'e_pass_match' => 'Пароли не совпадают', 'e_rules' => 'Необходимо принять правила сайта', "e_rules" => "Для регистрации необходимо принять правила", + "e_reg_limit" => "Вы уже регистрировались ранее", "e_success" => "Вы успешно зарегистрировались. Теперь вы можете войти под своим логином и паролем.", "e_success_mail" => "Письмо с подтверждением регистрации отправлено на E-Mail, указанный при регистрации", "repass" => "Повторите пароль", diff --git a/upload/modules/admin/settings.class.php b/upload/modules/admin/settings.class.php index 2154567..50882f6 100644 --- a/upload/modules/admin/settings.class.php +++ b/upload/modules/admin/settings.class.php @@ -329,6 +329,8 @@ $cfg['close_time'] = (@$_POST['close_time']=='') ? 0 : intval(strtotime(@$_POST['close_time'])); + $cfg['ipreglimit'] = (intval(@$_POST['input_reglimit'])<=0) ? 0 : intval(@$_POST['input_reglimit']); + if(!$this->cfg->savecfg($cfg, 'functions.php', 'func')){ $this->core->notify($this->core->lng["e_msg"], $this->lng['set_e_cfg_save'], 2, '?mode=admin&do=settings&op=functions'); } // Последнее обновление пользователя @@ -344,6 +346,7 @@ "ADVICE" => ($cfg['advice']) ? 'selected' : '', "BREADCRUMBS" => ($cfg['breadcrumbs']) ? 'selected' : '', "CLOSE" => ($cfg['close']) ? 'selected' : '', + "REGLIMIT" => intval(@$cfg['ipreglimit']), 'CLOSE_TIME' => (intval($cfg['close_time'])<=0) ? '' : date("d.m.Y H:i:s", $cfg['close_time']), ); diff --git a/upload/modules/ajax/register.php b/upload/modules/ajax/register.php index d2505e2..4c4c614 100644 --- a/upload/modules/ajax/register.php +++ b/upload/modules/ajax/register.php @@ -13,12 +13,32 @@ $this->lng = $core->load_language('register'); } + private function count_ip(){ + $ctables = $this->cfg->db['tables']; + $us_f = $ctables['users']['fields']; + + $query = $this->db->query("SELECT COUNT(*) + FROM `{$this->cfg->tabname('users')}` + WHERE `{$us_f['ip_create']}`='{$this->user->ip}' + OR `{$us_f['ip_last']}`='{$this->user->ip}'"); + + if(!$query){ return 0; } + + $ar = $this->db->fetch_array($query); + + return $ar[0]; + } + public function content(){ if($_SERVER['REQUEST_METHOD']!='POST'){ $this->core->js_notify($this->core->lng['e_hack']); } if($this->user->is_auth){ $this->core->js_notify($this->lng['e_already']); } + if(intval(@$this->cfg->func['ipreglimit'])>0 && $this->count_ip()>=intval(@$this->cfg->func['ipreglimit'])){ + $this->core->js_notify($this->lng['e_reg_limit']); + } + $login = $this->db->safesql(@$_POST['login']); $email = $this->db->safesql(@$_POST['email']); $uuid = $this->db->safesql($this->user->logintouuid(@$_POST['login'])); diff --git a/upload/system.php b/upload/system.php index 5b65a57..3eed546 100644 --- a/upload/system.php +++ b/upload/system.php @@ -8,7 +8,7 @@ // System constants define('PROGNAME', 'WebMCR Reloaded'. MCR); -define('VERSION', 'WebMCR Beta 1.4.1'); +define('VERSION', 'WebMCR Beta 1.4.2'); define('FEEDBACK', ''.PROGNAME.' © 2013-'.date("Y").' Qexy'); define('MCR_ROOT', dirname(__FILE__).'/'); define('MCR_MODE_PATH', MCR_ROOT.'modules/'); diff --git a/upload/themes/default/modules/admin/settings/functions.html b/upload/themes/default/modules/admin/settings/functions.html index 1c7a9a3..24eb6e5 100644 --- a/upload/themes/default/modules/admin/settings/functions.html +++ b/upload/themes/default/modules/admin/settings/functions.html @@ -60,6 +60,13 @@
+ +
+ +
+
+ +