diff --git a/core/init_core.inc.php b/core/init_core.inc.php index 180e921..9fe7cfb 100644 --- a/core/init_core.inc.php +++ b/core/init_core.inc.php @@ -85,6 +85,10 @@ include dirname(dirname(__FILE__)).'/inc/plugin.class.php'; */ include dirname(dirname(__FILE__)).'/inc/mail.class.php'; +/** + * Captcha + */ +include dirname(dirname(__FILE__)).'/inc/captcha.class.php'; $plugin=new plugins(); $db= new db($config['host'], $config['user'], $config['pass'], $config['db'],'utf8', true); @@ -201,6 +205,8 @@ if(defined('INSTALLED')){ header("Location: install/install.php"); } +$captcha = new captcha(); + /** * OpenID */ diff --git a/inc/cache.class.php b/inc/cache.class.php index 9e6b23d..0a2c7e1 100644 --- a/inc/cache.class.php +++ b/inc/cache.class.php @@ -1,7 +1,7 @@ '; + return '
'; + } else if ($config['captcha']==2) { + return '
'; + } else { + return ''; + } + } + + function validate($response){ + global $config; + if($config['captcha']==1) { + var_dump($response); + if(isset($response['mcaptcha__token']) && $response['mcaptcha__token']!=''){ + $token = $response['mcaptcha__token']; + } else { + return false; + } + $data = array( + 'token' => $token, + 'key' => $config['mcaptcha_sitekey'], + 'secret' => $config['mcaptcha_secret'] + ); + $json = json_encode($data); + $url = 'https://'.$config['mcaptcha_url'].'/api/v1/pow/siteverify'; + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS, $json); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($json) + )); + $fh=curl_exec($ch); + + // schließe den cURL-Handle und gebe die Systemresourcen frei + curl_close($ch); + var_dump($fh); + if(!$fh){ + return false; + }else{ + $response = json_decode($fh, true); + if($response["valid"] !== true){ + return true; + }else{ + return false; + } + } + }else if($config['captcha']==2) { + var_dump($response); + if(isset($response['g-recaptcha-response']) && $response['g-recaptcha-response']!=''){ + $data = $response['g-recaptcha-response']; + } else { + return false; + } + $ch = curl_init(); + + // setze die URL und andere Optionen + curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify?secret=".$config['recaptcha_secret']."&response=".$data."&remoteip=".$functions->get_ip()); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); + // führe die Aktion aus und gebe die Daten an den Browser weiter + $fh=curl_exec($ch); + + // schließe den cURL-Handle und gebe die Systemresourcen frei + curl_close($ch); + + if(!$fh){ + return false; + }else{ + $response = json_decode($fh, true); + if($response["success"] !== true){ + return true; + }else{ + return false; + } + } + } else { + return true; + } + } +} +?> diff --git a/login.php b/login.php index eebdefe..bd98926 100644 --- a/login.php +++ b/login.php @@ -1,7 +1,7 @@ num_rows ($result) <= 0){ $db->query("INSERT INTO `" . $config['prefix'] . "banned_ips` (`ip`,`date`,`reason`) VALUES ('".$session->ip."','".time()."','Autoban - Matched Cookie')"); } - $core->message('Gebannt','Es scheint als wäre deine IP aktulle von der Accounterstellung ausgeschlossen.
Wenn du denkst dies sei ein Fehler bitte sende uns eine E-Mail.',TRUE,$config['path'].'/index.php',5); + $core->message('Gebannt','Es scheint als wäre deine IP aktulle von der Accounterstellung ausgeschlossen.
Wenn du denkst dies sei ein Fehler bitte sende uns eine E-Mail.',TRUE,$config['path'].'/index.php',5); } $result = $db->query("SELECT `id` FROM `" . $config['prefix'] . "banned_ips` WHERE `ip` = '".$db->escape($session->ip)."'"); if ($db->num_rows ($result) > 0){ $row=$db->fetch_object($result); $id=$row->id; $session->setcookie($config['cookiename'] . '_rid', $id , time() + 60 * 60 * 24 * 365, $config['path'],$config['domain']); - $core->message('Gebannt','Es scheint als wäre deine IP aktulle von der Accounterstellung ausgeschlossen.
Wenn du denkst dies sei ein Fehler bitte sende uns eine E-Mail.',TRUE,$config['path'].'/index.php',5); + $core->message('Gebannt','Es scheint als wäre deine IP aktulle von der Accounterstellung ausgeschlossen.
Wenn du denkst dies sei ein Fehler bitte sende uns eine E-Mail.',TRUE,$config['path'].'/index.php',5); } /*if($_GET['activate']!=""){ if($_GET['regstring']!=""){ @@ -41,13 +41,11 @@ if(isset($_POST['submit']) && $_POST['openid']!='' && isset($_POST['openid'])){ $username=$session->sanitize_username($_POST['username']); $vusername=$session->verify_username($username); if($vusername!==TRUE){ - $emsg.=''.$vusername.'
'; + $emsg.=''.$vusername.'
'; } - if($config['captcha']==1){ - include ('thirdparty/securimage/securimage.php'); - $img = new Securimage(); - if(!$img->check($_POST['captcha'])){ - $emsg.='Das Captcha is ungültig!
'; + if($config['captcha']!=0){ + if(!$captcha->validate($_POST)){ + $emsg.='Das Captcha is ungültig!
'; } } if(!preg_match('/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/iD',$_POST['email'])){ @@ -55,11 +53,11 @@ if(isset($_POST['submit']) && $_POST['openid']!='' && isset($_POST['openid'])){ } $result = $db->query("SELECT `uid` FROM `" . $config['prefix'] . "users` WHERE `username` LIKE '".$db->escape($username)."' LIMIT 1"); if ($db->num_rows ($result) > 0){ - $emsg.='Dieser Nickname ist bereits vergeben!
'; + $emsg.='Dieser Nickname ist bereits vergeben!
'; } $result = $db->query("SELECT `uid` FROM `" . $config['prefix'] . "users` WHERE `email` LIKE '".$db->escape($_POST['email'])."' LIMIT 1"); if ($db->num_rows ($result) > 0){ - $emsg.='Diese E-Mail ist bereits registriert!
'; + $emsg.='Diese E-Mail ist bereits registriert!
'; } if(!$emsg){ // Secure Posted Data @@ -84,7 +82,7 @@ if(isset($_POST['submit']) && $_POST['openid']!='' && isset($_POST['openid'])){ $core->redirect_message('Logged in','You have been successfully logged-in and will be redirected shortly.',TRUE,$config['path'].'/index.php',3); }else{ $tpl->assign('emsg',$emsg); - $tpl->assign('captcha',$config['captcha']); + $tpl->assign('captcha',$captcha->getCaptcha()); $tpl->assign('openid',$config['use_openid']); $tpl->assign('identity',$_POST['openid']); $tpl->assign('data',$_POST); @@ -107,52 +105,32 @@ If(isset($_POST['submit'])){ $username=$session->sanitize_username($_POST['username']); $vusername=$session->verify_username($username); if($vusername!==TRUE){ - $emsg.=''.$vusername.'
'; + $emsg.=''.$vusername.'
'; } if(!isset($_POST['agreed']) || $_POST['agreed']==''){ - $emsg.='Du musst den Nutzungsbedingungen zustimmen!
'; + $emsg.='Du musst den Nutzungsbedingungen zustimmen!
'; } if(!isset($_POST['birthday']) || $_POST['birthday']==''){ - $emsg.='Du musst dein Geburtsdatum angeben!
'; + $emsg.='Du musst dein Geburtsdatum angeben!
'; }else{ $birthday = strtotime($_POST['birthday']); // check // 31536000 is the number of seconds in a 365 days year. if(time() - $birthday < 16 * 31536000) { - $emsg.='Du musst leider midnestens 16 Jahre alt sein.
'; + $emsg.='Du musst leider mindestens 16 Jahre alt sein.
'; } } if(!isset($_POST['password']) || $_POST['password']==''){ - $emsg.='Du musst ein Passwort vergeben!
'; + $emsg.='Du musst ein Passwort vergeben!
'; }elseif($_POST['password']!=$_POST['cpassword']){ - $emsg.='Deine Passwörter stimmen nicht überein!
'; + $emsg.='Deine Passwörter stimmen nicht überein!
'; }elseif(strlen($_POST['password'])<6){ - $emsg.='Dein Passwort ist zu kurz, es muss mindestens 6 Zeichen lang sein.
'; + $emsg.='Dein Passwort ist zu kurz, es muss mindestens 6 Zeichen lang sein.
'; } - if($config['captcha']==1){ - if(isset($_POST['g-recaptcha-response']) && $_POST['g-recaptcha-response']!=''){ - $ch = curl_init(); - - // setze die URL und andere Optionen - curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify?secret=".$config['recaptcha_secret']."&response=".$_POST['g-recaptcha-response']."&remoteip=".$functions->get_ip()); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_TIMEOUT, 10); - // führe die Aktion aus und gebe die Daten an den Browser weiter - $fh=curl_exec($ch); - - // schließe den cURL-Handle und gebe die Systemresourcen frei - curl_close($ch); - - if(!$fh){ - $emsg.='Das Captcha is ungültig!
'; - }else{ - $response = json_decode($fh, true); - if($response["success"] !== true){ - $emsg.='Das Captcha is ungültig!
'; - } - } + if($config['captcha']!=0){ + if(!$captcha->validate($_POST)){ + $emsg.='Das Captcha is ungültig!
'; } } if(!preg_match('/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/iD',$_POST['email'])){ @@ -209,11 +187,12 @@ If(isset($_POST['submit'])){ } $meta=' '; +'; +$dcap = $captcha->getCaptcha(); $tpl->assign('path','//'.$config['domain'].'/'.$config['path']); $tpl->assign('emsg',$emsg); $tpl->assign('regstring',$_GET['regstring']); -$tpl->assign('captcha',$config['captcha']); +$tpl->assign('captcha',$dcap); $tpl->assign('sid',md5(uniqid(time()))); $tpl->assign('data',$_POST); $content=$tpl->fetch('register.tpl'); diff --git a/themes/austria/register.tpl b/themes/austria/register.tpl index bea7800..54ad9e5 100644 --- a/themes/austria/register.tpl +++ b/themes/austria/register.tpl @@ -40,16 +40,14 @@
Ich stimme den Nutzungsbedingungen zu und bestätige mindestens 16 Jahre alt zu sein. - - {if $captcha==1} -
- Captcha -
-
+ {if $captcha != ""} + Captcha + {$captcha} {/if} + Pflichtfelder
-
\ No newline at end of file + diff --git a/themes/default/register.tpl b/themes/default/register.tpl index 233d3ea..ac0d48e 100644 --- a/themes/default/register.tpl +++ b/themes/default/register.tpl @@ -1,45 +1,43 @@ -

Registrieren

- -{$emsg} -
-
+

Registrieren

+ +{$emsg} + +
Grunddaten
Username:
-
-
+
+
E-Mail:
-
Passwort:
-
-
- Passwort wiederholen:
+
Passwort:
+
+
+ Passwort wiederholen:
+
Realer Name:
-
-
+
+
Herkunft:
-
+
/ Geschlecht:
-
-
+
+
Geburtstag:
-
-
-
-{if $captcha==1} + +
+
+{if $captcha != ""} Captcha
Captcha:
-
Refresh Sound

-
-
- Captcha eingeben:
-
-
-{/if} +{$captcha} + +
+{/if} benötigtes Feld
-
-
+ +