Changeset 1424

Show
Ignore:
Timestamp:
10/02/09 16:21:40 (4 years ago)
Author:
gbastien
Message:

* Email address format now corresponds to newer standard RFC2822 (#624)
* Corrected typos and tab alignment

Location:
trunk/wifidog-auth
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1421 r1424  
    11# $Id$ 
     2 
     32009-10-02 Geneviève Bastien <gbastien@versatic.net> 
     4  * Email address format now corresponds to newer standard RFC2822 (#624) 
     5  * Corrected typos and tab alignment 
    26 
    372009-09-18 Geneviève Bastien <gbastien@versatic.net> 
  • trunk/wifidog-auth/wifidog/admin/generic_object_admin.php

    r1421 r1424  
    324324        break; 
    325325 
    326             case "new_ui" : 
    327                 switch ($_REQUEST['object_class']) { 
    328                     case "Node" : 
    329                     case "Server" : 
    330                     case "Content" : 
    331                     case "ContentTypeFilter" : 
    332                     case "ProfileTemplate" : 
    333                         $newText = $addText; 
    334                         break; 
    335  
    336                     default : 
    337                         break; 
    338                 } 
    339  
    340                 $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' method='post'>"; 
    341                 $html .= "<input type='hidden' name='object_class' value='$class'>"; 
    342                 $html .= call_user_func(array ( 
    343                 $class, 
    344                 'getCreateNewObjectUI' 
    345                 )); 
    346                 $html .= "<input type='hidden' name='action' value='process_new_ui'>"; 
    347                 $html .= "<input type=submit name='new_ui_submit' value='$newText'>"; 
    348                 $html .= '</form>'; 
    349                 break; 
    350  
    351                     case "edit" : 
    352                         // Process preview abilities 
    353                         switch ($_REQUEST['object_class']) { 
    354                             case "Network" : 
    355                             case "Server" : 
    356                             case "User" : 
    357                             case "ContentTypeFilter" : 
    358                             case "ProfileTemplate" : 
    359                                 $supportsPreview = false; 
    360                                 break; 
    361  
    362                             default : 
    363                                 break; 
    364                         } 
    365  
    366                         // Process deletion abilities 
    367                         switch ($_REQUEST['object_class']) { 
    368                             case "User" : 
    369                                 $supportsDeletion = false; 
    370                                 break; 
    371                             case "Network" : 
    372                             case "Node" : 
    373                             case "Server" : 
    374                             case "ProfileTemplate" : 
    375                             case "ContentTypeFilter" : 
    376                                 break; 
    377  
    378                             default : 
    379                                 break; 
    380                         } 
    381  
    382                         if (!$object) { 
    383                             echo "<div class='errormsg'>" . _("Sorry, the 'object_id' parameter must be specified") . "</div>"; 
    384                             exit; 
    385                         } 
    386  
    387                         if (!empty ($_REQUEST['debug'])) { 
    388                             $common_input .= "<input type='hidden' name='debug' value='true'>"; 
    389                         } 
    390  
    391                         $common_input .= "<input type='hidden' name='object_id' value='" . $object->getId() . "'>"; 
    392                         $common_input .= "<input type='hidden' name='object_class' value='" . get_class($object) . "'>"; 
    393  
    394                         $html .= "<form name='generic_object_form' enctype='multipart/form-data' action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' method='post'>"; 
    395                         $html .= $common_input; 
    396                         $html .= $object->getAdminUI(); 
    397                         $html .= "<div class='generic_object_admin_edit'>"; 
    398                         $html .= "<input type='hidden' name='action' value='save'>"; 
    399                         $html .= "<input type='submit' class='submit' name='save_submit' value='" . _("Save") . " " . get_class($object) . "'>"; 
    400  
    401                         if ($supportsDeletion) { 
    402                             $html .= "<script type='text/javascript'>"; 
    403                             $html .= "document.write(\"<input type='hidden' name='action_delete' value='no' id='form_action_delete' />\");"; 
    404                             $html .= "document.write(\"<input type='submit' class='submit' name='action_delete_submit' onmouseup='document.getElementById(\\\"form_action_delete\\\").value = \\\"delete\\\"' onkeyup='document.getElementById(\\\"form_action_delete\\\").value = \\\"delete\\\"' value='" . _("Delete") . " " . get_class($object) . "' />\");"; 
    405                             $html .= "</script>"; 
    406                         } 
    407  
    408                         $html .= '</form>'; 
    409  
    410                         if ($supportsPreview) { 
    411                             $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' target='_blank' method='post'>"; 
    412                             $html .= $common_input; 
    413                             $html .= "<input type='hidden' name='action' value='preview'>"; 
    414                             $html .= "<input type='submit' class='submit' name='preview_submit' value='" . _("Preview") . " " . get_class($object) . "'>"; 
    415                             $html .= '</form>'; 
    416                         } 
    417  
    418                         // Display delete button (without check for unchecked persitant switch) only if JavaScript has been disabled 
    419                         if ($supportsDeletion) { 
    420                             $html .= "<noscript>"; 
    421                             $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' method='post'>"; 
    422                             $html .= $common_input; 
    423                             $html .= "<input type='hidden' name='action' value='delete'>"; 
    424                             $html .= "<input type='submit' class='submit'  name='delete_submit' value='" . _("Delete") . " " . get_class($object) . "'>"; 
    425                             $html .= '</form>'; 
    426                             $html .= "</noscript>"; 
    427                         } 
    428  
    429                         $html .= "<div class='clearbr'></div>"; 
    430                         $html .= "</div>"; 
    431                         break; 
    432  
    433                             default : 
    434                                 // Do nothing 
    435                                 break; 
     326    case "new_ui" : 
     327        switch ($_REQUEST['object_class']) { 
     328            case "Node" : 
     329            case "Server" : 
     330            case "Content" : 
     331            case "ContentTypeFilter" : 
     332            case "ProfileTemplate" : 
     333                $newText = $addText; 
     334                break; 
     335 
     336            default : 
     337                break; 
     338        } 
     339 
     340        $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' method='post'>"; 
     341        $html .= "<input type='hidden' name='object_class' value='$class'>"; 
     342        $html .= call_user_func(array ( 
     343            $class, 
     344            'getCreateNewObjectUI' 
     345            )); 
     346        $html .= "<input type='hidden' name='action' value='process_new_ui'>"; 
     347        $html .= "<input type=submit name='new_ui_submit' value='$newText'>"; 
     348        $html .= '</form>'; 
     349        break; 
     350 
     351    case "edit" : 
     352        // Process preview abilities 
     353        switch ($_REQUEST['object_class']) { 
     354            case "Network" : 
     355            case "Server" : 
     356            case "User" : 
     357            case "ContentTypeFilter" : 
     358            case "ProfileTemplate" : 
     359                $supportsPreview = false; 
     360                break; 
     361 
     362            default : 
     363                break; 
     364        } 
     365 
     366        // Process deletion abilities 
     367        switch ($_REQUEST['object_class']) { 
     368            case "User" : 
     369                $supportsDeletion = false; 
     370                break; 
     371            case "Network" : 
     372            case "Node" : 
     373            case "Server" : 
     374            case "ProfileTemplate" : 
     375            case "ContentTypeFilter" : 
     376                break; 
     377 
     378            default : 
     379                break; 
     380        } 
     381 
     382        if (!$object) { 
     383            echo "<div class='errormsg'>" . _("Sorry, the 'object_id' parameter must be specified") . "</div>"; 
     384            exit; 
     385        } 
     386 
     387        if (!empty ($_REQUEST['debug'])) { 
     388            $common_input .= "<input type='hidden' name='debug' value='true'>"; 
     389        } 
     390 
     391        $common_input .= "<input type='hidden' name='object_id' value='" . $object->getId() . "'>"; 
     392        $common_input .= "<input type='hidden' name='object_class' value='" . get_class($object) . "'>"; 
     393 
     394        $html .= "<form name='generic_object_form' enctype='multipart/form-data' action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' method='post'>"; 
     395        $html .= $common_input; 
     396        $html .= $object->getAdminUI(); 
     397        $html .= "<div class='generic_object_admin_edit'>"; 
     398        $html .= "<input type='hidden' name='action' value='save'>"; 
     399        $html .= "<input type='submit' class='submit' name='save_submit' value='" . _("Save") . " " . get_class($object) . "'>"; 
     400 
     401        if ($supportsDeletion) { 
     402            $html .= "<script type='text/javascript'>"; 
     403            $html .= "document.write(\"<input type='hidden' name='action_delete' value='no' id='form_action_delete' />\");"; 
     404            $html .= "document.write(\"<input type='submit' class='submit' name='action_delete_submit' onmouseup='document.getElementById(\\\"form_action_delete\\\").value = \\\"delete\\\"' onkeyup='document.getElementById(\\\"form_action_delete\\\").value = \\\"delete\\\"' value='" . _("Delete") . " " . get_class($object) . "' />\");"; 
     405            $html .= "</script>"; 
     406        } 
     407 
     408        $html .= '</form>'; 
     409 
     410        if ($supportsPreview) { 
     411            $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' target='_blank' method='post'>"; 
     412            $html .= $common_input; 
     413            $html .= "<input type='hidden' name='action' value='preview'>"; 
     414            $html .= "<input type='submit' class='submit' name='preview_submit' value='" . _("Preview") . " " . get_class($object) . "'>"; 
     415            $html .= '</form>'; 
     416        } 
     417 
     418        // Display delete button (without check for unchecked persitant switch) only if JavaScript has been disabled 
     419        if ($supportsDeletion) { 
     420            $html .= "<noscript>"; 
     421            $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' method='post'>"; 
     422            $html .= $common_input; 
     423            $html .= "<input type='hidden' name='action' value='delete'>"; 
     424            $html .= "<input type='submit' class='submit'  name='delete_submit' value='" . _("Delete") . " " . get_class($object) . "'>"; 
     425            $html .= '</form>'; 
     426            $html .= "</noscript>"; 
     427        } 
     428 
     429        $html .= "<div class='clearbr'></div>"; 
     430        $html .= "</div>"; 
     431        break; 
     432 
     433    default : 
     434        // Do nothing 
     435        break; 
    436436} 
    437437 
  • trunk/wifidog-auth/wifidog/classes/Locale.php

    r1421 r1424  
    218218                   if(!isset($AVAIL_LOCALE_ARRAY[$locale_id]) && !isset($AVAIL_LOCALE_ARRAY[$lang_only_locale_id])) 
    219219                   { 
    220                      echo sprintf("Warning in /classes/Locale.php setCurentLocale: Neither %s or %s are available in AVAIL_LOCALE_ARRAY", $locale_id, $lang_only_locale_id)."<br/>"; 
     220                     echo sprintf("Warning in /classes/Locale.php setCurrentLocale: Neither %s or %s are available in AVAIL_LOCALE_ARRAY", $locale_id, $lang_only_locale_id)."<br/>"; 
    221221                   } 
    222222            // Try to set locale 
     
    232232            // Test it against current PHP locale 
    233233            if (substr ($current_locale, 0 , 2) != $lang_only_locale_id) { 
    234                 echo sprintf("Warning in /classes/Locale.php setCurentLocale: Unable to setlocale() to %s: %s.  I tried %s, %s, %s, %s, and got return value: %s, current locale is: %s",$q, $locale_id, $candidate_locale_array[0], $candidate_locale_array[1], $candidate_locale_array[2], $candidate_locale_array[3], $current_locale, setlocale(LC_ALL, 0))."<br/>"; 
     234                echo sprintf("Warning in /classes/Locale.php setCurrentLocale: Unable to setlocale() to %s: %s.  I tried %s, %s, %s, %s, and got return value: %s, current locale is: %s",$q, $locale_id, $candidate_locale_array[0], $candidate_locale_array[1], $candidate_locale_array[2], $candidate_locale_array[3], $current_locale, setlocale(LC_ALL, 0))."<br/>"; 
    235235                $retval = false; 
    236236            } else { 
  • trunk/wifidog-auth/wifidog/classes/Mail.php

    r1321 r1424  
    411411         * Validates an email address 
    412412         * 
    413          * This function will make sure an e-mail is RFC822 compliant 
     413         * This function will make sure an e-mail is RFC2822 compliant 
    414414         * and is not black listed. 
     415         *  
     416         * The regex was taken from  http://www.regular-expressions.info/email.html 
     417         * Read also http://www.linuxjournal.com/article/9585 for more on email validation 
    415418         * 
    416419         * @param string $mail The email address to validate 
     
    427430 
    428431            // Test if the email address is valid 
    429             $regex = "/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i"; 
    430  
    431             if (preg_match_all($regex, $email, $_matches)) { 
    432                 // If the hostname is black listed, reject the email address 
    433                 $full_hostname = $_matches[2][0] . "." . $_matches[3][0]; 
    434  
    435                 if (!in_array(strtolower($full_hostname), self :: $_hosts_black_list)) { 
    436                     $_retVal = true; 
     432            // $regex = "/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i"; 
     433            // The full regex is  
     434            // /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i 
     435            // We will check it in two parts: domain and local 
     436                                                 
     437            $atIndex = strrpos($email, "@"); 
     438            if ($atIndex !== false) 
     439            { 
     440                $domain = substr($email, $atIndex+1); 
     441                $local = substr($email, 0, $atIndex); 
     442         
     443                // Verify local part 
     444                if (preg_match("/^[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+)*$/i",$local) && 
     445                    preg_match("/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i",$domain) )  
     446                { 
     447 
     448                    if (!in_array(strtolower($domain), self :: $_hosts_black_list)) { 
     449                        if (checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")) { 
     450                            $_retVal = true; 
     451                        } 
     452                    } 
    437453                } 
    438454            } 
  • trunk/wifidog-auth/wifidog/js/formutils.js

    r1064 r1424  
    4444function isValidEmail(elem) { 
    4545  var str = elem.value; 
    46   var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/; 
     46  //var re = /^[\w-+]+(\.[\w+-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/; 
     47  var re = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/; 
    4748  if (!str.match(re)) { 
    4849        focusElement(elem.form.name, elem.name);