Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff96c2bce3 | ||
|
|
2ecfdb18eb | ||
|
|
7c881aaac9 | ||
|
|
c880c904d5 | ||
|
|
f515e278a7 | ||
|
|
cb61131d04 | ||
|
|
2368828f68 |
17
swg-auth/admin/admin.php
Normal file
17
swg-auth/admin/admin.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
add_action('admin_menu', 'swg_auth_menu');
|
||||
function swg_auth_menu(){
|
||||
add_menu_page(
|
||||
'SWG Auth',
|
||||
'SWG Auth',
|
||||
'administrator',
|
||||
'swg-auth-menu',
|
||||
'swg_auth_menu_html',
|
||||
'',
|
||||
3
|
||||
);
|
||||
}
|
||||
function swg_auth_menu_html(){
|
||||
include(plugin_dir_path(__FILE__) . 'swg-auth-menu-html.php');
|
||||
}
|
||||
1
swg-auth/admin/index.php
Normal file
1
swg-auth/admin/index.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php //Shh...
|
||||
16
swg-auth/admin/swg-auth-menu-html.php
Normal file
16
swg-auth/admin/swg-auth-menu-html.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<div class="wrap">
|
||||
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
||||
<p>Welcome to SWG Auth for Wordpress. Your plugin is functioning normally.</p>
|
||||
<p>To enable authentication for your SWG server, edit these lines in your server config:</p>
|
||||
<code>
|
||||
[LoginServer]<br />
|
||||
useExternalAuth=true<br />
|
||||
externalAuthURL=<?php echo get_site_url() ?>/?action=swg-auth
|
||||
</code>
|
||||
<p>Additionally, you can use this plugin to enable God Mode in game. Wordpress Administrators will also be SWG Admins. To do this, be sure you have compiled the latest version of the src and add these lines to your server config:</p>
|
||||
<code>
|
||||
[ServerUtility]<br />
|
||||
externalAdminLevelsEnabled=true<br />
|
||||
externalAdminLevelsURL=<?php echo get_site_url() ?>/?action=swg-auth-admin-level
|
||||
</code>
|
||||
</div>
|
||||
1
swg-auth/includes/index.php
Normal file
1
swg-auth/includes/index.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php //Shh...
|
||||
18
swg-auth/includes/swg-auth-admin-level-check.php
Normal file
18
swg-auth/includes/swg-auth-admin-level-check.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// Check if the swg-auth-admin-level action is requested and that a user_name is provided
|
||||
if(isset($_GET['action']) && $_GET['action'] == 'swg-auth-admin-level' && isset($_POST['user_name'])){
|
||||
// Look up the user's ID
|
||||
$userID = get_user_by('login', $_POST['user_name']);
|
||||
// Check if the user is a Wordpress Admin
|
||||
if(user_can($userID, 'administrator')){
|
||||
// If the user is a Wordpress Admin, automatically send back level 50
|
||||
$response['message'] = "50";
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
// Not an admin
|
||||
$response['message'] = "0";
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
19
swg-auth/includes/swg-auth-check.php
Normal file
19
swg-auth/includes/swg-auth-check.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
// Check if the swg-auth action is requested and that a user_name and user_password are provided
|
||||
if(isset($_GET['action']) && $_GET['action'] == 'swg-auth' && isset($_POST['user_name']) && isset($_POST['user_password'])){
|
||||
// Ask Wordpress to authenticate the user_name and user_password
|
||||
$userInfo = wp_authenticate_username_password(NULL, $_POST['user_name'], $_POST['user_password']);
|
||||
// Check if the authentication request returned an error
|
||||
if(is_wp_error($userInfo)){
|
||||
// If there was an error, we'll let the client know.
|
||||
$response['message'] = "Account does not exist or password was incorrect";
|
||||
} else {
|
||||
// If there's no error, Success!
|
||||
$response['message'] = "success";
|
||||
}
|
||||
// Json encode our response so that the LoginServer knows what we're talking about
|
||||
echo json_encode($response);
|
||||
// Once we've responded, we don't want Wordpress to continue
|
||||
die;
|
||||
}
|
||||
1
swg-auth/index.php
Normal file
1
swg-auth/index.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php //Shh...
|
||||
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: SWG Auth
|
||||
* Plugin URI: https://tekaohswg.github.io/swg-auth-wordpress.html
|
||||
* Description: Star Wars Galaxies Authentication for Wordpress
|
||||
* Version: 0.2
|
||||
* Version: 0.3
|
||||
* Author: Tekaoh
|
||||
* Author URI: https://tekaohswg.github.io
|
||||
*/
|
||||
@@ -15,49 +15,10 @@ if(!defined('ABSPATH')){
|
||||
|
||||
// Run when Wordpress is loaded
|
||||
add_action('wp_loaded', 'swg_auth_run');
|
||||
|
||||
function swg_auth_run(){
|
||||
// Check if the swg-auth action is requested
|
||||
if($_GET['action'] == 'swg-auth'){
|
||||
// Check if a user_name and user_password are provided
|
||||
if($_POST['user_name'] && $_POST['user_password']){
|
||||
// Ask Wordpress to authenticate the user_name and user_password
|
||||
$userInfo = wp_authenticate_username_password(NULL, $_POST['user_name'], $_POST['user_password']);
|
||||
// Check if the authentication request returned an error
|
||||
if(is_wp_error($userInfo)){
|
||||
// If there was an error, we'll let the client know.
|
||||
$response['message'] = "Account does not exist or password was incorrect";
|
||||
} else {
|
||||
// If there's no error, Success!
|
||||
$response['message'] = "success";
|
||||
}
|
||||
// Json encode our response so that the LoginServer knows what we're talking about
|
||||
echo json_encode($response);
|
||||
// Once we've responded, we don't want Wordpress to continue
|
||||
die;
|
||||
}
|
||||
// If we're here, the swg-auth action was requested but no user_name and user_password were provided. That's weird... Don't return anything
|
||||
die;
|
||||
}
|
||||
// Check if the swg-auth-admin-level action is requested
|
||||
if($_GET['action'] == 'swg-auth-admin-level'){
|
||||
// Check if a user_name is provided
|
||||
if($_POST['user_name']){
|
||||
// Look up the user
|
||||
$userID = get_user_by('login', $_POST['user_name']);
|
||||
// Check if the user is a Wordpress Admin
|
||||
if(user_can($userID, 'administrator')){
|
||||
// Send back level 50
|
||||
$response['message'] = "50";
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
// Not an admin
|
||||
$response['message'] = "0";
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
// If we're here, the swg-auth-admin-level action was requested by no user_name was provided. Don't return anything.
|
||||
die;
|
||||
}
|
||||
include(plugin_dir_path(__FILE__) . 'includes/swg-auth-check.php');
|
||||
include(plugin_dir_path(__FILE__) . 'includes/swg-auth-admin-level-check.php');
|
||||
}
|
||||
|
||||
// Run the admin panel stuff
|
||||
include(plugin_dir_path(__FILE__) . 'admin/admin.php');
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
=== SWG Auth ===
|
||||
Contributors: tekaoh
|
||||
Donate link: https://tekaohswg.github.io/donate.html
|
||||
Tags: admin, integration
|
||||
Requires at least: 2.8
|
||||
Tested up to: 5.4
|
||||
Stable tag: 0.2
|
||||
Stable tag: 0.3
|
||||
Requires PHP: 4.3
|
||||
License: The Unlicense
|
||||
License URI: https://unlicense.org
|
||||
@@ -13,7 +12,7 @@ Star Wars Galaxies Authentication for Wordpress
|
||||
|
||||
== Description ==
|
||||
|
||||
If you're running a Star Wars Galaxies server, now you can use Wordpress to allow users to sign up and change their passwords.
|
||||
If you're running a Star Wars Galaxies server, now you can use Wordpress to manage your users.
|
||||
|
||||
== Installation ==
|
||||
|
||||
@@ -22,23 +21,25 @@ If you're running a Star Wars Galaxies server, now you can use Wordpress to allo
|
||||
3. Point your SWG server's externalAuthURL config flag to `http://url.to.wordpress/?action=swg-auth`.
|
||||
4. Done!
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= How do I run a Star Wars Galaxies server? =
|
||||
|
||||
Check out https://swg-source.github.io/ and join that community on discord. If you'd rather build your own VM than download one, you could check out https://tekaohswg.github.io/new.html but be aware that this isn't for the faint of heart.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Once this plugin is installed, your SWG Server will authenticate users with Wordpress.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 0.3 =
|
||||
* Added an admin menu that provides you with the server cfg you need
|
||||
* Bug fixes
|
||||
|
||||
= 0.2 =
|
||||
* Wordpress can now take requests for admin level checks
|
||||
|
||||
= 0.1 =
|
||||
* Initial version
|
||||
* Authentication is functional
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 0.3 =
|
||||
* Bug fixes
|
||||
|
||||
= 0.2 =
|
||||
* New features
|
||||
|
||||
= 0.1 =
|
||||
* Initial version
|
||||
Reference in New Issue
Block a user