summaryrefslogtreecommitdiff
path: root/src/chat/sman.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/chat/sman.cpp')
-rwxr-xr-xsrc/chat/sman.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/chat/sman.cpp b/src/chat/sman.cpp
index d80d421..530aa17 100755
--- a/src/chat/sman.cpp
+++ b/src/chat/sman.cpp
@@ -21,23 +21,33 @@ sman::~sman()
string sman::generate_id( int i_len )
{
- string valid_chars = wrap::CONF->get_elem("chat.session.validchars");
+ string s_valid = wrap::CONF->get_elem("chat.session.validchars");
string s_ret = "";
srand(time(0)+tool::string2int(wrap::CONF->get_elem("chat.session.kloakkey")));
int i_char;
+
for (int i = 0; i < i_len; i++)
{
- i_char = rand() % 64;
- s_ret += valid_chars[i_char];
+ i_char = rand() % s_valid.length();
+ s_ret += s_valid[i_char];
}
if ( wrap::CONF->get_elem("chat.session.md5hash") == "true" )
{
string s_salt = wrap::CONF->get_elem("chat.session.md5salt");
- s_ret = string(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str()));
- return s_ret.substr(s_ret.find(s_salt) + s_salt.length() + 3);
+ string s_hash(md5::MD5Crypt(s_ret.c_str(), s_salt.c_str()));
+ s_ret.append(s_hash.substr(s_ret.find(s_salt) + s_salt.length() + 3));
+ }
+
+ // Prove, if the TempID already exists
+ sess* p_sess = get_elem(s_ret);
+
+ if (p_sess)
+ {
+ wrap::system_message(SESSEXI);
+ return generate_id(i_len);
}
return s_ret;