• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP JFTP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了JFTP类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: move

 /**
  * Moves a folder.
  *
  * @param string The path to the source folder.
  * @param string The path to the destination folder.
  * @param string An optional base path to prefix to the file names.
  * @return mixed Error message on false or boolean true on success.
  * @since 1.5
  */
 function move($src, $dest, $path = '', $use_streams = false)
 {
     // Initialise variables.
     jimport('joomla.client.helper');
     $FTPOptions = JClientHelper::getCredentials('ftp');
     if ($path) {
         $src = JPath::clean($path . DS . $src);
         $dest = JPath::clean($path . DS . $dest);
     }
     if (!JFolder::exists($src)) {
         return JText::_('Cannot find source folder');
     }
     if (JFolder::exists($dest)) {
         return JText::_('Folder already exists');
     }
     if ($use_streams) {
         $stream =& JFactory::getStream();
         if (!$stream->move($src, $dest)) {
             return JText::_('Rename failed') . ': ' . $stream->getError();
             //return JError::raiseError(-1, JText::_('Rename failed').': '. $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:joebushi,项目名称:joomla,代码行数:53,代码来源:folder.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: saveConfig

 /**
  * Save the configuration information
  *
  * @return	boolean True if successful
  * @access	public
  * @since	1.5
  */
 function saveConfig()
 {
     global $mainframe;
     $vars =& $this->getVars();
     $lang =& JFactory::getLanguage();
     // Import authentication library
     jimport('joomla.user.helper');
     // Set some needed variables
     $vars['siteUrl'] = JURI::root();
     $vars['secret'] = JUserHelper::genRandomPassword(16);
     $vars['offline'] = JText::_('STDOFFLINEMSG');
     $vars['errormsg'] = JText::_('STDERRORMSG');
     $vars['metadesc'] = JText::_('STDMETADESC');
     $vars['metakeys'] = JText::_('STDMETAKEYS');
     $vars['tmp_path'] = JPATH_ROOT . DS . 'tmp';
     $vars['log_path'] = JPATH_ROOT . DS . 'logs';
     // set default language
     $forced = $mainframe->getLocalise();
     if (empty($forced['lang'])) {
         $vars['deflang'] = 'en-GB';
         $vars['bclang'] = 'english';
     } else {
         $vars['deflang'] = $forced['lang'];
         $vars['bclang'] = $lang->getBackwardLang();
     }
     if (empty($forced['helpurl'])) {
         $vars['helpurl'] = 'http://help.joomla.org';
     } else {
         $vars['helpurl'] = $forced['helpurl'];
     }
     // If FTP has not been enabled, set the value to 0
     if (!isset($vars['ftpEnable'])) {
         $vars['ftpEnable'] = 0;
     }
     /*
      * Trim the last slash from the FTP root, as the FTP root usually replaces JPATH_ROOT.
      * If the path had a trailing slash, this would lead to double slashes, like "/joomla//configuration.php"
      */
     if (isset($vars['ftpRoot'])) {
         $vars['ftpRoot'] = rtrim($vars['ftpRoot'], '/');
     }
     switch ($vars['DBtype']) {
         case 'mssql':
             $vars['ZERO_DATE'] = '1/01/1990';
             break;
         default:
             $vars['ZERO_DATE'] = '0000-00-00 00:00:00';
             break;
     }
     JInstallationHelper::createAdminUser($vars);
     /**
      * Write the configuration file
      */
     jimport('joomla.template.template');
     $tmpl = new JTemplate();
     $tmpl->applyInputFilter('ShortModifiers');
     // load the wrapper and common templates
     $tmpl->setRoot(JPATH_BASE . DS . 'template' . DS . 'tmpl');
     $tmpl->readTemplatesFromFile('configuration.html');
     $tmpl->addVars('configuration', $vars, 'var_');
     if (empty($vars['ftpSavePass'])) {
         $tmpl->addVar('configuration', 'var_ftpuser', '');
         $tmpl->addVar('configuration', 'var_ftppassword', '');
     }
     $buffer = $tmpl->getParsedTemplate('configuration');
     $path = JPATH_CONFIGURATION . DS . 'configuration.php';
     if (file_exists($path)) {
         $canWrite = is_writable($path);
     } else {
         $canWrite = is_writable(JPATH_CONFIGURATION . DS);
     }
     /*
      * 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
      */
     $ftpFlag = false;
     if (file_exists($path) && !is_writable($path) || !file_exists($path) && !is_writable(dirname($path) . '/')) {
         $ftpFlag = true;
     }
     // Check for safe mode
     if (ini_get('safe_mode')) {
         $ftpFlag = true;
     }
     // Enable/Disable override
     if (!isset($vars['ftpEnable']) || $vars['ftpEnable'] != 1) {
         $ftpFlag = false;
     }
     if ($ftpFlag == true) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         jimport('joomla.filesystem.path');
         $ftp =& JFTP::getInstance($vars['ftpHost'], $vars['ftpPort']);
         $ftp->login($vars['ftpUser'], $vars['ftpPassword']);
//.........这里部分代码省略.........
开发者ID:kumarsivarajan,项目名称:jaderp,代码行数:101,代码来源:model.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


示例16: deletePath

 private function deletePath($path)
 {
     // Initialize variables
     JLoader::import('joomla.client.helper');
     $ftpOptions = JClientHelper::getCredentials('ftp');
     // Check to make sure the path valid and clean
     $n_path = @realpath($path);
     $path = empty($n_path) ? $path : $n_path;
     if ($ftpOptions['enabled'] == 1) {
         // Connect the FTP client
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $ftp = JClientFTP::getInstance($ftpOptions['host'], $ftpOptions['port'], array(), $ftpOptions['user'], $ftpOptions['pass']);
         } else {
             $ftp = JFTP::getInstance($ftpOptions['host'], $ftpOptions['port'], array(), $ftpOptions['user'], $ftpOptions['pass']);
         }
     }
     if (@unlink($path)) {
         $ret = true;
     } elseif (@rmdir($path)) {
         $ret = true;
     } elseif ($ftpOptions['enabled'] == 1) {
         if (substr($path, 0, strlen(JPATH_ROOT)) !== JPATH_ROOT) {
             return false;
         }
         // Translate path and delete
         $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/');
         // FTP connector throws an error
         $ret = $ftp->delete($path);
     } else {
         return false;
     }
     return $ret;
 }
开发者ID:neoandrew1000,项目名称:crao_journal,代码行数:33,代码来源:cleantmp.php


示例17: validateFile


//.........这里部分代码省略.........
             if ($urlfile) {
                 if (CsviHelper::fileExistsRemote($urlfile)) {
                     // Copy the remote file to a local location
                     if (JFolder::create($folder)) {
                         if (touch($folder . '/' . $tempfile)) {
                             if (JFile::write($folder . '/' . $tempfile, JFile::read($urlfile))) {
                                 $csvilog->addDebug(JText::sprintf('COM_CSVI_RETRIEVE_FROM_URL', $urlfile));
                                 $jinput->set('csv_file', $folder . '/' . $tempfile);
                                 $jinput->set('upload_file_error', false);
                                 $this->extension = JFile::getExt($tempfile);
                             } else {
                                 $csvilog->AddStats('incorrect', JText::_('COM_CSVI_CANNOT_READ_FROM_URL'));
                                 return false;
                             }
                         } else {
                             $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_CANNOT_CREATE_TEMP_FILE', $folder . '/' . $tempfile));
                             return false;
                         }
                     } else {
                         $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_CANNOT_CREATE_TEMP_FOLDER', $folder));
                         return false;
                     }
                 } else {
                     $csvilog->AddStats('incorrect', JText::_('COM_CSVI_CANNOT_READ_FROM_URL'));
                     return false;
                 }
             } else {
                 $csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_FILENAME_GIVEN'));
                 return false;
             }
             break;
         case 'fromftp':
             // The temporary folder
             $folder = $this->_unpackpath . '/' . time();
             $ftpfile = $template->get('ftpfile', 'general', false);
             if ($ftpfile) {
                 // Create the output file
                 if (JFolder::create($folder)) {
                     if (touch($folder . '/' . $ftpfile)) {
                         // Start the FTP
                         jimport('joomla.client.ftp');
                         $ftp = JFTP::getInstance($template->get('ftphost', 'general'), $template->get('ftpport', 'general'), null, $template->get('ftpusername', 'general'), $template->get('ftppass', 'general'));
                         if ($ftp->get($folder . '/' . $ftpfile, $template->get('ftproot', 'general', '/') . $ftpfile)) {
                             $csvilog->addDebug(JText::sprintf('COM_CSVI_RETRIEVE_FROM_FTP', $template->get('ftproot', 'general', '/') . $ftpfile));
                             $jinput->set('csv_file', $folder . '/' . $ftpfile);
                             $jinput->set('upload_file_error', false);
                             $this->extension = JFile::getExt($ftpfile);
                         } else {
                             $csvilog->AddStats('incorrect', JText::_('COM_CSVI_CANNOT_READ_FROM_FTP'));
                             return false;
                         }
                         $ftp->quit();
                     } else {
                         $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_CANNOT_CREATE_TEMP_FILE', $folder . '/' . $ftpfile));
                         return false;
                     }
                 } else {
                     $csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_CANNOT_CREATE_TEMP_FOLDER', $folder));
                     return false;
                 }
             } else {
                 $csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_FILENAME_GIVEN'));
                 return false;
             }
             break;
             // No file given
         // No file given
         default:
             $csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_FILE_PROVIDED'));
             return false;
             break;
     }
     // Make sure txt files are not ignored
     if ($this->extension == 'txt') {
         $this->extension = 'csv';
     }
     // Set the filename
     $csv_file = $jinput->get('csv_file', '', 'string');
     if (JFile::exists($csv_file)) {
         $this->filename = JPath::clean($csv_file, '/');
         // Store the users filename for display purposes
         $csvilog->setFilename(basename($this->filename));
     } else {
         $csvilog->addDebug(JText::sprintf('COM_CSVI_LOCAL_FILE_DOESNT_EXIST', $jinput->get('csv_file')));
         return false;
     }
     if (in_array($this->extension, $this->suffixes)) {
         $this->valid_extension = true;
     } else {
         // Test the mime type
         if (!in_array($this->extension, $this->mimetypes)) {
             $csvilog->AddStats('information', JText::sprintf('COM_CSVI_EXTENSION_NOT_ACCEPTED', $this->extension));
             return false;
         }
     }
     // Debug message to know what filetype the user is uploading
     $csvilog->addDebug(JText::sprintf('COM_CSVI_IMPORT_FILETYPE', $this->extension));
     // All is fine
     return true;
 }
开发者ID:spiridonov-oa,项目名称:SheinCandles,代码行数:101,代码来源:file.php


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


示例19: copy

 
                       
                    
                    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP JFactory类代码示例发布时间:2022-05-23
下一篇:
PHP JFBCFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap