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

PHP Mage_Connect_Ftp类代码示例

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

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



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

示例1: save

 /**
  * Save file
  *
  * @return Maged_Model_Config
  */
 public function save()
 {
     if (!is_writable($this->getFilename()) && is_file($this->getFilename()) || dirname($this->getFilename()) != '' && !is_writable(dirname($this->getFilename()))) {
         if (isset($this->_data['ftp']) && !empty($this->_data['ftp']) && strlen($this->get('downloader_path')) > 0) {
             $confFile = $this->get('downloader_path') . DIRECTORY_SEPARATOR . basename($this->getFilename());
             $ftpObj = new Mage_Connect_Ftp();
             $ftpObj->connect($this->_data['ftp']);
             $tempFile = tempnam(sys_get_temp_dir(), 'configini');
             $fp = fopen($tempFile, 'w');
             foreach ($this->_data as $k => $v) {
                 fwrite($fp, $k . '=' . $v . "\n");
             }
             fclose($fp);
             $ret = $ftpObj->upload($confFile, $tempFile);
             $ftpObj->close();
         } else {
             /* @TODO: show Warning message*/
             $this->controller()->session()->addMessage('warning', 'Invalid file permissions, could not save configuration.');
             return $this;
         }
         /**/
     } else {
         $fp = fopen($this->getFilename(), 'w');
         foreach ($this->_data as $k => $v) {
             fwrite($fp, $k . '=' . $v . "\n");
         }
         fclose($fp);
     }
     return $this;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:35,代码来源:Abstract.php


示例2: store

 /**
  * Save config file on the disk or over ftp
  *
  * @return bool
  */
 public function store()
 {
     $result = false;
     if ($this->_forceSave || $this->_configLoaded || strlen($this->remote_config) > 0) {
         $data = serialize($this->toArray());
         if (strlen($this->remote_config) > 0) {
             //save config over ftp
             $confFile = $this->downloader_path . DIRECTORY_SEPARATOR . "connect.cfg";
             try {
                 $ftpObj = new Mage_Connect_Ftp();
                 $ftpObj->connect($this->remote_config);
             } catch (Exception $e) {
                 $this->_configError = 'Cannot access to deployment FTP path. ' . 'Check deployment FTP Installation path settings.';
                 return $result;
             }
             try {
                 $tempFile = tempnam(sys_get_temp_dir(), 'config');
                 $f = fopen($tempFile, "w+");
                 fwrite($f, self::HEADER);
                 fwrite($f, $data);
                 fclose($f);
             } catch (Exception $e) {
                 $this->_configError = 'Cannot access to temporary file storage to save Settings.' . 'Contact your system administrator.';
                 return $result;
             }
             try {
                 $result = $ftpObj->upload($confFile, $tempFile);
                 $ftpObj->close();
             } catch (Exception $e) {
                 $this->_configError = 'Cannot write file over FTP. ' . 'Check deployment FTP Installation path settings.';
                 return $result;
             }
             if (!$result) {
                 $this->_configError = '';
             }
         } elseif (is_file($this->_configFile) && is_writable($this->_configFile) || is_writable(getcwd())) {
             try {
                 $f = fopen($this->_configFile, "w+");
                 fwrite($f, self::HEADER);
                 fwrite($f, $data);
                 fclose($f);
                 $result = true;
             } catch (Exception $e) {
                 $result = false;
             }
         }
     }
     return $result;
 }
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:54,代码来源:Config.php


示例3: cleanCache

 protected function cleanCache()
 {
     $result = true;
     $message = '';
     try {
         if ($this->isInstalled()) {
             if (!empty($_REQUEST['clean_sessions'])) {
                 Mage::app()->cleanAllSessions();
                 $message .= 'Session cleaned successfully. ';
             }
             Mage::app()->cleanCache();
             // reinit config and apply all updates
             Mage::app()->getConfig()->reinit();
             Mage_Core_Model_Resource_Setup::applyAllUpdates();
             Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
             $message .= 'Cache cleaned successfully';
         } else {
             $result = true;
         }
     } catch (Exception $e) {
         $result = false;
         $message = "Exception during cache and session cleaning: " . $e->getMessage();
         $this->session()->addMessage('error', $message);
     }
     if ($result && $this->_getMaintenanceFlag()) {
         $maintenance_filename = 'maintenance.flag';
         $config = $this->config();
         if (!$this->isWritable() && strlen($config->__get('remote_config')) > 0) {
             $ftpObj = new Mage_Connect_Ftp();
             $ftpObj->connect($config->__get('remote_config'));
             $ftpObj->delete($maintenance_filename);
             $ftpObj->close();
         } else {
             @unlink($this->_getMaintenanceFilePath());
         }
     }
     return array('result' => $result, 'message' => $message);
 }
开发者ID:lightyoruichi,项目名称:Magento-Pre-Patched-Files,代码行数:38,代码来源:Controller.php


示例4: getRemoteModifiedFiles

 /**
  * Get remote modified files
  *
  * @param $chanName
  * @param $package
  * @param $cacheObj
  * @param Mage_Connect_Ftp $ftp
  * @return array
  */
 public function getRemoteModifiedFiles($chanName, $package, $cacheObj, $ftp)
 {
     $p = $cacheObj->getPackageObject($chanName, $package);
     $hashContents = $p->getHashContents();
     $listModified = array();
     foreach ($hashContents as $file => $hash) {
         $localFile = uniqid("temp_remote_");
         if (!$ftp->fileExists($file)) {
             continue;
         }
         $ftp->get($localFile, $file);
         if (file_exists($localFile) && md5_file($localFile) !== $hash) {
             $listModified[] = $file;
         }
         @unlink($localFile);
     }
     return $listModified;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:27,代码来源:Packager.php


示例5: validateConfigPost

 /**
  * Validate settings post data.
  *
  * @param array $p
  */
 public function validateConfigPost($p)
 {
     $errors = array();
     $configTestFile = 'connect.cfgt';
     $configObj = $this->connect()->getConfig();
     if ('ftp' == $p['deployment_type'] || '1' == $p['inst_protocol']) {
         /*check ftp*/
         $confFile = $configObj->downloader_path . DIRECTORY_SEPARATOR . $configTestFile;
         try {
             $ftpObj = new Mage_Connect_Ftp();
             $ftpObj->connect($p['ftp']);
             $tempFile = tempnam(sys_get_temp_dir(), 'config');
             $serial = md5('config test file');
             $f = @fopen($tempFile, "w+");
             @fwrite($f, $serial);
             @fclose($f);
             $ret = $ftpObj->upload($confFile, $tempFile);
             //read file
             if (!$errors && is_file($configTestFile)) {
                 $size = filesize($configTestFile);
                 if (!$size) {
                     $errors[] = 'Unable to read saved settings. Please check Installation Path of FTP Connection.';
                 }
                 if (!$errors) {
                     $f = @fopen($configTestFile, "r");
                     @fseek($f, 0, SEEK_SET);
                     $contents = @fread($f, strlen($serial));
                     if ($serial != $contents) {
                         $errors[] = 'Wrong Installation Path of FTP Connection.';
                     }
                     fclose($f);
                 }
             } else {
                 $errors[] = 'Unable to read saved settings. Please check Installation Path of FTP Connection.';
             }
             $ftpObj->delete($confFile);
             $ftpObj->close();
         } catch (Exception $e) {
             $errors[] = 'Deployment FTP Error. ' . $e->getMessage();
         }
     } else {
         $p['ftp'] = '';
     }
     if ('1' == $p['use_custom_permissions_mode']) {
         /*check permissions*/
         if (octdec(intval($p['mkdir_mode'])) < 73 || octdec(intval($p['mkdir_mode'])) > 511) {
             $errors[] = 'Folders permissions not valid. ';
         }
         if (octdec(intval($p['chmod_file_mode'])) < 73 || octdec(intval($p['chmod_file_mode'])) > 511) {
             $errors[] = 'Files permissions not valid. ';
         }
     }
     //$this->controller()->session()->addMessage('success', 'Settings has been successfully saved');
     return $errors;
 }
开发者ID:newedge-media,项目名称:iwantmymeds,代码行数:60,代码来源:Connect.php


示例6: store

 public function store()
 {
     if ($this->_configLoaded || strlen($this->remote_config) > 0) {
         // @TODO: use ftp to save config
         $data = serialize($this->toArray());
         if (strlen($this->remote_config) > 0) {
             $confFile = $this->downloader_path . DIRECTORY_SEPARATOR . "connect.cfg";
             $ftpObj = new Mage_Connect_Ftp();
             $ftpObj->connect($this->remote_config);
             $tempFile = tempnam(sys_get_temp_dir(), 'config');
             $f = @fopen($tempFile, "w+");
             @fwrite($f, self::HEADER);
             @fwrite($f, $data);
             @fclose($f);
             $ret = $ftpObj->upload($confFile, $tempFile);
             $ftpObj->close();
         } elseif (is_file($this->_configFile) && is_writable($this->_configFile) || is_writable(getcwd())) {
             $f = @fopen($this->_configFile, "w+");
             @fwrite($f, self::HEADER);
             @fwrite($f, $data);
             @fclose($f);
         }
     }
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:24,代码来源:Config.php


示例7: endInstall

 /**
  * End install package(s)
  *
  */
 public function endInstall()
 {
     if ($this->isInstalled()) {
         try {
             if (!empty($_GET['clean_sessions'])) {
                 Mage::app()->cleanAllSessions();
             }
             Mage::app()->cleanCache();
         } catch (Exception $e) {
             $this->session()->addMessage('error', "Exception during cache and session cleaning: " . $e->getMessage());
         }
         // reinit config and apply all updates
         Mage::app()->getConfig()->reinit();
         Mage_Core_Model_Resource_Setup::applyAllUpdates();
         Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
     }
     if ($this->_getMaintenanceFlag()) {
         $maintenance_filename = 'maintenance.flag';
         $config = $this->config();
         if (!$this->isWritable() && strlen($config->__get('remote_config')) > 0) {
             $ftpObj = new Mage_Connect_Ftp();
             $ftpObj->connect($config->__get('remote_config'));
             $ftpObj->delete($maintenance_filename);
             $ftpObj->close();
         } else {
             @unlink($this->_getMaintenanceFilePath());
         }
     }
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:33,代码来源:Controller.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Mage_Connect_Package类代码示例发布时间:2022-05-23
下一篇:
PHP Mage_Checkout_Controller_Action类代码示例发布时间: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