Recent changes

This commit is contained in:
Miguel Nogueira 2020-11-02 21:44:05 +00:00
parent 06d1e0ad3f
commit 96aa01b9c6
508 changed files with 333 additions and 79 deletions

0
.editorconfig Normal file → Executable file
View File

4
.env.example Normal file → Executable file
View File

@ -7,6 +7,10 @@ APP_LOGO="https://www.raspberrypi.org/app/uploads/2020/05/Raspberry-Pi-OS-downlo
APP_SITEHOMEPAGE=""
# This can be your main homepage, other than this site itself
# Forces ssl connections even if the environment is set to "local".
# Void if env is production.
NONPROD_FORCE_SECURE=false
LOG_CHANNEL=stack
DB_CONNECTION=mysql

0
.gitattributes vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/feature_request.md vendored Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
.idea/hrm-mcserver.iml Normal file → Executable file
View File

0
.idea/laravel-plugin.xml Normal file → Executable file
View File

0
.idea/misc.xml Normal file → Executable file
View File

0
.idea/modules.xml Normal file → Executable file
View File

0
.idea/php.xml Normal file → Executable file
View File

0
.idea/phpunit.xml Normal file → Executable file
View File

0
.idea/vcs.xml Normal file → Executable file
View File

0
.phive/phars.xml Normal file → Executable file
View File

0
.styleci.yml Normal file → Executable file
View File

0
.vscode/launch.json vendored Normal file → Executable file
View File

0
CODE_OF_CONDUCT.md Normal file → Executable file
View File

0
CONTRIBUTING.md Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
Procfile Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
SECURITY.md Normal file → Executable file
View File

0
app/Application.php Normal file → Executable file
View File

0
app/Appointment.php Normal file → Executable file
View File

0
app/Ban.php Normal file → Executable file
View File

0
app/Comment.php Normal file → Executable file
View File

0
app/Console/Commands/CountVotes.php Normal file → Executable file
View File

0
app/Console/Commands/CreateUser.php Normal file → Executable file
View File

0
app/Console/Commands/Install.php Normal file → Executable file
View File

0
app/Console/Commands/MakeFile.php Normal file → Executable file
View File

0
app/Console/Commands/SetEnv.php Normal file → Executable file
View File

0
app/Console/Kernel.php Normal file → Executable file
View File

0
app/CustomFacades/IP.php Normal file → Executable file
View File

0
app/Events/ApplicationApprovedEvent.php Normal file → Executable file
View File

0
app/Events/ApplicationDeniedEvent.php Normal file → Executable file
View File

0
app/Events/NewApplicationEvent.php Normal file → Executable file
View File

0
app/Events/UserBannedEvent.php Normal file → Executable file
View File

0
app/Exceptions/Handler.php Normal file → Executable file
View File

0
app/Facades/ContextAwareValidation.php Normal file → Executable file
View File

View File

@ -0,0 +1,17 @@
<?php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class DigitalStorageHelper extends Facade
{
protected static function getFacadeAccessor()
{
return 'digitalStorageHelperFacadeRoot';
}
}

0
app/Facades/IP.php Normal file → Executable file
View File

0
app/Facades/Options.php Normal file → Executable file
View File

0
app/Facades/UUID.php Normal file → Executable file
View File

0
app/Form.php Normal file → Executable file
View File

0
app/Helpers/ContextAwareValidator.php Normal file → Executable file
View File

View File

@ -0,0 +1,107 @@
<?php declare(strict_types=1);
namespace App\Helpers;
/**
* Class DigitalStorageHelper
*
* The digital storage helper class helps you convert bytes into several other units.
* It should be used whenever you need to display a file's size in a human readable way.
*
* It's framework agnostic, meaning you can take it out of context and it'll still work; However, you'll have to instantiate it first.
* @package App\Helpers
*/
class DigitalStorageHelper
{
/**
* The digital storage value to be manipulated.
* @var $value
*/
protected $value;
/**
* Sets the digital storage value for manipulation.
*
* @param int $value The digital storage value in bytes
* @return $this The current instance
*/
public function setValue(int $value): DigitalStorageHelper
{
$this->value = $value;
return $this;
}
/**
* Converts the digital storage value to kilobytes.
*
* @return float|int
*/
public function toKilobytes(): float
{
return $this->value / 1000;
}
/**
* Converts the digital storage value to megabytes.
*
* @return float|int
*/
public function toMegabytes(): float
{
return $this->value / (1 * pow(10, 6)); // 1 times 10 to the power of 6
}
/**
* Convert the digital storage value to gigabytes. Might be an approximation
*
* @return float
*/
public function toGigabytes(): float
{
return $this->value / (1 * pow(10, 9));
}
/**
* Convert the digital storage value to terabytes.
*
* @return float
*/
public function toTerabytes(): float
{
return $this->value / (1 * pow(10, 12));
}
/**
* Format the digital storage value to one of the units: b, kb, mb, gb and tb.
* The method has been adapted to use both MiB and MB values.
*
* @param int $precision The rounding precision
* @param bool $si Use international system units. Defaults to false
* @return string The human readable digital storage value, in either, for instance, MB or MiB
* @see https://stackoverflow.com/a/2510459/11540218 StackOverflow question regarding unit conversion
* @since 7.3.23
*/
public function formatBytes($precision = 2, $si = false): string
{
$units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
if ($si)
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$bytes = max($this->value, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(($si) ? 1000 : 1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(($si) ? 1000 : 1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
}

0
app/Helpers/Options.php Normal file → Executable file
View File

0
app/Http/Controllers/ApplicationController.php Normal file → Executable file
View File

0
app/Http/Controllers/AppointmentController.php Normal file → Executable file
View File

View File

0
app/Http/Controllers/Auth/ForgotPasswordController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/LoginController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/RegisterController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/ResetPasswordController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/TwofaController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/VerificationController.php Normal file → Executable file
View File

0
app/Http/Controllers/BanController.php Normal file → Executable file
View File

0
app/Http/Controllers/CommentController.php Normal file → Executable file
View File

0
app/Http/Controllers/ContactController.php Normal file → Executable file
View File

0
app/Http/Controllers/Controller.php Normal file → Executable file
View File

0
app/Http/Controllers/DashboardController.php Normal file → Executable file
View File

0
app/Http/Controllers/DevToolsController.php Normal file → Executable file
View File

0
app/Http/Controllers/FormController.php Normal file → Executable file
View File

0
app/Http/Controllers/HomeController.php Normal file → Executable file
View File

0
app/Http/Controllers/OptionsController.php Normal file → Executable file
View File

0
app/Http/Controllers/ProfileController.php Normal file → Executable file
View File

0
app/Http/Controllers/ResponseController.php Normal file → Executable file
View File

0
app/Http/Controllers/StaffProfileController.php Normal file → Executable file
View File

0
app/Http/Controllers/TeamController.php Normal file → Executable file
View File

102
app/Http/Controllers/TeamFileController.php Normal file → Executable file
View File

@ -2,11 +2,25 @@
namespace App\Http\Controllers;
// Most of these namespaces have no effect on the code, however, they're used by IDEs so they can resolve return types and for PHPDocumentor as well
use App\TeamFile;
use Illuminate\Http\Request;
use App\Http\Requests\UploadFileRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\FileNotFoundException;
// Documentation-purpose namespaces
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class TeamFileController extends Controller
{
@ -14,7 +28,7 @@ class TeamFileController extends Controller
* Display a listing of the resource.
*
* @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\Response
* @return Application|Factory|View|Response
*/
public function index(Request $request)
{
@ -25,28 +39,45 @@ class TeamFileController extends Controller
}
return view('dashboard.teams.team-files')
->with('files', TeamFile::with('team', 'uploader')->paginate(20));
->with('files', TeamFile::with('team', 'uploader')->paginate(6));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @param UploadFileRequest $request
* @return RedirectResponse
*/
public function store(Request $request)
public function store(UploadFileRequest $request)
{
//
$upload = $request->file('file');
$file = $upload->store('uploads');
$originalFileName = $upload->getClientOriginalName();
$originalFileExtension = $upload->extension();
$originalFileSize = $upload->getSize();
$fileEntry = TeamFile::create([
'uploaded_by' => Auth::user()->id,
'team_id' => Auth::user()->currentTeam->id,
'name' => $originalFileName,
'caption' => $request->caption,
'description' => $request->description,
'fs_location' => $file,
'extension' => $originalFileExtension,
'size' => $originalFileSize
]);
if ($fileEntry && !is_bool($file))
{
$request->session()->flash('success', 'File uploaded successfully!');
return redirect()->back();
}
$request->session()->flash('error', 'There was an unknown error whilst trying to upload your file.');
return redirect()->back();
}
@ -54,7 +85,7 @@ class TeamFileController extends Controller
{
try
{
return Storage::download('uploads/' . $teamFile->name);
return Storage::download($teamFile->fs_location, $teamFile->name);
}
catch (FileNotFoundException $ex)
{
@ -64,22 +95,11 @@ class TeamFileController extends Controller
}
}
/**
* Display the specified resource.
*
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
*/
public function show(TeamFile $teamFile)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
* @return Response
*/
public function edit(TeamFile $teamFile)
{
@ -91,7 +111,7 @@ class TeamFileController extends Controller
*
* @param \Illuminate\Http\Request $request
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
* @return Response
*/
public function update(Request $request, TeamFile $teamFile)
{
@ -101,11 +121,25 @@ class TeamFileController extends Controller
/**
* Remove the specified resource from storage.
*
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
* @param Request $request
* @param \App\TeamFile $teamFile
* @return RedirectResponse
*/
public function destroy(TeamFile $teamFile)
public function destroy(Request $request, TeamFile $teamFile)
{
//
try
{
Storage::delete($teamFile->fs_location);
$teamFile->delete();
$request->session()->flash('success', 'File deleted successfully.');
}
catch (\Exception $ex)
{
$request->session()->flash('error', 'There was an error deleting the file: ' . $ex->getMessage());
}
return redirect()->back();
}
}

0
app/Http/Controllers/UserController.php Normal file → Executable file
View File

0
app/Http/Controllers/VacancyController.php Normal file → Executable file
View File

0
app/Http/Controllers/VoteController.php Normal file → Executable file
View File

0
app/Http/Kernel.php Normal file → Executable file
View File

0
app/Http/Middleware/ApplicationEligibility.php Normal file → Executable file
View File

0
app/Http/Middleware/Authenticate.php Normal file → Executable file
View File

0
app/Http/Middleware/Bancheck.php Normal file → Executable file
View File

0
app/Http/Middleware/CheckForMaintenanceMode.php Normal file → Executable file
View File

0
app/Http/Middleware/EncryptCookies.php Normal file → Executable file
View File

0
app/Http/Middleware/ForceLogoutMiddleware.php Normal file → Executable file
View File

0
app/Http/Middleware/RedirectIfAuthenticated.php Normal file → Executable file
View File

0
app/Http/Middleware/TrimStrings.php Normal file → Executable file
View File

0
app/Http/Middleware/TrustProxies.php Normal file → Executable file
View File

0
app/Http/Middleware/UsernameUUID.php Normal file → Executable file
View File

0
app/Http/Middleware/VerifyCsrfToken.php Normal file → Executable file
View File

0
app/Http/Requests/Add2FASecretRequest.php Normal file → Executable file
View File

0
app/Http/Requests/BanUserRequest.php Normal file → Executable file
View File

0
app/Http/Requests/ChangeEmailRequest.php Normal file → Executable file
View File

0
app/Http/Requests/ChangePasswordRequest.php Normal file → Executable file
View File

0
app/Http/Requests/DeleteUserRequest.php Normal file → Executable file
View File

0
app/Http/Requests/EditTeamRequest.php Normal file → Executable file
View File

0
app/Http/Requests/FlushSessionsRequest.php Normal file → Executable file
View File

0
app/Http/Requests/NewCommentRequest.php Normal file → Executable file
View File

0
app/Http/Requests/NewTeamRequest.php Normal file → Executable file
View File

0
app/Http/Requests/ProfileSave.php Normal file → Executable file
View File

0
app/Http/Requests/Remove2FASecretRequest.php Normal file → Executable file
View File

0
app/Http/Requests/SaveNotesRequest.php Normal file → Executable file
View File

0
app/Http/Requests/SearchPlayerRequest.php Normal file → Executable file
View File

0
app/Http/Requests/SendInviteRequest.php Normal file → Executable file
View File

0
app/Http/Requests/UpdateUserRequest.php Normal file → Executable file
View File

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