Beispiel #1
0
 /**
  * Method to display a view.
  *
  * @param   boolean  $cachable   If true, the view output will be cached
  * @param   array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return  JController  This object to support chaining.
  *
  * @since   1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php';
     // Get the document object.
     $document = JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = $this->input->get('view', 'install');
     $vFormat = $document->getType();
     $lName = $this->input->get('layout', 'default', 'string');
     // Get and render the view.
     if ($view = $this->getView($vName, $vFormat)) {
         $ftp = JClientHelper::setCredentialsFromRequest('ftp');
         $view->ftp =& $ftp;
         // Get the model for the view.
         $model = $this->getModel($vName);
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->document = $document;
         // Load the submenu.
         InstallerHelper::addSubmenu($vName);
         $view->display();
     }
     return $this;
 }
Beispiel #2
0
 function themeinstall()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $post = JRequest::get('post');
     $theme = array();
     if (isset($post['theme_component'])) {
         $theme['component'] = 1;
     }
     if (isset($post['theme_categories'])) {
         $theme['categories'] = 1;
     }
     if (isset($post['theme_category'])) {
         $theme['category'] = 1;
     }
     if (!empty($theme)) {
         $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
         $model =& $this->getModel('phocagalleryt');
         if ($model->install($theme)) {
             $cache =& JFactory::getCache('mod_menu');
             $cache->clean();
             $msg = JText::_('New Theme Installed');
         }
     } else {
         $msg = JText::_('Select Application Area');
     }
     $this->setRedirect('index.php?option=com_phocagallery&view=phocagalleryt', $msg);
 }
Beispiel #3
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	1.5
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/installer.php';
     // Get the document object.
     $document = JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = JRequest::getCmd('view', 'install');
     $vFormat = $document->getType();
     $lName = JRequest::getCmd('layout', 'default');
     // Get and render the view.
     if ($view = $this->getView($vName, $vFormat)) {
         $ftp = JClientHelper::setCredentialsFromRequest('ftp');
         $view->assignRef('ftp', $ftp);
         // Get the model for the view.
         $model = $this->getModel($vName);
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->assignRef('document', $document);
         // Load the submenu.
         InstallerHelper::addSubmenu($vName);
         $view->display();
     }
     return $this;
 }
Beispiel #4
0
 /**
  * Method to display the view.
  */
 public function display($tpl = null)
 {
     $form = $this->get('Form');
     $data = $this->get('Data');
     // Check for model errors.
     if ($errors = $this->get('Errors')) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     // Bind the form to the data.
     if ($form && $data) {
         $form->bind($data);
     }
     // Get the params for com_users.
     $usersParams = JComponentHelper::getParams('com_users');
     // Get the params for com_media.
     $mediaParams = JComponentHelper::getParams('com_media');
     // Load settings for the FTP layer.
     jimport('joomla.client.helper');
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->assignRef('form', $form);
     $this->assignRef('data', $data);
     $this->assignRef('ftp', $ftp);
     $this->assignRef('usersParams', $usersParams);
     $this->assignRef('mediaParams', $mediaParams);
     $this->addToolbar();
     parent::display($tpl);
 }
Beispiel #5
0
 /**
  * Upload a file
  * @param	string	$source			File to upload
  * @param	string	$destination	Upload to here
  * @return True on success
  */
 public static function upload($source, $destination)
 {
     $err = null;
     $ret = false;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Load configurations.
     $config = CFactory::getConfig();
     // Make the filename safe
     jimport('joomla.filesystem.file');
     if (!isset($source['name'])) {
         JError::raiseNotice(100, JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST'));
         return $ret;
     }
     $source['name'] = JFile::makeSafe($source['name']);
     if (is_dir($destination)) {
         jimport('joomla.filesystem.folder');
         JFolder::create($destination, (int) octdec($config->get('folderpermissionsvideo')));
         JFile::copy(JPATH_ROOT . '/components/com_community/index.html', $destination . '/index.html');
         $destination = JPath::clean($destination . '/' . strtolower($source['name']));
     }
     if (JFile::exists($destination)) {
         JError::raiseNotice(100, JText::_('COM_COMMUNITY_FILE_EXISTS'));
         return $ret;
     }
     if (!JFile::upload($source['tmp_name'], $destination)) {
         JError::raiseWarning(100, JText::_('COM_COMMUNITY_UNABLE_TO_UPLOAD_FILE'));
         return $ret;
     } else {
         $ret = true;
         return $ret;
     }
 }
Beispiel #6
0
 /**
  * Display a list of uninstalled extensions
  *
  * @return  void
  */
 public function displayTask()
 {
     $model = new Models\Manage();
     $this->view->state = $model->getState();
     $this->view->items = $model->getItems();
     $this->view->pagination = $model->getPagination();
     $this->view->form = $model->getForm();
     // Check for errors.
     if (count($errors = $model->getErrors())) {
         App::abort(500, implode("\n", $errors));
     }
     //Check if there are no matching items
     if (!count($this->view->items)) {
         Notify::warning(Lang::txt('COM_INSTALLER_MSG_MANAGE_NOEXTENSION'));
     }
     $this->view->ftp = \JClientHelper::setCredentialsFromRequest('ftp');
     $showMessage = false;
     if (is_object($this->view->state)) {
         $message1 = $this->view->state->get('message');
         $message2 = $this->view->state->get('extension_message');
         $showMessage = $message1 || $message2;
     }
     $this->view->showMessage = $showMessage;
     // Include the component HTML helpers.
     Html::addIncludePath(dirname(__DIR__) . '/helpers/html');
     $this->view->display();
 }
Beispiel #7
0
 public function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('Template Manager'), 'thememanager');
     JToolBarHelper::custom('edit', 'back.png', 'back_f2.png', 'Back', false, false);
     require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'templates.php';
     // Initialise some variables
     $option = JRequest::getCmd('option');
     $id = JRequest::getVar('id', '', 'method', 'int');
     $template = TemplatesHelper::getTemplateName($id);
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     $tp = true;
     $url = $client->id ? JURI::base() : JURI::root();
     if (!$template) {
         return JError::raiseWarning(500, JText::_('Template not specified'));
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $this->assignRef('option', $option);
     $this->assignRef('client', $client);
     $this->assignRef('id', $id);
     $this->assignRef('template', $template);
     $this->assignRef('tp', $tp);
     $this->assignRef('url', $url);
     parent::display($tpl);
 }
Beispiel #8
0
 /**
  * Method to delete the images
  *
  * @access	public
  * @return int
  */
 public function delete($type)
 {
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Get some data from the request
     $images = $this->getImages($type);
     $folder = $this->map[$type]['folder'];
     $count = count($images);
     $fail = 0;
     if ($count) {
         foreach ($images as $image) {
             if ($image !== JFilterInput::getInstance()->clean($image, 'path')) {
                 JError::raiseWarning(100, JText::_('COM_JEM_HOUSEKEEPING_UNABLE_TO_DELETE') . ' ' . htmlspecialchars($image, ENT_COMPAT, 'UTF-8'));
                 $fail++;
                 continue;
             }
             $fullPath = JPath::clean(JPATH_SITE . '/images/jem/' . $folder . '/' . $image);
             $fullPaththumb = JPath::clean(JPATH_SITE . '/images/jem/' . $folder . '/small/' . $image);
             if (is_file($fullPath)) {
                 JFile::delete($fullPath);
                 if (JFile::exists($fullPaththumb)) {
                     JFile::delete($fullPaththumb);
                 }
             }
         }
     }
     $deleted = $count - $fail;
     return $deleted;
 }
Beispiel #9
0
 /**
  * Display a list of uninstalled extensions
  *
  * @return  void
  */
 public function displayTask()
 {
     $model = new Models\Database();
     // Get data from the model
     $this->view->state = $model->getState();
     $this->view->changeSet = $model->getItems();
     $this->view->errors = $this->view->changeSet->check();
     $this->view->results = $this->view->changeSet->getStatus();
     $this->view->schemaVersion = $this->getSchemaVersion();
     $this->view->updateVersion = $this->getUpdateVersion();
     $this->view->filterParams = $this->getDefaultTextFilters();
     $this->view->schemaVersion = $this->view->schemaVersion ? $this->view->schemaVersion : Lang::txt('JNONE');
     $this->view->updateVersion = $this->view->updateVersion ? $this->view->updateVersion : Lang::txt('JNONE');
     $this->view->pagination = $model->getPagination();
     $this->view->errorCount = count($this->errors);
     $errors = count($this->view->errors);
     if ($this->view->schemaVersion != $this->view->changeSet->getSchema()) {
         $this->view->errorCount++;
     }
     if (!$this->view->filterParams) {
         $this->view->errorCount++;
     }
     if (version_compare($this->view->updateVersion, JVERSION) != 0) {
         $this->view->errorCount++;
     }
     $this->view->ftp = \JClientHelper::setCredentialsFromRequest('ftp');
     $showMessage = false;
     if (is_object($this->view->state)) {
         $message1 = $this->view->state->get('message');
         $message2 = $this->view->state->get('extension_message');
         $showMessage = $message1 || $message2;
     }
     $this->view->showMessage = $showMessage;
     $this->view->display();
 }
Beispiel #10
0
 /**
  * Method to display the view.
  *
  * @return  string  The rendered view.
  *
  * @since   3.2
  */
 public function render()
 {
     $form = null;
     $data = null;
     try {
         // Load Form and Data
         $form = $this->model->getForm();
         $data = $this->model->getData();
         $user = JFactory::getUser();
     } catch (Exception $e) {
         JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
         return false;
     }
     // Bind data
     if ($form && $data) {
         $form->bind($data);
     }
     // Get the params for com_users.
     $usersParams = JComponentHelper::getParams('com_users');
     // Get the params for com_media.
     $mediaParams = JComponentHelper::getParams('com_media');
     // Load settings for the FTP layer.
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->form =& $form;
     $this->data =& $data;
     $this->ftp =& $ftp;
     $this->usersParams =& $usersParams;
     $this->mediaParams =& $mediaParams;
     $this->components = ConfigHelperConfig::getComponentsWithConfig();
     ConfigHelperConfig::loadLanguageForComponents($this->components);
     $this->userIsSuperAdmin = $user->authorise('core.admin');
     $this->addToolbar();
     return parent::render();
 }
Beispiel #11
0
 /**
  * create
  *
  * Creates and then Installs a Molajo Extension as per user instructions
  *
  * Note: was not able to use the create controller - the form submit of create.create did not find the folder/file
  * Change the task to create and added the create method to the display controller
  * JLoader::register('InstallerControllerCreate', MOLAJO_LIBRARY_COM_JFOOBARER.'/controllers/create.php');
  * require_once MOLAJO_LIBRARY_COM_JFOOBARER.'/controllers/create.php';
  *
  * @return	boolean result of install
  */
 function create()
 {
     /** set ftp credentials, if used **/
     JClientHelper::setCredentialsFromRequest('ftp');
     /** component */
     if ($this->getState('create.createtype') == 'component') {
         return $this->_createComponent();
     } else {
         if ($this->getState('create.createtype') == 'module') {
             return $this->_createModule();
         } else {
             if ($this->getState('create.createtype') == 'plugin') {
                 return $this->_createPlugin();
             } else {
                 if ($this->getState('create.createtype') == 'layout') {
                     return $this->_createLayout();
                 } else {
                     if ($this->getState('create.createtype') == 'template') {
                         return $this->_createTemplate();
                     } else {
                         JFactory::getApplication()->enqueueMessage(JText::_('PLG_SYSTEM_CREATE_INVALID_EXTENSION_TYPE_FAILED') . ': ' . $this->getState('create.createtype'), 'error');
                         return false;
                     }
                 }
             }
         }
     }
 }
Beispiel #12
0
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JController		This object to support chaining.
  * @since	2.5.4
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Get the document object.
     $document = JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = JRequest::getCmd('view', 'default');
     $vFormat = $document->getType();
     $lName = JRequest::getCmd('layout', 'default');
     // Get and render the view.
     if ($view = $this->getView($vName, $vFormat)) {
         $ftp = JClientHelper::setCredentialsFromRequest('ftp');
         $view->assignRef('ftp', $ftp);
         // Get the model for the view.
         $model = $this->getModel($vName);
         // Perform update source preference check and refresh update information
         $model->applyUpdateSite();
         $model->refreshUpdates();
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->assignRef('document', $document);
         $view->display();
     }
     return $this;
 }
Beispiel #13
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     JHTML::stylesheet('media/com_phocagallery/css/administrator/phocagallery.css');
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $this->ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->tmpl = new StdClass();
     $model = $this->getModel();
     // Set CSS for codemirror
     JFactory::getApplication()->setUserState('editor.source.syntax', 'css');
     // New or edit
     if (!$this->form->getValue('id') || $this->form->getValue('id') == 0) {
         $this->form->setValue('source', null, '');
         $this->form->setValue('type', null, 2);
         $this->tmpl->suffixtype = JText::_('COM_PHOCAGALERY_WILL_BE_CREATED_FROM_TITLE');
     } else {
         $this->source = $model->getSource($this->form->getValue('id'), $this->form->getValue('filename'), $this->form->getValue('type'));
         $this->form->setValue('source', null, $this->source->source);
         $this->tmpl->suffixtype = '';
     }
     // Only help input form field - to display Main instead of 1 and Custom instead of 2
     if ($this->form->getValue('type') == 1) {
         $this->form->setValue('typeoutput', null, JText::_('COM_PHOCAGALLERY_MAIN_CSS'));
     } else {
         $this->form->setValue('typeoutput', null, JText::_('COM_PHOCAGALLERY_CUSTOM_CSS'));
     }
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     parent::display($tpl);
 }
Beispiel #14
0
 /**
  * Method to display the view.
  */
 public function display($tpl = null)
 {
     $form = $this->get('Form');
     $data = $this->get('Data');
     $user = JFactory::getUser();
     // Check for model errors.
     if ($errors = $this->get('Errors')) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     // Bind the form to the data.
     if ($form && $data) {
         $form->bind($data);
     }
     // Get the params for com_users.
     $usersParams = JComponentHelper::getParams('com_users');
     // Get the params for com_media.
     $mediaParams = JComponentHelper::getParams('com_media');
     // Load settings for the FTP layer.
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->form =& $form;
     $this->data =& $data;
     $this->ftp =& $ftp;
     $this->usersParams =& $usersParams;
     $this->mediaParams =& $mediaParams;
     $this->components = ConfigHelperComponent::getComponentsWithConfig();
     ConfigHelperComponent::loadLanguageForComponents($this->components);
     $this->userIsSuperAdmin = $user->authorise('core.admin');
     $this->addToolbar();
     parent::display($tpl);
 }
 /**
  * Method to display a view.
  *
  * @param   boolean  $cachable   If true, the view output will be cached.
  * @param   array    $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return  JController  This object to support chaining.
  *
  * @since   2.5.4
  */
 public function display($cachable = false, $urlparams = false)
 {
     // Get the document object.
     $document = JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = $this->input->get('view', 'default');
     $vFormat = $document->getType();
     $lName = $this->input->get('layout', 'default', 'string');
     // Get and render the view.
     if ($view = $this->getView($vName, $vFormat)) {
         $ftp = JClientHelper::setCredentialsFromRequest('ftp');
         $view->ftp =& $ftp;
         // Get the model for the view.
         /** @var JoomlaupdateModelDefault $model */
         $model = $this->getModel('default');
         // Push the Installer Warnings model into the view, if we can load it
         static::addModelPath(JPATH_ADMINISTRATOR . '/components/com_installer/models', 'InstallerModel');
         $warningsModel = $this->getModel('warnings', 'InstallerModel');
         if (is_object($warningsModel)) {
             $view->setModel($warningsModel, false);
         }
         // Perform update source preference check and refresh update information.
         $model->applyUpdateSite();
         $model->refreshUpdates();
         // Push the model into the view (as default).
         $view->setModel($model, true);
         $view->setLayout($lName);
         // Push document object into the view.
         $view->document = $document;
         $view->display();
     }
     return $this;
 }
Beispiel #16
0
 /**
  * TuiyoParameter::saveParams()
  * 
  * @param mixed $postParams
  * @param mixed $key
  * @param string $type
  * @return
  */
 public function saveParams($postParams, $key, $type = "system")
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.client.helper');
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = TUIYO_CONFIG . DS . strtolower($key) . ".ini";
     if (JFile::exists($file)) {
         JFile::write($file);
     }
     if (count($postParams)) {
         $registry = new JRegistry();
         $registry->loadArray($postParams);
         $iniTxt = $registry->toString();
         // Try to make the params file writeable
         if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
             JError::raiseNotice('SOME_ERROR_CODE', _('Could not make the template parameter file writable'));
             return false;
         }
         //Write the file
         $return = JFile::write($file, $iniTxt);
         // Try to make the params file unwriteable
         if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
             JError::raiseNotice('SOME_ERROR_CODE', _('Could not make the template parameter file unwritable'));
             return false;
         }
         if (!$return) {
             JError::raiseError(TUIYO_SERVER_ERROR, _("Could not save the template parameters"));
             return false;
         }
         return $return;
     }
 }
Beispiel #17
0
 function themeinstall()
 {
     JRequest::checkToken() or die('Invalid Token');
     $post = JRequest::get('post');
     $theme = array();
     if (isset($post['theme_component'])) {
         $theme['component'] = 1;
     }
     if (isset($post['theme_categories'])) {
         // TODO - change to 1 in case the parameters component will be added to Joomla! CMS back
         $theme['categories'] = 0;
     }
     if (isset($post['theme_category'])) {
         // TODO - change to 1 in case the parameters component will be added to Joomla! CMS back
         $theme['category'] = 0;
     }
     if (!empty($theme)) {
         $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
         $model =& $this->getModel('phocagalleryt');
         if ($model->install($theme)) {
             $cache =& JFactory::getCache('mod_menu');
             $cache->clean();
             $msg = JText::_('COM_PHOCAGALLERY_SUCCESS_THEME_INSTALLED');
         }
     } else {
         $msg = JText::_('COM_PHOCAGALLERY_ERROR_THEME_APPLICATION_AREA');
     }
     $this->setRedirect('index.php?option=com_phocagallery&view=phocagalleryt', $msg);
 }
Beispiel #18
0
 /**
  * Install an extension from either folder, url or upload.
  *
  * @return	boolean result of install
  * @since	1.5
  */
 function install()
 {
     jimport('joomla.client.helper');
     $this->setState('action', 'install');
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $app = JFactory::getApplication();
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             // Remember the 'Install from Directory' path.
             $app->getUserStateFromRequest($this->_context . '.install_directory', 'install_directory');
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             $app->setUserState('com_installer.message', JText::_('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         $app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
         return false;
     }
     // Get an installer instance
     $installer = JInstaller::getInstance();
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         $msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
         $result = false;
     } else {
         // Package installed sucessfully
         $msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
         $result = true;
     }
     // Set some model state values
     $app = JFactory::getApplication();
     $app->enqueueMessage($msg);
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     $app->setUserState('com_installer.message', $installer->message);
     $app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
     $app->setUserState('com_installer.redirect_url', $installer->get('redirect_url'));
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config = JFactory::getConfig();
         $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
Beispiel #19
0
 public function copy()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     JRequest::setVar('installtype', 'folder');
     $newName = JRequest::getCmd('new_name');
     $newNameRaw = JRequest::getVar('new_name', null, '', 'string');
     $templateID = JRequest::getInt('id', 0);
     $this->setRedirect('index.php?option=com_templates&view=template&id=' . $templateID);
     $model = $this->getModel('Template', 'TemplatesModel');
     $model->setState('new_name', $newName);
     $model->setState('tmp_prefix', uniqid('template_copy_'));
     $model->setState('to_path', JFactory::getConfig()->get('tmp_path') . '/' . $model->getState('tmp_prefix'));
     // Process only if we have a new name entered
     if (strlen($newName) > 0) {
         if (!JFactory::getUser()->authorise('core.create', 'com_templates')) {
             // User is not authorised to delete
             JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_CREATE_NOT_PERMITTED'));
             return false;
         }
         // Set FTP credentials, if given
         JClientHelper::setCredentialsFromRequest('ftp');
         // Check that new name is valid
         if ($newNameRaw !== null && $newName !== $newNameRaw) {
             JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_INVALID_TEMPLATE_NAME'));
             return false;
         }
         // Check that new name doesn't already exist
         if (!$model->checkNewName()) {
             JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_DUPLICATE_TEMPLATE_NAME'));
             return false;
         }
         // Check that from name does exist and get the folder name
         $fromName = $model->getFromName();
         if (!$fromName) {
             JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_INVALID_FROM_NAME'));
             return false;
         }
         // Call model's copy method
         if (!$model->copy()) {
             JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_COULD_NOT_COPY'));
             return false;
         }
         // Call installation model
         JRequest::setVar('install_directory', JFactory::getConfig()->get('tmp_path') . '/' . $model->getState('tmp_prefix'));
         $installModel = $this->getModel('Install', 'InstallerModel');
         JFactory::getLanguage()->load('com_installer');
         if (!$installModel->install()) {
             JError::raiseWarning(403, JText::_('COM_TEMPLATES_ERROR_COULD_NOT_INSTALL'));
             return false;
         }
         $this->setMessage(JText::sprintf('COM_TEMPLATES_COPY_SUCCESS', $newName));
         $model->cleanup();
         return true;
     }
 }
Beispiel #20
0
 /**
  * Method to save global configuration.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken()) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin')) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $model = new ConfigModelConfig();
     $form = $model->getForm();
     $data = $this->input->post->get('jform', array(), 'array');
     // Validate the posted data.
     $return = $model->validate($form, $data);
     // Check for validation errors.
     if ($return === false) {
         /*
          * The validate method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Redirect back to the edit screen.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     }
     // Attempt to save the configuration.
     $data = $return;
     // Access back-end com_config
     JLoader::registerPrefix('Config', JPATH_ADMINISTRATOR . '/components/com_config');
     $saveClass = new ConfigControllerApplicationSave();
     // Get a document object
     $document = JFactory::getDocument();
     // Set back-end required params
     $document->setType('json');
     // Execute back-end controller
     $return = $saveClass->execute();
     // Reset params back after requesting from service
     $document->setType('html');
     // Check the return value.
     if ($return === false) {
         /*
          * The save method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Save failed, go back to the screen and display a notice.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     }
     // Redirect back to com_config display
     $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
     $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     return true;
 }
Beispiel #21
0
 /**
  * Save the configuration
  */
 function save()
 {
     // Check for request forgeries.
     JRequest::checkToken() or jexit(JText::_('Invalid_Token'));
     // Set FTP credentials, if given.
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Initialise variables.
     $app = JFactory::getApplication();
     $model = $this->getModel('Component');
     $form = $model->getForm();
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     $id = JRequest::getInt('id');
     $option = JRequest::getWord('component');
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorize('core.admin', $option)) {
         JFactory::getApplication()->redirect('index.php', JText::_('ALERTNOTAUTH'));
         return;
     }
     // Validate the posted data.
     $return = $model->validate($form, $data);
     // Check for validation errors.
     if ($return === false) {
         // Get the validation messages.
         $errors = $model->getErrors();
         // Push up to three validation messages out to the user.
         for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
             if (JError::isError($errors[$i])) {
                 $app->enqueueMessage($errors[$i]->getMessage(), 'notice');
             } else {
                 $app->enqueueMessage($errors[$i], 'notice');
             }
         }
         // Save the data in the session.
         $app->setUserState('com_config.config.global.data', $data);
         // Redirect back to the edit screen.
         $this->setRedirect(JRoute::_('index.php?option=com_config&view=component&component=' . $option . '&tmpl=component', false));
         return false;
     }
     // Attempt to save the configuration.
     $data = array('params' => $return, 'id' => $id, 'option' => $option);
     $return = $model->save($data);
     // Check the return value.
     if ($return === false) {
         // Save the data in the session.
         $app->setUserState('com_config.config.global.data', $data);
         // Save failed, go back to the screen and display a notice.
         $message = JText::sprintf('JError_Save_Failed', $model->getError());
         $this->setRedirect('index.php?option=com_config&view=component&component=' . $option . '&tmpl=component', $message, 'error');
         return false;
     }
     $this->setRedirect('index.php?option=com_config&view=close&tmpl=component');
     return true;
 }
Beispiel #22
0
 /**
  * Install an extension from either folder, url or upload.
  *
  * @return	boolean result of install
  * @since	1.5
  */
 public function install()
 {
     $this->setState('action', 'install');
     // Set FTP credentials, if given.
     \JClientHelper::setCredentialsFromRequest('ftp');
     switch (Request::getWord('installtype')) {
         case 'folder':
             // Remember the 'Install from Directory' path.
             Request::getState($this->_context . '.install_directory', 'install_directory');
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             User::setState('com_installer.message', Lang::txt('COM_INSTALLER_NO_INSTALL_TYPE_FOUND'));
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         User::setState('com_installer.message', Lang::txt('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE'));
         return false;
     }
     // Get an installer instance
     $installer = \JInstaller::getInstance();
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         Notify::error(Lang::txt('COM_INSTALLER_INSTALL_ERROR', Lang::txt('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type']))));
         $result = false;
     } else {
         // Package installed sucessfully
         Notify::success(Lang::txt('COM_INSTALLER_INSTALL_SUCCESS', Lang::txt('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type']))));
         $result = true;
     }
     // Set some model state values
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     User::setState('com_installer.message', $installer->message);
     User::setState('com_installer.extension_message', $installer->get('extension_message'));
     User::setState('com_installer.redirect_url', $installer->get('redirect_url'));
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $package['packagefile'] = Config::get('tmp_path') . '/' . $package['packagefile'];
     }
     \JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
Beispiel #23
0
 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     //initialise variables
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     //only admins have access to this view (view is used only in J1.5)
     if ($user->get('gid') < 24) {
         JError::raiseWarning('SOME_ERROR_CODE', JText::_('FLEXI_ALERTNOTAUTH'));
         $mainframe->redirect('index.php?option=com_flexicontent&view=flexicontent');
     }
     //get vars
     $option = JRequest::getVar('option');
     $filename = 'flexicontent.acl.php';
     $path = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes';
     $acl_path = $path . DS . $filename;
     //create the toolbar
     JToolBarHelper::title(JText::_('FLEXI_EDIT_ACL'), 'editacl');
     JToolBarHelper::apply('applyacl');
     JToolBarHelper::save('saveacl');
     JToolBarHelper::cancel();
     JRequest::setVar('hidemainmenu', 1);
     //add css to document
     $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
     if (FLEXI_J30GE) {
         $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
     } else {
         if (FLEXI_J16GE) {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
         } else {
             $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
         }
     }
     //read the the stylesheet
     jimport('joomla.filesystem.file');
     $content = JFile::read($acl_path);
     jimport('joomla.client.helper');
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     if ($content !== false) {
         $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
     } else {
         $msg = JText::sprintf('FAILED TO OPEN FILE FOR WRITING', $acl_path);
         $mainframe->redirect('index.php?option=' . $option, $msg);
     }
     //assign data to template
     $this->assignRef('acl_path', $acl_path);
     $this->assignRef('content', $content);
     $this->assignRef('filename', $filename);
     $this->assignRef('ftp', $ftp);
     parent::display($tpl);
 }
 /**
  * Returns the updated options for help site selector
  *
  * @return  void
  *
  * @since   3.5
  * @throws  Exception
  */
 public function gethelpsites()
 {
     jimport('joomla.filesystem.file');
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     if (($data = file_get_contents('https://update.joomla.org/helpsites/helpsites.xml')) === false) {
         throw new Exception(JText::_('COM_CONFIG_ERROR_HELPREFRESH_FETCH'), 500);
     } elseif (!JFile::write(JPATH_ADMINISTRATOR . '/help/helpsites.xml', $data)) {
         throw new Exception(JText::_('COM_CONFIG_ERROR_HELPREFRESH_ERROR_STORE'), 500);
     }
     $options = array_merge(array(JHtml::_('select.option', '', JText::_('JOPTION_USE_DEFAULT'))), JHelp::createSiteList(JPATH_ADMINISTRATOR . '/help/helpsites.xml'));
     echo json_encode($options);
     JFactory::getApplication()->close();
 }
Beispiel #25
0
 function upload()
 {
     global $mainframe;
     // Check for request forgeries
     if (!JRequest::checkToken('request')) {
         // 401 Unauthorized
         return $this->end(401, 'Invalid Token');
     }
     // Check to see if uploading is enabled
     if ($mainframe->isSite() && !LinkrHelper::getParam('frontend_upload', '0')) {
         // 401 Unauthorized
         return $this->end(401, 'Uploading Disabled');
     }
     $this->file = JRequest::getVar('Filedata', '', 'files', 'array');
     $this->json = JRequest::getVar('format', 'html', '', 'cmd') == 'json';
     $this->returnURL = 'index.php?option=com_linkr&view=articles&tmpl=component';
     LinkrHelper::log('File::upload ' . $this->file['name']);
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Make the filename safe
     $this->file['name'] = strtolower(JFile::makeSafe($this->file['name']));
     if (empty($this->file['name'])) {
         LinkrHelper::log('Upload failed: empty filename ');
         return $this->end(400, 'bad request');
     }
     if (!$this->canUpload()) {
         return $this->end(415, 'Unsupported Media Type');
     }
     // Get full filename
     $model =& $this->getModel('articles');
     $paths = $model->fileInfo();
     $name = $paths['path'] . DS . $this->file['name'];
     // Check filename
     $name = JPath::clean($name);
     if (JFile::exists($name)) {
         // 409 Conflict
         LinkrHelper::log("Upload failed: file already exists ({$name})");
         return $this->end(409, 'File already exists');
     }
     // Uplaod
     if (!JFile::upload($this->file['tmp_name'], $name)) {
         // Is this a 400 bad request or 500 internal error?
         LinkrHelper::log("Upload failed: could not upload file ({$name})");
         return $this->end(500, 'Could not upload file');
     }
     // Upload complete
     LinkrHelper::log('File uploaded');
     $this->end(200, 'File uploaded!');
 }
Beispiel #26
0
 function save()
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     JClientHelper::setCredentialsFromRequest('ftp');
     $app = JFactory::getApplication();
     $model = $this->getModel('settings');
     $form = $model->getForm();
     $extension = JRequest::getVar('extension', null);
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     $id = JRequest::getInt('id');
     if (!JFactory::getUser()->authorise('core.admin', $extension)) {
         JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'));
         return;
     }
     $valid_data = array();
     foreach ($form as $f) {
         $return = $model->validate($f, $data);
         // Check for validation errors.
         if ($return === false) {
             // Get the validation messages.
             $errors = $model->getErrors();
             // Push up to three validation messages out to the user.
             for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
                 if ($errors[$i] instanceof Exception) {
                     $app->enqueueMessage($errors[$i]->getMessage(), 'warning');
                 } else {
                     $app->enqueueMessage($errors[$i], 'warning');
                 }
             }
             // Save the data in the session.
             $app->setUserState($extension . '.settings.global.data', $data);
             // Redirect back to the edit screen.
             $this->setRedirect(JRoute::_('index.php?option=com_ksen&view=settings&extension=' . $extension, false));
             return false;
         } else {
             $valid_data = array_merge($valid_data, $return);
         }
     }
     $data = array('params' => $valid_data, 'id' => $id, 'option' => $extension);
     $return = $model->save($data);
     if ($return === false) {
         $app->setUserState($extension . '.settings.global.data', $data);
         $message = JText::sprintf('JERROR_SAVE_FAILED', $model->getError());
         $this->setRedirect('index.php?option=com_ksen&view=settings&extension=' . $extension, $message, 'error');
         return false;
     }
     $this->setRedirect('index.php?option=com_ksen&view=settings&extension=' . $extension);
     return true;
 }
Beispiel #27
0
 /**
  * Display a list of uninstalled extensions
  *
  * @return  void
  */
 public function displayTask()
 {
     $model = new Models\Warnings();
     $this->view->ftp = \JClientHelper::setCredentialsFromRequest('ftp');
     $this->view->messages = $model->getItems();
     $this->view->state = $model->getState();
     $showMessage = false;
     if (is_object($this->view->state)) {
         $message1 = $this->view->state->get('message');
         $message2 = $this->view->state->get('extension_message');
         $showMessage = $message1 || $message2;
     }
     $this->view->showMessage = $showMessage;
     $this->view->display();
 }
Beispiel #28
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->source = $this->get('Source');
     $this->state = $this->get('State');
     $this->template = $this->get('Template');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     parent::display($tpl);
 }
 function saveProfile()
 {
     global $mainframe;
     // Initialize some variables
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     $json = JRequest::getVar('json', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $post = json_decode($json);
     $profile = JRequest::getCmd('profile');
     $result = array();
     if (!$profile) {
         $result['error'] = JText::_('No Profile name contains space or special chracters.');
         echo json_encode($result);
         exit;
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $errors = array();
     $file = dirname(dirname(__FILE__)) . DS . 'profiles' . DS . $profile . '.ini';
     $params = new JParameter('');
     if (isset($post)) {
         foreach ($post as $k => $v) {
             $params->set($k, $v);
         }
     }
     $data = $params->toString();
     if (JFile::exists($file)) {
         @chmod($file, 0777);
     }
     $return = @JFile::write($file, $data);
     // Try to make the params file unwriteable
     if (!$ftp['enabled'] && @JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
         $errors[] = sprintf(JText::_('Profile file unwritable'), $file);
     }
     if (!$return) {
         $errors[] = JText::_('Operation Failed') . ': ' . JText::sprintf('Failed to open file for writing.', $file);
     }
     if ($errors) {
         $result['error'] = implode('<br/>', $errors);
     } else {
         $result['successful'] = sprintf(JText::_('SAVE PROFILE SUCCESSFULLY'), $profile);
         $result['profile'] = $profile;
         $result['type'] = 'new';
     }
     echo json_encode($result);
     exit;
 }
Beispiel #30
0
/**
* Compiles a list of installed languages
*/
function viewLanguages()
{
    global $mainframe, $option;
    // Initialize some variables
    $db =& JFactory::getDBO();
    $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
    $rows = array();
    $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
    $limitstart = $mainframe->getUserStateFromRequest($option . '.limitstart', 'limitstart', 0, 'int');
    $rowid = 0;
    // Set FTP credentials, if given
    jimport('joomla.client.helper');
    $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
    //load folder filesystem class
    jimport('joomla.filesystem.folder');
    $path = JLanguage::getLanguagePath($client->path);
    $dirs = JFolder::folders($path);
    foreach ($dirs as $dir) {
        $files = JFolder::files($path . DS . $dir, '^([-_A-Za-z]*)\\.xml$');
        foreach ($files as $file) {
            $data = JApplicationHelper::parseXMLLangMetaFile($path . DS . $dir . DS . $file);
            $row = new StdClass();
            $row->id = $rowid;
            $row->language = substr($file, 0, -4);
            if (!is_array($data)) {
                continue;
            }
            foreach ($data as $key => $value) {
                $row->{$key} = $value;
            }
            // if current than set published
            $params = JComponentHelper::getParams('com_languages');
            if ($params->get($client->name, 'en-GB') == $row->language) {
                $row->published = 1;
            } else {
                $row->published = 0;
            }
            $row->checked_out = 0;
            $row->mosname = JString::strtolower(str_replace(" ", "_", $row->name));
            $rows[] = $row;
            $rowid++;
        }
    }
    jimport('joomla.html.pagination');
    $pageNav = new JPagination($rowid, $limitstart, $limit);
    $rows = array_slice($rows, $pageNav->limitstart, $pageNav->limit);
    HTML_languages::showLanguages($rows, $pageNav, $option, $client, $ftp);
}