Compare commits

..

No commits in common. "main" and "1.5" have entirely different histories.
main ... 1.5

369 changed files with 15623 additions and 151143 deletions

View file

@ -1,15 +0,0 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

8
.gitattributes vendored
View file

@ -1,8 +0,0 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
/public/css/* -diff
/public/js/* -diff

View file

@ -1,79 +0,0 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@main
with:
cosign-release: 'v1.11.0'
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
latest
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

60
.gitignore vendored
View file

@ -1,60 +0,0 @@
### Laravel ###
vendor/
node_modules/
npm-debug.log
# Laravel 4 specific
bootstrap/compiled.php
app/storage/
# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
.env.*.php
.env.php
.env
Homestead.yaml
Homestead.json
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/
# Created by https://www.gitignore.io/api/phpstorm
### PhpStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### PhpStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
storage/clockwork/
!public/

View file

@ -1,13 +0,0 @@
php:
preset: laravel
disabled:
- no_unused_imports
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

4
AUTH.php Normal file
View file

@ -0,0 +1,4 @@
<?php
require_once('class.php');
$create_account = new auth();
$create_account->selfDestruct();

View file

@ -1,14 +0,0 @@
FROM php:8.2-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql sockets
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin --filename=composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /app
COPY . .
RUN composer install
ENV APP_ENV production
ENTRYPOINT ["/app/run.sh"]

365
README.md
View file

@ -1,339 +1,132 @@
# My idlers
A self-hosted web app for displaying, organizing and storing information about your servers (VPS/Dedi), shared &
reseller hosting, seedboxes,
domains, DNS and misc services.
A web app for displaying, organizing and storing information about servers (VPS), shared hosting and domains.
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
GeekBench 5 & 6 scores to do easier comparing and sorting. Of course storing other services e.g. web hosting is possible
and supported too with My idlers.
## V2 notes
[![Generic badge](https://img.shields.io/badge/version-3.0.0-blue.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Laravel-11.0-red.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/PHP-8.3-purple.svg)](https://shields.io/) [![Generic badge](https://img.shields.io/badge/Bootstrap-5.3-pink.svg)](https://shields.io/)
V2 build is going to be a complete overhaul of My idlers with the project being moved onto the Laravel framework. This will simplyfy development and most of the features from the original build will be present in V2.
<img src="https://raw.githubusercontent.com/cp6/my-idlers/main/public/My%20Idlers%20logo.jpg" width="128" height="128" />
[Live demo](https://myidlers.srv3r.com/)
[View demo site](https://demo.myidlers.com/)
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 GeekBench 5 scores to do easier comparing and sorting.
**Note:** Create, Update and Delete are disabled on the demo site.
## Project sponsor
[![Generic badge](https://img.shields.io/badge/version-1.5-blue.svg)](https://shields.io/)
Currently seeking a project sponsor
## 3.0.0 changes (9 December 2024):
* Updated PHP version to 8.3
* Updated Laravel version to ^11
* Updated composer package versions
* Updated routes into middleware grouping for auth
* Updated login and register forms
* Updated servers, shared, reseller and domains pages to use Datatables
* Added icons to back and submit button components
* Added icon button to shared and reseller create pages
* Added several updated OS versions to OsSeeder
* Added Font awesome Brands webfont
* Added IP whois data columns to the ips table
* Added IP whois data fetching and updating DB
* Added Note to API
* Fixed OS icons not loading in servers index page
* Fixed Settings being called without being created (existing)
* Fixed issue with OS: `Call to a member function toJson() on array`
* Fixed due in (days) column showing a massive float
* Removed 1 user being seeded
* Removed doctrine/dbal
#### Please run the following if updating from an existing install:
```shell
composer update
php artisan migrate
php artisan route:cache
php artisan cache:clear
```
## 1.4 changes:
**If you have version 1.3 already installed please run ```update1.3to1.4.sql```**
* Added compare servers section
* Added ASN fetcher
* Added check for min version PHP 7.4
* Added errors checks for YABs output inserting
* Added improved screenshots to readme
* Updated delete YABs txt file when deleting server data
* Added save YABs to txt file constant
* Updated domain attached to errors when null
* Updated getIpForDomain() call to echo (working now)
* Updated `my_idlers.sql` for changes
## Requires
* PHP 8.3
* PHP 7.4 (compatible with 8.0)
* MySQL
## Features
* Add servers
* Add shared hosting
* Add domains
* [Auto suggest locations](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-location.gif)
* [Auto suggest providers](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-provider.gif)
* [Auto get IP's from hostname](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-ips-from-hostname.gif)
* [Check up/down status](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-ping-up-feature.gif)
* Get YABS data from output
* Get YABs data from output
* Compare 2 servers
* Save & view YABS output
* Update YABS disk & network results
* Save & view YABs output
* Update YABs disk & network results
* Next due date system
* Multi currency compatibility
* Multi payment-term compatibility
* Pre-defined operating systems
* Assign tags
* Assign labels
* Assign server type (KVM, OVZ, LXC & dedi)
* Easy to edit values
* Assign notes
* Order by table
* Search items
* Tally/stats card
* One-page design
## Install
* Run `git clone https://github.com/cp6/my-idlers.git` into your directory of choice
* Run `composer install`
* Run `cp .env.example .env`
* Edit (If needed) MySQL details in .env
* Run `php artisan key:generate`
* Run `php artisan make:database my_idlers` to create database
* Run `php artisan migrate:fresh --seed` to create tables and seed data
* Run `php artisan serve`
* Download [the zip](https://github.com/cp6/my-idlers/archive/main.zip) and unpack the files from ```my-idlers-main/``` into your directory of choice.
* Run `my_idlers.sql` in MySQL.
## Updating
* **Only run ```update1.3to1.4.sql``` if you have version 1.3 installed.**
If you already have at least version 2.0 installed:
* Edit ```class.php``` lines ```13-16``` for your MySQL details.
* Edit ```class.php``` lines ```8-10``` for card order type.
* Run `git clone https://github.com/cp6/my-idlers.git`
* Run `composer install`
* Run `composer update`
* Run `php artisan migrate`
* Run `php artisan route:cache`
* Run `php artisan cache:clear`
* Make sure you have write access to process and store the YABs outputs.
## Run using Docker
```
docker run \
-p 8000:8000\
-e APP_URL=https://... \
-e DB_HOST=... \
-e DB_DATABASE=... \
-e DB_USERNAME=... \
-e DB_PASSWORD=... \
ghcr.io/cp6/my-idlers:latest
docker exec ... php artisan migrate:fresh --seed --force # Set up database one time
```
## Managed Hosting
Run with a single click on [PikaPods.com](https://www.pikapods.com/)
[![PikaPods](https://www.pikapods.com/static/run-button.svg)](https://www.pikapods.com/pods?run=my-idlers)
## Adding a YABS benchmark
yabs.sh now has JSON formatted response and can POST the output directly from calling the script.
With My idlers you can use your API key and the server id to directly POST the benchmark result
`https://yourdomain.com/api/yabs/SERVERID/USERAPIKEYISHERE`
Example yabs.sh call to POST the result:
`curl -sL yabs.sh | bash -s -- -s "https://yourdomain.com/api/yabs/SERVERID/USERAPIKEYISHERE"`
## Credits
IP who is data provided by [ipwhois.io](https://ipwhois.io/documentation)
## API endpoints
For GET requests the header must have `Accept: application/json` and your API token (found at `/account`)
`Authorization : Bearer API_TOKEN_HERE`
All API requests must be appended with `api/` e.g `mydomain.com/api/servers/gYk8J0a7`
**GET request:**
`dns/`
`dns/{id}`
`domains/`
`domains/{id}`
`servers`
`servers/{id}`
`labels/`
`labels/{id}`
`locations/`
`locations/{id}`
`misc/`
`misc/{id}`
`networkSpeeds/`
`networkSpeeds/{id}`
`os/`
`os/{id}`
`pricing/`
`pricing/{id}`
`providers/`
`providers/{id}`
`reseller/`
`reseller/{id}`
`seedbox/`
`seedbox/{id}`
`settings/`
`shared/`
`shared/{id}`
`note/{id}`
**POST requests**
Create a server
`/servers`
Body content template
```json
{
"active": 1,
"show_public": 0,
"hostname": "test.domain.com",
"ns1": "ns1",
"ns2": "ns2",
"server_type": 1,
"os_id": 2,
"provider_id": 10,
"location_id": 15,
"ssh_port": 22,
"bandwidth": 2000,
"ram": 2024,
"ram_type": "MB",
"ram_as_mb": 2024,
"disk": 30,
"disk_type": "GB",
"disk_as_gb": 30,
"cpu": 2,
"has_yabs": 0,
"was_promo": 1,
"ip1": "127.0.0.1",
"ip2": null,
"owned_since": "2022-01-01",
"currency": "USD",
"price": 4.00,
"payment_term": 1,
"as_usd": 4.00,
"usd_per_month": 4.00,
"next_due_date": "2022-02-01"
}
```
**PUT requests**
Update a server
`/servers/ID`
Body content template
```json
{
"active": 1,
"show_public": 0,
"hostname": "test.domain.com",
"ns1": "ns1",
"ns2": "ns2",
"server_type": 1,
"os_id": 2,
"provider_id": 10,
"location_id": 15,
"ssh_port": 22,
"bandwidth": 2000,
"ram": 2024,
"ram_type": "MB",
"ram_as_mb": 2024,
"disk": 30,
"disk_type": "GB",
"disk_as_gb": 30,
"cpu": 2,
"has_yabs": 0,
"was_promo": 1,
"owned_since": "2022-01-01"
}
```
Update pricing
`/pricing/ID`
Body content template
```json
{
"price": 10.50,
"currency": "USD",
"term": 1
}
```
**DELETE requests**
Delete a server
`/servers/ID`
## Notes
**Public viewable listings**
**There is no authentication provided!**
Either use on a local network or put behind authentication.
If enabled the public viewable table for your server listings is at `/servers/public`
You can configure what you want viewable at ```/settings```
**Supporting YABS commands:**
**Due date / due soon**
This is simply just a reminder. If the homepage is requested (viewed) when a service is over due date it will get reset
to plus the term from the old due date.
E.g if the term is a month then the due date gets updated to be 1 month from the old due date.
**Supporting YABS commands:**
```curl -sL yabs.sh | bash```
```curl -sL yabs.sh | bash```
or
```curl -sL yabs.sh | bash -s -- -r```
Logo icons created by Freepik - Flaticon
**Make sure YABs output starts at the first line which is:**
## Screenshots for v2
```# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #```
[![My idlers screenshot1](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-home-2.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-home-2.jpg)
[![My idlers screenshot2](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-server-view.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-server-view.jpg)
**A trimmed Bootstrap is used.** Only the used classes and elements are in ```style.css```
Therefore adding more obscure columns or Bootstrap classes will not initially work as intended until you put this source css into ```style.css```.
[![My idlers screenshot3](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-servers-home.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-servers-home.jpg)
**Auto complete provider & location are text inputs!** This means that if your choice isn't there then simply type it out
and upon form submission it gets added to the pool to choose from next time.
[![My idlers screenshot4](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-YABs.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-YABs.jpg)
### Screenshots
[![My idlers screenshot5](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-add-server_2.png)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-add-server_2.png)
[![My idlers screenshot1](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-cards.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-cards.jpg)
[![My idlers screenshot6](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-servers-compare.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-servers-compare.jpg)
[![My idlers screenshot2](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-table.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-table.jpg)
[![My idlers screenshot7](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-Ips.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-Ips.jpg)
[![My idlers screenshot3](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-more-modal.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-more-modal.jpg)
[![My idlers screenshot4](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-edit-modal.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-edit-modal.jpg)
[![My idlers screenshot5](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-order-servers.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-order-servers.jpg)
[![My idlers screenshot6](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-search.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-search.jpg)
[![My idlers screenshot7](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-summary-card.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-summary-card.jpg)
[![My idlers screenshot8](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-compare-two-servers.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-compare-two-servers.jpg)
[![My idlers screenshot9](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-server-from-yabs.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-server-from-yabs.jpg)
[![My idlers screenshot10](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-shared-hosting.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2021/02/my-idlers-self-hosted-server-info-add-shared-hosting.jpg)
[![Auto complete location](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-location.gif)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-location.gif)
[![Auto complete provider](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-provider.gif)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-auto-provider.gif)
[![Auto complete IP's](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-ips-from-hostname.gif)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-ips-from-hostname.gif)
[![Get up/down status](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-ping-up-feature.gif)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-ping-up-feature.gif)
[![Table scrolling x](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-table-view.gif)](https://cdn.write.corbpie.com/wp-content/uploads/2021/01/my-idlers-self-hosted-server-domain-information-table-view.gif)
[![My idlers screenshot8](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-labels.jpg)](https://cdn.write.corbpie.com/wp-content/uploads/2022/03/My-idlers-v2-labels.jpg)

View file

@ -1,33 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class CreateDatabaseCommand extends Command
{
protected $signature = 'make:database {name}';
protected $description = 'Creates my_idlers database';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$schemaName = $this->argument('name') ?: config("database.connections.mysql.database");
$charset = config("database.connections.mysql.charset",'utf8mb4');
$collation = config("database.connections.mysql.collation",'utf8mb4_unicode_ci');
config(["database.connections.mysql.database" => null]);
$query = "CREATE DATABASE IF NOT EXISTS $schemaName CHARACTER SET $charset COLLATE $collation;";
DB::statement($query);
config(["database.connections.mysql.database" => $schemaName]);
}
}

View file

@ -1,41 +0,0 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View file

@ -1,40 +0,0 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
}
}

View file

@ -1,26 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class AccountController extends Controller
{
public function index()
{
return view('account.index');
}
public function update(Request $request)
{
$user = Auth::user();
$user->name = $request->name;
$user->email = $request->email;
$user->save();
return redirect()->route('account.index')
->with('success', 'Account Updated Successfully.');
}
}

View file

@ -1,510 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Domains;
use App\Models\IPs;
use App\Models\Labels;
use App\Models\Misc;
use App\Models\NetworkSpeed;
use App\Models\Note;
use App\Models\OS;
use App\Models\Pricing;
use App\Models\Providers;
use App\Models\Reseller;
use App\Models\SeedBoxes;
use App\Models\Server;
use App\Models\Shared;
use App\Models\User;
use App\Models\Yabs;
use DataTables;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
class ApiController extends Controller
{
protected function getAllServers()
{
$servers = Server::allServers()->toJson(JSON_PRETTY_PRINT);
return response($servers, 200);
}
protected function getServer($id)
{
$server = Server::server($id)->toJson(JSON_PRETTY_PRINT);
return response($server, 200);
}
protected function getAllPricing()
{
$pricing = Pricing::all()->toJson(JSON_PRETTY_PRINT);
return response($pricing, 200);
}
protected function getPricing($id)
{
$pricing = Pricing::where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($pricing, 200);
}
protected function getAllNetworkSpeeds()
{
$ns = NetworkSpeed::all()->toJson(JSON_PRETTY_PRINT);
return response($ns, 200);
}
protected function getNetworkSpeeds($id)
{
$ns = NetworkSpeed::where('server_id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($ns, 200);
}
protected function getAllLabels()
{
$labels = Labels::all()->toJson(JSON_PRETTY_PRINT);
return response($labels, 200);
}
protected function getLabel($id)
{
$label = Labels::where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($label, 200);
}
protected function getAllShared()
{
$shared = Shared::allSharedHosting()->toJson(JSON_PRETTY_PRINT);
return response($shared, 200);
}
protected function getShared($id)
{
$shared = Shared::sharedHosting($id)->toJson(JSON_PRETTY_PRINT);
return response($shared, 200);
}
protected function getAllReseller()
{
$reseller = Reseller::allResellerHosting()->toJson(JSON_PRETTY_PRINT);
return response($reseller, 200);
}
protected function getReseller($id)
{
$reseller = Reseller::resellerHosting($id)->toJson(JSON_PRETTY_PRINT);
return response($reseller, 200);
}
protected function getAllSeedbox()
{
$reseller = SeedBoxes::allSeedboxes()->toJson(JSON_PRETTY_PRINT);
return response($reseller, 200);
}
protected function getSeedbox($id)
{
$reseller = SeedBoxes::seedbox($id)->toJson(JSON_PRETTY_PRINT);
return response($reseller, 200);
}
protected function getAllDomains()
{
$domains = Domains::allDomains()->toJson(JSON_PRETTY_PRINT);
return response($domains, 200);
}
protected function getDomains($id)
{
$domain = Domains::domain($id)->toJson(JSON_PRETTY_PRINT);
return response($domain, 200);
}
protected function getAllMisc()
{
$misc = Misc::allMisc()->toJson(JSON_PRETTY_PRINT);
return response($misc, 200);
}
protected function getMisc($id)
{
$misc = Misc::misc($id)->toJson(JSON_PRETTY_PRINT);
return response($misc, 200);
}
protected function getAllDns()
{
$dns = DB::table('d_n_s')
->get()->toJson(JSON_PRETTY_PRINT);
return response($dns, 200);
}
protected function getDns($id)
{
$dns = DB::table('d_n_s')
->where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($dns, 200);
}
protected function getAllLocations()
{
$locations = DB::table('locations')
->get()->toJson(JSON_PRETTY_PRINT);
return response($locations, 200);
}
protected function getLocation($id)
{
$location = DB::table('locations')
->where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($location, 200);
}
protected function getAllProviders()
{
$providers = DB::table('providers')
->get()->toJson(JSON_PRETTY_PRINT);
return response($providers, 200);
}
protected function getProvider($id)
{
$providers = DB::table('providers')
->where('id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($providers, 200);
}
protected function getAllSettings()
{
$settings = DB::table('settings')
->get()->toJson(JSON_PRETTY_PRINT);
return response($settings, 200);
}
protected function getAllOs()
{
$os = OS::allOS()->toJson(JSON_PRETTY_PRINT);
return response($os, 200);
}
protected function getOs($id)
{
$os = DB::table('os as o')
->where('o.id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($os, 200);
}
protected function getAllIPs()
{
$ip = IPs::all()->toJson(JSON_PRETTY_PRINT);
return response($ip, 200);
}
protected function getIP($id)
{
$ip = DB::table('ips as i')
->where('i.id', $id)
->get()->toJson(JSON_PRETTY_PRINT);
return response($ip, 200);
}
public function getAllProvidersTable(Request $request)
{
if ($request->ajax()) {
$data = Providers::latest()->get();
$dt = Datatables::of($data)
->addIndexColumn()
->addColumn('action', function ($row) {
$actionBtn = '<form action="' . route('providers.destroy', $row['id']) . '" method="POST"><i class="fas fa-trash text-danger ms-3" @click="modalForm" id="btn-' . $row['name'] . '" title="' . $row['id'] . '"></i> </form>';
return $actionBtn;
})
->rawColumns(['action'])
->make(true);
return $dt;
}
}
protected function checkHostIsUp(string $hostname)
{//Check if host/ip is "up"
($fp = @fsockopen($hostname, 80, $errCode, $errStr, 1)) ? $result = true : $result = false;
if ($fp) {
@fclose($fp);
}
return response(array('is_online' => $result), 200);
}
protected function getIpForDomain(string $domainname, string $type)
{//Gets IP from A record for a domain
switch ($type) {
case "A":
$data = dns_get_record($domainname, DNS_A);
if (isset($data['0']['ip'])) {
return response(array('ip' => $data['0']['ip']), 200);
}
break;
case "AAAA":
$data = dns_get_record($domainname, DNS_AAAA);
if (isset($data['0']['ipv6'])) {
return response(array('ip' => $data['0']['ipv6']), 200);
}
break;
}
return response(array('ip' => null), 200);
}
protected function storeServer(Request $request)
{
$rules = [
'hostname' => 'min:3',
'server_type' => 'required|integer',
'os_id' => 'required|integer',
'provider_id' => 'required|integer',
'location_id' => 'required|integer',
'ssh_port' => 'required|integer',
'ram' => 'required|integer',
'ram_as_mb' => 'required|integer',
'disk' => 'required|integer',
'disk_as_gb' => 'required|integer',
'cpu' => 'required|integer',
'bandwidth' => 'required|integer',
'was_promo' => 'required|integer',
'active' => 'required|integer',
'show_public' => 'required|integer',
'ip1' => 'ip',
'ip2' => 'ip',
'owned_since' => 'required|date',
'ram_type' => 'required|string|size:2',
'disk_type' => 'required|string|size:2',
'currency' => 'required|string|size:3',
'price' => 'required|numeric',
'payment_term' => 'required|integer',
'next_due_date' => 'date',
];
$messages = [
'required' => ':attribute is required',
'min' => ':attribute must be longer than 3',
'integer' => ':attribute must be an integer',
'string' => ':attribute must be a string',
'size' => ':attribute must be exactly :size characters',
'numeric' => ':attribute must be a float',
'ip' => ':attribute must be a valid IP address',
'date' => ':attribute must be a date Y-m-d',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return response()->json(['result' => 'fail', 'messages' => $validator->messages()], 400);
}
$server_id = Str::random(8);
$pricing = new Pricing();
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $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);
}
$insert = Server::create([
'id' => $server_id,
'hostname' => $request->hostname,
'server_type' => $request->server_type,
'os_id' => $request->os_id,
'ssh_port' => $request->ssh_port,
'provider_id' => $request->provider_id,
'location_id' => $request->location_id,
'ram' => $request->ram,
'ram_type' => $request->ram_type,
'ram_as_mb' => ($request->ram_type === 'MB') ? $request->ram : ($request->ram * 1024),
'disk' => $request->disk,
'disk_type' => $request->disk_type,
'disk_as_gb' => ($request->disk_type === 'GB') ? $request->disk : ($request->disk * 1024),
'owned_since' => $request->owned_since,
'ns1' => $request->ns1,
'ns2' => $request->ns2,
'bandwidth' => $request->bandwidth,
'cpu' => $request->cpu,
'was_promo' => $request->was_promo,
'show_public' => (isset($request->show_public)) ? 1 : 0
]);
Server::serverRelatedCacheForget();
if ($insert) {
return response()->json(array('result' => 'success', 'server_id' => $server_id), 200);
}
return response()->json(array('result' => 'fail', 'request' => $request->post()), 500);
}
public function destroyServer(Request $request)
{
$items = Server::find($request->id);
(!is_null($items)) ? $result = $items->delete() : $result = false;
$p = new Pricing();
$p->deletePricing($request->id);
Labels::deleteLabelsAssignedTo($request->id);
IPs::deleteIPsAssignedTo($request->id);
Server::serverRelatedCacheForget();
if ($result) {
return response()->json(array('result' => 'success'), 200);
}
return response()->json(array('result' => 'fail'), 500);
}
public function updateServer(Request $request)
{
$rules = [
'hostname' => 'string|min:3',
'server_type' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'ssh_port' => 'integer',
'ram' => 'integer',
'ram_as_mb' => 'integer',
'disk' => 'integer',
'disk_as_gb' => 'integer',
'cpu' => 'integer',
'bandwidth' => 'integer',
'was_promo' => 'integer',
'active' => 'integer',
'show_public' => 'integer',
'owned_since' => 'date',
'ram_type' => 'string|size:2',
'disk_type' => 'string|size:2',
'currency' => 'string|size:3',
'price' => 'numeric',
'payment_term' => 'integer',
'next_due_date' => 'date',
];
$messages = [
'required' => ':attribute is required',
'min' => ':attribute must be longer than 3',
'integer' => ':attribute must be an integer',
'string' => ':attribute must be a string',
'size' => ':attribute must be exactly :size characters',
'numeric' => ':attribute must be a float',
'date' => ':attribute must be a date Y-m-d',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return response()->json(['result' => 'fail', 'messages' => $validator->messages()], 400);
}
$server_update = Server::where('id', $request->id)->update(request()->all());
Server::serverRelatedCacheForget();
Server::serverSpecificCacheForget($request->id);
if ($server_update) {
return response()->json(array('result' => 'success', 'server_id' => $request->id), 200);
}
return response()->json(array('result' => 'fail', 'request' => $request->post()), 500);
}
public function updatePricing(Request $request)
{
$rules = [
'price' => 'required|numeric',
'currency' => 'required|string|size:3',
'term' => 'required|integer',
'active' => 'integer',
'next_due_date' => 'date',
];
$messages = [
'required' => ':attribute is required',
'integer' => ':attribute must be an integer',
'string' => ':attribute must be a string',
'size' => ':attribute must be exactly :size characters',
'numeric' => ':attribute must be a float',
'date' => ':attribute must be a date Y-m-d',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return response()->json(['result' => 'fail', 'messages' => $validator->messages()], 400);
}
$pricing = new Pricing();
$request->as_usd = $pricing->convertToUSD($request->price, $request->currency);
$request->usd_per_month = $pricing->costAsPerMonth($request->as_usd, $request->term);
$price_update = Pricing::where('id', $request->id)->update(request()->all());
Cache::forget("all_pricing");
Server::serverRelatedCacheForget();
if ($price_update) {
return response()->json(array('result' => 'success', 'server_id' => $request->id), 200);
}
return response()->json(array('result' => 'fail', 'request' => $request->post()), 500);
}
public function storeYabs(Request $request, Server $server, string $key): \Illuminate\Http\JsonResponse
{
$r = User::where('api_token', $key)->first();
if (!isset($r->id)) {
return response()->json(['error' => 'Unauthenticated'], 401);
}
$insert = Yabs::insertFromJson($request, $server->id);
if ($insert) {
Cache::forget('all_active_servers');//all servers cache
Cache::forget('non_active_servers');//all servers cache
Cache::forget('all_yabs');//Forget the all YABS cache
return response()->json(array('message' => 'Successfully added YABS'), 200);
}
return response()->json(array('error' => 'Server error'), 500);
}
public function getAllYabs()
{
$yabs = Yabs::allYabs()->toJson(JSON_PRETTY_PRINT);
return response($yabs, 200);
}
protected function getYabs($id)
{
$yabs = Yabs::yabs($id)->toJson(JSON_PRETTY_PRINT);
return response($yabs, 200);
}
protected function getNote($id)
{
$note = Note::where('id', $id)->firstOrFail('note')->pluck('note');
return response($note, 200)->header('Content-Type', 'text/plain');
}
}

View file

@ -1,59 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use App\Models\User;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AuthenticatedSessionController extends Controller
{
/**
* Display the login view.
*
* @return \Illuminate\View\View
*/
public function create()
{
$users = User::all();
if ($users->count() === 0) {//Only allow 1 user for this app
return redirect('/register');
}
return view('auth.login');
}
/**
* Handle an incoming authentication request.
*
* @param \App\Http\Requests\Auth\LoginRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(LoginRequest $request)
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(RouteServiceProvider::HOME);
}
/**
* Destroy an authenticated session.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Request $request)
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}

View file

@ -1,40 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}

View file

@ -1,44 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
class ConfirmablePasswordController extends Controller
{
/**
* Show the confirm password view.
*
* @return \Illuminate\View\View
*/
public function show()
{
return view('auth.confirm-password');
}
/**
* Confirm the user's password.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function store(Request $request)
{
if (! Auth::guard('web')->validate([
'email' => $request->user()->email,
'password' => $request->password,
])) {
throw ValidationException::withMessages([
'password' => __('auth.password'),
]);
}
$request->session()->put('auth.password_confirmed_at', time());
return redirect()->intended(RouteServiceProvider::HOME);
}
}

View file

@ -1,27 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
class EmailVerificationNotificationController extends Controller
{
/**
* Send a new email verification notification.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(RouteServiceProvider::HOME);
}
$request->user()->sendEmailVerificationNotification();
return back()->with('status', 'verification-link-sent');
}
}

View file

@ -1,23 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
class EmailVerificationPromptController extends Controller
{
/**
* Display the email verification prompt.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function __invoke(Request $request)
{
return $request->user()->hasVerifiedEmail()
? redirect()->intended(RouteServiceProvider::HOME)
: view('auth.verify-email');
}
}

View file

@ -1,22 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}

View file

@ -1,42 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}

View file

@ -1,65 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
class NewPasswordController extends Controller
{
/**
* Display the password reset view.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function create(Request $request)
{
return view('auth.reset-password', ['request' => $request]);
}
/**
* Handle an incoming new password request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'token' => ['required'],
'email' => ['required', 'email'],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
function ($user) use ($request) {
$user->forceFill([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
])->save();
event(new PasswordReset($user));
}
);
// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $status == Password::PASSWORD_RESET
? redirect()->route('login')->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
}
}

View file

@ -1,47 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
class PasswordResetLinkController extends Controller
{
/**
* Display the password reset link request view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('auth.forgot-password');
}
/**
* Handle an incoming password reset link request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'email' => ['required', 'email'],
]);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$status = Password::sendResetLink(
$request->only('email')
);
return $status == Password::RESET_LINK_SENT
? back()->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
}
}

View file

@ -1,75 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'api_token' => Str::random(60)
]);
}
}

View file

@ -1,61 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\Settings;
use App\Models\User;
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
class RegisteredUserController extends Controller
{
/**
* Display the registration view.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function create()
{
$users = User::all();
if ($users->count() >= 1) {//Only allow 1 user for this app
return redirect('/login');
}
return view('auth.register');
}
/**
* Handle an incoming registration request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
'api_token' => Str::random(60)
]);
event(new Registered($user));
Auth::login($user);
return redirect('/');
}
}

View file

@ -1,31 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
}

View file

@ -1,42 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View file

@ -1,30 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
class VerifyEmailController extends Controller
{
/**
* Mark the authenticated user's email address as verified.
*
* @param \Illuminate\Foundation\Auth\EmailVerificationRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function __invoke(EmailVerificationRequest $request)
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1');
}
}

View file

@ -1,13 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View file

@ -1,137 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\DNS;
use App\Models\Labels;
use App\Models\Reseller;
use App\Models\Server;
use App\Models\Domains;
use App\Models\Shared;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class DNSController extends Controller
{
public function index()
{
$dn = DB::table('d_n_s')->get();
return view('dns.index', compact(['dn']));
}
public function create()
{
$Servers = Server::all();
$Domains = Domains::all();
$Shareds = Shared::all();
$Resellers = Reseller::all();
return view('dns.create', compact(['Servers', 'Domains', 'Shareds', 'Resellers']));
}
public function store(Request $request)
{
$request->validate([
'hostname' => 'required|string|min:2',
'address' => 'required|string|min:2',
'dns_type' => 'required|string',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$dns_id = Str::random(8);
DNS::create([
'id' => $dns_id,
'hostname' => $request->hostname,
'dns_type' => $request->dns_type,
'address' => $request->address,
'server_id' => ($request->server_id !== 'null') ? $request->server_id : null,
'shared_id' => ($request->shared_id !== 'null') ? $request->shared_id : null,
'reseller_id' => ($request->reseller_id !== 'null') ? $request->reseller_id : null,
'domain_id' => ($request->domain_id !== 'null') ? $request->domain_id : null
]);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $dns_id);
Cache::forget('dns_count');
return redirect()->route('dns.index')
->with('success', 'DNS Created Successfully.');
}
public function show(DNS $dn)
{
$dns = DNS::findOrFail($dn->id);
$labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', 'labels.id')
->where('l.service_id', $dn->id)
->get(['labels.label']);
return view('dns.show', compact(['dn', 'dns', 'labels']));
}
public function edit(DNS $dn)
{
$Servers = Server::all();
$Domains = Domains::all();
$Shareds = Shared::all();
$Resellers = Reseller::all();
$dn = DNS::findOrFail($dn->id);
$labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', 'labels.id')
->where('l.service_id', $dn->id)
->get(['labels.id']);
return view('dns.edit', compact(['dn', 'labels', 'Servers', 'Domains', 'Shareds', 'Resellers']));
}
public function update(Request $request, DNS $dn): \Illuminate\Http\RedirectResponse
{
$request->validate([
'hostname' => 'required|string|min:2',
'address' => 'required|string|min:2',
'dns_type' => 'required|string',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$dn->update([
'hostname' => $request->hostname,
'dns_type' => $request->dns_type,
'address' => $request->address,
'server_id' => ($request->server_id !== 'null') ? $request->server_id : null,
'shared_id' => ($request->shared_id !== 'null') ? $request->shared_id : null,
'reseller_id' => ($request->reseller_id !== 'null') ? $request->reseller_id : null,
'domain_id' => ($request->domain_id !== 'null') ? $request->domain_id : null
]);
Labels::deleteLabelsAssignedTo($dn->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $dn->id);
return redirect()->route('dns.index')
->with('success', 'DNS updated Successfully.');
}
public function destroy(DNS $dn): \Illuminate\Http\RedirectResponse
{
if ( $dn->delete()){
Cache::forget('dns_count');
Labels::deleteLabelsAssignedTo($dn->id);
return redirect()->route('dns.index')
->with('success', 'DNS was deleted Successfully.');
}
return redirect()->route('dns.index')
->with('error', 'DNS was not deleted.');
}
}

View file

@ -1,11 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\DiskSpeed;
use Illuminate\Http\Request;
class DiskSpeedController extends Controller
{
}

View file

@ -1,148 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Domains;
use App\Models\Home;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class DomainsController extends Controller
{
public function index()
{
$domains = Domains::allDomains();
return view('domains.index', compact(['domains']));
}
public function show(Domains $domain)
{//Need to modern
$domain_info = Domains::domain($domain->id);
return view('domains.show', compact(['domain_info']));
}
public function create()
{
return view('domains.create');
}
public function store(Request $request)
{
$request->validate([
'domain' => 'required|string|min:2',
'extension' => 'required|string|min:2',
'ns1' => 'sometimes|nullable|min:2',
'ns2' => 'sometimes|nullable|min:2',
'ns3' => 'sometimes|nullable|min:2',
'provider_id' => 'integer',
'payment_term' => 'integer',
'price' => 'numeric',
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$domain_id = Str::random(8);
$pricing = new Pricing();
$pricing->insertPricing(4, $domain_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Domains::create([
'id' => $domain_id,
'domain' => $request->domain,
'extension' => $request->extension,
'ns1' => $request->ns1,
'ns2' => $request->ns2,
'ns3' => $request->ns3,
'provider_id' => $request->provider_id,
'owned_since' => $request->owned_since
]);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $domain_id);
Cache::forget("all_domains");
Home::homePageCacheForget();
return redirect()->route('domains.index')
->with('success', 'Domain Created Successfully.');
}
public function edit(Domains $domain)
{
$domain_info = Domains::domain($domain->id);
return view('domains.edit', compact(['domain_info']));
}
public function update(Request $request, Domains $domain)
{
$request->validate([
'domain' => 'required|string|min:2',
'extension' => 'required|string|min:2',
'ns1' => 'sometimes|nullable|min:2',
'ns2' => 'sometimes|nullable|min:2',
'ns3' => 'sometimes|nullable|min:2',
'provider_id' => 'integer',
'payment_term' => 'integer',
'price' => 'numeric',
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$pricing = new Pricing();
$pricing->updatePricing($domain->id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
$domain->update([
'domain' => $request->domain,
'extension' => $request->extension,
'ns1' => $request->ns1,
'ns2' => $request->ns2,
'ns3' => $request->ns3,
'provider_id' => $request->provider_id,
'owned_since' => $request->owned_since,
'active' => (isset($request->is_active)) ? 1 : 0
]);
Labels::deleteLabelsAssignedTo($domain->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $domain->id);
Cache::forget("all_domains");
Cache::forget("domain.{$domain->id}");
Cache::forget("labels_for_service.{$domain->id}");
Home::homePageCacheForget();
return redirect()->route('domains.index')
->with('success', 'Domain Updated Successfully.');
}
public function destroy(Domains $domain)
{
if ($domain->delete()){
$p = new Pricing();
$p->deletePricing($domain->id);
Labels::deleteLabelsAssignedTo($domain->id);
Cache::forget("all_domains");
Cache::forget("domain.{$domain->id}");
Home::homePageCacheForget();
return redirect()->route('domains.index')
->with('success', 'Domain was deleted Successfully.');
}
return redirect()->route('domains.index')
->with('error', 'Domain was not deleted.');
}
}

View file

@ -1,71 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\DNS;
use App\Models\Home;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\Settings;
use App\Process;
use Illuminate\Support\Facades\Session;
class HomeController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index()
{
$p = new Process();
$p->startTimer();
//Get & set the settings, 1 minute cache
$settings = Settings::getSettings();
Settings::setSettingsToSession($settings);
//Check for past due date and refresh the due date if so:
$due_soon = Home::doDueSoon(Home::dueSoonData());
//Orders services most recently added first, cached with limit from settings
$recently_added = Home::recentlyAdded();
//Get count tally for each of the services type
$service_count = Home::doServicesCount(Home::servicesCount());
//Get pricing for weekly, monthly, yearly, 2 yearly
$pricing_breakdown = Home::breakdownPricing(Pricing::allPricing());
//Summary of servers specs
$server_summary = Home::serverSummary();
$p->stopTimer();
$information = [
'servers' => $service_count['servers'],
'domains' => $service_count['domains'],
'shared' => $service_count['shared'],
'reseller' => $service_count['reseller'],
'misc' => $service_count['other'],
'seedbox' => $service_count['seedbox'],
'labels' => Labels::labelsCount(),
'dns' => DNS::dnsCount(),
'total_services' => $service_count['total'],
'total_inactive' => $pricing_breakdown['inactive_count'],
'total_cost_weekly' => number_format($pricing_breakdown['total_cost_weekly'], 2),
'total_cost_monthly' => number_format($pricing_breakdown['total_cost_monthly'], 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,
'newest' => $recently_added,
'execution_time' => number_format($p->getTimeTaken(), 2),
'servers_summary' => $server_summary,
'currency' => Session::get('dashboard_currency')
];
return view('home', compact('information'));
}
}

View file

@ -1,77 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\IPs;
use App\Models\Reseller;
use App\Models\SeedBoxes;
use App\Models\Server;
use App\Models\Shared;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
class IPsController extends Controller
{
public function index()
{
$ips = IPs::all();
return view('ips.index', compact(['ips']));
}
public function create()
{
$servers = Server::all();
$shareds = Shared::all();
$resellers = Reseller::all();
$seed_boxes = SeedBoxes::all();
return view('ips.create', compact(['servers', 'shareds', 'resellers', 'seed_boxes']));
}
public function store(Request $request)
{
$request->validate([
'address' => 'required|ip|min:2',
'ip_type' => 'required|string|size:4',
'service_id' => 'required|string'
]);
$ip_id = Str::random(8);
$ip = IPs::create([
'id' => $ip_id,
'address' => $request->address,
'is_ipv4' => ($request->ip_type === 'ipv4') ? 1 : 0,
'service_id' => $request->service_id,
'active' => 1
]);
$fetch = IPs::getUpdateIpInfo($ip);
return redirect()->route('IPs.index')
->with('success', 'IP address created Successfully.');
}
public function destroy(IPs $IP)
{
if ($IP->delete()) {
return redirect()->route('IPs.index')
->with('success', 'IP address was deleted Successfully.');
}
return redirect()->route('IPs.index')
->with('error', 'IP was not deleted.');
}
public function getUpdateWhoIs(IPs $IP): \Illuminate\Http\RedirectResponse
{
$result = IPs::getUpdateIpInfo($IP);
if ($result) {
return redirect()->route('IPs.index')
->with('success', 'IP address updated Successfully.');
}
return redirect()->route('IPs.index')
->with('error', 'IP was not updated.');
}
}

View file

@ -1,73 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Labels;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class LabelsController extends Controller
{
public function index()
{
$labels = Labels::all();
return view('labels.index', compact(['labels']));
}
public function create()
{
return view('labels.create');
}
public function store(Request $request)
{
$request->validate([
'label' => 'required|string|min:2'
]);
Labels::create([
'id' => Str::random(8),
'label' => $request->label
]);
Cache::forget('all_labels');
Cache::forget('labels_count');
return redirect()->route('labels.index')
->with('success', 'Label Created Successfully.');
}
public function show(Labels $label)
{
$labels = DB::table('labels_assigned as las')
->leftJoin('pricings as p', 'las.service_id', 'p.service_id')
->leftJoin('servers as s', 'las.service_id', 's.id')
->leftJoin('shared_hosting as sh', 'las.service_id', 'sh.id')
->leftJoin('reseller_hosting as r', 'las.service_id', 'r.id')
->leftJoin('domains as d', 'las.service_id', 'd.id')
->where('las.label_id', $label->id)
->get(['p.service_type', 'p.service_id', 's.hostname', 'sh.main_domain as shared', 'r.main_domain as reseller', 'd.domain', 'd.extension']);
return view('labels.show', compact(['label', 'labels']));
}
public function destroy(Labels $label)
{
if ($label->delete()) {
Cache::forget('labels_count');
Labels::deleteLabelAssignedAs($label->id);
Cache::forget('all_labels');
return redirect()->route('labels.index')
->with('success', 'Label was deleted Successfully.');
}
return redirect()->route('labels.index')
->with('error', 'Label was not deleted.');
}
}

View file

@ -1,75 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Locations;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class LocationsController extends Controller
{
public function index()
{
$locations = Locations::allLocations();
return view('locations.index', compact(['locations']));
}
public function create()
{
return view('locations.create');
}
public function store(Request $request)
{
$request->validate([
'location_name' => 'required|string|min:2|max:255'
]);
Locations::create([
'name' => $request->location_name
]);
Cache::forget('locations');
return redirect()->route('locations.index')
->with('success', 'Location Created Successfully.');
}
public function show(Locations $location)
{
$servers = DB::table('servers as s')
->where('s.location_id', $location->id)
->get(['s.id', 's.hostname'])
->toArray();
$shared = DB::table('shared_hosting as s')
->where('s.location_id', $location->id)
->get(['s.id', 's.main_domain as main_domain_shared'])
->toArray();
$reseller = DB::table('reseller_hosting as r')
->where('r.location_id', $location->id)
->get(['r.id', 'r.main_domain as main_domain_reseller'])
->toArray();
$data = array_merge($servers, $shared, $reseller);
return view('locations.show', compact(['location', 'data']));
}
public function destroy(Locations $location)
{
if ($location->delete()){
Cache::forget('locations');
return redirect()->route('locations.index')
->with('success', 'Location was deleted Successfully.');
}
return redirect()->route('locations.index')
->with('error', 'Location was not deleted.');
}
}

View file

@ -1,111 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\Misc;
use App\Models\Pricing;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
class MiscController extends Controller
{
public function index()
{
$misc = Misc::allMisc();
return view('misc.index', compact(['misc']));
}
public function create()
{
return view('misc.create');
}
public function show(Misc $misc)
{
$misc_data = Misc::misc($misc->id);
return view('misc.show', compact(['misc_data']));
}
public function store(Request $request)
{
$request->validate([
'name' => 'required|string|min:3',
'price' => 'required|numeric',
'payment_term' => 'required|integer',
'currency' => 'required|string|size:3',
'owned_since' => 'sometimes|nullable|date',
'next_due_date' => 'required|date'
]);
$misc_id = Str::random(8);
$pricing = new Pricing();
$pricing->insertPricing(5, $misc_id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Misc::create([
'id' => $misc_id,
'name' => $request->name,
'owned_since' => $request->owned_since
]);
Cache::forget("all_misc");
Home::homePageCacheForget();
return redirect()->route('misc.index')
->with('success', 'Misc service created Successfully.');
}
public function edit(Misc $misc)
{
$misc_data = Misc::misc($misc->id);
return view('misc.edit', compact('misc_data'));
}
public function update(Request $request, Misc $misc)
{
$request->validate([
'name' => 'required|string|min:3',
'price' => 'required|numeric',
'payment_term' => 'required|integer',
'currency' => 'required|string|size:3',
'owned_since' => 'sometimes|nullable|date',
'next_due_date' => 'required|date'
]);
$misc->update([
'name' => $request->name,
'owned_since' => $request->owned_since,
'active' => (isset($request->is_active)) ? 1 : 0
]);
$pricing = new Pricing();
$pricing->updatePricing($misc->id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Cache::forget("all_misc");
Cache::forget("misc.{$misc->id}");
Home::homePageCacheForget();
return redirect()->route('misc.index')
->with('success', 'Misc service updated Successfully.');
}
public function destroy(Misc $misc)
{
if ($misc->delete()) {
$p = new Pricing();
$p->deletePricing($misc->id);
Cache::forget("all_misc");
Cache::forget("misc.{$misc->id}");
Home::homePageCacheForget();
return redirect()->route('misc.index')
->with('success', 'Misc service was deleted Successfully.');
}
return redirect()->route('misc.index')
->with('error', 'Misc service was not deleted.');
}
}

View file

@ -1,10 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\NetworkSpeed;
use Illuminate\Http\Request;
class NetworkSpeedController extends Controller
{
}

View file

@ -1,123 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\DNS;
use App\Models\Domains;
use App\Models\IPs;
use App\Models\Note;
use App\Models\Reseller;
use App\Models\Server;
use App\Models\Shared;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
class NoteController extends Controller
{
public function index()
{
$notes = Note::allNotes();
return view('notes.index', compact('notes'));
}
public function create()
{
$servers = Server::all();
$shareds = Shared::all();
$resellers = Reseller::all();
$domains = Domains::all();
$dns = DNS::all();
$ips = IPs::all();
return view('notes.create', compact(['servers', 'shareds', 'resellers', 'domains', 'dns', 'ips']));
}
public function store(Request $request)
{
$request->validate([
'service_id' => 'required|string|size:8',
'note' => 'required|string',
]);
try {
$note_id = Str::random(8);
$a = Note::create([
'id' => $note_id,
'service_id' => $request->service_id,
'note' => $request->note
]);
} catch (\Exception $e) {
if ($e->getCode() === "23000") {
$message = "A note already exists for this service";
} else {
$message = "Error inserting note";
}
return redirect()->route('notes.create')
->withInput($request->input())->with('error', $message);
}
Cache::forget('all_notes');
return redirect()->route('notes.index')
->with('success', 'Note created successfully.');
}
public function edit(Note $note)
{
$note = Note::note($note->service_id);
$servers = Server::all();
$shareds = Shared::all();
$resellers = Reseller::all();
$domains = Domains::all();
$dns = DNS::all();
$ips = IPs::all();
return view('notes.edit', compact(['note', 'servers', 'shareds', 'resellers', 'domains', 'dns', 'ips']));
}
public function update(Request $request, Note $note)
{
$request->validate([
'service_id' => 'required|string|size:8',
'note' => 'required|string'
]);
$note->update([
'service_id' => $request->service_id,
'note' => $request->note
]);
Cache::forget('all_notes');
Cache::forget("note.$note->service_id");
return redirect()->route('notes.index')
->with('success', 'Note was updated successfully.');
}
public function show(Note $note)
{
$note = Note::note($note->service_id);
return view('notes.show', compact(['note']));
}
public function destroy(Note $note)
{
if ($note->delete()) {
Cache::forget("all_notes");
Cache::forget("note.$note->service_id");
return redirect()->route('notes.index')
->with('success', 'Note was deleted successfully.');
}
return redirect()->route('notes.index')
->with('error', 'Note was not deleted.');
}
}

View file

@ -1,51 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\OS;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class OsController extends Controller
{
public function index()
{
$os = OS::allOS()->toArray();
return view('os.index', compact(['os']));
}
public function create()
{
return view('os.create');
}
public function store(Request $request)
{
$request->validate([
'os_name' => 'required|string|min:2|max:255'
]);
OS::create([
'name' => $request->os_name
]);
Cache::forget('operating_systems');
return redirect()->route('os.index')
->with('success', 'OS Created Successfully.');
}
public function destroy(OS $o)
{
if ($o->delete()) {
Cache::forget('operating_systems');
return redirect()->route('os.index')
->with('success', 'OS was deleted Successfully.');
}
return redirect()->route('os.index')
->with('error', 'OS was not deleted.');
}
}

View file

@ -1,11 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Pricing;
use Illuminate\Http\Request;
class PricingController extends Controller
{
}

View file

@ -1,59 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Providers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class ProvidersController extends Controller
{
public function index()
{
$providers = Providers::allProviders();
return view('providers.index', compact(['providers']));
}
public function create()
{
return view('providers.create');
}
public function store(Request $request)
{
$request->validate([
'provider_name' => 'required|string|min:2|max:255'
]);
Providers::create([
'name' => $request->provider_name
]);
Cache::forget('providers');
return redirect()->route('providers.index')
->with('success', 'Provider Created Successfully.');
}
public function show(Providers $provider)
{
$data = Providers::showServicesForProvider($provider->id);
return view('providers.show', compact(['provider', 'data']));
}
public function destroy(Providers $provider)
{
if ($provider->delete()) {
Cache::forget('providers');
return redirect()->route('providers.index')
->with('success', 'Provider was deleted Successfully.');
}
return redirect()->route('providers.index')
->with('error', 'Provider was not deleted.');
}
}

View file

@ -1,194 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\IPs;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\Reseller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
class ResellerController extends Controller
{
public function index()
{
$resellers = Reseller::allResellerHosting();
return view('reseller.index', compact(['resellers']));
}
public function create()
{
return view('reseller.create');
}
public function store(Request $request)
{
$request->validate([
'domain' => 'required|min:4',
'reseller_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'accounts' => 'integer',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$reseller_id = Str::random(8);
$pricing = new Pricing();
$pricing->insertPricing(3, $reseller_id, $request->currency, $request->price, $request->payment_term, $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([
'id' => $reseller_id,
'main_domain' => $request->domain,
'accounts' => $request->accounts,
'reseller_type' => $request->reseller_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,
'was_promo' => $request->was_promo,
'domains_limit' => $request->domains,
'subdomains_limit' => $request->sub_domains,
'email_limit' => $request->email,
'ftp_limit' => $request->ftp,
'db_limit' => $request->db
]);
Cache::forget("all_reseller");
Home::homePageCacheForget();
return redirect()->route('reseller.index')
->with('success', 'Reseller hosting created Successfully.');
}
public function show(Reseller $reseller)
{
$reseller = Reseller::resellerHosting($reseller->id);
return view('reseller.show', compact(['reseller']));
}
public function edit(Reseller $reseller)
{
$reseller = Reseller::resellerHosting($reseller->id);
return view('reseller.edit', compact(['reseller']));
}
public function update(Request $request, Reseller $reseller)
{
$request->validate([
'domain' => 'required|min:4',
'reseller_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'accounts' => 'integer',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$reseller->update([
'main_domain' => $request->domain,
'reseller_type' => $request->reseller_type,
'provider_id' => $request->provider_id,
'location_id' => $request->location_id,
'accounts' => $request->accounts,
'disk' => $request->disk,
'disk_type' => 'GB',
'disk_as_gb' => $request->disk,
'owned_since' => $request->owned_since,
'bandwidth' => $request->bandwidth,
'was_promo' => $request->was_promo,
'domains_limit' => $request->domains,
'subdomains_limit' => $request->sub_domains,
'email_limit' => $request->email,
'ftp_limit' => $request->ftp,
'db_limit' => $request->db
]);
$pricing = new Pricing();
$pricing->updatePricing($reseller->id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Labels::deleteLabelsAssignedTo($reseller->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $reseller->id);
IPs::deleteIPsAssignedTo($reseller->id);
if (!is_null($request->dedicated_ip)) {
IPs::insertIP($reseller->id, $request->dedicated_ip);
}
Cache::forget("all_reseller");
Cache::forget("reseller_hosting.{$reseller->id}");
Cache::forget("labels_for_service.{$reseller->id}");
Home::homePageCacheForget();
return redirect()->route('reseller.index')
->with('success', 'Reseller hosting updated Successfully.');
}
public function destroy(Reseller $reseller)
{
if ($reseller->delete()) {
$p = new Pricing();
$p->deletePricing($reseller->id);
Labels::deleteLabelsAssignedTo($reseller->id);
IPs::deleteIPsAssignedTo($reseller->id);
Cache::forget("all_reseller");
Cache::forget("reseller_hosting.$reseller->id");
Home::homePageCacheForget();
return redirect()->route('reseller.index')
->with('success', 'Reseller hosting was deleted Successfully.');
}
return redirect()->route('reseller.index')
->with('error', 'Reseller was not deleted.');
}
}

View file

@ -1,163 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\SeedBoxes;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
class SeedBoxesController extends Controller
{
public function index()
{
$seedboxes = SeedBoxes::allSeedboxes();
return view('seedboxes.index', compact(['seedboxes']));
}
public function create()
{
return view('seedboxes.create');
}
public function store(Request $request)
{
$request->validate([
'title' => 'required|string|min:2',
'hostname' => 'sometimes|nullable|string|min:2',
'seed_box_type' => 'required|string',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'disk' => 'integer',
'bandwidth' => 'integer',
'port_speed' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$seedbox_id = Str::random(8);
$pricing = new Pricing();
$pricing->insertPricing(6, $seedbox_id, $request->currency, $request->price, $request->payment_term, $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
]);
Cache::forget("all_seedboxes");
Home::homePageCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box created Successfully.');
}
public function show(SeedBoxes $seedbox)
{
$seedbox_data = SeedBoxes::seedbox($seedbox->id);
return view('seedboxes.show', compact(['seedbox_data']));
}
public function edit(SeedBoxes $seedbox)
{
$seedbox_data = SeedBoxes::seedbox($seedbox->id);
return view('seedboxes.edit', compact(['seedbox_data']));
}
public function update(Request $request, SeedBoxes $seedbox)
{
$request->validate([
'title' => 'required|string|min:2',
'hostname' => 'sometimes|nullable|string|min:2',
'seed_box_type' => 'required|string',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'disk' => 'integer',
'bandwidth' => 'integer',
'port_speed' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$seedbox->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();
$pricing->updatePricing($seedbox->id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Labels::deleteLabelsAssignedTo($seedbox->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $seedbox->id);
Cache::forget("all_seedboxes");
Cache::forget("seedbox.{$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)
{
if ($seedbox->delete()) {
$p = new Pricing();
$p->deletePricing($seedbox->id);
Labels::deleteLabelsAssignedTo($seedbox->id);
Cache::forget("all_seedboxes");
Cache::forget("seedbox.{$seedbox->id}");
Home::homePageCacheForget();
return redirect()->route('seedboxes.index')
->with('success', 'Seed box was deleted Successfully.');
}
return redirect()->route('seedboxes.index')
->with('error', 'Seed box was not deleted.');
}
}

View file

@ -1,246 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\IPs;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\Server;
use App\Models\Settings;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
class ServerController extends Controller
{
public function index()
{
$servers = Server::allActiveServers();
$non_active_servers = Server::allNonActiveServers();
return view('servers.index', compact(['servers', 'non_active_servers']));
}
public function showServersPublic()
{
$settings = Settings::getSettings();
Settings::setSettingsToSession($settings);
if ((Session::get('show_servers_public') === 1)) {
$servers = Server::allPublicServers();
return view('servers.public-index', compact('servers'));
}
abort(404);
}
public function create()
{
return view('servers.create');
}
public function store(Request $request)
{
$request->validate([
'hostname' => 'required|min:5',
'ip1' => 'sometimes|nullable|ip',
'ip2' => 'sometimes|nullable|ip',
'ns1' => 'sometimes|nullable|string',
'ns2' => 'sometimes|nullable|string',
'server_type' => 'integer',
'ssh_port' => 'integer',
'bandwidth' => 'integer',
'ram' => 'required|numeric',
'disk' => 'required|integer',
'os_id' => 'required|integer',
'provider_id' => 'required|integer',
'location_id' => 'required|integer',
'price' => 'required|numeric',
'cpu' => 'required|integer',
'was_promo' => 'integer',
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$server_id = Str::random(8);
$pricing = new Pricing();
$pricing->insertPricing(1, $server_id, $request->currency, $request->price, $request->payment_term, $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([
'id' => $server_id,
'hostname' => $request->hostname,
'server_type' => $request->server_type,
'os_id' => $request->os_id,
'ssh' => $request->ssh_port,
'provider_id' => $request->provider_id,
'location_id' => $request->location_id,
'ram' => $request->ram,
'ram_type' => $request->ram_type,
'ram_as_mb' => ($request->ram_type === 'MB') ? $request->ram : ($request->ram * 1024),
'disk' => $request->disk,
'disk_type' => $request->disk_type,
'disk_as_gb' => ($request->disk_type === 'GB') ? $request->disk : ($request->disk * 1024),
'owned_since' => $request->owned_since,
'ns1' => $request->ns1,
'ns2' => $request->ns2,
'bandwidth' => $request->bandwidth,
'cpu' => $request->cpu,
'was_promo' => $request->was_promo,
'show_public' => (isset($request->show_public)) ? 1 : 0
]);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $server_id);
Server::serverRelatedCacheForget();
return redirect()->route('servers.index')
->with('success', 'Server Created Successfully.');
}
public function show(Server $server)
{
$server_data = Server::server($server->id);
return view('servers.show', compact(['server_data']));
}
public function edit(Server $server)
{
$server_data = Server::server($server->id);
return view('servers.edit', compact(['server_data']));
}
public function update(Request $request, Server $server)
{
$request->validate([
'hostname' => 'required|min:5',
'ip1' => 'sometimes|nullable|ip',
'ip2' => 'sometimes|nullable|ip',
'ns1' => 'sometimes|nullable|string',
'ns2' => 'sometimes|nullable|string',
'server_type' => 'integer',
'ssh_port' => 'integer',
'bandwidth' => 'integer',
'ram' => 'required|numeric',
'disk' => 'required|integer',
'os_id' => 'required|integer',
'provider_id' => 'required|integer',
'location_id' => 'required|integer',
'price' => 'required|numeric',
'cpu' => 'required|integer',
'was_promo' => 'integer',
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$server->update([
'hostname' => $request->hostname,
'server_type' => $request->server_type,
'os_id' => $request->os_id,
'ssh' => $request->ssh_port,
'provider_id' => $request->provider_id,
'location_id' => $request->location_id,
'ram' => $request->ram,
'ram_type' => $request->ram_type,
'ram_as_mb' => ($request->ram_type === 'MB') ? $request->ram : ($request->ram * 1024),
'disk' => $request->disk,
'disk_type' => $request->disk_type,
'disk_as_gb' => ($request->disk_type === 'GB') ? $request->disk : ($request->disk * 1024),
'owned_since' => $request->owned_since,
'ns1' => $request->ns1,
'ns2' => $request->ns2,
'bandwidth' => $request->bandwidth,
'cpu' => $request->cpu,
'was_promo' => $request->was_promo,
'active' => (isset($request->is_active)) ? 1 : 0,
'show_public' => (isset($request->show_public)) ? 1 : 0
]);
$pricing = new Pricing();
$pricing->updatePricing($server->id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Labels::deleteLabelsAssignedTo($server->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $server->id);
IPs::deleteIPsAssignedTo($server->id);
for ($i = 1; $i <= 8; $i++) {//Max of 8 ips
$obj = 'ip' . $i;
if (isset($request->$obj) && !is_null($request->$obj)) {
IPs::insertIP($server->id, $request->$obj);
}
}
Server::serverRelatedCacheForget();
Server::serverSpecificCacheForget($server->id);
return redirect()->route('servers.index')
->with('success', 'Server Updated Successfully.');
}
public function destroy(Server $server)
{
if ($server->delete()) {
$p = new Pricing();
$p->deletePricing($server->id);
Labels::deleteLabelsAssignedTo($server->id);
IPs::deleteIPsAssignedTo($server->id);
Server::serverRelatedCacheForget();
return redirect()->route('servers.index')
->with('success', 'Server was deleted Successfully.');
}
return redirect()->route('servers.index')
->with('error', 'Server was not deleted.');
}
public function chooseCompare()
{//NOTICE: Selecting servers is not cached yet
$all_servers = Server::where('has_yabs', 1)->get();
if (isset($all_servers[1])) {
return view('servers.choose-compare', compact('all_servers'));
}
return redirect()->route('servers.index')
->with('error', 'You need atleast 2 servers with a YABS to do a compare');
}
public function compareServers($server1, $server2)
{
$server1_data = Server::server($server1);
if (!isset($server1_data[0]->yabs[0])) {
abort(404);
}
$server2_data = Server::server($server2);
if (!isset($server2_data[0]->yabs[0])) {
abort(404);
}
return view('servers.compare', compact('server1_data', 'server2_data'));
}
}

View file

@ -1,98 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Settings;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
class SettingsController extends Controller
{
public function index()
{
return view('settings.index', ['setting' => Settings::where('id', 1)->first()]);
}
public function update(Request $request)
{
$request->validate([
'dark_mode' => 'required|integer|min:0|max:1',
'show_versions_footer' => 'required|integer|min:0|max:1',
'show_server_value_ip' => 'required|integer|min:0|max:1',
'show_server_value_hostname' => 'required|integer|min:0|max:1',
'show_server_value_provider' => 'required|integer|min:0|max:1',
'show_server_value_location' => 'required|integer|min:0|max:1',
'show_server_value_price' => 'required|integer|min:0|max:1',
'show_server_value_yabs' => 'required|integer|min:0|max:1',
'save_yabs_as_txt' => 'integer|min:0|max:1',
'default_currency' => 'required|string|size:3',
'default_server_os' => 'required|integer',
'due_soon_amount' => 'required|integer|between:0,12',
'recently_added_amount' => 'required|integer|between:0,12',
'currency' => 'required|string|size:3',
'sort_on' => 'required|integer|between:1,10',
'favicon' => 'sometimes|nullable|mimes:ico,jpg,png|max:40',
]);
$settings = Settings::where('id', 1)->first();
if ($request->favicon) {//Has a favicon upload
$file = $request->favicon;
$extension = $file->getClientOriginalExtension();
$favicon_filename = "favicon.$extension";
if ($favicon_filename !== $settings->favicon && $settings->favicon !== 'favicon.ico') {
Storage::disk('public_uploads')->delete($settings->favicon);//Delete old favicon
}
$file->storeAs("", $favicon_filename, "public_uploads");//Save into /public
}
$do_update = $settings->update([
'dark_mode' => $request->dark_mode,
'show_versions_footer' => $request->show_versions_footer,
'show_servers_public' => $request->show_servers_public,
'show_server_value_ip' => $request->show_server_value_ip,
'show_server_value_hostname' => $request->show_server_value_hostname,
'show_server_value_provider' => $request->show_server_value_provider,
'show_server_value_location' => $request->show_server_value_location,
'show_server_value_price' => $request->show_server_value_price,
'show_server_value_yabs' => $request->show_server_value_yabs,
'save_yabs_as_txt' => 0,
'default_currency' => $request->default_currency,
'default_server_os' => $request->default_server_os,
'due_soon_amount' => $request->due_soon_amount,
'recently_added_amount' => $request->recently_added_amount,
'dashboard_currency' => $request->currency,
'sort_on' => $request->sort_on,
'favicon' => $favicon_filename ?? $settings->favicon
]);
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('pricing_breakdown');//Main page pricing breakdown
Cache::forget('settings');//Main page settings cache
//Clear because they are affected by settings change (sort_on)
Cache::forget('all_servers');
Cache::forget('all_active_servers');
Cache::forget('all_shared');
Cache::forget('all_seedboxes');
Cache::forget('all_reseller');
Cache::forget('all_misc');
Cache::forget('all_domains');
Settings::setSettingsToSession(Settings::getSettings());
if ($do_update) {
return redirect()->route('settings.index')
->with('success', 'Settings Updated Successfully.');
}
return redirect()->route('settings.index')
->with('error', 'Settings failed to update.');
}
}

View file

@ -1,190 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Home;
use App\Models\IPs;
use App\Models\Labels;
use App\Models\Pricing;
use App\Models\Shared;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
class SharedController extends Controller
{
public function index()
{
$shared = Shared::allSharedHosting();
return view('shared.index', compact(['shared']));
}
public function create()
{
return view('shared.create');
}
public function store(Request $request)
{
$request->validate([
'domain' => 'required|min:4',
'shared_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$shared_id = Str::random(8);
$pricing = new Pricing();
$pricing->insertPricing(2, $shared_id, $request->currency, $request->price, $request->payment_term, $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([
'id' => $shared_id,
'main_domain' => $request->domain,
'shared_type' => $request->shared_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,
'was_promo' => $request->was_promo,
'domains_limit' => $request->domains,
'subdomains_limit' => $request->sub_domains,
'email_limit' => $request->email,
'ftp_limit' => $request->ftp,
'db__limit' => $request->db
]);
Cache::forget('all_shared');
Home::homePageCacheForget();
return redirect()->route('shared.index')
->with('success', 'Shared hosting created Successfully.');
}
public function show(Shared $shared)
{
$shared = Shared::sharedHosting($shared->id);
return view('shared.show', compact(['shared']));
}
public function edit(Shared $shared)
{
$shared = Shared::sharedHosting($shared->id);
return view('shared.edit', compact(['shared']));
}
public function update(Request $request, Shared $shared)
{
$request->validate([
'domain' => 'required|min:4',
'shared_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$shared->update([
'main_domain' => $request->domain,
'shared_type' => $request->shared_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,
'was_promo' => $request->was_promo,
'domains_limit' => $request->domains,
'subdomains_limit' => $request->sub_domains,
'email_limit' => $request->email,
'ftp_limit' => $request->ftp,
'db_limit' => $request->db
]);
$pricing = new Pricing();
$pricing->updatePricing($shared->id, $request->currency, $request->price, $request->payment_term, $request->next_due_date);
Labels::deleteLabelsAssignedTo($shared->id);
Labels::insertLabelsAssigned([$request->label1, $request->label2, $request->label3, $request->label4], $shared->id);
Cache::forget("labels_for_service.{$shared->id}");
IPs::deleteIPsAssignedTo($shared->id);
if (isset($request->dedicated_ip)) {
IPs::insertIP($shared->id, $request->dedicated_ip);
}
Cache::forget("shared_hosting.{$shared->id}");
Cache::forget('all_shared');
Home::homePageCacheForget();
return redirect()->route('shared.index')
->with('success', 'Shared hosting updated Successfully.');
}
public function destroy(Shared $shared)
{
if ($shared->delete()) {
$p = new Pricing();
$p->deletePricing($shared->id);
Labels::deleteLabelsAssignedTo($shared->id);
IPs::deleteIPsAssignedTo($shared->id);
Cache::forget("shared_hosting.$shared->id");
Cache::forget('all_shared');
Home::homePageCacheForget();
return redirect()->route('shared.index')
->with('success', 'Shared hosting was deleted Successfully.');
}
return redirect()->route('shared.index')
->with('error', 'Shared was not deleted.');
}
}

View file

@ -1,77 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\Server;
use App\Models\Yabs;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class YabsController extends Controller
{
public function index()
{
return view('yabs.index', ['yabs' => Yabs::allYabs()]);
}
public function show(Yabs $yab)
{
return view('yabs.show', ['yabs' => Yabs::yabs($yab->id)]);
}
public function destroy(Yabs $yab)
{
if ($yab->delete()) {
if (Server::serverYabsAmount($yab->server_id) === 0) {
DB::table('servers')
->where('id', $yab->server_id)
->update(['has_yabs' => 0]);
}
Cache::forget('all_yabs');
Cache::forget("yabs.{$yab->id}");
return redirect()->route('yabs.index')
->with('success', 'YABS was deleted Successfully.');
}
return redirect()->route('yabs.index')
->with('error', 'YABS was not deleted.');
}
public function chooseYabsCompare()
{
$all_yabs = Yabs::allYabs();
if (isset($all_yabs[1])) {
return view('yabs.choose-compare', compact('all_yabs'));
}
return redirect()->route('yabs.index')
->with('error', 'You need atleast 2 YABS to do a compare');
}
public function compareYabs(string $yabs1, string $yabs2)
{
$yabs1_data = Yabs::yabs($yabs1);
if (is_null($yabs1_data)) {
abort(404);
}
$yabs2_data = Yabs::yabs($yabs2);
if (is_null($yabs2_data)) {
abort(404);
}
return view('yabs.compare', compact('yabs1_data', 'yabs2_data'));
}
public function yabsToJson(Yabs $yab): array
{
$all_yabs = Yabs::yabs($yab->id)[0];
return Yabs::buildYabsArray($all_yabs);
}
}

View file

@ -1,71 +0,0 @@
<?php
namespace App\Http;
use App\Console\Commands\CreateDatabaseCommand;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
protected $commands = [
CreateDatabaseCommand::class
];
}

View file

@ -1,21 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View file

@ -1,17 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -1,17 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -1,32 +0,0 @@
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null ...$guards
* @return mixed
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}

View file

@ -1,18 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View file

@ -1,20 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View file

@ -1,28 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string|null
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

View file

@ -1,17 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -1,93 +0,0 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function authenticate()
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => __('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function ensureIsNotRateLimited()
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*
* @return string
*/
public function throttleKey()
{
return Str::lower($this->input('email')).'|'.$this->ip();
}
}

View file

@ -1,34 +0,0 @@
<?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 DNS extends Model
{
use HasFactory;
public $incrementing = false;
protected $keyType = 'string';
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 function dnsCount()
{
return Cache::remember('dns_count', now()->addMonth(1), function () {
return DNS::count();
});
}
public function note(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Note::class, 'service_id', 'id');
}
}

View file

@ -1,24 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class DiskSpeed extends Model
{
use HasFactory;
public $incrementing = false;
protected $keyType = 'string';
protected $table = 'disk_speed';
protected $fillable = ['id', 'server_id', 'd_4k', 'd_4k_type', 'd_4k_as_mbps', 'd_64k', 'd_64k_type', 'd_64k_as_mbps', 'd_512k', 'd_512k_type', 'd_512k_as_mbps', 'd_1m', 'd_1m_type', 'd_1m_as_mbps'];
public function yabs(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Yabs::class, 'id', 'id');
}
}

View file

@ -1,63 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
class Domains extends Model
{
use HasFactory;
public $incrementing = false;
protected $table = 'domains';
protected $keyType = 'string';
protected $fillable = ['id', 'domain', 'extension', 'ns1', 'ns2', 'ns3', 'price', 'currency', 'payment_term', 'owned_since', 'provider_id', 'next_due_date'];
public static function allDomains()
{//All domains and relationships (no using joins)
return Cache::remember("all_domains", now()->addMonth(1), function () {
$query = Domains::with(['provider', 'price', 'labels']);
if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on'));
$query->orderBy(Pricing::select("pricings.$options[0]")->whereColumn("pricings.service_id", "domains.id"), $options[1]);
}
return $query->get();
});
}
public static function domain(string $domain_id)
{//Single domains and relationships (no using joins)
return Cache::remember("domain.$domain_id", now()->addMonth(1), function () use ($domain_id) {
return Domains::where('id', $domain_id)
->with(['provider', 'price', 'labels'])->first();
});
}
public function provider(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Providers::class, 'id', 'provider_id');
}
public function price(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Pricing::class, 'service_id', 'id');
}
public function labels(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(LabelsAssigned::class, 'service_id', 'id');
}
public function note(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Note::class, 'service_id', 'id');
}
}

View file

@ -1,210 +0,0 @@
<?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(): 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_pricing');//All the pricing
Cache::forget('services_count_all');
Cache::forget('pricing_breakdown');
}
public static function servicesCount()
{
return Cache::remember('services_count', now()->addHours(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()->addHours(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()->addHours(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()->addHours(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;
$server_due_date_changed = false;
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;
if ($service->service_type === 1) {
$server_due_date_changed = true;
Server::serverSpecificCacheForget($service->service_id);
}
} else {
break;//Break because if this date isnt past than the ones after it in the loop wont be either
}
$count++;
}
if ($server_due_date_changed) {
Server::serverRelatedCacheForget();
}
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);
return Cache::remember('pricing_breakdown', now()->addWeek(1), function () use ($pricing) {
$total_cost_weekly = $total_cost_pm = $inactive_count = 0;
foreach ($pricing as $price) {
if ($price['active'] === 1) {
if (Session::get('dashboard_currency') !== 'USD') {
$the_price = Pricing::convertFromUSD($price['as_usd'], Session::get('dashboard_currency'));
} else {
$the_price = $price['as_usd'];
}
if ($price['term'] === 1) {//1 month
$total_cost_weekly += ($the_price / 4);
$total_cost_pm += $the_price;
} elseif ($price['term'] === 2) {//3 months
$total_cost_weekly += ($the_price / 12);
$total_cost_pm += ($the_price / 3);
} elseif ($price['term'] === 3) {// 6 month
$total_cost_weekly += ($the_price / 24);
$total_cost_pm += ($the_price / 6);
} elseif ($price['term'] === 4) {// 1 year
$total_cost_weekly += ($the_price / 48);
$total_cost_pm += ($the_price / 12);
} elseif ($price['term'] === 5) {//2 years
$total_cost_weekly += ($the_price / 96);
$total_cost_pm += ($the_price / 24);
} elseif ($price['term'] === 6) {//3 years
$total_cost_weekly += ($the_price / 144);
$total_cost_pm += ($the_price / 36);
}
} else {
$inactive_count++;
}
}
$total_cost_yearly = ($total_cost_pm * 12);
return array(
'total_cost_weekly' => $total_cost_weekly,
'total_cost_monthly' => $total_cost_pm,
'total_cost_yearly' => $total_cost_yearly,
'inactive_count' => $inactive_count,
);
});
}
public static function doServicesCount($services_count): array
{
$services_count = json_decode($services_count, true);
return Cache::remember('services_count_all', now()->addWeek(1), function () use ($services_count) {
$servers_count = $domains_count = $shared_count = $reseller_count = $other_count = $seedbox_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'];
} 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

@ -1,81 +0,0 @@
<?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;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
class IPs extends Model
{
use HasFactory;
public $table = 'ips';
protected $keyType = 'string';
protected $fillable = ['id', 'service_id', 'address', 'is_ipv4', 'active', 'continent', 'country', 'region', 'city', 'org', 'isp', 'asn', 'timezone_gmt', 'fetched_at'];
public $incrementing = false;
public static function deleteIPsAssignedTo($service_id): void
{
DB::table('ips')->where('service_id', $service_id)->delete();
}
public static function insertIP(string $service_id, string $address): IPs
{
return 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()->addHours(1), function () use ($server_id) {
return json_decode(DB::table('ips as i')
->where('i.service_id', $server_id)
->get(), true);
});
}
public function note(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Note::class, 'service_id', 'id');
}
public static function getUpdateIpInfo(IPs $IP): bool
{
$response = Http::get("https://ipwhois.app/json/{$IP->address}");
if ($response->ok()) {
$data = $response->json();
$IP->update([
'continent' => $data['continent'],
'country' => $data['country'],
'region' => $data['region'],
'city' => $data['city'],
'org' => $data['org'],
'isp' => $data['isp'],
'asn' => $data['asn'],
'timezone_gmt' => $data['timezone_gmt'],
'fetched_at' => now()
]);
}
return $response->ok();
}
}

View file

@ -1,60 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Mockery\Exception;
class Labels extends Model
{
use HasFactory;
public $incrementing = false;
protected $table = 'labels';
protected $keyType = 'string';
protected $fillable = ['id', 'label', 'server_id', 'server_id_2', 'domain_id', 'domain_id_2', 'shared_id', 'shared_id_2'];
public static function deleteLabelsAssignedTo($service_id): void
{
LabelsAssigned::where('service_id', $service_id)->delete();
}
public static function deleteLabelAssignedAs($label_id): void
{
LabelsAssigned::where('label_id', $label_id)->delete();
}
public static function insertLabelsAssigned(array $labels_array, string $service_id): void
{
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
try {
LabelsAssigned::create([
'label_id' => $labels_array[($i - 1)],
'service_id' => $service_id
]);
} catch (Exception $exception) {
}
}
}
}
public static function labelsCount(): int
{
return Cache::remember('labels_count', now()->addMonth(1), function () {
return Labels::count();
});
}
public function assigned(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(LabelsAssigned::class, 'label_id', 'id');
}
}

View file

@ -1,27 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LabelsAssigned extends Model
{
use HasFactory;
public $incrementing = false;
public $timestamps = false;
public $table = 'labels_assigned';
protected $fillable = ['label_id', 'service_id'];
protected $keyType = 'string';
public function label(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Labels::class, 'id', 'label_id');
}
}

View file

@ -1,25 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class Locations extends Model
{
use HasFactory;
protected $fillable = ['name'];
protected $table = 'locations';
protected $keyType = 'string';
public static function allLocations(): array
{
return Cache::remember("locations", now()->addMonth(1), function () {
return self::orderBy('name')->get()->toArray();
});
}
}

View file

@ -1,60 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
class Misc extends Model
{
use HasFactory;
public $incrementing = false;
protected $table = 'misc_services';
protected $keyType = 'string';
protected $fillable = ['id', 'name', 'owned_since'];
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]);
}
});
}
public static function allMisc()
{//All misc and relationships (no using joins)
return Cache::remember("all_misc", now()->addMonth(1), function () {
$query = Misc::with(['price']);
if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on'));
$query->orderBy(Pricing::select("pricings.$options[0]")->whereColumn("pricings.service_id", "misc_services.id"), $options[1]);
}
return $query->get();
});
}
public static function misc(string $misc_id)
{//Single misc and relationships (no using joins)
return Cache::remember("misc.$misc_id", now()->addMonth(1), function () use ($misc_id) {
return Misc::where('id', $misc_id)
->with(['price'])->first();
});
}
public function price(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Pricing::class, 'service_id', 'id');
}
}

View file

@ -1,24 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class NetworkSpeed extends Model
{
use HasFactory;
public $incrementing = false;
protected $keyType = 'string';
protected $table = 'network_speed';
protected $fillable = ['id', 'server_id', 'location', 'send', 'send_type', 'send_as_mbps', 'receive', 'receive_type', 'receive_as_mbps', 'created_at', 'updated_at'];
public function yabs(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Yabs::class, 'id', 'id');
}
}

View file

@ -1,65 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class Note extends Model
{
use HasFactory;
public $incrementing = false;
protected $table = 'notes';
protected $keyType = 'string';
protected $fillable = ['id', 'service_id', 'note'];
public static function note(string $service_id): Note
{
return Cache::remember("note.$service_id", now()->addMonth(1), function () use ($service_id) {
return self::where('service_id', $service_id)->with(['server', 'shared', 'reseller', 'domain', 'dns', 'ip'])->first();
});
}
public static function allNotes()
{
return Cache::remember("all_notes", now()->addMonth(1), function () {
return self::with(['server', 'shared', 'reseller', 'domain', 'dns', 'ip'])->orderBy('created_at', 'desc')->get();
});
}
public function server(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Server::class, 'service_id', 'id');
}
public function shared(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Shared::class, 'service_id', 'id');
}
public function reseller(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Reseller::class, 'service_id', 'id');
}
public function domain(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Domains::class, 'service_id', 'id');
}
public function dns(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(DNS::class, 'service_id', 'id');
}
public function ip(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(IPs::class, 'service_id', 'id');
}
}

View file

@ -1,25 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class OS extends Model
{
use HasFactory;
protected $fillable = ['name'];
protected $keyType = 'string';
protected $table = 'os';
public static function allOS()
{
return Cache::remember("operating_systems", now()->addMonth(1), function () {
return self::orderBy('name')->get();
});
}
}

View file

@ -1,151 +0,0 @@
<?php
namespace App\Models;
use Exception;
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\Log;
class Pricing extends Model
{
use HasFactory;
protected $table = 'pricings';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = ['service_id', 'service_type', 'currency', 'price', 'term', 'as_usd', 'usd_per_month', 'next_due_date'];
private static function refreshRates(): object
{
if (Cache::has("currency_rates")) {
return Cache::get("currency_rates");
}
$response_json = file_get_contents("https://open.er-api.com/v6/latest/USD");
if (false === $response_json) {
Log::error("do file_get_contents failed");
return (object)null;
}
try {
$response = json_decode($response_json);
if ('success' === $response->result) {
return Cache::remember("currency_rates", now()->addWeek(1), function () use ($response) {
return $response->rates;
});
}
Log::error("server response is " . $response->result . ", expecting success");
} catch (Exception $e) {
Log::error("failed to request v6.exchangerate-api.com", ['err' => $e]);
}
return (object)null;
}
private static function getRates($currency): float
{
$rate = self::refreshRates()->$currency;
return $rate ?? 1.00;
}
public static function getCurrencyList(): array
{
return array_keys((array)self::refreshRates());
}
public static function convertFromUSD(string $amount, string $convert_to): float
{
return $amount * self::getRates($convert_to);
}
public function convertToUSD(string $amount, string $convert_from): float
{
return $amount / self::getRates($convert_from);
}
public function costAsPerMonth(string $cost, int $term): float
{
if ($term === 1) {
return $cost;
} elseif ($term === 2) {
return ($cost / 3);
} elseif ($term === 3) {
return ($cost / 6);
} elseif ($term === 4) {
return ($cost / 12);
} elseif ($term === 5) {
return ($cost / 24);
} elseif ($term === 6) {
return ($cost / 36);
} else {
return $cost;
}
}
public function termAsMonths(int $term): int
{
if ($term === 1) {
return 1;
} elseif ($term === 2) {
return 3;
} elseif ($term === 3) {
return 6;
} elseif ($term === 4) {
return 12;
} elseif ($term === 5) {
return 24;
} elseif ($term === 6) {
return 36;
} else {
return 62;
}
}
public function deletePricing($id): void
{
DB::table('pricings')->where('service_id', $id)->delete();
}
public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, string $next_due_date, int $is_active = 1): Pricing
{
$as_usd = $this->convertToUSD($price, $currency);
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
]);
}
public function updatePricing(string $service_id, string $currency, float $price, int $term, string $next_due_date, int $is_active = 1): int
{
$as_usd = $this->convertToUSD($price, $currency);
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
]);
}
public static function allPricing()
{
return Cache::remember('all_active_pricing', now()->addWeek(1), function () {
return Pricing::where('active', 1)->get();
});
}
}

View file

@ -1,46 +0,0 @@
<?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 Providers extends Model
{
use HasFactory;
protected $fillable = ['name'];
protected $keyType = 'string';
protected $table = 'providers';
public static function allProviders(): array
{
return Cache::remember("providers", now()->addMonth(1), function () {
return self::orderBy('name')->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

@ -1,86 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
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 Reseller extends Model
{
use HasFactory;
protected $table = 'reseller_hosting';
protected $keyType = 'string';
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;
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]);
}
});
}
public static function allResellerHosting()
{//All reseller hosting and relationships (no using joins)
return Cache::remember("all_reseller", now()->addMonth(1), function () {
$query = Reseller::with(['location', 'provider', 'price', 'ips', 'labels']);
if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on'));
$query->orderBy(Pricing::select("pricings.$options[0]")->whereColumn("pricings.service_id", "reseller_hosting.id"), $options[1]);
}
return $query->get();
});
}
public static function resellerHosting(string $reseller_id)
{//Single reseller hosting and relationships (no using joins)
return Cache::remember("reseller_hosting.$reseller_id", now()->addMonth(1), function () use ($reseller_id) {
return Reseller::where('id', $reseller_id)
->with(['location', 'provider', 'price', 'ips', 'labels'])->first();
});
}
public function ips(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(IPs::class, 'service_id', 'id');
}
public function location(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Locations::class, 'id', 'location_id');
}
public function provider(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Providers::class, 'id', 'provider_id');
}
public function price(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Pricing::class, 'service_id', 'id');
}
public function labels(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(LabelsAssigned::class, 'service_id', 'id');
}
public function note(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Note::class, 'service_id', 'id');
}
}

View file

@ -1,75 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
class SeedBoxes extends Model
{
use HasFactory;
protected $table = 'seedboxes';
protected $keyType = 'string';
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'];
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]);
}
});
}
public static function allSeedboxes()
{//All seedboxes and relationships (no using joins)
return Cache::remember("all_seedboxes", now()->addMonth(1), function () {
$query = SeedBoxes::with(['location', 'provider', 'price']);
if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on'));
$query->orderBy(Pricing::select("pricings.$options[0]")->whereColumn("pricings.service_id", "seedboxes.id"), $options[1]);
}
return $query->get();
});
}
public static function seedbox(string $seedbox_id)
{//Single seedbox and relationships (no using joins)
return Cache::remember("seedbox.$seedbox_id", now()->addMonth(1), function () use ($seedbox_id) {
return SeedBoxes::where('id', $seedbox_id)
->with(['location', 'provider', 'price'])->first();
});
}
public function location(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Locations::class, 'id', 'location_id');
}
public function provider(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Providers::class, 'id', 'provider_id');
}
public function price(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Pricing::class, 'service_id', 'id');
}
public function labels(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(LabelsAssigned::class, 'service_id', 'id');
}
}

View file

@ -1,239 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
use Illuminate\Database\Eloquent\Builder;
class Server extends Model
{
use HasFactory;
protected $table = 'servers';
protected $keyType = 'string';
public $incrementing = false;
protected $fillable = ['id', 'hostname', 'ipv4', 'ipv6', 'server_type', 'os_id', 'location_id', 'provider_id',
'ram', 'disk', 'ram_type', 'disk_type', 'ns1', 'ns2', 'label', 'bandwidth', 'ram_as_mb', 'disk_as_gb',
'has_yabs', 'was_promo', 'owned_since', 'ssh', 'active', 'show_public', 'cpu'];
/**
* @var mixed
*/
private $id;
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]);
}
});
}
public static function allServers()
{//All servers and relationships (no using joins)
return Cache::remember("all_servers", now()->addMonth(1), function () {
$query = Server::with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels']);
if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on'));
$query->orderBy(Pricing::select("pricings.$options[0]")->whereColumn("pricings.service_id", "servers.id"), $options[1]);
}
return $query->get();
});
}
public static function server(string $server_id): Server
{//Single server and relationships (no using joins)
return Cache::remember("server.$server_id", now()->addMonth(1), function () use ($server_id) {
return Server::where('id', $server_id)
->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels'])->first();
});
}
public static function allActiveServers()
{//All ACTIVE servers and relationships replaces activeServersDataIndexPage()
return Cache::remember("all_active_servers", now()->addMonth(1), function () {
$query = Server::where('active', 1)
->with(['location', 'provider', 'os', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels', 'price']);
if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on'));
$query->orderBy(Pricing::select("pricings.$options[0]")->whereColumn("pricings.service_id", "servers.id"), $options[1]);
}
return $query->get();
});
}
public static function allNonActiveServers()
{//All NON ACTIVE servers and relationships replaces nonActiveServersDataIndexPage()
return Cache::remember("non_active_servers", now()->addMonth(1), function () {
return Server::where('active', 0)
->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels'])
->get();
});
}
public static function allPublicServers()
{//server data that will be publicly viewable (values in settings)
return Cache::remember("public_server_data", now()->addMonth(1), function () {
return Server::where('show_public', 1)
->with(['location', 'provider', 'os', 'price', 'ips', 'yabs', 'yabs.disk_speed', 'yabs.network_speed', 'labels'])
->get();
});
}
public static function serviceServerType(int $type, bool $short = true): string
{
if ($type === 1) {
return "KVM";
} elseif ($type === 2) {
return "OVZ";
} elseif ($type === 3) {
if (!$short) {
return "Dedicated";
}
return "DEDI";
} elseif ($type === 4) {
return "LXC";
} elseif ($type === 6) {
return "VMware";
} elseif ($type === 7) {
return "NAT";
} else {
if (!$short) {
return "Semi-dedicated";
}
return "SEMI-DEDI";
}
}
public static function osIntToIcon(int $os, string $os_name): string
{
if ($os === 1) {//None
return "<i class='fas fa-expand' title='{$os_name}'></i>";
} else if ($os <= 3) {//Centos
return "<i class='fa-brands fa-centos os-icon' title='{$os_name}'></i>";
} elseif (($os > 7 && $os <= 10) || $os === 44) {//Debian
return "<i class='fa-brands fa-linux os-icon' title='{$os_name}'></i>";
} elseif (($os > 11 && $os < 15) || $os === 43) {//Fedora
return "<i class='fa-brands fa-fedora os-icon' title='{$os_name}'></i>";
} elseif (($os > 14 && $os < 18) || $os === 46) {//FreeBSD
return "<i class='fa-brands fa-linux os-icon' title='{$os_name}'></i>";
} elseif (($os > 17 && $os < 21) || $os === 42) {//OpenBSD
return "<i class='fa-brands fa-linux os-icon' title='{$os_name}'></i>";
} elseif (($os > 25 && $os < 32) || $os === 41) {//Ubuntu
return "<i class='fa-brands fa-ubuntu os-icon' title='{$os_name}'></i>";
} elseif (($os > 32 && $os < 38) || $os === 40) {//Windows
return "<i class='fa-brands fa-windows os-icon' title='{$os_name}'></i>";
} else {//OTHER ISO CUSTOM etc
return "<i class='fa-solid fa-compact-disc os-icon' title='{$os_name}'></i>";
}
}
public static function tableRowCompare(string $val1, string $val2, string $value_type = '', bool $is_int = true): string
{
//<td class="td-nowrap plus-td">+303<span class="data-type">MBps</span></td>
$str = '<td class="td-nowrap ';
$value_append = '<span class="data-type">' . $value_type . '</span>';
if ($is_int) {
$val1 = (int)$val1;
$val2 = (int)$val2;
}
if ($val1 > $val2) {//val1 is greater than val2
$result = '+' . ($val1 - $val2);
if (!empty($value_type)) {
$result = '+' . ($val1 - $val2) . $value_append;
}
$str .= 'plus-td">' . $result . '</td>';
} elseif ($val1 < $val2) {//val1 is less than val2
$result = '-' . ($val2 - $val1);
if (!empty($value_type)) {
$result = '-' . ($val2 - $val1) . $value_append;
}
$str .= 'neg-td">' . $result . '</td>';
} else {//Equal
$result = 0;
if (!empty($value_type)) {
$result = '0' . $value_append;
}
$str .= 'equal-td">' . $result . '</td>';
}
return $str;
}
public static function serverRelatedCacheForget(): void
{
Cache::forget('all_servers');//All servers
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 active servers cache
Cache::forget('non_active_servers');//all non active servers cache
Cache::forget('servers_summary');//servers summary cache
Cache::forget('public_server_data');//public servers
Cache::forget('all_pricing');//All pricing
Cache::forget('services_count_all');
Cache::forget('pricing_breakdown');
Cache::forget('all_active_pricing');
}
public static function serverSpecificCacheForget(string $server_id): void
{
Cache::forget("server.$server_id");//Will replace one below
Cache::forget("service_pricing.$server_id");//Pricing
}
public static function serverYabsAmount(string $server_id): int
{//Returns amount of YABS a server has
return Yabs::where('server_id', $server_id)->count();
}
public function yabs(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(Yabs::class, 'server_id', 'id');
}
public function ips(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(IPs::class, 'service_id', 'id');
}
public function location(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Locations::class, 'id', 'location_id');
}
public function provider(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Providers::class, 'id', 'provider_id');
}
public function os(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(OS::class, 'id', 'os_id');
}
public function price(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Pricing::class, 'service_id', 'id');
}
public function labels(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(LabelsAssigned::class, 'service_id', 'id');
}
public function note(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Note::class, 'service_id', 'id');
}
}

View file

@ -1,77 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
class Settings extends Model
{
use HasFactory;
protected $table = 'settings';
protected $fillable = ['id', 'show_versions_footer', 'show_servers_public', 'show_server_value_ip', 'show_server_value_hostname', 'show_server_value_provider', 'show_server_value_location', 'show_server_value_price', 'show_server_value_yabs', 'save_yabs_as_txt', 'default_currency', 'default_server_os', 'due_soon_amount', 'recently_added_amount', 'dark_mode', 'dashboard_currency', 'sort_on', 'favicon'];
public static function getSettings(): Settings
{
return Cache::remember('settings', now()->addWeek(1), function () {
$settings = self::where('id', 1)->first();
if (is_null($settings)){
$settings = Settings::create();
}
return $settings;
});
}
public static function setSettingsToSession($settings): void
{
Session::put('dark_mode', $settings->dark_mode ?? 0);
Session::put('timer_version_footer', $settings->show_versions_footer ?? 1);
Session::put('show_servers_public', $settings->show_servers_public ?? 0);
Session::put('show_server_value_ip', $settings->show_server_value_ip ?? 0);
Session::put('show_server_value_hostname', $settings->show_server_value_hostname ?? 0);
Session::put('show_server_value_price', $settings->show_server_value_price ?? 0);
Session::put('show_server_value_yabs', $settings->show_server_value_yabs ?? 0);
Session::put('show_server_value_provider', $settings->show_server_value_provider ?? 0);
Session::put('show_server_value_location', $settings->show_server_value_location ?? 0);
Session::put('save_yabs_as_txt', $settings->save_yabs_as_txt ?? 0);
Session::put('default_currency', $settings->default_currency ?? 'USD');
Session::put('default_server_os', $settings->default_server_os ?? 1);
Session::put('due_soon_amount', $settings->due_soon_amount ?? 6);
Session::put('recently_added_amount', $settings->recently_added_amount ?? 6);
Session::put('dashboard_currency', $settings->dashboard_currency ?? 'USD');
Session::put('sort_on', $settings->sort_on ?? 1);
Session::put('favicon', $settings->favicon ?? 'favicon.ico');
Session::save();
}
public static function orderByProcess(int $value): array
{
if ($value === 1) {//created_at ASC
return ['created_at', 'asc'];
} elseif ($value === 2) {//created_at DESC
return ['created_at', 'desc'];
} elseif ($value === 3) {//next_due_date ASC
return ['next_due_date', 'asc'];
} elseif ($value === 4) {//next_due_date DESC
return ['next_due_date', 'desc'];
} elseif ($value === 5) {//as_usd ASC
return ['as_usd', 'asc'];
} elseif ($value === 6) {//as_usd DESC
return ['as_usd', 'desc'];
} elseif ($value === 7) {//owned_since ASC
return ['owned_since', 'asc'];
} elseif ($value === 8) {//owned_since DESC
return ['owned_since', 'desc'];
} elseif ($value === 9) {//updated_at ASC
return ['updated_at', 'asc'];
} elseif ($value === 10) {//updated_at DESC
return ['updated_at', 'desc'];
}
return ['created_at', 'desc'];
}
}

View file

@ -1,85 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Session;
class Shared extends Model
{
use HasFactory;
public $table = 'shared_hosting';
protected $keyType = 'string';
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;
protected static function boot()
{
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$array = Settings::orderByProcess(Session::get('sort_on') ?? 2);//created_at desc if not set
if (!in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$builder->orderBy($array[0], $array[1]);
}
});
}
public static function allSharedHosting()
{//All shared hosting and relationships (no using joins)
return Cache::remember("all_shared", now()->addMonth(1), function () {
$query = Shared::with(['location', 'provider', 'price', 'ips', 'labels']);
if (in_array(Session::get('sort_on'), [3, 4, 5, 6], true)) {
$options = Settings::orderByProcess(Session::get('sort_on'));
$query->orderBy(Pricing::select("pricings.$options[0]")->whereColumn("pricings.service_id", "shared_hosting.id"), $options[1]);
}
return $query->get();
});
}
public static function sharedHosting(string $shared_id)
{//Single shared hosting and relationships (no using joins)
return Cache::remember("shared_hosting.$shared_id", now()->addMonth(1), function () use ($shared_id) {
return Shared::where('id', $shared_id)
->with(['location', 'provider', 'price', 'ips', 'labels'])->first();
});
}
public function ips(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(IPs::class, 'service_id', 'id');
}
public function location(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Locations::class, 'id', 'location_id');
}
public function provider(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Providers::class, 'id', 'provider_id');
}
public function price(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Pricing::class, 'service_id', 'id');
}
public function labels(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(LabelsAssigned::class, 'service_id', 'id');
}
public function note(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Note::class, 'service_id', 'id');
}
}

View file

@ -1,44 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
'api_token'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}

View file

@ -1,337 +0,0 @@
<?php
namespace App\Models;
use DateTime;
use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class Yabs extends Model
{
use HasFactory;
public $incrementing = false;
protected $keyType = 'string';
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', 'gb6_single', 'gb6_multi', 'gb6_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', 'uptime', 'distro', 'kernel', 'swap', 'swap_type', 'swap_mb'];
public static function yabs(string $yabs_id)
{
return Cache::remember("yabs.$yabs_id", now()->addMonth(1), function () use ($yabs_id) {
return self::where('id', $yabs_id)->with(['server', 'disk_speed', 'network_speed', 'server.location', 'server.provider'])
->first();
});
}
public static function allYabs()
{
return Cache::remember("all_yabs", now()->addMonth(1), function () {
return self::with(['server', 'disk_speed', 'network_speed', 'server.location', 'server.provider'])
->get();
});
}
public function server(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(Server::class, 'id', 'server_id');
}
public function disk_speed(): \Illuminate\Database\Eloquent\Relations\HasOne
{
return $this->hasOne(DiskSpeed::class, 'id', 'id');
}
public function network_speed(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(NetworkSpeed::class, 'id', 'id');
}
public static function buildYabsArray($data): array
{
$speed_tests = [];
foreach ($data->network_speed as $ns) {
$speed_tests[] = [
'location' => $ns->location,
'send' => $ns->send . ' ' . $ns->send_type,
'receive' => $ns->receive . ' ' . $ns->receive_type,
];
}
return [
'date_time' => $data->output_date,
'location' => $data->server->location->name,
'provider' => $data->server->provider->name,
'uptime' => $data->uptime,
'distro' => $data->distro,
'kernel' => $data->kernel,
'cpu' => [
'cores' => $data->cpu_cores,
'speed_mhz' => $data->cpu_freq,
'model' => $data->cpu_model,
'aes' => $data->aes === 1,
'vm' => $data->vm === 1,
'GB5_single' => $data->gb5_single,
'GB5_multi' => $data->gb5_multi,
],
'ram' => [
'amount' => $data->ram . ' ' . $data->ram_type,
'mb' => $data->ram_mb,
'swap' => [
'amount' => $data->swap ?? null . ' ' . $data->swap_type ?? null,
'mb' => $data->swap_mb ?? null,
],
],
'disk' => [
'amount' => $data->disk . ' ' . $data->disk_type,
'gb' => $data->disk_gb,
'speed_tests' => [
'4k' => $data->disk_speed->d_4k . ' ' . $data->disk_speed->d_4k_type,
'64k' => $data->disk_speed->d_64k . ' ' . $data->disk_speed->d_64k_type,
'512k' => $data->disk_speed->d_512k . ' ' . $data->disk_speed->d_512k_type,
'1m' => $data->disk_speed->d_1m . ' ' . $data->disk_speed->d_1m_type,
],
],
'network' => [
'has_ipv6' => $data->has_ipv6 === 1,
'speed_tests' => $speed_tests
],
];
}
public static function speedAsMbps(string $string): float
{
$data = explode(" ", $string);
if ($data[0] === 'busy') {
return 0;
}
if ($data[1] === "Gbits/sec") {
return $data[0] * 1000;
} else if ($data[1] === "Mbits/sec") {
return $data[0];
} else {//Kbps
return $data[0] / 1000;
}
}
public static function speedType(string $string): string
{
$data = explode(" ", $string);
if ($data[0] === 'busy') {
return "MBps";
}
if ($data[1] === "Gbits/sec") {
return "GBps";
} else if ($data[1] === "Mbits/sec") {
return "MBps";
} else {//Kbps
return "KBps";
}
}
public static function speedAsFloat(string $string): float
{
$data = explode(" ", $string);
if ($data[0] === 'busy') {
return 0;
}
return (float)$data[0];
}
public static function formatRunTime(string $date): string
{
return DateTime::createFromFormat('Ymd-His', $date)->format('Y-m-d H:i:s');
}
public static function gb5IdFromURL(string $url): int
{
return str_replace("https://browser.geekbench.com/v5/cpu/", "", $url);
}
public static function gb6IdFromURL(string $url): int
{
return str_replace("https://browser.geekbench.com/v6/cpu/", "", $url);
}
public static function KBstoMBs(int $kbs): float
{
return $kbs / 1000;
}
public static function insertFromJson($data, string $server_id): bool
{
$data = (object)$data;
try {
$date_ran = self::formatRunTime($data->time);
$version = $data['version'];
$has_ipv4 = $data['net']['ipv4'];
$has_ipv6 = $data['net']['ipv6'];
//OS
$arch = $data['os']['arch'];
$distro = $data['os']['distro'];
$kernel = $data['os']['kernel'];
$uptime = $data['os']['uptime'];
//CPU
$model = $data['cpu']['model'];
$cores = $data['cpu']['cores'];
$freq = $data['cpu']['freq'];
$aes = $data['cpu']['aes'];
$virt = $data['cpu']['virt'];
//RAM Disk
$ram = $data['mem']['ram'];
$swap = $data['mem']['swap'];
$disk = $data['mem']['disk'];
$gb5_single = $gb5_multi = $gb5_id = $gb6_single = $gb6_multi = $gb6_id = null;
foreach ($data['geekbench'] as $gb) {
if ($gb['version'] === 5) {
$gb5_single = $gb['single'];
$gb5_multi = $gb['multi'];
$gb5_id = self::gb5IdFromURL($gb['url']);
} elseif ($gb['version'] === 6) {
$gb6_single = $gb['single'];
$gb6_multi = $gb['multi'];
$gb6_id = self::gb6IdFromURL($gb['url']);
}
}
$yabs_id = Str::random(8);
if ($ram > 999999) {
$ram_f = ($ram / 1024 / 1024);
$ram_type = 'GB';
} else {
$ram_f = ($ram / 1024);
$ram_type = 'MB';
}
if ($disk > 100000000) {
$disk_f = ($disk / 1024 / 1024 / 1024);
$disk_type = 'TB';
} else {
$disk_f = ($disk / 1024 / 1024);
$disk_type = 'GB';
}
self::create([
'id' => $yabs_id,
'server_id' => $server_id,
'has_ipv6' => $has_ipv6,
'aes' => $aes,
'vm' => $virt,
'distro' => $distro,
'kernel' => $kernel,
'uptime' => $uptime,
'cpu_model' => $model,
'cpu_cores' => $cores,
'cpu_freq' => (float)$freq,
'ram' => $ram_f,
'ram_type' => $ram_type,
'ram_mb' => ($ram / 1024),
'swap' => $swap / 1024,
'swap_mb' => ($swap / 1024),
'swap_type' => 'MB',
'disk' => $disk_f,
'disk_gb' => ($disk / 1024 / 1024),
'disk_type' => $disk_type,
'output_date' => $date_ran,
'gb5_single' => $gb5_single,
'gb5_multi' => $gb5_multi,
'gb5_id' => $gb5_id,
'gb6_single' => $gb6_single,
'gb6_multi' => $gb6_multi,
'gb6_id' => $gb6_id
]);
//fio
foreach ($data['fio'] as $ds) {
if ($ds['bs'] === '4k') {
$d4k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d4k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d4k_mbps = self::KBstoMBs($ds['speed_rw']);
}
if ($ds['bs'] === '64k') {
$d64k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d64k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d64k_mbps = self::KBstoMBs($ds['speed_rw']);
}
if ($ds['bs'] === '512k') {
$d512k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d512k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d512k_mbps = self::KBstoMBs($ds['speed_rw']);
}
if ($ds['bs'] === '1m') {
$d1m = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d1m_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d1m_mbps = self::KBstoMBs($ds['speed_rw']);
}
}
DiskSpeed::create([
'id' => $yabs_id,
'server_id' => $server_id,
'd_4k' => $d4k,
'd_4k_type' => $d4k_type,
'd_4k_as_mbps' => $d4k_mbps,
'd_64k' => $d64k,
'd_64k_type' => $d64k_type,
'd_64k_as_mbps' => $d64k_mbps,
'd_512k' => $d512k,
'd_512k_type' => $d512k_type,
'd_512k_as_mbps' => $d512k_mbps,
'd_1m' => $d1m,
'd_1m_type' => $d1m_type,
'd_1m_as_mbps' => $d1m_mbps
]);
//iperf
foreach ($data['iperf'] as $st) {
($has_ipv4) ? $match = 'IPv4' : $match = 'IPv6';
if ($st['mode'] === $match) {
if ($st['send'] !== "busy " || $st['recv'] !== "busy ") {
NetworkSpeed::create([
'id' => $yabs_id,
'server_id' => $server_id,
'location' => $st['loc'],
'send' => self::speedAsFloat($st['send']),
'send_type' => self::speedType($st['send']),
'send_as_mbps' => self::speedAsMbps($st['send']),
'receive' => self::speedAsFloat($st['recv']),
'receive_type' => self::speedType($st['recv']),
'receive_as_mbps' => self::speedAsMbps($st['recv'])
]);
}
}
}
//Update server
$update_server = DB::table('servers')
->where('id', $server_id)
->update([
'ram' => $ram_f,
'ram_type' => $ram_type,
'ram_as_mb' => ($ram / 1024),
'disk' => $disk_f,
'disk_as_gb' => ($disk / 1024 / 1024),
'disk_type' => $disk_type,
'cpu' => $cores,
'has_yabs' => 1
]);
Cache::forget("yabs.$yabs_id");
Cache::forget("all_yabs");
Cache::forget("server.$server_id");
Cache::forget("all_servers");
} catch (Exception $e) {//Not valid JSON
return false;
}
return true;
}
}

View file

@ -1,43 +0,0 @@
<?php
namespace App;
class Process
{
public string $start_time;
public string $end_time;
public function startTimer(): void
{
$this->start_time = microtime(true);
}
public function stopTimer(): void
{
$this->end_time = microtime(true);
}
public function getTimeTaken(): float
{//In seconds
return ($this->end_time - $this->start_time) * 100;
}
public static function paymentTermIntToString(int $term): string
{
if ($term === 1) {
return "p/m";
} elseif ($term === 2) {
return "p/qtr";
} elseif ($term === 3) {
return "p/hy";
} elseif ($term === 4) {
return "p/y";
} elseif ($term === 5) {
return "p/2y";
} elseif ($term === 6) {
return "p/3y";
} else {
return "unknown";
}
}
}

View file

@ -1,28 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
}

View file

@ -1,30 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}

View file

@ -1,21 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View file

@ -1,32 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
}

View file

@ -1,66 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
if (config('app.env') === 'production') {
\Illuminate\Support\Facades\URL::forceScheme('https');
}
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}

View file

@ -1,18 +0,0 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class AppLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('layouts.app');
}
}

View file

@ -1,19 +0,0 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class CurrencySelect extends Component
{
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.currency-select');
}
}

View file

@ -1,18 +0,0 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class GuestLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('layouts.guest');
}
}

View file

@ -1,25 +0,0 @@
<?php
namespace App\View\Components;
use App\Models\Labels;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\Component;
class LabelsSelect extends Component
{
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
$all_labels = Cache::rememberForever('all_labels', function () {
return Labels::all();
});
return view('components.labels-select', [
'labels' => $all_labels
]);
}
}

View file

@ -1,23 +0,0 @@
<?php
namespace App\View\Components;
use App\Models\Locations;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\Component;
class LocationsSelect extends Component
{
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
$all_locations = Locations::allLocations();
return view('components.locations-select', [
'locations' => $all_locations
]);
}
}

View file

@ -1,17 +0,0 @@
<?php
namespace App\View\Components;
use App\Models\OS;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\Component;
class OsSelect extends Component
{
public function render()
{
return view('components.os-select', [
'os' => OS::allOS()->toArray()
]);
}
}

View file

@ -1,28 +0,0 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class PricingSelect extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.pricing-select');
}
}

View file

@ -1,24 +0,0 @@
<?php
namespace App\View\Components;
use App\Models\Providers;
use Illuminate\Support\Facades\Cache;
use Illuminate\View\Component;
class ProvidersSelect extends Component
{
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
$all_providers = Providers::allProviders();
return view('components.providers-select', [
'providers' => $all_providers
]);
}
}

View file

@ -1,28 +0,0 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class TermSelect extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.term-select');
}
}

53
artisan
View file

@ -1,53 +0,0 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);

5
assets/css/all.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1569
assets/css/style.css Normal file

File diff suppressed because it is too large Load diff

BIN
assets/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

2
assets/js/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
assets/js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

556
assets/js/scripts.min.js vendored Normal file

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show more