mChat

Displaying mChat externally with integrated sessions - mChat

Displaying mChat externally with integrated sessions

by Rogerjwilkinson » Fri Jan 19, 2018 6:58 pm

Is there anyway, anyhow, somebody can please try and either dumb this down for me, or tell me if I'm at least barking up the right tree or something.

I have a webpage that uses integrated sessions with phpbb to do a few small tasks, like restrict access to certain pages, deliver news, provide a comments section etc... The website sits in webroot, and phpbb location is in /forum below it (so yoursite.com/forum). My next step, has been mChat. It's awesome. It works well. It's fast and responsive. But I can't for the life of me figure out how to get it show externally. Everything so far has led me to two different pieces of code trying achieve this, neither of them seem to work after hours of bending, but I ask for help with this one (seems most promising so far).

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../../../';  // This makes no difference, I was simply trying it in the ext/dmzx/mchat path for this scenario to see if that would do it
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path.'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management.
$user->session_begin();
$auth->acl($user->data);
$user->setup();


// BEGIN mChat Mod
$mchat_installed = (!empty($config['mchat_version']) && !empty($config['mchat_enable'])) ? true : false;
if ($mchat_installed && $auth->acl_get('u_mchat_view'))
{
   if(!defined('MCHAT_INCLUDE') && $config['mchat_on_index'] && !empty($user->data['user_mchat_index']))
   {
      define('MCHAT_INCLUDE', true);
      $mchat_include_index = true;
      include($phpbb_root_path . 'ext/dmzx/mchat/core/mchat.' . $phpEx);
   }   

   if (!empty($config['mchat_stats_index']) && !empty($user->data['user_mchat_stats_index']))
   {
      if (!function_exists('mchat_users'))
      {
         include($phpbb_root_path . 'ext/dmzx/mchat/core/functions.' . $phpEx);
      }
      // Add lang file
      $user->add_lang('ext/dmzx/mchat/language/en/mchat' . $phpEx);
      // stats display
      $mchat_session_time = !empty($config_mchat['timeout']) ? $config_mchat['timeout'] : 3600;// you can change this number to a greater number for longer chat sessions
      $mchat_stats = mchat_users($mchat_session_time);
      $template->assign_vars(array(
         'MCHAT_INDEX_STATS'   => true,
         'MCHAT_INDEX_USERS_COUNT'   => $mchat_stats['mchat_users_count'],
         'MCHAT_INDEX_USERS_LIST'   => $mchat_stats['online_userlist'],
         'L_MCHAT_ONLINE_EXPLAIN'   => $mchat_stats['refresh_message'],   
      ));
   }
}   
// END mChat Mod
// Output page
page_header($user->lang['MCHAT_TITLE']);

$template->set_filenames(array(
   'body' => 'mchat_body.html')
);

page_footer();
?>
Using it as is in a file anywhere called "mchat.php" (and updating the relevent phpbb rootpath wherever I put if of course), gives me the following errors

"
Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'Unable to find template "mchat_body2.html" (looked into: /var/www/html/forum/styles/prosilver/template, /var/www/html/forum/styles/prosilver/theme, /var/www/html/forum/styles/all/template)...."

I tried copying the template files from the ext/dmzx/mchat directory into that directory, and it LOOKED LIKE it worked, but all it did is give me a page with all the forms and ubttons, and no working chat. I tried setting "

'body' => 'mchat_body.html')"
to
"'body' => 'mchat_body2.html')"

with the following in mchat_body2.html

Code: Select all

<!-- INCLUDE overall_header.html -->

      <!-- INCLUDE mchat_body.html -->

<!-- INCLUDE overall_footer.html -->
to try and trick it into finding this, then pointing to mchat_body, but same problem. Is there anyway to force either this piece of code, or phpbb, to look for the files in the correct location and bypass this error (and, in a perfect world, put all the pieces of this puzzle together for me :D)?

ANY HELP whatsoever would be so very much appreciated on this matter, I've been driving myself crazy on it for days now.

Thank for your time!


Edit: By using

Code: Select all

$template->set_filenames(array(
   'body' => '@dmzx_mchat/mchat_body.html')
);
I'm able to access the extensions template path finally (!), but it's left me in the same boat - a page with a form box that does nothing, "MCHAT_OK" and "Cancel" buttons that do nothing, "MCHAT_NOMESSAGE, MCHAT_USESOUND" and a tick-box that does nothing, all white background. But it still feels like progress. Do I need to somehow incorporate this pull for the java libraries from the other piece of code I found into this one? hmmmm. Closer and closer ^_^

Code: Select all

 $html='<html><head><link href="'.$phpbb_root_path.'ext/dmzx/mchat/styles/prosilver/theme/mchat.css" rel="stylesheet" /></head><body>';
 $html.='<script type="text/javascript" src="'.$phpbb_root_path.'assets/javascript/editor.js"></script>';
 $html.='<script type="text/javascript" src="'.$phpbb_root_path.'assets/javascript/jquery.min.js"></script>';
 $html.='<script type="text/javascript" src="'.$phpbb_root_path.'styles/prosilver/template/ajax.js"></script>';
 $html.='<script type="text/javascript">
Rogerjwilkinson
Registered User
Posts: 33
Joined: Wed Jan 17, 2018 2:42 pm
Contact:

Re: Displaying mChat externally with integrated sessions

by Rogerjwilkinson » Sat Jan 20, 2018 4:55 am

Bump. Just copy and pasting the lines in didn't work (surprise surprise).

I'm making some head-way with the iFrame route at least. I was able to replace the header and footer on the /forum/app.php/mchat page with a blank header and footer, which made the iFrame load about 10x faster each page reload. So that's something at least! I'm trying to map through this "mchat_body.html" markup one-by-one and see what exactly I'm missing and see what I need to do to get a simple

<?php include = "/forum/mchatstandalone.php"?>

Or closest thing to it going instead. So far, no luck. But the iFrame is looking mint! :lol:
Rogerjwilkinson
Registered User
Posts: 33
Joined: Wed Jan 17, 2018 2:42 pm
Contact:

Re: Displaying mChat externally with integrated sessions

by kasimi » Sat Jan 20, 2018 8:44 am

Your code is for the mChat MOD. This is the mChat extension. See here for a walkthrough with some code snippets: https://kasimi.net/viewtopic.php?p=322#p322
User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2760
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Displaying mChat externally with integrated sessions

by Rogerjwilkinson » Sun Jan 21, 2018 5:33 am

kasimi wrote:Your code is for the mChat MOD. This is the mChat extension. See here for a walkthrough with some code snippets: https://kasimi.net/viewtopic.php?p=322#p322
Both your reasoning of this being an extension and NOT a mod (are extensions NOT mods for phpbb or something?) and your page with a "walkthrough", have served to do nothing but confuse me further :\

Thanks for your time though bud.
Rogerjwilkinson
Registered User
Posts: 33
Joined: Wed Jan 17, 2018 2:42 pm
Contact:

Re: Displaying mChat externally with integrated sessions

by kasimi » Wed Jan 24, 2018 11:17 am

MODs are for phpBB 3.0. Basically, they are instructions for manual file edits. A MOD will most probably not work for phpBB 3.1 or later, as there have been substantial changes to the phpBB core code. In rare cases you might get lucky though. mChat is not one of those cases.

Extensions are for phpBB 3.1 and later. They do not work on phpBB 3.0.

If you have a specific problem with a piece of code, I can try to help you.
User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2760
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact: