root/trunk/plugins/CL_OpenID/index.php

Revision 7047, 3.0 kB (checked in by inureyes, 6 weeks ago)

refs #777

  • 모든 클래스의 첫자는 대문자로 통일하도록 하는 변경을 반영
Line 
1<?php
2/// Copyright (c) 2004-2008, Needlworks / Tatter Network Foundation
3/// All rights reserved. Licensed under the GPL.
4/// See the GNU General Public License for more details. (/doc/LICENSE, /doc/COPYRIGHT)
5
6if (!defined('ROOT')) {
7    header('HTTP/1.1 403 Forbidden');
8    header("Connection: close");
9    exit;
10}
11
12if( !defined( 'OPENID_REGISTERS' ) ) {
13    define('OPENID_REGISTERS', 10);
14}
15
16global $hostURL, $service;
17
18requireComponent( "Textcube.Function.misc" );
19
20function openid_Logout($target)
21{
22    requireComponent( "Textcube.Control.Openid" );
23    OpenIDConsumer::logout();
24    return $target;
25}
26
27function openid_hardcore_login($target)
28{
29    global $suri;
30    global $hostURL, $service, $blogURL;
31    if( !isset($_COOKIE['openid_auto']) || $_COOKIE['openid_auto'] != 'y' ) {
32        return $target;
33    }
34    if( Acl::getIdentity('openid') ) {
35        return $target;
36    }
37    if( empty($_COOKIE['openid']) ) {
38        return $target;
39    }
40    if( strstr( $_SERVER["REQUEST_URI"], "/login/openid" ) !== false ) {
41        return $target;
42    }
43    if( headers_sent() ) {
44        return $target;
45    }
46    header( "Location: $blogURL/login/openid?action=hardcore&requestURI=" . urlencode($_SERVER["REQUEST_URI"]) );
47    exit;
48}
49
50function openid_add_delegate($target)
51{
52    global $suri;
53    $openid_delegate = Setting::getBlogSettingGlobal( 'OpenIDDelegate', '' );
54    $openid_server = Setting::getBlogSettingGlobal( 'OpenIDServer', '' );
55    $openid_xrduri = Setting::getBlogSettingGlobal( 'OpenIDXRDSUri', '' );
56    if( empty($openid_delegate) ) {
57        return $target;
58    }
59    if( $suri['directive'] != '/' ) {
60        return $target;
61    }
62    $target ="<!--OpenID Delegation Begin-->
63<link rel=\"openid.server\" href=\"$openid_server\" />
64<link rel=\"openid.delegate\" href=\"$openid_delegate\" />
65<meta http-equiv=\"X-XRDS-Location\" content=\"$openid_xrduri\" />
66<!--OpenID Delegation End-->
67$target";
68    header( "X-XRDS-Location: $openid_xrduri" );
69    return $target;
70}
71
72function openid_ViewCommenter($name, $comment)
73{
74    global $database;
75    global $hostURL, $service, $blogURL;
76    $blogid = getBlogId();
77
78    if( $comment['secret'] ) {
79        return $name;
80    }
81    if( empty($comment['openid']) ) {
82        return $name;
83    }
84    $openidlogodisplay = Setting::getBlogSettingGlobal( "OpenIDLogoDisplay", 0 );
85    if( $openidlogodisplay ) {
86        $name = "<a href=\"".$comment['openid']."\" class=\"openid\"><img src=\"" .$service['path']. "/resources/image/icon_openid.gif\" alt=\"OpenID Logo\" title=\"" .
87            _textf("오픈아이디(%1)로 작성하였습니다", $comment['openid'] ) . "\" /></a>" . $name;
88    } else {
89        preg_match_all('@<a(.*)>(.*)</a>@Usi', $name, $temp);
90       
91        for ($i=0; $i<count($temp[0]); $i++) {
92            if (strip_tags($temp[2][$i]) == $comment['name'])
93                $name = str_replace($temp[0][$i], "<a{$temp[1][$i]} title='" ._textf("오픈아이디(%1)로 작성하였습니다", $comment['openid'] )."'>".$temp[2][$i]."</a>", $name);
94        }
95        $name .= "<a href=\"".$comment['openid']."\" class=\"openid\">&nbsp;</a>";
96    }
97    return $name;
98}
99
100function openid_OpenIDAffiliateLinks( $links, $requestURI )
101{
102    include_once "affiliate.php";
103    return array( $openid_help_link, $openid_signup_link );
104}
105?>
Note: See TracBrowser for help on using the browser.