Merge pull request #42 from cp6/2.1.0

2.1.0
This commit is contained in:
corbpie 2022-05-16 23:17:37 +10:00 committed by GitHub
commit 2a6087b843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 2066 additions and 860 deletions

View File

@ -1,47 +1,39 @@
# My idlers # My idlers
A web app for displaying, organizing and storing information about servers (VPS), shared & reseller hosting, domains, A web app for displaying, organizing and storing information about servers (VPS), shared & reseller hosting, seed boxes, domains,
DNS and misc services. DNS and misc services.
Despite what the name infers this self hosted web app isn't just for storing idling server information. By using Despite what the name infers this self hosted web app isn't just for storing idling server information. By using
a [YABs](https://github.com/masonr/yet-another-bench-script) output you can get disk & network speed values along with a [YABs](https://github.com/masonr/yet-another-bench-script) output you can get disk & network speed values along with
GeekBench 5 scores to do easier comparing and sorting. GeekBench 5 scores to do easier comparing and sorting.
[![Generic badge](https://img.shields.io/badge/version-2.0-blue.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Laravel-9.0-red.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/PHP-8.1-purple.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Bootstrap-5.1-pink.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/version-2.1.0-blue.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Laravel-9.0-red.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/PHP-8.1-purple.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Bootstrap-5.1-pink.svg)](https://shields.io/)
## V2 notes [demo site](https://demo.myidlers.com/) **Note:** Create, Update and Delete are disabled.
V2 build is a complete overhaul of My idlers with the project being moved onto the Laravel framework. This will simplify
development and most of the features from the original build will be present in V2.
Using Laravel will bring in an API endpoint and the possibilities to show servers publicly with certain parameters
removed.
## Project sponsor ## Project sponsor
[Cloud Five Limited](https://cloud-v.net/) for providing the hosting for demo installation. [Cloud Five Limited](https://cloud-v.net/) for providing the hosting for demo installation.
## 2.0 changes: ## 2.1.0 changes:
**Unfortunately you cannot migrate your current install to the new 2.0 version** * Added Seedbox CRUD
* Added dark mode (settings option. Bootstrap-Night https://vinorodrigues.github.io/bootstrap-dark-5/)
* Laravel framework (version 9). * Added some foreign keys for certain tables
* Breeze authentication. * Added functions for IP and label assignments
* API GET for any of the CRUD data. * Added functions to forget (clear) cache, preventing chunks of duplicate code
* Labels (titles/desc) CRUD. * Added VMware to server virt select dropdown options
* Misc services CRUD. * Added Kharkiv and Sao Paulo to locations seeder
* DNS CRUD. * Updated Controllers with DB calls and logic moved to relevant Model
* Ip address CRUD. * Updated YABs inserts for version v2022-05-06
* Reseller hosting. * Updated DB calls to use caching
* Added Operating systems to DB, Deleting and creating them now possible. * Updated Home blade info cards to be col-6 instead of 12 when on mobile
* Make servers displayable public with config options to hide certain values. * Updated home page view links on recently added
* Vue JS used where possible. * Fixed YABs insert error not displaying
* Datatables used on large tables (Locations, labels, and providers).
* Added caching for home page and servers
## Requires ## Requires
* PHP 8 (minimum, compatible with 8.1) * PHP 8 (8.1 recommended)
## Features ## Features
@ -73,7 +65,16 @@ removed.
* Run `php artisan migrate:fresh --seed` to create tables and seed data * Run `php artisan migrate:fresh --seed` to create tables and seed data
* Run `php artisan serve` * Run `php artisan serve`
## Update
If you have at least version 2.0 installed:
* Run `git clone https://github.com/cp6/my-idlers.git`
* Run `composer install`
* Run `php artisan migrate`
## Run using Docker ## Run using Docker
``` ```
docker run \ docker run \
-p 8000:8000\ -p 8000:8000\
@ -140,6 +141,10 @@ All API requests must be appended with `api/` e.g `mydomain.com/api/servers/gYk8
`reseller/{id}` `reseller/{id}`
`seedbox/`
`seedbox/{id}`
`settings/` `settings/`
`shared/` `shared/`

View File

@ -142,6 +142,23 @@ class ApiController extends Controller
return response($reseller, 200); return response($reseller, 200);
} }
protected function getAllSeedbox()
{
$reseller = DB::table('seedboxes as sb')
->Join('pricings as p', 'sb.id', '=', 'p.service_id')
->get(['sb.*', 'p.id as price_id', 'p.currency', 'p.price', 'p.term', 'p.as_usd', 'p.usd_per_month', 'p.next_due_date'])->toJson(JSON_PRETTY_PRINT);
return response($reseller, 200);
}
protected function getSeedbox($id)
{
$reseller = DB::table('seedboxes as sb')
->Join('pricings as p', 'sb.id', '=', 'p.service_id')
->where('sb.id', '=', $id)
->get(['sb.*', 'p.id as price_id', 'p.currency', 'p.price', 'p.term', 'p.as_usd', 'p.usd_per_month', 'p.next_due_date'])->toJson(JSON_PRETTY_PRINT);
return response($reseller, 200);
}
protected function getAllDomains() protected function getAllDomains()
{ {
$domains = DB::table('domains as d') $domains = DB::table('domains as d')
@ -230,7 +247,7 @@ class ApiController extends Controller
protected function getAllOs() protected function getAllOs()
{ {
$os = OS::all()->toJson(JSON_PRETTY_PRINT); $os = OS::allOS()->toJson(JSON_PRETTY_PRINT);
return response($os, 200); return response($os, 200);
} }

View File

@ -10,6 +10,7 @@ use App\Models\Domains;
use App\Models\Shared; use App\Models\Shared;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -51,13 +52,9 @@ class DNSController extends Controller
'domain_id' => ($request->domain_id !== 'null') ? $request->domain_id : null 'domain_id' => ($request->domain_id !== 'null') ? $request->domain_id : null
]); ]);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4]; Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $dns_id);
for ($i = 1; $i <= 4; $i++) { Cache::forget('dns_count');
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned (label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $dns_id]);
}
}
return redirect()->route('dns.index') return redirect()->route('dns.index')
->with('success', 'DNS Created Successfully.'); ->with('success', 'DNS Created Successfully.');
@ -108,16 +105,9 @@ class DNSController extends Controller
'domain_id' => ($request->domain_id !== 'null') ? $request->domain_id : null 'domain_id' => ($request->domain_id !== 'null') ? $request->domain_id : null
]); ]);
Labels::deleteLabelsAssignedTo($dn->id);
$deleted = DB::table('labels_assigned')->where('service_id', '=', $dn->id)->delete(); Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $dn->id);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned ( label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $dn->id]);
}
}
return redirect()->route('dns.index') return redirect()->route('dns.index')
->with('success', 'DNS updated Successfully.'); ->with('success', 'DNS updated Successfully.');
@ -130,6 +120,8 @@ class DNSController extends Controller
$items->delete(); $items->delete();
Cache::forget('dns_count');
Labels::deleteLabelsAssignedTo($id); Labels::deleteLabelsAssignedTo($id);
return redirect()->route('dns.index') return redirect()->route('dns.index')

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Domains; use App\Models\Domains;
use App\Models\Home;
use App\Models\Labels; use App\Models\Labels;
use App\Models\Pricing; use App\Models\Pricing;
use App\Models\Providers; use App\Models\Providers;
@ -16,35 +17,22 @@ class DomainsController extends Controller
public function index() public function index()
{ {
$domains = DB::table('domains as d') $domains = Domains::domainsDataIndexPage();
->join('providers as p', 'd.provider_id', '=', 'p.id')
->join('pricings as pr', 'd.id', '=', 'pr.service_id')
->get(['d.*', 'p.name as provider_name', 'pr.*']);
return view('domains.index', compact(['domains'])); return view('domains.index', compact(['domains']));
} }
public function show(Domains $domain) public function show(Domains $domain)
{ {
$service_extras = Domains::domainsDataShowPage($domain->id);
$service_extras = DB::table('domains as d') $labels = Labels::labelsForService($domain->id);
->join('providers as p', 'd.provider_id', '=', 'p.id')
->join('pricings as pr', 'd.id', '=', 'pr.service_id')
->where('d.id', '=', $domain->id)
->get(['d.*', 'p.name as provider_name', 'pr.*']);
$labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $domain->id)
->get(['labels.label']);
return view('domains.show', compact(['domain', 'service_extras', 'labels'])); return view('domains.show', compact(['domain', 'service_extras', 'labels']));
} }
public function create() public function create()
{ {
$Providers = Providers::all(); return view('domains.create');
return view('domains.create', compact('Providers'));
} }
public function store(Request $request) public function store(Request $request)
@ -59,6 +47,12 @@ class DomainsController extends Controller
$domain_id = Str::random(8); $domain_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(4, $domain_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Domains::create([ Domains::create([
'id' => $domain_id, 'id' => $domain_id,
'domain' => $request->domain, 'domain' => $request->domain,
@ -70,32 +64,9 @@ class DomainsController extends Controller
'owned_since' => $request->owned_since 'owned_since' => $request->owned_since
]); ]);
$pricing = new Pricing(); Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $domain_id);
$as_usd = $pricing->convertToUSD($request->price, $request->currency); Home::homePageCacheForget();
Pricing::create([
'service_id' => $domain_id,
'service_type' => 4,
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
]);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned (label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $domain_id]);
}
}
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('domains.index') return redirect()->route('domains.index')
->with('success', 'Domain Created Successfully.'); ->with('success', 'Domain Created Successfully.');
@ -103,15 +74,9 @@ class DomainsController extends Controller
public function edit(Domains $domain) public function edit(Domains $domain)
{ {
$domain_info = DB::table('domains as d') $domain_info = Domains::domainsDataEditPage($domain->id);
->join('pricings as pr', 'd.id', '=', 'pr.service_id')
->where('d.id', '=', $domain->id)
->get(['d.*', 'pr.*']);
$labels = DB::table('labels_assigned as l') $labels = Labels::labelsForService($domain->id);
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $domain->id)
->get(['labels.id', 'labels.label']);
return view('domains.edit', compact(['domain', 'domain_info', 'labels'])); return view('domains.edit', compact(['domain', 'domain_info', 'labels']));
} }
@ -125,6 +90,12 @@ class DomainsController extends Controller
'price' => 'numeric' 'price' => 'numeric'
]); ]);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->updatePricing($domain->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
$domain->update([ $domain->update([
'domain' => $request->domain, 'domain' => $request->domain,
'extension' => $request->extension, 'extension' => $request->extension,
@ -136,36 +107,12 @@ class DomainsController extends Controller
'active' => (isset($request->is_active)) ? 1 : 0 'active' => (isset($request->is_active)) ? 1 : 0
]); ]);
$pricing = new Pricing(); Labels::deleteLabelsAssignedTo($domain->id);
$as_usd = $pricing->convertToUSD($request->price, $request->currency); Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $domain->id);
DB::table('pricings') Cache::forget("labels_for_service.{$domain->id}");
->where('service_id', $domain->id) Home::homePageCacheForget();
->update([
'service_type' => 4,
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
'active' => (isset($request->is_active)) ? 1 : 0
]);
$deleted = DB::table('labels_assigned')->where('service_id', '=', $domain->id)->delete();
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned ( label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $domain->id]);
}
}
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('domains.index') return redirect()->route('domains.index')
->with('success', 'Domain Updated Successfully.'); ->with('success', 'Domain Updated Successfully.');
@ -182,9 +129,7 @@ class DomainsController extends Controller
Labels::deleteLabelsAssignedTo($domain->id); Labels::deleteLabelsAssignedTo($domain->id);
Cache::forget('services_count');//Main page services_count cache Home::homePageCacheForget();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('domains.index') return redirect()->route('domains.index')
->with('success', 'Domain was deleted Successfully.'); ->with('success', 'Domain was deleted Successfully.');

View File

@ -2,23 +2,20 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\DNS;
use App\Models\Home;
use App\Models\Labels;
use App\Models\Pricing; use App\Models\Pricing;
use App\Models\Settings;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use App\Process; use App\Process;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
//Custom code example
class HomeController extends Controller class HomeController extends Controller
{ {
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct() public function __construct()
{ {
$this->middleware('auth'); $this->middleware('auth');
@ -29,161 +26,42 @@ class HomeController extends Controller
$p = new Process(); $p = new Process();
$p->startTimer(); $p->startTimer();
$services_count = Cache::remember('services_count', 1440, function () { //Get & set the settings, 1 minute cache
return DB::table('pricings') $settings = Settings::getSettings();
->select('service_type', DB::raw('COUNT(*) as amount')) Settings::setSettingsToSession($settings);
->groupBy('service_type')
->where('active', '=', 1)
->get();
});
$due_soon = Cache::remember('due_soon', 1440, function () {
return DB::table('pricings as p')
->leftJoin('servers as s', 'p.service_id', '=', 's.id')
->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id')
->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id')
->leftJoin('domains as d', 'p.service_id', '=', 'd.id')
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->where('p.active', '=', 1)
->orderBy('next_due_date', 'ASC')
->limit(Session::get('due_soon_amount'))
->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name']);
});
$server_summary = Cache::remember('servers_summary', 1440, function () {
$cpu_sum = DB::table('servers')->get()->where('active', '=', 1)->sum('cpu');
$ram_mb = DB::table('servers')->get()->where('active', '=', 1)->sum('ram_as_mb');
$disk_gb = DB::table('servers')->get()->where('active', '=', 1)->sum('disk_as_gb');
$bandwidth = DB::table('servers')->get()->where('active', '=', 1)->sum('bandwidth');
$locations_sum = DB::table('servers')->get()->where('active', '=', 1)->groupBy('location_id')->count();
$providers_sum = DB::table('servers')->get()->where('active', '=', 1)->groupBy('provider_id')->count();
return array(
'cpu_sum' => $cpu_sum,
'ram_mb_sum' => $ram_mb,
'disk_gb_sum' => $disk_gb,
'bandwidth_sum' => $bandwidth,
'locations_sum' => $locations_sum,
'providers_sum' => $providers_sum,
);
});
//Check for past due date and refresh the due date if so: //Check for past due date and refresh the due date if so:
$pricing = new Pricing(); $due_soon = Home::doDueSoon(Home::dueSoonData());
$count = 0;
foreach ($due_soon as $service) {
if (Carbon::createFromFormat('Y-m-d', $service->next_due_date)->isPast()) {
$months = $pricing->termAsMonths($service->term);//Get months for term to update the next due date to
$new_due_date = Carbon::createFromFormat('Y-m-d', $service->next_due_date)->addMonths($months)->format('Y-m-d');
DB::table('pricings')//Update the DB
->where('service_id', $service->service_id)
->update(['next_due_date' => $new_due_date]);
$due_soon[$count]->next_due_date = $new_due_date;//Update array being sent to view
} else {
break;//Break because if this date isnt past than the ones after it in the loop wont be either
}
$count++;
}
Cache::put('due_soon', $due_soon); //Orders services most recently added first, cached with limit from settings
$recently_added = Home::recentlyAdded();
$recently_added = Cache::remember('recently_added', 1440, function () { //Get count tally for each of the services type
return DB::table('pricings as p') $service_count = Home::doServicesCount(Home::servicesCount());
->leftJoin('servers as s', 'p.service_id', '=', 's.id')
->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id')
->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id')
->leftJoin('domains as d', 'p.service_id', '=', 'd.id')
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->where('p.active', '=', 1)
->orderBy('created_at', 'DESC')
->limit(Session::get('recently_added_amount'))
->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name']);
});
$settings = Cache::remember('settings', 15, function () { //Get pricing for weekly, monthly, yearly, 2 yearly
return DB::table('settings') $pricing_breakdown = Home::breakdownPricing(Pricing::allPricing());
->where('id', '=', 1)
->get();
});
Session::put('timer_version_footer', $settings[0]->show_versions_footer ?? 1); //Summary of servers specs
Session::put('show_servers_public', $settings[0]->show_servers_public ?? 0); $server_summary = Home::serverSummary();
Session::put('show_server_value_ip', $settings[0]->show_server_value_ip ?? 0);
Session::put('show_server_value_hostname', $settings[0]->show_server_value_hostname ?? 0);
Session::put('show_server_value_price', $settings[0]->show_server_value_price ?? 0);
Session::put('show_server_value_yabs', $settings[0]->show_server_value_yabs ?? 0);
Session::put('show_server_value_provider', $settings[0]->show_server_value_provider ?? 0);
Session::put('show_server_value_location', $settings[0]->show_server_value_location ?? 0);
Session::put('default_currency', $settings[0]->default_currency ?? 'USD');
Session::put('default_server_os', $settings[0]->default_server_os ?? 1);
Session::put('due_soon_amount', $settings[0]->due_soon_amount ?? 6);
Session::put('recently_added_amount', $settings[0]->recently_added_amount ?? 6);
Session::save();
$pricing = json_decode(DB::table('pricings')->get(), true);
$total_cost_weekly = $total_cost_pm = $inactive_count = 0;
foreach ($pricing as $price) {
if ($price['active'] === 1) {
if ($price['term'] === 1) {//1 month
$total_cost_weekly += ($price['as_usd'] / 4);
$total_cost_pm += $price['as_usd'];
} elseif ($price['term'] === 2) {//3 months
$total_cost_weekly += ($price['as_usd'] / 12);
$total_cost_pm += ($price['as_usd'] / 3);
} elseif ($price['term'] === 3) {// 6 month
$total_cost_weekly += ($price['as_usd'] / 24);
$total_cost_pm += ($price['as_usd'] / 6);
} elseif ($price['term'] === 4) {// 1 year
$total_cost_weekly += ($price['as_usd'] / 48);
$total_cost_pm += ($price['as_usd'] / 12);
} elseif ($price['term'] === 5) {//2 years
$total_cost_weekly += ($price['as_usd'] / 96);
$total_cost_pm += ($price['as_usd'] / 24);
} elseif ($price['term'] === 6) {//3 years
$total_cost_weekly += ($price['as_usd'] / 144);
$total_cost_pm += ($price['as_usd'] / 36);
}
} else {
$inactive_count++;
}
}
$total_cost_yearly = ($total_cost_pm * 12);
$services_count = json_decode($services_count, true);
$servers_count = $domains_count = $shared_count = $reseller_count = $other_count = $total_services = 0;
foreach ($services_count as $sc) {
$total_services += $sc['amount'];
if ($sc['service_type'] === 1) {
$servers_count = $sc['amount'];
} else if ($sc['service_type'] === 2) {
$shared_count = $sc['amount'];
} else if ($sc['service_type'] === 3) {
$reseller_count = $sc['amount'];
} else if ($sc['service_type'] === 4) {
$domains_count = $sc['amount'];
} else if ($sc['service_type'] === 5) {
$other_count = $sc['amount'];
}
}
$p->stopTimer(); $p->stopTimer();
$information = array( $information = array(
'servers' => $servers_count, 'servers' => $service_count['servers'],
'domains' => $domains_count, 'domains' => $service_count['domains'],
'shared' => $shared_count, 'shared' => $service_count['shared'],
'reseller' => $reseller_count, 'reseller' => $service_count['reseller'],
'misc' => $other_count, 'misc' => $service_count['other'],
'labels' => DB::table('labels')->count(), 'seedbox' => $service_count['seedbox'],
'dns' => DB::table('d_n_s')->count(), 'labels' => Labels::labelsCount(),
'total_services' => $total_services, 'dns' => DNS::dnsCount(),
'total_inactive' => $inactive_count, 'total_services' => $service_count['total'],
'total_cost_weekly' => number_format($total_cost_weekly, 2), 'total_inactive' => $pricing_breakdown['inactive_count'],
'total_cost_monthly' => number_format($total_cost_pm, 2), 'total_cost_weekly' => number_format($pricing_breakdown['total_cost_weekly'], 2),
'total_cost_yearly' => number_format($total_cost_yearly, 2), 'total_cost_monthly' => number_format($pricing_breakdown['total_cost_montly'], 2),
'total_cost_2_yearly' => number_format(($total_cost_yearly * 2), 2), 'total_cost_yearly' => number_format($pricing_breakdown['total_cost_yearly'], 2),
'total_cost_2_yearly' => number_format(($pricing_breakdown['total_cost_yearly'] * 2), 2),
'due_soon' => $due_soon, 'due_soon' => $due_soon,
'newest' => $recently_added, 'newest' => $recently_added,
'execution_time' => number_format($p->getTimeTaken(), 2), 'execution_time' => number_format($p->getTimeTaken(), 2),

View File

@ -34,6 +34,7 @@ class LabelsController extends Controller
]); ]);
Cache::forget('all_labels'); Cache::forget('all_labels');
Cache::forget('labels_count');
return redirect()->route('labels.index') return redirect()->route('labels.index')
->with('success', 'Label Created Successfully.'); ->with('success', 'Label Created Successfully.');
@ -66,6 +67,8 @@ class LabelsController extends Controller
$items->delete(); $items->delete();
Cache::forget('labels_count');
Labels::deleteLabelAssignedAs($label_id); Labels::deleteLabelAssignedAs($label_id);
Cache::forget('all_labels'); Cache::forget('all_labels');

View File

@ -12,7 +12,7 @@ class LocationsController extends Controller
{ {
public function index() public function index()
{ {
$locations = Locations::all(); $locations = Locations::allLocations();
return view('locations.index', compact(['locations'])); return view('locations.index', compact(['locations']));
} }
@ -31,7 +31,7 @@ class LocationsController extends Controller
'name' => $request->location_name 'name' => $request->location_name
]); ]);
Cache::forget('all_locations'); Cache::forget('locations');
return redirect()->route('locations.index') return redirect()->route('locations.index')
->with('success', 'Location Created Successfully.'); ->with('success', 'Location Created Successfully.');
@ -65,7 +65,7 @@ class LocationsController extends Controller
$items->delete(); $items->delete();
Cache::forget('all_locations'); Cache::forget('locations');
return redirect()->route('locations.index') return redirect()->route('locations.index')
->with('success', 'Location was deleted Successfully.'); ->with('success', 'Location was deleted Successfully.');

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\Misc; use App\Models\Misc;
use App\Models\Pricing; use App\Models\Pricing;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -46,30 +47,19 @@ class MiscController extends Controller
$ms_id = Str::random(8); $ms_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(5, $ms_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Misc::create([ Misc::create([
'id' => $ms_id, 'id' => $ms_id,
'name' => $request->name, 'name' => $request->name,
'owned_since' => $request->owned_since 'owned_since' => $request->owned_since
]); ]);
$pricing = new Pricing(); Home::homePageCacheForget();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
Pricing::create([
'service_id' => $ms_id,
'service_type' => 5,
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
]);
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('misc.index') return redirect()->route('misc.index')
->with('success', 'Misc service created Successfully.'); ->with('success', 'Misc service created Successfully.');
@ -104,21 +94,9 @@ class MiscController extends Controller
$as_usd = $pricing->convertToUSD($request->price, $request->currency); $as_usd = $pricing->convertToUSD($request->price, $request->currency);
DB::table('pricings') $pricing->updatePricing($misc->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
->where('service_id', $misc->id)
->update([
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
'active' => (isset($request->is_active)) ? 1 : 0
]);
Cache::forget('services_count');//Main page services_count cache Home::homePageCacheForget();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('misc.index') return redirect()->route('misc.index')
->with('success', 'Misc service updated Successfully.'); ->with('success', 'Misc service updated Successfully.');
@ -133,9 +111,7 @@ class MiscController extends Controller
$p = new Pricing(); $p = new Pricing();
$p->deletePricing($misc->id); $p->deletePricing($misc->id);
Cache::forget('services_count');//Main page services_count cache Home::homePageCacheForget();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('misc.index') return redirect()->route('misc.index')
->with('success', 'Misc service was deleted Successfully.'); ->with('success', 'Misc service was deleted Successfully.');

View File

@ -10,7 +10,7 @@ class OsController extends Controller
{ {
public function index() public function index()
{ {
$os = OS::all(); $os = OS::allOS();
return view('os.index', compact(['os'])); return view('os.index', compact(['os']));
} }
@ -29,7 +29,7 @@ class OsController extends Controller
'name' => $request->os_name 'name' => $request->os_name
]); ]);
Cache::forget('all_os'); Cache::forget('operating_systems');
return redirect()->route('os.index') return redirect()->route('os.index')
->with('success', 'OS Created Successfully.'); ->with('success', 'OS Created Successfully.');
@ -41,7 +41,7 @@ class OsController extends Controller
$items->delete(); $items->delete();
Cache::forget('all_os'); Cache::forget('operating_systems');
return redirect()->route('os.index') return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.'); ->with('success', 'OS was deleted Successfully.');

View File

@ -12,7 +12,7 @@ class ProvidersController extends Controller
{ {
public function index() public function index()
{ {
$providers = Providers::all(); $providers = Providers::allProviders();
return view('providers.index', compact(['providers'])); return view('providers.index', compact(['providers']));
} }
@ -31,7 +31,7 @@ class ProvidersController extends Controller
'name' => $request->provider_name 'name' => $request->provider_name
]); ]);
Cache::forget('all_providers'); Cache::forget('providers');
return redirect()->route('providers.index') return redirect()->route('providers.index')
->with('success', 'Provider Created Successfully.'); ->with('success', 'Provider Created Successfully.');
@ -39,22 +39,7 @@ class ProvidersController extends Controller
public function show(Providers $provider) public function show(Providers $provider)
{ {
$servers = DB::table('servers as s') $data = Providers::showServicesForProvider($provider->id);
->where('s.provider_id', '=', $provider->id)
->get(['s.id', 's.hostname'])
->toArray();
$shared = DB::table('shared_hosting as s')
->where('s.provider_id', '=', $provider->id)
->get(['s.id', 's.main_domain as main_domain_shared'])
->toArray();
$reseller = DB::table('reseller_hosting as r')
->where('r.provider_id', '=', $provider->id)
->get(['r.id', 'r.main_domain as main_domain_reseller'])
->toArray();
$data = array_merge($servers, $shared, $reseller);
return view('providers.show', compact(['provider', 'data'])); return view('providers.show', compact(['provider', 'data']));
} }
@ -65,7 +50,7 @@ class ProvidersController extends Controller
$items->delete(); $items->delete();
Cache::forget('all_providers'); Cache::forget('providers');
return redirect()->route('providers.index') return redirect()->route('providers.index')
->with('success', 'Provider was deleted Successfully.'); ->with('success', 'Provider was deleted Successfully.');

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\IPs; use App\Models\IPs;
use App\Models\Labels; use App\Models\Labels;
use App\Models\Locations; use App\Models\Locations;
@ -17,19 +18,15 @@ class ResellerController extends Controller
{ {
public function index() public function index()
{ {
$resellers = DB::table('reseller_hosting as s') $resellers = Reseller::resellerDataIndexPage();
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->get(['s.*', 'p.name as provider_name', 'pr.*', 'l.name as location']);
return view('reseller.index', compact(['resellers'])); return view('reseller.index', compact(['resellers']));
} }
public function create() public function create()
{ {
$Providers = Providers::all(); $Providers = Providers::allProviders();
$Locations = Locations::all(); $Locations = Locations::allLocations();
return view('reseller.create', compact(['Providers', 'Locations'])); return view('reseller.create', compact(['Providers', 'Locations']));
} }
@ -62,6 +59,18 @@ class ResellerController extends Controller
$reseller_id = Str::random(8); $reseller_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(3, $reseller_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
if (!is_null($request->dedicated_ip)) {
IPs::insertIP($reseller_id, $request->dedicated_ip);
}
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $reseller_id);
Reseller::create([ Reseller::create([
'id' => $reseller_id, 'id' => $reseller_id,
'main_domain' => $request->domain, 'main_domain' => $request->domain,
@ -82,44 +91,7 @@ class ResellerController extends Controller
'db_limit' => $request->db 'db_limit' => $request->db
]); ]);
$pricing = new Pricing(); Home::homePageCacheForget();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
Pricing::create([
'service_id' => $reseller_id,
'service_type' => 3,
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
]);
if (!is_null($request->dedicated_ip)) {
IPs::create(
[
'id' => Str::random(8),
'service_id' => $reseller_id,
'address' => $request->dedicated_ip,
'is_ipv4' => (filter_var($request->dedicated_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1,
'active' => 1
]
);
}
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned (label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $reseller_id]);
}
}
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('reseller.index') return redirect()->route('reseller.index')
->with('success', 'Reseller hosting created Successfully.'); ->with('success', 'Reseller hosting created Successfully.');
@ -128,45 +100,23 @@ class ResellerController extends Controller
public function show(Reseller $reseller) public function show(Reseller $reseller)
{ {
$reseller_extras = DB::table('reseller_hosting as s') $reseller_extras = Reseller::resellerDataShowPage($reseller->id);
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $reseller->id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
$labels = DB::table('labels_assigned as l') $labels = Labels::labelsForService($reseller->id);
->LeftJoin('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $reseller->id)
->get(['labels.label']);
$ip_address = DB::table('ips as i')
->where('i.service_id', '=', $reseller->id)
->get();
$ip_address = IPs::ipsForServer($reseller->id);
return view('reseller.show', compact(['reseller', 'reseller_extras', 'labels', 'ip_address'])); return view('reseller.show', compact(['reseller', 'reseller_extras', 'labels', 'ip_address']));
} }
public function edit(Reseller $reseller) public function edit(Reseller $reseller)
{ {
$locations = DB::table('locations')->get(['*']); $labels = Labels::labelsForService($reseller->id);
$providers = json_decode(DB::table('providers')->get(['*']), true);
$labels = DB::table('labels_assigned as l') $ip_address = IPs::ipsForServer($reseller->id);
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $reseller->id)
->get(['labels.id', 'labels.label']);
$ip_address = json_decode(DB::table('ips as i') $reseller = Reseller::resellerDataEditPage($reseller->id);
->where('i.service_id', '=', $reseller->id)
->get(), true);
$reseller = DB::table('reseller_hosting as s') return view('reseller.edit', compact(['reseller', 'ip_address', 'labels']));
->join('pricings as p', 's.id', '=', 'p.service_id')
->where('s.id', '=', $reseller->id)
->get(['s.*', 'p.*']);
return view('reseller.edit', compact(['reseller', 'locations', 'providers', 'ip_address', 'labels']));
} }
public function update(Request $request, Reseller $reseller) public function update(Request $request, Reseller $reseller)
@ -217,41 +167,21 @@ class ResellerController extends Controller
$as_usd = $pricing->convertToUSD($request->price, $request->currency); $as_usd = $pricing->convertToUSD($request->price, $request->currency);
DB::table('pricings') $pricing->updatePricing($request->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
->where('service_id', $request->id)
->update([
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
]);
$deleted = DB::table('labels_assigned')->where('service_id', '=', $request->id)->delete(); Labels::deleteLabelsAssignedTo($request->id);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4]; Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $request->id);
for ($i = 1; $i <= 4; $i++) { IPs::deleteIPsAssignedTo($request->id);
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned ( label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $request->id]);
}
}
$delete_ip = DB::table('ips')->where('service_id', '=', $request->id)->delete();
if (isset($request->dedicated_ip)) { if (isset($request->dedicated_ip)) {
DB::insert('INSERT INTO ips (id, address, service_id, is_ipv4) values (?, ?, ?, ?)', [ IPs::insertIP($request->id, $request->dedicated_ip);
Str::random(8),
$request->dedicated_ip,
$request->id,
(filter_var($request->dedicated_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1
]);
} }
Cache::forget('services_count');//Main page services_count cache Cache::forget("labels_for_service.{$request->id}");
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache Home::homePageCacheForget();
return redirect()->route('reseller.index') return redirect()->route('reseller.index')
->with('success', 'Reseller hosting updated Successfully.'); ->with('success', 'Reseller hosting updated Successfully.');
@ -271,9 +201,7 @@ class ResellerController extends Controller
IPs::deleteIPsAssignedTo($id); IPs::deleteIPsAssignedTo($id);
Cache::forget('services_count');//Main page services_count cache Home::homePageCacheForget();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('reseller.index') return redirect()->route('reseller.index')
->with('success', 'Reseller hosting was deleted Successfully.'); ->with('success', 'Reseller hosting was deleted Successfully.');

View File

@ -0,0 +1,170 @@
<?php
namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\IPs;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\SeedBoxes;
use App\Models\Shared;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class SeedBoxesController extends Controller
{
public function index()
{
$seedboxes = SeedBoxes::seedBoxesDataIndexPage();
return view('seedboxes.index', compact(['seedboxes']));
}
public function create()
{
return view('seedboxes.create');
}
public function store(Request $request)
{
$request->validate([
'title' => 'required|string',
'hostname' => 'string|nullable',
'seed_box_type' => 'required',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'disk' => 'numeric',
'bandwidth' => 'numeric',
'port_speed' => 'numeric',
'next_due_date' => 'required|date'
]);
$seedbox_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(6, $seedbox_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Labels::deleteLabelsAssignedTo($seedbox_id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $seedbox_id);
SeedBoxes::create([
'id' => $seedbox_id,
'title' => $request->title,
'hostname' => $request->hostname,
'seed_box_type' => $request->seed_box_type,
'provider_id' => $request->provider_id,
'location_id' => $request->location_id,
'disk' => $request->disk,
'disk_type' => 'GB',
'disk_as_gb' => $request->disk,
'owned_since' => $request->owned_since,
'bandwidth' => $request->bandwidth,
'port_speed' => $request->port_speed,
'was_promo' => $request->was_promo
]);
Home::homePageCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box created Successfully.');
}
public function show(SeedBoxes $seedbox)
{
$seedbox_extras = SeedBoxes::seedBoxDataShowPage($seedbox->id);
$labels = Labels::labelsForService($seedbox->id);
return view('seedboxes.show', compact(['seedbox', 'seedbox_extras', 'labels']));
}
public function edit(SeedBoxes $seedbox)
{
$seedbox = SeedBoxes::seedBoxEditDataPage($seedbox->id);
$labels = Labels::labelsForService($seedbox[0]->id);
return view('seedboxes.edit', compact(['seedbox', 'labels']));
}
public function update(Request $request, SeedBoxes $seedbox)
{
$request->validate([
'id' => 'required|size:8',
'title' => 'required|string',
'hostname' => 'string|nullable',
'seed_box_type' => 'required',
'disk' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'bandwidth' => 'numeric',
'port_speed' => 'numeric'
]);
DB::table('seedboxes')
->where('id', $seedbox->id)
->update([
'title' => $request->title,
'hostname' => $request->hostname,
'seed_box_type' => $request->seed_box_type,
'location_id' => $request->location_id,
'provider_id' => $request->provider_id,
'disk' => $request->disk,
'disk_type' => 'GB',
'disk_as_gb' => $request->disk,
'owned_since' => $request->owned_since,
'bandwidth' => $request->bandwidth,
'port_speed' => $request->port_speed,
'was_promo' => $request->was_promo
]);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->updatePricing($seedbox->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Labels::deleteLabelsAssignedTo($seedbox->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $seedbox->id);
Cache::forget("labels_for_service.{$seedbox->id}");
Home::homePageCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box updated Successfully.');
}
public function destroy(SeedBoxes $seedbox)
{
$seedbox_id = $seedbox->id;
$items = SeedBoxes::find($seedbox_id);
$items->delete();
$p = new Pricing();
$p->deletePricing($seedbox_id);
Labels::deleteLabelsAssignedTo($seedbox_id);
Home::homePageCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box was deleted Successfully.');
}
}

View File

@ -4,53 +4,31 @@ namespace App\Http\Controllers;
use App\Models\IPs; use App\Models\IPs;
use App\Models\Labels; use App\Models\Labels;
use App\Models\OS;
use App\Models\Pricing; use App\Models\Pricing;
use App\Models\Server; use App\Models\Server;
use App\Models\Providers; use App\Models\Settings;
use App\Models\Locations; use App\Models\Yabs;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class ServerController extends Controller class ServerController extends Controller
{ {
public function index() public function index()
{ {
$servers = Cache::remember('all_active_servers', 1440, function () { $servers = Server::activeServersDataIndexPage();
return DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->where('s.active', '=', 1)
->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']);
});
$non_active_servers = Cache::remember('non_active_servers', 1440, function () { $non_active_servers = Server::nonActiveServersDataIndexPage();
return DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->where('s.active', '=', 0)
->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']);
});
return view('servers.index', compact(['servers', 'non_active_servers'])); return view('servers.index', compact(['servers', 'non_active_servers']));
} }
public function showServersPublic() public function showServersPublic()
{ {
$settings = DB::table('settings') $settings = Settings::getSettings();
->where('id', '=', 1)
->get();
Session::put('timer_version_footer', $settings[0]->show_versions_footer ?? 1); Session::put('timer_version_footer', $settings[0]->show_versions_footer ?? 1);
Session::put('show_servers_public', $settings[0]->show_servers_public ?? 0); Session::put('show_servers_public', $settings[0]->show_servers_public ?? 0);
@ -63,17 +41,7 @@ class ServerController extends Controller
Session::save(); Session::save();
if ((Session::get('show_servers_public') === 1)) { if ((Session::get('show_servers_public') === 1)) {
$servers = DB::table('servers as s') $servers = Server::publicServerData();
->Join('pricings as pr', 's.id', '=', 'pr.service_id')
->Join('providers as p', 's.provider_id', '=', 'p.id')
->Join('locations as l', 's.location_id', '=', 'l.id')
->Join('os as o', 's.os_id', '=', 'o.id')
->LeftJoin('ips as i', 's.id', '=', 'i.service_id')
->LeftJoin('yabs as y', 's.id', '=', 'y.server_id')
->LeftJoin('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.show_public', '=', 1)
->get(['pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'pr.service_id', 'p.name as provider_name', 'l.name as location', 'o.name as os_name', 'y.*', 'y.id as yabs_id', 'ds.*', 's.*', 'i.address as ip', 'i.is_ipv4']);
return view('servers.public-index', compact('servers')); return view('servers.public-index', compact('servers'));
} }
return response()->view('errors.404', array("status" => 404, "title" => "Page not found", "message" => ""), 404); return response()->view('errors.404', array("status" => 404, "title" => "Page not found", "message" => ""), 404);
@ -81,10 +49,7 @@ class ServerController extends Controller
public function create() public function create()
{ {
$Providers = Providers::all(); return view('servers.create');
$Locations = Locations::all();
$Os = OS::all();
return view('servers.create', compact(['Providers', 'Locations', 'Os']));
} }
public function store(Request $request) public function store(Request $request)
@ -109,6 +74,20 @@ class ServerController extends Controller
$server_id = Str::random(8); $server_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
if (!is_null($request->ip1)) {
IPs::insertIP($server_id, $request->ip1);
}
if (!is_null($request->ip2)) {
IPs::insertIP($server_id, $request->ip2);
}
Server::create([ Server::create([
'id' => $server_id, 'id' => $server_id,
'hostname' => $request->hostname, 'hostname' => $request->hostname,
@ -132,59 +111,9 @@ class ServerController extends Controller
'show_public' => (isset($request->show_public)) ? 1 : 0 'show_public' => (isset($request->show_public)) ? 1 : 0
]); ]);
if (!is_null($request->ip1)) { Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $server_id);
IPs::create(
[
'id' => Str::random(8),
'service_id' => $server_id,
'address' => $request->ip1,
'is_ipv4' => (filter_var($request->ip1, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1,
'active' => 1
]
);
}
if (!is_null($request->ip2)) { Server::serverRelatedCacheForget();
IPs::create(
[
'id' => Str::random(8),
'service_id' => $server_id,
'address' => $request->ip2,
'is_ipv4' => (filter_var($request->ip2, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1,
'active' => 1
]
);
}
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
Pricing::create([
'service_id' => $server_id,
'service_type' => 1,
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
]);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned (label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $server_id]);
}
}
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_active_servers');//all servers cache
Cache::forget('non_active_servers');//all servers cache
Cache::forget('servers_summary');//servers summary cache
return redirect()->route('servers.index') return redirect()->route('servers.index')
->with('success', 'Server Created Successfully.'); ->with('success', 'Server Created Successfully.');
@ -192,53 +121,24 @@ class ServerController extends Controller
public function show(Server $server) public function show(Server $server)
{ {
$server_extras = DB::table('servers as s') $server_extras = Server::serverDataShowPage($server->id);
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->Leftjoin('yabs as y', 's.id', '=', 'y.server_id')
->Leftjoin('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.id', '=', $server->id)
->get(['s.*', 'p.name as provider', 'l.name as location', 'o.name as os_name', 'pr.*', 'y.*', 'ds.*']);
$network_speeds = json_decode(DB::table('network_speed') $network_speeds = Yabs::networkSpeedsForServer($server->id);
->where('network_speed.server_id', '=', $server->id)
->get(), true);
$ip_addresses = json_decode(DB::table('ips as i') $ip_addresses = IPs::ipsForServer($server->id);
->where('i.service_id', '=', $server->id)
->get(), true);
$labels = DB::table('labels_assigned as l') $labels = Labels::labelsForService($server->id);
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $server->id)
->get(['labels.label']);
return view('servers.show', compact(['server', 'server_extras', 'network_speeds', 'labels', 'ip_addresses'])); return view('servers.show', compact(['server', 'server_extras', 'network_speeds', 'labels', 'ip_addresses']));
} }
public function edit(Server $server) public function edit(Server $server)
{ {
$locations = DB::table('locations')->get(['*']); $ip_addresses = IPs::ipsForServer($server->id);
$providers = DB::table('providers')->get(['*']);
$labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $server->id)
->get(['labels.id', 'labels.label']);
$os = DB::table('os')->get(['*']); $server = Pricing::pricingForService($server->id);
$ip_addresses = json_decode(DB::table('ips as i') return view('servers.edit', compact(['server', 'ip_addresses']));
->where('i.service_id', '=', $server->id)
->get(), true);
$server = DB::table('servers as s')
->join('pricings as p', 's.id', '=', 'p.service_id')
->where('s.id', '=', $server->id)
->get(['s.*', 'p.*']);
return view('servers.edit', compact(['server', 'locations', 'providers', 'os', 'labels', 'ip_addresses']));
} }
public function update(Request $request, Server $server) public function update(Request $request, Server $server)
@ -256,9 +156,10 @@ class ServerController extends Controller
'next_due_date' => 'date' 'next_due_date' => 'date'
]); ]);
$server_id = $request->server_id;
DB::table('servers') DB::table('servers')
->where('id', $request->server_id) ->where('id', $server_id)
->update([ ->update([
'hostname' => $request->hostname, 'hostname' => $request->hostname,
'server_type' => $request->server_type, 'server_type' => $request->server_type,
@ -286,49 +187,23 @@ class ServerController extends Controller
$as_usd = $pricing->convertToUSD($request->price, $request->currency); $as_usd = $pricing->convertToUSD($request->price, $request->currency);
DB::table('pricings') $pricing->updatePricing($server_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
->where('service_id', $request->server_id)
->update([
'service_type' => 1,
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
'active' => (isset($request->is_active)) ? 1 : 0
]);
$deleted = DB::table('labels_assigned')->where('service_id', '=', $server->id)->delete(); Labels::deleteLabelsAssignedTo($server_id);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4]; Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $server_id);
for ($i = 1; $i <= 4; $i++) { IPs::deleteIPsAssignedTo($server_id);
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned ( label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $request->server_id]);
}
}
$deleted = DB::table('ips')->where('service_id', '=', $server->id)->delete();
for ($i = 1; $i <= 8; $i++) {//Max of 8 ips for ($i = 1; $i <= 8; $i++) {//Max of 8 ips
$obj = 'ip' . $i; $obj = 'ip' . $i;
if (isset($request->$obj) && !is_null($request->$obj)) { if (isset($request->$obj) && !is_null($request->$obj)) {
DB::insert('INSERT INTO ips (id, address, service_id, is_ipv4) values (?, ?, ?, ?)', [ IPs::insertIP($server_id, $request->$obj);
Str::random(8),
$request->$obj,
$request->server_id,
(filter_var($request->$obj, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1
]);
} }
} }
Cache::forget('services_count');//Main page services_count cache Server::serverRelatedCacheForget();
Cache::forget('due_soon');//Main page due_soon cache Server::serverSpecificCacheForget($server_id);
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_active_servers');//all servers cache
Cache::forget('non_active_servers');//all servers cache
Cache::forget('servers_summary');//servers summary cache
return redirect()->route('servers.index') return redirect()->route('servers.index')
->with('success', 'Server Updated Successfully.'); ->with('success', 'Server Updated Successfully.');
@ -347,12 +222,7 @@ class ServerController extends Controller
IPs::deleteIPsAssignedTo($server->id); IPs::deleteIPsAssignedTo($server->id);
Cache::forget('services_count');//Main page services_count cache Server::serverRelatedCacheForget();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_active_servers');//all servers cache
Cache::forget('non_active_servers');//all servers cache
Cache::forget('servers_summary');//servers summary cache
return redirect()->route('servers.index') return redirect()->route('servers.index')
->with('success', 'Server was deleted Successfully.'); ->with('success', 'Server was deleted Successfully.');
@ -366,40 +236,21 @@ class ServerController extends Controller
public function compareServers($server1, $server2) public function compareServers($server1, $server2)
{ {
$server1_data = DB::table('servers as s') $server1_data = Server::serverCompareData($server1);
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->Join('yabs as y', 's.id', '=', 'y.server_id')
->Join('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.id', '=', $server1)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*', 'y.*', 'y.id as yabs_id', 'ds.*']);
if (count($server1_data) === 0) { if (count($server1_data) === 0) {
return response()->view('errors.404', array("status" => 404, "title" => "Page not found", "message" => "No server with YABs data was found for id '$server1'"), 404); return response()->view('errors.404', array("status" => 404, "title" => "Page not found", "message" => "No server with YABs data was found for id '$server1'"), 404);
} }
$server1_network = DB::table('network_speed') $server1_network = Yabs::serverCompareNetwork($server1_data[0]->yabs_id);
->where('id', '=', $server1_data[0]->yabs_id)
->get();
$server2_data = DB::table('servers as s') $server2_data = Server::serverCompareData($server2);
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->Join('yabs as y', 's.id', '=', 'y.server_id')
->Join('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.id', '=', $server2)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*', 'y.*', 'y.id as yabs_id', 'ds.*']);
if (count($server2_data) === 0) { if (count($server2_data) === 0) {
return response()->view('errors.404', array("status" => 404, "title" => "Page not found", "message" => "No server with YABs data was found for id '$server2'"), 404); return response()->view('errors.404', array("status" => 404, "title" => "Page not found", "message" => "No server with YABs data was found for id '$server2'"), 404);
} }
$server2_network = DB::table('network_speed') $server2_network = Yabs::serverCompareNetwork($server2_data[0]->yabs_id);
->where('id', '=', $server2_data[0]->yabs_id)
->get();
return view('servers.compare', compact('server1_data', 'server2_data', 'server1_network', 'server2_network')); return view('servers.compare', compact('server1_data', 'server2_data', 'server1_network', 'server2_network'));
} }
} }

View File

@ -22,6 +22,7 @@ class SettingsController extends Controller
public function update(Request $request, Settings $settings) public function update(Request $request, Settings $settings)
{ {
$request->validate([ $request->validate([
'dark_mode' => 'required|boolean',
'show_versions_footer' => 'required|boolean', 'show_versions_footer' => 'required|boolean',
'show_server_value_ip' => 'required|boolean', 'show_server_value_ip' => 'required|boolean',
'show_server_value_hostname' => 'required|boolean', 'show_server_value_hostname' => 'required|boolean',
@ -38,6 +39,7 @@ class SettingsController extends Controller
DB::table('settings') DB::table('settings')
->where('id', 1) ->where('id', 1)
->update([ ->update([
'dark_mode' => $request->dark_mode,
'show_versions_footer' => $request->show_versions_footer, 'show_versions_footer' => $request->show_versions_footer,
'show_servers_public' => $request->show_servers_public, 'show_servers_public' => $request->show_servers_public,
'show_server_value_ip' => $request->show_server_value_ip, 'show_server_value_ip' => $request->show_server_value_ip,
@ -52,19 +54,7 @@ class SettingsController extends Controller
'recently_added_amount' => $request->recently_added_amount 'recently_added_amount' => $request->recently_added_amount
]); ]);
Session::put('timer_version_footer', $request->show_versions_footer); Settings::setSettingsToSession($settings);
Session::put('show_servers_public', $request->show_servers_public);
Session::put('show_server_value_ip', $request->show_server_value_ip);
Session::put('show_server_value_hostname', $request->show_server_value_hostname);
Session::put('show_server_value_price', $request->show_server_value_price);
Session::put('show_server_value_yabs', $request->show_server_value_yabs);
Session::put('show_server_value_provider', $request->show_server_value_provider);
Session::put('show_server_value_location', $request->show_server_value_location);
Session::put('default_currency', $request->default_currency);
Session::put('default_server_os', $request->default_server_os);
Session::put('due_soon_amount', $request->due_soon_amount);
Session::put('recently_added_amount', $request->recently_added_amount);
Session::save();
Cache::forget('due_soon');//Main page due_soon cache Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache Cache::forget('recently_added');//Main page recently_added cache

View File

@ -2,11 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\IPs; use App\Models\IPs;
use App\Models\Labels; use App\Models\Labels;
use App\Models\Locations;
use App\Models\Pricing; use App\Models\Pricing;
use App\Models\Providers;
use App\Models\Shared; use App\Models\Shared;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
@ -17,20 +16,14 @@ class SharedController extends Controller
{ {
public function index() public function index()
{ {
$shared = DB::table('shared_hosting as s') $shared = Shared::sharedDataIndexPage();
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->get(['s.*', 'p.name as provider_name', 'pr.*', 'l.name as location']);
return view('shared.index', compact(['shared'])); return view('shared.index', compact(['shared']));
} }
public function create() public function create()
{ {
$Providers = Providers::all(); return view('shared.create');
$Locations = Locations::all();
return view('shared.create', compact(['Providers', 'Locations']));
} }
public function store(Request $request) public function store(Request $request)
@ -60,6 +53,22 @@ class SharedController extends Controller
$shared_id = Str::random(8); $shared_id = Str::random(8);
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
$pricing->insertPricing(2, $shared_id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
Labels::deleteLabelsAssignedTo($shared_id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $shared_id);
IPs::deleteIPsAssignedTo($shared_id);
if (!is_null($request->dedicated_ip)) {
IPs::insertIP($shared_id, $request->dedicated_ip);
}
Shared::create([ Shared::create([
'id' => $shared_id, 'id' => $shared_id,
'main_domain' => $request->domain, 'main_domain' => $request->domain,
@ -79,44 +88,7 @@ class SharedController extends Controller
'db__limit' => $request->db 'db__limit' => $request->db
]); ]);
$pricing = new Pricing(); Home::homePageCacheForget();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
Pricing::create([
'service_id' => $shared_id,
'service_type' => 2,
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
]);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned (label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $shared_id]);
}
}
if (!is_null($request->dedicated_ip)) {
IPs::create(
[
'id' => Str::random(8),
'service_id' => $shared_id,
'address' => $request->dedicated_ip,
'is_ipv4' => (filter_var($request->dedicated_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1,
'active' => 1
]
);
}
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('shared.index') return redirect()->route('shared.index')
->with('success', 'Shared hosting created Successfully.'); ->with('success', 'Shared hosting created Successfully.');
@ -124,44 +96,24 @@ class SharedController extends Controller
public function show(Shared $shared) public function show(Shared $shared)
{ {
$shared_extras = DB::table('shared_hosting as s') $shared_extras = Shared::sharedDataShowPage($shared->id);
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $shared->id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
$labels = DB::table('labels_assigned as l') $labels = Labels::labelsForService($shared->id);
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $shared->id)
->get(['labels.label']);
$ip_address = DB::table('ips as i') $ip_address = IPs::ipsForServer($shared->id);
->where('i.service_id', '=', $shared->id)
->get();
return view('shared.show', compact(['shared', 'shared_extras', 'labels', 'ip_address'])); return view('shared.show', compact(['shared', 'shared_extras', 'labels', 'ip_address']));
} }
public function edit(Shared $shared) public function edit(Shared $shared)
{ {
$locations = DB::table('locations')->get(['*']); $labels = Labels::labelsForService($shared->id);
$providers = json_decode(DB::table('providers')->get(['*']), true);
$labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $shared->id)
->get(['labels.id', 'labels.label']);
$ip_address = json_decode(DB::table('ips as i') $ip_address = IPs::ipsForServer($shared->id);
->where('i.service_id', '=', $shared->id)
->get(), true);
$shared = DB::table('shared_hosting as s') $shared = Shared::sharedEditDataPage($shared->id);
->join('pricings as p', 's.id', '=', 'p.service_id')
->where('s.id', '=', $shared->id)
->get(['s.*', 'p.*']);
return view('shared.edit', compact(['shared', 'locations', 'providers', 'labels', 'ip_address'])); return view('shared.edit', compact(['shared', 'labels', 'ip_address']));
} }
public function update(Request $request, Shared $shared) public function update(Request $request, Shared $shared)
@ -212,41 +164,21 @@ class SharedController extends Controller
$as_usd = $pricing->convertToUSD($request->price, $request->currency); $as_usd = $pricing->convertToUSD($request->price, $request->currency);
DB::table('pricings') $pricing->updatePricing($request->id, $request->currency, $request->price, $request->payment_term, $as_usd, $request->next_due_date);
->where('service_id', $request->id)
->update([
'currency' => $request->currency,
'price' => $request->price,
'term' => $request->payment_term,
'as_usd' => $as_usd,
'usd_per_month' => $pricing->costAsPerMonth($as_usd, $request->payment_term),
'next_due_date' => $request->next_due_date,
]);
$deleted = DB::table('labels_assigned')->where('service_id', '=', $request->id)->delete(); Labels::deleteLabelsAssignedTo($request->id);
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4]; Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $request->id);
for ($i = 1; $i <= 4; $i++) { Cache::forget("labels_for_service.{$request->id}");
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned ( label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $request->id]);
}
}
$delete_ip = DB::table('ips')->where('service_id', '=', $request->id)->delete(); IPs::deleteIPsAssignedTo($request->id);
if (isset($request->dedicated_ip)) { if (isset($request->dedicated_ip)) {
DB::insert('INSERT INTO ips (id, address, service_id, is_ipv4) values (?, ?, ?, ?)', [ IPs::insertIP($request->id, $request->dedicated_ip);
Str::random(8),
$request->dedicated_ip,
$request->id,
(filter_var($request->dedicated_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1
]);
} }
Cache::forget('services_count');//Main page services_count cache Home::homePageCacheForget();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('shared.index') return redirect()->route('shared.index')
->with('success', 'Shared hosting updated Successfully.'); ->with('success', 'Shared hosting updated Successfully.');
@ -254,21 +186,19 @@ class SharedController extends Controller
public function destroy(Shared $shared) public function destroy(Shared $shared)
{ {
$id = $shared->id; $shared_id = $shared->id;
$items = Shared::find($id); $items = Shared::find($shared_id);
$items->delete(); $items->delete();
$p = new Pricing(); $p = new Pricing();
$p->deletePricing($shared->id); $p->deletePricing($shared_id);
Labels::deleteLabelsAssignedTo($shared->id); Labels::deleteLabelsAssignedTo($shared_id);
IPs::deleteIPsAssignedTo($shared->id); IPs::deleteIPsAssignedTo($shared_id);
Cache::forget('services_count');//Main page services_count cache Home::homePageCacheForget();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
return redirect()->route('shared.index') return redirect()->route('shared.index')
->with('success', 'Shared hosting was deleted Successfully.'); ->with('success', 'Shared hosting was deleted Successfully.');

View File

@ -37,8 +37,8 @@ class YabsController extends Controller
$yabs = $process->yabsOutputAsJson($request->server_id, $request->yabs); $yabs = $process->yabsOutputAsJson($request->server_id, $request->yabs);
if (isset($yabs['error_id'])) { if (isset($yabs['error_id'])) {
return redirect()->route('yabs.index') return back()->withErrors(["yabs" => 'Problem inserting YABs. Error id ' . $yabs['error_id']])->withInput();
->with('error', 'Problem inserting YABs. Error id ' . $yabs['error_id']); //return redirect()->route('yabs.index')->with('error', 'Problem inserting YABs. Error id ' . $yabs['error_id']);
} }
//No errors, do insert //No errors, do insert

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class DNS extends Model class DNS extends Model
{ {
@ -14,4 +16,11 @@ class DNS extends Model
protected $fillable = ['id', 'service_id', 'hostname', 'dns_type', 'address', 'server_id', 'domain_id']; protected $fillable = ['id', 'service_id', 'hostname', 'dns_type', 'address', 'server_id', 'domain_id'];
public static $dns_types = ['A', 'AAAA', 'DNAME', 'MX', 'NS', 'SOA', 'TXT', 'URI']; public static $dns_types = ['A', 'AAAA', 'DNAME', 'MX', 'NS', 'SOA', 'TXT', 'URI'];
public static function dnsCount()
{
return Cache::remember('dns_count', now()->addMonth(1), function () {
return DB::table('d_n_s')->count();
});
}
} }

View File

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Domains extends Model class Domains extends Model
{ {
@ -12,4 +13,29 @@ class Domains extends Model
public $incrementing = false; public $incrementing = false;
protected $fillable = ['id', 'domain', 'extension', 'ns1', 'ns2', 'ns3', 'price', 'currency', 'payment_term', 'owned_since', 'provider_id', 'next_due_date']; protected $fillable = ['id', 'domain', 'extension', 'ns1', 'ns2', 'ns3', 'price', 'currency', 'payment_term', 'owned_since', 'provider_id', 'next_due_date'];
public static function domainsDataIndexPage()
{
return DB::table('domains as d')
->join('providers as p', 'd.provider_id', '=', 'p.id')
->join('pricings as pr', 'd.id', '=', 'pr.service_id')
->get(['d.*', 'p.name as provider_name', 'pr.*']);
}
public static function domainsDataShowPage(string $domain_id)
{
return DB::table('domains as d')
->join('providers as p', 'd.provider_id', '=', 'p.id')
->join('pricings as pr', 'd.id', '=', 'pr.service_id')
->where('d.id', '=', $domain_id)
->get(['d.*', 'p.name as provider_name', 'pr.*']);
}
public static function domainsDataEditPage(string $domain_id)
{
return DB::table('domains as d')
->join('pricings as pr', 'd.id', '=', 'pr.service_id')
->where('d.id', '=', $domain_id)
->get(['d.*', 'pr.*']);
}
} }

190
app/Models/Home.php Normal file
View File

@ -0,0 +1,190 @@
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
class Home extends Model
{
use HasFactory;
public static function homePageCacheForget()
{
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_pricing');//All the pricing
}
public static function servicesCount()
{
return Cache::remember('services_count', now()->addHour(6), function () {
return DB::table('pricings')
->select('service_type', DB::raw('COUNT(*) as amount'))
->groupBy('service_type')
->where('active', '=', 1)
->get();
});
}
public static function dueSoonData()
{
return Cache::remember('due_soon', now()->addHour(6), function () {
return DB::table('pricings as p')
->leftJoin('servers as s', 'p.service_id', '=', 's.id')
->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id')
->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id')
->leftJoin('domains as d', 'p.service_id', '=', 'd.id')
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->leftJoin('seedboxes as sb', 'p.service_id', '=', 'sb.id')
->where('p.active', '=', 1)
->orderBy('next_due_date', 'ASC')
->limit(Session::get('due_soon_amount'))
->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name', 'sb.title']);
});
}
public static function serverSummary()
{
return Cache::remember('servers_summary', now()->addHour(6), function () {
$cpu_sum = DB::table('servers')->get()->where('active', '=', 1)->sum('cpu');
$ram_mb = DB::table('servers')->get()->where('active', '=', 1)->sum('ram_as_mb');
$disk_gb = DB::table('servers')->get()->where('active', '=', 1)->sum('disk_as_gb');
$bandwidth = DB::table('servers')->get()->where('active', '=', 1)->sum('bandwidth');
$locations_sum = DB::table('servers')->get()->where('active', '=', 1)->groupBy('location_id')->count();
$providers_sum = DB::table('servers')->get()->where('active', '=', 1)->groupBy('provider_id')->count();
return array(
'cpu_sum' => $cpu_sum,
'ram_mb_sum' => $ram_mb,
'disk_gb_sum' => $disk_gb,
'bandwidth_sum' => $bandwidth,
'locations_sum' => $locations_sum,
'providers_sum' => $providers_sum,
);
});
}
public static function recentlyAdded()
{
return Cache::remember('recently_added', now()->addHour(6), function () {
return DB::table('pricings as p')
->leftJoin('servers as s', 'p.service_id', '=', 's.id')
->leftJoin('shared_hosting as sh', 'p.service_id', '=', 'sh.id')
->leftJoin('reseller_hosting as r', 'p.service_id', '=', 'r.id')
->leftJoin('domains as d', 'p.service_id', '=', 'd.id')
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->leftJoin('seedboxes as sb', 'p.service_id', '=', 'sb.id')
->where('p.active', '=', 1)
->orderBy('created_at', 'DESC')
->limit(Session::get('recently_added_amount'))
->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name', 'sb.title']);
});
}
public static function doDueSoon($due_soon)
{
$pricing = new Pricing();
$count = $altered_due_soon = 0;
foreach ($due_soon as $service) {
if (Carbon::createFromFormat('Y-m-d', $service->next_due_date)->isPast()) {
$months = $pricing->termAsMonths($service->term);//Get months for term to update the next due date to
$new_due_date = Carbon::createFromFormat('Y-m-d', $service->next_due_date)->addMonths($months)->format('Y-m-d');
DB::table('pricings')//Update the DB
->where('service_id', $service->service_id)
->update(['next_due_date' => $new_due_date]);
$due_soon[$count]->next_due_date = $new_due_date;//Update array being sent to view
$altered_due_soon = 1;
} else {
break;//Break because if this date isnt past than the ones after it in the loop wont be either
}
$count++;
}
if ($altered_due_soon === 1) {//Made changes to due soon so re-write it
Cache::put('due_soon', $due_soon);
}
return $due_soon;
}
public static function breakdownPricing($all_pricing): array
{
$pricing = json_decode($all_pricing, true);
$total_cost_weekly = $total_cost_pm = $inactive_count = 0;
foreach ($pricing as $price) {
if ($price['active'] === 1) {
if ($price['term'] === 1) {//1 month
$total_cost_weekly += ($price['as_usd'] / 4);
$total_cost_pm += $price['as_usd'];
} elseif ($price['term'] === 2) {//3 months
$total_cost_weekly += ($price['as_usd'] / 12);
$total_cost_pm += ($price['as_usd'] / 3);
} elseif ($price['term'] === 3) {// 6 month
$total_cost_weekly += ($price['as_usd'] / 24);
$total_cost_pm += ($price['as_usd'] / 6);
} elseif ($price['term'] === 4) {// 1 year
$total_cost_weekly += ($price['as_usd'] / 48);
$total_cost_pm += ($price['as_usd'] / 12);
} elseif ($price['term'] === 5) {//2 years
$total_cost_weekly += ($price['as_usd'] / 96);
$total_cost_pm += ($price['as_usd'] / 24);
} elseif ($price['term'] === 6) {//3 years
$total_cost_weekly += ($price['as_usd'] / 144);
$total_cost_pm += ($price['as_usd'] / 36);
}
} else {
$inactive_count++;
}
}
$total_cost_yearly = ($total_cost_pm * 12);
return array(
'total_cost_weekly' => $total_cost_weekly,
'total_cost_montly' => $total_cost_pm,
'total_cost_yearly' => $total_cost_yearly,
'inactive_count' => $inactive_count,
);
}
public static function doServicesCount($services_count): array
{
$servers_count = $domains_count = $shared_count = $reseller_count = $other_count = $seedbox_count = $total_services = 0;
$services_count = json_decode($services_count, true);
foreach ($services_count as $sc) {
$total_services += $sc['amount'];
if ($sc['service_type'] === 1) {
$servers_count = $sc['amount'];
} else if ($sc['service_type'] === 2) {
$shared_count = $sc['amount'];
} else if ($sc['service_type'] === 3) {
$reseller_count = $sc['amount'];
} else if ($sc['service_type'] === 4) {
$domains_count = $sc['amount'];
} else if ($sc['service_type'] === 5) {
$other_count = $sc['amount'];
} else if ($sc['service_type'] === 6) {
$seedbox_count = $sc['amount'];
}
}
return array(
'servers' => $servers_count,
'shared' => $shared_count,
'reseller' => $reseller_count,
'domains' => $domains_count,
'other' => $other_count,
'seedbox' => $seedbox_count,
'total' => $total_services
);
}
}

View File

@ -4,7 +4,9 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class IPs extends Model class IPs extends Model
{ {
@ -21,4 +23,26 @@ class IPs extends Model
DB::table('ips')->where('service_id', '=', $service_id)->delete(); DB::table('ips')->where('service_id', '=', $service_id)->delete();
} }
public static function insertIP(string $service_id, string $address)
{
self::create(
[
'id' => Str::random(8),
'service_id' => $service_id,
'address' => $address,
'is_ipv4' => (filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1,
'active' => 1
]
);
}
public static function ipsForServer(string $server_id)
{
return Cache::remember("ip_addresses.$server_id", now()->addHour(1), function () use ($server_id) {
return json_decode(DB::table('ips as i')
->where('i.service_id', '=', $server_id)
->get(), true);
});
}
} }

View File

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class Labels extends Model class Labels extends Model
@ -24,4 +25,30 @@ class Labels extends Model
DB::table('labels_assigned')->where('label_id', '=', $label_id)->delete(); DB::table('labels_assigned')->where('label_id', '=', $label_id)->delete();
} }
public static function insertLabelsAssigned(array $labels_array, string $service_id)
{
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT INTO labels_assigned (label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $service_id]);
}
}
}
public static function labelsCount()
{
return Cache::remember('labels_count', now()->addMonth(1), function () {
return DB::table('labels')->count();
});
}
public static function labelsForService(string $service_id)
{
return Cache::remember("labels_for_service.$service_id", now()->addMinute(5), function () use ($service_id) {
return DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $service_id)
->get(['labels.id', 'labels.label']);
});
}
} }

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Locations extends Model class Locations extends Model
{ {
@ -12,4 +14,11 @@ class Locations extends Model
protected $fillable = ['name']; protected $fillable = ['name'];
protected $table = 'locations'; protected $table = 'locations';
public static function allLocations(): array
{
return Cache::remember("locations", now()->addMonth(1), function () {
return DB::table('locations')->get()->toArray();
});
}
} }

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class OS extends Model class OS extends Model
{ {
@ -12,4 +14,11 @@ class OS extends Model
protected $fillable = ['name']; protected $fillable = ['name'];
protected $table = 'os'; protected $table = 'os';
public static function allOS(): array
{
return Cache::remember("operating_systems", now()->addMonth(1), function () {
return DB::table('os')->get()->toArray();
});
}
} }

View File

@ -4,7 +4,9 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
class Pricing extends Model class Pricing extends Model
{ {
@ -75,4 +77,52 @@ class Pricing extends Model
{ {
DB::table('pricings')->where('service_id', '=', $id)->delete(); DB::table('pricings')->where('service_id', '=', $id)->delete();
} }
public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, float $as_usd, string $next_due_date, int $is_active = 1)
{
return self::create([
'service_type' => $type,
'service_id' => $service_id,
'currency' => $currency,
'price' => $price,
'term' => $term,
'as_usd' => $as_usd,
'usd_per_month' => $this->costAsPerMonth($as_usd, $term),
'next_due_date' => $next_due_date,
'active' => ($is_active) ? 1 : 0
]);
}
public function updatePricing(string $service_id, string $currency, float $price, int $term, float $as_usd, string $next_due_date, int $is_active = 1)
{
return DB::table('pricings')
->where('service_id', $service_id)
->update([
'currency' => $currency,
'price' => $price,
'term' => $term,
'as_usd' => $as_usd,
'usd_per_month' => $this->costAsPerMonth($as_usd, $term),
'next_due_date' => $next_due_date,
'active' => ($is_active) ? 1 : 0
]);
}
public static function allPricing()
{
return Cache::remember('all_pricing', now()->addWeek(1), function () {
return DB::table('pricings')
->get();
});
}
public static function pricingForService(string $service_id)
{
return Cache::remember("service_pricing.$service_id", now()->addWeek(1), function () use ($service_id) {
return DB::table('servers as s')
->join('pricings as p', 's.id', '=', 'p.service_id')
->where('s.id', '=', $service_id)
->get(['s.*', 'p.*']);
});
}
} }

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Providers extends Model class Providers extends Model
{ {
@ -12,4 +14,31 @@ class Providers extends Model
protected $fillable = ['name']; protected $fillable = ['name'];
protected $table = 'providers'; protected $table = 'providers';
public static function allProviders(): array
{
return Cache::remember("providers", now()->addMonth(1), function () {
return DB::table('providers')->get()->toArray();
});
}
public static function showServicesForProvider($provider): array
{
$servers = DB::table('servers as s')
->where('s.provider_id', '=', $provider)
->get(['s.id', 's.hostname'])
->toArray();
$shared = DB::table('shared_hosting as s')
->where('s.provider_id', '=', $provider)
->get(['s.id', 's.main_domain as main_domain_shared'])
->toArray();
$reseller = DB::table('reseller_hosting as r')
->where('r.provider_id', '=', $provider)
->get(['r.id', 'r.main_domain as main_domain_reseller'])
->toArray();
return array_merge($servers, $shared, $reseller);
}
} }

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Reseller extends Model class Reseller extends Model
{ {
@ -14,4 +16,33 @@ class Reseller extends Model
protected $fillable = ['id', 'active', 'accounts', 'main_domain', 'has_dedicated_ip', 'ip', 'reseller_type', 'provider_id', 'location_id', 'bandwidth', 'disk', 'disk_type', 'disk_as_gb', 'domains_limit', 'subdomains_limit', 'ftp_limit', 'email_limit', 'db_limit', 'was_promo', 'owned_since']; protected $fillable = ['id', 'active', 'accounts', 'main_domain', 'has_dedicated_ip', 'ip', 'reseller_type', 'provider_id', 'location_id', 'bandwidth', 'disk', 'disk_type', 'disk_as_gb', 'domains_limit', 'subdomains_limit', 'ftp_limit', 'email_limit', 'db_limit', 'was_promo', 'owned_since'];
public $incrementing = false; public $incrementing = false;
public static function resellerDataIndexPage()
{
return DB::table('reseller_hosting as s')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->get(['s.*', 'p.name as provider_name', 'pr.*', 'l.name as location']);
}
public static function resellerDataShowPage(string $reseller_id)
{
return DB::table('reseller_hosting as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $reseller_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
}
public static function resellerDataEditPage(string $reseller_id)
{
return DB::table('reseller_hosting as s')
->join('pricings as p', 's.id', '=', 'p.service_id')
->where('s.id', '=', $reseller_id)
->get(['s.*', 'p.*']);
}
} }

50
app/Models/SeedBoxes.php Normal file
View File

@ -0,0 +1,50 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class SeedBoxes extends Model
{
use HasFactory;
protected $table = 'seedboxes';
public $incrementing = false;
protected $fillable = ['id', 'active', 'title', 'hostname', 'seed_box_type', 'provider_id', 'location_id', 'bandwidth', 'port_speed', 'disk', 'disk_type', 'disk_as_gb', 'was_promo', 'owned_since'];
public static function seedBoxesDataIndexPage()
{
return DB::table('seedboxes as s')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->get(['s.*', 'p.name as provider_name', 'pr.*', 'l.name as location']);
}
public static function seedBoxDataShowPage(string $seed_box_id)
{
return DB::table('seedboxes as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $seed_box_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
}
public static function seedBoxEditDataPage(string $seed_box_id)
{
return DB::table('seedboxes as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $seed_box_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
}
}

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Server extends Model class Server extends Model
{ {
@ -27,6 +29,8 @@ class Server extends Model
return "DEDI"; return "DEDI";
} elseif ($type === 4) { } elseif ($type === 4) {
return "LXC"; return "LXC";
} elseif ($type === 6) {
return "VMware";
} else { } else {
return "SEMI-DEDI"; return "SEMI-DEDI";
} }
@ -150,4 +154,95 @@ class Server extends Model
return $str; return $str;
} }
public static function serverRelatedCacheForget(): void
{
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('all_active_servers');//all servers cache
Cache::forget('non_active_servers');//all servers cache
Cache::forget('servers_summary');//servers summary cache
Cache::forget('public_server_data');//public servers
Cache::forget('all_pricing');//All pricing
}
public static function serverSpecificCacheForget(string $server_id): void
{
Cache::forget("server_show_data.$server_id");//data for show
Cache::forget("ip_addresses.$server_id");//ips for server
Cache::forget("labels_for_service.$server_id");//labels for server
Cache::forget("service_pricing.$server_id");//Pricing
}
public static function activeServersDataIndexPage()
{
return Cache::remember('all_active_servers', now()->addMonth(1), function () {
return DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->where('s.active', '=', 1)
->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']);
});
}
public static function nonActiveServersDataIndexPage()
{
return Cache::remember('non_active_servers', now()->addMonth(1), function () {
return DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->where('s.active', '=', 0)
->get(['s.*', 'pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'p.name as provider_name', 'l.name as location', 'o.name as os_name']);
});
}
public static function serverDataShowPage(string $server_id)
{
return Cache::remember("server_show_data.$server_id", now()->addDay(1), function () use ($server_id) {
return DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('os as o', 's.os_id', '=', 'o.id')
->Leftjoin('yabs as y', 's.id', '=', 'y.server_id')
->Leftjoin('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.id', '=', $server_id)
->get(['s.*', 'p.name as provider', 'l.name as location', 'o.name as os_name', 'pr.*', 'y.*', 'ds.*']);
});
}
public static function publicServerData()
{
return Cache::remember('public_server_data', now()->addMonth(1), function () {
return DB::table('servers as s')
->Join('pricings as pr', 's.id', '=', 'pr.service_id')
->Join('providers as p', 's.provider_id', '=', 'p.id')
->Join('locations as l', 's.location_id', '=', 'l.id')
->Join('os as o', 's.os_id', '=', 'o.id')
->LeftJoin('ips as i', 's.id', '=', 'i.service_id')
->LeftJoin('yabs as y', 's.id', '=', 'y.server_id')
->LeftJoin('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.show_public', '=', 1)
->get(['pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'pr.service_id', 'p.name as provider_name', 'l.name as location', 'o.name as os_name', 'y.*', 'y.id as yabs_id', 'ds.*', 's.*', 'i.address as ip', 'i.is_ipv4']);
});
}
public static function serverCompareData(string $server_id)
{
return Cache::remember("server_compare.$server_id", now()->addMonth(1), function () use ($server_id) {
return DB::table('servers as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->Join('yabs as y', 's.id', '=', 'y.server_id')
->Join('disk_speed as ds', 'y.id', '=', 'ds.id')
->where('s.id', '=', $server_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*', 'y.*', 'y.id as yabs_id', 'ds.*']);
});
}
} }

View File

@ -4,6 +4,9 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
class Settings extends Model class Settings extends Model
{ {
@ -12,4 +15,33 @@ class Settings extends Model
protected $table = 'settings'; protected $table = 'settings';
protected $fillable = ['id', 'show_versions_footer', 'show_servers_public']; protected $fillable = ['id', 'show_versions_footer', 'show_servers_public'];
public static function getSettings()
{
return Cache::remember('settings', now()->addMinute(1), function () {
return DB::table('settings')
->where('id', '=', 1)
->get();
});
}
public static function setSettingsToSession($settings): void
{
Session::put('dark_mode', $settings[0]->dark_mode ?? 0);
Session::put('timer_version_footer', $settings[0]->show_versions_footer ?? 1);
Session::put('show_servers_public', $settings[0]->show_servers_public ?? 0);
Session::put('show_server_value_ip', $settings[0]->show_server_value_ip ?? 0);
Session::put('show_server_value_hostname', $settings[0]->show_server_value_hostname ?? 0);
Session::put('show_server_value_price', $settings[0]->show_server_value_price ?? 0);
Session::put('show_server_value_yabs', $settings[0]->show_server_value_yabs ?? 0);
Session::put('show_server_value_provider', $settings[0]->show_server_value_provider ?? 0);
Session::put('show_server_value_location', $settings[0]->show_server_value_location ?? 0);
Session::put('default_currency', $settings[0]->default_currency ?? 'USD');
Session::put('default_server_os', $settings[0]->default_server_os ?? 1);
Session::put('due_soon_amount', $settings[0]->due_soon_amount ?? 6);
Session::put('recently_added_amount', $settings[0]->recently_added_amount ?? 6);
Session::save();
}
} }

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Shared extends Model class Shared extends Model
{ {
@ -14,4 +16,31 @@ class Shared extends Model
protected $fillable = ['id', 'active', 'main_domain', 'has_dedicated_ip', 'ip', 'shared_type', 'provider_id', 'location_id', 'bandwidth', 'disk', 'disk_type', 'disk_as_gb', 'domains_limit', 'subdomains_limit', 'ftp_limit', 'email_limit', 'db_limit', 'was_promo', 'owned_since']; protected $fillable = ['id', 'active', 'main_domain', 'has_dedicated_ip', 'ip', 'shared_type', 'provider_id', 'location_id', 'bandwidth', 'disk', 'disk_type', 'disk_as_gb', 'domains_limit', 'subdomains_limit', 'ftp_limit', 'email_limit', 'db_limit', 'was_promo', 'owned_since'];
public $incrementing = false; public $incrementing = false;
public static function sharedDataIndexPage()
{
return DB::table('shared_hosting as s')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->get(['s.*', 'p.name as provider_name', 'pr.*', 'l.name as location']);
}
public static function sharedDataShowPage(string $shared_id)
{
return DB::table('shared_hosting as s')
->join('pricings as pr', 's.id', '=', 'pr.service_id')
->join('providers as p', 's.provider_id', '=', 'p.id')
->join('locations as l', 's.location_id', '=', 'l.id')
->where('s.id', '=', $shared_id)
->get(['s.*', 'p.name as provider_name', 'l.name as location', 'pr.*']);
}
public static function sharedEditDataPage(string $shared_id)
{
return DB::table('shared_hosting as s')
->join('pricings as p', 's.id', '=', 'p.service_id')
->where('s.id', '=', $shared_id)
->get(['s.*', 'p.*']);
}
} }

View File

@ -4,6 +4,8 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class Yabs extends Model class Yabs extends Model
{ {
@ -14,4 +16,23 @@ class Yabs extends Model
protected $table = 'yabs'; protected $table = 'yabs';
protected $fillable = ['id', 'server_id', 'has_ipv6', 'aes', 'vm', 'output_date', 'cpu_cores', 'cpu_freq', 'cpu_model', 'ram', 'ram_type', 'ram_mb', 'disk', 'disk_type', 'disk_gb', 'gb5_single', 'gb5_multi', 'gb5_id', '4k', '4k_type', '4k_as_mbps', '64k', '64k_type', '64k_as_mbps', '512k', '512k_type', '512k_as_mbps', '1m', '1m_type', '1m_as_mbps', 'location', 'send', 'send_type', 'send_as_mbps', 'receive', 'receive_type', 'receive_as_mbps']; protected $fillable = ['id', 'server_id', 'has_ipv6', 'aes', 'vm', 'output_date', 'cpu_cores', 'cpu_freq', 'cpu_model', 'ram', 'ram_type', 'ram_mb', 'disk', 'disk_type', 'disk_gb', 'gb5_single', 'gb5_multi', 'gb5_id', '4k', '4k_type', '4k_as_mbps', '64k', '64k_type', '64k_as_mbps', '512k', '512k_type', '512k_as_mbps', '1m', '1m_type', '1m_as_mbps', 'location', 'send', 'send_type', 'send_as_mbps', 'receive', 'receive_type', 'receive_as_mbps'];
public static function networkSpeedsForServer(string $server_id)
{
return Cache::remember("network_speeds.$server_id", now()->addMonth(1), function () use ($server_id) {
return json_decode(DB::table('network_speed')
->where('network_speed.server_id', '=', $server_id)
->get(), true);
});
}
public static function serverCompareNetwork(string $yabs_id)
{
return Cache::remember("compare_network_speeds.$yabs_id", now()->addMonth(1), function () use ($yabs_id) {
return DB::table('network_speed')
->where('id', '=', $yabs_id)
->get();
});
}
} }

View File

@ -192,11 +192,26 @@ class Process
} }
$version_array = explode(' ', preg_replace('!\s+!', ' ', $this->trimRemoveR($array[2]))); $version_array = explode(' ', preg_replace('!\s+!', ' ', $this->trimRemoveR($array[2])));
if ($version_array[1] === 'v2021-12-28' || $version_array[1] === 'v2022-02-18' || $version_array[1] === 'v2022-04-30') {//YABs version if ($version_array[1] === 'v2021-12-28' || $version_array[1] === 'v2022-02-18' || $version_array[1] === 'v2022-04-30' || $version_array[1] === 'v2022-05-06') {//YABs version
if ($version_array[1] === 'v2022-05-06') {
$cpu = $this->trimRemoveR(str_replace(':', '', strstr($array[11], ': ')));
$cpu_spec = explode(' ', strstr($array[12], ': '));//: 2 @ 3792.872 MHz
$ram_line = $this->trimRemoveR(str_replace(':', '', strstr($array[15], ': ')));
$ram = (float)$ram_line;
$ram_type = $this->datatype($ram_line);
$swap_line = $this->trimRemoveR(str_replace(':', '', strstr($array[16], ': ')));
$swap = (float)$swap_line;
$swap_type = $this->datatype($swap_line);
$disk_line = $this->trimRemoveR(str_replace(':', '', strstr($array[17], ': ')));
$disk = (float)$disk_line;
$disk_type = $this->datatype($disk_line);
$io_3 = explode(' ', preg_replace('!\s+!', ' ', $array[27]));
$io_6 = explode(' ', preg_replace('!\s+!', ' ', $array[33]));
(str_contains($array[13], 'Enabled')) ? $aes_ni = true : $aes_ni = false;
(str_contains($array[14], 'Enabled')) ? $vm_amd_v = true : $vm_amd_v = false;
} else {
$cpu = $this->trimRemoveR(str_replace(':', '', strstr($array[10], ': '))); $cpu = $this->trimRemoveR(str_replace(':', '', strstr($array[10], ': ')));
$cpu_spec = explode(' ', strstr($array[11], ': '));//: 2 @ 3792.872 MHz $cpu_spec = explode(' ', strstr($array[11], ': '));//: 2 @ 3792.872 MHz
$cpu_cores = $cpu_spec[1];
$cpu_freq = $cpu_spec[3];
$ram_line = $this->trimRemoveR(str_replace(':', '', strstr($array[14], ': '))); $ram_line = $this->trimRemoveR(str_replace(':', '', strstr($array[14], ': ')));
$ram = (float)$ram_line; $ram = (float)$ram_line;
$ram_type = $this->datatype($ram_line); $ram_type = $this->datatype($ram_line);
@ -210,6 +225,10 @@ class Process
$io_6 = explode(' ', preg_replace('!\s+!', ' ', $array[30])); $io_6 = explode(' ', preg_replace('!\s+!', ' ', $array[30]));
(str_contains($array[12], 'Enabled')) ? $aes_ni = true : $aes_ni = false; (str_contains($array[12], 'Enabled')) ? $aes_ni = true : $aes_ni = false;
(str_contains($array[13], 'Enabled')) ? $vm_amd_v = true : $vm_amd_v = false; (str_contains($array[13], 'Enabled')) ? $vm_amd_v = true : $vm_amd_v = false;
}
$cpu_cores = $cpu_spec[1];
$cpu_freq = $cpu_spec[3];
$d4k_as_mbps = $this->diskSpeedAsMbps($io_3[3], $this->floatValue($io_3[2])); $d4k_as_mbps = $this->diskSpeedAsMbps($io_3[3], $this->floatValue($io_3[2]));
$d64k_as_mbps = $this->diskSpeedAsMbps($io_3[7], $this->floatValue($io_3[6])); $d64k_as_mbps = $this->diskSpeedAsMbps($io_3[7], $this->floatValue($io_3[6]));
@ -231,6 +250,51 @@ class Process
); );
if (isset($array[40])) { if (isset($array[40])) {
if ($version_array[1] === 'v2022-05-06') {
if ($array[43] === "Geekbench 5 Benchmark Test:\r") {
//No ipv6
//Has short ipv4 network speed testing (-r)
$has_ipv6 = false;
$start_st = 39;
$end_st = 41;
$gb_s = 47;
$gb_m = 48;
$gb_url = 49;
} elseif ($array[45] === "Geekbench 4 Benchmark Test:\r") {
return array('error_id' => 6, 'error_message' => 'GeekBench 5 only allowed');
} elseif ($array[45] === "Geekbench 5 test failed. Run manually to determine cause.\r") {
return array('error_id' => 7, 'error_message' => 'GeekBench test failed');
} elseif ($array[46] === "Geekbench 5 Benchmark Test:\r") {
//No ipv6
//Has full ipv4 network speed testing
$has_ipv6 = false;
$start_st = 39;
$end_st = 44;
$gb_s = 44;
$gb_m = 45;
$gb_url = 46;
} elseif ($array[43] === "iperf3 Network Speed Tests (IPv6):\r") {
//HAS ipv6
//Has short ipv4 & ipv6 network speed testing
$has_ipv6 = true;
$start_st = 39;
$end_st = 41;
$gb_s = 55;
$gb_m = 56;
$gb_url = 57;
} elseif ($array[56] === "Geekbench 5 Benchmark Test:\r") {
//HAS ipv6
//Has full ipv4 & ipv6 network speed testing
$has_ipv6 = true;
$start_st = 39;
$end_st = 44;
$gb_s = 60;
$gb_m = 61;
$gb_url = 62;
} else {
return array('error_id' => 5, 'error_message' => 'Not correct YABs command output');
}
} else {
if ($array[45] === "Geekbench 5 Benchmark Test:\r") { if ($array[45] === "Geekbench 5 Benchmark Test:\r") {
//No ipv6 //No ipv6
//Has short ipv4 network speed testing (-r) //Has short ipv4 network speed testing (-r)
@ -274,6 +338,7 @@ class Process
} else { } else {
return array('error_id' => 5, 'error_message' => 'Not correct YABs command output'); return array('error_id' => 5, 'error_message' => 'Not correct YABs command output');
} }
}
} else { } else {
return array('error_id' => 4, 'error_message' => 'Not correct formatting'); return array('error_id' => 4, 'error_message' => 'Not correct formatting');
} }

View File

@ -15,9 +15,7 @@ class LocationsSelect extends Component
*/ */
public function render() public function render()
{ {
$all_locations = Cache::rememberForever('all_locations', function () { $all_locations = Locations::allLocations();
return Locations::all();
});
return view('components.locations-select', [ return view('components.locations-select', [
'locations' => $all_locations 'locations' => $all_locations
]); ]);

View File

@ -10,11 +10,8 @@ class OsSelect extends Component
{ {
public function render() public function render()
{ {
$all_os = Cache::rememberForever('all_os', function () {
return OS::all();
});
return view('components.os-select', [ return view('components.os-select', [
'os' => $all_os 'os' => OS::allOS()
]); ]);
} }
} }

View File

@ -16,9 +16,7 @@ class ProvidersSelect extends Component
*/ */
public function render() public function render()
{ {
$all_providers = Cache::rememberForever('all_providers', function () { $all_providers = Providers::allProviders();
return Providers::all();
});
return view('components.providers-select', [ return view('components.providers-select', [
'providers' => $all_providers 'providers' => $all_providers
]); ]);

View File

@ -21,9 +21,9 @@ class CreateServersTable extends Migration
$table->string('ns1')->nullable()->default(null); $table->string('ns1')->nullable()->default(null);
$table->string('ns2')->nullable()->default(null); $table->string('ns2')->nullable()->default(null);
$table->tinyInteger('server_type')->default(1); $table->tinyInteger('server_type')->default(1);
$table->integer('os_id')->default(0); $table->unsignedBigInteger('os_id')->default(0);
$table->integer('provider_id')->default(9999); $table->unsignedBigInteger('provider_id')->default(9999);
$table->integer('location_id')->default(9999); $table->unsignedBigInteger('location_id')->default(9999);
$table->integer('ssh')->nullable()->default(22); $table->integer('ssh')->nullable()->default(22);
$table->integer('bandwidth')->nullable(); $table->integer('bandwidth')->nullable();
$table->integer('ram')->default(1024); $table->integer('ram')->default(1024);

View File

@ -21,7 +21,7 @@ class CreateDomainsTable extends Migration
$table->string('ns1')->nullable(); $table->string('ns1')->nullable();
$table->string('ns2')->nullable(); $table->string('ns2')->nullable();
$table->string('ns3')->nullable(); $table->string('ns3')->nullable();
$table->integer('provider_id')->default(9999); $table->unsignedBigInteger('provider_id')->default(9999);
$table->date('owned_since')->nullable(); $table->date('owned_since')->nullable();
$table->timestamps(); $table->timestamps();
}); });

View File

@ -18,8 +18,8 @@ class CreateSharedsTable extends Migration
$table->tinyInteger('active')->default(1); $table->tinyInteger('active')->default(1);
$table->string('main_domain'); $table->string('main_domain');
$table->string('shared_type')->nullable(); $table->string('shared_type')->nullable();
$table->integer('provider_id')->default(9999); $table->unsignedBigInteger('provider_id')->default(9999);
$table->integer('location_id')->default(9999); $table->unsignedBigInteger('location_id')->default(9999);
$table->integer('bandwidth')->nullable(); $table->integer('bandwidth')->nullable();
$table->integer('disk')->default(10); $table->integer('disk')->default(10);
$table->char('disk_type', 2)->default('GB'); $table->char('disk_type', 2)->default('GB');

View File

@ -19,8 +19,8 @@ class CreateResellersTable extends Migration
$table->string('main_domain'); $table->string('main_domain');
$table->integer('accounts')->default(1); $table->integer('accounts')->default(1);
$table->string('reseller_type')->nullable(); $table->string('reseller_type')->nullable();
$table->integer('provider_id')->default(9999); $table->unsignedBigInteger('provider_id')->default(9999);
$table->integer('location_id')->default(9999); $table->unsignedBigInteger('location_id')->default(9999);
$table->integer('bandwidth')->nullable(); $table->integer('bandwidth')->nullable();
$table->integer('disk')->default(10); $table->integer('disk')->default(10);
$table->char('disk_type', 2)->default('GB'); $table->char('disk_type', 2)->default('GB');

View File

@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddForeignKeys extends Migration
{
public function up()
{
Schema::table('servers', function (Blueprint $table) {
//$table->foreign('location_id','servers_fk_location')->references('id')->on('locations');
//$table->foreign('provider_id','servers_fk_provider')->references('id')->on('providers');
//$table->foreign('os_id','servers_fk_os')->references('id')->on('os');
$table->foreign('id', 'servers_fk_pricing')->references('service_id')->on('pricings')->onDelete('cascade');
});
Schema::table('shared_hosting', function (Blueprint $table) {
//$table->foreign('location_id','shared_fk_location')->references('id')->on('locations');
//$table->foreign('provider_id','shared_fk_provider')->references('id')->on('providers');
$table->foreign('id', 'shared_fk_pricing')->references('service_id')->on('pricings')->onDelete('cascade');
});
Schema::table('reseller_hosting', function (Blueprint $table) {
//$table->foreign('location_id','reseller_fk_location')->references('id')->on('locations');
//$table->foreign('provider_id','reseller_fk_provider')->references('id')->on('providers');
$table->foreign('id', 'reseller_fk_pricing')->references('service_id')->on('pricings')->onDelete('cascade');
});
Schema::table('domains', function (Blueprint $table) {
//$table->foreign('provider_id','domains_fk_provider')->references('id')->on('providers');
$table->foreign('id', 'domains_fk_pricing')->references('service_id')->on('pricings')->onDelete('cascade');
});
Schema::table('misc_services', function (Blueprint $table) {
$table->foreign('id', 'misc_fk_pricing')->references('service_id')->on('pricings')->onDelete('cascade');
});
Schema::table('yabs', function (Blueprint $table) {
$table->foreign('server_id', 'yabs_fk_servers')->references('id')->on('servers');
});
Schema::table('disk_speed', function (Blueprint $table) {
$table->foreign('id', 'ds_fk_yabs')->references('id')->on('yabs');
});
Schema::table('network_speed', function (Blueprint $table) {
$table->foreign('id', 'ns_fk_yabs')->references('id')->on('yabs');
});
}
public function down()
{
}
}

View File

@ -0,0 +1,19 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDarkModeSetting extends Migration
{
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->boolean('dark_mode')->default(false);
});
}
public function down()
{
}
}

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('seedboxes', function (Blueprint $table) {
$table->char('id', 8)->primary();
$table->tinyInteger('active')->default(1);
$table->string('title');
$table->string('hostname')->nullable();
$table->string('seed_box_type')->nullable();
$table->unsignedBigInteger('provider_id')->default(9999);
$table->unsignedBigInteger('location_id')->default(9999);
$table->integer('bandwidth')->nullable();
$table->integer('port_speed')->nullable();
$table->integer('disk')->default(10);
$table->char('disk_type', 2)->default('GB');
$table->integer('disk_as_gb')->nullable()->default(0);
$table->tinyInteger('was_promo')->default(0);
$table->date('owned_since')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('seedboxes');
}
};

View File

@ -94,7 +94,9 @@ class LocationsSeeder extends Seeder
['name' => 'Washington, USA'], ['name' => 'Washington, USA'],
['name' => 'Wellington, New Zealand'], ['name' => 'Wellington, New Zealand'],
['name' => 'Zurich, Switzerland'], ['name' => 'Zurich, Switzerland'],
['name' => 'Quebec, Canada'] ['name' => 'Quebec, Canada'],
['name' => 'Kharkiv, Ukraine'],
['name' => 'Sao Paulo, Brazil'],
]; ];
DB::table('locations')->insert($locations); DB::table('locations')->insert($locations);

BIN
public/css/bootstrap-dark.min.css vendored Normal file

Binary file not shown.

View File

@ -2,8 +2,9 @@
<div class="input-group-prepend"><span class="input-group-text">{{ $title ??'Location'}}</span></div> <div class="input-group-prepend"><span class="input-group-text">{{ $title ??'Location'}}</span></div>
<select class="form-control" name="{{$name ?? 'location_id'}}"> <select class="form-control" name="{{$name ?? 'location_id'}}">
@foreach ($locations as $location) @foreach ($locations as $location)
<option value="{{ $location['id'] }}" {{(isset($current) && (string)$current === (string)$location['id'])? 'selected' : ''}}> <option
{{ $location['name'] }} value="{{ $location->id }}" {{(isset($current) && (string)$current === (string)$location->id)? 'selected' : ''}}>
{{ $location->name }}
</option> </option>
@endforeach @endforeach
</select> </select>

View File

@ -2,8 +2,8 @@
<div class="input-group-prepend"><span class="input-group-text">{{ $title ??'OS'}}</span></div> <div class="input-group-prepend"><span class="input-group-text">{{ $title ??'OS'}}</span></div>
<select class="form-control" name="{{$name ?? 'os_id'}}"> <select class="form-control" name="{{$name ?? 'os_id'}}">
@foreach ($os as $o) @foreach ($os as $o)
<option value="{{ $o['id'] }}" {{(isset($current) && (string)$current === (string)$o['id'])? 'selected' : ''}}> <option value="{{ $o->id }}" {{(isset($current) && (string)$current === (string)$o->id)? 'selected' : ''}}>
{{ $o['name'] }} {{ $o->name }}
</option> </option>
@endforeach @endforeach
</select> </select>

View File

@ -2,8 +2,8 @@
<div class="input-group-prepend"><span class="input-group-text">{{ $title ??'Provider'}}</span></div> <div class="input-group-prepend"><span class="input-group-text">{{ $title ??'Provider'}}</span></div>
<select class="form-control" name="{{$name ?? 'provider_id'}}"> <select class="form-control" name="{{$name ?? 'provider_id'}}">
@foreach ($providers as $provider) @foreach ($providers as $provider)
<option value="{{ $provider['id'] }}" {{(isset($current) && (string)$current === (string)$provider['id'])? 'selected' : ''}}> <option value="{{ $provider->id }}" {{(isset($current) && (string)$current === (string)$provider->id)? 'selected' : ''}}>
{{ $provider['name'] }} {{ $provider->name }}
</option> </option>
@endforeach @endforeach
</select> </select>

View File

@ -4,7 +4,7 @@
@if (Route::has('login')) @if (Route::has('login'))
@auth @auth
<div class="row mt-4"> <div class="row mt-4">
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -14,7 +14,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -24,7 +24,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -34,7 +34,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -44,7 +44,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -54,7 +54,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -132,7 +132,7 @@
</div> </div>
<div class="row mt-3"> <div class="row mt-3">
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -142,7 +142,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -154,7 +154,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -173,7 +173,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -185,7 +185,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -195,7 +195,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-2 mb-3"> <div class="col-6 col-lg-2 mb-3">
<div class="card"> <div class="card">
<div class="card-body text-center shadow"> <div class="card-body text-center shadow">
<div class="row"> <div class="row">
@ -237,6 +237,8 @@
{{$due_soon->domain}}.{{$due_soon->extension}} {{$due_soon->domain}}.{{$due_soon->extension}}
@elseif($due_soon->service_type === 5) @elseif($due_soon->service_type === 5)
{{$due_soon->name}} {{$due_soon->name}}
@elseif($due_soon->service_type === 6)
{{$due_soon->title}}
@endif @endif
</td> </td>
<td class="text-nowrap"> <td class="text-nowrap">
@ -250,6 +252,8 @@
Domain Domain
@elseif($due_soon->service_type === 5) @elseif($due_soon->service_type === 5)
Misc Misc
@elseif($due_soon->service_type === 6)
Seedbox
@endif @endif
</td> </td>
<td class="text-nowrap"> <td class="text-nowrap">
@ -276,6 +280,10 @@
<a href="{{ route('misc.show', $due_soon->service_id) }}" <a href="{{ route('misc.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye" class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a> title="view"></i></a>
@elseif($due_soon->service_type === 6)
<a href="{{ route('seedboxes.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@endif @endif
</td> </td>
</tr> </tr>
@ -319,6 +327,8 @@
{{$new->domain}}.{{$new->extension}} {{$new->domain}}.{{$new->extension}}
@elseif($new->service_type === 5) @elseif($new->service_type === 5)
{{$new->name}} {{$new->name}}
@elseif($new->service_type === 6)
{{$new->title}}
@endif @endif
</td> </td>
<td class="text-nowrap"> <td class="text-nowrap">
@ -332,15 +342,38 @@
Domain Domain
@elseif($new->service_type === 5) @elseif($new->service_type === 5)
Misc Misc
@elseif($new->service_type === 6)
Seedbox
@endif @endif
</td> </td>
<td class="text-nowrap">{{Carbon\Carbon::parse($new->created_at)->diffForHumans()}}</td> <td class="text-nowrap">{{Carbon\Carbon::parse($new->created_at)->diffForHumans()}}</td>
<td class="text-nowrap">{{$new->price}} {{$new->currency}} {{\App\Process::paymentTermIntToString($new->term)}}</td> <td class="text-nowrap">{{$new->price}} {{$new->currency}} {{\App\Process::paymentTermIntToString($new->term)}}</td>
<td class="text-nowrap text-center"> <td class="text-nowrap text-center">
@if($new->service_type === 1)
<a href="{{ route('servers.show', $new->service_id) }}" <a href="{{ route('servers.show', $new->service_id) }}"
class="text-body mx-1"> class="text-body mx-1"><i class="fas fa-eye"
<i class="fas fa-eye" title="view"></i> title="view"></i></a>
</a> @elseif($new->service_type === 2)
<a href="{{ route('shared.show', $new->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($new->service_type === 3)
<a href="{{ route('reseller.show', $new->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($new->service_type === 4)
<a href="{{ route('domains.show', $new->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($new->service_type === 5)
<a href="{{ route('misc.show', $new->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($new->service_type === 6)
<a href="{{ route('seedboxes.show', $new->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@endif
</td> </td>
</tr> </tr>
@endforeach @endforeach

View File

@ -10,7 +10,12 @@
<title>@yield('title') - @if (config()->has('app.name')) {{ config('app.name') }} @else My idlers @endif</title> <title>@yield('title') - @if (config()->has('app.name')) {{ config('app.name') }} @else My idlers @endif</title>
@if(Session::get('dark_mode'))
<link rel="stylesheet" href="{{ asset('css/bootstrap-dark.min.css') }}">
@else
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}"> <link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
@endif
<link rel="stylesheet" href="{{ asset('css/fa.min.css') }}"> <link rel="stylesheet" href="{{ asset('css/fa.min.css') }}">
@yield('css_links') @yield('css_links')

View File

@ -36,6 +36,7 @@
<li><a class="dropdown-item" href="{{route('locations.index')}}">Locations</a></li> <li><a class="dropdown-item" href="{{route('locations.index')}}">Locations</a></li>
<li><a class="dropdown-item" href="{{route('os.index')}}">OS</a></li> <li><a class="dropdown-item" href="{{route('os.index')}}">OS</a></li>
<li><a class="dropdown-item" href="{{route('providers.index')}}">Providers</a></li> <li><a class="dropdown-item" href="{{route('providers.index')}}">Providers</a></li>
<li><a class="dropdown-item" href="{{route('seedboxes.index')}}">Seedboxes</a></li>
<li><a class="dropdown-item" href="{{route('yabs.index')}}">YABs</a></li> <li><a class="dropdown-item" href="{{route('yabs.index')}}">YABs</a></li>
<li><a class="dropdown-item" href="{{route('settings.index')}}">Settings</a></li> <li><a class="dropdown-item" href="{{route('settings.index')}}">Settings</a></li>
<li><a class="dropdown-item" href="{{route('account.index')}}">Account</a></li> <li><a class="dropdown-item" href="{{route('account.index')}}">Account</a></li>

View File

@ -0,0 +1,173 @@
@section('title') {{'Enter new seed box'}} @endsection
<x-app-layout>
<x-slot name="header">
{{ __('Insert a new seed box') }}
</x-slot>
<div class="container">
<div class="card shadow mt-3">
<div class="card-body">
<h4 class="mb-3">Seed box information</h4>
<x-auth-validation-errors></x-auth-validation-errors>
<a href="{{ route('shared.index') }}"
class="btn btn-primary py-0 px-4 mb-4">
Go back
</a>
<form action="{{ route('seedboxes.store') }}" method="POST">
@csrf
<div class="row">
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Title</span></div>
<input type="text"
class="form-control"
name="title">
@error('title') <span class="text-red-500">{{ $message }}
</span>@enderror
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Hostname</span></div>
<input type="text"
class="form-control"
name="hostname">
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Type</span></div>
<select class="form-control" id="seed_box_type" name="seed_box_type">
<option value="uTorrent" selected="">uTorrent</option>
<option value="BitTorrent">BitTorrent</option>
<option value="ruTorrent">ruTorrent</option>
<option value="Transmission">Transmission</option>
<option value="qBitTorrent">qBitTorrent</option>
<option value="Zona">Zona</option>
<option value="Deluge">Deluge</option>
<option value="Other">Other</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 mb-3">
<x-providers-select>
<x-slot name="current">10</x-slot>
</x-providers-select>
</div>
<div class="col-md-3 mb-3">
<x-number-input>
<x-slot name="title">Price</x-slot>
<x-slot name="name">price</x-slot>
<x-slot name="value">2.50</x-slot>
<x-slot name="max">9999</x-slot>
<x-slot name="step">0.01</x-slot>
<x-slot name="required"></x-slot>
</x-number-input>
</div>
<div class="col-md-3 mb-3">
<x-term-select></x-term-select>
</div>
<div class="col-md-3 mb-3">
<x-currency-select>
<x-slot name="current">{{Session::get('default_currency')}}</x-slot>
</x-currency-select>
</div>
</div>
<div class="row mb-2">
<div class="col-12 col-md-3 mb-3">
<x-locations-select>
<x-slot name="current">1</x-slot>
</x-locations-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-yes-no-select>
<x-slot name="title">Was promo</x-slot>
<x-slot name="name">was_promo</x-slot>
<x-slot name="value">0</x-slot>
</x-yes-no-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Owned since</x-slot>
<x-slot name="name">owned_since</x-slot>
<x-slot name="value">{{Carbon\Carbon::now()->format('Y-m-d') }}</x-slot>
</x-date-input>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Next due date</x-slot>
<x-slot name="name">next_due_date</x-slot>
<x-slot name="value">{{Carbon\Carbon::now()->addDays(30)->format('Y-m-d') }}</x-slot>
</x-date-input>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Disk GB</x-slot>
<x-slot name="name">disk</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">500</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Bandwidth GB</x-slot>
<x-slot name="name">bandwidth</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">1000</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Port speed Mbps</x-slot>
<x-slot name="name">port_speed</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">1000</x-slot>
</x-number-input>
</div>
</div>
<div class="row mb-3">
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot>
</x-labels-select>
</div>
</div>
<div>
<button type="submit"
class="btn btn-success py-0 px-4 mt-2">
Insert Seed box
</button>
</div>
</form>
</div>
</div>
</div>
</x-app-layout>

View File

@ -0,0 +1,219 @@
@section('title') {{$seedbox[0]->title}} {{'edit'}} @endsection
<x-app-layout>
<x-slot name="header">
Edit {{ $seedbox[0]->title }}
</x-slot>
<div class="container">
<div class="card mt-3 shadow">
<div class="card-body">
<a href="{{ route('seedboxes.index') }}"
class="btn btn-primary px-4 py-1">
Back to seed boxes
</a>
<x-auth-validation-errors></x-auth-validation-errors>
<form action="{{ route('seedboxes.update', $seedbox[0]->service_id) }}" method="POST">
@csrf
@method('PUT')
<div class="row mt-3">
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Title</span></div>
<input type="text"
class="form-control"
name="title" value="{{$seedbox[0]->title}}">
@error('title') <span class="text-red-500">{{ $message }}
</span>@enderror
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Hostname</span></div>
<input type="text"
class="form-control"
name="hostname" value="{{$seedbox[0]->hostname}}">
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<input type="hidden" name="id" value="{{$seedbox[0]->service_id}}">
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Type</span></div>
<select class="form-control" name="seed_box_type">
<option
value="uTorrent" {{ ($seedbox[0]->seed_box_type === 'uTorrent') ? 'selected' : '' }}>
uTorrent
</option>
<option
value="BitTorrent" {{ ($seedbox[0]->seed_box_type === 'BitTorrent') ? 'selected' : '' }}>
BitTorrent
</option>
<option
value="ruTorrent" {{ ($seedbox[0]->seed_box_type === 'ruTorrent') ? 'selected' : '' }}>
ruTorrent
</option>
<option
value="Transmission" {{ ($seedbox[0]->seed_box_type === 'Transmission') ? 'selected' : '' }}>
Transmission
</option>
<option
value="qBitTorrent" {{ ($seedbox[0]->seed_box_type === 'qBitTorrent') ? 'selected' : '' }}>
qBitTorrent
</option>
<option
value="Zona" {{ ($seedbox[0]->seed_box_type === 'Zona') ? 'selected' : '' }}>
Zona
</option>
<option
value="Other" {{ ($seedbox[0]->seed_box_type === 'Other') ? 'selected' : '' }}>
Other
</option>
<option
value="Deluge" {{ ($seedbox[0]->seed_box_type === 'Deluge') ? 'selected' : '' }}>
Deluge
</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 mb-3">
<x-providers-select>
<x-slot name="current">{{$seedbox[0]->provider_id}}</x-slot>
</x-providers-select>
</div>
<div class="col-md-3 mb-3">
<x-number-input>
<x-slot name="title">Price</x-slot>
<x-slot name="name">price</x-slot>
<x-slot name="value">{{$seedbox[0]->price}}</x-slot>
<x-slot name="max">9999</x-slot>
<x-slot name="step">0.01</x-slot>
<x-slot name="required"></x-slot>
</x-number-input>
</div>
<div class="col-md-3 mb-3">
<x-term-select>
<x-slot name="current">{{$seedbox[0]->term}}</x-slot>
</x-term-select>
</div>
<div class="col-md-3 mb-3">
<x-currency-select>
<x-slot name="current">{{$seedbox[0]->currency}}</x-slot>
</x-currency-select>
</div>
</div>
<div class="row mb-2">
<div class="col-12 col-md-3 mb-3">
<x-locations-select>
<x-slot name="current">{{$seedbox[0]->location_id}}</x-slot>
</x-locations-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-yes-no-select>
<x-slot name="title">Promo price</x-slot>
<x-slot name="name">was_promo</x-slot>
<x-slot name="value">{{ $seedbox[0]->was_promo }}</x-slot>
</x-yes-no-select>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Owned since</x-slot>
<x-slot name="name">owned_since</x-slot>
<x-slot name="value">{{$seedbox[0]->owned_since }}</x-slot>
</x-date-input>
</div>
<div class="col-12 col-md-3 mb-3">
<x-date-input>
<x-slot name="title">Next due date</x-slot>
<x-slot name="name">next_due_date</x-slot>
<x-slot name="value">{{$seedbox[0]->next_due_date }}</x-slot>
</x-date-input>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Disk GB</x-slot>
<x-slot name="name">disk</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">{{$seedbox[0]->disk_as_gb}}</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Bandwidth GB</x-slot>
<x-slot name="name">bandwidth</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">{{$seedbox[0]->bandwidth}}</x-slot>
</x-number-input>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-number-input>
<x-slot name="title">Port speed GB</x-slot>
<x-slot name="name">port_speed</x-slot>
<x-slot name="value">1</x-slot>
<x-slot name="max">999999</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="value">{{$seedbox[0]->port_speed}}</x-slot>
</x-number-input>
</div>
</div>
<div class="row mb-3">
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot>
@if(isset($labels[0]->id))
<x-slot name="current">{{$labels[0]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot>
@if(isset($labels[1]->id))
<x-slot name="current">{{$labels[1]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot>
@if(isset($labels[2]->id))
<x-slot name="current">{{$labels[2]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot>
@if(isset($labels[3]->id))
<x-slot name="current">{{$labels[3]->id}}</x-slot>
@endif
</x-labels-select>
</div>
</div>
<div class="form-check mt-2">
<input class="form-check-input" name="is_active" type="checkbox"
value="1" {{ ($seedbox[0]->active === 1) ? 'checked' : '' }}>
<label class="form-check-label">
I still have this server
</label>
</div>
<div>
<button type="submit"
class="btn btn-success px-4 py-1 mt-3">
Update seed box
</button>
</div>
</form>
</div>
</div>
</div>
</x-app-layout>

View File

@ -0,0 +1,124 @@
@section('title') {{'Seed boxes'}} @endsection
@section('style')
<x-modal-style></x-modal-style>
@endsection
@section('scripts')
<script src="{{ asset('js/vue.min.js') }}"></script>
<script src="{{ asset('js/axios.min.js') }}"></script>
@endsection
<x-app-layout>
<x-slot name="header">
{{ __('Seed boxes') }}
</x-slot>
<div class="container" id="app">
<x-delete-confirm-modal></x-delete-confirm-modal>
<div class="card shadow mt-3">
<div class="card-body">
<a href="{{ route('seedboxes.create') }}" class="btn btn-primary mb-3">Add a seed box</a>
@if ($message = Session::get('success'))
<div class="alert alert-success" role="alert">
<p class="my-1">{{ $message }}</p>
</div>
@endif
<div class="table-responsive">
<table class="table table-bordered">
<thead class="table-light">
<tr class="bg-gray-100">
<th>Title</th>
<th>Type</th>
<th>Location</th>
<th>Provider</th>
<th>Disk</th>
<th>BWidth</th>
<th>Port</th>
<th>Price</th>
<th>Due</th>
<th>Had since</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@if(isset($seedboxes[0]))
@foreach($seedboxes as $row)
<tr>
<td>{{ $row->title }}</td>
<td>{{ $row->seed_box_type }}</td>
<td class="text-nowrap">{{ $row->location }}</td>
<td class="text-nowrap">{{ $row->provider_name }}</td>
<td>
@if($row->disk_as_gb >= 1000)
{{ number_format($row->disk_as_gb / 1000,1) }} <small>TB</small>
@else
{{ $row->disk_as_gb }} <small>GB</small>
@endif
</td>
<td>
@if($row->bandwidth >= 1000)
{{ number_format($row->bandwidth / 1000,1) }} <small>TB</small>
@else
{{ $row->bandwidth }} <small>GB</small>
@endif
</td>
<td>
@if($row->port_speed >= 1000)
{{ number_format($row->port_speed / 1000,1) }} <small>Gbps</small>
@else
{{ $row->port_speed }} <small>Mbps</small>
@endif
</td>
<td>{{ $row->price }} {{$row->currency}} {{\App\Process::paymentTermIntToString($row->term)}}</td>
<td>{{Carbon\Carbon::parse($row->next_due_date)->diffForHumans()}}</td>
<td class="text-nowrap">{{ $row->owned_since }}</td>
<td class="text-nowrap">
<form action="{{ route('seedboxes.destroy', $row->service_id) }}" method="POST">
@csrf
<a href="{{ route('seedboxes.show', $row->service_id) }}"
class="text-body mx-1">
<i class="fas fa-eye" title="view"></i>
</a>
<a href="{{ route('seedboxes.edit', $row->service_id) }}"
class="text-body mx-1">
<i class="fas fa-pen" title="edit"></i>
</a>
<i class="fas fa-trash text-danger ms-3" @click="modalForm"
id="btn-{{$row->title}}" title="{{$row->service_id}}"></i>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td class="px-4 py-2 border text-red-500" colspan="3">No seed boxes found.</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
@if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1)
<p class="text-muted mt-4 text-end"><small>Built on Laravel
v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }})</small></p>
@endif
</div>
<script>
let app = new Vue({
el: "#app",
data: {
"modal_hostname": '',
"modal_id": '',
"delete_form_action": '',
showModal: false
},
methods: {
modalForm(event) {
this.showModal = true;
this.modal_hostname = event.target.id.replace('btn-', '');
this.modal_id = event.target.title;
this.delete_form_action = 'seedboxes/' + this.modal_id;
}
}
});
</script>
</x-app-layout>

View File

@ -0,0 +1,145 @@
@section('title') {{$seedbox->title}} {{'Seed box'}} @endsection
<x-app-layout>
<x-slot name="header">
{{ __('Seed box details') }}
</x-slot>
<div class="container">
<x-card class="shadow mt-3">
<div class="row">
<div class="col-12 col-md-6 mb-2">
<h2>{{ $seedbox->title }}</h2>
<code>@foreach($labels as $label)
@if($loop->last)
{{$label->label}}
@else
{{$label->label}},
@endif
@endforeach</code>
</div>
<div class="col-12 col-md-6 text-md-end">
<h6 class="text-muted pe-lg-4">{{ $seedbox->id }}</h6>
@if($seedbox->active !== 1)
<h6 class="text-danger pe-lg-4">not active</h6>
@endif
</div>
</div>
<div class="row">
<div class="'col-12 col-lg-6">
<div class="table-responsive">
<table class="table table-borderless text-nowrap">
<tbody>
<tr>
<td class="px-2 py-2 font-bold text-muted">Type</td>
<td>{{ $seedbox->seed_box_type }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Hostname</td>
<td><code>{{ $seedbox_extras[0]->hostname }}</code></td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Location</td>
<td>{{ $seedbox_extras[0]->location }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Provider</td>
<td>{{ $seedbox_extras[0]->provider_name }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Price</td>
<td>{{ $seedbox_extras[0]->price }} {{ $seedbox_extras[0]->currency }}
<small>{{\App\Process::paymentTermIntToString($seedbox_extras[0]->term)}}</small>
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Was promo</td>
<td>{{ ($seedbox_extras[0]->was_promo === 1) ? 'Yes' : 'No' }}</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Owned since</td>
<td>
@if(!is_null($seedbox->owned_since))
{{ date_format(new DateTime($seedbox->owned_since), 'jS F Y') }}
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Next due date</td>
<td>{{Carbon\Carbon::parse($seedbox_extras[0]->next_due_date)->diffForHumans()}}
({{Carbon\Carbon::parse($seedbox_extras[0]->next_due_date)->format('d/m/Y')}})
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Inserted</td>
<td>
@if(!is_null($seedbox->created_at))
{{ date_format(new DateTime($seedbox->created_at), 'jS M y g:i a') }}
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Updated</td>
<td>
@if(!is_null($seedbox->updated_at))
{{ date_format(new DateTime($seedbox->updated_at), 'jS M y g:i a') }}
@endif
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="'col-12 col-lg-6">
<table class="table table-borderless">
<tbody>
<tr>
<td class="px-2 py-2 font-bold text-muted">Disk</td>
<td>
@if($seedbox->disk_as_gb >= 1000)
{{ number_format($seedbox->disk_as_gb / 1000,1) }} <small>TB</small>
@else
{{ $seedbox->disk_as_gb }} <small>GB</small>
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Bandwidth</td>
<td>
@if($seedbox->bandwidth >= 1000)
{{ number_format($seedbox->bandwidth / 1000,1) }} <small>TB</small>
@else
{{ $seedbox->bandwidth }} <small>GB</small>
@endif
</td>
</tr>
<tr>
<td class="px-2 py-2 font-bold text-muted">Port speed</td>
<td>
@if($seedbox->port_speed >= 1000)
{{ number_format($seedbox->port_speed / 1000,1) }} <small>Gbps</small>
@else
{{ $seedbox->port_speed }} <small>Mbps</small>
@endif
</td>
</tr>
</tbody>
</table>
</div>
</div>
<a href="{{ route('seedboxes.index') }}"
class="btn btn-success btn-sm mx-2">
Go back
</a>
<a href="{{ route('seedboxes.edit', $seedbox->id) }}"
class="btn btn-primary btn-sm mx-2">
Edit
</a>
</x-card>
@if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1)
<p class="text-muted mt-4 text-end"><small>
Built on Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}
)</small>
</p>
@endif
</div>
</x-app-layout>

View File

@ -93,6 +93,7 @@
<option value="3">DEDI</option> <option value="3">DEDI</option>
<option value="4">LXC</option> <option value="4">LXC</option>
<option value="5">SEMI-DEDI</option> <option value="5">SEMI-DEDI</option>
<option value="6">VMware</option>
</select></div> </select></div>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">

View File

@ -78,6 +78,9 @@
<option value="5" {{ ($server[0]->server_type === 5) ? 'selected' : '' }}> <option value="5" {{ ($server[0]->server_type === 5) ? 'selected' : '' }}>
SEMI-DEDI SEMI-DEDI
</option> </option>
<option value="6" {{ ($server[0]->server_type === 6) ? 'selected' : '' }}>
VMware
</option>
</select></div> </select></div>
</div> </div>
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">

View File

@ -17,6 +17,22 @@
<form action="{{ route('settings.update', 1) }}" method="POST"> <form action="{{ route('settings.update', 1) }}" method="POST">
@csrf @csrf
@method('PUT') @method('PUT')
<div class="row mt-2">
<div class="col-12 col-md-4 mb-3">
<div class="input-group">
<div class="input-group-prepend"><span
class="input-group-text">Use dark mode</span></div>
<select class="form-control" name="dark_mode">
<option value="1" {{ ($setting[0]->dark_mode === 1) ? 'selected' : '' }}>
Yes
</option>
<option value="0" {{ ($setting[0]->dark_mode === 0) ? 'selected' : '' }}>
No
</option>
</select>
</div>
</div>
</div>
<div class="row mt-2"> <div class="row mt-2">
<div class="col-12 col-md-4 mb-3"> <div class="col-12 col-md-4 mb-3">
<div class="input-group"> <div class="input-group">

View File

@ -55,6 +55,9 @@ Route::middleware('auth:api')->get('providers/{id}', 'App\Http\Controllers\ApiCo
Route::middleware('auth:api')->get('reseller/', 'App\Http\Controllers\ApiController@getAllReseller'); Route::middleware('auth:api')->get('reseller/', 'App\Http\Controllers\ApiController@getAllReseller');
Route::middleware('auth:api')->get('reseller/{id}', 'App\Http\Controllers\ApiController@getReseller'); Route::middleware('auth:api')->get('reseller/{id}', 'App\Http\Controllers\ApiController@getReseller');
Route::middleware('auth:api')->get('seedbox/', 'App\Http\Controllers\ApiController@getAllSeedbox');
Route::middleware('auth:api')->get('seedbox/{id}', 'App\Http\Controllers\ApiController@getSeedbox');
Route::middleware('auth:api')->get('settings/', 'App\Http\Controllers\ApiController@getAllSettings'); Route::middleware('auth:api')->get('settings/', 'App\Http\Controllers\ApiController@getAllSettings');
Route::middleware('auth:api')->get('shared/', 'App\Http\Controllers\ApiController@getAllShared'); Route::middleware('auth:api')->get('shared/', 'App\Http\Controllers\ApiController@getAllShared');

View File

@ -10,6 +10,7 @@ use App\Http\Controllers\MiscController;
use App\Http\Controllers\OsController; use App\Http\Controllers\OsController;
use App\Http\Controllers\ProvidersController; use App\Http\Controllers\ProvidersController;
use App\Http\Controllers\ResellerController; use App\Http\Controllers\ResellerController;
use App\Http\Controllers\SeedBoxesController;
use App\Http\Controllers\ServerController; use App\Http\Controllers\ServerController;
use App\Http\Controllers\SettingsController; use App\Http\Controllers\SettingsController;
use App\Http\Controllers\SharedController; use App\Http\Controllers\SharedController;
@ -63,6 +64,8 @@ Route::resource('servers', ServerController::class)->middleware(['auth']);
Route::resource('settings', SettingsController::class)->middleware(['auth']); Route::resource('settings', SettingsController::class)->middleware(['auth']);
Route::resource('seedboxes', SeedBoxesController::class)->middleware(['auth']);
Route::resource('shared', SharedController::class)->middleware(['auth']); Route::resource('shared', SharedController::class)->middleware(['auth']);
Route::resource('yabs', YabsController::class)->middleware(['auth']); Route::resource('yabs', YabsController::class)->middleware(['auth']);