88 lines
2.2 KiB
PHP
88 lines
2.2 KiB
PHP
<?php
|
|
|
|
// No Direct Access
|
|
if(!defined("IN_MYBB")){
|
|
die();
|
|
}
|
|
|
|
function swg_auth_info(){
|
|
return array(
|
|
"name" => "SWG Auth",
|
|
"description" => "Star Wars Galaxies Authentication for MyBB",
|
|
"website" => "https://tekaohswg.github.io/swg-auth-mybb.html",
|
|
"author" => "Tekaoh",
|
|
"authorsite" => "https://tekaohswg.github.io/",
|
|
"version" => "0.1",
|
|
"guid" => "",
|
|
"codename" => "swg_auth",
|
|
"compatibility" => "*"
|
|
);
|
|
}
|
|
|
|
require_once MYBB_ROOT."inc/functions_user.php";
|
|
|
|
$plugins->add_hook('misc_start', 'swg_auth_run');
|
|
|
|
function swg_auth_run(){
|
|
global $mybb;
|
|
if($mybb->get_input('action') == 'swg-auth' && isset($_POST['user_name']) && isset($_POST['user_password'])){
|
|
$userInfo = validate_password_from_username($_POST['user_name'], $_POST['user_password']);
|
|
if ($userInfo == false) {
|
|
$response['message'] = "Account does not exist or password was incorrect";
|
|
} else {
|
|
$response['message'] = "success";
|
|
}
|
|
echo json_encode($response);
|
|
}
|
|
}
|
|
|
|
function swg_auth_install(){
|
|
global $db, $mybb;
|
|
$setting_group = array(
|
|
'name' => 'swgAuthSettings',
|
|
'title' => 'SWG Auth Settings',
|
|
'description' => 'SWG Authentication Settings',
|
|
'disporder' => 5,
|
|
'isdefault' => 0
|
|
);
|
|
$gid = $db->insert_query("settinggroups", $setting_group);
|
|
$setting_array = array(
|
|
'swgAuthType' => array(
|
|
'title' => 'Auth Type',
|
|
'description' => 'Select the type of authentication that you would like to use.',
|
|
'optionscode' => 'select \n 1=webAPI',
|
|
'value' => 1,
|
|
'disporder' => 1
|
|
)
|
|
);
|
|
foreach($setting_array as $name => $setting)
|
|
{
|
|
$setting['name'] = $name;
|
|
$setting['gid'] = $gid;
|
|
$db->insert_query('settings', $setting);
|
|
}
|
|
rebuild_settings();
|
|
}
|
|
|
|
function swg_auth_is_installed(){
|
|
global $mybb;
|
|
if(isset($mybb->settings['swgAuthType'])){
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function swg_auth_uninstall(){
|
|
global $db;
|
|
$db->delete_query('settings', "name IN ('swgAuthType')");
|
|
$db->delete_query('settinggroups', "name = 'swgAuthSettings'");
|
|
rebuild_settings();
|
|
}
|
|
|
|
function swg_auth_activate(){
|
|
}
|
|
|
|
function swg_auth_deactivate(){
|
|
}
|