mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 17:10:29 +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;
|
namespace App\Livewire;
|
||||||
|
|
||||||
use App\Models\Domain;
|
use App\Models\Domain;
|
||||||
|
use App\Models\HostingSubscription;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class FileManager extends Component
|
class FileManager extends Component
|
||||||
{
|
{
|
||||||
public $hostingSubscriptionId;
|
public $hostingSubscriptionId;
|
||||||
|
|
||||||
|
public $hostingSubscriptionSystemUsername;
|
||||||
|
|
||||||
|
public $domainHomeRoot;
|
||||||
|
|
||||||
public $currentRealPath;
|
public $currentRealPath;
|
||||||
|
|
||||||
public $currentPath;
|
public $currentPath;
|
||||||
|
@ -16,24 +22,62 @@ class FileManager extends Component
|
||||||
public function mount($hostingSubscriptionId)
|
public function mount($hostingSubscriptionId)
|
||||||
{
|
{
|
||||||
$this->hostingSubscriptionId = $hostingSubscriptionId;
|
$this->hostingSubscriptionId = $hostingSubscriptionId;
|
||||||
}
|
|
||||||
|
|
||||||
public function render()
|
$findHostingSubscription = HostingSubscription::where('id', $this->hostingSubscriptionId)->first();
|
||||||
{
|
|
||||||
$findDomain = Domain::where('hosting_subscription_id', $this->hostingSubscriptionId)
|
$findDomain = Domain::where('hosting_subscription_id', $this->hostingSubscriptionId)
|
||||||
->where('is_main', 1)
|
->where('is_main', 1)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($findDomain) {
|
if (!$findHostingSubscription || !$findDomain) {
|
||||||
if (!$this->currentRealPath) {
|
throw new \Exception('Hosting subscription not found');
|
||||||
$this->currentRealPath = $findDomain->home_root;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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 = [];
|
$all = [];
|
||||||
$files = [];
|
$files = [];
|
||||||
$folders = [];
|
$folders = [];
|
||||||
if ($this->currentRealPath) {
|
if ($this->currentRealPath) {
|
||||||
|
|
||||||
$scanFiles = scandir($this->currentRealPath);
|
$scanFiles = scandir($this->currentRealPath);
|
||||||
foreach ($scanFiles as $scanFile) {
|
foreach ($scanFiles as $scanFile) {
|
||||||
if ($scanFile == '.' || $scanFile == '..') {
|
if ($scanFile == '.' || $scanFile == '..') {
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
Path: {{$currentRealPath}}
|
Path: {{$currentRealPath}}
|
||||||
</div>
|
</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))
|
@if(!empty($files))
|
||||||
<table class="w-full rounded mt-2 border border-slate-200">
|
<table class="w-full rounded mt-2 border border-slate-200">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -17,7 +23,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@foreach($files as $file)
|
@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">
|
<td class="w-6 p-4">
|
||||||
<div>
|
<div>
|
||||||
@if($file['name'] == 'public_html')
|
@if($file['name'] == 'public_html')
|
||||||
|
|
Loading…
Reference in a new issue