dopetalk

Technology => SMF Forum Code Modifications => Topic started by: Chip on August 17, 2015, 05:34:17 PM

Title: SA Chat
Post by: Chip on August 17, 2015, 05:34:17 PM
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.
Title: Re: SA Chat
Post by: Chip on October 30, 2019, 03:36:31 AM
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)
Title: Re: SA Chat
Post by: Chip on February 11, 2020, 08:56:30 PM
Not compatible with SMF 2.0.16 and 2.0.17.

Maybe we can patch it accordingly as per these observations (https://www.simplemachines.org/community/index.php?topic=391961.msg4045817#msg4045817)
Title: Re: SA Chat
Post by: Chip on February 21, 2020, 10:24:45 AM
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 (https://www.simplemachines.org/community/index.php?topic=391961.msg4046455#msg4046455)   

Locate: ./sachat/index.php
Code: [Select]
//SMF Cookie autentication!!!
list ($member_id, $password) = initCookies();

Replace:
Code: [Select]
//SMF Cookie autentication!!!
$member_id = initCookies();

Locate:
Code: [Select]
        // 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';
        }

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

Locate: ./sachat/functions.php
Code: [Select]
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);
}
}

Replace:
Code: [Select]
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;
}
}



Note: the first attachment contains the changes above
Title: Re: SA Chat
Post by: Chip on May 16, 2021, 01:59:30 PM
Important PHP 7.2 and onwards bug fix:

in ./sachat/index.php:

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

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



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: [Select]
//                      $sachat.getScript(\'http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-503f263237ff99da\');
Title: Re: SA Chat
Post by: smfadmin on May 16, 2021, 11:58:07 PM
PHP 7.3 - Many warning messages in the SA Error Log ...

Code: [Select]
WARNING: count(): Parameter must be an array or an object that implements Countable
another fix for ./sachat/functions.php (by SMF helpers) for PHP 7.2 and above:

see https://www.simplemachines.org/community/index.php?topic=577720

locate:
Code: [Select]
return count(isset($context['friends']) ? $context['friends'] : null);
replace:
Code: [Select]
return count(isset($context['friends']) ? $context['friends'] : array());
Title: Re: SA Chat
Post by: Chip on May 31, 2021, 09:15:03 PM
Here are the latest mods with all the patches:

SAChatBar-1.0b.zip is the most recent version

SAChatBar-0.1.7.zip is the original version

Both work on SMF 2.0.18


Title: Re: SA Chat
Post by: Chip on June 26, 2021, 03:40:38 PM
MySQL 5.7 upgrade for the database errors reported at https://www.simplemachines.org/community/index.php?topic=391961.msg4089434#msg4089434

I did some research and found a workaround. It is failing on the INSERT so I had to change my.cnf for MySQL to add:

Code: [Select]
sql_mode=NO_ENGINE_SUBSTITUTION
5.7 is far more stricter than 5.6 and we are using a 0 date/time value for the table 2sichat: isrd column:

Code: [Select]
INSERT INTO smf209_2sichat(`to`, `from`, `msg`, `sent`, `isrd`)
                        VALUES
                                (2, 1, 'msgtext', '2021-06-26 17:26:07', 0)"

see https://www.percona.com/blog/2016/10/18/upgrading-to-mysql-5-7-beware-of-the-new-strict-mode/
Title: Re: SA Chat
Post by: Chip on July 13, 2021, 09:09:18 AM
Code: [Select]
mysql -u root -passwd -e "USE smf209; SELECT t1.sent, t1.from, t2.member_name, t1.to, t3.member_name, t1.msg FROM smf209_2sichat t1 INNER JOIN smf209_members t2 ON t1.from=t2.id_member INNER JOIN smf209_members t3 ON t1.to=t3.id_member\G;" > /tmp/chatlog

mailx -s "SA_Chat log" -r "SA_Chat" root < "/tmp/chatlog"

The output looks like this:

Code: [Select]
*************************** 10. row ***************************
       sent: 2021-06-23 05:12:07
       from: 2
member_name: Chipper
         to: 1260
member_name: hanna
        msg: welcome back !
*************************** 11. row ***************************
       sent: 2021-06-23 05:12:49
       from: 1260
member_name: hanna
         to: 2
member_name: Chipper
        msg: thx! been awhile my friend
*************************** 12. row ***************************
SimplePortal 2.3.6 © 2008-2014, SimplePortal