Apply fixes from StyleCI
This commit is contained in:
parent
a1d3bbf73d
commit
c1fb0a665f
150 changed files with 1558 additions and 1760 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,21 +21,19 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Repositories;
|
||||
|
||||
use Crypt;
|
||||
use Log;
|
||||
use DB;
|
||||
use Crypt;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
class DatabaseRepository {
|
||||
|
||||
class DatabaseRepository
|
||||
{
|
||||
/**
|
||||
* Adds a new database to a given database server.
|
||||
* @param int $server Id of the server to add a database for.
|
||||
|
@ -64,7 +62,7 @@ class DatabaseRepository {
|
|||
'database' => "s{$server->id}_{$options['database']}",
|
||||
'username' => $server->uuidShort . '_' . str_random(7),
|
||||
'remote' => $options['remote'],
|
||||
'password' => Crypt::encrypt(str_random(20))
|
||||
'password' => Crypt::encrypt(str_random(20)),
|
||||
]);
|
||||
$db->save();
|
||||
|
||||
|
@ -84,11 +82,10 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
throw new DisplayException('There was an error while connecting to the Database Host Server. Please check the error logs.', $ex);
|
||||
|
@ -128,7 +125,6 @@ class DatabaseRepository {
|
|||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
|
||||
$db->password = Crypt::encrypt($password);
|
||||
$db->save();
|
||||
|
||||
|
@ -145,7 +141,7 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
@ -157,16 +153,16 @@ class DatabaseRepository {
|
|||
));
|
||||
|
||||
DB::commit();
|
||||
} catch(\Exception $ex) {
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollback();
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops a database from the associated MySQL Server
|
||||
* Drops a database from the associated MySQL Server.
|
||||
* @param int $database The ID of the database to drop.
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function drop($database)
|
||||
{
|
||||
|
@ -189,7 +185,7 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
@ -200,12 +196,12 @@ class DatabaseRepository {
|
|||
$db->delete();
|
||||
|
||||
DB::commit();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollback();
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,7 +227,6 @@ class DatabaseRepository {
|
|||
*/
|
||||
public function add(array $data)
|
||||
{
|
||||
|
||||
if (isset($data['host'])) {
|
||||
$data['host'] = gethostbyname($data['host']);
|
||||
}
|
||||
|
@ -265,7 +260,7 @@ class DatabaseRepository {
|
|||
'prefix' => '',
|
||||
'options' => [
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
|
@ -280,8 +275,8 @@ class DatabaseRepository {
|
|||
'port' => $data['port'],
|
||||
'username' => $data['username'],
|
||||
'password' => Crypt::encrypt($data['password']),
|
||||
'max_databases' => NULL,
|
||||
'linked_node' => (!empty($data['linked_node']) && $data['linked_node'] > 0) ? $data['linked_node'] : NULL
|
||||
'max_databases' => null,
|
||||
'linked_node' => (! empty($data['linked_node']) && $data['linked_node'] > 0) ? $data['linked_node'] : null,
|
||||
]);
|
||||
$dbh->save();
|
||||
|
||||
|
@ -291,5 +286,4 @@ class DatabaseRepository {
|
|||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue