]> git.mxchange.org Git - friendica.git/commitdiff
clean up some regex's for i18n, and eliminate old ereg patterns.
authorFriendika <info@friendika.com>
Sun, 14 Nov 2010 08:32:31 +0000 (00:32 -0800)
committerFriendika <info@friendika.com>
Sun, 14 Nov 2010 08:32:31 +0000 (00:32 -0800)
INSTALL
boot.php
mod/invite.php
mod/register.php
mod/settings.php

diff --git a/INSTALL b/INSTALL
index b2b1a703a5f8a4f30d0c3b5f2cb10119f9d3c87f..624333e906b8db576fb81f9e0d6b2a9932b19a44 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -7,8 +7,7 @@ local .htaccess file
 
        - PHP > 5.1. The later the better. You'll need 5.3 for full openssl 
 encryption support
-
-       - PHP *command line* access with register_argc_argv set to true in the 
+               - PHP *command line* access with register_argc_argv set to true in the 
 php.ini file
 
        - Mysql 5.x
index 948cca46dc1383be8b466ab3a205907cde103974..ad1df4ed13e4f3aa7889e971c537b0414ba4dcf5 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -736,7 +736,7 @@ function hex2bin($s) {
 if(! function_exists('paginate')) {
 function paginate(&$a) {
        $o = '';
-       $stripped = ereg_replace("(&page=[0-9]*)","",$_SERVER['QUERY_STRING']);
+       $stripped = preg_replace('/(&page=[0-9]*)/','',$_SERVER['QUERY_STRING']);
        $stripped = str_replace('q=','',$stripped);
        $stripped = trim($stripped,'/');
        $url = $a->get_baseurl() . '/' . $stripped;
@@ -1444,3 +1444,10 @@ function search($s) {
        return $o;
 }}
 
+if(! function_exists('valid_email')) {
+function valid_email($x){
+       if(preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x))
+               return true;
+       return false;
+}}
+
index 3f9efc57427a5a881fee5fe5fa22ceed718e6b57..fe706a5244d90007d475f13cf656b3b43dd3a328 100644 (file)
@@ -17,12 +17,13 @@ function invite_post(&$a) {
 
                $recip = trim($recip);
 
-               if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}', $recip)) {
-                       notice(  $recip . t(' : ') . t('Not a valid email address.') . EOL);
+               if(! valid_email($recip)) {
+                       notice(  $recip . t(' : ') . t('Not a valid email address.') . EOL);
                        continue;
                }
 
-                $res = mail($recip, t('Please join my network on ') . $a->config['sitename'], $message, "From: " . $a->user['email']);
+               $res = mail($recip, t('Please join my network on ') . $a->config['sitename'], 
+                       $message, "From: " . $a->user['email']);
                if($res) {
                        $total ++;
                }
index 99823f45138bab5d94b694f7040be7d53045334a..a0a5e5c284f880ba7003d5732452184ea1472cee 100644 (file)
@@ -46,7 +46,7 @@ function register_post(&$a) {
 
        // TODO fix some of these regex's for int'l/utf-8.
 
-       if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}',$email))
+       if(! valid_email($email))
                $err .= t(' Not a valid email address.');
        if(strlen($username) > 48)
                $err .= t(' Please use a shorter name.');
@@ -55,19 +55,22 @@ function register_post(&$a) {
 
        // I don't really like having this rule, but it cuts down
        // on the number of auto-registrations by Russian spammers
+       
+       $no_utf = get_config('system','no_utf');
 
-       if(! preg_match("/^[a-zA-Z]* [a-zA-Z]*$/",$username))
-               $err .= t(' That doesn\'t appear to be your full name.');
+       $pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' ); 
 
-       if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}',$email))
-                       $err .= t(' Not valid email.');
+       $loose_reg = get_config('system','no_regfullname');
+
+       if((! $loose_reg) && (! preg_match($pat,$username)))
+               $err .= t(' That doesn\'t appear to be your full name.');
 
        if(! allowed_email($email))
                        $err .= t(' Your email domain is not among those allowed on this site.');
 
        $nickname = strtolower($nickname);
        if(! preg_match("/^[a-z][a-z0-9\-\_]*$/",$nickname))
-               $err .= t(' Nickname <strong>must</strong> start with a letter and contain only letters, numbers, dashes, or underscore.') ;
+               $err .= t(' Your "nickname" can only contain "a-z", "0-9", "-", and "_", and must also begin with a letter.');
        $r = q("SELECT `uid` FROM `user`
                        WHERE `nickname` = '%s' LIMIT 1",
                        dbesc($nickname)
index eab4ac52e7c7906cd5905b3d774efdec93c635d4..0687a498f2cdcea785d2e2c7b481d14854f64e9e 100644 (file)
@@ -86,8 +86,8 @@ function settings_post(&$a) {
 
        if($email != $a->user['email']) {
                $email_changed = true;
-               if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}',$email))
-                       $err .= t(' Not valid email.');
+        if(! valid_email($email))
+                       $err .= t(' Not valid email.');
        }
 
        if(strlen($err)) {