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


PHP Ftp类代码示例

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


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

示例1: testFailure

 public function testFailure()
 {
     $ftp = new Ftp("chc-deaf.org.ua");
     $ftp->login("chc-deaf", "moskvich408");
     $this->assertFalse($ftp->push_file("/file/maxim3.jpg", "../maxim3.jpg", "jpg2"));
     $this->assertFalse($ftp->push_file("/file/maxim3.jpg", "../maxim3.jpg", "doc"));
 }
开发者ID:KosovMax,项目名称:ftp2,代码行数:7,代码来源:testFtp.php

示例2: factory

 /**
  * Returns a new Ftp object. If you do not define the "file" parameter,
  *
  *     $ftp = static::factory('group');
  *
  * @param   string  Ftp filename
  * @param   array   array of values
  * @return  Ftp
  */
 public static function factory($config = 'default', $connect = true)
 {
     $ftp = new Ftp($config);
     // Unless told not to, connect automatically
     $connect === true and $ftp->connect();
     return $ftp;
 }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:16,代码来源:ftp.php

示例3: upload

 public function upload()
 {
     if (!$this->input['video_id']) {
         $this->errorOutput(NOID);
     }
     $sql = " SELECT video_base_path,video_path,video_filename,id FROM " . DB_PREFIX . "vodinfo WHERE id IN (" . $this->input['video_id'] . ")";
     $q = $this->db->query($sql);
     $video = array();
     while ($r = $this->db->fetch_array($q)) {
         $video[] = $r;
     }
     //实例化ftp,并连接
     $ftp_config = array('hostname' => $this->input['hostname'], 'username' => $this->input['username'], 'password' => $this->input['password']);
     $ftp = new Ftp();
     if (!$ftp->connect($ftp_config)) {
         $this->errorOutput('CAN NOT CONNECT FTP SERVER');
     }
     foreach ($video as $k => $v) {
         $target_dir = date('Y', TIMENOW) . '/' . date('m', TIMENOW) . '/' . TIMENOW . hg_rand_num(6) . '/';
         $target_path = $target_dir . $v['video_filename'];
         $video_filepath = $v['video_base_path'] . $v['video_path'] . $v['video_filename'];
         if (!$ftp->mkdir($target_dir)) {
             $this->errorOutput('CAN NOT MAKE DIR');
         }
         if (!$ftp->upload($video_filepath, $target_path)) {
             $this->errorOutput('CAN NOT UPLOAD FILE');
         }
         $pathinfo = pathinfo($target_path);
         $filename = basename($pathinfo['basename'], '.' . $pathinfo['extension']);
         $this->addItem(array('path' => $target_path, 'id' => $v['id'], 'dir' => $pathinfo['dirname'], 'filename' => $filename));
     }
     $this->output();
 }
开发者ID:h3len,项目名称:Project,代码行数:33,代码来源:ftp_upload.php

示例4: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $menu = $model->attributes;
     if (isset($_POST['FrontMenu'])) {
         $model->attributes = $_POST['FrontMenu'];
         foreach ($this->uploadArr as $column) {
             $file = CUploadedFile::getInstance($model, $column);
             //获取表单名为filename的上传信息
             if ($file) {
                 $model->{$column} = $this->uploadIcon($file);
                 if ($menu[$column]) {
                     $ftp = new Ftp();
                     $res = $ftp->delete_file('common/frontmenu/' . $menu[$column]);
                     $ftp->close();
                 }
             } else {
                 unset($model->{$column});
             }
         }
         if (!$model->ParentID) {
             $model->ParentID = 0;
         }
         if ($model->save()) {
             $this->freshMenuCache();
             $this->redirect(array('admin'));
         }
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:zwq,项目名称:unpei,代码行数:35,代码来源:FrontmenuController.php

示例5: update

 /**
  * Ist für den Abgleich der Bestellungen im Cronjob.
  */
 public function update()
 {
     global $selectline, $oxid, $ftp;
     $this->set_log('Cronjob: ' . date('d.m.Y H:i:s') . "\r\n");
     try {
         $ftp = new Ftp();
         $ftp->connect($oxid['ftp_host']);
         $ftp->login($oxid['ftp_user'], $oxid['ftp_password']);
         $ftp->close();
     } catch (Exception $e) {
         $this->set_log('SelectConnect konnte keine Verbindung zum FTP-Server herstellen!');
         exit;
     }
     if (!oxid_userlogin()) {
         $this->set_log('SelectConnect konnte sich nicht bei Oxid einloggen!');
         exit;
     }
     if (!$this->is_current_update_process()) {
         $this->set_log("Cronjob wurde gestartet \r\n");
         $this->set_lock_file();
         $last_update = $this->get_last_update();
         $this->set_log("Bestellungen werden in Selectline importiert \r\n");
         $orders = $oxid['db']->get_results("SELECT * FROM " . $oxid['table_order'] . " WHERE OXFOLDER  = '" . $oxid['get_order_status'] . "' ORDER BY OXORDERNR");
         if ($orders) {
             foreach ($orders as $order) {
                 $order_products = $oxid['db']->get_results("SELECT * FROM " . $oxid['table_orderarticles'] . " WHERE OXORDERID = '" . $order->OXID . "' ");
                 $order->products = $order_products;
                 $order_payment = $oxid['db']->get_row("SELECT * FROM " . $oxid['table_payments'] . " WHERE ('" . $order->OXPAYMENTTYPE . "' = OXID)");
                 $order->payment = $order_payment;
                 $this->set_order_to_selectline($order, true);
                 $oxid['db']->query("UPDATE " . $oxid['table_order'] . " SET OXFOLDER = '" . $oxid['set_order_status'] . "', OXEXPORT = 1 WHERE `OXID` = '" . $order->OXID . "' ");
             }
         }
         $this->set_log("Bestellungstatus wird abgeglichen \r\n");
         $orders = $selectline['db']->get_results("SELECT * FROM " . $selectline['table_orders'] . " WHERE [Belegtyp] = '" . $selectline['filter_order_invoice'] . "' AND [BearbeitetAm] >= CONVERT(datetime, '" . $last_update->format('d.m.Y H:i:s') . "',104)");
         if ($orders) {
             foreach ($orders as $order) {
                 $tracking_id = $this->get_tracking_id_from_selectline($order);
                 $updateArray = array('OXBILLNR' => $order->Belegnummer, 'OXBILLDATE' => $order->Datum->format('Y-m-d'), 'OXSENDDATE' => $order->Datum->format('Y-m-d H:i:s'), 'OXFOLDER' => $oxid['order_status_finish']);
                 if ($tracking_id !== NULL) {
                     $updateArray['OXTRACKCODE'] = $tracking_id;
                 }
                 //print_r($this->format_update_query($oxid['table_order'], $updateArray, array('OXORDERNR' => str_replace('OX', '', $order->IhrAuftrag))));
                 $oxid['db']->query($this->format_update_query($oxid['table_order'], $updateArray, array('OXORDERNR' => str_replace('OX', '', $order->IhrAuftrag))));
                 $this->set_log("Bestellung " . $order->IhrAuftrag . "/" . $order->Belegnummer . " - Status: FINISHED - Tracking: " . $tracking_id . " \r\n");
             }
         }
         $this->set_last_update();
         $this->remove_lock_file();
         $this->set_log("Cron wurde beendet \r\n");
         $this->set_log("\r\n##################################\r\n\r\n");
     } else {
         print_r('Error: Es läuft bereits Update-Prozess.');
     }
 }
开发者ID:baltruschat,项目名称:selectconnect,代码行数:58,代码来源:orders.php

示例6: testDownload

 /**
  * Download test.
  * @return void
  */
 public function testDownload()
 {
     $ftp = new Ftp();
     // Opens an FTP connection to the specified host
     $ftp->connect('ftp.nettephp.com');
     $ftp->pasv(TRUE);
     // Login with username and password
     $ftp->login('nette@php7.org', 'anonymous');
     // Download file 'README' to local temporary file
     $temp = tmpfile();
     $ftp->fget($temp, 'README', Ftp::ASCII);
     // echo file
     fseek($temp, 0);
     $this->assertEquals("Nette Framework rocks!", stream_get_contents($temp));
 }
开发者ID:vrana,项目名称:nette,代码行数:19,代码来源:NetteWebFtpTest.php

示例7: get_ftp_content

function get_ftp_content($source, $target)
{
    $result = false;
    $config = array('hostname' => FTP_HOST, 'username' => FTP_USER, 'password' => FTP_PASSWORD, 'port' => FTP_PORT, 'timeout' => FTP_TIMEOUT);
    $ftp = new Ftp();
    $ftp->connect($config);
    if ($ftp->existsFile($source)) {
        $result = $ftp->download($source, $target);
    } else {
        access_log('log', 'No documents.');
        //clear_file();
    }
    $ftp->close();
    return $result;
}
开发者ID:hardyswang,项目名称:down_ftp_zip_and_unzip,代码行数:15,代码来源:get_ftp_list.php

示例8: __construct

 /**
  * @param string $ftp_dsn ftp://user:pass@localhost/
  */
 public function __construct($ftp_dsn)
 {
     $ftp = Ftp::parse_dsn($ftp_dsn);
     foreach ($ftp as $k => $v) {
         $this->{$k} = $v;
     }
 }
开发者ID:liuyu121,项目名称:myqee,代码行数:10,代码来源:ftp.class.php

示例9: __construct

 public function __construct($connection = '')
 {
     if ($connection) {
         $this->ftpCon = Ftp::connection($connection);
     } else {
         $this->ftpCon = Ftp::connection();
     }
 }
开发者ID:huycao,项目名称:yoplatform,代码行数:8,代码来源:MyFTP.php

示例10: process

 /**
  * @param DatabaseBackupFile $file
  * @return ResultObject[]
  */
 public function process(DatabaseBackupFile $file)
 {
     $d = $file->getBackupDate();
     $results = [];
     foreach ($this->uploadsCredentials as $credentials) {
         $result = new ResultObject();
         // empty ResultObject means all is OK
         $backupPath = $credentials['path'] . '/' . $d->format('Y') . '/' . $d->format('F');
         $entireFilePath = $backupPath . '/' . $file->getFileName();
         try {
             $ftp = new \Ftp();
             $ftp->connect($credentials['host']);
             $ftp->login($credentials['username'], $credentials['password']);
             if (!$ftp->fileExists($backupPath)) {
                 $ftp->mkDirRecursive($backupPath);
             }
             $ftp->put($entireFilePath, $file->getFilePath(), FTP_BINARY);
             $ftp->close();
         } catch (\FtpException $e) {
             $this->logger->addCritical(sprintf('Uploading backup file\'s failed. %s', $e));
             $result->addError('Zálohu se nepodařilo nahrát na: ' . $credentials['host'], 'error');
         }
         $results[] = $result;
     }
     return $results;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:30,代码来源:DatabaseBackupFileHandler.php

示例11: loadLibs

 private static function loadLibs()
 {
     if (is_file('config/libs' . PHP)) {
         self::$libs = unserialize(include $root . '/config/libs' . PHP);
     } else {
         self::$libsInfo = self::getlibsInfo();
         self::$libs = Ftp::getFilesFromYaml(self::$libsInfo);
     }
 }
开发者ID:Nivl,项目名称:Ninaca_1,代码行数:9,代码来源:Autoload.class.php

示例12: moveTableClasses

 private function moveTableClasses()
 {
     if ($this->getOptionsValue('generate-table') === true) {
         if (!Misc::isEmpty($to = $this->getOptionsValue('table-dir'))) {
             $from = $this->getOptionsValue('models-path');
             $to = $from . '/' . $to;
             $opt = array('suffix' => 'Table' . self::getOptionsValue('suffix'));
             Ftp::moveFiles($from, $to, false, false, $opt);
         }
     }
 }
开发者ID:Nivl,项目名称:Ninaca_1,代码行数:11,代码来源:GenerateModels.class.php

示例13: getFtpFiles

/**
 * 
 * @param type $from
 * @return type 
 */
function getFtpFiles($from)
{
    $info = pathinfo($from);
    $name = trim($info['basename']);
    $ftpCon = new Ftp(FTP_HOST, FTP_USER, FTP_PASS, FTP_PORT);
    $content_download = FALSE;
    $connected = $ftpCon->login_r(null, null, FTP_CONN_RETRIES);
    if ($connected === TRUE) {
        $to = TMP_QR_DIR . "/" . $name;
        $downloaded = $ftpCon->bajar_r($from, $to, FTP_CONN_RETRIES);
        if ($downloaded === TRUE) {
            $content_download = TRUE;
        } else {
            $content_download = FALSE;
        }
    } else {
        $content_download = FALSE;
    }
    $ftpCon->logout();
    return $content_download;
}
开发者ID:vallejos,项目名称:samples,代码行数:26,代码来源:functions.php

示例14: globalChecks

 private function globalChecks($file, $content, $name)
 {
     if (is_file('apps/controllers/' . $file)) {
         exit("This application already exists.\n");
     }
     if (!file_put_contents("apps/controllers/{$file}", $content)) {
         exit("The file apps/controllers/{$file} can't be created.\n");
     }
     if (!Ftp::makeDir('apps/views/' . $name)) {
         exit("The file apps/views/{$name} can't be created.");
     }
 }
开发者ID:Nivl,项目名称:Ninaca_1,代码行数:12,代码来源:GenerateApp.class.php

示例15: action_ajax_test_ftp

 public function action_ajax_test_ftp()
 {
     // is ajax
     if (!\Input::is_ajax()) {
         \Response::redirect(\Uri::create('admin'));
     }
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('config_global', 'config_global') == false) {
         \Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
         return null;
     }
     if (\Input::method() == 'POST') {
         // get post value and test connection
         $config['hostname'] = trim(\Input::post('hostname'));
         $config['username'] = trim(\Input::post('username'));
         $config['password'] = trim(\Input::post('password'));
         $config['port'] = (int) trim(\Input::post('port'));
         $config['passive'] = trim(\Input::post('passive')) == 'true' ? true : false;
         $config['ssl_mode'] = false;
         $config['debug'] = false;
         $basepath = trim(\Input::post('basepath'));
         // connect to ftp
         $ftp = \Ftp::forge($config);
         $ftp->connect();
         $ftp->change_dir($basepath);
         $files = $ftp->list_files();
         $ftp->close();
         $output = array();
         if ($files !== false) {
             $output['form_status'] = 'success';
             $output['form_status_message'] = \Lang::get('config_ftp_connected_check_basepath_from_dir_structure_below');
             natsort($files);
             $output['list_files'] = '<ul>';
             foreach ($files as $file) {
                 $output['list_files'] .= '<li>' . $file . '</li>';
             }
             $output['list_files'] .= '</ul>';
         } else {
             // got false from list_files means cannot connect
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('config_ftp_could_not_connect_to_server');
         }
         // clear no use variables
         unset($basepath, $config, $file, $files, $ftp);
         // send out json values
         $response = new \Response();
         $response->set_header('Content-Type', 'application/json');
         $response->body(json_encode($output));
         return $response;
     }
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:51,代码来源:config.php


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