本文整理汇总了PHP中Ftp::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Ftp::close方法的具体用法?PHP Ftp::close怎么用?PHP Ftp::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ftp
的用法示例。
在下文中一共展示了Ftp::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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));
}
示例3: 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.');
}
}
示例4: 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;
}
示例5: set_product_images_oxid
/**
* [set_product_images_oxid description]
* @param [type] $product [description]
*/
private function set_product_images_oxid($product)
{
global $oxid, $selectline;
$product->images = $selectline['db']->get_results("SELECT * FROM " . $selectline['table_product_img'] . " WHERE [Blobkey] = 'AR" . $product->Artikelnummer . "'");
if ($product->images) {
$i = 1;
$ftp = new Ftp();
$ftp->connect($oxid['ftp_host']);
$ftp->login($oxid['ftp_user'], $oxid['ftp_password']);
foreach ($product->images as $image) {
$img = WideImage::load($image->Bild);
if ($i > 1) {
$filename = $product->ART_ID . '_' . $i . '.jpg';
} else {
$filename = $product->ART_ID . '.jpg';
}
$img->saveToFile(ABSPATH . '/images/' . $filename);
$ftp->put($oxid['img_path'] . '/master/product/' . $i . '/' . $filename, ABSPATH . '/images/' . $filename, FTP_BINARY);
@unlink(ABSPATH . '/images/' . $filename);
$oxid['db']->query($this->format_update_query($oxid['table_products'], array('OXPIC1' => $filename), array('OXID' => $product->ART_ID)));
$i++;
}
$ftp->close();
}
}
示例6: Ftp
<script src="js/jquery-2.1.3.min.js"></script>
<script src="js/jQuery.ajaxQueue.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="bootstrap/js/bootstrap-select.min.js"></script>
</head>
<body class="<?php
echo $action;
?>
">
<?php
try {
$ftp = new Ftp();
$ftp->connect($oxid['ftp_host']);
$ftp->login($oxid['ftp_user'], $oxid['ftp_password']);
$ftp->close();
} catch (Exception $e) {
print_r('<p class="alert alert-danger">SelectConnect konnte keine Verbindung zum FTP-Server herstellen!</p>');
$action = 'error';
}
if (!oxid_userlogin()) {
print_r('<p class="alert alert-danger">SelectConnect konnte sich nicht bei Oxid einloggen!</p>');
$action = 'error';
}
switch ($action) {
case 'orders':
$orders = new Orders();
$items = $orders->import();
?>
<h1>SelectConnect | Bestellungen</h1>
<p>Es wurden <?php
示例7: forward_suobei
public function forward_suobei($id)
{
//获取视频id
$sql = 'SELECT content_id,vodid FROM ' . DB_PREFIX . 'materials WHERE content_id IN (' . $id . ') AND vodid !=""';
$query = $this->db->query($sql);
$k = array();
while ($row = $this->db->fetch_array($query)) {
$k[$row['content_id']] = $row['vodid'];
}
$ids = '';
$ret = array();
if (!empty($k)) {
//获取视频信息
$ids = implode(',', $k);
$keys = array_keys($k);
$vodpath = array();
//获取报料标题
$sql = 'SELECT id,title FROM ' . DB_PREFIX . 'content WHERE id IN (' . implode(',', $keys) . ')';
$query = $this->db->query($sql);
$title = array();
while ($row = $this->db->fetch_array($query)) {
$title[$row['id']] = $row['title'];
}
$title = array_combine($k, $title);
$ftp = $this->settings['App_suobei']['ftp'];
$ids = implode(',', $k);
$ret = $this->get_vodinfo($ids, $ftp['host'], $ftp['username'], $ftp['password']);
$vodpath = array();
if (!empty($ret) && is_array($ret)) {
foreach ($ret as $key => $val) {
$vodpath[$val['id']] = $ret[$key];
}
} else {
$this->errorOutput('ftp上传失败');
}
}
if (!empty($vodpath) && !empty($title)) {
//获取报料标题
//写xml文件
$this->vod_xml($vodpath, $title);
//ftp上传
//实例化ftp,并连接
$ftp_config = array('hostname' => $ftp['host'], 'username' => $ftp['username'], 'password' => $ftp['password']);
$ftp_up = new Ftp();
if (!$ftp_up->connect($ftp_config)) {
$this->errorOutput('CAN NOT CONNECT FTP SERVER');
}
foreach ($vodpath as $k => $v) {
$target_dir = $v['dir'] . '/';
$target_path = $target_dir . $v['filename'] . '.xml';
$xml_filepath = $this->settings['App_suobei']['xmldir'] . $v['filename'] . '.xml';
if (!file_exists($xml_filepath)) {
$this->errorOutput('CAN NOT FIND XML');
}
if (!$ftp_up->mkdir($target_dir)) {
$this->errorOutput('CAN NOT MAKE DIR');
}
if (!$ftp_up->upload($xml_filepath, $target_path)) {
$this->errorOutput('CAN NOT UPLOAD FILE');
}
}
$ftp_up->close();
//更新状态位
$sql = 'UPDATE ' . DB_PREFIX . 'content SET suobei=1 WHERE id IN (' . implode(',', $keys) . ')';
$this->db->query($sql);
}
return $id;
}
示例8: upload2ftp
public function upload2ftp()
{
$config = json_decode($this->input['config'], 1);
$files = json_decode($this->input['files'], 1);
include_once ROOT_PATH . 'lib/class/ftp.class.php';
$ftp = new Ftp();
$server_dir = trim($config['server_dir'], '/');
$app_dir = $config['app_dir'];
$message = array('error' => 0);
if (!$ftp->connect($config)) {
$message['error'] = 1;
$message['message'] = '连接服务器失败[' . $config['hostname'] . ']';
}
if ($server_dir && !$message['error']) {
if (!$ftp->mkdir($server_dir)) {
$message['error'] = 2;
$message['message'] = '目标目录不存在且创建失败[' . $server_dir . ']';
}
}
if (!$files && !$message['error']) {
$message['error'] = 3;
$message['message'] = '文件列表不存在[' . $files . ']';
}
if (!$message['error']) {
foreach ($files as $file) {
if (!file_exists($file)) {
//continue;
}
//返回上传错误的文件
$dfile = str_replace($app_dir, '', $file);
//如果设定了ftp目标目录
$dfile = $server_dir ? $server_dir . $dfile : $dfile;
$upload_dir = trim(str_replace('/' . basename($file), '', $dfile), '/');
if ($upload_dir) {
$ftp->mkdir($upload_dir);
}
if (!$ftp->upload($file, $dfile)) {
$message['error'] = 4;
$message['message'][$file] = $dfile;
}
}
}
//file_put_contents(CACHE_DIR . 'debug.txt', var_export($config,1));
$ftp->close();
$this->addItem($message);
$this->output();
}
示例9: actionSaveserviceorgan
/**
* 公司信息保存
*/
public function actionSaveserviceorgan()
{
$OrganID = Yii::app()->user->getOrganID();
$Organ = Yii::app()->request->getParam("Organ");
$arr = Yii::app()->request->getParam("telPhone");
$TelPhone = "";
foreach ($arr as $key => $val) {
if (empty($val)) {
continue;
}
$TelPhone .= $val . ",";
}
$model = Organ::model()->findByPK($OrganID);
if (empty($model)) {
$model = new Organ();
}
//保存organ数据
$model->attributes = $Organ;
$model->TelPhone = trim($TelPhone, ',');
//判断基本信息是否为空,为空则不提交
if ($Organ) {
//接收删除图片的地址
$photoId = Yii::app()->request->getParam("photoId");
//判断是否删除图片
if (!empty($photoId)) {
$imageids = explode(',', $photoId);
foreach ($imageids as $imageid) {
$picture = OrganPhoto::model()->find('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
//判断该图片路径是否存在数据库中
if (empty($picture)) {
$ftp = new Ftp();
$res = $ftp->delete_file($imageid);
$ftp->close();
} else {
OrganPhoto::model()->deleteAll('Path=:img AND OrganID=:OrganID', array(':img' => $imageid, ':OrganID' => $OrganID));
$ftp = new Ftp();
$res = $ftp->delete_file($picture->Path);
$ftp->close();
}
}
}
//接收上传图片地址
$goodsImages = Yii::app()->request->getParam("goodsImages");
//判断是否有上传图片
if (!empty($goodsImages)) {
$imglegth = count($goodsImages);
for ($i = 0; $i < $imglegth; $i++) {
$goodsImg = new OrganPhoto();
$goodsImg->OrganID = $OrganID;
$goodsImg->Path = $goodsImages[$i];
$goodsImg->save();
}
}
//判断是否上传营业执照
$BLPoto = Yii::app()->request->getParam("BLPoto");
if ($model->BLPoto != $BLPoto) {
if (!empty($model->BLPoto)) {
$ftp = new Ftp();
$res = $ftp->delete_file($model->BLPoto);
$ftp->close();
}
$model->BLPoto = $BLPoto;
}
//接收service数据
$service = Yii::app()->request->getParam("Service");
$opentime = Yii::app()->request->getParam("OpenTime");
//保存service数据
$servicemodel = Service::model()->find("OrganID=:organid", array(":organid" => $OrganID));
if (empty($servicemodel)) {
//判断是否第一次添加
$servicemodel = new Service();
$servicemodel->OrganID = $OrganID;
}
$servicemodel->PositionCount = $service['PositionCount'];
$servicemodel->TechnicianCount = $service['TechnicianCount'];
$servicemodel->ParkingDigits = $service['ParkingDigits'];
$servicemodel->ReservationMode = $service['ReservationMode'];
$servicemodel->ShopArea = $service['ShopArea'];
$servicemodel->OpenTime = $opentime[0] . ',' . $opentime[1] . ',' . $opentime[2] . ',' . $opentime[3];
//$model->attributes = $Organ;
if ($servicemodel->save() && $model->save()) {
//保存成功
//$file->saveAs(Yii::app()->params['uploadPath'].$model->Logo, true);
$this->redirect(array('index'));
} else {
var_dump($goodsImg->errors);
die;
}
}
}
示例10: actionEditlogo
public function actionEditlogo()
{
$organID = Yii::app()->user->OrganID;
//organ表单验证
$model = Organ::model()->findByPK($organID);
if ($model->Logo) {
//删除
$ftp = new Ftp();
$res = $ftp->delete_file($model->Logo);
$ftp->close();
}
//获得一个CUploadedFile的实例
$file = CUploadedFile::getInstanceByName('Logo');
$rs = array('code' => 100, 'msg' => '上传失败!' . $ImgName . '已经上传');
$upload = Yii::app()->params['uploadPath'] . 'tmp/logo/' . $organID . '/';
$path = Yii::app()->params['uploadPath'] . 'tmp/';
if (!is_dir($upload)) {
mkdir($upload, 0777, true) or die('创建失败');
chmod($upload, 0777);
}
// 判断实例化是否成功
if (is_object($file) && get_class($file) === 'CUploadedFile') {
$model->Logo = 'logo/' . $organID . '/' . 'file_' . date("YmdHis") . '_' . rand(1000, 9999) . '.' . $file->extensionName;
//定义文件保存的名称
}
/* else{ // 若果失败则应该是什么图片
$model->url = './assets/upfile/noPic.jpg';
} */
if ($model->save()) {
$file->saveAs($path . $model->Logo, true);
$ftp = new Ftp();
$res = $ftp->uploadfile($path . $model->Logo, $model->Logo);
$ftp->close();
@unlink($path . $model->Logo);
}
$this->redirect(array('index'));
}
示例11: actualiza
/**
* Cambia el nombre de una imagen existente
*
* Actualiza el nombre nuevo en la tabla de imagenes y cambia
* el nombre al archivo físico
*
* @param string $titulo El titulo de la imagen
* @param string $slug El nombre de la imagen sin limpiar
* @param booelan $mostrarPieFoto TRUE si se quiere mostrar el titulo en el pie de la imagen
* @param array $documento Array con los parametros del documento
* @param booelan $idThumbnail
* @param integer $orden
* @return boolean TRUE si se cambió con Exito
*/
public function actualiza()
{
$ok = TRUE;
// Cargo los datos del objeto antes de cambiarlos
$doc = new CpanDocs($this->getId());
$pathName = $doc->getPathName();
$nombreAnterior = $doc->getName();
unset($doc);
// Si el nombre propuesto es distinto al que ya tiene y no es Thumbnail
// recalculo el nombre amigable, cambio el path y renombro el archivo
$this->actualizaNombreAmigable();
$nombreNuevo = $this->getName();
$pathInfo = pathinfo($pathName);
$carpetaDestino = $this->_prePath . $pathInfo['dirname'];
$ftp = new Ftp($_SESSION['project']['ftp']);
$ok = $ftp->rename($carpetaDestino, $nombreAnterior, $nombreNuevo);
$this->_errores = $ftp->getErrores();
$ftp->close();
unset($ftp);
if ($this->_ArrayDoc['tmp_name'] != '') {
$ok = $this->subeDocumento();
}
// Si todo ha ido bien, actualizo el objeto
if ($ok) {
$this->save();
}
unset($this);
return $ok;
}
示例12: actionUploadFile
public function actionUploadFile()
{
$path = $_POST['path'];
if (!empty($_FILES)) {
$oldfileName = $_FILES['Filedata']['name'];
$ext = substr($oldfileName, strrpos($oldfileName, ".") + 1);
$filesize = $_FILES['Filedata']['size'];
//上传文件大小
$fileName = $this->getRandomName($oldfileName);
$tmpFile = $_FILES['Filedata']['tmp_name'];
//缓存文件路径
//$type = $_FILES['Filedata']['type']; //上传文件类型
$tp = array('gif', 'jpg', 'png', 'bmp', 'jpeg', 'doc', 'docx', 'xls', 'xlsx', 'txt');
//检查上传文件是否在允许上传的类型
if (!in_array($ext, $tp)) {
echo json_encode(array('code' => 1, 'msg' => '只能发送图片、文档、表格等文件'));
die;
}
if (in_array($ext, array('gif', 'jpg', 'png', 'bmp', 'jpeg'))) {
$ftype = 1;
} else {
$ftype = 2;
}
//检查文件大小
$max_size = 2 * 1024 * 1024;
//2M
if ($filesize > $max_size) {
echo json_encode(array('code' => 0, 'msg' => '上传文件大小超过限制,不允许超过2M '));
die;
}
//上传文件临时保存路径
$tmpsavepath = Yii::app()->params['uploadPath'] . 'tmp/';
if (!file_exists($tmpsavepath)) {
if (!@mkdir($tmpsavepath, 0777, true)) {
echo json_encode(array('code' => 0, 'msg' => '临时保存目录创建失败 - ' . $tmpsavepath));
die;
} else {
chmod($tmpsavepath, 0777);
}
}
//检查目录写权限
if (@is_writable($tmpsavepath) === false) {
echo json_encode(array('code' => 0, 'msg' => '临时保存目录没有写权限 - ' . $tmpsavepath));
die;
}
$tmpsavefile = $tmpsavepath . basename($tmpFile);
if (@move_uploaded_file($tmpFile, $tmpsavefile) === false) {
echo json_encode(array('code' => 0, 'msg' => '文件保存失败 - ' . $tmpsavefile));
die;
}
$fileurl = $path . $fileName;
// 新文件名
$ftp = new Ftp();
$res = $ftp->uploadfile($tmpsavefile, $fileurl);
$ftp->close();
if ($res['success']) {
@unlink($tmpsavefile);
//删除临时文件
echo json_encode(array('code' => 200, 'ftype' => $ftype, 'fileurl' => $fileurl, 'filename' => $oldfileName, 'msg' => '上传成功!'));
} else {
echo json_encode(array('code' => 0, 'msg' => $res['msg']));
}
} else {
echo json_encode(array('code' => 0, 'msg' => '请选择文件!'));
}
}
示例13: actionDelPto
public function actionDelPto()
{
$imageid = Yii::app()->request->getParam("imageid");
$ftp = new Ftp();
$res = $ftp->delete_file($imageid);
$ftp->close();
echo json_encode($res);
}
示例14: ftp_upload
/**
* ftp上传
* @param $file_path:本地文件的路径
* @param $savename:文件名
* @return 1;上传成功<br>
* 0;上传失败
*/
private function ftp_upload($ftp_file_path, $local_file_path, $savename, $type)
{
import("@.ORG.Ftp");
$ftp = new Ftp();
$conn = $ftp->connect('w1.weimg.cn', 'images', 'images580230', $port = '21', $pasv = false, $ssl = false, $timeout = 30);
$ftp->mkdir($ftp_file_path);
$res = $ftp->put($ftp_file_path . $savename, $local_file_path . $savename);
if ($type == 4) {
$ftp->put($ftp_file_path . 's_' . $savename, $local_file_path . 's_' . $savename);
unlink('./Public/upload/s_' . $savename);
}
$ftp->close();
unlink('./Public/upload/' . $savename);
if (!$res) {
return 0;
} else {
return 1;
}
}
示例15: SubirPlantillaAction
/**
* Sube al servidor el archivo de plantilla a la carpeta
* docs/docsXXX/circulares/plantillas.
*
* Debe existir la carpeta docs/docsXXX/circulares.
* Se sube usando ftp.
*
* @return type
*/
public function SubirPlantillaAction()
{
$fichero = $this->request['FILES']['filePlantilla'];
if (in_array($fichero['type'], $this->tiposPermitidos)) {
$carpetaPlantillas = $_SESSION['appPath'] . "/docs/docs{$_SESSION['emp']}/circulares/plantillas";
Archivo::creaCarpeta($carpetaPlantillas);
if (is_uploaded_file($fichero['tmp_name'])) {
$ftp = new Ftp($_SESSION['project']['ftp']);
if ($ftp) {
$ok = $ftp->upLoad($carpetaPlantillas, $fichero['tmp_name'], $fichero['name']);
$this->_errores = $ftp->getErrores();
$ftp->close();
} else {
$this->_errores[] = "Fallo al conectar vía FTP";
foreach ($_SESSION['project']['ftp'] as $item) {
$this->_errores[] = $item;
}
}
}
} else {
$this->_errores[] = "Tipo de archivo no permitido. Sólo se admiten archivos rtf,txt y html";
}
$this->values['errores'] = $this->_errores;
return $this->IndexAction();
}