Started with the first adaptation to implement the ssh protocol as mentioned in gh-230

This commit is contained in:
2018-02-15 02:42:39 +02:00
parent c78ef21678
commit 0c798d9579
59 changed files with 2231 additions and 935 deletions

View File

@ -13,7 +13,7 @@
@version 2.6.x
@created 30th April, 2015
@package Component Builder
@subpackage ftp.php
@subpackage server.php
@author Llewellyn van der Merwe <http://joomlacomponentbuilder.com>
@github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
@copyright Copyright (C) 2015. All Rights Reserved
@ -30,9 +30,9 @@ defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controllerform');
/**
* Ftp Controller
* Server Controller
*/
class ComponentbuilderControllerFtp extends JControllerForm
class ComponentbuilderControllerServer extends JControllerForm
{
/**
* Current or most recently performed task.
@ -45,7 +45,7 @@ class ComponentbuilderControllerFtp extends JControllerForm
public function __construct($config = array())
{
$this->view_list = 'Ftps'; // safeguard for setting the return view listing to the main view.
$this->view_list = 'Servers'; // safeguard for setting the return view listing to the main view.
parent::__construct($config);
}
@ -61,13 +61,13 @@ class ComponentbuilderControllerFtp extends JControllerForm
protected function allowAdd($data = array())
{
// Access check.
$access = JFactory::getUser()->authorise('ftp.access', 'com_componentbuilder');
$access = JFactory::getUser()->authorise('server.access', 'com_componentbuilder');
if (!$access)
{
return false;
}
// In the absense of better information, revert to the component permissions.
return JFactory::getUser()->authorise('ftp.create', $this->option);
return JFactory::getUser()->authorise('server.create', $this->option);
}
/**
@ -89,7 +89,7 @@ class ComponentbuilderControllerFtp extends JControllerForm
// Access check.
$access = ($user->authorise('ftp.access', 'com_componentbuilder.ftp.' . (int) $recordId) && $user->authorise('ftp.access', 'com_componentbuilder'));
$access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $recordId) && $user->authorise('server.access', 'com_componentbuilder'));
if (!$access)
{
return false;
@ -98,10 +98,10 @@ class ComponentbuilderControllerFtp extends JControllerForm
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('ftp.edit', 'com_componentbuilder.ftp.' . (int) $recordId);
$permission = $user->authorise('server.edit', 'com_componentbuilder.server.' . (int) $recordId);
if (!$permission)
{
if ($user->authorise('ftp.edit.own', 'com_componentbuilder.ftp.' . $recordId))
if ($user->authorise('server.edit.own', 'com_componentbuilder.server.' . $recordId))
{
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
@ -120,7 +120,7 @@ class ComponentbuilderControllerFtp extends JControllerForm
// If the owner matches 'me' then allow.
if ($ownerId == $user->id)
{
if ($user->authorise('ftp.edit.own', 'com_componentbuilder'))
if ($user->authorise('server.edit.own', 'com_componentbuilder'))
{
return true;
}
@ -130,7 +130,7 @@ class ComponentbuilderControllerFtp extends JControllerForm
}
}
// Since there is no permission, revert to the component permissions.
return $user->authorise('ftp.edit', $this->option);
return $user->authorise('server.edit', $this->option);
}
/**
@ -196,10 +196,10 @@ class ComponentbuilderControllerFtp extends JControllerForm
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Ftp', '', array());
$model = $this->getModel('Server', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=ftps' . $this->getRedirectToListAppend(), false));
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=servers' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}

View File

@ -13,7 +13,7 @@
@version 2.6.x
@created 30th April, 2015
@package Component Builder
@subpackage ftps.php
@subpackage servers.php
@author Llewellyn van der Merwe <http://joomlacomponentbuilder.com>
@github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
@copyright Copyright (C) 2015. All Rights Reserved
@ -30,16 +30,16 @@ defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controlleradmin');
/**
* Ftps Controller
* Servers Controller
*/
class ComponentbuilderControllerFtps extends JControllerAdmin
class ComponentbuilderControllerServers extends JControllerAdmin
{
protected $text_prefix = 'COM_COMPONENTBUILDER_FTPS';
protected $text_prefix = 'COM_COMPONENTBUILDER_SERVERS';
/**
* Proxy for getModel.
* @since 2.5
*/
public function getModel($name = 'Ftp', $prefix = 'ComponentbuilderModel', $config = array())
public function getModel($name = 'Server', $prefix = 'ComponentbuilderModel', $config = array())
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
@ -52,7 +52,7 @@ class ComponentbuilderControllerFtps extends JControllerAdmin
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// check if export is allowed for this user.
$user = JFactory::getUser();
if ($user->authorise('ftp.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder'))
if ($user->authorise('server.export', 'com_componentbuilder') && $user->authorise('core.export', 'com_componentbuilder'))
{
// Get the input
$input = JFactory::getApplication()->input;
@ -60,19 +60,19 @@ class ComponentbuilderControllerFtps extends JControllerAdmin
// Sanitize the input
JArrayHelper::toInteger($pks);
// Get the model
$model = $this->getModel('Ftps');
$model = $this->getModel('Servers');
// get the data to export
$data = $model->getExportData($pks);
if (ComponentbuilderHelper::checkArray($data))
{
// now set the data to the spreadsheet
$date = JFactory::getDate();
ComponentbuilderHelper::xls($data,'Ftps_'.$date->format('jS_F_Y'),'Ftps exported ('.$date->format('jS F, Y').')','ftps');
ComponentbuilderHelper::xls($data,'Servers_'.$date->format('jS_F_Y'),'Servers exported ('.$date->format('jS F, Y').')','servers');
}
}
// Redirect to the list screen with error.
$message = JText::_('COM_COMPONENTBUILDER_EXPORT_FAILED');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=ftps', false), $message, 'error');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=servers', false), $message, 'error');
return;
}
@ -83,10 +83,10 @@ class ComponentbuilderControllerFtps extends JControllerAdmin
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
// check if import is allowed for this user.
$user = JFactory::getUser();
if ($user->authorise('ftp.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder'))
if ($user->authorise('server.import', 'com_componentbuilder') && $user->authorise('core.import', 'com_componentbuilder'))
{
// Get the import model
$model = $this->getModel('Ftps');
$model = $this->getModel('Servers');
// get the headers to import
$headers = $model->getExImPortHeaders();
if (ComponentbuilderHelper::checkObject($headers))
@ -94,18 +94,18 @@ class ComponentbuilderControllerFtps extends JControllerAdmin
// Load headers to session.
$session = JFactory::getSession();
$headers = json_encode($headers);
$session->set('ftp_VDM_IMPORTHEADERS', $headers);
$session->set('backto_VDM_IMPORT', 'ftps');
$session->set('dataType_VDM_IMPORTINTO', 'ftp');
$session->set('server_VDM_IMPORTHEADERS', $headers);
$session->set('backto_VDM_IMPORT', 'servers');
$session->set('dataType_VDM_IMPORTINTO', 'server');
// Redirect to import view.
$message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_FTPS');
$message = JText::_('COM_COMPONENTBUILDER_IMPORT_SELECT_FILE_FOR_SERVERS');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=import', false), $message);
return;
}
}
// Redirect to the list screen with error.
$message = JText::_('COM_COMPONENTBUILDER_IMPORT_FAILED');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=ftps', false), $message, 'error');
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=servers', false), $message, 'error');
return;
}
}