本文整理汇总了PHP中Ftp类的典型用法代码示例。如果您正苦于以下问题:PHP Ftp类的具体用法?PHP Ftp怎么用?PHP Ftp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ftp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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('[email protected]', '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
示例16: getTasks
public function getTasks()
{
$tasks = array();
$list = Ftp::getFilesFromYaml($this->tasksDirs);
foreach ($list as $name => $path) {
$Tmp = new $name();
if (!$Tmp->hasName()) {
$Tmp->setName($name);
}
if (!$Tmp->hasDescription()) {
$Tmp->setDescription(_('No descriptions.'));
}
$new_name = $Tmp->hasNamespace() ? $Tmp->getNamespace() . ':' : null;
$new_name .= $Tmp->getName();
$tasks[$new_name] = $Tmp;
}
return $tasks;
}
开发者ID:Nivl,项目名称:Ninaca_1,代码行数:18,代码来源:Cli.class.php
示例17: checkUploadError
private function checkUploadError($file)
{
if (!isset($file['error'])) {
$this->addError(_('Unknown error.'));
} else {
if ($file['error'] === UPLOAD_ERR_NO_FILE) {
$this->addError(_('No Files has been uploaded.'));
} else {
if ($file['error'] === UPLOAD_ERR_PARTIAL) {
$this->addError(_('The file has been partially uploaded.'));
} else {
if ($file['error'] === UPLOAD_ERR_INI_SIZE) {
$error = _("You can’t upload a file bigger than %d octets.");
$max = Ftp::octetConverter(ini_get('upload_max_filesize'));
$this->addError(sprintf($error, $max));
} else {
if ($file['error'] === UPLOAD_ERR_FORM_SIZE) {
$this->addError(_("The file’s size is bigger than the maximum size " . "specified in the form."));
} else {
if ($file['error'] === UPLOAD_ERR_NO_TMP_DIR) {
$this->addError(_('The temporary directory is missing.'));
} else {
if ($file['error'] === UPLOAD_ERR_CANT_WRITE) {
$this->addError(_("The file can’t be wrote on the disk."));
} else {
if ($file['error'] === UPLOAD_ERR_EXTEMSION) {
$this->addError(_('The file’s extention is not allowed.'));
} else {
$this->addError(_('Unknown error.'));
}
}
}
}
}
}
}
}
}
开发者ID:Nivl,项目名称:Ninaca_1,代码行数:38,代码来源:ValidateFile.class.php
示例18: file_remote_delete
function file_remote_delete($file)
{
global $_W;
if (empty($file)) {
return true;
}
if ($_W['setting']['remote']['type'] == '1') {
require IA_ROOT . '/framework/library/ftp/ftp.php';
$ftp_config = array('hostname' => $_W['setting']['remote']['ftp']['host'], 'username' => $_W['setting']['remote']['ftp']['username'], 'password' => $_W['setting']['remote']['ftp']['password'], 'port' => $_W['setting']['remote']['ftp']['port'], 'ssl' => $_W['setting']['remote']['ftp']['ssl'], 'passive' => $_W['setting']['remote']['ftp']['pasv'], 'timeout' => $_W['setting']['remote']['ftp']['timeout'], 'rootdir' => $_W['setting']['remote']['ftp']['dir']);
$ftp = new Ftp($ftp_config);
if (true === $ftp->connect()) {
if ($ftp->delete_file($file)) {
return true;
} else {
return error(1, '删除附件失败,请检查配置并重新删除');
}
} else {
return error(1, '删除附件失败,请检查配置并重新删除');
}
} elseif ($_W['setting']['remote']['type'] == '2') {
require IA_ROOT . '/framework/library/alioss/sdk.class.php';
$oss = new ALIOSS($_W['setting']['remote']['alioss']['key'], $_W['setting']['remote']['alioss']['secret'], $_W['setting']['remote']['alioss']['ossurl']);
$response = $oss->delete_object($_W['setting']['remote']['alioss']['bucket'], $file);
if ($response->status == 204) {
return true;
} else {
return error(1, '删除oss远程文件失败');
}
}
return true;
}
开发者ID:zhang19960118,项目名称:html11,代码行数:31,代码来源:file.func.php
示例19: editscheme
public static function editscheme($params)
{
$organID = Yii::app()->user->getOrganID();
$time = $_SERVER['REQUEST_TIME'];
//更新报价单
$quoID = self::ifsendquo(array('inqid' => $params['inqid']));
$quodatas['UpdateTime'] = $time;
$quodatas['Title'] = $params['quoname'];
$result = Yii::app()->papdb->createCommand()->update('pap_quotation', $quodatas, 'QuoID=' . $quoID);
$SchID = $params['schid'];
$datas['TotalFee'] = $params['quoprices'];
$datas['GoodFee'] = $params['totalprices'];
$datas['ShipFee'] = $params['shipprices'];
$datas['ShipFee'] = $params['shipprices'];
$datas['UpdateTime'] = $time;
//保存附件
if ($params['fileurl']) {
$datas['FileName'] = $params['filename'];
$datas['FileUrl'] = $params['fileurl'];
//删除之前附件
$quo_data = PapQuotationScheme::model()->findByPk($SchID);
if (!empty($quo_data['FileName'])) {
$ftp = new Ftp();
$res = $ftp->delete_file($quo_data->FileUrl);
$ftp->close();
}
}
$result = Yii::app()->papdb->createCommand()->update('pap_quotation_scheme', $datas, 'SchID=:SchID', array(':SchID' => $SchID));
//获取商品信息
$goodsinfo = array();
$goodsids = explode(',', $params['quoids']);
$goodsnum = explode(',', $params['quonum']);
$goodsprice = explode(',', $params['quoprice']);
//获取以前的商品信息
$oldgoodsinfo = PapQuotationGoods::model()->findAll('SchID=' . $SchID);
$newgoodsinfo = array();
foreach ($goodsids as $key => $v) {
if ($v) {
$newgoodsinfo[$key]['GoodsID'] = $goodsids[$key];
$newgoodsinfo[$key]['Num'] = $goodsnum[$key];
$newgoodsinfo[$key]['Price'] = $goodsprice[$key];
$version = QuotationService::getgoodsversion($goodsids[$key]);
$newgoodsinfo[$key]['Version'] = $version ? $version : 0;
}
}
$insertid = array();
//将报价单商品插入报价单商品表中
if ($SchID) {
foreach ($newgoodsinfo as $nkey => $new) {
$newids[] = $new['GoodsID'];
}
if ($oldgoodsinfo) {
foreach ($oldgoodsinfo as $okey => $old) {
$oldids[] = $old['GoodsID'];
}
} else {
$oldids = array();
}
foreach ($oldids as $id) {
if (!in_array($id, $newids)) {
//删除商品
$delcount = Yii::app()->papdb->createCommand()->delete('pap_quotation_goods', 'SchID=:SchID and GoodsID=:goodsid', array(':SchID' => $SchID, ':goodsid' => $id));
}
}
foreach ($newids as $key => $id) {
if (in_array($id, $oldids)) {
//更新商品
$update['Num'] = $newgoodsinfo[$key]['Num'];
$update['Price'] = $newgoodsinfo[$key]['Price'];
$update['Version'] = $newgoodsinfo[$key]['Version'];
$result = Yii::app()->papdb->createCommand()->update('pap_quotation_goods', $update, 'SchID=:SchID and GoodsID=:goodsid', array(':SchID' => $SchID, ':goodsid' => $id));
if ($result == 1) {
$res = 1;
}
} else {
//插入商品
$goodsdatas['SchID'] = $SchID;
$goodsdatas['GoodsID'] = $newgoodsinfo[$key]['GoodsID'];
$goodsdatas['Num'] = $newgoodsinfo[$key]['Num'];
$goodsdatas['Price'] = $newgoodsinfo[$key]['Price'];
$goodsdatas['Version'] = $newgoodsinfo[$key]['Version'];
$result = Yii::app()->papdb->createCommand()->insert('pap_quotation_goods', $goodsdatas);
$insertid[] = Yii::app()->papdb->getLastInsertID();
}
}
}
if ($res = 1 || count($insertid) > 0 || $delcount > 0) {
echo json_encode(array('count' => 1, 'schid' => $SchID, 'success' => true));
} else {
echo json_encode(array('count' => 0));
}
}
开发者ID:zwq,项目名称:unpei,代码行数:92,代码来源:InquiryService.php
示例20: Ftp
$from = $video->getContent();
$bajado = $ftpCon->bajar($from, $to);
if ($bajado !== TRUE) {
$bajado = $ftpCon->bajar($from, $to);
}
if ($bajado !== TRUE) {
$bajado = $ftpCon->bajar($from, $to);
}
if ($bajado !== TRUE) {
$bajado = $ftpCon->bajar($from, $to);
}
if ($bajado === TRUE) {
$to = $tmpDir . "/preview_tmp.gif";
$from = $video->getPreview();
$log .= "\tdescargando preview {$from} > {$to}\n";
$ftpConUSA = new Ftp(FTP_USA, FTP_USA_USR, FTP_USA_PWD);
$connectUSA = $ftpConUSA->login();
if ($conectado !== TRUE) {
$connectUSA = $ftpConUSA->login();
}
if ($conectado !== TRUE) {
$connectUSA = $ftpConUSA->login();
}
if ($conectado !== TRUE) {
$connectUSA = $ftpConUSA->login();
}
$bajado = $ftpConUSA->bajar($from, $to);
if ($bajado !== TRUE) {
$bajado = $ftpConUSA->bajar($from, $to);
}
if ($bajado !== TRUE) {
开发者ID:vallejos,项目名称:samples,代码行数:31,代码来源:process-video.php
注:本文中的Ftp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论