Your IP : 10.10.0.253


Current Path : /var/www/plugins/system/pushalertjoomla/
Upload File :
Current File : /var/www/plugins/system/pushalertjoomla/pushalertjoomla.php

<?php
/**
 * @package Plugin PushAlert - Web Push Notifications for Joomla! 1.6 and above
 * @version 1.0.5
 * @author Abhinav Pathak
 * @email contactus@pushalert.co
 * @website https://pushalert.co
 * @copyright (C) 2022 - PushAlert.co
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/

// no direct access
defined( '_JEXEC' ) or die( 'Unauthorized Access' );
jimport( 'joomla.plugin.plugin');
jimport('joomla.version');

class plgSystempushalertjoomla extends JPlugin
{
	function onAfterRender()
		{
		$currApp = JFactory::getApplication();
		
		
		if(strpos($_SERVER["PHP_SELF"], "index.php") === false){
			return;
		}
		
		if ( (JVERSION != NULL) && round(floatval(JVERSION)) >= 4){
			if ($currApp->isClient('administrator')){
				return;
			}
		}else{
			if ($currApp->isAdmin()){
				return;
			}
		}

		$pushalert_web_id = $this->params->get('pushalert_web_id', ''); 

		if($pushalert_web_id == '')
		{
			return;
		}

		$javascript ='
		<!-- PushAlert for Joomla 1.0.5 -->
		<script type="text/javascript">
			(function(d, t) {
				var g = d.createElement(t),
				s = d.getElementsByTagName(t)[0];
				g.src = "https://cdn.pushalert.co/integrate_'.$pushalert_web_id.'.js";
				s.parentNode.insertBefore(g, s);
			}(document, "script"));
		</script>
		<!-- End PushAlert for Joomla 1.0.5 -->
		';
		
		
		if((JVERSION != NULL) && round(floatval(JVERSION)) < 4){
			if (floatval(JVERSION) <=3.1) {
				$currDoc = JResponse::getBody();
				$currDoc = preg_replace ("/<\/head>/", "\n\n".$javascript."\n\n</head>", $currDoc);
				JResponse::setBody($currDoc);
				return true;
			}else{
				$currDoc = JFactory::getApplication()->getBody();
				$currDoc = preg_replace ("/<\/head>/", "\n\n".$javascript."\n\n</head>", $currDoc);
				JFactory::getApplication()->setBody($currDoc);
				return true;
			}
		}else if ((JVERSION != NULL) && round(floatval(JVERSION)) >= 4){
			$currDoc = JFactory::getApplication()->getBody();
			$currDoc = preg_replace ("/<\/head>/", "\n\n".$javascript."\n\n</head>", $currDoc);
			JFactory::getApplication()->setBody($currDoc);
			return true;
		}
	}
}
?>