Your IP : 216.73.216.85


Current Path : /home/smartconb/www/armencom33/administrator/components/com_eyesite/views/about/
Upload File :
Current File : /home/smartconb/www/armencom33/administrator/components/com_eyesite/views/about/view.html.php

<?php
/********************************************************************
Product     : Eyesite
Date		: 1 December 2023
Copyright	: Les Arbres Design 2009-2023
Contact	    : https://www.lesarbresdesign.info
Licence     : GNU General Public License
*********************************************************************/
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Http\HttpFactory;
use Joomla\CMS\Installer\Installer;

class EyesiteViewAbout extends HtmlView
{
function display($tpl = null)
{
	LAE_helper::addSubMenu('about');
	LAE_helper::viewStart();
	ToolBarHelper::title('Eyesite: '.Text::_('COM_EYESITE_ABOUT'), 'lad.png');
	ToolBarHelper::cancel('cancel_to_main','JTOOLBAR_CLOSE');

	echo '<form method="post" name="adminForm" id="adminForm" class="form-horizontal">';
	echo HTMLHelper::_('form.token');
	echo '<input type="hidden" name="option" value="com_eyesite">';
	echo '<input type="hidden" name="task" value="">';
	
// get the component version

	$xml_array = Installer::parseXMLInstallFile(JPATH_ADMINISTRATOR.'/components/com_eyesite/eyesite.xml');
	$component_version = $xml_array['version'];

// get the latest version info

    $this->latest_version = '';
    $this->transaction_status = '';
	$this->get_version('eyesite', '');
    
// build the help screen

	$about['name'] = 'Eyesite';
	$about['prefix'] = 'COM_EYESITE';
	$about['current_version'] = $component_version;
    $about['latest_version'] = $this->latest_version;
	$about['reference'] = 'eyesite';
	$about['link_version'] = "https://www.lesarbresdesign.info/version-history/eyesite";
	$about['link_doc'] = "https://www.lesarbresdesign.info/extensions/eyesite";
	$about['link_rating'] = "https://extensions.joomla.org/extension/access-a-security/site-security/eyesite/";

// add the plugin status, if it's installed

    $plugin_status = LAE_trace::getPluginStatus();
    $about['extra'][0]['left'] = Text::_('COM_EYESITE_PLUGIN_STATE');
    $about['extra'][0]['right'] = $plugin_status;
    if (!stristr($plugin_status,'not'))
        {
	    $this->latest_version = '';
        $this->get_version('plg_eyesite', $this->purchase_id);
        $about['extra'][1]['left'] = Text::_('COM_EYESITE_LATEST_PLUGIN');
        $about['extra'][1]['right'] = $this->latest_version;
        }

	$this->draw_about($about);
	echo '<p></p>';
	Form::addFieldPath(LAE_FORM_FIELD_PATH);
	$form = Form::getInstance('about_form', LAE_FORMS_PATH.'/about.xml');
    
// If the Eyesite Plugin update server is installed, show the Purchase ID field

	if ($this->purchase_id)		// if not false, the plugin update server is installed
        {
		ToolBarHelper::apply('save_about');
		if ($this->purchase_id === true)
			$this->purchase_id = '';
	    $form->bind($this);
		echo $form->renderField('purchase_id');  
		if (!empty($this->transaction_status))
			echo $this->transaction_status;
		}

	echo $form->renderField('buttons');		// trace controls
	echo '</form>';
	LAE_helper::viewEnd();
}

//------------------------------------------------------------------------------
// draw the about screen - this is the same in all our components
//
function draw_about($about)
{
	echo '<h3>'.$about['name'].': '.Text::_($about['prefix'].'_HELP_TITLE').'</h3>';

	if (!empty($this->lad_info_notice))
		echo $this->lad_info_notice;
	else
		{
		echo '<h4>'.Text::_($about['prefix'].'_HELP_RATING').' ';
		echo HTMLHelper::link($about['link_rating'], 'Joomla Extensions Directory', 'target="_blank"').'</h4>';
		}

	echo '<table class="table table-striped table-bordered width-auto">';
	
	echo '<tr><td>'.Text::_($about['prefix'].'_VERSION').'</td>';
	echo '<td>'.$about['current_version'].'</td></tr>';
	
	if ($about['latest_version'] != '')
		echo '<tr><td>'.Text::_($about['prefix'].'_LATEST_VERSION').'</td><td>'.$about['latest_version'].'</td></tr>';

	echo '<tr><td>'.Text::_($about['prefix'].'_HELP_CHECK').'</td>';
	echo '<td>'.HTMLHelper::link($about['link_version'], 'Les Arbres Design - '.$about['name'], 'target="_blank"').'</td></tr>';

	echo '<tr><td>'.Text::_($about['prefix'].'_HELP_DOC').'</td>';
	echo '<td>'.HTMLHelper::link($about['link_doc'], "www.lesarbresdesign.info", 'target="_blank"').'</td></tr>';

	echo '<tr><td>'.Text::_($about['prefix'].'_HELP_LES_ARBRES').'</td>';
	echo '<td>'.HTMLHelper::link("https://www.lesarbresdesign.info/", 'Les Arbres Design', 'target="_blank"').'</td></tr>';
		
	if (!empty($about['extra']))
		foreach($about['extra'] as $row)
			echo '<tr><td>'.$row['left'].'</td><td>'.$row['right'].'</td></tr>';

	echo '</table>';
}
	
//------------------------------------------------------------------------------
// get the latest version info
//
function get_version($product, $purchase_id)
{
	$version_file = JPATH_ROOT.'/administrator/components/com_eyesite/latest_'.$product.'.xml';
	$version_info = '';
	$filetime = 0;
	if (file_exists($version_file))
		$filetime = @filemtime($version_file);
	if ((time() - $filetime) < 3600)				// version info is valid for one hour
		$version_info = file_get_contents($version_file);
	else
		{
		$url = 'https://www.lesarbresdesign.info/jupdate?product='.$product.'&src=about';
		if (strlen($purchase_id) == 32)
			$url .= '&tid='.$purchase_id;
		try
			{
			$http = HttpFactory::getHttp();
			$response = $http->get($url, array(), 20);
			$version_info = $response->body;
			}
		catch (RuntimeException $e)
			{
			return;
			}
		}
	file_put_contents($version_file, $version_info);
    $this->latest_version = self::str_between($version_info,'<version>','</version>');
    $this->transaction_status = self::str_between($version_info,'<lad_transaction_status><![CDATA[',']]></lad_transaction_status>');
	if (empty($this->lad_info_notice))				// the second call for the plugin does not have the lad_info_notice
		$this->lad_info_notice = self::str_between($version_info, '<lad_info_notice><![CDATA[', ']]></lad_info_notice>');  
}
				
function str_between($string, $start, $end)
{
    $string = ' '.$string;
    $pos = strpos($string, $start);
    if ($pos == 0)
        return '';
    $pos += strlen($start);
    $len = strpos($string, $end, $pos) - $pos;
    return substr($string, $pos, $len);
}

}