summaryrefslogtreecommitdiff
path: root/Simple-UM-Login-Admin.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-08-04 20:06:44 -0700
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-08-04 20:06:44 -0700
commitb0782a625d50c6fce4da50d5c604f5cc4f128b43 (patch)
tree5a1570d3ef160f2858e7feb8625d7dfaddecf522 /Simple-UM-Login-Admin.php
parentcc63226762c39c22340b830a4daea6d4b3a55e21 (diff)
initial fork of simple-ldap-pluginHEADsimple-um-login
Diffstat (limited to 'Simple-UM-Login-Admin.php')
-rw-r--r--Simple-UM-Login-Admin.php190
1 files changed, 190 insertions, 0 deletions
diff --git a/Simple-UM-Login-Admin.php b/Simple-UM-Login-Admin.php
new file mode 100644
index 0000000..4ca94dd
--- /dev/null
+++ b/Simple-UM-Login-Admin.php
@@ -0,0 +1,190 @@
+<html>
+<head>
+<style>
+div.simpleum_style {
+ padding: 5px;
+ background: #EBEBEB;
+ margin: 10px;
+ font-family: Calibri,Helvetica,Arial,sans-serif;
+ float: left;
+}
+div.simpleum_style_test {
+ padding: 5px;
+ margin: 0px 10px 10px 10px;
+ background: #EBEBEB;
+ font-family: Calibri,Helvetica,Arial,sans-serif;
+ float: left;
+}
+h1.banner {
+ padding 5px;
+ margin-left: 10px;
+ margin-top: 15px;
+ font-family: Calibri,Helvetica,Arial,sans-serif;
+}
+h2, h3, h4 {
+ margin: 0;
+}
+p {
+ margin-bottom: 0;
+}
+</style>
+</head>
+<?php
+//Debug
+$debug = false;
+
+//Where are we?
+$this_page = $_SERVER['PHP_SELF'].'?page='.$_GET['page'];
+
+//If this is a test, we will use this variable
+$bool_test = 0;
+
+//If admin options updated (uses hidden field)
+if ($_POST['stage'] == 'process') {
+ // Store settings
+ update_option('simpleum_url', $_POST['um_url']);
+
+ // Version 1.3
+ update_option('simpleum_login_mode',$_POST['mode']);
+ update_option('simpleum_group',$_POST['group_name']);
+ update_option('simpleum_account_type',$_POST['create_type']);
+
+ // Version 1.3.0.2
+ update_option('simpleum_security_mode',$_POST['security_mode']);
+}
+// Test credentials
+if ($_POST['stage'] == 'test') {
+ //Temporarily change security mode for test. Store old setting.
+ $temp_holder = get_option("simpleum_security_mode");
+ update_option("simpleum_security_mode", "security_high");
+
+ $test_user = wp_authenticate($_POST['test_username'],$_POST['test_password']);
+
+ // Restore security mode setting.
+ update_option("simpleum_security_mode", $temp_holder);
+
+ if ($test_user->ID > 0) {
+ $bool_test = 1;
+ } else {
+ $bool_test = 2;
+ }
+}
+// Load settings, etc
+$simpleum_url = get_option("simpleum_url");
+
+// Version 1.3
+$simpleum_login_mode = get_option("simpleum_login_mode");
+$simpleum_group = get_option("simpleum_group");
+$simpleum_account_type = get_option("simpleum_account_type");
+
+// Version 1.3.0.2
+$simpleum_security_mode = get_option("simpleum_security_mode");
+
+?>
+<body>
+ <div class="container">
+ <div class="banner"><h1 class="banner">Simple UM Login 1.4.0.5.1</h1></div>
+ <form method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>&updated=true">
+ <div class="simpleum_style">
+ <h2>Settings</h2>
+ <h3>These are rather important.</h3>
+ <label for="um_url">URL of UM installation:</label>
+ <input name="um_url" id="um_url" type="text" value="<?php echo $simpleum_url; ?>" />
+ <br />
+ <h2>Advanced</h2>
+ <h3>For the intrepid and daring among you.</h3>
+ <h4>Login mode:</h4>
+ <ul>
+ <li>
+ <input name="mode" type="radio" value="mode_normal" <?php if($simpleum_login_mode=="mode_normal"){echo "checked";}?> />
+ <label for="mode_normal">Authenticate Wordpress users against UM. I will create the accounts in wordpress myself. (default)</label>
+ </li>
+ <li>
+ <input name="mode" type="radio" value="mode_create_all" <?php if($simpleum_login_mode=="mode_create_all"){echo "checked";}?> />
+ <label for="mode_create_all">Create Wordpress account for anyone who successfully authenticates against UM.</label>
+ </li>
+ <li>
+ <input name="mode" type="radio" value="mode_create_group" <?php if($simpleul_login_mode=="mode_create_group"){echo "checked";}?> />
+ <label for="mode_create_group">Create Wordpress account for users in specified UM group:</label>
+ <input name="group_name" type="text" value="<?php echo $simpleum_group; ?>" />
+ </li>
+ </ul>
+ <h4>For latter two options, create account as:</h4>
+ <select name="create_type">
+ <option value="Administrator" <?php if($simpleum_account_type=="Administrator"){echo 'selected="selected"';}?> >Administrator</option>
+ <option value="Editor" <?php if($simpleum_account_type=="Editor"){echo 'selected="selected"';}?> >Editor</option>
+ <option value="Author" <?php if($simpleum_account_type=="Author"){echo 'selected="selected"';}?> >Author</option>
+ <option value="Contributor" <?php if($simpleum_account_type=="Contributor"){echo 'selected="selected"';}?> >Contributor</option>
+ <option value="Subscriber" <?php if($simpleum_account_type=="Subscriber"){echo 'selected="selected"';}?> >Subscriber</option>
+ </select>
+ <h4>Security mode:</h4>
+ <ul>
+ <li>
+ <input name="security_mode" type="radio" id="security_low" value="security_low" <?php if($simpleum_security_mode=="security_low"){echo "checked";}?> />
+ <label for="security_low"><strong>Low.</strong> Default mode. First attempts to login with UM password, failing that, it attempts to login using the local wordpress password. If you intend to use a mixture of local and UM accounts, leave this mode enabled.</label>
+ </li>
+ <li>
+ <input name="security_mode" type="radio" id="security_high" value="security_high" <?php if($simpleum_security_mode=="security_high"){echo "checked";}?> />
+ <label for="security_high"><strong>High.</strong>Restrict login to only UM passwords. If a wordpress username fails to authenticate against UM, login will fail. More secure.</label>
+ </li>
+ </ul>
+ <input type="hidden" name="stage" value="process" />
+ <input type="submit" name="button_submit" value="<?php _e('Update Options', 'simple-um-login') ?> &raquo;" />
+ </div>
+ </form>
+ <div class="simpleum_style_test">
+ <h2>Test Settings</h2>
+ <h3>Use this form as a limited test for those settings you saved.* This <em>will</em> test user creation and group membership. If settings don't work, use another browser to try actually logging in. (unless you'd rather get locked out)</h3>
+ <h4>*You did save them, right?</h4>
+ <form method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
+ <ul>
+ <li>
+ <label for="test_username">Username:</label>
+ <input name="test_username" id="test_username"type="text" />
+ </li>
+ <li>
+ <label for="test_password">Password:</label>
+ <input name="test_password" id="test_password" type="password" />
+ </li>
+ </ul>
+ <input type="hidden" name="stage" value="test" />
+ <input type="submit" name="button_submit" value="<?php _e('Test Settings', 'simple-um-login') ?> &raquo;" />
+ </form>
+ <div>
+ <h4>Test Results:</h4>
+ <p><?php
+if ($bool_test == 0) {
+ echo "Nothing to report yet, Mr. Fahrenheit.";
+} if ($bool_test == 1) {
+ echo "Congratulations! The test succeeded. This account is able to login.";
+} elseif ($bool_test == 2) {
+ echo "Failure. Your settings do not seem to work yet or the credentials are either wrong or have insufficient group membership.";
+ if (is_a($test_user, 'WP_Error')) {
+ echo '</p><p>'.$test_user->get_error_message();
+ }
+}
+?></p>
+ </div>
+ </div>
+ </div>
+<?php
+//Echo settings
+if($debug) { ?>
+ <div>
+ <h4>Debug Info:</h4>
+ <ul>
+ <li>simpleum_login_mode:
+ <?php echo get_option("simpleum_login_mode")."/".$_POST['mode']; ?>
+ </li>
+ <li>simpleum_group:
+ <?php echo get_option("simpleum_group")."/".$_POST['group_name']; ?>
+ </li>
+ <li>simpleum_account_type:
+ <?php echo get_option("simpleum_account_type")."/".$_POST['create_type']; ?>
+ </li>
+ </ul>
+ </div>
+<?php }
+?>
+</body>
+</html>