public function upload($localfile, $remotefile, $mode = null) { if (!in_array($savedir = dirname($remotefile), array('.', '/'))) { $this->mkdirs($savedir); } $remotefile = $this->rootPath . WindSecurity::escapePath($remotefile); return $this->conn->put($remotefile, $localfile, NET_SFTP_LOCAL_FILE); }
/** * 删除本地文件 * * @param string $filename 文件绝对地址 * @return bool */ public static function deleteFile($filename) { return WindFile::del(WindSecurity::escapePath($filename, true)); }
/** * 存储附件,如果是远程存储,记得删除本地文件 * * @param string $source 本地源文件地址 * @param string $filePath 存储相对位置 * @return bool */ public function save($source, $filePath) { $this->_getFtp()->upload($source, $filePath, 'I'); WindFile::del(WindSecurity::escapePath($source, true)); return true; }
public function delete($file) { return $this->sendcmd('DELE', $this->rootPath . WindSecurity::escapePath($file)); }
/** * 级联创建文件夹 * * @param string $dir 待创建文件夹路径 * @param string $permissions 创建的文件夹的权限 * @return boolean 创建成功返回true创建失败返回false */ public function mkdirs($dir, $permissions = 0777) { $dir = explode('/', WindSecurity::escapePath($dir)); $dirs = ''; $result = false; $count = count($dir); for ($i = 0; $i < $count; $i++) { if (strpos($dir[$i], '.') === 0) { continue; } $result = $this->mkdir($dir[$i], $permissions); $this->changeDir($this->rootPath . $dirs . $dir[$i]); $dirs .= "{$dir[$i]}/"; } $this->changeDir($this->rootPath); return $result; }
protected function buildThreeArea() { $fileTmp = WindSecurity::escapePath(Wind::getRealDir('DATA:') . 'tmp/' . 'area.php'); file_exists($fileTmp) && (self::$_map = (include $fileTmp)); if (!self::$_map) { $area = $this->_getAreaDs()->fetchAll(); foreach ($area as $key => $value) { if ($value['parentid'] < 100) { continue; } self::$_map[] = $value['areaid']; } WindFile::savePhpData($fileTmp, self::$_map); } return self::$_map; }
public function upload($sourceFile, $desFile, $mode = 'I') { $mode = $this->getMode($sourceFile, $mode); if (!in_array($savedir = dirname($desFile), array('.', '/'))) { $this->mkdirs($savedir); } $desFile = $this->rootPath . WindSecurity::escapePath($desFile); $result = ftp_put($this->getFtp(), $desFile, $sourceFile, $mode); if (false === $result) { throw new WindFtpException('[ftp.WindFtp.upload] PUT', WindFtpException::COMMAND_FAILED); } $this->chmod($desFile, 0644); return $this->size($desFile); }
/** * 本地安装, 分步模式执行应用安装 */ public function doInstallAction() { list($file, $step, $hash) = $this->getInput(array('file', 'step', 'hash'), 'post'); if (!$file) { $this->showError('APPCENTER:install.checkpackage.fail'); } $install = $this->_installService(); if ($file) { $file = Wind::getRealDir($install->getConfig('tmp_dir'), true) . '/' . $file; $file = WindSecurity::escapePath($file, true); $install->setTmpPath(dirname($file)); if (!WindFile::isFile($file)) { $this->showError('APPCENTER:install.checkpackage.fail'); } $_r = $install->extractPackage($file); if (true !== $_r) { $this->showError('APPCENTER:install.checkpackage.format.fail'); } $this->addMessage('APPCENTER:install.step.express'); $_r = $install->initInstall(); if (true !== $_r) { $this->showError('APPCENTER:install.initinstall.fail'); } $this->addMessage('APPCENTER:install.step.init'); $hash = $install->getHash(); $this->addMessage('APPCENTER:install.step.install'); } $step || ($step = 0); //$_r = $install->doInstall($step, $hash); //在360和ie下,写日志有问题,而且多web环境下,多进程安装也是有问题的 $_r = $install->doInstall('all', $hash); if (true === $_r) { $install->clear(); $this->showMessage('APPCENTER:install.success'); } elseif (is_array($_r)) { $this->setOutput(array('step' => $_r[0], 'hash' => $hash), 'data'); $this->showMessage($_r[1]); } else { $install->rollback(); $this->addMessage(array('step' => $step, 'hash' => $hash), 'data'); $this->showError($_r->getError()); } }
protected function deleteFile($filename) { return WindFile::del(WindSecurity::escapePath($filename, true)); }
/** * 导入数据表 * * @return void */ public function importAction() { list($file, $dir) = $this->getInput(array('file', 'dir')); list($step, $count, $isdir) = $this->getInput(array('step', 'count', 'isdir')); !$dir && $this->showError('BACKUP:name.empty'); $siteState = Wekit::C('site', 'visit.state'); if ($siteState != 2) { $this->showError('BACKUP:site.isopen'); } if (!$count) { $count = 1; $files = WindFolder::read(WindSecurity::escapePath($this->_bakupDir . $dir)); foreach ($files as $v) { if (preg_match("/^{$dir}\\_\\d+\\.(sql|zip)\$/i", $v)) { $count++; } } } !$step && ($step = 1); !$isdir ? $this->_getBackupService()->bakinSql($this->_bakupDir . $dir . '/' . $file) : $this->_getBackupService()->backinData($dir, $step); $i = $step; $step++; if ($count > 1 && $step <= $count) { $referer = 'admin/backup/backup/import?' . "step={$step}&file={$file}&dir={$dir}&isdir={$isdir}&count={$count}"; $this->showMessage(array('BACKUP:bakup_import', array('{i}' => $i)), $referer, true); } $this->showMessage('success', 'admin/backup/backup/restore'); }
public function upload($sourceFile, $desFile, $mode = 'A') { $mode = $this->getMode($sourceFile, $mode); if (!in_array($savedir = dirname($desFile), array('.', '/'))) { $this->mkdirs($savedir); } $desFile = $this->rootPath . WindSecurity::escapePath($desFile); $result = ftp_put($this->getFtp(), $desFile, $sourceFile, $mode); if (false === $result) { return false; } $this->chmod($desFile, 0644); return $this->size($desFile); }