wiki pages first try

This commit is contained in:
2018-10-27 01:57:46 -05:00
parent 3a43361c3c
commit ca38c00ec6
12 changed files with 256 additions and 7 deletions

View File

@@ -4,6 +4,9 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Models\DokuGroupNames;
use App\Models\DokuMember;
use App\Models\DokuUser;
class WikiController extends Controller
{
@@ -17,7 +20,68 @@ class WikiController extends Controller
'password2' => 'required',
]);
$password = '';
//Check to make sure the password matches
if($request->password !== $request->password2) {
return view('/dashboard')->with('error');
} else {
$password = md5($request->password);
}
//Load the model
$user = new App\Models\DokuUser;
$member = new App\Models\DokuMember;
//make user name syntax like we want it.
$name = Auth::user()->name;
$name = strtolower($name);
$name = str_replace(' ', '_', $name);
//Add the new user to the wiki
$user->login = $name;
$user->pass = $password;
$user->name = Auth::user()->name;
$user->save();
//Get the user from the table to get the uid
$uid = DB::select('SELECT id FROM wiki_user WHERE login = ?', [$name]);
$gname = DB::select('SELECT gname FROM wiki_groupnames WHERE id = ?', [1]);
$member->uid = $uid[0]->id;
$member->gid = 1;
$member->gname = $gname[0]->gname;
$member->save();
//Return to the dashboard view
return view('/dashboard')->with('success');
}
public function displayChangePassword() {
return view('wiki.changepassword');
}
public function changePassword(Request $request) {
$this->validate($request, [
'password' => 'required',
'password2' => 'required',
]);
//Check for a valid password
$password = '';
if($request->password !== $request->password2) {
return view('/dashboard')->with('error');
} else {
$password = md5($request->password);
}
//Get a model ready for the database
$user = new App\Models\DokuUser;
//Find the username for the database through the character name in auth
$name = Auth::user()->name;
$name = strtolower($name);
$name = str_replace(' ', '_', $name);
//Update the password for the login name
DB::table('wiki_user')
->where('login', $name)
->update(['pass' => $password]);
return view('/dashboard')->with('success');
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class DokuGroupNames extends Model
{
// Table Name
protected $table = 'wiki_groupnames';
// Timestamps
public $timestamps = 'false';
}

14
app/Models/DokuMember.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class DokuMember extends Model
{
// Table Name
protected $table = 'wiki_member';
// Timestamps
public $timestamps = 'false';
}

14
app/Models/DokuUser.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class DokuUser extends Model
{
// Table Name
protected $table = 'wiki_user';
// Timestamps
public $timestamps = 'false';
}

View File

@@ -54,6 +54,21 @@ return [
'engine' => null,
],
'wiki' => [
'driver' => 'mysql',
'host' => env('WIKI_DB_HOST', '127.0.0.1'),
'port' => env('WIKI_DB_PORT', '3306'),
'database' => env('WIKI_DB_DATABASE', 'dokureg'),
'username' => env('WIKI_DB_USERNAME', 'dokureg'),
'password' => env('WIKI_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'),

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatWikiUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('wiki_user', function(Blueprint $table) {
$table->increments('id');
$table->string('login');
$table->string('password');
$table->string('name');
$table->string('mail');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schemma::dropIfExists('wiki_user');
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateWikiGroupnames extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('wiki_groupnames', function(Blueprint $table) {
$table->increments('id');
$table->string('gname');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('wiki_groupname');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateWikiMember extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('wiki_member', function(Blueprint $table) {
$table->integer('uid');
$table->integer('gid');
$table->string('groupname');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('wiki_member');
}
}

View File

@@ -0,0 +1,16 @@
@extends('layouts.b4')
@include('layouts.navbar')
@section('content')
<div class="container">
<h2>Change Wiki Password</h2>
{!! Form::open(['action' => 'WikiController@changePassword', 'method' => 'POST']) !!}
<div class="form-group col-md-6">
{{ Form::label('password', 'Password') }}
{{ Form::password('password', '',['class' => 'form-control']) }}
{{ Form::label('password2', 'Repeat Password') }}
{{ Form::password('password2', '', ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
@endsection

View File

@@ -33,5 +33,7 @@ Route::post('storeUpdateMoon', 'MoonsController@storeUpdateMoon');
//Wiki Controller display pages
Route::get('/wiki/register', 'WikiController@displayRegister');
Route::get('/wiki/changepassword', 'WikiController@displayChangePassword');
//Wiki Controller POST requests
Route::post('storeRegister', 'WikiController@storeRegister');
Route::post('changePassword', 'WikiController@changePassword');

View File

@@ -6,8 +6,11 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'App\\Config' => $baseDir . '/app/Config.php',
'App\\Config' => $baseDir . '/app/Models/Config.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\DokuGroupNames' => $baseDir . '/app/Models/DokuGroupNames.php',
'App\\DokuMember' => $baseDir . '/app/Models/DokuMember.php',
'App\\DokuUser' => $baseDir . '/app/Models/DokuUser.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php',
@@ -17,6 +20,7 @@ return array(
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\DashboardController' => $baseDir . '/app/Http/Controllers/DashboardController.php',
'App\\Http\\Controllers\\MoonsController' => $baseDir . '/app/Http/Controllers/MoonsController.php',
'App\\Http\\Controllers\\WikiController' => $baseDir . '/app/Http/Controllers/WikiController.php',
'App\\Http\\Kernel' => $baseDir . '/app/Http/Kernel.php',
'App\\Http\\Middleware\\Authenticate' => $baseDir . '/app/Http/Middleware/Authenticate.php',
'App\\Http\\Middleware\\CheckForMaintenanceMode' => $baseDir . '/app/Http/Middleware/CheckForMaintenanceMode.php',
@@ -25,9 +29,11 @@ return array(
'App\\Http\\Middleware\\TrimStrings' => $baseDir . '/app/Http/Middleware/TrimStrings.php',
'App\\Http\\Middleware\\TrustProxies' => $baseDir . '/app/Http/Middleware/TrustProxies.php',
'App\\Http\\Middleware\\VerifyCsrfToken' => $baseDir . '/app/Http/Middleware/VerifyCsrfToken.php',
'App\\ItemComposition' => $baseDir . '/app/Models/ItemComposition.php',
'App\\Library\\MoonCalc' => $baseDir . '/app/Library/MoonCalc.php',
'App\\Moon' => $baseDir . '/app/Moon.php',
'App\\Price' => $baseDir . '/app/Price.php',
'App\\Moon' => $baseDir . '/app/Models/Moon.php',
'App\\OrePrice' => $baseDir . '/app/Models/OrePrice.php',
'App\\Price' => $baseDir . '/app/Models/Price.php',
'App\\Providers\\AppServiceProvider' => $baseDir . '/app/Providers/AppServiceProvider.php',
'App\\Providers\\AuthServiceProvider' => $baseDir . '/app/Providers/AuthServiceProvider.php',
'App\\Providers\\BroadcastServiceProvider' => $baseDir . '/app/Providers/BroadcastServiceProvider.php',

View File

@@ -401,8 +401,11 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
);
public static $classMap = array (
'App\\Config' => __DIR__ . '/../..' . '/app/Config.php',
'App\\Config' => __DIR__ . '/../..' . '/app/Models/Config.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\DokuGroupNames' => __DIR__ . '/../..' . '/app/Models/DokuGroupNames.php',
'App\\DokuMember' => __DIR__ . '/../..' . '/app/Models/DokuMember.php',
'App\\DokuUser' => __DIR__ . '/../..' . '/app/Models/DokuUser.php',
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php',
@@ -412,6 +415,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\DashboardController' => __DIR__ . '/../..' . '/app/Http/Controllers/DashboardController.php',
'App\\Http\\Controllers\\MoonsController' => __DIR__ . '/../..' . '/app/Http/Controllers/MoonsController.php',
'App\\Http\\Controllers\\WikiController' => __DIR__ . '/../..' . '/app/Http/Controllers/WikiController.php',
'App\\Http\\Kernel' => __DIR__ . '/../..' . '/app/Http/Kernel.php',
'App\\Http\\Middleware\\Authenticate' => __DIR__ . '/../..' . '/app/Http/Middleware/Authenticate.php',
'App\\Http\\Middleware\\CheckForMaintenanceMode' => __DIR__ . '/../..' . '/app/Http/Middleware/CheckForMaintenanceMode.php',
@@ -420,9 +424,11 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Http\\Middleware\\TrimStrings' => __DIR__ . '/../..' . '/app/Http/Middleware/TrimStrings.php',
'App\\Http\\Middleware\\TrustProxies' => __DIR__ . '/../..' . '/app/Http/Middleware/TrustProxies.php',
'App\\Http\\Middleware\\VerifyCsrfToken' => __DIR__ . '/../..' . '/app/Http/Middleware/VerifyCsrfToken.php',
'App\\ItemComposition' => __DIR__ . '/../..' . '/app/Models/ItemComposition.php',
'App\\Library\\MoonCalc' => __DIR__ . '/../..' . '/app/Library/MoonCalc.php',
'App\\Moon' => __DIR__ . '/../..' . '/app/Moon.php',
'App\\Price' => __DIR__ . '/../..' . '/app/Price.php',
'App\\Moon' => __DIR__ . '/../..' . '/app/Models/Moon.php',
'App\\OrePrice' => __DIR__ . '/../..' . '/app/Models/OrePrice.php',
'App\\Price' => __DIR__ . '/../..' . '/app/Models/Price.php',
'App\\Providers\\AppServiceProvider' => __DIR__ . '/../..' . '/app/Providers/AppServiceProvider.php',
'App\\Providers\\AuthServiceProvider' => __DIR__ . '/../..' . '/app/Providers/AuthServiceProvider.php',
'App\\Providers\\BroadcastServiceProvider' => __DIR__ . '/../..' . '/app/Providers/BroadcastServiceProvider.php',