- Code: Select all
// --- start of the user check
define( "_JEXEC", 1 );
define( "DS", "/" );
define("JPATH_BASE", "..");
require_once ( JPATH_BASE.DS."includes".DS."defines.php" );
require_once ( JPATH_BASE.DS."includes".DS."framework.php" );
$uc_maifra =& JFactory::getApplication("site");
$uc_maifra->initialise();
$uc_user = JFactory::getUser();
$uc_usenam = $uc_user->get("username");
print $uc_usenam;
// --- end of the user check
which I have in the test.php file and while I make a call from the Joomla menu item (type URL) it prints out the username without any problems. I can access all the user info via uc_user->get() command.
When I am trying to include this code to the pfc's index.php as follows,
- Code: Select all
<?php
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
$params = array();
$params["title"] = "MyDomain.NET";
$params["channels"] = array("Room");
//$params["nick"] = "guest".rand(1,1000); // setup the intitial nickname
// --- start of the user check
define( "_JEXEC", 1 );
define( "DS", "/" );
define("JPATH_BASE", "..");
require_once ( JPATH_BASE.DS."includes".DS."defines.php" );
require_once ( JPATH_BASE.DS."includes".DS."framework.php" );
$uc_maifra =& JFactory::getApplication("site");
$uc_maifra->initialise();
$uc_user = JFactory::getUser();
$uc_usenam = $uc_user->get("username");
$params["nick"] = $uc_usenam;
// --- end of the user check
$params['firstisadmin'] = false;
//$params["isadmin"] = true; // makes everybody admin: do not use it on production servers ;)
$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
$params["debug"] = false;
$params["shownotice"] = 0;
$params["max_msg"] = 1000;
$params["max_displayed_lines"] = 1000;
$params['admins'] = array('admin => 'huuhaahii');
$params["refresh_delay"] = 2000; // 2000ms = 2s
$params["refresh_delay_steps"] = array(3000,20000,4000,60000,5000,120000);
$params["theme"] = "phoenity";
$chat = new phpFreeChat( $params );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Chat</title>
<link rel="stylesheet" title="classic" type="text/css" href="style/content.css" />
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div class="content">
<?php $chat->printChat(); ?>
<?php if (isset($params["isadmin"]) && $params["isadmin"]) { ?>
<p style="color:red;font-weight:bold;">Warning: because of "isadmin" parameter, everybody is admin. Please modify this script before using it on production servers !</p>
<?php } ?>
</div>
</body></html>
I will receive the following error message:
Fatal error: Cannot redeclare utf8_substr() (previously declared in /home/me/public_html/phpchat/lib/utf8/utf8_substr.php:18) in /home/me/public_html/libraries/phputf8/mbstring/core.php on line 104
Can someone more experienced please check what goes wrong and how to fix it?
Or at least tell me what could be the problem and what kind of fix could do it?
If this could be done this would be very easy way to integrate the Joomla's user authentication with the pfc.
Or am I missing something and trying to do something impossible ?