Exemplo n.º 1
0
 /**
  * Output filter: Transforms URLs to the appropriate format for the embedded mode
  * @param  string                    $content  template content
  * @param  \Smarty_Internal_Template $template template instance
  * @return string                    template content
  */
 public static function outputEmbeddedUrl($content, \Smarty_Internal_Template $template)
 {
     $path = Registry::get('config.current_host') . Registry::get('config.current_path');
     // Transform 'href' attribute values of the 'a' elements, which:
     // - have 'href' attribute
     // - the 'href' value contains current path and host, or its a relative url
     // - do not have class attribute starting with 'cm-' prefix
     $pattern = '{' . '<(?:a)\\s+' . '(?=[^>]*\\bhref="([^"]*//' . $path . '[^"]*|(?!//)(?!https?)[^"]*)")' . '(?![^>]*\\bclass="[^"]*cm-[^"]*")' . '[^>]*>' . '}Usi';
     $content = preg_replace_callback($pattern, function ($matches) {
         return str_replace($matches[1], Embedded::resolveUrl($matches[1]), $matches[0]);
     }, $content);
     // Transform relative 'src'attribute values
     $pattern = '{<[^>]+\\bsrc="((?!//)(?!https?)[^"]+)"[^>]*>}Usi';
     $content = preg_replace_callback($pattern, function ($matches) {
         return str_replace($matches[1], Url::resolve($matches[1], Registry::get('config.current_location')), $matches[0]);
     }, $content);
     $area = Registry::get('view')->getArea();
     if ($area[1] == 'mail') {
         // Transform URLs in the text
         $pattern = '{\\bhttps?://' . $path . '[^\\s<>"\']*(?=[^>]*<)}s';
         $content = preg_replace_callback($pattern, function ($matches) {
             return Embedded::resolveUrl($matches[0]);
         }, $content);
     }
     return $content;
 }
Exemplo n.º 2
0
function fn_hybrid_auth_process($action, &$redirect_url = '')
{
    $hybridauth = fn_hybrid_auth_init();
    if ($hybridauth) {
        unset($_SESSION['hybrid_auth']);
        $provider = !empty($_REQUEST['provider']) ? $_REQUEST['provider'] : '';
        if (!empty($provider) && $hybridauth->isConnectedWith($provider)) {
            $auth_data = fn_hybrid_auth_get_auth_data($hybridauth, $provider);
            if (!$auth_data) {
                return HYBRID_AUTH_ERROR_AUTH_DATA;
            }
            fn_hybrid_auth_fix_old_user($auth_data, $provider);
            // linked users without providers. for compatibility with the old version of the add-on
            $user_data = fn_hybrid_auth_get_user_data($auth_data);
            if ($action == 'login_provider') {
                $redirect_url = fn_hybrid_auth_login($user_data, $auth_data, $provider);
            } elseif ($action == 'link_provider') {
                $redirect_url = fn_hybrid_auth_link($user_data, $auth_data, $provider);
            } elseif ($action == 'link_provider_profile') {
                $redirect_url = fn_hybrid_auth_link_profile($auth_data, $provider);
            }
            $status = HYBRID_AUTH_LOGIN;
        } else {
            if (!empty($provider)) {
                $params = array();
                if ($provider == "OpenID") {
                    $params["openid_identifier"] = @$_REQUEST["openid_identifier"];
                }
            }
            if (!empty($_REQUEST['redirect_to_idp'])) {
                try {
                    $adapter = $hybridauth->authenticate($provider, $params);
                    $status = HYBRID_AUTH_OK;
                } catch (Exception $e) {
                    fn_set_notification('E', __('error'), $e->getMessage());
                    $status = HYBRID_AUTH_LOGIN;
                }
            } else {
                Registry::get('view')->assign('provider', $provider);
                $status = HYBRID_AUTH_LOADING;
            }
        }
    } else {
        $status = HYBRID_AUTH_FALSE;
    }
    if (!empty($_REQUEST['embedded'])) {
        $redirect_url = Embedded::resolveUrl($redirect_url . (parse_url($redirect_url, PHP_URL_QUERY) ? '&' : '?') . '_ts=' . TIME);
    }
    return $status;
}