当前位置: 首页>>代码示例>>PHP>>正文


PHP JPath::isOwner方法代码示例

本文整理汇总了PHP中JPath::isOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP JPath::isOwner方法的具体用法?PHP JPath::isOwner怎么用?PHP JPath::isOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JPath的用法示例。


在下文中一共展示了JPath::isOwner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: admin_postinstall_eaccelerator_action

/**
 * Disables the unsupported eAccelerator caching method, replacing it with the
 * "file" caching method.
 *
 * @return  void
 *
 * @since   3.2
 */
function admin_postinstall_eaccelerator_action()
{
    $prev = new JConfig();
    $prev = JArrayHelper::fromObject($prev);
    $data = array('cacheHandler' => 'file');
    $data = array_merge($prev, $data);
    $config = new Registry('config');
    $config->loadArray($data);
    jimport('joomla.filesystem.path');
    jimport('joomla.filesystem.file');
    // Set the configuration file path.
    $file = JPATH_CONFIGURATION . '/configuration.php';
    // Get the new FTP credentials.
    $ftp = JClientHelper::getCredentials('ftp', true);
    // Attempt to make the file writeable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
    }
    // Attempt to write the configuration file as a PHP class named JConfig.
    $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
    if (!JFile::write($file, $configuration)) {
        JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
        return;
    }
    // Attempt to make the file unwriteable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
    }
}
开发者ID:grlf,项目名称:eyedock,代码行数:37,代码来源:eaccelerator.php

示例2: save

 function save($data)
 {
     // Get the previous configuration.
     if (is_object($data)) {
         $data = JArrayHelper::fromObject($data);
     }
     $prev = JTheFactoryHelper::getConfig();
     $prev = JArrayHelper::fromObject($prev);
     $data = array_merge($prev, $data);
     $configfile = JTheFactoryAdminHelper::getConfigFile();
     $config = new JRegistry('config');
     $config->loadArray($data);
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.file');
     jimport('joomla.client.helper');
     // Get the new FTP credentials.
     $ftp = JClientHelper::getCredentials('ftp', true);
     // Attempt to make the file writeable if using FTP.
     if (!$ftp['enabled'] && JPath::isOwner($configfile) && !JPath::setPermissions($configfile, '0644')) {
         JError::raiseNotice(101, JText::_('FACTORY_SETTINGS_FILE_IS_NOT_WRITABLE'));
     }
     // Attempt to write the configuration file as a PHP class named JConfig.
     $configString = $config->toString('PHP', array('class' => ucfirst(APP_PREFIX) . "Config", 'closingtag' => false));
     if (!JFile::write($configfile, $configString)) {
         JError::raiseWarning(101, JText::_('FACTORY_SETTINGS_FILE_WRITE_FAILED'));
         return false;
     }
     // Attempt to make the file unwriteable if using FTP.
     if (!$ftp['enabled'] && JPath::isOwner($configfile) && !JPath::setPermissions($configfile, '0444')) {
         JError::raiseNotice(101, JText::_('FACTORY_SETTINGS_FILE_IS_NOT_WRITABLE'));
     }
     return true;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:33,代码来源:config.php

示例3: isWritable

 /**
  * Determines if a given path is writable in the current environment
  *
  * @param   string  $path  Path to check
  *
  * @return  boolean  True if writable
  *
  * @since   4.0
  */
 public static function isWritable($path)
 {
     if (JFactory::getConfig()->get('config.ftp_enable')) {
         return true;
     } else {
         while (!file_exists($path)) {
             $path = dirname($path);
         }
         return is_writable($path) || JPath::isOwner($path) || JPath::canChmod($path);
     }
 }
开发者ID:svenbluege,项目名称:com_localise,代码行数:20,代码来源:localise.php

示例4: setDatabaseType

 public function setDatabaseType()
 {
     $path = JPATH_CONFIGURATION . '/configuration.php';
     $result = false;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     $ftp = JClientHelper::getCredentials('ftp');
     jimport('joomla.filesystem.path');
     if ($ftp['enabled'] || JPath::isOwner($path) && JPath::setPermissions($path, '0644')) {
         $search = JFile::read($path);
         $replaced = str_replace('$dbtype = \'mysql\';', '$dbtype = \'mysqli\';', $search);
         $result = JFile::write($path, $replaced);
         if (!$ftp['enabled'] && JPath::isOwner($path)) {
             JPath::setPermissions($path, '0444');
         }
     }
     return $result;
 }
开发者ID:janssit,项目名称:www.marlinfishingcanaria.com,代码行数:18,代码来源:helper.php

示例5: savecss

 /**
  * Saves the css
  *
  */
 function savecss()
 {
     global $mainframe;
     JRequest::checkToken() or die('Invalid Token');
     // Initialize some variables
     $option = JRequest::getVar('option');
     $filename = JRequest::getVar('filename', '', 'post', 'cmd');
     $filecontent = JRequest::getVar('filecontent', '', '', '', JREQUEST_ALLOWRAW);
     if (!$filecontent) {
         $mainframe->redirect('index.php?option=' . $option, JText::_('OPERATION FAILED') . ': ' . JText::_('CONTENT EMPTY'));
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = JPATH_SITE . DS . 'components' . DS . 'com_eventlist' . DS . 'assets' . DS . 'css' . DS . $filename;
     // Try to make the css file writeable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'COULD NOT MAKE CSS FILE WRITABLE');
     }
     jimport('joomla.filesystem.file');
     $return = JFile::write($file, $filecontent);
     // Try to make the css file unwriteable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'COULD NOT MAKE CSS FILE UNWRITABLE');
     }
     if ($return) {
         $task = JRequest::getVar('task');
         switch ($task) {
             case 'applycss':
                 $mainframe->redirect('index.php?option=' . $option . '&view=editcss', JText::_('CSS FILE SUCCESSFULLY ALTERED'));
                 break;
             case 'savecss':
             default:
                 $mainframe->redirect('index.php?option=' . $option, JText::_('CSS FILE SUCCESSFULLY ALTERED'));
                 break;
         }
     } else {
         $mainframe->redirect('index.php?option=' . $option, JText::_('OPERATION FAILED') . ': ' . JText::sprintf('FAILED TO OPEN FILE FOR WRITING', $file));
     }
 }
开发者ID:janssit,项目名称:www.kadulleke.be,代码行数:45,代码来源:controller.php

示例6: onAfterSave

 protected function onAfterSave(&$table)
 {
     if ($table->body_source == 'file' && $table->body_source_file != '-1') {
         jimport('joomla.filesystem.file');
         $app = JFactory::getApplication();
         $fileName = $table->body_source_file;
         $filePath = JPath::clean(JPATH_ADMINISTRATOR . '/components/com_j2store/views/emailtemplate/tpls/' . $fileName);
         // Include the extension plugins for the save events.
         JPluginHelper::importPlugin('extension');
         $user = get_current_user();
         chown($filePath, $user);
         JPath::setPermissions($filePath, '0644');
         // Try to make the template file writable.
         if (!is_writable($filePath)) {
             $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_WRITABLE'), 'warning');
             $app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_PERMISSIONS' . JPath::getPermissions($filePath)), 'warning');
             if (!JPath::isOwner($filePath)) {
                 $app->enqueueMessage(JText::_('COM_TEMPLATES_CHECK_FILE_OWNERSHIP'), 'warning');
             }
             return false;
         }
         $source = JFactory::getApplication()->input->get('source', '', 'RAW');
         jimport('joomla.filter.filterinput');
         $filter = JFilterInput::getInstance(null, null, 1, 1);
         $value = $filter->clean($source, 'raw');
         $return = true;
         if (!empty($value)) {
             $return = JFile::write($filePath, $value);
         }
         // Try to make the template file unwritable.
         if (JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0644')) {
             $app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_UNWRITABLE'), 'error');
             return false;
         } elseif (!$return) {
             $app->enqueueMessage(JText::sprintf('COM_TEMPLATES_ERROR_FAILED_TO_SAVE_FILENAME', $fileName), 'error');
             return false;
         }
     }
 }
开发者ID:davetheapple,项目名称:oakencraft,代码行数:39,代码来源:emailtemplates.php

示例7: save

 function save()
 {
     $app =& JFactory::getApplication();
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = JPATH_RSGALLERY2_SITE . '/templates/' . $this->template . '/html/' . $this->filename;
     // Try to make the css file writeable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'Could not make the html file writable');
     }
     jimport('joomla.filesystem.file');
     $return = JFile::write($file, $this->content);
     // Try to make the css file unwriteable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'Could not make the html file unwritable');
     }
     if ($return) {
         $app->enqueueMessage('File saved');
     }
     return $return;
 }
开发者ID:realityking,项目名称:rsgallery2,代码行数:23,代码来源:editHtml.php

示例8: save


//.........这里部分代码省略.........
     // FTP SETTINGS
     $config_array['ftp_enable'] = JRequest::getVar('ftp_enable', 0, 'post', 'int');
     $config_array['ftp_host'] = JRequest::getVar('ftp_host', '', 'post', 'string');
     $config_array['ftp_port'] = JRequest::getVar('ftp_port', '', 'post', 'int');
     $config_array['ftp_user'] = JRequest::getVar('ftp_user', '', 'post', 'string');
     $config_array['ftp_pass'] = JRequest::getVar('ftp_pass', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $config_array['ftp_root'] = JRequest::getVar('ftp_root', '', 'post', 'string');
     // DATABASE SETTINGS
     $config_array['dbtype'] = JRequest::getVar('dbtype', 'mysql', 'post', 'word');
     $config_array['host'] = JRequest::getVar('host', 'localhost', 'post', 'string');
     $config_array['user'] = JRequest::getVar('user', '', 'post', 'string');
     $config_array['db'] = JRequest::getVar('db', '', 'post', 'string');
     $config_array['dbprefix'] = JRequest::getVar('dbprefix', 'jos_', 'post', 'string');
     // MAIL SETTINGS
     $config_array['mailer'] = JRequest::getVar('mailer', 'mail', 'post', 'word');
     $config_array['mailfrom'] = JRequest::getVar('mailfrom', '', 'post', 'string');
     $config_array['fromname'] = JRequest::getVar('fromname', 'Joomla 1.5', 'post', 'string');
     $config_array['sendmail'] = JRequest::getVar('sendmail', '/usr/sbin/sendmail', 'post', 'string');
     $config_array['smtpauth'] = JRequest::getVar('smtpauth', 0, 'post', 'int');
     $config_array['smtpsecure'] = JRequest::getVar('smtpsecure', 'none', 'post', 'word');
     $smtpport = JRequest::getVar('smtpport', '', 'post', 'int');
     $config_array['smtpport'] = $smtpport ? $smtpport : '25';
     $config_array['smtpuser'] = JRequest::getVar('smtpuser', '', 'post', 'string');
     $config_array['smtppass'] = JRequest::getVar('smtppass', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $config_array['smtphost'] = JRequest::getVar('smtphost', '', 'post', 'string');
     // META SETTINGS
     $config_array['MetaAuthor'] = JRequest::getVar('MetaAuthor', 1, 'post', 'int');
     $config_array['MetaTitle'] = JRequest::getVar('MetaTitle', 1, 'post', 'int');
     // SESSION SETTINGS
     $config_array['lifetime'] = JRequest::getVar('lifetime', 0, 'post', 'int');
     $config_array['session_handler'] = JRequest::getVar('session_handler', 'none', 'post', 'word');
     //LANGUAGE SETTINGS
     //$config_array['lang']				= JRequest::getVar('lang', 'none', 'english', 'cmd');
     //$config_array['language']			= JRequest::getVar('language', 'en-GB', 'post', 'cmd');
     $config->loadArray($config_array);
     //override any possible database password change
     $config->setValue('config.password', $mainframe->getCfg('password'));
     // handling of special characters
     $sitename = htmlspecialchars(JRequest::getVar('sitename', '', 'post', 'string'), ENT_COMPAT, 'UTF-8');
     $config->setValue('config.sitename', $sitename);
     $MetaDesc = htmlspecialchars(JRequest::getVar('MetaDesc', '', 'post', 'string'), ENT_COMPAT, 'UTF-8');
     $config->setValue('config.MetaDesc', $MetaDesc);
     $MetaKeys = htmlspecialchars(JRequest::getVar('MetaKeys', '', 'post', 'string'), ENT_COMPAT, 'UTF-8');
     $config->setValue('config.MetaKeys', $MetaKeys);
     // handling of quotes (double and single) and amp characters
     // htmlspecialchars not used to preserve ability to insert other html characters
     $offline_message = JRequest::getVar('offline_message', '', 'post', 'string');
     $offline_message = JFilterOutput::ampReplace($offline_message);
     $offline_message = str_replace('"', '"', $offline_message);
     $offline_message = str_replace("'", ''', $offline_message);
     $config->setValue('config.offline_message', $offline_message);
     //purge the database session table (only if we are changing to a db session store)
     if ($mainframe->getCfg('session_handler') != 'database' && $config->getValue('session_handler') == 'database') {
         $table =& JTable::getInstance('session');
         $table->purge(-1);
     }
     // Get the path of the configuration file
     $fname = JPATH_CONFIGURATION . DS . 'configuration.php';
     // Update the credentials with the new settings
     $oldconfig =& JFactory::getConfig();
     $oldconfig->setValue('config.ftp_enable', $config_array['ftp_enable']);
     $oldconfig->setValue('config.ftp_host', $config_array['ftp_host']);
     $oldconfig->setValue('config.ftp_port', $config_array['ftp_port']);
     $oldconfig->setValue('config.ftp_user', $config_array['ftp_user']);
     $oldconfig->setValue('config.ftp_pass', $config_array['ftp_pass']);
     $oldconfig->setValue('config.ftp_root', $config_array['ftp_root']);
     JClientHelper::getCredentials('ftp', true);
     if (!$config->get('caching') && $oldconfig->get('caching')) {
         $cache = JFactory::getCache();
         $cache->clean();
     }
     // Try to make configuration.php writeable
     jimport('joomla.filesystem.path');
     if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0644')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable');
     }
     // Get the config registry in PHP class format and write it to configuation.php
     jimport('joomla.filesystem.file');
     if (JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) {
         $msg = JText::_('The Configuration Details have been updated');
     } else {
         $msg = JText::_('ERRORCONFIGFILE');
     }
     // Redirect appropriately
     $task = $this->getTask();
     switch ($task) {
         case 'apply':
             $this->setRedirect('index.php?option=com_config', $msg);
             break;
         case 'save':
         default:
             $this->setRedirect('index.php', $msg);
             break;
     }
     // Try to make configuration.php unwriteable
     //if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) {
     if ($config_array['ftp_enable'] == 0 && !$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) {
         JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php unwritable');
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:101,代码来源:application.php

示例9: save

 public function save($data)
 {
     jimport('joomla.filesystem.file');
     // New
     if ($data['id'] < 1) {
         $data['type'] = 2;
         // Custom in every case
         if ($data['title'] != '') {
             $filename = JApplication::stringURLSafe($data['title']);
             if (trim(str_replace('-', '', $filename)) == '') {
                 $filename = JFactory::getDate()->format("Y-m-d-H-i-s");
             }
         } else {
             $filename = JFactory::getDate()->format("Y-m-d-H-i-s");
         }
         $filename = $filename . '.css';
         $data['filename'] = $filename;
         $filePath = PhocaGalleryFile::existsCSS($filename, $data['type']);
         if ($filePath) {
             $this->setError(JText::sprintf('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS', $fileName));
             return false;
         } else {
             $filePath = PhocaGalleryFile::getCSSPath($data['type']) . $filename;
         }
     } else {
         $filename = PhocaGalleryFile::getCSSFile($data['id']);
         $filePath = PhocaGalleryFile::existsCSS($filename, $data['type']);
     }
     //$dispatcher = JEventDispatcher::getInstance();
     $fileName = $filename;
     // Include the extension plugins for the save events.
     //JPluginHelper::importPlugin('extension');
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     // Try to make the template file writeable.
     if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0644')) {
         $this->setError(JText::_('COM_PHOCAGALLERY_ERROR_SOURCE_FILE_NOT_WRITABLE'));
         return false;
     }
     // Trigger the onExtensionBeforeSave event.
     /*$result = $dispatcher->trigger('onExtensionBeforeSave', array('com_phocagallery.source', &$data, false));
     		if (in_array(false, $result, true)) {
     			$this->setError($table->getError());
     			return false;
     		}*/
     $return = JFile::write($filePath, $data['source']);
     // Try to make the template file unwriteable.
     if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0444')) {
         $this->setError(JText::_('COM_PHOCAGALLERY_ERROR_SOURCE_FILE_NOT_UNWRITABLE'));
         return false;
     } elseif (!$return) {
         $this->setError(JText::sprintf('COM_PHOCAGALLERY_ERROR_FAILED_TO_SAVE_FILENAME', $fileName));
         return false;
     }
     // Trigger the onExtensionAfterSave event.
     //$dispatcher->trigger('onExtensionAfterSave', array('com_templates.source', &$table, false));
     //return true;
     return parent::save($data);
 }
开发者ID:naka211,项目名称:malerfirmaet,代码行数:60,代码来源:phocagalleryef.php

示例10: removeroot

 /**
  * Method to unset the root_user value from configuration data.
  *
  * This method will load the global configuration data straight from
  * JConfig and remove the root_user value for security, then save the configuration.
  *
  * @since	1.6
  */
 function removeroot()
 {
     // Include client helper
     jimport('joomla.client.helper');
     // Get the previous configuration.
     $prev = new JConfig();
     $prev = JArrayHelper::fromObject($prev);
     // Clean the cache if disabled but previously enabled.
     if ($prev['caching']) {
         $cache = JFactory::getCache();
         $cache->clean();
     }
     // Create the new configuration object, and unset the root_user property
     $config = new JRegistry('config');
     unset($prev['root_user']);
     $config->loadArray($prev);
     /*
      * Write the configuration file.
      */
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.file');
     // Set the configuration file path.
     $file = JPATH_CONFIGURATION . DS . 'configuration.php';
     // Overwrite the old FTP credentials with the new ones.
     $temp = JFactory::getConfig();
     $temp->set('ftp_enable', $prev['ftp_enable']);
     $temp->set('ftp_host', $prev['ftp_host']);
     $temp->set('ftp_port', $prev['ftp_port']);
     $temp->set('ftp_user', $prev['ftp_user']);
     $temp->set('ftp_pass', $prev['ftp_pass']);
     $temp->set('ftp_root', $prev['ftp_root']);
     // Get the new FTP credentials.
     $ftp = JClientHelper::getCredentials('ftp', true);
     // Attempt to make the file writeable if using FTP.
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
         JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
     }
     // Attempt to write the configuration file as a PHP class named JConfig.
     if (!JFile::write($file, $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false)))) {
         $this->setError(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'));
         return false;
     }
     // Attempt to make the file unwriteable if using FTP.
     if ($prev['ftp_enable'] == 0 && !$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
         JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
     }
     return true;
 }
开发者ID:akksi,项目名称:jcg,代码行数:56,代码来源:application.php

示例11: saveTemplateCSS

function saveTemplateCSS()
{
    $kunena_app =& JFactory::getApplication();
    $option = JRequest::getCmd('option');
    $template = JRequest::getVar('id', '', 'post', 'cmd');
    $filename = JRequest::getVar('filename', '', 'post', 'cmd');
    $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);
    if (!$template) {
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect(JURI::base() . 'index.php?option=' . $option . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_OPERATION_FAILED') . ': ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_TEMPLATE_NOT_SPECIFIED.'));
    }
    if (!$filecontent) {
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect(JURI::base() . 'index.php?option=' . $option . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_OPERATION_FAILED') . ': ' . JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_CONTENT_EMPTY'));
    }
    // Set FTP credentials, if given
    jimport('joomla.client.helper');
    JClientHelper::setCredentialsFromRequest('ftp');
    $ftp = JClientHelper::getCredentials('ftp');
    $file = KUNENA_PATH_TEMPLATE . '/' . $template . '/css/' . $filename;
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_COULD_NOT_CSS_WRITABLE'));
    }
    jimport('joomla.filesystem.file');
    $return = JFile::write($file, $filecontent);
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_COULD_NOT_CSS_UNWRITABLE'));
    }
    if ($return) {
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect(JURI::base() . 'index.php?option=' . $option . '&task=editKTemplate&cid[]=' . $template, JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_FILE_SAVED'));
    } else {
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect(JURI::base() . 'index.php?option=' . $option . '&id=' . $template . '&task=chooseCSSTemplate', JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_OPERATION_FAILED') . ': ' . JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_FAILED_OPEN_FILE.', $file));
    }
}
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:40,代码来源:admin.kunena.php

示例12: setStatus

 function setStatus($state)
 {
     $ajax = intval(JRequest::getVar('ajax')) == 1;
     if (!$ajax) {
         JRequest::checkToken() or jexit('Invalid Token');
     }
     $type = JRequest::getVar('cid', array(''), 'post', 'array');
     $type = JRequest::getVar('statusType', $type[0], 'post', 'string');
     $types = array('sef', 'mod_rewrite', 'sef_suffix', 'joomsef', 'plugin', 'newurls', 'versioncheck', 'jfrouter');
     $msg = '';
     if (in_array($type, $types)) {
         // SEF and mod_rewrite settings
         if ($type == 'sef' || $type == 'mod_rewrite' || $type == 'sef_suffix') {
             jimport('joomla.client.helper');
             jimport('joomla.filesystem.path');
             jimport('joomla.filesystem.file');
             // We need to load the config file manually,
             // because on Joomla 3 the global JFactory::getConfig()
             // already contains some changed themeParams data,
             // which causes fatal error after saving
             $file = JPATH_CONFIGURATION . '/configuration.php';
             if (!is_file($file)) {
                 $msg = JText::_('COM_SEF_ERROR_LOADING_CONFIG');
             } else {
                 include_once $file;
                 if (!class_exists('JConfig')) {
                     $msg = JText::_('COM_SEF_ERROR_LOADING_CONFIG');
                 } else {
                     $config = new JRegistry();
                     $data = new JConfig();
                     $config->loadObject($data);
                     if ($type == 'sef') {
                         $config->set('sef', $state);
                     } else {
                         if ($type == 'mod_rewrite') {
                             $config->set('sef_rewrite', $state);
                         } else {
                             $config->set('sef_suffix', $state);
                         }
                     }
                     // Store the configuration
                     // Get the new FTP credentials.
                     $ftp = JClientHelper::getCredentials('ftp', true);
                     // Attempt to make the file writeable if using FTP.
                     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
                         $msg = JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE');
                     }
                     if (!JFile::write($file, $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false)))) {
                         $msg = JText::_('COM_SEF_ERROR_WRITING_CONFIG');
                     }
                 }
             }
         } else {
             if ($type == 'joomsef' || $type == 'newurls' || $type == 'versioncheck') {
                 // JoomSEF and new URLs settings
                 $sefConfig = SEFConfig::getConfig();
                 if ($type == 'joomsef') {
                     $sefConfig->enabled = $state;
                 } else {
                     if ($type == 'newurls') {
                         $sefConfig->disableNewSEF = 1 - $state;
                     } else {
                         $sefConfig->versionChecker = $state;
                     }
                 }
                 // Store the configuration
                 if (!$sefConfig->saveConfig()) {
                     $msg = JText::_('COM_SEF_ERROR_WRITING_CONFIG');
                 }
             } else {
                 if ($type == 'plugin' || $type == 'jfrouter') {
                     // Plugins settings
                     $db = JFactory::getDBO();
                     if ($type == 'plugin') {
                         $plg = 'joomsef';
                     } else {
                         if ($type == 'jfrouter') {
                             $plg = 'jfrouter';
                         }
                     }
                     $query = "UPDATE `#__extensions` SET `enabled` = '{$state}' WHERE (`type` = 'plugin') AND (`element` = '{$plg}') AND (`folder` = 'system') LIMIT 1";
                     $db->setQuery($query);
                     if (!$db->query()) {
                         $msg = JText::_('COM_SEF_ERROR_WRITING_CONFIG');
                     }
                     // Clear cache for com_plugins!
                     $model = $this->getModel();
                     $model->clearCache('com_plugins');
                 }
             }
         }
     }
     if ($ajax) {
         $obj = new stdClass();
         $obj->id = $type;
         $obj->newValue = $state;
         $ret = array($obj);
         echo json_encode($ret);
         $app = JFactory::getApplication();
         $app->close();
//.........这里部分代码省略.........
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:101,代码来源:controller.php

示例13: saveTemplateCSS

 function saveTemplateCSS()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Initialize some variables
     $option = JRequest::getCmd('option');
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     $template = JRequest::getVar('id', '', 'post', 'cmd');
     $filename = JRequest::getVar('filename', '', 'post', 'cmd');
     $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);
     if (!$template) {
         $mainframe->redirect('index.php?option=' . $option . '&client=' . $client->id, JText::_('Operation Failed') . ': ' . JText::_('No template specified.'));
     }
     if (!$filecontent) {
         $mainframe->redirect('index.php?option=' . $option . '&client=' . $client->id, JText::_('Operation Failed') . ': ' . JText::_('Content empty.'));
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = $client->path . DS . 'templates' . DS . $template . DS . 'css' . DS . $filename;
     // Try to make the css file writeable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
         JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file writable'));
     }
     jimport('joomla.filesystem.file');
     $return = JFile::write($file, $filecontent);
     // Try to make the css file unwriteable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
         JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file unwritable'));
     }
     if ($return) {
         $task = JRequest::getCmd('task');
         switch ($task) {
             case 'apply_css':
                 $mainframe->redirect('index.php?option=' . $option . '&client=' . $client->id . '&task=edit_css&id=' . $template . '&filename=' . $filename, JText::_('File Saved'));
                 break;
             case 'save_css':
             default:
                 $mainframe->redirect('index.php?option=' . $option . '&client=' . $client->id . '&task=edit&cid[]=' . $template, JText::_('File Saved'));
                 break;
         }
     } else {
         $mainframe->redirect('index.php?option=' . $option . '&client=' . $client->id . '&id=' . $template . '&task=choose_css', JText::_('Operation Failed') . ': ' . JText::sprintf('Failed to open file for writing.', $file));
     }
 }
开发者ID:jicheng17,项目名称:comanova,代码行数:47,代码来源:controller.php

示例14: writeConfigFile

 /**
  * Method to write the configuration to a file.
  *
  * @param   Registry  $config  A Registry object containing all global config data.
  *
  * @return	boolean  True on success, false on failure.
  *
  * @since	2.5.4
  * @throws  RuntimeException
  */
 private function writeConfigFile(Registry $config)
 {
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.file');
     // Set the configuration file path.
     $file = JPATH_CONFIGURATION . '/configuration.php';
     // Get the new FTP credentials.
     $ftp = JClientHelper::getCredentials('ftp', true);
     $app = JFactory::getApplication();
     // Attempt to make the file writeable if using FTP.
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
         $app->enqueueMessage(JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'notice');
     }
     // Attempt to write the configuration file as a PHP class named JConfig.
     $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
     if (!JFile::write($file, $configuration)) {
         throw new RuntimeException(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'));
     }
     // Attempt to make the file unwriteable if using FTP.
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
         $app->enqueueMessage(JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'), 'notice');
     }
     return true;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:34,代码来源:application.php

示例15: save

 /**
  * Method to store the source file contents.
  *
  * @param	array	The souce data to save.
  *
  * @return	boolean	True on success, false otherwise and internal error set.
  * @since	1.6
  */
 public function save($data)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.client.helper');
     // Get the template.
     $template = $this->getTemplate();
     if (empty($template)) {
         return false;
     }
     $dispatcher = JDispatcher::getInstance();
     $fileName = $this->getState('filename');
     $client = JApplicationHelper::getClientInfo($template->client_id);
     $filePath = JPath::clean($client->path . '/templates/' . $template->element . '/' . $fileName);
     // Include the extension plugins for the save events.
     JPluginHelper::importPlugin('extension');
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     // Try to make the template file writeable.
     if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0644')) {
         $this->setError(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_WRITABLE'));
         return false;
     }
     // Trigger the onExtensionBeforeSave event.
     $result = $dispatcher->trigger('onExtensionBeforeSave', array('com_templates.source', &$data, false));
     if (in_array(false, $result, true)) {
         $this->setError($table->getError());
         return false;
     }
     $return = JFile::write($filePath, $data['source']);
     // Try to make the template file unwriteable.
     if (!$ftp['enabled'] && JPath::isOwner($filePath) && !JPath::setPermissions($filePath, '0444')) {
         $this->setError(JText::_('COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_UNWRITABLE'));
         return false;
     } else {
         if (!$return) {
             $this->setError(JText::sprintf('COM_TEMPLATES_ERROR_FAILED_TO_SAVE_FILENAME', $fileName));
             return false;
         }
     }
     // Trigger the onExtensionAfterSave event.
     $dispatcher->trigger('onExtensionAfterSave', array('com_templates.source', &$table, false));
     return true;
 }
开发者ID:Joomla-on-NoSQL,项目名称:LaMojo,代码行数:52,代码来源:source.php


注:本文中的JPath::isOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。