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


PHP JFTP::getInstance方法代码示例

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


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

示例1: setCredentials

 /**
  * Method to set client login credentials
  *
  * @param   string  $client  Client name, currently only 'ftp' is supported
  * @param   string  $user    Username
  * @param   string  $pass    Password
  *
  * @return  boolean  True if the given login credentials have been set and are valid
  *
  * @since   11.1
  */
 public static function setCredentials($client, $user, $pass)
 {
     $return = false;
     $client = strtolower($client);
     // Test if the given credentials are valid
     switch ($client) {
         case 'ftp':
             $config = JFactory::getConfig();
             $options = array('enabled' => $config->get('ftp_enable'), 'host' => $config->get('ftp_host'), 'port' => $config->get('ftp_port'));
             if ($options['enabled']) {
                 jimport('joomla.client.ftp');
                 $ftp = JFTP::getInstance($options['host'], $options['port']);
                 // Test the conection and try to log in
                 if ($ftp->isConnected()) {
                     if ($ftp->login($user, $pass)) {
                         $return = true;
                     }
                     $ftp->quit();
                 }
             }
             break;
         default:
             break;
     }
     if ($return) {
         // Save valid credentials to the session
         $session = JFactory::getSession();
         $session->set($client . '.user', $user, 'JClientHelper');
         $session->set($client . '.pass', $pass, 'JClientHelper');
         // Force re-creation of the data saved within JClientHelper::getCredentials()
         JClientHelper::getCredentials($client, true);
     }
     return $return;
 }
开发者ID:Radek-Suski,项目名称:joomla-platform,代码行数:45,代码来源:helper.php

示例2: dgChmod

function dgChmod($dir, $mode = 0755)
{
    static $ftpOptions;
    if (!isset($ftpOptions)) {
        jimport('joomla.client.helper');
        $ftpOptions = JClientHelper::getCredentials('ftp');
    }
    if ($ftpOptions['enabled'] == 1) {
        jimport('joomla.client.ftp');
        $ftp = JFTP::getInstance($ftpOptions['host'], $ftpOptions['port'], null, $ftpOptions['user'], $ftpOptions['pass']);
        $dir = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dir), '/');
        return $ftp->chmod($dir, $mode);
    } else {
        return true;
    }
}
开发者ID:j0rg3m414,项目名称:centerar,代码行数:16,代码来源:images.datsogallery.php

示例3: getSourceFtp

 public static function getSourceFtp()
 {
     $params = JComponentHelper::getParams('com_vmmigrate');
     $ftp_active = $params->get('ftp_enable', 0);
     $ftp_host = $params->get('ftp_host', '');
     $ftp_port = $params->get('ftp_port', '');
     $ftp_user = $params->get('ftp_user', '');
     $ftp_pass = $params->get('ftp_pass', '');
     $ftp_root = $params->get('ftp_root', '');
     $ftp_root = rtrim($ftp_root, "/");
     $ftp_root = '/' . ltrim($ftp_root, "/");
     jimport('joomla.client.ftp');
     $source_ftp = JFTP::getInstance($ftp_host, $ftp_port, array(), $ftp_user, $ftp_pass);
     //$source_ftp->chdir($ftp_root);
     return $source_ftp;
 }
开发者ID:naka211,项目名称:compac,代码行数:16,代码来源:filesystem.php

示例4: jimport

 /**
  * @return JFTP handle
  */
 function &getFtpHandle()
 {
     static $ftp = null;
     if (is_null($ftp)) {
         // Initialize variables
         jimport('joomla.client.helper');
         $FTPOptions = JClientHelper::getCredentials('ftp');
         if ($FTPOptions['enabled'] == 1) {
             // Connect the FTP client
             jimport('joomla.client.ftp');
             $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
         } else {
             $ftp = false;
         }
     }
     return $ftp;
 }
开发者ID:alphashuro,项目名称:audeprac,代码行数:20,代码来源:jd_ftp.php

示例5: _write

 /**
  * @package   AdminTools
  *
  * @copyright Copyright (c)2010-2011 Nicholas K. Dionysopoulos
  * @license   GNU General Public License version 3, or later
  *
  * @param string $file
  * @param string $buffer
  *
  * @return boolean
  */
 static function _write($file, $buffer)
 {
     // Initialize variables
     jimport('joomla.client.helper');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.path');
     $FTPOptions = JClientHelper::getCredentials('ftp');
     // If the destination directory doesn't exist we need to create it
     if (!file_exists(dirname($file))) {
         JFolder::create(dirname($file));
     }
     if ($FTPOptions['enabled'] == 1) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $ftp = JClientFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], NULL, $FTPOptions['user'], $FTPOptions['pass']);
         } else {
             $ftp = JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], NULL, $FTPOptions['user'], $FTPOptions['pass']);
         }
         // Translate path for the FTP account and use FTP write buffer to
         // file
         $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/');
         $ret = $ftp->write($file, $buffer);
     } else {
         if (!is_writable($file)) {
             chmod($file, 0755);
         }
         if (!is_writable($file)) {
             chmod($file, 0777);
         }
         $ret = @file_put_contents($file, $buffer);
         chmod($file, 0644);
     }
     if (!$ret) {
         jimport('joomla.filesystem.file');
         JFile::write($file, $buffer);
     }
     return $ret;
 }
开发者ID:ranamimran,项目名称:persivia,代码行数:51,代码来源:bfFilesystem.php

示例6: _createConfiguration


//.........这里部分代码省略.........
     $registry->set('gzip', 0);
     $registry->set('error_reporting', 'none');
     $registry->set('helpurl', 'http://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}');
     $registry->set('ftp_host', $options->ftp_host);
     $registry->set('ftp_port', $options->ftp_port);
     $registry->set('ftp_user', $options->ftp_save ? $options->ftp_user : '');
     $registry->set('ftp_pass', $options->ftp_save ? $options->ftp_pass : '');
     $registry->set('ftp_root', $options->ftp_save ? $options->ftp_root : '');
     $registry->set('ftp_enable', $options->ftp_enable);
     /* Locale Settings */
     $registry->set('offset', 'UTC');
     $registry->set('offset_user', 'UTC');
     /* Mail Settings */
     $registry->set('mailer', 'mail');
     $registry->set('mailfrom', $options->admin_email);
     $registry->set('fromname', 'PlayJoomServer');
     $registry->set('sendmail', '/usr/sbin/sendmail');
     $registry->set('smtpauth', 0);
     $registry->set('smtpuser', '');
     $registry->set('smtppass', '');
     $registry->set('smtphost', 'localhost');
     $registry->set('smtpsecure', 'none');
     $registry->set('smtpport', '25');
     /* Cache Settings */
     $registry->set('caching', 0);
     $registry->set('cache_handler', 'file');
     $registry->set('cachetime', 15);
     /* Meta Settings */
     $registry->set('MetaDesc', '');
     $registry->set('MetaKeys', '');
     $registry->set('MetaTitle', 1);
     $registry->set('MetaAuthor', 1);
     $registry->set('MetaVersion', 0);
     $registry->set('robots', '');
     /* SEO Settings */
     $registry->set('sef', 0);
     $registry->set('sef_rewrite', 0);
     $registry->set('sef_suffix', 0);
     $registry->set('unicodeslugs', 0);
     /* Feed Settings */
     $registry->set('feed_limit', 10);
     $registry->set('log_path', JPATH_ROOT . '/logs');
     $registry->set('tmp_path', JPATH_ROOT . '/tmp');
     /* Session Setting */
     $registry->set('lifetime', 15);
     $registry->set('session_handler', 'database');
     // Generate the configuration class string buffer.
     $buffer = $registry->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
     // Build the configuration file path.
     $path = JPATH_CONFIGURATION . '/configuration.php';
     // Determine if the configuration file path is writable.
     if (file_exists($path)) {
         $canWrite = is_writable($path);
     } else {
         $canWrite = is_writable(JPATH_CONFIGURATION . '/');
     }
     /*
      * If the file exists but isn't writable OR if the file doesn't exist and the parent directory
      * is not writable we need to use FTP
      */
     $useFTP = false;
     if (file_exists($path) && !is_writable($path) || !file_exists($path) && !is_writable(dirname($path) . '/')) {
         $useFTP = true;
     }
     // Check for safe mode
     if (ini_get('safe_mode')) {
         $useFTP = true;
     }
     // Enable/Disable override
     if (!isset($options->ftpEnable) || $options->ftpEnable != 1) {
         $useFTP = false;
     }
     if ($useFTP == true) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         jimport('joomla.filesystem.path');
         $ftp = JFTP::getInstance($options->ftp_host, $options->ftp_port);
         $ftp->login($options->ftp_user, $options->ftp_pass);
         // Translate path for the FTP account
         $file = JPath::clean(str_replace(JPATH_CONFIGURATION, $options->ftp_root, $path), '/');
         // Use FTP write buffer to file
         if (!$ftp->write($file, $buffer)) {
             // Set the config string to the session.
             $session = JFactory::getSession();
             $session->set('setup.config', $buffer);
         }
         $ftp->quit();
     } else {
         if ($canWrite) {
             file_put_contents($path, $buffer);
             $session = JFactory::getSession();
             $session->set('setup.config', null);
         } else {
             // Set the config string to the session.
             $session = JFactory::getSession();
             $session->set('setup.config', $buffer);
         }
     }
     return true;
 }
开发者ID:TFToto,项目名称:playjoom-builds,代码行数:101,代码来源:configuration.php

示例7: _outputEnd

 /**
  * Finalize export output
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		private
  * @param
  * @return 		void
  * @since 		3.0
  */
 private function _outputEnd()
 {
     $jinput = JFactory::getApplication()->input;
     $csvilog = $jinput->get('csvilog', null, null);
     $template = $jinput->get('template', null, null);
     $exportfilename = $jinput->get('export.filename', null, 'string');
     jimport('joomla.filesystem.file');
     switch ($template->get('exportto', 'general')) {
         case 'todownload':
             break;
         case 'tofile':
             $csvilog->AddStats('information', JText::sprintf('COM_CSVI_EXPORTFILE_CREATED', $exportfilename));
             fclose($jinput->get('handle', null, null));
             break;
         case 'toftp':
             // Close the file handle
             fclose($jinput->get('handle', null, null));
             // Start the FTP
             jimport('joomla.client.ftp');
             $ftp = JFTP::getInstance($template->get('ftphost', 'general', '', 'string'), $template->get('ftpport', 'general'), null, $template->get('ftpusername', 'general', '', 'string'), $template->get('ftppass', 'general', '', 'string'));
             $ftp->chdir($template->get('ftproot', 'general', '/', 'string'));
             $ftp->store($exportfilename);
             $ftp->quit();
             // Remove the temporary file
             JFile::delete($exportfilename);
             $csvilog->AddStats('information', JText::sprintf('COM_CSVI_EXPORTFILE_CREATED', $exportfilename));
             break;
         case 'toemail':
             fclose($jinput->get('handle', null, null));
             $this->_getMailer();
             // Add the email address
             $addresses = explode(',', $template->get('export_email_addresses', 'email'));
             foreach ($addresses as $address) {
                 if (!empty($address)) {
                     $this->mailer->AddAddress($address);
                 }
             }
             $addresses_cc = explode(',', $template->get('export_email_addresses_cc', 'email'));
             if (!empty($addresses_cc)) {
                 foreach ($addresses_cc as $address) {
                     if (!empty($address)) {
                         $this->mailer->AddCC($address);
                     }
                 }
             }
             $addresses_bcc = explode(',', $template->get('export_email_addresses_bcc', 'email'));
             if (!empty($addresses_bcc)) {
                 foreach ($addresses_bcc as $address) {
                     if (!empty($address)) {
                         $this->mailer->AddBCC($address);
                     }
                 }
             }
             // Mail submitter
             $htmlmsg = '<html><body>' . $this->_getRelToAbs($template->get('export_email_body', 'email')) . '</body></html>';
             $this->mailer->setBody($htmlmsg);
             $this->mailer->setSubject($template->get('export_email_subject', 'email'));
             // Add the attachemnt
             $this->mailer->AddAttachment($exportfilename);
             // Send the mail
             $sendmail = $this->mailer->Send();
             if (is_a($sendmail, 'JException')) {
                 $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_NO_MAIL_SEND', $sendmail->getMessage()));
             } else {
                 $csvilog->AddStats('information', JText::_('COM_CSVI_MAIL_SEND'));
             }
             // Clear the mail details
             $this->mailer->ClearAddresses();
             // Remove the temporary file
             JFile::delete($exportfilename);
             $csvilog->AddStats('information', JText::sprintf('COM_CSVI_EXPORTFILE_CREATED', $exportfilename));
             break;
     }
 }
开发者ID:spiridonov-oa,项目名称:SheinCandles,代码行数:86,代码来源:exportfile.php

示例8: Joom_Chmod

/**
 * Changes the permissions of a directory (or file)
 * either by the FTP-Layer if enabled
 * or by JPath::setPermissions (chmod())
 *
 * not sure but probable: J! 1.6 will use
 * FTP-Layer automatically in setPermissions
 * so Joom_Chmod will become unnecessary
 *
 * @param string $dir directory
 * @param int or octal number $mode permissions which will be applied to $dir
 * @return boolean true on success, false otherwise
 */
function Joom_Chmod($dir, $mode = 0644)
{
    static $ftpOptions;
    if (!isset($ftpOptions)) {
        // Initialize variables
        jimport('joomla.client.helper');
        $ftpOptions = JClientHelper::getCredentials('ftp');
    }
    if ($ftpOptions['enabled'] == 1) {
        // Connect the FTP client
        jimport('joomla.client.ftp');
        $ftp =& JFTP::getInstance($ftpOptions['host'], $ftpOptions['port'], null, $ftpOptions['user'], $ftpOptions['pass']);
        // Translate path to FTP path
        $dir = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dir), '/');
        return $ftp->chmod($dir, $mode);
    } else {
        return true;
    }
}
开发者ID:planetangel,项目名称:Planet-Angel-Website,代码行数:32,代码来源:common.joomgallery.php

示例9: upload

 function upload($src, $dest)
 {
     // Initialize variables
     jimport('joomla.client.helper');
     $FTPOptions = JClientHelper::getCredentials('ftp');
     $ret = false;
     if (is_uploaded_file($src)) {
         if ($FTPOptions['enabled'] == 1 && self::exists($dest) && !CKunenaPath::isOwner($dest)) {
             @chmod($dest, 0777);
         }
         $ret = parent::upload($src, $dest);
         if ($FTPOptions['enabled'] == 1) {
             if ($ret === true) {
                 jimport('joomla.client.ftp');
                 $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
                 @unlink($src);
                 $ret = true;
             } else {
                 @chmod($src, 0644);
             }
         }
     } else {
         JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
     }
 }
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:25,代码来源:kunena.file.class.1.5.php

示例10: chmod

 /**
  * Change the permissions of a file, optionally using FTP
  * 
  * @param   string  $path  Absolute path to file
  * @param   int     $mode  Permissions, e.g. 0755
  * 
  * @return  boolean True on success
  *
  * @since   2.5.4
  */
 private static function chmod($path, $mode)
 {
     if (is_string($mode)) {
         $mode = octdec($mode);
         if ($mode < 0600 || $mode > 0777) {
             $mode = 0755;
         }
     }
     // Initialize variables
     jimport('joomla.client.helper');
     $ftpOptions = JClientHelper::getCredentials('ftp');
     // Check to make sure the path valid and clean
     $path = JPath::clean($path);
     if ($ftpOptions['enabled'] == 1) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         $ftp =& JFTP::getInstance($ftpOptions['host'], $ftpOptions['port'], null, $ftpOptions['user'], $ftpOptions['pass']);
     }
     if (@chmod($path, $mode)) {
         $ret = true;
     } elseif ($ftpOptions['enabled'] == 1) {
         // Translate path and delete
         jimport('joomla.client.ftp');
         $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/');
         // FTP connector throws an error
         $ret = $ftp->chmod($path, $mode);
     } else {
         return false;
     }
 }
开发者ID:albertobarquin,项目名称:cemasa,代码行数:40,代码来源:download.php

示例11: move

 /**
  * Moves a folder.
  *
  * @param   string   $src          The path to the source folder.
  * @param   string   $dest         The path to the destination folder.
  * @param   string   $path         An optional base path to prefix to the file names.
  * @param   boolean  $use_streams  Optionally use streams.
  *
  * @return  mixed  Error message on false or boolean true on success.
  *
  * @since   11.1
  */
 public static function move($src, $dest, $path = '', $use_streams = false)
 {
     // Initialise variables.
     $FTPOptions = JClientHelper::getCredentials('ftp');
     if ($path) {
         $src = JPath::clean($path . '/' . $src);
         $dest = JPath::clean($path . '/' . $dest);
     }
     if (!self::exists($src)) {
         return JText::_('JLIB_FILESYSTEM_ERROR_FIND_SOURCE_FOLDER');
     }
     if (self::exists($dest)) {
         return JText::_('JLIB_FILESYSTEM_ERROR_FOLDER_EXISTS');
     }
     if ($use_streams) {
         $stream = JFactory::getStream();
         if (!$stream->move($src, $dest)) {
             return JText::sprintf('JLIB_FILESYSTEM_ERROR_FOLDER_RENAME', $stream->getError());
         }
         $ret = true;
     } else {
         if ($FTPOptions['enabled'] == 1) {
             // Connect the FTP client
             jimport('joomla.client.ftp');
             $ftp = JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
             //Translate path for the FTP account
             $src = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $src), '/');
             $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/');
             // Use FTP rename to simulate move
             if (!$ftp->rename($src, $dest)) {
                 return JText::_('Rename failed');
             }
             $ret = true;
         } else {
             if (!@rename($src, $dest)) {
                 return JText::_('Rename failed');
             }
             $ret = true;
         }
     }
     return $ret;
 }
开发者ID:Roma48,项目名称:abazherka_old,代码行数:54,代码来源:folder.php

示例12: removeFolder

	/**
	 * @return	void
	 * @since	1.6
	 */
	public function removeFolder()
	{
		jimport('joomla.filesystem.folder');

		// Check for a valid token. If invalid, send a 403 with the error message.
		JRequest::checkToken('request') or $this->sendResponse(new JException(JText::_('JINVALID_TOKEN'), 403));

		// Get the posted config options.
		$vars = JRequest::getVar('jform', array());

		$path = JPATH_INSTALLATION;
		//check whether the folder still exists
		if (!file_exists($path)) {
			$this->sendResponse(new JException(JText::sprintf('INSTL_COMPLETE_ERROR_FOLDER_ALREADY_REMOVED'), 500));
		}

		// check whether we need to use FTP
		$useFTP = false;
		if ((file_exists($path) && !is_writable($path))) {
			$useFTP = true;
		}

		// Check for safe mode
		if (ini_get('safe_mode')) {
			$useFTP = true;
		}

		// Enable/Disable override
		if (!isset($options->ftpEnable) || ($options->ftpEnable != 1)) {
			$useFTP = false;
		}

		if ($useFTP == true) {
			// Connect the FTP client
			jimport('joomla.client.ftp');
			jimport('joomla.filesystem.path');

			$ftp = JFTP::getInstance($options->ftp_host, $options->ftp_port);
			$ftp->login($options->ftp_user, $options->ftp_pass);

			// Translate path for the FTP account
			$file = JPath::clean(str_replace(JPATH_CONFIGURATION, $options->ftp_root, $path), '/');
			$return = $ftp->delete($file);

			// Delete the extra XML file while we're at it
			if ($return) {
				$file = JPath::clean($options->ftp_root.'/joomla.xml');
				if (file_exists($file)) {
					$return = $ftp->delete($file);
				}
			}

			$ftp->quit();
		} else {
			// Try to delete the folder.
			// We use output buffering so that any error message echoed JFolder::delete
			// doesn't land in our JSON output.
			ob_start();
			$return = JFolder::delete($path) && (!file_exists(JPATH_ROOT.'/joomla.xml') || JFile::delete(JPATH_ROOT.'/joomla.xml'));
			ob_end_clean();
		}

		// If an error was encountered return an error.
		if (!$return) {
			$this->sendResponse(new JException(JText::_('INSTL_COMPLETE_ERROR_FOLDER_DELETE'), 500));
		}

		// Create a response body.
		$r = new JObject();
		$r->text = JText::_('INSTL_COMPLETE_FOLDER_REMOVED');

		// Send the response.
		$this->sendResponse($r);
	}
开发者ID:realityking,项目名称:JAJAX,代码行数:78,代码来源:setup.json.php

示例13: resize

 static function resize($imgSrc, $imgDest, $dWidth, $dHeight, $crop = true, $quality = 100)
 {
     $info = getimagesize($imgSrc, $imageinfo);
     $sWidth = $info[0];
     $sHeight = $info[1];
     if ($sHeight / $sWidth > $dHeight / $dWidth) {
         $width = $sWidth;
         $height = round($dHeight * $sWidth / $dWidth);
         $sx = 0;
         $sy = round(($sHeight - $height) / 3);
     } else {
         $height = $sHeight;
         $width = round($sHeight * $dWidth / $dHeight);
         $sx = round(($sWidth - $width) / 2);
         $sy = 0;
     }
     if (!$crop) {
         $sx = 0;
         $sy = 0;
         $width = $sWidth;
         $height = $sHeight;
     }
     //echo "$sx:$sy:$width:$height";die();
     $ext = str_replace('image/', '', $info['mime']);
     $imageCreateFunc = self::getImageCreateFunction($ext);
     $imageSaveFunc = self::getImageSaveFunction(JFile::getExt($imgDest));
     $sImage = $imageCreateFunc($imgSrc);
     $dImage = imagecreatetruecolor($dWidth, $dHeight);
     // Make transparent
     if ($ext == 'png') {
         imagealphablending($dImage, false);
         imagesavealpha($dImage, true);
         $transparent = imagecolorallocatealpha($dImage, 255, 255, 255, 127);
         imagefilledrectangle($dImage, 0, 0, $dWidth, $dHeight, $transparent);
     }
     imagecopyresampled($dImage, $sImage, 0, 0, $sx, $sy, $dWidth, $dHeight, $width, $height);
     // Initialise variables.
     $FTPOptions = JClientHelper::getCredentials('ftp');
     if ($FTPOptions['enabled'] == 1) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         $ftp = JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], array(), $FTPOptions['user'], $FTPOptions['pass']);
         ob_start();
         if ($ext == 'png') {
             $imageSaveFunc($dImage, null, 9);
         } else {
             if ($ext == 'gif') {
                 $imageSaveFunc($dImage, null);
             } else {
                 $imageSaveFunc($dImage, null, $quality);
             }
         }
         $buffer = ob_get_contents();
         ob_end_clean();
         // Translate path for the FTP account and use FTP write buffer to file
         $imgDest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $imgDest), '/');
         $ret = $ftp->write($imgDest, $buffer);
         //$ftp->chmode($imgDest,0755);
     } else {
         if ($ext == 'png') {
             $imageSaveFunc($dImage, $imgDest, 9);
         } else {
             if ($ext == 'gif') {
                 $imageSaveFunc($dImage, $imgDest);
             } else {
                 $imageSaveFunc($dImage, $imgDest, $quality);
             }
         }
     }
 }
开发者ID:Tommar,项目名称:remate,代码行数:70,代码来源:images.php

示例14: chmod

 /**
  * Changes the permissions of a directory (or file)
  * either by the FTP-Layer if enabled
  * or by JPath::setPermissions (chmod()).
  *
  * Not sure but probable: J! 1.6 will use
  * FTP-Layer automatically in setPermissions
  * so JoomFile::chmod will become unnecessary.
  *
  * @param   string  $path   Directory or file for which the permissions will be changed
  * @param   string  $mode   Permissions which will be applied to $path
  * @param   boolean $is_dir True if the given path is a directory, false if it is a file
  * @return  boolean True on success, false otherwise
  * @since   1.5.0
  */
 public static function chmod($path, $mode, $is_dir = false)
 {
     static $ftpOptions;
     if (!isset($ftpOptions)) {
         // Initialize variables
         jimport('joomla.client.helper');
         $ftpOptions = JClientHelper::getCredentials('ftp');
     }
     if ($ftpOptions['enabled'] == 1) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         $ftp = JFTP::getInstance($ftpOptions['host'], $ftpOptions['port'], array(), $ftpOptions['user'], $ftpOptions['pass']);
         // Translate path to FTP path
         $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/');
         return $ftp->chmod($path, $mode);
     } else {
         if ($is_dir) {
             return JPath::setPermissions(JPath::clean($path), null, $mode);
         }
         return JPath::setPermissions(JPath::clean($path), $mode, null);
     }
 }
开发者ID:pabloarias,项目名称:JoomGallery,代码行数:37,代码来源:file.php

示例15: array

if (is_callable("jimport")) {
    global $CB_AdminFileFunctions;
    /** @noinspection PhpUnusedParameterInspection */
    $CB_AdminFileFunctions = array('_constructor' => function (&$functions) {
        jimport('joomla.filesystem.file');
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.archive');
        jimport('joomla.filesystem.path');
    }, 'mkdir' => array('JFolder', 'create'), 'rmdir' => array('JFolder', 'delete'), 'is_dir' => null, 'opendir' => null, 'readdir' => null, 'closedir' => null, 'rename' => function ($old_name, $new_name) {
        if (is_file($old_name)) {
            return JFile::move($old_name, $new_name);
        } elseif (is_dir($old_name)) {
            return JFolder::move($old_name, $new_name);
        } else {
            return false;
        }
    }, 'file_exists' => null, 'is_writable' => null, 'is_file' => null, 'chmod' => function ($pathname, $mode) {
        jimport('joomla.client.helper');
        $FTPOptions = JClientHelper::getCredentials('ftp');
        if ($FTPOptions['enabled'] == 1) {
            jimport('joomla.client.ftp');
            // JFTPClient is Joomla 3.x-only, not in 2.5.
            $ftp = JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], array(), $FTPOptions['user'], $FTPOptions['pass']);
            //Translate path to FTP account:
            $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $pathname), '/');
            return $ftp->chmod($dest, $mode);
        } else {
            return @chmod($pathname, $mode);
        }
    }, 'chmoddir' => null, 'copy' => array('JFile', 'copy'), 'copydir' => array('JFolder', 'copy'), 'unlink' => array('JFile', 'delete'), 'file_put_contents' => array('JFile', 'write'), 'move_uploaded_file' => array('JFile', 'upload'));
}
开发者ID:Raul-mz,项目名称:web-erpcya,代码行数:31,代码来源:cbAdminFileSystem.php


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