Example #1
0
<?php

/**
 * This is a Branax pagecontroller.
 *
 */
// Include the essential config-file which also creates the $branax variable with its defaults.
include __DIR__ . '/config.php';
$user = new CUser($branax['database']);
$user->isAuthenticated() or die('Check: You must login to edit.');
define('MOVIE_PATH', __DIR__ . '/img/movie/');
$content = new CUser($branax['database']);
// Do it and store it all in variables in the Branax container.
$branax['title'] = "Edit";
$branax['main'] = <<<EOD
<h1>Editera innehÄll</h1>
{$content->update()}
EOD;
// Finally, leave it all to the rendering phase of Branax.
include BRANAX_THEME_PATH;
Example #2
0
 $user['autologout'] = get_request('autologout', 0);
 $user['lang'] = get_request('lang');
 $user['theme'] = get_request('theme');
 $user['refresh'] = get_request('refresh');
 $user['rows_per_page'] = get_request('rows_per_page');
 $user['type'] = get_request('user_type');
 //			$user['user_groups'] = get_request('user_groups', array());
 $user['user_medias'] = get_request('user_medias', array());
 $usrgrps = get_request('user_groups', array());
 $usrgrps = zbx_toObject($usrgrps, 'usrgrpid');
 $user['usrgrps'] = $usrgrps;
 if (isset($_REQUEST['userid'])) {
     $action = AUDIT_ACTION_UPDATE;
     $user['userid'] = $_REQUEST['userid'];
     DBstart();
     $result = CUser::update($user);
     if (!$result) {
         error(CUser::resetErrors());
     }
     // if($result)	$result = CUserGroup::updateUsers(array('users' => $user, 'usrgrps' => $usrgrps));
     // if($result === false)
     // error(CUserGroup::resetErrors());
     if ($result !== false) {
         $result = CUser::updateMedia(array('users' => $user, 'medias' => $user['user_medias']));
     }
     $result = $result === false ? false : true;
     $result = DBend($result);
     show_messages($result, S_USER_UPDATED, S_CANNOT_UPDATE_USER);
 } else {
     $action = AUDIT_ACTION_ADD;
     DBstart();
Example #3
-1
    public function Authorize()
    {
        global $APPLICATION;
        $APPLICATION->RestartBuffer();
        $authError = SOCSERV_AUTHORISATION_ERROR;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            $redirect_uri = CSocServUtil::ServerName() . '/bitrix/tools/oauth/bitrix24net.php';
            if ($this->getEntityOAuth($_REQUEST["code"])->GetAccessToken($redirect_uri) !== false) {
                $arB24NetUser = $this->entityOAuth->GetCurrentUser();
                if ($arB24NetUser) {
                    if (isset($_REQUEST['checkword']) && $arB24NetUser['PROFILE_ID'] > 0) {
                        $profileId = $arB24NetUser['PROFILE_ID'];
                        $checkword = trim($_REQUEST['checkword']);
                        $dbRes = CUser::getById($profileId);
                        $arUser = $dbRes->fetch();
                        if ($arUser && !$arUser['LAST_LOGIN']) {
                            if ($arUser['CONFIRM_CODE'] == $checkword) {
                                $arUserFields = array('XML_ID' => $arB24NetUser['ID'], 'EXTERNAL_AUTH_ID' => 'socservices');
                                if ($arUser['NAME'] == '' && $arUser['LAST_NAME'] == '') {
                                    $arUserFields['NAME'] = $arB24NetUser['NAME'];
                                    $arUserFields['LAST_NAME'] = $arB24NetUser['LAST_NAME'];
                                    if (strlen($arB24NetUser['PERSONAL_PHOTO']) > 0 && self::CheckPhotoURI($arB24NetUser['PERSONAL_PHOTO'])) {
                                        $arUserFields['PERSONAL_PHOTO'] = CFile::MakeFileArray($arB24NetUser['PERSONAL_PHOTO']);
                                    }
                                }
                                $obUser = new CUser();
                                if ($obUser->update($profileId, $arUserFields)) {
                                    foreach (GetModuleEvents("main", "OnUserInitialize", true) as $arEvent) {
                                        ExecuteModuleEventEx($arEvent, array($profileId, $arUserFields));
                                    }
                                }
                            }
                        }
                    }
                    $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arB24NetUser["ID"], 'LOGIN' => "B24_" . $arB24NetUser["ID"], 'NAME' => $arB24NetUser["NAME"], 'LAST_NAME' => $arB24NetUser["LAST_NAME"], 'EMAIL' => $arB24NetUser["EMAIL"], 'PERSONAL_WWW' => $arB24NetUser["PROFILE"], 'OATOKEN' => $this->entityOAuth->getToken(), 'REFRESH_TOKEN' => $this->entityOAuth->getRefreshToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires());
                    if (IsModuleInstalled('bitrix24')) {
                        $arFields['LOGIN'] = $arFields['EMAIL'];
                    }
                    if (strlen(SITE_ID) > 0) {
                        $arFields["SITE_ID"] = SITE_ID;
                    }
                    $authError = $this->AuthorizeUser($arFields);
                }
            }
        }
        $bSuccess = $authError === true;
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset", "checkword");
        $url = $APPLICATION->GetCurDir() == "/login/" ? "" : $APPLICATION->GetCurDir();
        $mode = 'page';
        if (isset($_REQUEST["state"])) {
            $arState = array();
            parse_str($_REQUEST["state"], $arState);
            if (isset($arState['backurl']) || isset($arState['redirect_url'])) {
                $parseUrl = parse_url(isset($arState['redirect_url']) ? $arState['redirect_url'] : $arState['backurl']);
                $urlPath = $parseUrl["path"];
                $arUrlQuery = explode('&', $parseUrl["query"]);
                foreach ($arUrlQuery as $key => $value) {
                    foreach ($aRemove as $param) {
                        if (strpos($value, $param . "=") === 0) {
                            unset($arUrlQuery[$key]);
                            break;
                        }
                    }
                }
                $url = !empty($arUrlQuery) ? $urlPath . '?' . implode("&", $arUrlQuery) : $urlPath;
            }
            if (isset($arState['mode'])) {
                $mode = $arState['mode'];
            }
        }
        if (strlen($url) <= 0 || preg_match("'^(http://|https://|ftp://|//)'i", $url)) {
            $url = CSocServUtil::ServerName() . '/';
        }
        $url = CUtil::JSEscape($url);
        if ($bSuccess) {
            unset($_SESSION['B24_NETWORK_REDIRECT_TRY']);
        } else {
            if (IsModuleInstalled('bitrix24')) {
                if (isset($_SESSION['B24_NETWORK_REDIRECT_TRY'])) {
                    unset($_SESSION['B24_NETWORK_REDIRECT_TRY']);
                    $url = self::getUrl();
                    $url .= (strpos($url, '?') >= 0 ? '&' : '?') . 'skip_redirect=1';
                } else {
                    $_SESSION['B24_NETWORK_REDIRECT_TRY'] = true;
                    $url = '/';
                }
            } else {
                if ($authError === SOCSERV_REGISTRATION_DENY) {
                    $url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
                    $url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $authError;
                } elseif ($bSuccess !== true) {
                    $url = isset($urlPath) ? $urlPath . '?auth_service_id=' . self::ID . '&auth_service_error=' . $authError : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $authError, $aRemove);
                }
            }
        }
        if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
            $url .= (strpos($url, "?") === false ? '?' : '&') . "current_fieldset=SOCSERV";
        }
        $location = $mode == "popup" ? 'if(window.opener) window.opener.location = \'' . $url . '\'; window.close();' : 'window.location = \'' . $url . '\';';
        ?>
<script type="text/javascript">
<?php 
        echo $location;
        ?>
</script>
<?php 
        die;
    }