diff --git a/.env.example b/.env.example index 7e6b5cf18..a6ce2e431 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ +DB_CONNECTION = nntmux DB_SYSTEM = mysql DB_HOST = localhost DB_PORT = 3306 diff --git a/.gitignore b/.gitignore index ba85e71ad..4a264e1e1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ test.php *.orig /.idea/ -/app/libraries/* +/app/Libraries/* /app/resources/tmp/* /nntmux/config/settings.php /nntmux/config/ircscraper_settings.php diff --git a/.scrutinizer.yml b/.scrutinizer.yml index e4d7e83e1..e5d555256 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -94,6 +94,6 @@ coding_style: true_false_null: undefined filter: - excluded_paths: [app/libraries/*, libraries/*, libs/*, resources/*] + excluded_paths: [app/Libraries/*, libraries/*, libs/*, resources/*] tools: sensiolabs_security_checker: true diff --git a/_install/install.sh b/_install/install.sh index 23162e2a6..810797dbe 100644 --- a/_install/install.sh +++ b/_install/install.sh @@ -26,7 +26,7 @@ echo "" echo "Setting cache directory permissions for you..." sudo chown -R www-data:www-data /var/lib/php/sessions/ chmod 755 ./ -chmod -R 755 app/libraries +chmod -R 755 app/Libraries chmod -R 777 app/resources chmod -R 755 libraries chmod -R 755 resources diff --git a/app/Models/Settings.php b/app/Models/Settings.php index 62ff057a3..d4b5c7963 100644 --- a/app/Models/Settings.php +++ b/app/Models/Settings.php @@ -26,10 +26,7 @@ use App\extensions\console\Command; /** * Settings - model for settings table. * - * laravel app completely ignore the 'setting' column and only uses 'section', 'subsection', and 'name' - * for finding values/hints. - * - *@package app\models + *@package App\Models */ class Settings extends Model { diff --git a/bootstrap/app.php b/bootstrap/app.php index f2801adf6..75c38a65e 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -12,7 +12,7 @@ */ $app = new Illuminate\Foundation\Application( - realpath(__DIR__.'/../') + dirname(__DIR__) . '/' ); /* diff --git a/bootstrap/bootstrap.php b/bootstrap/bootstrap.php index ac35eff1f..884dec164 100644 --- a/bootstrap/bootstrap.php +++ b/bootstrap/bootstrap.php @@ -2,6 +2,14 @@ require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'nntmux' . DIRECTORY_SEPARATOR . 'constants.php'; require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'nntmux' . DIRECTORY_SEPARATOR . 'bootstrap.php'; +require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'nntmux.php'; + +use Dotenv\Dotenv; + +$dotenv = new Dotenv(dirname(__DIR__, 1)); +$dotenv->load(); + +define('NNTMUX_START', microtime(true)); define('NN_APP_PATH', dirname(__DIR__) . DS . 'app'); @@ -9,4 +17,4 @@ if (!defined('NN_ROOT')) { define('NN_ROOT', dirname(NN_APP_PATH, 2)); } -require_once NN_APP_PATH . DS . 'libraries' . DS . 'autoload.php'; +require_once NN_APP_PATH . DS . 'Libraries' . DS . 'autoload.php'; diff --git a/composer.json b/composer.json index b2236c90b..641143313 100755 --- a/composer.json +++ b/composer.json @@ -6,12 +6,14 @@ ], "autoload": { "files": [ - "app/libraries/laravel/framework/src/Illuminate/Support/helpers.php", + "app/Libraries/laravel/framework/src/Illuminate/Support/helpers.php", "app/Extensions/helper/helpers.php" ], "psr-4": { "nntmux\\": "nntmux/", - "App\\": "app/" + "App\\": "app/", + "App\\Http\\Controllers\\": "nntmux/Controllers", + "App\\Http\\Middleware\\": "nntmux/Middleware" }, "classmap": [ "www/pages/", @@ -33,7 +35,7 @@ "bower-asset-library": "www/themes/shared/assets" } }, - "vendor-dir": "app/libraries" + "vendor-dir": "app/Libraries" }, "description": "A Usenet Indexer", "extra": { @@ -144,6 +146,9 @@ }, "scripts": { + "post-create-project-cmd": [ + "php artisan key:generate" + ], "post-install-cmd": [ "nntmux\\build\\ComposerScripts::postInstall", "nntmux\\build\\ComposerScripts::postInstallCmd" diff --git a/config/database.php b/config/database.php index c43f8e7f1..67c30c532 100644 --- a/config/database.php +++ b/config/database.php @@ -2,132 +2,132 @@ return [ - /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | - */ + /* + |-------------------------------------------------------------------------- + | Default Database Connection Name + |-------------------------------------------------------------------------- + | + | Here you may specify which of the database connections below you wish + | to use as your default connection for all database work. Of course + | you may use many connections at once using the Database library. + | + */ - 'default' => env('DB_CONNECTION', 'nntmux'), + 'default' => env('DB_CONNECTION', 'nntmux'), - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ - 'connections' => [ + 'connections' => [ - 'sqlite' => [ - 'driver' => 'sqlite', - 'database' => env('DB_DATABASE', database_path('database.sqlite')), - 'prefix' => '', - ], + 'sqlite' => [ + 'driver' => 'sqlite', + 'database' => env('DB_DATABASE', database_path('database.sqlite')), + 'prefix' => '', + ], - 'mysql' => [ - 'driver' => 'mysql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'strict' => true, - 'engine' => null, - ], + 'mysql' => [ + 'driver' => 'mysql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'strict' => true, + 'engine' => null, + ], - 'pgsql' => [ - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - 'sslmode' => 'prefer', - ], + 'pgsql' => [ + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + 'sslmode' => 'prefer', + ], - 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - ], + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + ], 'nntmux' => [ - 'driver' => env('DB_SYSTEM', 'mysql'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_NAME', 'nntmux'), - 'username' => env('DB_USER', 'root'), - 'password' => env('DB_PASSWORD', ''), + 'driver' => env('DB_SYSTEM', 'mysql'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_NAME', 'nntmux'), + 'username' => env('DB_USER', 'root'), + 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'strict' => false -], + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'strict' => false + ], - ], + ], - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ - 'migrations' => 'migrations', + 'migrations' => 'migrations', - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer set of commands than a typical key-value systems - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer set of commands than a typical key-value systems + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ - 'redis' => [ + 'redis' => [ - 'client' => 'predis', + 'client' => 'predis', - 'default' => [ - 'host' => env('REDIS_HOST', '127.0.0.1'), - 'password' => env('REDIS_PASSWORD', null), - 'port' => env('REDIS_PORT', 6379), - 'database' => 0, - ], + 'default' => [ + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', 6379), + 'database' => 0, + ], - ], + ], ]; diff --git a/config/nntmux.php b/config/nntmux.php new file mode 100644 index 000000000..d5f6a40e3 --- /dev/null +++ b/config/nntmux.php @@ -0,0 +1,22 @@ +load(); +$capsule = new Capsule; +// Same as database configuration file of Laravel. +$capsule->addConnection([ + 'driver' => env('DB_SYSTEM'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_NAME', 'nntmux'), + 'username' => env('DB_USER', 'root'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'strict' => false +], 'default'); +$capsule->bootEloquent(); +$capsule->setAsGlobal(); \ No newline at end of file diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/nntmux/Controllers/Auth/ForgotPasswordController.php similarity index 100% rename from app/Http/Controllers/Auth/ForgotPasswordController.php rename to nntmux/Controllers/Auth/ForgotPasswordController.php diff --git a/app/Http/Controllers/Auth/LoginController.php b/nntmux/Controllers/Auth/LoginController.php similarity index 100% rename from app/Http/Controllers/Auth/LoginController.php rename to nntmux/Controllers/Auth/LoginController.php diff --git a/app/Http/Controllers/Auth/RegisterController.php b/nntmux/Controllers/Auth/RegisterController.php similarity index 100% rename from app/Http/Controllers/Auth/RegisterController.php rename to nntmux/Controllers/Auth/RegisterController.php diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/nntmux/Controllers/Auth/ResetPasswordController.php similarity index 100% rename from app/Http/Controllers/Auth/ResetPasswordController.php rename to nntmux/Controllers/Auth/ResetPasswordController.php diff --git a/app/Http/Controllers/Controller.php b/nntmux/Controllers/Controller.php similarity index 100% rename from app/Http/Controllers/Controller.php rename to nntmux/Controllers/Controller.php diff --git a/app/Http/Middleware/EncryptCookies.php b/nntmux/Middleware/EncryptCookies.php similarity index 100% rename from app/Http/Middleware/EncryptCookies.php rename to nntmux/Middleware/EncryptCookies.php diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/nntmux/Middleware/RedirectIfAuthenticated.php similarity index 100% rename from app/Http/Middleware/RedirectIfAuthenticated.php rename to nntmux/Middleware/RedirectIfAuthenticated.php diff --git a/app/Http/Middleware/TrimStrings.php b/nntmux/Middleware/TrimStrings.php similarity index 100% rename from app/Http/Middleware/TrimStrings.php rename to nntmux/Middleware/TrimStrings.php diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/nntmux/Middleware/VerifyCsrfToken.php similarity index 100% rename from app/Http/Middleware/VerifyCsrfToken.php rename to nntmux/Middleware/VerifyCsrfToken.php diff --git a/nntmux/bootstrap.php b/nntmux/bootstrap.php index a01a103f2..f5a4f68c5 100755 --- a/nntmux/bootstrap.php +++ b/nntmux/bootstrap.php @@ -18,7 +18,7 @@ * @author niel * @copyright 2016 nZEDb */ -require_once NN_ROOT . 'app/libraries/autoload.php'; +require_once NN_ROOT . 'app/Libraries/autoload.php'; use nntmux\config\Configure; use nntmux\utility\Utility;