64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use League\Flysystem\Sftp\SftpAdapter;
|
|
use League\Flysystem\Filesystem;
|
|
|
|
class SkyxuController extends Controller
|
|
{
|
|
|
|
/**
|
|
* Notes: 链接sftp
|
|
* @Author: 玄尘
|
|
* @Date : 2021/1/26 8:18
|
|
*/
|
|
public function sftp()
|
|
{
|
|
$path = '/home/wwwroot/pingan/upload/';
|
|
$name = 'JYMX66007320190722.txt';
|
|
$adapter = new SftpAdapter([
|
|
'host' => '123.57.16.212',
|
|
'port' => 22,
|
|
'username' => 'root',
|
|
'password' => 'Anetadmin1',
|
|
'privateKey' => '',
|
|
'passphrase' => '',
|
|
'root' => $path,
|
|
'timeout' => 10,
|
|
'directoryPerm' => 0755,
|
|
]);
|
|
|
|
$filesystem = new Filesystem($adapter);
|
|
$lists = $filesystem->listContents();
|
|
|
|
$content = $filesystem->read($name);
|
|
|
|
$content = str_replace("\n", "br", $content);
|
|
dump($content);
|
|
|
|
$content = explode("br", $content);
|
|
|
|
foreach ($content as $item) {
|
|
$array = explode('|', $item);
|
|
foreach ($array as $item) {
|
|
echo $item . "<br>";
|
|
}
|
|
echo '----------------------------------------' . "<br>";
|
|
}
|
|
dd($content);
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
if (method_exists($this, $request->action)) {
|
|
|
|
return call_user_func_array([$this, $request->action], [$request->all()]);
|
|
|
|
} else {
|
|
dd('未找到方法');
|
|
}
|
|
}
|
|
|
|
} |