Files
swg-auth-mybb/swgauth.php
2020-04-10 09:18:58 -04:00

86 lines
2.1 KiB
PHP

<?php
if(!defined("IN_MYBB")){
die();
}
function swgauth_info(){
return array(
"name" => "SWG Auth",
"description" => "Star Wars Galaxies Authentication for MyBB",
"website" => "https://tekaohswg.github.io/",
"author" => "Tekaoh",
"authorsite" => "https://tekaohswg.github.io/",
"version" => "0.1",
"guid" => "",
"codename" => "swgauth",
"compatibility" => "*"
);
}
require_once MYBB_ROOT."inc/functions_user.php";
$plugins->add_hook('misc_start', 'swgauth_run');
function swgauth_run(){
global $mybb;
if($mybb->get_input('action') == 'swgauth' && $_POST['user_name'] && $_POST['user_password']){
$userInfo = validate_password_from_username($_POST['user_name'], $_POST['user_password']);
if ($userInfo != false) {
$response['message'] = "success";
} else {
$response['message'] = "Account does not exist or password was incorrect";
}
echo json_encode($response);
}
}
function swgauth_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=SWGAuth',
'value' => 1,
'disporder' => 1
)
);
foreach($setting_array as $name => $setting)
{
$setting['name'] = $name;
$setting['gid'] = $gid;
$db->insert_query('settings', $setting);
}
rebuild_settings();
}
function swgauth_is_installed(){
global $mybb;
if(isset($mybb->settings['swgAuthType'])){
return true;
}else{
return false;
}
}
function swgauth_uninstall(){
global $db;
$db->delete_query('settings', "name IN ('swgAuthType')");
$db->delete_query('settinggroups', "name = 'swgauthsettings'");
rebuild_settings();
}
function swgauth_activate(){
}
function swgauth_deactivate(){
}