Technology > SMF Forum Code Modifications

SA Chat

(1/2) > >>

Chip:
http://custom.simplemachines.org/mods/index.php?mod=2534

Please note that I am using the earlier version as I find it more reliable - there is a later version (REV120)  if you wish to try it but it requires changes to accomodate 2.0.16 and above.

EDIT: copy the sachat/cache directory to any backup system for it to work correctly or start afresh with an empty cache file.

NOTE: PrettyURLs (not desired or installed here) messes up .htaccess and stops SA Chat from working.

Chip:
Now available to all.

Chat logs are retained for a period of time and then purged.

You will be audited randomly so be smart and cautious.

Clearing/closing of persistent chat windows is by clearing cache/cookies (which will log you out of most sites)

Chip:
Not compatible with SMF 2.0.16 and 2.0.17.

Maybe we can patch it accordingly as per these observations

Chip:
Since the new version (REV120) is not as reliable as the old version for me so this is how to upgrade the old revision (SAChatBar-0.1.5 Rev110) to 2.0.16 -> 17 partially borrowed from SMF's Diego AndrĂ©s here   

Locate: ./sachat/index.php
--- Code: ---//SMF Cookie autentication!!!
list ($member_id, $password) = initCookies();
--- End code ---

Replace:
--- Code: ---//SMF Cookie autentication!!!
$member_id = initCookies();
--- End code ---

Locate:
--- Code: ---        // Lets validate the password, anyone can put a number in a cookie, lets see if the password checks out.
        if (isset($user_settings['passwd']) && strlen($password) != 40 || isset($user_settings['passwd']) && sha1($user_settings['passwd'] . $user_settings['password_salt']) != $password) {
                $context['JSON']['STATUS'] = 'AUTH FAILED';
                doOutput();
        } else {
                $context['JSON']['STATUS'] = 'ACTIVE';
        }

--- End code ---

Replace:
--- Code: ---        // No need to validate the password since 2.0.16
        $context['JSON']['STATUS'] = 'ACTIVE';
--- End code ---

Locate: ./sachat/functions.php
--- Code: ---function initCookies() {
global $cookiename;

if (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;(i:\d{1,6}|s:[1-8]:"\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~i', $_COOKIE[$cookiename]) == 1) {
list ($member_id, $password) = @unserialize($_COOKIE[$cookiename]);
$member_id = !empty($member_id) && strlen($password) > 0 ? (int) $member_id : 0;

return array($member_id, $password);
} elseif (isset($_COOKIE[$cookiename])) {
list ($member_id, $password) = @unserialize(stripslashes($_COOKIE[$cookiename]));
$member_id = !empty($member_id) && strlen($password) > 0 ? (int) $member_id : 0;

return array($member_id, $password);
}
}
--- End code ---

Replace:
--- Code: ---function initCookies() {
global $cookiename;

if (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;(i:\d{1,6}|s:[1-8]:"\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~i', $_COOKIE[$cookiename]) == 1) {
list ($id_member, $password) = @unserialize($_COOKIE[$cookiename]);
$id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0;

return $id_member;
} elseif (isset($_COOKIE[$cookiename])) {
list ($id_member, $password, $login_span) = @unserialize($_SESSION['login_' . $cookiename]);
$id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0;

return $id_member;
}
}
--- End code ---


Note: the first attachment contains the changes above

Chip:
Important PHP 7.2 and onwards bug fix:

in ./sachat/index.php:

find:

--- Code: ---        session_start();
        session_cache_limiter('nocache'); //Shouldent this be before session_start() http://php.net/manual/en/function.session-cache-limiter.php

--- End code ---

replace:

--- Code: ---        session_cache_limiter('nocache'); // goes before "session_start();" see php.net/manual/en/function.session-cache-limiter.php
        session_start();

--- End code ---


Trivial spyware removal: (see https://www.2-spyware.com/remove-s7-addthis-com.html)

in ./sachat/themes/default/js/body.js.php:

comment out this line so it looks like this:

--- Code: ---//                      $sachat.getScript(\'http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-503f263237ff99da\');
--- End code ---

Navigation

[0] Message Index

[#] Next page

It appears that you have not registered with dopetalk. To register, please click here...
Go to full version