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


PHP JPath::setPermissions方法代码示例

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


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

示例1: uploadFile

 function uploadFile($filename, $userfile_name, &$msg, $tmp_folder = '')
 {
     if (!$tmp_folder) {
         $tmp_folder = JPATH_SITE . DS . "tmp";
     }
     jimport('joomla.filesystem.path');
     $baseDir = JPath::clean($tmp_folder);
     $baseDir = rtrim($baseDir, DS) . DS;
     if (file_exists($baseDir)) {
         if (is_writable($baseDir)) {
             if (move_uploaded_file($filename, $baseDir . $userfile_name)) {
                 if (JPath::setPermissions($baseDir . $userfile_name)) {
                     return true;
                 } else {
                     $msg = 'Failed to change the permissions of the uploaded file.';
                 }
             } else {
                 $msg = 'Failed to move uploaded file to tmp directory.';
             }
         } else {
             $msg = 'Upload failed as tmp directory is not writable.';
         }
     } else {
         $msg = 'Upload failed as tmp directory does not exist.';
     }
     return false;
 }
开发者ID:parkmi,项目名称:dolschool14,代码行数:27,代码来源:lms.lib.files.php

示例2: setPermissions

 /**
  * Chmods files and directories recursively to given permissions.
  *
  * @param   string  $path        Root path to begin changing mode [without trailing slash].
  * @param   string  $filemode    Octal representation of the value to change file mode to [null = no change].
  * @param   string  $foldermode  Octal representation of the value to change folder mode to [null = no change].
  *
  * @return  boolean  True if successful [one fail means the whole operation failed].
  *
  * @since   11.1
  */
 public static function setPermissions($path, $filemode = '0644', $foldermode = '0755')
 {
     // Initialise return value
     $ret = true;
     if (is_dir($path)) {
         $dh = opendir($path);
         while ($file = readdir($dh)) {
             if ($file != '.' && $file != '..') {
                 $fullpath = $path . '/' . $file;
                 if (is_dir($fullpath)) {
                     if (!JPath::setPermissions($fullpath, $filemode, $foldermode)) {
                         $ret = false;
                     }
                 } else {
                     if (isset($filemode)) {
                         if (!@chmod($fullpath, octdec($filemode))) {
                             $ret = false;
                         }
                     }
                 }
             }
         }
         closedir($dh);
         if (isset($foldermode)) {
             if (!@chmod($path, octdec($foldermode))) {
                 $ret = false;
             }
         }
     } else {
         if (isset($filemode)) {
             $ret = @chmod($path, octdec($filemode));
         }
     }
     return $ret;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:46,代码来源:path.php

示例3: uploader

 public static function uploader()
 {
     $params = modPwebcontactHelper::getParams();
     // check if upload is enabled
     if (!$params->get('show_upload', 0)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Uploader disabled');
         }
         return array('status' => 402, 'files' => array());
     }
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $path = $params->get('upload_path');
     if (!JFolder::exists($path)) {
         JFolder::create($path, 0777);
     }
     if (!is_writable($path) and JPath::canChmod($path)) {
         JPath::setPermissions($path, null, '0777');
     }
     if (!is_writable($path)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Upload dir is not writable');
         }
         return array('status' => 403, 'files' => array());
     }
     // load uploader
     $uploader = new modPWebContactUploader(array('upload_dir' => $params->get('upload_path'), 'upload_url' => $params->get('upload_url'), 'accept_file_types' => '/(\\.|\\/)(' . $params->get('upload_allowed_ext', '.+') . ')$/i', 'max_file_size' => (double) $params->get('upload_size_limit', 1) * 1024 * 1024, 'image_versions' => array(), 'delete_type' => 'POST'), false, array(1 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 3 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_3'), 4 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_4'), 6 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_6'), 7 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_7'), 8 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_8'), 'post_max_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 'max_file_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_SIZE_ERR'), 'accept_file_types' => JText::_('MOD_PWEBCONTACT_UPLOAD_TYPE_ERR')));
     $response = $uploader->handleRequest();
     if (PWEBCONTACT_DEBUG) {
         modPwebcontactHelper::setLog('Uploader exit');
     }
     return $response;
 }
开发者ID:01J,项目名称:topm,代码行数:33,代码来源:uploader.php

示例4: 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

示例5: 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

示例6: doExecute

 /**
  * doExecute
  *
  * @return  void
  *
  * @throws \Exception
  */
 protected function doExecute()
 {
     jimport('joomla.filesystem.file');
     $file = JPATH_CONFIGURATION . '/configuration.php';
     \JPath::setPermissions($file, '0644');
     $config = \JFactory::getConfig();
     $config->set('offline', $this->offline);
     $class = $config->toString('php', array('class' => 'JConfig'));
     if (!\JFile::write($file, $class)) {
         throw new \Exception('Writing config fail.');
     }
     \JPath::setPermissions($file, '0444');
     $this->out("\nSystem <info>" . strtoupper($this->name) . "</info>");
     return;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:22,代码来源:OnCommand.php

示例7: download

 /**
  * Get a page and save it as file.
  *
  * @param   string $url    A url to request.
  * @param   string $path   A system path with file name to save it.
  * @param   array  $option An option array to override CURL OPT.
  *
  * @return  Object Object with success or fail information.
  */
 public static function download($url, $path = null, $option = array())
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.path');
     $url = new \JUri($url);
     $path = \JPath::clean($path);
     // $folder_path = JPATH_ROOT.DS.'files'.DS.$url->task_id ;
     if (substr($path, -1) == DIRECTORY_SEPARATOR) {
         $file_name = basename($url);
         $file_path = $path . $file_name;
         $folder_path = $path;
     } else {
         $file_path = $path;
         $folder_path = str_replace(basename($path), '', $file_path);
     }
     \JPath::setPermissions($folder_path, 644, 755);
     if (!\is_dir($folder_path)) {
         \JFolder::create($folder_path);
     }
     $fp = fopen($file_path, 'w+');
     $ch = curl_init();
     $options = array(CURLOPT_URL => UriHelper::safe($url), CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1", CURLOPT_FOLLOWLOCATION => !ini_get('open_basedir') ? true : false, CURLOPT_FILE => $fp, CURLOPT_SSL_VERIFYPEER => false);
     // Merge option
     foreach ($option as $key => $opt) {
         if (isset($option[$key])) {
             $options[$key] = $option[$key];
         }
     }
     curl_setopt_array($ch, $options);
     curl_exec($ch);
     $errno = curl_errno($ch);
     $errmsg = curl_error($ch);
     curl_close($ch);
     fclose($fp);
     if ($errno) {
         $return = new Object();
         $return->set('errorCode', $errno);
         $return->set('errorMsg', $errmsg);
         return $return;
     } else {
         $return = new Object();
         $return->set('filePath', $file_path);
         return $return;
     }
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:55,代码来源:CurlHelper.php

示例8: genRandomFilename

function genRandomFilename($directory, $filename = '' , $extension = '', $length = 11)
{
	if (strlen($directory) < 1)
		return false;

	$directory = JPath::clean($directory);
	
	jimport('joomla.filesystem.file');
	jimport('joomla.filesystem.folder');

	if (!JFile::exists($directory)){
		JFolder::create( $directory);
		JPath::setPermissions($directory, '0777');
	}

	if (strlen($filename) > 0)
		$filename	= JFile::makeSafe($filename);

	if (!strlen($extension) > 0)
		$extension	= '';

	$dotExtension 	= $filename ? JFile::getExt($filename) : $extension;
	$dotExtension 	= $dotExtension ? '.' . $dotExtension : '';

	$map			= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
	$len 			= strlen($map);
	$stat			= stat(__FILE__);
	$randFilename	= '';

	if(empty($stat) || !is_array($stat))
		$stat = array(php_uname());

	mt_srand(crc32(microtime() . implode('|', $stat)));
	for ($i = 0; $i < $length; $i ++) {
		$randFilename .= $map[mt_rand(0, $len -1)];
	}

	$randFilename .= $dotExtension;

	if (JFile::exists($directory . DS . $randFilename)) {
		genRandomFilename($directory, $filename, $extension, $length);
	}

	return $randFilename;
}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:45,代码来源:file.php

示例9: resize

 function resize($src, $dest = null, $width, $height, $quality, $sx = null, $sy = null, $sw = null, $sh = null)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     require_once dirname(__FILE__) . DS . 'wideimage' . DS . 'WideImage.php';
     if (!isset($dest) || $dest == '') {
         $dest = $src;
     }
     $ext = strtolower(JFile::getExt($src));
     $src = @JFile::read($src);
     if ($src) {
         $image = @WideImage::loadFromString($src);
         // cropped thumbnail
         if (($sx || $sy) && $sw && $sh) {
             $result = @$image->crop($sx, $sy, $sw, $sh)->resize($width, $height, 'fill');
         } else {
             $result = @$image->resize($width, $height);
         }
         switch ($ext) {
             case 'jpg':
             case 'jpeg':
                 $quality = intval($quality);
                 if ($this->get('ftp', 0)) {
                     @JFile::write($dest, $result->asString($ext, $quality));
                 } else {
                     @$result->saveToFile($dest, $quality);
                 }
                 break;
             default:
                 if ($this->get('ftp', 0)) {
                     @JFile::write($dest, $result->asString($ext));
                 } else {
                     @$result->saveToFile($dest);
                 }
                 break;
         }
         unset($image);
         unset($result);
     }
     if (file_exists($dest)) {
         @JPath::setPermissions($dest);
         return $dest;
     }
     return false;
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:45,代码来源:editor.php

示例10: 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

示例11: up

 /**
  * Up
  **/
 public function up()
 {
     // Update configuration, replacing mysql with pdo
     $configuration = file_get_contents(PATH_ROOT . DS . 'configuration.php');
     $configuration = preg_replace('/(var \\$dbtype[\\s]*=[\\s]*[\'"]*)mysql([\'"]*)/', '$1pdo$2', $configuration);
     // The configuration file typically doesn't even give write permissions to the owner
     // Change that and then write it out
     $permissions = substr(decoct(fileperms(PATH_ROOT . DS . 'configuration.php')), 2);
     if (substr($permissions, 1, 1) != '6') {
         \JPath::setPermissions(PATH_ROOT . DS . 'configuration.php', substr_replace($permissions, '6', 1, 1));
     }
     if (!file_put_contents(PATH_ROOT . DS . 'configuration.php', $configuration)) {
         $this->setError('Unable to write out new configuration file: permission denied', 'warning');
         return false;
     }
     // Change permissions back to what they were before
     \JPath::setPermissions(PATH_ROOT . DS . 'configuration.php', $permissions);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:21,代码来源:Migration20150330124145Core.php

示例12: delete

 function delete(&$id)
 {
     $element = $this->get(reset($id));
     if (!$element) {
         return false;
     }
     jimport('joomla.filesystem.file');
     if (!JFile::exists($element->override)) {
         return true;
     }
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     if (!$ftp['enabled'] && !JPath::setPermissions($element->override, '0755')) {
         JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('FILE_NOT_WRITABLE', $element->override));
     }
     $result = JFile::delete($element->override);
     return $result;
 }
开发者ID:rodhoff,项目名称:MNW,代码行数:19,代码来源:view.php

示例13: display

 public function display()
 {
     //Prepare MediaHelper
     JLoader::register('MediaHelper', JPATH_ROOT . '/components/com_media/helpers/media.php');
     //Set the cache expire, which is 3 months in seconds
     $this->expires = 7889231;
     $item = $this->getModel()->getItem();
     $image = $this->getModel()->getImage();
     if (is_a($image, 'ComNinjaHelperImage')) {
         $path = $image->file;
     } else {
         $path = $image;
         $image = KFactory::get('admin::com.ninja.helper.image', array('image' => $path));
     }
     //$this->mimetype = 'image/'.MediaHelper::getTypeIcon($image->file);
     $this->mimetype = $image->mime;
     $identifier = $this->getIdentifier();
     $cache = JPATH_ROOT . '/cache/com_' . $identifier->package . '/' . KInflector::pluralize($this->getName());
     $cache .= '/' . $item->id . '/' . $identifier->name . '&' . urldecode(http_build_query($image->actions)) . '.' . $image->ext;
     if (!JFile::exists($cache)) {
         //To avoid "image directory unwritable" messages
         JFile::write($cache, '');
         $image->save($cache);
         JPath::setPermissions($cache);
     } else {
         //Time since created, in seconds
         $mtime = filemtime($cache);
         $created = time() - date('U', $mtime);
         //Set modified since header
         //header('Last-Modified: '.gmdate("D, d M Y H:i:s", $mtime).' GMT');
         if ($created > $this->expires) {
             //To avoid permission errors on some systems, delete the image first instead of overwriting
             JFile::delete($cache);
             $image->save($cache);
             JPath::setPermissions($cache);
         }
     }
     $this->disposition = 'inline';
     $this->output = JFile::read($cache);
     $this->filename = basename($path);
     return parent::display();
 }
开发者ID:ravenlife,项目名称:Ninja-Framework,代码行数:42,代码来源:image.php

示例14: checkDirectory

 /**
  * Check if the path exists, and if not, tries to create it
  * @param string $dir
  * @param bool $create
  */
 function checkDirectory($dir, $create = true)
 {
     $return = true;
     if (!($exists = JFolder::exists($dir))) {
         if ($create) {
             if (!($return = JFolder::create($dir))) {
                 self::setError("Attempted to Create Dir But Failed");
             }
         } else {
             $return = false;
             self::setError("Dir Does Not Exist and Did Not Attempt to Create");
         }
     }
     if (!is_writable($dir)) {
         if (!($change = JPath::setPermissions($dir))) {
             self::setError("Changing Permissions on Dir Failed");
         }
     }
     return $return;
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:25,代码来源:helper.php

示例15: 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


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