mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-22 07:30:25 +00:00
update
This commit is contained in:
parent
8cbd0e2c21
commit
eb8d4936c8
2 changed files with 58 additions and 8 deletions
|
@ -3,12 +3,18 @@
|
|||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Domain;
|
||||
use App\Models\HostingSubscription;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
|
||||
class FileManager extends Component
|
||||
{
|
||||
public $hostingSubscriptionId;
|
||||
|
||||
public $hostingSubscriptionSystemUsername;
|
||||
|
||||
public $domainHomeRoot;
|
||||
|
||||
public $currentRealPath;
|
||||
|
||||
public $currentPath;
|
||||
|
@ -16,24 +22,62 @@ class FileManager extends Component
|
|||
public function mount($hostingSubscriptionId)
|
||||
{
|
||||
$this->hostingSubscriptionId = $hostingSubscriptionId;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$findHostingSubscription = HostingSubscription::where('id', $this->hostingSubscriptionId)->first();
|
||||
$findDomain = Domain::where('hosting_subscription_id', $this->hostingSubscriptionId)
|
||||
->where('is_main', 1)
|
||||
->first();
|
||||
|
||||
if ($findDomain) {
|
||||
if (!$this->currentRealPath) {
|
||||
$this->currentRealPath = $findDomain->home_root;
|
||||
if (!$findHostingSubscription || !$findDomain) {
|
||||
throw new \Exception('Hosting subscription not found');
|
||||
}
|
||||
|
||||
$this->hostingSubscriptionSystemUsername = $findHostingSubscription->system_username;
|
||||
$this->domainHomeRoot = $findDomain->home_root;
|
||||
|
||||
}
|
||||
|
||||
public function goto($dirOrFile)
|
||||
{
|
||||
$newPath = $this->currentRealPath . '/' . $dirOrFile;
|
||||
if (is_dir($newPath)) {
|
||||
$this->currentRealPath = $newPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function back()
|
||||
{
|
||||
$newRealPath = dirname($this->currentRealPath);
|
||||
|
||||
if (Str::startsWith($newRealPath, $this->domainHomeRoot)) {
|
||||
$this->currentRealPath = $newRealPath;
|
||||
}
|
||||
}
|
||||
|
||||
public function canIAccess($realPath, $systemUsername)
|
||||
{
|
||||
$checkOwner = posix_getpwuid(fileowner($realPath));
|
||||
|
||||
if (isset($checkOwner['name']) && $checkOwner['name'] == $systemUsername) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (!$this->currentRealPath) {
|
||||
$this->currentRealPath = $this->domainHomeRoot;
|
||||
}
|
||||
|
||||
$all = [];
|
||||
$files = [];
|
||||
$folders = [];
|
||||
if ($this->currentRealPath) {
|
||||
|
||||
$scanFiles = scandir($this->currentRealPath);
|
||||
foreach ($scanFiles as $scanFile) {
|
||||
if ($scanFile == '.' || $scanFile == '..') {
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
Path: {{$currentRealPath}}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button wire:click="back" class="bg-gray-100 text-gray-800 px-2 py-1 rounded-md">
|
||||
Back
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if(!empty($files))
|
||||
<table class="w-full rounded mt-2 border border-slate-200">
|
||||
<thead>
|
||||
|
@ -17,7 +23,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
@foreach($files as $file)
|
||||
<tr class="border border-slate-200 cursor-pointer hover:bg-gray-50 p-4">
|
||||
<tr wire:click="goto('{{$file['name']}}')" wire:key="{{md5($file['name'])}}" class="border border-slate-200 cursor-pointer hover:bg-gray-50 p-4">
|
||||
<td class="w-6 p-4">
|
||||
<div>
|
||||
@if($file['name'] == 'public_html')
|
||||
|
|
Loading…
Reference in a new issue