Changeset 1428
- Timestamp:
- 10/30/09 14:21:05 (4 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 9 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/classes/AbstractDb.php (modified) (2 diffs)
-
wifidog/classes/Authenticators/AuthenticatorLocalUser.php (modified) (2 diffs)
-
wifidog/classes/Network.php (modified) (6 diffs)
-
wifidog/classes/NodeList.php (modified) (1 diff)
-
wifidog/classes/User.php (modified) (4 diffs)
-
wifidog/include/common.php (modified) (1 diff)
-
wifidog/include/schema_validate.php (modified) (2 diffs)
-
wifidog/js/formutils.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1424 r1428 1 1 # $Id$ 2 2 3 2009-10-30 Geneviève Bastien <gbastien@versatic.net> 4 * Network can now be set as case insensitive. Emails are now never case sensitive and usernames' case sensitivity is consistent with network settings (#616) 5 * Yet again some tab alignment 6 3 7 2009-10-02 Geneviève Bastien <gbastien@versatic.net> 4 8 * Email address format now corresponds to newer standard RFC2822 (#624) -
trunk/wifidog-auth/wifidog/classes/AbstractDb.php
r1421 r1428 142 142 143 143 if ($debug == TRUE) 144 echo "<p>".sprintf(_("Elapsed time for query execution : %.6f second(s)"), $sql_timetaken)."</p>\n";144 echo "<p>".sprintf(_("Elapsed time for query execution : %.6f second(s)"), $sql_timetaken)."</p>\n"; 145 145 146 146 if ($result == FALSE) … … 317 317 { 318 318 $retval = ""; 319 319 320 320 /* PHP time */ 321 321 $parts_of_starttime = explode(' ', $this->construct_start_time); -
trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUser.php
r1419 r1428 119 119 } 120 120 else{ 121 /* gbastien: this is not reusable!!, why not use password directly? */ 122 //$password_hash = User::passwordHash($_REQUEST['password']); 123 $password_hash = User::passwordHash($password); 121 124 $password = $db->escapeString($password); 122 $password_hash = User::passwordHash($_REQUEST['password']);123 124 $sql = "SELECT user_id FROM users WHERE (username ='$username' OR email='$username') AND account_origin='".$this->getNetwork()->getId()."' AND pass='$password_hash'";125 126 $comparison = ($this->getNetwork()->getUsernamesCaseSensitive()? ' = ': ' ILike '); 127 $sql = "SELECT user_id FROM users WHERE (username$comparison'$username' OR email$comparison'$username') AND account_origin='".$this->getNetwork()->getId()."' AND pass='$password_hash'"; 125 128 $db->execSqlUniqueRes($sql, $user_info, false); 126 129 … … 141 144 */ 142 145 $user_info = null; 143 $db->execSqlUniqueRes("SELECT * FROM users WHERE (username ='$username' OR email='$username') AND account_origin='".$this->getNetwork()->getId()."'", $user_info, false);146 $db->execSqlUniqueRes("SELECT * FROM users WHERE (username$comparison'$username' OR email$comparison'$username') AND account_origin='".$this->getNetwork()->getId()."'", $user_info, false); 144 147 145 148 if ($user_info == null) { -
trunk/wifidog-auth/wifidog/classes/Network.php
r1421 r1428 1618 1618 return $retVal; 1619 1619 } 1620 1621 /** Are usernames on this network case sensitive or not 1622 * 1623 * @return bool true or false 1624 */ 1625 public function getUsernamesCaseSensitive() 1626 { 1627 return (($this->_row['usernames_case_sensitive'] == 't') ? true : false); 1628 } 1629 1630 /** Are usernames on this network case sensitive or not 1631 * If set to false, we need to verify if some users have name-clash and propose actions 1632 * 1633 * @param string $value The new creation date 1634 * 1635 * @return bool True on success, false on failure 1636 */ 1637 public function setUsernamesCaseSensitive($value) 1638 { 1639 // Init values 1640 $retval = true; 1641 1642 if ($value != $this->getUsernamesCaseSensitive()) { 1643 $db = AbstractDb::getObject(); 1644 // Verify if usernames differing by case exists 1645 if (!$value) { 1646 $sql = "Select username, email from users where 1647 lower(username) in (Select lower(username) as uname from users where account_origin = '{$this->getId()}' group by lower(username) having count(user_id) > 1) 1648 or lower(email) in (Select lower(email) from users where account_origin = '{$this->getId()}' group by lower(email) having count(user_id) > 1) order by username"; 1649 if (!$db->execSql($sql, $duplicates)) 1650 $retval = false; 1651 if (!empty($duplicates)) { 1652 $duplicatenames = array(); 1653 foreach($duplicates as $duplicate) $duplicatenames[] = "{$duplicate['username']} ({$duplicate['email']})"; 1654 $this->errorMsg = _("You cannot change the case sensitivity of this network because some users would have duplicate names or emails. Some action must be performed before.<br/>Here is a list of duplicate usernames: " . implode(', ', $duplicatenames)); 1655 $retval = false; 1656 } 1657 } 1658 if ($retval) { 1659 $value ? $value = 'TRUE' : $value = 'FALSE'; 1660 $retval = $db->execSqlUpdate("UPDATE networks SET usernames_case_sensitive = {$value} WHERE network_id = '{$this->getId()}'", false); 1661 $this->refresh(); 1662 } 1663 } 1664 1665 return $retval; 1666 } 1620 1667 1621 1668 … … 1631 1678 // Init values 1632 1679 $html = ''; 1680 1681 /* 1682 * Verify if an error message was registered before outputting the form 1683 */ 1684 if (isset($this->errorMsg)) { 1685 $html .= "<div class='errormsg'>" . $this->errorMsg . "</div>"; 1686 } 1633 1687 1634 1688 /* … … 1711 1765 $data = ThemePack::getSelectUI("network_" . $this->getId() . "_theme_pack", $this->getThemePack()); 1712 1766 $html_network_properties[] = InterfaceElements::generateAdminSectionContainer("network_theme_pack", $title, $data); 1713 1767 1714 1768 // Build section 1715 1769 $html .= InterfaceElements::generateAdminSectionContainer("network_properties", _("Network properties"), implode(null, $html_network_properties)); … … 1736 1790 $help = _("Are nodes allowed to redirect users to the web page they originally requested instead of the portal?"); 1737 1791 $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_original_URL_redirect", "", _("Yes"), $this->getPortalOriginalUrlAllowed(), "network_allow_original_URL_redirect_radio"); 1738 $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_original_URL_redirect", $title, $data, $help); 1792 $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_original_URL_redirect", $title, $data, $help); 1739 1793 1740 1794 // Build section … … 1762 1816 $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_multiple_login", "", _("Yes"), $this->getMultipleLoginAllowed(), "network_allow_multiple_login_radio"); 1763 1817 $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_allow_multiple_login", $title, $data, $help); 1818 1819 1820 // network_authenticator_params 1821 $title = _("Case sensitivity"); 1822 $help = _("Are usernames case sensitive?"); 1823 $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_usernames_case_sensitive","", _("Yes"), $this->getUsernamesCaseSensitive(), "network_usernames_case_sensitive"); 1824 $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_usernames_case_sensitive", $title, $data, $help); 1764 1825 1765 1826 // Build section … … 1924 1985 $name = "network_".$this->getId()."_validation_email_from_address"; 1925 1986 $this->setValidationEmailFromAddress($_REQUEST[$name]); 1987 1988 $name = "network_" . $this->getId() . "_usernames_case_sensitive"; 1989 $this->setUsernamesCaseSensitive(empty ($_REQUEST[$name]) ? false : true); 1926 1990 1927 1991 // theme_pack -
trunk/wifidog-auth/wifidog/classes/NodeList.php
r1391 r1428 208 208 209 209 $items[] = array('path' => 'node_lists/map', 210 'title' => _("Deployed HotSpots map"),211 'url' => BASE_URL_PATH."hotspots_map.php"212 );210 'title' => _("Deployed HotSpots map"), 211 'url' => BASE_URL_PATH."hotspots_map.php" 212 ); 213 213 214 214 $listTypes=self::getAvailableNodeListTypes(); 215 215 //pretty_print_r($listTypes); 216 216 foreach ($listTypes as $type) { 217 $nodeListClass = "NodeList" . $type;218 require_once("classes/NodeLists/NodeList{$type}.php");217 $nodeListClass = "NodeList" . $type; 218 require_once("classes/NodeLists/NodeList{$type}.php"); 219 219 if(call_user_func(array($nodeListClass, 'isAvailable'))) { 220 $items[] = array('path' => 'node_lists/'.$type,221 'title' => sprintf(_("List in %s format"), $type),222 'url' => BASE_URL_PATH."hotspot_status.php?format=$type"223 );220 $items[] = array('path' => 'node_lists/'.$type, 221 'title' => sprintf(_("List in %s format"), $type), 222 'url' => BASE_URL_PATH."hotspot_status.php?format=$type" 223 ); 224 224 } 225 225 } 226 226 $items[] = array('path' => 'node_lists/technical_status', 227 'title' => _("Full node technical status (includes non-deployed nodes)"),228 'url' => BASE_URL_PATH."node_list.php"229 );227 'title' => _("Full node technical status (includes non-deployed nodes)"), 228 'url' => BASE_URL_PATH."node_list.php" 229 ); 230 230 $items[] = array('path' => 'node_lists', 231 'title' => _('Find Hotspots'), 232 'type' => MENU_ITEM_GROUPING); 233 234 235 231 'title' => _('Find Hotspots'), 232 'type' => MENU_ITEM_GROUPING); 236 233 237 234 return $items; -
trunk/wifidog-auth/wifidog/classes/User.php
r1421 r1428 160 160 161 161 $username_str = $db->escapeString($username); 162 $comparison = ($account_origin->getUsernamesCaseSensitive()? '=': 'ILike'); 162 163 $account_origin_str = $db->escapeString($account_origin->getId()); 163 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE username ='$username_str' AND account_origin = '$account_origin_str'", $user_info, false);164 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE username {$comparison} '$username_str' AND account_origin = '$account_origin_str'", $user_info, false); 164 165 165 166 if ($user_info != null) { … … 182 183 183 184 $usernameOrEmail_str = $db->escapeString($usernameOrEmail); 184 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE username ILike'$usernameOrEmail_str' OR email ILike '$usernameOrEmail_str'", $user_info, false);185 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE username = '$usernameOrEmail_str' OR email ILike '$usernameOrEmail_str'", $user_info, false); 185 186 186 187 if ($user_info != null) { … … 221 222 $email_str = $db->escapeString($email); 222 223 $account_origin_str = $db->escapeString($account_origin->getId()); 223 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE email ='$email_str' AND account_origin = '$account_origin_str'", $user_info, false);224 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE email ILike '$email_str' AND account_origin = '$account_origin_str'", $user_info, false); 224 225 225 226 if ($user_info != null) … … 378 379 if ($value != $this->getUsername()) { 379 380 $db = AbstractDb::getObject(); 381 $otherUser = User::getUserByUsernameAndOrigin($value, $this->getNetwork()); 382 if (!is_null($otherUser)) { 383 throw new exception(sprintf(_("Sorry, the username %s is not available"), $value)); 384 } 380 385 $value = $db->escapeString($value); 381 386 $retval = @ $db->execSqlUpdate("UPDATE users SET username = '{$value}' WHERE user_id='{$this->id}'", false); 382 if (!$retval) {383 throw new exception(sprintf(_("Sorry, the username %s is not available"), $value));384 }385 387 $this->refresh(); 386 388 } -
trunk/wifidog-auth/wifidog/include/common.php
r1421 r1428 347 347 348 348 return $string; 349 }350 }351 $myLogfile = !defined('WIFIDOG_LOGFILE') ? "tmp/wifidog.log" : constant('WIFIDOG_LOGFILE');352 if (!empty ($myLogfile)) {353 if (substr($myLogfile, 0, 1) != '/')354 $myLogfile = WIFIDOG_ABS_FILE_PATH . $myLogfile;355 356 EventLogging :: stAddChannel(new FileChannel($myLogfile, new WifidogSyslogFormatter(), 'warning,notice'), 'logfile');357 }349 } 350 } 351 $myLogfile = !defined('WIFIDOG_LOGFILE') ? "tmp/wifidog.log" : constant('WIFIDOG_LOGFILE'); 352 if (!empty ($myLogfile)) { 353 if (substr($myLogfile, 0, 1) != '/') 354 $myLogfile = WIFIDOG_ABS_FILE_PATH . $myLogfile; 355 356 EventLogging :: stAddChannel(new FileChannel($myLogfile, new WifidogSyslogFormatter(), 'warning,notice'), 'logfile'); 357 } 358 358 359 359 // trigger_error("here i am", E_USER_NOTICE); -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r1421 r1428 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 6 6);50 define('REQUIRED_SCHEMA_VERSION', 67); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1449 1449 } 1450 1450 1451 $new_schema_version = 67; 1452 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1453 printUpdateVersion($new_schema_version); 1454 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1455 $sql .= "\n\nALTER TABLE networks ADD COLUMN usernames_case_sensitive boolean NOT NULL DEFAULT true;\n"; 1456 } 1457 1451 1458 /* 1452 1459 $new_schema_version = ; -
trunk/wifidog-auth/wifidog/js/formutils.js
r1424 r1428 45 45 var str = elem.value; 46 46 //var re = /^[\w-+]+(\.[\w+-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/; 47 var re = /^[a-z 0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;47 var re = /^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/; 48 48 if (!str.match(re)) { 49 49 focusElement(elem.form.name, elem.name);
