0

Hi I've already installed the CometChat, but I'm facing the following error:

Call to undefined function mcrypt_decrypt() in /home/vagrant/changeglobe/public/cometchat/integration.php on line 89

I'm using Homestead with Nginx for Laravel. I have read at many places that I need to enable mycrypt, but did not found any correct. Please let me know about this issue if you know. Thank you.

Siddharth
  • 1,649
  • 4
  • 22
  • 47
  • `php5-mcrypt` must be installed _and_ enabled. Check your `php.ini` file to make sure it is enabled (uncommented). – camelCase Apr 13 '16 at 18:29
  • It is best not to use mcrypt, it is abandonware, has not been updated in years and does not support standard PKCS#7 padding, only non-standard null padding that can't even be used with binary data. Instead consider using [defuse](https://github.com/defuse/php-encryption), it is being maintained and is correct. – zaph Apr 13 '16 at 20:01

1 Answers1

0

Try replacing the getUserID() function in /cometchat/integration.php file with the code below:

function getUserID() {
        $userid = 0;
        if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
            $_REQUEST['basedata'] = $_SESSION['basedata'];
        }

        if (!empty($_REQUEST['basedata'])) {
            if (function_exists('mcrypt_encrypt') && defined('ENCRYPT_USERID') && ENCRYPT_USERID == '1') {
                $key = "";
                if( defined('KEY_A') && defined('KEY_B') && defined('KEY_C') ){
                    $key = KEY_A.KEY_B.KEY_C;
                }
                $uid = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode(rawurldecode($_REQUEST['basedata'])), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
                if (intval($uid) > 0) {
                    $userid = $uid;
                }
            } else {
                $userid = $_REQUEST['basedata'];
            }
        }

        if (!empty($_COOKIE['laravel_session'])) {
            $session= cookie_decrypt($_COOKIE['laravel_session']);          
            $data = file_get_contents(dirname(dirname(dirname(__FILE__))).'/storage/framework/sessions/'.$session);
            if (!empty($data)) {
                $k = explode(';i:',$data);
                $m = explode(';s:',$k[1]);
                $userid = $m[0];
            }
        }
        $userid = intval($userid);
        return $userid;
    }

If you are still facing issues please create a support ticket https://my.cometchat.com/tickets and our team will assist you.

halfer
  • 19,824
  • 17
  • 99
  • 186
CometChat
  • 57
  • 3