Skip to content

Commit

Permalink
Renaming the db field length constants
Browse files Browse the repository at this point in the history
USERLEN ==> DB_FIELD_SIZE_USERNAME
REALLEN ==> DB_FIELD_SIZE_REALNAME
PASSLEN ==> DB_FIELD_SIZE_PASSWORD
  • Loading branch information
dregad committed Jul 25, 2011
1 parent 3c6b36e commit 0f9cf06
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion account_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
$t_show_update_button = true;
echo '<label for="realname"><span>' . lang_get( 'realname' ) . '</span></label>';
echo '<span class="input">';
echo '<input id="realname" type="text" size="32" maxlength="' . REALLEN . '" name="realname" value="' . string_attribute( $u_realname ) . '" />';
echo '<input id="realname" type="text" size="32" maxlength="' . DB_FIELD_SIZE_REALNAME . '" name="realname" value="' . string_attribute( $u_realname ) . '" />';
echo '</span>';
} ?>
<span class="label-style"></span>
Expand Down
10 changes: 5 additions & 5 deletions core/authentication_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function auth_get_password_max_size() {
case PLAIN:
case BASIC_AUTH:
case HTTP_AUTH:
return PASSLEN;
return DB_FIELD_SIZE_PASSWORD;

# All other cases, i.e. password is stored as a hash
default:
Expand Down Expand Up @@ -440,7 +440,7 @@ function auth_does_password_match( $p_user_id, $p_test_password ) {
* @param string $p_password
* @param string $p_salt salt, defaults to null
* @param string $p_method logon method, defaults to null (use config login method)
* @return string processed password, maximum PASSLEN chars in length
* @return string processed password, maximum DB_FIELD_SIZE_PASSWORD chars in length
* @access public
*/
function auth_process_plain_password( $p_password, $p_salt = null, $p_method = null ) {
Expand All @@ -466,8 +466,8 @@ function auth_process_plain_password( $p_password, $p_salt = null, $p_method = n
break;
}

# cut this off to PASSLEN characters which the largest possible string in the database
return utf8_substr( $t_processed_password, 0, PASSLEN );
# cut this off to DB_FIELD_SIZE_PASSWORD characters which the largest possible string in the database
return utf8_substr( $t_processed_password, 0, DB_FIELD_SIZE_PASSWORD );
}

/**
Expand Down Expand Up @@ -730,7 +730,7 @@ function auth_reauthenticate_page( $p_user_id, $p_username ) {
<input type="hidden" name="_authenticate" value="1" />
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="username"><span><?php echo lang_get( 'username' );?></span></label>
<span class="input"><input id="username" type="text" disabled="disabled" size="32" maxlength="<?php echo USERLEN;?>" value="<?php echo string_attribute( $p_username );?>" /></span>
<span class="input"><input id="username" type="text" disabled="disabled" size="32" maxlength="<?php echo DB_FIELD_SIZE_USERNAME;?>" value="<?php echo string_attribute( $p_username );?>" /></span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
Expand Down
6 changes: 3 additions & 3 deletions core/constant_inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@
define( 'PHPMAILER_METHOD_SMTP', 2 );

# Lengths - NOTE: these may represent hard-coded values in db schema and should not be changed.
define( 'USERLEN', 32);
define( 'REALLEN', 64);
define( 'PASSLEN', 32);
define( 'DB_FIELD_SIZE_USERNAME', 32);
define( 'DB_FIELD_SIZE_REALNAME', 64);
define( 'DB_FIELD_SIZE_PASSWORD', 32);

# Maximum size for the user's password when storing it as a hash
define( 'PASSWORD_MAX_SIZE_BEFORE_HASH', 1024 );
Expand Down
4 changes: 2 additions & 2 deletions core/user_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ function user_ensure_realname_unique( $p_username, $p_realname ) {
# Return true if it is, false otherwise
function user_is_name_valid( $p_username ) {

# The DB field is hard-coded. USERLEN should not be modified.
if( utf8_strlen( $p_username ) > USERLEN ) {
# The DB field is hard-coded. DB_FIELD_SIZE_USERNAME should not be modified.
if( utf8_strlen( $p_username ) > DB_FIELD_SIZE_USERNAME ) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion login_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
</ul>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="username"><span><?php echo lang_get( 'username' ) ?></span></label>
<span class="input"><input id="username" type="text" name="username" size="32" maxlength="<?php echo USERLEN;?>" value="<?php echo string_attribute( $f_username ); ?>" class="<?php echo $t_username_field_autofocus ?>" /></span>
<span class="input"><input id="username" type="text" name="username" size="32" maxlength="<?php echo DB_FIELD_SIZE_USERNAME;?>" value="<?php echo string_attribute( $f_username ); ?>" class="<?php echo $t_username_field_autofocus ?>" /></span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
Expand Down
2 changes: 1 addition & 1 deletion lost_pwd_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
if ( $t_allow_passwd ) { ?>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="username"><span><?php echo lang_get( 'username' ) ?></span></label>
<span class="input"><input id="username" type="text" name="username" size="32" maxlength="<?php echo USERLEN;?>" class="autofocus" /></span>
<span class="input"><input id="username" type="text" name="username" size="32" maxlength="<?php echo DB_FIELD_SIZE_USERNAME;?>" class="autofocus" /></span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
Expand Down
4 changes: 2 additions & 2 deletions manage_user_create_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
<?php echo form_security_field( 'manage_user_create' ) ?>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="user-username"><span><?php echo lang_get( 'username' ) ?></span></label>
<span class="input"><input type="text" id="user-username" name="username" size="32" maxlength="<?php echo USERLEN;?>" /></span>
<span class="input"><input type="text" id="user-username" name="username" size="32" maxlength="<?php echo DB_FIELD_SIZE_USERNAME;?>" /></span>
<span class="label-style"></span>
</div><?php
if ( !$t_ldap || config_get( 'use_ldap_realname' ) == OFF ) { ?>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="user-realname"><span><?php echo lang_get( 'realname' ) ?></span></label>
<span class="input"><input type="text" id="user-realname" name="realname" size="32" maxlength="<?php echo REALLEN;?>" /></span>
<span class="input"><input type="text" id="user-realname" name="realname" size="32" maxlength="<?php echo DB_FIELD_SIZE_REALNAME;?>" /></span>
<span class="label-style"></span>
</div><?php
}
Expand Down
4 changes: 2 additions & 2 deletions manage_user_edit_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<!-- Username -->
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="edit-username"><span><?php echo lang_get( 'username_label' ) ?></span></label>
<span class="input"><input id="edit-username" type="text" size="32" maxlength="<?php echo USERLEN;?>" name="username" value="<?php echo string_attribute( $t_user['username'] ) ?>" /></span>
<span class="input"><input id="edit-username" type="text" size="32" maxlength="<?php echo DB_FIELD_SIZE_USERNAME;?>" name="username" value="<?php echo string_attribute( $t_user['username'] ) ?>" /></span>
<span class="label-style"></span>
</div>

Expand All @@ -112,7 +112,7 @@
} else {
# Without LDAP ?>
<label for="edit-realname"><span><?php echo lang_get( 'realname_label' ) ?></span></label>
<span class="input"><input id="edit-realname" type="text" size="32" maxlength="<?php echo REALLEN;?>" name="realname" value="<?php echo string_attribute( $t_user['realname'] ) ?>" /></span><?php
<span class="input"><input id="edit-realname" type="text" size="32" maxlength="<?php echo DB_FIELD_SIZE_REALNAME;?>" name="realname" value="<?php echo string_attribute( $t_user['realname'] ) ?>" /></span><?php
}
?>
<span class="label-style"></span>
Expand Down
2 changes: 1 addition & 1 deletion signup_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</ul>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="username"><span><?php echo lang_get( 'username' ) ?></span></label>
<span class="input"><input id="username" type="text" name="username" size="32" maxlength="<?php echo USERLEN;?>" class="autofocus" /></span>
<span class="input"><input id="username" type="text" name="username" size="32" maxlength="<?php echo DB_FIELD_SIZE_USERNAME;?>" class="autofocus" /></span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
Expand Down

0 comments on commit 0f9cf06

Please sign in to comment.