function OnLoadPageData()
 {
     # get item to be deleted
     if (!is_object($this->data_object)) {
         $id = $this->manager->GetItemId($this->data_object);
         $this->data_object = $this->manager->ReadRoleById($id);
     }
 }
 public function validateUser($userName, $password, AuthenticationManager $authenticationManager)
 {
     ResultHelper::whenEqual($password, null, AppLabelUtil::$ERROR_USER_NOT_FOUND, HttpStatusCode::badRequest());
     $user = $this->userService->validateUser($userName, $password);
     ResultHelper::whenEmpty($user, AppLabelUtil::$ERROR_USER_NOT_FOUND, HttpStatusCode::unauthorized());
     $token = Hash::create("sha256", mcrypt_create_iv(64, MCRYPT_DEV_URANDOM), HASH_USER_TOKEN_KEY);
     $authenticationManager->createValidationToken($user->getId(), $user->getRole()->getName(), $token);
     return $this->userMapper->mapUserToDto($user, $token);
 }
 /**
  * @return bool
  * @param string $s_input
  * @param string[] field names $a_keys
  * @desc Test whether a short URL is already taken by another page
  */
 public function Test($s_input, $a_keys)
 {
     $this->SetMessage(str_replace('{0}', htmlspecialchars($s_input), $this->GetMessage()));
     require_once 'authentication-manager.class.php';
     $manager = new AuthenticationManager($this->GetSiteSettings(), $this->GetDataConnection());
     $taken = $manager->IsEmailRegistered($s_input);
     unset($manager);
     return !$taken;
 }
 function OnPreRender()
 {
     /* @var $o_top_level Category */
     $review_item = $this->o_topic->GetReviewItem();
     $s_suggested_title = urlencode(StringFormatter::PlainText(trim($review_item->GetTitle())));
     $s_page = urlencode($_SERVER['REQUEST_URI']);
     $s_subscribe_link = '/play/subscribe.php?type=' . $review_item->GetType() . '&item=' . $review_item->GetId() . '&title=' . $s_suggested_title . '&page=' . $s_page;
     $s_subscribe_title = 'Get an email alert every time there are new comments on this page';
     $this->AddControl('<div class="forumSubscribe"><a href="' . $s_subscribe_link . '" title="' . $s_subscribe_title . '">Subscribe to comments</a></div>');
     if (!$this->authentication_manager->GetUser()->Permissions()->HasPermission(PermissionType::ForumAddMessage())) {
         $add = $this->o_topic->GetCount() ? 'Add your comments' : 'Be the first to add your comments!';
         $this->AddControl('<div class="forumPost"><a href="' . Html::Encode($this->authentication_manager->GetPermissionUrl()) . urlencode('#forumMessageForm') . '">' . $add . '</a></div>');
     }
 }
 function OnPageLoad()
 {
     echo new XhtmlElement('h1', Html::Encode($this->GetPageTitle()));
     $user = AuthenticationManager::GetUser();
     $list = '';
     if ($user->Permissions()->HasPermission(PermissionType::MANAGE_CATEGORIES)) {
         $list .= '<li><a href="/yesnosorry/categorylist.php">Categories</a></li>';
     }
     if ($user->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS)) {
         $list .= '<li><a href="/play/clubs">Clubs and schools</a></li>';
         $list .= '<li><a href="/yesnosorry/contact-audit.php">Contact details audit</a></li>';
     }
     if ($user->Permissions()->HasPermission(PermissionType::MANAGE_GROUNDS)) {
         $list .= '<li><a href="/yesnosorry/groundlist.php">Grounds</a></li>';
     }
     if ($user->Permissions()->HasPermission(PermissionType::MANAGE_USERS_AND_PERMISSIONS)) {
         $list .= '<li><a href="/yesnosorry/personlist.php">Users</a></li>' . '<li><a href="/yesnosorry/roles.php">Roles</a></li>';
     }
     if ($user->Permissions()->HasPermission(PermissionType::MANAGE_URLS)) {
         $list .= '<li><a href="regenerate-short-urls.php">Regenerate short URL cache</a></li>';
     }
     if ($user->Permissions()->HasPermission(PermissionType::MANAGE_SEARCH)) {
         $list .= '<li><a href="/search/reindex.php">Reindex search</a></li>';
     }
     if ($user->Permissions()->HasPermission(PermissionType::MANAGE_STATISTICS)) {
         $list .= '<li><form action="/play/statistics/recalculate-player-statistics.php" method="post"><div><input type="submit" value="Recalculate player statistics" /></div></form></li>';
     }
     if ($list) {
         echo '<ul>' . $list . '</ul>';
     }
 }
    function OnPageLoad()
    {
        if ($this->b_success) {
            ?>
<h1>Confirmation successful</h1>
<p>Thank you for confirming your email address. Your profile has been updated.</p>
<p>When you next sign in to <?php 
            echo Html::Encode($this->GetSettings()->GetSiteName());
            ?>
 you'll
need to use your new email address, <strong><?php 
            echo Html::Encode(AuthenticationManager::GetUser()->GetEmail());
            ?>
</strong>, along with your existing password.</p>
<p><a href="<?php 
            echo Html::Encode($this->GetSettings()->GetUrl('AccountEdit'));
            ?>
">Back to your profile</a></p>
			<?php 
        } else {
            ?>
<h1>Confirmation failed</h1>
<p>Sorry, your request to change your registered email address could not be confirmed.</p>
<p>Please check that you used the exact address in the email you received, or try to <a href="<?php 
            echo Html::Encode($this->GetSettings()->GetUrl('AccountEssential'));
            ?>
">change your email address</a> again.</p>
			<?php 
        }
    }
 function OnLoadPageData()
 {
     # get id of team
     $i_id = $this->team_manager->GetItemId($this->team);
     # no need to read team data if creating a new team
     # unlike some pages though, re-read after a save because not all info is posted back
     if ($i_id) {
         # get team
         $this->team_manager->ReadById(array($i_id));
         $this->team = $this->team_manager->GetFirst();
         # Check user has permission to edit this team
         if (!$this->team instanceof Team or !AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS, $this->team->GetLinkedDataUri())) {
             $this->GetAuthenticationManager()->GetPermission();
         }
     } else {
         # Check user has permission to create teams
         if (!AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS)) {
             $this->GetAuthenticationManager()->GetPermission();
         }
     }
     # get all clubs
     $this->club_manager->ReadAll();
     $this->edit->SetClubs($this->club_manager->GetItems());
     # get all grounds
     $this->ground_manager->ReadAll();
     $this->edit->SetGrounds($this->ground_manager->GetItems());
     # tidy up
     unset($this->team_manager);
     unset($this->club_manager);
     unset($this->ground_manager);
 }
 /**
  * Creates a new EditSchoolControl
  *
  * @param SiteSettings $settings
  */
 public function __construct(SiteSettings $settings)
 {
     # set up element
     $this->SetDataObjectClass('School');
     parent::__construct($settings);
     $this->is_admin = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS);
 }
 function OnLoadPageData()
 {
     # Add subscription
     $o_subs = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection());
     $o_subs->SaveSubscription($this->o_review_item->GetId(), $this->o_review_item->GetType(), AuthenticationManager::GetUser()->GetId());
     unset($o_subs);
 }
 function OnPageInit()
 {
     $this->manager = new ClubManager($this->GetSettings(), $this->GetDataConnection());
     $this->has_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS);
     if (!$this->has_permission) {
         header("HTTP/1.1 401 Unauthorized");
     }
     parent::OnPageInit();
 }
 /**
  * Creates a new TeamEditControl
  *
  * @param SiteSettings $settings
  */
 public function __construct(SiteSettings $settings)
 {
     # set up element
     $this->SetDataObjectClass('Team');
     parent::__construct($settings);
     # Set up aggregated editors
     $this->a_clubs = array();
     $this->a_grounds = array();
     $this->is_admin = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS);
 }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', $this->GetPageTitle());
        # If no search term, show a search form (intended for mobile)
        if (!$this->query instanceof SearchQuery) {
            ?>
            <form action="/search" method="get"><div>
            <input type="search" name="q" />
            <input type="submit" value="Search" />
            </div></form>
            <?php 
            return;
        }
        if ($this->paging->GetTotalResults()) {
            # write the paging navbar
            $paging_bar = $this->paging->GetNavigationBar();
            echo $paging_bar;
            # Load files used for custom formats
            require_once 'email/email-address-protector.class.php';
            require_once 'search/search-highlighter.class.php';
            $protector = new EmailAddressProtector($this->GetSettings());
            $highlighter = new SearchHighlighter();
            echo '<dl class="search">';
            foreach ($this->results as $result) {
                /* @var $result SearchItem */
                echo '<dt>';
                $title = htmlentities($result->Title(), ENT_QUOTES, "UTF-8", false);
                $title = $highlighter->Highlight($this->query->GetSanitisedTerms(), $title);
                echo '<a href="' . htmlentities($result->Url(), ENT_QUOTES, "UTF-8", false) . '">' . $title . "</a> ";
                echo "</dt>";
                echo '<dd>';
                $description = htmlentities($result->Description(), ENT_QUOTES, "UTF-8", false);
                $description = $protector->ApplyEmailProtection($description, AuthenticationManager::GetUser()->IsSignedIn());
                $description = $highlighter->Highlight($this->query->GetSanitisedTerms(), $description);
                echo "<p>" . $description . "</p>";
                echo $result->RelatedLinksHtml();
                echo '<p class="url">' . htmlentities($this->DisplayUrl($result->Url()), ENT_QUOTES, "UTF-8", false) . "</p>";
                if (isset($_GET['debug'])) {
                    echo '<ul class="weight">' . '<li>Matched field weight: <strong>' . $result->WeightOfMatchedField() . '</strong></li>' . '<li>Weight of result type: <strong>' . $result->WeightOfType() . '</strong></li>' . '<li>Weight within type: <strong>' . $result->WeightWithinType() . '</strong></li>' . '<li>Weight: <strong>' . $result->Weight() . '</strong></li>' . '</ul>';
                }
                echo "</dd>";
            }
            echo '</dl>';
            echo $paging_bar;
        } else {
            ?>
			<p>Sorry, we didn't find anything matching your search.</p>
			<p>Please check your spelling, or try rewording your search.</p>
			<p>If you still can't find what you're looking for, please <a href="/contact/"> contact us</a>.</p>
			<?php 
        }
        $this->AddSeparator();
        $this->BuySomething();
    }
 /**
  * Creates a TeamEditPanel
  *
  * @param SiteSettings $settings
  * @param Team $team
  * @param Season[] $seasons
  * @param Match[] $matches
  */
 public function __construct(SiteSettings $settings, Team $team, $seasons, $matches)
 {
     parent::__construct($settings, " this team");
     $is_one_time_team = $team->GetTeamType() == Team::ONCE;
     if (!$is_one_time_team) {
         $this->AddLink('tell us about your team', $settings->GetUrl('TeamAdd'));
     }
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS, $team->GetLinkedDataUri())) {
         $this->AddLink('edit this team', $team->GetEditTeamUrl());
     }
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS)) {
         $this->AddLink('delete this team', $team->GetDeleteTeamUrl());
     }
     if (!$is_one_time_team) {
         $b_in_league = false;
         $b_in_cup = false;
         if (is_array($seasons)) {
             foreach ($seasons as $season) {
                 /* @var $season Season */
                 if (!$b_in_cup and $season->MatchTypes()->Contains(MatchType::CUP)) {
                     $b_in_cup = true;
                 }
                 if (!$b_in_league and $season->MatchTypes()->Contains(MatchType::LEAGUE)) {
                     $b_in_league = true;
                 }
                 if ($b_in_cup and $b_in_league) {
                     break;
                 }
             }
         }
         $this->AddLink('add practice', $team->GetAddMatchNavigateUrl(MatchType::PRACTICE));
         $this->AddLink('add friendly match', $team->GetAddMatchNavigateUrl(MatchType::FRIENDLY));
         $this->AddLink('add tournament', $team->GetAddMatchNavigateUrl(MatchType::TOURNAMENT));
         if ($b_in_league) {
             $this->AddLink('add league match', $team->GetAddMatchNavigateUrl(MatchType::LEAGUE));
         }
         if ($b_in_cup) {
             $this->AddLink('add cup match', $team->GetAddMatchNavigateUrl(MatchType::CUP));
         }
         if (is_array($matches) and count($matches)) {
             # Make sure there's at least one match which is not a tournament or a practice
             foreach ($matches as $o_match) {
                 /* @var $o_match Match */
                 if ($o_match->GetMatchType() == MatchType::PRACTICE or $o_match->GetMatchType() == MatchType::TOURNAMENT or $o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
                     continue;
                 } else {
                     $this->AddLink('update results', $team->GetResultsNavigateUrl());
                     break;
                 }
             }
             $this->AddLink('add matches to your calendar', $team->GetCalendarNavigateUrl());
         }
     }
 }
 function OnPageLoad()
 {
     echo new XhtmlElement('h1', Html::Encode($this->GetPageTitle()));
     echo new ClubListControl($this->a_clubs);
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS)) {
         require_once "stoolball/user-edit-panel.class.php";
         $this->AddSeparator();
         $panel = new UserEditPanel($this->GetSettings(), "clubs and schools");
         $panel->AddLink("add a club or school", "/play/clubs/clubedit.php");
         echo $panel;
     }
 }
 function OnPageLoad()
 {
     echo new XhtmlElement('h1', htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false));
     echo new XhtmlElement('div', $this->content, "play");
     $this->ShowSocialAccounts();
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_COMPETITIONS)) {
         $this->AddSeparator();
         require_once 'stoolball/user-edit-panel.class.php';
         $panel = new UserEditPanel($this->GetSettings(), '');
         $panel->AddLink('add a competition', '/play/competitions/competitionedit.php');
         echo $panel;
     }
 }
 function OnPostback()
 {
     $user = AuthenticationManager::GetUser();
     if (isset($_POST['gender'])) {
         $user->SetGender($_POST['gender']);
     }
     $user->SetOccupation(trim($_POST['occupation']));
     $user->SetInterests(trim($_POST['interests']));
     $user->SetLocation(trim($_POST['location']));
     $authentication_manager = $this->GetAuthenticationManager();
     $authentication_manager->SavePersonalInfo($user);
     # redirect to edit profile home
     $this->Redirect($this->GetSettings()->GetUrl('AccountEdit'));
 }
 public function initialize()
 {
     $this->database = new Database();
     $this->utility = new Utility();
     $this->dispatcher = new Dispatcher();
     $this->authenticationManager = new AuthenticationManager();
     $this->mailer = new Mailer();
     $this->cache = new Cache();
     if ($this->utility->hasForwardedIp()) {
         $this->utility->correctRemoteAddr();
     }
     AuthenticationManager::startSession();
     AuthenticationManager::verifySession();
 }
 /**
  * Creates a MatchFixtureEditControl
  *
  * @param SiteSettings $o_settings
  * @param Match $o_match
  * @param bool $b_entire_form
  */
 public function __construct(SiteSettings $o_settings, Match $o_match = null, $b_entire_form = true)
 {
     $this->SetDataObjectClass('Match');
     if (!is_null($o_match)) {
         $this->SetDataObject($o_match);
     }
     parent::__construct($o_settings, $b_entire_form);
     $this->a_teams = array();
     $this->a_grounds = array();
     $this->SetButtonText('Save match');
     $this->i_match_type = MatchType::FRIENDLY;
     $this->seasons = new Collection();
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES)) {
         $this->b_user_is_admin = true;
     }
 }
 /**
  * Fetches authentication adapter from authentication.conf,
  * loads the corresponding class if it exists and sets
  * AuthenticationManager::$g_authentication_adapter accordingly.
  *
  * @throws AuthClassDoesNotExistException
  */
 public static function init()
 {
     if (strlen(self::$g_authentication_adapter) == 0 || !class_exists(self::$g_authentication_adapter)) {
         $o_app_conf = Configuration::load();
         $o_auth_config = Configuration::load($o_app_conf->get('authentication_config'));
         $vs_auth_adapter = $o_auth_config->get('auth_adapter');
         if (file_exists(__CA_LIB_DIR__ . "/core/Auth/Adapters/{$vs_auth_adapter}.php")) {
             @(require_once __CA_LIB_DIR__ . "/core/Auth/Adapters/{$vs_auth_adapter}.php");
             if (class_exists($vs_auth_adapter . 'AuthAdapter')) {
                 self::$g_authentication_adapter = $vs_auth_adapter . 'AuthAdapter';
                 return;
             }
         }
         throw new AuthClassDoesNotExistException();
     }
 }
 /**
  * (non-PHPdoc)
  * @see data/DataEditControl#BuildPostedDataObject()
  */
 protected function BuildPostedDataObject()
 {
     # Prepare swear filter
     require_once 'text/bad-language-filter.class.php';
     $o_filter = new BadLanguageFilter();
     # Build object
     $user = AuthenticationManager::GetUser();
     $user->SetName($o_filter->Filter($_POST['known_as']));
     $user->SetFirstName($o_filter->Filter($_POST['first_name']));
     $user->SetLastName($o_filter->Filter($_POST['last_name']));
     $user->SetRequestedEmail($_POST['email']);
     $user->SetPassword($_POST['password1']);
     $user->SetRequestedPassword($_POST['password2']);
     $user->SetAutoSignIn(isset($_POST['remember_me']));
     $this->SetDataObject($user);
 }
 function OnPrePageLoad()
 {
     $this->SetPageTitle('Edit profile for ' . AuthenticationManager::GetUser()->GetName());
 }
 /**
  * @param $postId integer
  * @throws Exception
  */
 public static function deletePost($postId)
 {
     $postId = intval($postId);
     $post = self::getPostById($postId);
     $userId = AuthenticationManager::getAuthenticatedUser()->getId();
     if (!self::isPostLastInChannel($post)) {
         throw new Exception("Post is not the last one in it's channel and therefore can't be deleted.");
     }
     if ($post->getUserId() != $userId) {
         throw new Exception("Post has not been created by the current user and therefore can't be deleted.");
     }
     $con = self::getConnection();
     self::query($con, "UPDATE posts SET active = 0 WHERE id = " . $postId . ";");
     self::closeConnection($con);
     self::logAction('Deleted post with id=' . $postId . ' by user with id=' . $userId);
 }
 function OnLoadPageData()
 {
     /* @var $match_manager MatchManager */
     # get id of Match
     $i_id = $this->match_manager->GetItemId();
     # Get details of match but, if invalid, don't replace submitted details with saved ones
     if ($i_id and $this->IsValid()) {
         $this->match_manager->ReadByMatchId(array($i_id));
         $this->match_manager->ExpandMatchScorecards();
         $this->match = $this->match_manager->GetFirst();
         if ($this->match instanceof Match) {
             $this->b_user_is_match_owner = AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId();
             $this->b_is_tournament = $this->match->GetMatchType() == MatchType::TOURNAMENT;
         }
     }
     unset($this->match_manager);
     # Tournament or match in the future or not played is page not found
     $editable_results = array(MatchResult::UNKNOWN, MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::TIE, MatchResult::ABANDONED);
     if (!$this->match instanceof Match or $this->b_is_tournament or $this->match->GetStartTime() > gmdate('U') or !in_array($this->match->Result()->GetResultType(), $editable_results)) {
         http_response_code(404);
         $this->page_not_found = true;
     }
 }
 /**
  * Get user info from back-end
  *
  * @param string $ps_username
  * @param string $ps_password
  * @return array
  */
 public static function getUserInfo($ps_username, $ps_password)
 {
     self::init();
     if ($vn_rc = call_user_func(self::$g_authentication_adapter . '::getUserInfo', $ps_username, $ps_password)) {
         return $vn_rc;
     } elseif (self::$g_authentication_adapter !== 'CaUsers') {
         // fall back to ca_users "native" authentication
         self::init('CaUsers');
         $vn_rc = call_user_func(self::$g_authentication_adapter . '::getUserInfo', $ps_username, $ps_password, $pa_options);
         self::$g_authentication_adapter = null;
         return $vn_rc;
     }
 }
 function OnPageInit()
 {
     $this->manager = new CategoryManager($this->GetSettings(), $this->GetDataConnection());
     $this->has_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_CATEGORIES);
     parent::OnPageInit();
 }
Beispiel #26
0
<?php

require_once '_pm/class.authenticationmgr.php';
require_once 'task/config.inc.php';
mysql_connect($dbs, $dbu, $dbp);
mysql_select_db($dbn);
ob_start();
$autMgr = new AuthenticationManager();
$userID = $autMgr->getUserID();
$userGroup = $autMgr->getUserGroup();
if ($userID == 1 or $userGroup != 5) {
    $autMgr->endSession();
    header('location: /login');
    exit;
}
if (isset($_POST['sID']) && is_numeric($_POST['sID'])) {
    $sID = $_POST['sID'];
} else {
    $sID = 0;
}
if ($sID) {
    $oResult = mysql_query("SELECT accID FROM pm_as_parts WHERE sID='{$sID}' LIMIT 1");
    if ($oResult && mysql_num_rows($oResult)) {
        list($accID) = mysql_fetch_array($oResult);
        @mysql_query("DELETE FROM pm_as_parts_properties WHERE accID='{$accID}'");
        @mysql_query("DELETE FROM pm_as_parts WHERE accID='{$accID}' LIMIT 1");
        @mysql_query("DELETE FROM pm_structure WHERE sID='{$sID}' LIMIT 1");
        print 'Товар удален<br />';
    } else {
        print 'Товар с sID=' . $sID . ' не найден.<br />';
    }
Beispiel #27
0
 /**
  * This is a option-less authentication. Either your login works or it doesn't.
  * Other apps implementing this interface may need to know what you're trying to do 
  * in order to make a decision; $pa_options is an associative array of User handler-specific
  * keys and values that can contain such information
  */
 public function authenticate(&$ps_username, $ps_password = "", $pa_options = null)
 {
     // if user doesn't exist, try creating it through the authentication backend, if the backend supports it
     if (strlen($ps_username) > 0 && !$this->load($ps_username)) {
         if (AuthenticationManager::supports(__CA_AUTH_ADAPTER_FEATURE_AUTOCREATE_USERS__)) {
             try {
                 $va_values = AuthenticationManager::getUserInfo($ps_username, $ps_password);
             } catch (Exception $e) {
                 $this->opo_log->log(array('CODE' => 'SYS', 'SOURCE' => 'ca_users/authenticate', 'MESSAGE' => _t('There was an error while trying to fetch information for a new user from the current authentication backend. The message was %1 : %2', get_class($e), $e->getMessage())));
                 return false;
             }
             if (!is_array($va_values) || sizeof($va_values) < 1) {
                 return false;
             }
             // @todo: check sanity on values from plugins before inserting them?
             foreach ($va_values as $vs_k => $vs_v) {
                 if (in_array($vs_k, array('roles', 'groups'))) {
                     continue;
                 }
                 $this->set($vs_k, $vs_v);
             }
             $vn_mode = $this->getMode();
             $this->setMode(ACCESS_WRITE);
             $this->insert();
             if (!$this->getPrimaryKey()) {
                 $this->setMode($vn_mode);
                 $this->opo_log->log(array('CODE' => 'SYS', 'SOURCE' => 'ca_users/authenticate', 'MESSAGE' => _t('User could not be created after getting info from authentication adapter. API message was: %1', join(" ", $this->getErrors()))));
                 return false;
             }
             if (is_array($va_values['groups']) && sizeof($va_values['groups']) > 0) {
                 $this->addToGroups($va_values['groups']);
             }
             if (is_array($va_values['roles']) && sizeof($va_values['roles']) > 0) {
                 $this->addRoles($va_values['roles']);
             }
             if (is_array($va_values['preferences']) && sizeof($va_values['preferences']) > 0) {
                 foreach ($va_values['preferences'] as $vs_pref => $vs_pref_val) {
                     $this->setPreference($vs_pref, $vs_pref_val);
                 }
             }
             $this->update();
             // restore mode
             $this->setMode($vn_mode);
         }
     }
     if (AuthenticationManager::authenticate($ps_username, $ps_password, $pa_options)) {
         $this->load($ps_username);
         return true;
     }
     // check ips
     if (!isset($pa_options["dont_check_ips"]) || !$pa_options["dont_check_ips"]) {
         if ($vn_user_id = $this->ipAuthenticate()) {
             if ($this->load($vn_user_id)) {
                 $ps_username = $this->get("user_name");
                 return 2;
             }
         }
     }
     return false;
 }
 * 
 *  PHP version 5
 *
 *  @category Code_Sample
 *  @package  O365-PHP-Microsoft-Graph-Connect
 *  @author   Ricardo Loo <ricardol@microsoft.com>
 *  @license  MIT License
 *  @link     http://GitHub.com/OfficeDev/O365-PHP-Microsoft-Graph-Connect
 */
/*! 
    @abstract Users are redirected to this page to initiate the disconnect flow
 */
namespace Microsoft\Office365\UnifiedAPI\Connect;

require_once 'AuthenticationManager.php';
AuthenticationManager::disconnect();
// *********************************************************
//
// O365-PHP-Microsoft-Graph-Connect
// https://github.com/OfficeDev/O365-PHP-Microsoft-Graph-Connect
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
<?php

require_once __DIR__ . '/../config/config.php';
$objAuthenticationManager = new AuthenticationManager(COOKIE_NAME, COOKIE_EXPIRE_TIME);
if ($objAuthenticationManager->doAuthentication($_REQUEST) || trim($_REQUEST['url']) == '') {
    header('Location: ' . $_REQUEST['url']);
} else {
    header('Location: ' . LOGIN_URL . '?login_attempt=1');
}
exit(0);
 public function DoReset()
 {
     if (!AuthenticationManager::supports(__CA_AUTH_ADAPTER_FEATURE_RESET_PASSWORDS__)) {
         $this->Login();
         return;
     }
     $vs_token = $this->getRequest()->getParameter('token', pString);
     $vs_username = $this->getRequest()->getParameter('username', pString);
     $t_user = new ca_users();
     $vs_pw = $this->getRequest()->getParameter('password', pString);
     $vs_pw_check = $this->getRequest()->getParameter('password2', pString);
     if ($t_user->load($vs_username)) {
         if ($t_user->isValidToken($vs_token)) {
             // no password match
             if ($vs_pw !== $vs_pw_check) {
                 $this->notification->addNotification(_t("Passwords did not match. Please try again."), __NOTIFICATION_TYPE_ERROR__);
                 $this->view->setVar('notifications', $this->notification->getNotifications());
                 $this->view->setVar('renderForm', true);
                 $this->view->setVar('token', $vs_token);
                 $this->view->setVar('username', $vs_username);
                 $this->render('password_reset_form_html.php');
             } else {
                 $t_user->set('password', $vs_pw);
                 $t_user->setMode(ACCESS_WRITE);
                 $t_user->update();
                 $this->notification->addNotification(_t("Password was successfully changed. You can now log in with your new password."), __NOTIFICATION_TYPE_INFO__);
                 $this->view->setVar('notifications', $this->notification->getNotifications());
                 $this->Login();
             }
         }
     }
 }