%PDF- %PDF-
| Direktori : /home1/lightco1/public_html/plugins/system/chatnox/ |
| Current File : //home1/lightco1/public_html/plugins/system/chatnox/chatnox.php |
<?php
/**
* @version $Id: Chatnox.php
* @copyright Copyright (C) 2010-2014 Chatnox. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin');
class plgSystemchatnox extends JPlugin
{
function plgchatnox(&$subject, $config)
{
parent::__construct($subject, $config);
$this->_plugin = JPluginHelper::getPlugin( 'system', 'chatnox' );
$this->_params = new JParameter( $this->_plugin->params );
}
function onAfterRender()
{
$app = JFactory::getApplication();
// Skip if admin page
if($app->isAdmin())
{
return;
}
// Get params
$sql = "select * from #__chatnox limit 1";
$db =& JFactory::getDBO();
$db->setQuery($sql );
$groupid = "";
if($result = $db->query())
{
$rows = $db->getNumRows();
if($rows != 0)
{
$chatnox_data = $db->loadAssocList();
$groupid = $chatnox_data[0]["group_id"];
}
}
//Getting body code and storing as buffer
$buffer = JResponse::getBody();
//Embed Click Desk Code
$javascript = "<script type='text/javascript'>
var _chatnox = _chatnox || [];_chatnox.setAccount = '".$groupid."';
var cnox = document.createElement('script');cnox.type = 'text/javascript';cnox.async = true;
cnox.src = ('https:' == document.location.protocol ? 'https://chatnoxapp.appspot.com' : 'http://app.chatnox.com') + '/site/chat.js';
var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(cnox, s);
</script>";
$buffer = preg_replace ("/<\/head>/", "\n\n".$javascript."\n\n</head>", $buffer);
//Output the buffer
JResponse::setBody($buffer);
return true;
}
}
?>