当前位置: 首页>>代码示例>>PHP>>正文


PHP authenticate_user函数代码示例

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


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

示例1: login

 function login()
 {
     $login = db_escape_string($_REQUEST["user"]);
     $password = $_REQUEST["password"];
     $password_base64 = base64_decode($_REQUEST["password"]);
     if (SINGLE_USER_MODE) {
         $login = "admin";
     }
     $result = db_query($this->link, "SELECT id FROM ttrss_users WHERE login = '{$login}'");
     if (db_num_rows($result) != 0) {
         $uid = db_fetch_result($result, 0, "id");
     } else {
         $uid = 0;
     }
     if (!$uid) {
         print $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
         return;
     }
     if (get_pref($this->link, "ENABLE_API_ACCESS", $uid)) {
         if (authenticate_user($this->link, $login, $password)) {
             // try login with normal password
             print $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL));
         } else {
             if (authenticate_user($this->link, $login, $password_base64)) {
                 // else try with base64_decoded password
                 print $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL));
             } else {
                 // else we are not logged in
                 print $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
             }
         }
     } else {
         print $this->wrap(self::STATUS_ERR, array("error" => "API_DISABLED"));
     }
 }
开发者ID:rolfkleef,项目名称:Tiny-Tiny-RSS,代码行数:35,代码来源:api.php

示例2: auth

 private function auth($username, $password)
 {
     global $config;
     $login_ok = false;
     if (!empty($username) && !empty($password)) {
         $attributes = array();
         $authcfg = auth_get_authserver($config['system']['webgui']['authmode']);
         if (authenticate_user($username, $password, $authcfg, $attributes) || authenticate_user($username, $password)) {
             $login_ok = true;
         }
     }
     if (!$login_ok) {
         log_auth("webConfigurator authentication error for '" . $username . "' from " . $this->remote_addr);
         require_once "XML/RPC2/Exception.php";
         throw new XML_RPC2_FaultException(gettext('Authentication failed: Invalid username or password'), -1);
     }
     $user_entry = getUserEntry($username);
     /*
      * admin (uid = 0) is allowed
      * or regular user with necessary privilege
      */
     if (isset($user_entry['uid']) && $user_entry['uid'] != '0' && !userHasPrivilege($user_entry, 'system-xmlrpc-ha-sync')) {
         log_auth("webConfigurator authentication error for '" . $username . "' from " . $this->remote_addr . " not enough privileges");
         require_once "XML/RPC2/Exception.php";
         throw new XML_RPC2_FaultException(gettext('Authentication failed: not enough privileges'), -2);
     }
     return;
 }
开发者ID:KyleJohnstonNet,项目名称:pfsense,代码行数:28,代码来源:xmlrpc.php

示例3: before

function before($route = array())
{
    #print_r($route); exit;
    #inspect the $route array, looking at various options that may have been passed in
    if (@$route['options']['authenticate']) {
        authenticate_user() or halt("Access denied");
    }
    if (@$route['options']['validation_function']) {
        call_if_exists($route['options']['validation_function'], params()) or halt("Woops! Params did not pass validation");
    }
}
开发者ID:Energeyser,项目名称:projet_framework,代码行数:11,代码来源:index.php

示例4: http_basic_auth

/**
 * do a basic authentication, uses $_SERVER['HTTP_AUTHORIZATION'] to validate user.
 * @param $http_auth_header http_authorization header content
 * @return bool
 */
function http_basic_auth($http_auth_header)
{
    $tags = explode(" ", $http_auth_header);
    if (count($tags) >= 2) {
        $userinfo = explode(":", base64_decode($tags[1]));
        if (count($userinfo) >= 2) {
            return authenticate_user($userinfo[0], $userinfo[1]);
        }
    }
    // not authenticated
    return false;
}
开发者ID:8191,项目名称:opnsense-core,代码行数:17,代码来源:xmlrpc.php

示例5: login

 function login()
 {
     @session_destroy();
     @session_start();
     $login = $this->dbh->escape_string($_REQUEST["user"]);
     $password = $_REQUEST["password"];
     $password_base64 = base64_decode($_REQUEST["password"]);
     if (SINGLE_USER_MODE) {
         $login = "admin";
     }
     $result = $this->dbh->query("SELECT id FROM ttrss_users WHERE login = '{$login}'");
     if ($this->dbh->num_rows($result) != 0) {
         $uid = $this->dbh->fetch_result($result, 0, "id");
     } else {
         $uid = 0;
     }
     if (!$uid) {
         $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
         return;
     }
     if (get_pref("ENABLE_API_ACCESS", $uid)) {
         if (authenticate_user($login, $password)) {
             // try login with normal password
             $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL));
         } else {
             if (authenticate_user($login, $password_base64)) {
                 // else try with base64_decoded password
                 $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL));
             } else {
                 // else we are not logged in
                 user_error("Failed login attempt for {$login} from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
                 $this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
             }
         }
     } else {
         $this->wrap(self::STATUS_ERR, array("error" => "API_DISABLED"));
     }
 }
开发者ID:Verisor,项目名称:tt-rss,代码行数:38,代码来源:api.php

示例6: change_password

/**	function used to change the password for the customer portal
 *	@param array $input_array - array which contains the following values
 => 	int $id - customer id
	int $sessionid - session id
	string $username - customer name
	string $password - new password to change
	*	return array $list - returns array with all the customer details
	*/
function change_password($input_array)
{
    global $adb, $log;
    $log->debug("Entering customer portal function change_password");
    $adb->println($input_array);
    $id = (int) $input_array['id'];
    $sessionid = $input_array['sessionid'];
    $username = $input_array['username'];
    $password = $input_array['password'];
    $version = $input_array['version'];
    if (!validateSession($id, $sessionid)) {
        return null;
    }
    $list = authenticate_user($username, $password, $version, 'false');
    if (!empty($list[0]['id'])) {
        return array('MORE_THAN_ONE_USER');
    }
    $sql = "update vtiger_portalinfo set user_password=? where id=? and user_name=?";
    $result = $adb->pquery($sql, array($password, $id, $username));
    $log->debug("Exiting customer portal function change_password");
    return $list;
}
开发者ID:sacredwebsite,项目名称:vtigercrm,代码行数:30,代码来源:customerportal.php

示例7: get_templates

function get_templates($r)
{
    xml_start_tag("get_templates");
    $app_name = (string) $r->app_name;
    if ($app_name) {
        $app = get_submit_app($app_name);
    } else {
        $job_name = (string) $r->job_name;
        $wu = get_wu($job_name);
        $app = BoincApp::lookup_id($wu->appid);
    }
    list($user, $user_submit) = authenticate_user($r, $app);
    $in = file_get_contents(project_dir() . "/templates/" . $app->name . "_in");
    $out = file_get_contents(project_dir() . "/templates/" . $app->name . "_out");
    if ($in === false || $out === false) {
        xml_error(-1, "template file missing");
    }
    echo "<templates>\n{$in}\n{$out}\n</templates>\n        </get_templates>\n    ";
}
开发者ID:brevilo,项目名称:boinc,代码行数:19,代码来源:submit_rpc_handler.php

示例8: db_escape_string

 case "delete-connection":
     $ids = db_escape_string($_REQUEST["ids"]);
     db_query($link, "DELETE FROM ttirc_connections WHERE\n\t\t\tid IN ({$ids}) AND status = 0 AND owner_uid = " . $_SESSION["uid"]);
     print_connections($link);
     break;
 case "create-connection":
     $title = db_escape_string(trim($_REQUEST["title"]));
     if ($title) {
         db_query($link, "INSERT INTO ttirc_connections (enabled, title, owner_uid)\n\t\t\t\tVALUES ('false', '{$title}', '" . $_SESSION["uid"] . "')");
     }
     print_connections($link);
     break;
 case "fetch-profiles":
     $login = db_escape_string($_REQUEST["login"]);
     $password = db_escape_string($_REQUEST["password"]);
     if (authenticate_user($link, $login, $password)) {
         $result = db_query($link, "SELECT * FROM ttirc_settings_profiles\n\t\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY title");
         print "<select style='width: 100%' name='profile'>";
         print "<option value='0'>" . __("Default profile") . "</option>";
         while ($line = db_fetch_assoc($result)) {
             $id = $line["id"];
             $title = $line["title"];
             print "<option value='{$id}'>{$title}</option>";
         }
         print "</select>";
         $_SESSION = array();
     }
     break;
 case "toggle-connection":
     $connection_id = (int) db_escape_string($_REQUEST["connection_id"]);
     $status = bool_to_sql_bool(db_escape_string($_REQUEST["set_enabled"]));
开发者ID:RulerOf,项目名称:Tiny-Tiny-IRC,代码行数:31,代码来源:backend.php

示例9: authenticate_user

?>
				</div>
				
				<div class="button">
					<p><a href ="user.php">Member Area</a></p>
				</div>
                
                <div class="button">
					<p><a href ="admin.php">Admin Area</a></p>
				</div>
				
			</header>
            
            <?php 
// Authenticate user
authenticate_user(100);
?>
			
			<article style="color:#FFFFFF;">
				<p>
					<!-- <center><img src="logo_big.png"></center> Insert Main Logo here -->
					
					<hr/>
					<center><h1>Member Area</h1></center>
					<hr/>
					<p>
						<div class="box">
							<p>
								Hello, user! Welcome to the user area of this site.
							</p>
						</div>
开发者ID:newmight2015,项目名称:csc235_project1,代码行数:31,代码来源:user.php

示例10: unset

##|-PRIV
require "guiconfig.inc";
require_once "radius.inc";
if ($_POST) {
    $pconfig = $_POST;
    unset($input_errors);
    $authcfg = auth_get_authserver($_POST['authmode']);
    if (!$authcfg) {
        $input_errors[] = $_POST['authmode'] . " " . gettext("is not a valid authentication server");
    }
    if (empty($_POST['username']) || empty($_POST['password'])) {
        $input_errors[] = gettext("A username and password must be specified.");
    }
    if (!$input_errors) {
        $attributes = array();
        if (authenticate_user($_POST['username'], $_POST['password'], $authcfg, $attributes)) {
            $savemsg = gettext("User") . ": " . $_POST['username'] . " " . gettext("authenticated successfully.");
            $groups = getUserGroups($_POST['username'], $authcfg, $attributes);
            $savemsg .= "&nbsp;" . gettext("This user is a member of groups") . ": <br />";
            $savemsg .= "<ul>";
            foreach ($groups as $group) {
                $savemsg .= "<li>" . "{$group} " . "</li>";
            }
            $savemsg .= "</ul>";
        } else {
            $input_errors[] = gettext("Authentication failed.");
        }
    }
} else {
    if (isset($config['system']['webgui']['authmode'])) {
        $pconfig['authmode'] = $config['system']['webgui']['authmode'];
开发者ID:toshisam,项目名称:pfsense,代码行数:31,代码来源:diag_authentication.php

示例11: editSingleMultipleChoiceQuest

    // for($i=0;$i<sizeof($options);$i++):
    // 	echo $options[$i];
    // endfor;
    // die();
    $d = editSingleMultipleChoiceQuest($qID, $diff, $isMultiple, $quest, $correct, $options, $correctID, $optionalID);
    echo $d;
    // unset($_SESSION['optIDS']);
    // unset($_SESSION['corrIDS']);
}
if (isset($_POST['loginPassword'])) {
    if (!isset($_POST['loginUsername'])) {
        echo "Please fill out the form!";
        header("Location: ../HTML/login.php");
    }
    //Assign values to variables
    $username = $_POST['loginUsername'];
    $password = $_POST['loginPassword'];
    $q = authenticate_user($username, $password);
    // header("Location: ../HTML/login.php");
    //Create our session variables that will be used for validation, etc.
    $_SESSION['user_type'] = $q['user_type'];
    $_SESSION['user_ID'] = $q['user_ID'];
    $_SESSION['vKey'] = $q['vKey'];
    header("Location: ../HTML/login.php");
}
//Delete multiple choice question
if (isset($_POST['delete_qID'])) {
    $qID = $_POST['delete_qID'];
    $q = deleteMultipleChoiceQuestion($qID);
    echo $q;
}
开发者ID:kubar123,项目名称:diploma,代码行数:31,代码来源:usefunctions.php

示例12: syslog

    syslog(LOG_WARNING, "Username does not match certificate common name ({$username} != {$common_name}), access denied.\n");
    closelog();
    exit(1);
}
if (!is_array($authmodes)) {
    syslog(LOG_WARNING, "No authentication server has been selected to authenticate against. Denying authentication for user {$username}");
    closelog();
    exit(1);
}
$attributes = array();
foreach ($authmodes as $authmode) {
    $authcfg = auth_get_authserver($authmode);
    if (!$authcfg && $authmode != "local") {
        continue;
    }
    $authenticated = authenticate_user($username, $password, $authcfg);
    if ($authenticated == true) {
        break;
    }
}
if ($authenticated == false) {
    syslog(LOG_WARNING, "user '{$username}' could not authenticate.\n");
    closelog();
    exit(-1);
}
if (empty($common_name)) {
    $common_name = getenv("common_name");
    if (empty($common_name)) {
        $common_name = getenv("username");
    }
}
开发者ID:8191,项目名称:opnsense-core,代码行数:31,代码来源:openvpn.auth-user.php

示例13: authenticate_user

<?php

include 'system_load.php';
//Including this file we load system.
//user Authentication.
authenticate_user('admin');
//user level object
$new_userlevel = new Userlevel();
//installation form processing when submits.
if (isset($_POST['settings_submit']) && $_POST['settings_submit'] == 'Yes') {
    //validation to check if fields are empty!
    if ($_POST['site_url'] == '') {
        $message = $language['site_url_empty'];
    } else {
        if ($_POST['email_from'] == '') {
            $message = $language['email_from_required'];
        } else {
            if ($_POST['email_to'] == '') {
                $message = $language['reply_cannot_empty'];
            } else {
                //adding site url
                set_option('site_url', $_POST['site_url']);
                set_option('site_name', $_POST['site_name']);
                set_option('email_from', $_POST['email_from']);
                set_option('email_to', $_POST['email_to']);
                set_option('public_key', $_POST['public_key']);
                set_option('private_key', $_POST['private_key']);
                set_option('redirect_on_logout', $_POST['redirect_on_logout']);
                set_option('language', $_POST['language']);
                set_option('skin', $_POST['skin']);
                set_option('maximum_login_attempts', $_POST['maximum_login_attempts']);
开发者ID:jackhardcastle,项目名称:wiseoldman,代码行数:31,代码来源:general_settings.php

示例14: header

     header("Location: index.php");
     exit;
 } else {
     if ($_REQUEST['state'] == "login_screen") {
         // LOGIN SCREEN
         $smarty->display('header.tpl');
         require 'src/login_screen.php';
         $smarty->display('footer.tpl');
         exit;
     } else {
         if ($_REQUEST['state'] == "login") {
             // LOGIN
             if (!isset($_REQUEST['mode'])) {
                 $auth = "FALSE";
                 if (isset($_REQUEST['email']) && isset($_REQUEST['password'])) {
                     $auth = authenticate_user($_REQUEST['email'], $_REQUEST['password']);
                 } else {
                     set_msg_err("Error: You must supply a username and password");
                     header("Location: " . $_SERVER['PHP_SELF'] . "?" . SID);
                     exit;
                 }
                 if ($auth == "TRUE") {
                     header("Location: " . $_SERVER['PHP_SELF'] . "?" . SID . "&state=logged_in");
                     exit;
                 } else {
                     set_msg_err("Error signing on: incorrect email address or password<p><a href=" . $_SERVER['PHP_SELF'] . "?" . SID . "&state=help>forgot your password?</a>");
                     header("Location: " . $_SERVER['PHP_SELF'] . "?" . SID);
                     exit;
                 }
             } else {
                 // Make sure they are logged in
开发者ID:impelling,项目名称:VegaDNS,代码行数:31,代码来源:index.php

示例15: no_cache_incantation

require_once "config.php";
require_once "db.php";
require_once "db-prefs.php";
no_cache_incantation();
startup_gettext();
$script_started = getmicrotime();
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (!init_connection($link)) {
    return;
}
header("Content-Type: text/plain; charset=utf-8");
if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) {
    ob_start("ob_gzhandler");
}
if (SINGLE_USER_MODE) {
    authenticate_user($link, "admin", null);
}
$purge_intervals = array(0 => __("Use default"), -1 => __("Never purge"), 5 => __("1 week old"), 14 => __("2 weeks old"), 31 => __("1 month old"), 60 => __("2 months old"), 90 => __("3 months old"));
$update_intervals = array(0 => __("Default interval"), -1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly"));
$update_intervals_nodefault = array(-1 => __("Disable updates"), 15 => __("Each 15 minutes"), 30 => __("Each 30 minutes"), 60 => __("Hourly"), 240 => __("Each 4 hours"), 720 => __("Each 12 hours"), 1440 => __("Daily"), 10080 => __("Weekly"));
$update_methods = array(0 => __("Default"), 1 => __("Magpie"), 2 => __("SimplePie"));
if (DEFAULT_UPDATE_METHOD == "1") {
    $update_methods[0] .= ' (SimplePie)';
} else {
    $update_methods[0] .= ' (Magpie)';
}
$access_level_names = array(0 => __("User"), 5 => __("Power User"), 10 => __("Administrator"));
#$error = sanity_check($link);
#if ($error['code'] != 0 && $op != "logout") {
#	print json_encode(array("error" => $error));
#	return;
开发者ID:rolfkleef,项目名称:Tiny-Tiny-RSS,代码行数:31,代码来源:backend.php


注:本文中的authenticate_user函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。