diff --git a/README.md b/README.md index e459e24..7d3c1ed 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # Zontreck.com -Zontreck.com Website \ No newline at end of file +Zontreck.com Website + +# OpenSim Web Interface +__________ + +1. How to set up +``` +Setting up the web interface externally is not officially supported. This was designed and built to be used integrated with zontreck.com. + +However, if you still wish to do so, you will have quite a bit of code to edit. First off, edit main.dart in libs/pages. You'll need to remove the reference to HomePage, and add a homePage attribute to MaterialApp that points to OpenSimPage() + +Next up, you'll want to edit Settings.dart, the reason is because this seeks out services.json from the Aria's Creations github. That file controls where to look for the API server. Either hardcode a return value, or upload your own somewhere + +Next, you need to edit the API Endpoint paths to point to where these files reside on your actual server. +``` + +I will be releasing a separate system based on this code in a separate repository that is intended for third party hosting as soon as this interface is completed. + +The released standalone will also be uploaded as a packaged library for dart. It will then still be included here but primarily maintained in the standalone once this happens. \ No newline at end of file diff --git a/lib/Settings.dart b/lib/Settings.dart index dcfcc6c..6831040 100644 --- a/lib/Settings.dart +++ b/lib/Settings.dart @@ -1,9 +1,10 @@ import 'package:dio/dio.dart'; import 'package:libac_flutter/nbt/impl/CompoundTag.dart'; +import 'package:libac_flutter/utils/Hashing.dart'; enum APIEndpoint { - SetupCheck(script: "SetupCheck.php", path: "/ac/home/"), - Login(script: "Login.php", path: "/ac/home/"); + SetupCheck(script: "SetupCheck.php", path: "/ac/home/supports/"), + Login(script: "Login.php", path: "/ac/home/supports/"); final String script; final String path; @@ -48,4 +49,14 @@ class Settings { API_SERVER = "${protocol}://${host}:${port}/"; } + + Future hashPSK(String PSK) async { + String hash = Hashing.md5Hash("AriasCreations"); + for (int i = 0; i < 512; i++) { + hash = Hashing.sha256Hash("${hash}:${PSK}"); + } + hash = Hashing.md5Hash(hash); + + return hash; + } } diff --git a/lib/pages/OpenSim.dart b/lib/pages/OpenSim.dart index 9a70694..48c9a10 100644 --- a/lib/pages/OpenSim.dart +++ b/lib/pages/OpenSim.dart @@ -14,13 +14,19 @@ class OpenSimPage extends StatefulWidget { class OpenSimPageState extends State { Settings settings = Settings(); + TextEditingController databaseHostController = TextEditingController(); + TextEditingController databaseUsernameController = TextEditingController(); + TextEditingController databasePasswordController = TextEditingController(); + TextEditingController databaseNameController = TextEditingController(); + TextEditingController PSKController = TextEditingController(); + @override Future didChangeDependencies() async { // Send check for setup completion var reply = await settings.dio.get(APIEndpoint.SetupCheck.getURL()); var replyJson = json.decode(reply.data); - if (replyJson['done'] as String == "true") { + if (replyJson['done'] as bool == true) { setState(() { settings.OpenSimSetupCompleted = true; }); @@ -37,16 +43,69 @@ class OpenSimPageState extends State { body: Padding( padding: EdgeInsets.all(8), child: SingleChildScrollView( - child: Column( - children: [ - settings.OpenSimSetupCompleted - ? ListTile( - title: Text("Login Required"), + child: settings.OpenSimSetupCompleted + ? Column( + children: [], + ) + : Column( + children: [ + ListTile( + title: Text("Initial Setup Required"), tileColor: Constants.TITLEBAR_COLOR, - ) - : Text("You need to set up the database") - ], - ), + ), + ListTile( + title: Text("Database Host"), + subtitle: TextField( + controller: databaseHostController, + decoration: + InputDecoration(hintText: "example.com:3306"), + ), + ), + ListTile( + title: Text("Database Username"), + subtitle: TextField( + controller: databaseUsernameController, + decoration: InputDecoration(hintText: "Username"), + ), + ), + ListTile( + title: Text("Database Password"), + subtitle: TextField( + decoration: + InputDecoration(hintText: "****", hintMaxLines: 1), + obscureText: true, + obscuringCharacter: "*", + controller: databasePasswordController, + ), + ), + ListTile( + title: Text("Database Name"), + subtitle: TextField( + decoration: + InputDecoration(hintText: "acwi", hintMaxLines: 1), + controller: databaseNameController, + ), + ), + ListTile( + title: Text("PreShared Secret"), + subtitle: TextField( + controller: PSKController, + decoration: InputDecoration( + hintText: + "Pre-Shared Key. Long text that gets hashed"), + ), + ), + ElevatedButton( + onPressed: () async { + var PSK = await settings.hashPSK(PSKController.text); + + setState(() { + PSKController.text = PSK; + }); + }, + child: Text("Submit")) + ], + ), ), ), ); diff --git a/php/Common.php b/php/Common.php index 8d53ff6..e5c647c 100644 --- a/php/Common.php +++ b/php/Common.php @@ -26,9 +26,10 @@ function rewrite_DB_conf($host, $user, $pass, $db) file_put_contents("../database.user.php", $ptl); } -require("Database.php"); if(file_exists("../database.user.php")) require("../database.user.php"); +else + require("Database.php"); session_start(); ?> \ No newline at end of file diff --git a/php/Setup.php b/php/Setup.php new file mode 100644 index 0000000..58db1f1 --- /dev/null +++ b/php/Setup.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index de3d1f8..1568eba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: cupertino_icons: ^1.0.6 libac_flutter: hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/ - version: 1.0.1 + version: 1.0.2 dio: ^5.4.3+1 shared_preferences: ^2.2.3 diff --git a/web/index.html b/web/index.html index 8861def..5092a51 100644 --- a/web/index.html +++ b/web/index.html @@ -23,7 +23,7 @@ - +