• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_enabled_auth_plugins函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_enabled_auth_plugins函数的典型用法代码示例。如果您正苦于以下问题:PHP get_enabled_auth_plugins函数的具体用法?PHP get_enabled_auth_plugins怎么用?PHP get_enabled_auth_plugins使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_enabled_auth_plugins函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: list_enabled_auth_plugins

 private function list_enabled_auth_plugins()
 {
     $plugins = get_enabled_auth_plugins();
     echo "\nList of enabled auth plugins:\n\n";
     for ($i = 0; $i < count($plugins); $i++) {
         echo $i + 1 . ". " . $plugins[$i] . "\n";
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:8,代码来源:AuthList.php


示例2: __logout

 function __logout()
 {
     $authsequence = get_enabled_auth_plugins();
     // auths, in sequence
     foreach ($authsequence as $authname) {
         $authplugin = get_auth_plugin($authname);
         $authplugin->logoutpage_hook();
     }
     require_logout();
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:10,代码来源:clinique_logout.php


示例3: execute

 public function execute()
 {
     global $CFG;
     $action = $this->arguments[0];
     $pluginname = $this->arguments[1];
     // Does the authentication module exist?
     if (!exists_auth_plugin($pluginname)) {
         print_error('pluginnotinstalled', 'auth', '', $pluginname);
     }
     // Get enabled plugins.
     $authsenabled = get_enabled_auth_plugins(true);
     if (empty($CFG->auth)) {
         $authsenabled = array();
     } else {
         $authsenabled = explode(',', $CFG->auth);
     }
     switch ($action) {
         case 'disable':
             $key = array_search($pluginname, $authsenabled);
             if ($key !== false) {
                 unset($authsenabled[$key]);
                 set_config('auth', implode(',', $authsenabled));
             }
             break;
         case 'down':
             $key = array_search($pluginname, $authsenabled);
             if ($key !== false && $key < count($authsenabled) - 1) {
                 $fsave = $authsenabled[$key];
                 $authsenabled[$key] = $authsenabled[$key + 1];
                 $authsenabled[$key + 1] = $fsave;
                 set_config('auth', implode(',', $authsenabled));
             }
         case 'enable':
             if (!in_array($pluginname, $authsenabled)) {
                 $authsenabled[] = $pluginname;
                 $authsenabled = array_unique($authsenabled);
                 set_config('auth', implode(',', $authsenabled));
             }
             break;
         case 'up':
             $key = array_search($pluginname, $authsenabled);
             if ($key !== false && $key >= 1) {
                 $fsave = $authsenabled[$key];
                 $authsenabled[$key] = $authsenabled[$key - 1];
                 $authsenabled[$key - 1] = $fsave;
                 set_config('auth', implode(',', $authsenabled));
             }
             break;
     }
     echo "Auth modules enabled: " . implode(',', $authsenabled) . "\n";
 }
开发者ID:dariogs,项目名称:moosh,代码行数:51,代码来源:AuthManage.php


示例4: __construct

 public function __construct()
 {
     global $CFG, $SESSION, $OUTPUT;
     // Get all alternative login methods and add to potentialipds array.
     $authsequence = get_enabled_auth_plugins(true);
     $potentialidps = [];
     foreach ($authsequence as $authname) {
         if (isset($SESSION->snapwantsurl)) {
             $urltogo = $SESSION->snapwantsurl;
         } else {
             $urltogo = $CFG->wwwroot . '/';
         }
         unset($SESSION->snapwantsurl);
         $authplugin = get_auth_plugin($authname);
         $potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list($urltogo));
     }
     if (!empty($potentialidps)) {
         foreach ($potentialidps as $idp) {
             $this->potentialidps[] = (object) ['url' => $idp['url']->out(), 'name' => $idp['name'], 'icon' => $OUTPUT->pix_url($idp['icon']->pix)];
         }
     }
 }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:22,代码来源:login_alternative_methods.php


示例5: optional_param

*/
require_once '../../config.php';
require_once 'lib.php';
require_once $CFG->libdir . '/adminlib.php';
$confirm = optional_param('confirm', 0, PARAM_BOOL);
require_login();
admin_externalpage_setup('userbulk');
require_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM));
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
if (empty($SESSION->bulk_users)) {
    redirect($return);
}
echo $OUTPUT->header();
if ($confirm and confirm_sesskey()) {
    // only force password change if user may actually change the password
    $authsavailable = get_enabled_auth_plugins();
    $changeable = array();
    foreach ($authsavailable as $authplugin) {
        if (!($auth = get_auth_plugin($authplugin))) {
            continue;
        }
        if ($auth->is_internal() and $auth->can_change_password()) {
            $changeable[$authplugin] = true;
        }
    }
    $parts = array_chunk($SESSION->bulk_users, 300);
    foreach ($parts as $users) {
        list($in, $params) = $DB->get_in_or_equal($users);
        if ($rs = $DB->get_recordset_select('user', "id {$in}", $params)) {
            foreach ($rs as $user) {
                if (!empty($changeable[$user->auth])) {
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:user_bulk_forcepasswordchange.php


示例6: gc

 /**
  * Periodic timed-out session cleanup.
  */
 public static function gc()
 {
     global $CFG, $DB;
     // This may take a long time...
     \core_php_time_limit::raise();
     $maxlifetime = $CFG->sessiontimeout;
     try {
         // Kill all sessions of deleted and suspended users without any hesitation.
         $rs = $DB->get_recordset_select('sessions', "userid IN (SELECT id FROM {user} WHERE deleted <> 0 OR suspended <> 0)", array(), 'id DESC', 'id, sid');
         foreach ($rs as $session) {
             self::kill_session($session->sid);
         }
         $rs->close();
         // Kill sessions of users with disabled plugins.
         $auth_sequence = get_enabled_auth_plugins(true);
         $auth_sequence = array_flip($auth_sequence);
         unset($auth_sequence['nologin']);
         // No login means user cannot login.
         $auth_sequence = array_flip($auth_sequence);
         list($notplugins, $params) = $DB->get_in_or_equal($auth_sequence, SQL_PARAMS_QM, '', false);
         $rs = $DB->get_recordset_select('sessions', "userid IN (SELECT id FROM {user} WHERE auth {$notplugins})", $params, 'id DESC', 'id, sid');
         foreach ($rs as $session) {
             self::kill_session($session->sid);
         }
         $rs->close();
         // Now get a list of time-out candidates - real users only.
         $sql = "SELECT u.*, s.sid, s.timecreated AS s_timecreated, s.timemodified AS s_timemodified\n                      FROM {user} u\n                      JOIN {sessions} s ON s.userid = u.id\n                     WHERE s.timemodified < :purgebefore AND u.id <> :guestid";
         $params = array('purgebefore' => time() - $maxlifetime, 'guestid' => $CFG->siteguest);
         $authplugins = array();
         foreach ($auth_sequence as $authname) {
             $authplugins[$authname] = get_auth_plugin($authname);
         }
         $rs = $DB->get_recordset_sql($sql, $params);
         foreach ($rs as $user) {
             foreach ($authplugins as $authplugin) {
                 /** @var \auth_plugin_base $authplugin*/
                 if ($authplugin->ignore_timeout_hook($user, $user->sid, $user->s_timecreated, $user->s_timemodified)) {
                     continue;
                 }
             }
             self::kill_session($user->sid);
         }
         $rs->close();
         // Delete expired sessions for guest user account, give them larger timeout, there is no security risk here.
         $params = array('purgebefore' => time() - $maxlifetime * 5, 'guestid' => $CFG->siteguest);
         $rs = $DB->get_recordset_select('sessions', 'userid = :guestid AND timemodified < :purgebefore', $params, 'id DESC', 'id, sid');
         foreach ($rs as $session) {
             self::kill_session($session->sid);
         }
         $rs->close();
         // Delete expired sessions for userid = 0 (not logged in), better kill them asap to release memory.
         $params = array('purgebefore' => time() - $maxlifetime);
         $rs = $DB->get_recordset_select('sessions', 'userid = 0 AND timemodified < :purgebefore', $params, 'id DESC', 'id, sid');
         foreach ($rs as $session) {
             self::kill_session($session->sid);
         }
         $rs->close();
         // Cleanup letfovers from the first browser access because it may set multiple cookies and then use only one.
         $params = array('purgebefore' => time() - 60 * 3);
         $rs = $DB->get_recordset_select('sessions', 'userid = 0 AND timemodified = timecreated AND timemodified < :purgebefore', $params, 'id ASC', 'id, sid');
         foreach ($rs as $session) {
             self::kill_session($session->sid);
         }
         $rs->close();
     } catch (\Exception $ex) {
         debugging('Error gc-ing sessions: ' . $ex->getMessage(), DEBUG_NORMAL, $ex->getTrace());
     }
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:71,代码来源:manager.php


示例7: cron_run


//.........这里部分代码省略.........
                } else {
                    trigger_error("Could not create and mail new user password!");
                }
            }
        }
        if (!empty($CFG->usetags)) {
            require_once $CFG->dirroot . '/tag/lib.php';
            tag_cron();
            mtrace('Executed tag cron');
        }
        // Accesslib stuff
        cleanup_contexts();
        mtrace('Cleaned up contexts');
        gc_cache_flags();
        mtrace('Cleaned cache flags');
        // If you suspect that the context paths are somehow corrupt
        // replace the line below with: build_context_path(true);
        build_context_path();
        mtrace('Built context paths');
        if (!empty($CFG->messagingdeletereadnotificationsdelay)) {
            $notificationdeletetime = time() - $CFG->messagingdeletereadnotificationsdelay;
            $DB->delete_records_select('message_read', 'notification=1 AND timeread<:notificationdeletetime', array('notificationdeletetime' => $notificationdeletetime));
            mtrace('Cleaned up read notifications');
        }
        mtrace("Finished clean-up tasks...");
    }
    // End of occasional clean-up tasks
    // Run automated backups if required.
    require_once $CFG->dirroot . '/backup/util/includes/backup_includes.php';
    require_once $CFG->dirroot . '/backup/util/helper/backup_cron_helper.class.php';
    backup_cron_automated_helper::run_automated_backup();
    /// Run the auth cron, if any
    /// before enrolments because it might add users that will be needed in enrol plugins
    $auths = get_enabled_auth_plugins();
    mtrace("Running auth crons if required...");
    foreach ($auths as $auth) {
        $authplugin = get_auth_plugin($auth);
        if (method_exists($authplugin, 'cron')) {
            mtrace("Running cron for auth/{$auth}...");
            $authplugin->cron();
            if (!empty($authplugin->log)) {
                mtrace($authplugin->log);
            }
        }
        unset($authplugin);
    }
    mtrace("Running enrol crons if required...");
    $enrols = enrol_get_plugins(true);
    foreach ($enrols as $ename => $enrol) {
        // do this for all plugins, disabled plugins might want to cleanup stuff such as roles
        if (!$enrol->is_cron_required()) {
            continue;
        }
        mtrace("Running cron for enrol_{$ename}...");
        $enrol->cron();
        $enrol->set_config('lastcron', time());
    }
    if (!empty($CFG->enablestats) and empty($CFG->disablestatsprocessing)) {
        require_once $CFG->dirroot . '/lib/statslib.php';
        // check we're not before our runtime
        $timetocheck = stats_get_base_daily() + $CFG->statsruntimestarthour * 60 * 60 + $CFG->statsruntimestartminute * 60;
        if (time() > $timetocheck) {
            // process configured number of days as max (defaulting to 31)
            $maxdays = empty($CFG->statsruntimedays) ? 31 : abs($CFG->statsruntimedays);
            if (stats_cron_daily($maxdays)) {
                if (stats_cron_weekly()) {
开发者ID:vuchannguyen,项目名称:web,代码行数:67,代码来源:cronlib.php


示例8: print_string

    <td><?php 
print_string("auth_saml_supportcourses_description", "auth_saml");
?>
</td>
</tr>

<tr valign="top">
    <td class="right"><?php 
print_string('auth_saml_syncusersfrom', 'auth_saml');
?>
:</td>
    <td>
        <select name="syncusersfrom">
        <option name="none" value="">Disabled</option>
        <?php 
foreach (get_enabled_auth_plugins() as $name) {
    $plugin = get_auth_plugin($name);
    if (method_exists($plugin, 'sync_users')) {
        print '<option name="' . $name . '" value ="' . $name . '" ' . ($config->syncusersfrom == $name ? 'selected="selected"' : '') . '>' . $name . '</option>';
    }
}
?>
        </select>
    </td>
    <td><?php 
print_string("auth_saml_syncusersfrom_description", "auth_saml");
?>
</td>
</tr>

<tr valign="top" class="required" id="samlcourses_tr" <?php 
开发者ID:blionut,项目名称:elearning,代码行数:31,代码来源:config.php


示例9: cm_jasper_link_enabled

/**
 * Specifies whether the CM system should link to a Jasper
 * reporting server
 *
 * @return  boolean  true if applicable, otherwise false
 */
function cm_jasper_link_enabled()
{
    $show_jasper_link = false;
    //check the necessary auth plugins
    $auths_enabled = get_enabled_auth_plugins();
    $mnet_auth_enabled = in_array('mnet', $auths_enabled);
    $elis_auth_enabled = in_array('elis', $auths_enabled);
    if ($mnet_auth_enabled && $elis_auth_enabled) {
        //check the necessary config data
        $jasper_shortname = get_config('auth/elis', 'jasper_shortname');
        $jasper_wwwroot = get_config('auth/elis', 'jasper_wwwroot');
        if ($jasper_shortname !== false && $jasper_wwwroot !== false) {
            //don't respond to bogus data
            $jasper_shortname = trim($jasper_shortname);
            $jasper_wwwroot = trim($jasper_wwwroot);
            if (strlen($jasper_shortname) > 0 && strlen($jasper_wwwroot) > 0) {
                $show_jasper_link = true;
            }
        }
    }
    return $show_jasper_link;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:28,代码来源:deprecatedlib.php


示例10: authenticate_user_login

/**
 * Authenticates a user against the chosen authentication mechanism
 *
 * Given a username and password, this function looks them
 * up using the currently selected authentication mechanism,
 * and if the authentication is successful, it returns a
 * valid $user object from the 'user' table.
 *
 * Uses auth_ functions from the currently active auth module
 *
 * After authenticate_user_login() returns success, you will need to
 * log that the user has logged in, and call complete_user_login() to set
 * the session up.
 *
 * Note: this function works only with non-mnet accounts!
 *
 * @param string $username  User's username
 * @param string $password  User's password
 * @return user|flase A {@link $USER} object or false if error
 */
function authenticate_user_login($username, $password)
{
    global $CFG, $DB;
    $authsenabled = get_enabled_auth_plugins();
    if ($user = get_complete_user_data('username', $username, $CFG->mnet_localhost_id)) {
        $auth = empty($user->auth) ? 'manual' : $user->auth;
        // use manual if auth not set
        if (!empty($user->suspended)) {
            add_to_log(SITEID, 'login', 'error', 'index.php', $username);
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Suspended Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            return false;
        }
        if ($auth == 'nologin' or !is_enabled_auth($auth)) {
            add_to_log(SITEID, 'login', 'error', 'index.php', $username);
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Disabled Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            return false;
        }
        $auths = array($auth);
    } else {
        // check if there's a deleted record (cheaply)
        if ($DB->get_field('user', 'id', array('username' => $username, 'deleted' => 1))) {
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Deleted Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            return false;
        }
        // User does not exist
        $auths = $authsenabled;
        $user = new stdClass();
        $user->id = 0;
    }
    foreach ($auths as $auth) {
        $authplugin = get_auth_plugin($auth);
        // on auth fail fall through to the next plugin
        if (!$authplugin->user_login($username, $password)) {
            continue;
        }
        // successful authentication
        if ($user->id) {
            // User already exists in database
            if (empty($user->auth)) {
                // For some reason auth isn't set yet
                $DB->set_field('user', 'auth', $auth, array('username' => $username));
                $user->auth = $auth;
            }
            if (empty($user->firstaccess)) {
                //prevent firstaccess from remaining 0 for manual account that never required confirmation
                $DB->set_field('user', 'firstaccess', $user->timemodified, array('id' => $user->id));
                $user->firstaccess = $user->timemodified;
            }
            update_internal_user_password($user, $password);
            // just in case salt or encoding were changed (magic quotes too one day)
            if ($authplugin->is_synchronised_with_external()) {
                // update user record from external DB
                $user = update_user_record($username);
            }
        } else {
            // if user not found, create him
            $user = create_user_record($username, $password, $auth);
        }
        $authplugin->sync_roles($user);
        foreach ($authsenabled as $hau) {
            $hauth = get_auth_plugin($hau);
            $hauth->user_authenticated_hook($user, $username, $password);
        }
        if (empty($user->id)) {
            return false;
        }
        if (!empty($user->suspended)) {
            // just in case some auth plugin suspended account
            add_to_log(SITEID, 'login', 'error', 'index.php', $username);
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Suspended Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            return false;
        }
        return $user;
    }
    // failed if all the plugins have failed
    add_to_log(SITEID, 'login', 'error', 'index.php', $username);
    if (debugging('', DEBUG_ALL)) {
        error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Failed Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
    }
    return false;
//.........这里部分代码省略.........
开发者ID:hitphp,项目名称:moodle,代码行数:101,代码来源:moodlelib.php


示例11: defined

// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * @package    enrol_attributes
 * @author     Nicolas Dunand <[email protected]>
 * @copyright  2012-2015 Université de Lausanne (@link http://www.unil.ch}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
    // 1. Default role
    $options = get_default_enrol_roles(context_system::instance());
    $student = get_archetype_roles('student');
    $student_role = array_shift($student);
    //    $settings->add(new admin_setting_heading('enrol_myunil_defaults', get_string('enrolinstancedefaults', 'admin'),
    //            ''));
    $settings->add(new admin_setting_configselect('enrol_attributes/default_roleid', get_string('defaultrole', 'enrol_attributes'), get_string('defaultrole_desc', 'enrol_attributes'), $student_role->id, $options));
    // 2. Fields to use in the selector
    $customfieldrecords = $DB->get_records('user_info_field');
    if ($customfieldrecords) {
        $customfields = [];
        foreach ($customfieldrecords as $customfieldrecord) {
            $customfields[$customfieldrecord->shortname] = $customfieldrecord->name;
        }
        asort($customfields);
        $settings->add(new admin_setting_configmultiselect('enrol_attributes/profilefields', get_string('profilefields', 'enrol_attributes'), get_string('profilefields_desc', 'enrol_attributes'), [], $customfields));
    }
    // 3. Fields to update via Shibboleth login
    if (in_array('shibboleth', get_enabled_auth_plugins())) {
        $settings->add(new admin_setting_configtextarea('enrol_attributes/mappings', get_string('mappings', 'enrol_attributes'), get_string('mappings_desc', 'enrol_attributes'), '', PARAM_TEXT, 60, 10));
    }
}
开发者ID:ndunand,项目名称:moodle-enrol_attributes,代码行数:31,代码来源:settings.php


示例12: output_html

    /**
     * Return XHTML to display control
     *
     * @param mixed $data Unused
     * @param string $query
     * @return string highlight
     */
    public function output_html($data, $query='') {
        global $CFG, $OUTPUT, $DB;

        // display strings
        $txt = get_strings(array('authenticationplugins', 'users', 'administration',
            'settings', 'edit', 'name', 'enable', 'disable',
            'up', 'down', 'none', 'users'));
        $txt->updown = "$txt->up/$txt->down";
        $txt->uninstall = get_string('uninstallplugin', 'core_admin');
        $txt->testsettings = get_string('testsettings', 'core_auth');

        $authsavailable = core_component::get_plugin_list('auth');
        get_enabled_auth_plugins(true); // fix the list of enabled auths
        if (empty($CFG->auth)) {
            $authsenabled = array();
        } else {
            $authsenabled = explode(',', $CFG->auth);
        }

        // construct the display array, with enabled auth plugins at the top, in order
        $displayauths = array();
        $registrationauths = array();
        $registrationauths[''] = $txt->disable;
        $authplugins = array();
        foreach ($authsenabled as $auth) {
            $authplugin = get_auth_plugin($auth);
            $authplugins[$auth] = $authplugin;
            /// Get the auth title (from core or own auth lang files)
            $authtitle = $authplugin->get_title();
            /// Apply titles
            $displayauths[$auth] = $authtitle;
            if ($authplugin->can_signup()) {
                $registrationauths[$auth] = $authtitle;
            }
        }

        foreach ($authsavailable as $auth => $dir) {
            if (array_key_exists($auth, $displayauths)) {
                continue; //already in the list
            }
            $authplugin = get_auth_plugin($auth);
            $authplugins[$auth] = $authplugin;
            /// Get the auth title (from core or own auth lang files)
            $authtitle = $authplugin->get_title();
            /// Apply titles
            $displayauths[$auth] = $authtitle;
            if ($authplugin->can_signup()) {
                $registrationauths[$auth] = $authtitle;
            }
        }

        $return = $OUTPUT->heading(get_string('actauthhdr', 'auth'), 3, 'main');
        $return .= $OUTPUT->box_start('generalbox authsui');

        $table = new html_table();
        $table->head  = array($txt->name, $txt->users, $txt->enable, $txt->updown, $txt->settings, $txt->testsettings, $txt->uninstall);
        $table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');
        $table->data  = array();
        $table->attributes['class'] = 'admintable generaltable';
        $table->id = 'manageauthtable';

        //add always enabled plugins first
        $displayname = $displayauths['manual'];
        $settings = "<a href=\"auth_config.php?auth=manual\">{$txt->settings}</a>";
        //$settings = "<a href=\"settings.php?section=authsettingmanual\">{$txt->settings}</a>";
        $usercount = $DB->count_records('user', array('auth'=>'manual', 'deleted'=>0));
        $table->data[] = array($displayname, $usercount, '', '', $settings, '', '');
        $displayname = $displayauths['nologin'];
        $settings = "<a href=\"auth_config.php?auth=nologin\">{$txt->settings}</a>";
        $usercount = $DB->count_records('user', array('auth'=>'nologin', 'deleted'=>0));
        $table->data[] = array($displayname, $usercount, '', '', $settings, '', '');


        // iterate through auth plugins and add to the display table
        $updowncount = 1;
        $authcount = count($authsenabled);
        $url = "auth.php?sesskey=" . sesskey();
        foreach ($displayauths as $auth => $name) {
            if ($auth == 'manual' or $auth == 'nologin') {
                continue;
            }
            $class = '';
            // hide/show link
            if (in_array($auth, $authsenabled)) {
                $hideshow = "<a href=\"$url&amp;action=disable&amp;auth=$auth\">";
                $hideshow .= "<img src=\"" . $OUTPUT->pix_url('t/hide') . "\" class=\"iconsmall\" alt=\"disable\" /></a>";
                // $hideshow = "<a href=\"$url&amp;action=disable&amp;auth=$auth\"><input type=\"checkbox\" checked /></a>";
                $enabled = true;
                $displayname = $name;
            }
            else {
                $hideshow = "<a href=\"$url&amp;action=enable&amp;auth=$auth\">";
                $hideshow .= "<img src=\"" . $OUTPUT->pix_url('t/show') . "\" class=\"iconsmall\" alt=\"enable\" /></a>";
//.........这里部分代码省略.........
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:101,代码来源:adminlib.php


示例13: RWSPCReqs

function RWSPCReqs()
{
    global $RWSESL3;
    global $RWSCRURL;
    $r_rwc = RWSGSOpt("rwscas", PARAM_ALPHANUM);
    if ($r_rwc === false || strlen($r_rwc) == 0) {
        return;
    }
    if ($r_rwc != "1" && $r_rwc != "2" && $r_rwc != "3") {
        return;
    }
    $r_ver = RWSGSOpt("version", PARAM_ALPHANUMEXT);
    if ($r_ver === false || strlen($r_ver) == 0) {
        return;
    }
    $r_rwu = RWSGSOpt("rwsuser", PARAM_RAW);
    if ($r_rwu === false || strlen($r_rwu) == 0) {
        unset($r_rwu);
    }
    $r_rwp = RWSGSOpt("rwspass", PARAM_RAW);
    if ($r_rwp === false || strlen($r_rwp) == 0) {
        unset($r_rwp);
    }
    $r_tkt = RWSGSOpt("ticket", PARAM_RAW);
    if ($r_tkt === false || strlen($r_tkt) == 0) {
        unset($r_tkt);
    }
    $r_pid = RWSGSOpt("pgtId", PARAM_RAW);
    if ($r_pid === false || strlen($r_pid) == 0) {
        unset($r_pid);
    }
    $r_piou = RWSGSOpt("pgtIou", PARAM_RAW);
    if ($r_piou === false || strlen($r_piou) == 0) {
        unset($r_piou);
    }
    $r_aus = get_enabled_auth_plugins();
    foreach ($r_aus as $r_aun) {
        $r_aup = get_auth_plugin($r_aun);
        if (strcasecmp($r_aup->authtype, RWSCAS) == 0) {
            $r_csp = $r_aup;
            break;
        }
    }
    if (!isset($r_csp)) {
        return;
    }
    if (empty($r_csp->config->hostname)) {
        return;
    }
    list($r_v1, $r_v2, $r_v3) = explode(".", phpCAS::getVersion());
    $r_csp->connectCAS();
    if ($r_rwc == "1") {
        if (isset($r_tkt)) {
            RWSRHXml();
            echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
            echo "<rwscas>\r\n";
            echo "\t<st>";
            echo utf8_encode(htmlspecialchars(trim($r_tkt)));
            echo "\t</st>\r\n";
            echo "</rwscas>\r\n";
            exit;
        } else {
            if ($_SERVER['REQUEST_METHOD'] == "GET") {
                $r_ok = phpCAS::checkAuthentication();
                if (!isset($r_rwu)) {
                    $r_rwu = phpCAS::getUser();
                }
                if (!isset($r_rwp)) {
                    $r_rwp = "passwdCas";
                }
                RWSLIMUser($r_rwu, $r_rwp, $r_ok);
            } else {
                if ($_SERVER['REQUEST_METHOD'] == "POST") {
                    $r_psd = urldecode(file_get_contents("php://input"));
                    if (stripos($r_psd, "<samlp:LogoutRequest ") !== false) {
                        RWSAOLog();
                    }
                }
            }
        }
    } else {
        if ($r_rwc == "2") {
            if (isset($r_pid) && isset($r_piou)) {
                if ($r_csp->config->proxycas) {
                    phpCAS::checkAuthentication();
                }
            } else {
                if ($_SERVER['REQUEST_METHOD'] == "POST") {
                    $r_psd = urldecode(file_get_contents("php://input"));
                    if (stripos($r_psd, "<samlp:LogoutRequest ") !== false) {
                        RWSAOLog();
                    }
                }
            }
        } else {
            if ($r_rwc == "3") {
                if (isset($r_tkt)) {
                    if (strlen($RWSCRURL) > 0) {
                        $r_svu = $RWSCRURL;
                    } else {
//.........这里部分代码省略.........
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:101,代码来源:servicelib.php


示例14: process_login

 public static function process_login(\core\event\user_loggedin $event)
 {
     global $CFG, $DB;
     // we just received the event from the authentication system; check if well-formed:
     if (!$event->userid) {
         // didn't get an user ID, return as there is nothing we can do
         return true;
     }
     if (in_array('shibboleth', get_enabled_auth_plugins()) && $_SERVER['SCRIPT_FILENAME'] == $CFG->dirroot . '/auth/shibboleth/index.php') {
         // we did get this event from the Shibboleth authentication plugin,
         // so let's try to make the relevant mappings, ensuring that necessary profile fields exist and Shibboleth attributes are provided:
         $customfieldrecords = $DB->get_records('user_info_field');
         $customfields = array();
         foreach ($customfieldrecords as $customfieldrecord) {
             $customfields[] = $customfieldrecord->shortname;
         }
         $mapping = array();
         $mappings_str = explode("\n", str_replace("\r", '', get_config('enrol_attributes', 'mappings')));
         foreach ($mappings_str as $mapping_str) {
             if (preg_match('/^\\s*([^: ]+)\\s*:\\s*([^: ]+)\\s*$/', $mapping_str, $matches) && in_array($matches[2], $customfields) && array_key_exists($matches[1], $_SERVER)) {
                 $mapping[$matches[1]] = $matches[2];
             }
         }
         if (count($mapping)) {
             // now update user profile data from Shibboleth params received as part of the event:
             $user = $DB->get_record('user', ['id' => $event->userid], '*', MUST_EXIST);
             foreach ($mapping as $shibattr => $fieldname) {
                 if (isset($_SERVER[$shibattr])) {
                     $propertyname = 'profile_field_' . $fieldname;
                     $user->{$propertyname} = $_SERVER[$shibattr];
                 }
             }
             require_once $CFG->dirroot . '/user/profile/lib.php';
             profile_save_data($user);
         }
     }
     // last, process the actual enrolments, whether we're using Shibboleth authentication or not:
     self::process_enrolments($event);
 }
开发者ID:ndunand,项目名称:moodle-enrol_attributes,代码行数:39,代码来源:lib.php


示例15: get_content

 function get_content()
 {
     global $USER, $CFG, $SESSION, $OUTPUT;
     require_once $CFG->libdir . '/authlib.php';
     $wwwroot = '';
     $signup = '';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($CFG->loginhttps)) {
         $wwwroot = $CFG->wwwroot;
     } else {
         // This actually is not so secure ;-), 'cause we're
         // in unencrypted connection...
         $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
     }
     if (signup_is_enabled()) {
         $signup = $wwwroot . '/login/signup.php';
     }
     // TODO: now that we have multiauth it is hard to find out if there is a way to change password
     $forgot = $wwwroot . '/login/forgot_password.php';
     if (!empty($CFG->loginpasswordautocomplete)) {
         $autocomplete = 'autocomplete="off"';
     } else {
         $autocomplete = '';
     }
     $username = get_moodle_cookie();
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (!isloggedin() or isguestuser()) {
         // Show the block
         if (empty($CFG->authloginviaemail)) {
             $strusername = get_string('username');
         } else {
             $strusername = get_string('usernameemail');
         }
         $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>';
         $this->content->text .= '<div class="form-group"><label for="login_username">' . $strusername . '</label>';
         $this->content->text .= '<input type="text" name="username" id="login_username" class="form-control" value="' . s($username) . '" /></div>';
         $this->content->text .= '<div class="form-group"><label for="login_password">' . get_string('password') . '</label>';
         $this->content->text .= '<input type="password" name="password" id="login_password" class="form-control" value="" ' . $autocomplete . ' /></div>';
         if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
             $checked = $username ? 'checked="checked"' : '';
             $this->content->text .= '<div class="form-check">';
             $this->content->text .= '<label class="form-check-label">';
             $this->content->text .= '<input type="checkbox" name="rememberusername" id="rememberusername"
                     class="form-check-input" value="1" ' . $checked . '/> ';
             $this->content->text .= get_string('rememberusername', 'admin') . '</label>';
             $this->content->text .= '</div>';
         }
         $this->content->text .= '<div class="form-group">';
         $this->content->text .= '<input type="submit" class="btn btn-primary btn-block" value="' . get_string('login') . '" />';
         $this->content->text .= '</div>';
         $this->content->text .= "</form>\n";
         if (!empty($signup)) {
             $this->content->text .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
         }
         if (!empty($forgot)) {
             $this->content->text .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
         }
         $authsequence = get_enabled_auth_plugins(true);
         // Get all auths, in sequence.
         $potentialidps = array();
         foreach ($authsequence as $authname) {
             $authplugin = get_auth_plugin($authname);
             $potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list($this->page->url->out(false)));
         }
         if (!empty($potentialidps)) {
             $this->content->text .= '<div class="potentialidps">';
             $this->content->text .= '<h6>' . get_string('potentialidps', 'auth') . '</h6>';
             $this->content->text .= '<div class="potentialidplist">';
             foreach ($potentialidps as $idp) {
                 $this->content->text .= '<div class="potentialidp"><a href="' . $idp['url']->out() . '" title="' . s($idp['name']) . '">';
                 $this->content->text .= $OUTPUT->render($idp['icon'], $idp['name']) . s($idp['name']) . '</a></div>';
             }
             $this->content->text .= '</div>';
             $this->content->text .= '</div>';
         }
     }
     return $this->content;
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:82,代码来源:block_login.php


示例16: uu_allowed_auths

/**
 * Returns list of auth plugins that are enabled and known to work.
 */
function uu_allowed_auths()
{
    global $CFG;
    // only following plugins are guaranteed to work properly
    // TODO: add support for more plguins in 2.0
    $whitelist = array('manual', 'nologin', 'none', 'email');
    $plugins = get_enabled_auth_plugins();
    $choices = array();
    foreach ($plugins as $plugin) {
        $choices[$plugin] = auth_get_plugin_title($plugin);
    }
    return $choices;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:16,代码来源:uploaduser.php


示例17: authenticate_user_login

/**
 * Authenticates a user against the chosen authentication mechanism
 *
 * Given a username and password, this function looks them
 * up using the currently selected authentication mechanism,
 * and if the authentication is successful, it returns a
 * valid $user object from the 'user' table.
 *
 * Uses auth_ functions from the currently active auth module
 *
 * After authenticate_user_login() returns success, you will need to
 * log that the user has logged in, and call complete_user_login() to set
 * the session up.
 *
 * Note: this function works only with non-mnet accounts!
 *
 * @param string $username  User's username
 * @param string $password  User's password
 * @param bool $ignorelockout useful when guessing is prevented by other mechanism such as captcha or SSO
 * @param int $failurereason login failure reason, can be used in renderers (it may disclose if account exists)
 * @return stdClass|false A {@link $USER} object or false if error
 */
function authenticate_user_login($username, $password, $ignorelockout = false, &$failurereason = null)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/authlib.php";
    $authsenabled = get_enabled_auth_plugins();
    if ($user = get_complete_user_data('username', $username, $CFG->mnet_localhost_id)) {
        // Use manual if auth not set.
        $auth = empty($user->auth) ? 'manual' : $user->auth;
        if (!empty($user->suspended)) {
            add_to_log(SITEID, 'login', 'error', 'index.php', $username);
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Suspended Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            $failurereason = AUTH_LOGIN_SUSPENDED;
            return false;
        }
        if ($auth == 'nologin' or !is_enabled_auth($auth)) {
            add_to_log(SITEID, 'login', 'error', 'index.php', $username);
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Disabled Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            // Legacy way to suspend user.
            $failurereason = AUTH_LOGIN_SUSPENDED;
            return false;
        }
        $auths = array($auth);
    } else {
        // Check if there's a deleted record (cheaply), this should not happen because we mangle usernames in delete_user().
        if ($DB->get_field('user', 'id', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 1))) {
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Deleted Login:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            $failurereason = AUTH_LOGIN_NOUSER;
            return false;
        }
        // Do not try to authenticate non-existent accounts when user creation is not disabled.
        if (!empty($CFG->authpreventaccountcreation)) {
            add_to_log(SITEID, 'login', 'error', 'index.php', $username);
            error_log('[client ' . getremoteaddr() . "]  {$CFG->wwwroot}  Unknown user, can not create new accounts:  {$username}  " . $_SERVER['HTTP_USER_AGENT']);
            $failurereason = AUTH_LOGIN_NOUSER;
            return false;
        }
        // User does not exist.
        $auths = $authsenabled;
        $user = new stdClass();
        $user->id = 0;
    }
    if ($ignorelocko 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_enclosed函数代码示例发布时间:2022-05-15
下一篇:
PHP get_emp_no函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap