X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-nickname.php;h=bcda07e5be41281cef866149b85c223d2a13d6d9;hb=e6d0294f587cab6b74f689ecdf2ebb3cf2b09e25;hp=038010f0540e1a0dfecfc70d3fe92aa81db0f33f;hpb=d86f2ead64eed4ed981605b84cc0f00dc3bdaa31;p=mailer.git diff --git a/inc/modules/member/what-nickname.php b/inc/modules/member/what-nickname.php index 038010f054..bcda07e5be 100644 --- a/inc/modules/member/what-nickname.php +++ b/inc/modules/member/what-nickname.php @@ -10,9 +10,14 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Nickname anstelle der ID * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * - * Copyright (c) 2003 - 2008 by Roland Haeder * + * Copyright (c) 2003 - 2009 by Roland Haeder * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -33,61 +38,60 @@ // Some security stuff... if (!defined('__SECURITY')) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; - require($INC); -} elseif (!IS_MEMBER()) { - LOAD_URL("modules.php?module=index"); -} elseif (!EXT_IS_ACTIVE("nickname")) { - ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "nickname"); - return; + die(); +} elseif (!isMember()) { + redirectToIndexMemberOnlyModule(); } // Add description as navigation point -ADD_DESCR("member", __FILE__); -$VALID = false; +addMenuDescription('member', __FILE__); -if (isset($_POST['ok'])) { +if ((!isExtensionActive('nickname')) && (!isAdmin())) { + loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('nickname')); + return; +} // END - if + +$isValid = false; + +if (isFormSent()) { // Nickname was submitted so let's check if it is not already in use - if (!empty($_POST['nickname'])) { + if (isPostRequestElementSet('nickname')) { // Check if nickname is valid - $PATTERN = "[".__NICKNAME_PATTERN."]{".__NICKNAME_LENGTH.",}"; - if (ereg($PATTERN, $_POST['nickname'], $array)) { + $PATTERN = '[' . getConfig('nickname_pattern') . ']{' . getConfig('nickname_len') . ',}'; + if (ereg($PATTERN, postRequestElement('nickname'), $array)) { // Entered nickname is valid? - if ($array[0] == $_POST['nickname']) $VALID = true; + $isValid = ($array[0] == postRequestElement('nickname')); } // END - if } // END - if } // END - if -if ($VALID) { - // Look for nickname in database (we only need just one entry so don't worry about the "LIMIT 1" ! - $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE nickname='%s' AND userid != '%s' LIMIT 1", - array($_POST['nickname'], $GLOBALS['userid']), __FILE__, __LINE__); +if ($isValid === true) { + // Look for nickname in database (we only need just one entry so don't worry about the "LIMIT 1" !) + $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `nickname`='%s' AND `userid` != '%s' LIMIT 1", + array(postRequestElement('nickname'), getUserId()), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 0) { // Nickname not in use, so set it now - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET nickname='%s' WHERE userid=%s LIMIT 1", - array($_POST['nickname'], $GLOBALS['userid']), __FILE__, __LINE__); - $content = NICKNAME_SAVED; + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `nickname`='%s' WHERE `userid`=%s LIMIT 1", + array(postRequestElement('nickname'), getUserId()), __FILE__, __LINE__); + $content = getMessage('NICKNAME_SAVED'); } else { // Free result SQL_FREERESULT($result); // Nickname already in use! - $content = NICKNAME_ALREADY_IN_USE; + $content = getMessage('NICKNAME_ALREADY_IN_USE'); } // Load template - LOAD_TEMPLATE("admin_settings_saved", false, $content); + loadTemplate('admin_settings_saved', false, $content); } else { - // Load current nickname - define('__NICKNAME', NICKNAME_GET_NICK($GLOBALS['userid'])); - // Do we have already submit the form? - if (!empty($_POST['nickname'])) { - OUTPUT_HTML("".NICKNAME_IS_INVALID."
"); + if (isPostRequestElementSet('nickname')) { + loadTemplate('admin_settings_saved', false, "