OSDN Git Service

v1.1.0
authorhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 7 Jun 2008 19:33:43 +0000 (19:33 +0000)
committerhsur <hsur@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 7 Jun 2008 19:33:43 +0000 (19:33 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@627 1ca29b6e-896d-4ea0-84a5-967f57386b96

26 files changed:
trunk/NP_OpenId/NP_OpenId.php
trunk/NP_OpenId/openid/help.html
trunk/NP_OpenId/openid/index.php
trunk/NP_OpenId/openid/mkeuc.sh [new file with mode: 0644]
trunk/NP_OpenId/openid/profile.php [deleted file]
trunk/NP_OpenId/openid/rd.php
trunk/NP_OpenId/openid/template/np_openid/admin_english.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/form_english.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/form_japanese-euc.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/form_japanese-utf8.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/loggedin_english.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-euc.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-utf8.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/notloggedin_english.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-euc.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-utf8.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/updatefailed_english.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_english.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-euc.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-utf8.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/user_english.html [new file with mode: 0644]
trunk/NP_OpenId/openid/template/np_openid/yui_english.html [new file with mode: 0644]
trunk/NP_OpenId/sharedlibs/Auth/TypeKey.php [deleted file]
trunk/NP_OpenId/sharedlibs/cles/Feedback.php
trunk/NP_OpenId/sharedlibs/cles/SQLStoreForNucleus.php
trunk/NP_OpenId/sharedlibs/cles/Template.php

index 0aa5bda..f64f875 100644 (file)
@@ -2,9 +2,9 @@
 // vim: tabstop=2:shiftwidth=2
 
 /**
-  * NP_OpenId ($Revision: 1.1 $)
+  * NP_OpenId ($Revision: 1.2 $)
   * by hsur ( http://blog.cles.jp/np_cles )
-  * $Id: NP_OpenId.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
+  * $Id: NP_OpenId.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
   *
 */
 
@@ -36,6 +36,7 @@
   * but you are not obligated to do so. If you do not wish to do so, delete
   * this exception statement from your version.
 */
+
 // ParanoidHTTPFetcher bug?
 define('Auth_Yadis_CURL_OVERRIDE', '1');
 
@@ -44,10 +45,11 @@ define('NP_OPENID_COOKIE', 'EXTAUTH');
 
 // libs
 require(dirname(__FILE__).'/sharedlibs/sharedlibs.php');
-require_once "Auth/OpenID/Consumer.php";
-require_once "cles/SQLStoreForNucleus.php";
-require_once "Auth/OpenID/SReg.php";
-require_once "Auth/OpenID/PAPE.php";
+require_once 'cles/Template.php';
+require_once 'Auth/OpenID/Consumer.php';
+require_once 'cles/SQLStoreForNucleus.php';
+require_once 'Auth/OpenID/SReg.php';
+require_once 'Auth/OpenID/PAPE.php';
 
 class NP_OpenId extends NucleusPlugin {
 
@@ -61,7 +63,7 @@ class NP_OpenId extends NucleusPlugin {
                return 'http://blog.cles.jp/np_cles/category/31/subcatid/21';
        }
        function getVersion() {
-               return '1.0.0';
+               return '1.1.0';
        }
        function getMinNucleusVersion() {
                return 330;
@@ -82,7 +84,7 @@ class NP_OpenId extends NucleusPlugin {
                );
        }
        function getDescription() {
-               return '[$Revision: 1.1 $]<br />Adds OpenID authentication to anonymous comment, to prevent robots from spamming.';
+               return '[$Revision: 1.2 $]<br />Adds OpenID authentication to anonymous comment, to prevent robots from spamming.';
        }
        function supportsFeature($what) {
                switch ($what) {
@@ -108,7 +110,7 @@ class NP_OpenId extends NucleusPlugin {
 
                $this->store = new cles_SQLStoreForNucleus();
                $this->consumer = new Auth_OpenID_Consumer($this->store);
-               $this->loginedUser = null;
+               $this->loggedinUser = null;
                $this->comments = array();
        }
 
@@ -149,19 +151,9 @@ class NP_OpenId extends NucleusPlugin {
         );
                
                global $CONF;
-               $loginedHtml = "<p>Thanks for signing in(<%identity%>). Now you can comment or send mail. (<a href=\"<%url%>\" rel=\"nofollow\">Sign out</a>/<a href=\"<%profileUpdateUrl%>\" rel=\"nofollow\" target=\"_blank\">Update Profile</a>)\n<script type=\"text/javascript\">\n(function(){\nvar onload_org = window.onload;\nwindow.onload = function(){\nif(onload_org) onload_org();\ndocument.getElementById('nucleus_cf_name').value = '<%nick%> [OpenID]';\ndocument.getElementById('nucleus_cf_name').style.background = '#FFFFCC';\ndocument.getElementById('nucleus_cf_name').readOnly = true;\ndocument.getElementById('nucleus_cf_email').value = '<%email%>';\ndocument.getElementById('nucleus_cf_email').style.background = '#FFFFCC';\ndocument.getElementById('nucleus_cf_email').readOnly = true;\n}\n})()\n</script></p>";
-               $notLoginedHtml =  '<p>If you have a OpenID identity, you can sign in to use it here.<br /><form method="post" action="<%url%>">Identity URL: <input style="padding-left:20px; background:url('.$CONF['PluginURL'].'openid/openid.png) no-repeat left center #FFF;" type="text" name="openid_identifier" value="" size="50"/><input type="submit" value="Sign in" /></form></p>';
-               $templateHtml =  '<a href="<%identity%>" rel="nofollow" title="OpenID Profile"><img src="' . $CONF['PluginURL'] . 'openid/openid.png" border="0"/><%identity%></a>';
-               $templateAdminHtml = '<a href="<%identity%>" rel="nofollow" title="OpenID Profile"><img src="' . $CONF['PluginURL'] . 'openid/openid.png" border="0"/><%identity%></a>';
-
                $this->createOption('permitComment', 'Permit comments w/o login?', 'yesno', 'yes', '');
                $this->createOption('permitMail', 'Permit mail w/o login?', 'yesno', 'yes', '');
                
-               $this->createOption('LoginedHtml', 'Logined Template', 'textarea', $loginedHtml, '');
-               $this->createOption('NotLoginedHtml', 'Not Logined Template', 'textarea', $notLoginedHtml, '');
-               $this->createOption('TemplateHtml', 'Template html', 'textarea', $templateHtml, '');
-               $this->createOption('TemplateAdminHtml', 'Template admin html', 'textarea', $templateAdminHtml, '');
-               
                $this->createOption('CommentFormError', 'Error message (comment)', 'text', 'To submit comment, you need to sign-in to OpenID.', '');
                $this->createOption('MemberMailError', 'Error message  (mail form)', 'text', 'To send email, you need to sign-in to OpenID.', '');
                
@@ -169,25 +161,26 @@ class NP_OpenId extends NucleusPlugin {
                $this->createOption('debug', 'Debug mode ?', 'yesno', 'no');
                
                $this->createOption('enableLinkedWith', 'Enable local account linked with OpenID account ? ', 'yesno', 'no');
-               $this->createMemberOption('linkedWith', 'Linked with following account (hash value)', 'text', '');
+               $this->createMemberOption('linkedWith', 'Linked with following account', 'text', '');
        }
 
        function unInstall() {
+               sql_query('DROP TABLE '.sql_table('plugin_openid_assc'));
+               sql_query('DROP TABLE '.sql_table('plugin_openid_nonce'));
+               
                if ($this->getOption('dropdb') == 'yes'){
                        sql_query('DROP TABLE '.sql_table('plugin_openid'));
                        sql_query('DROP TABLE '.sql_table('plugin_openid_profile'));
                        sql_query('DROP TABLE '.sql_table('plugin_openid_comment'));
-                       sql_query('DROP TABLE '.sql_table('plugin_openid_assc'));
-                       sql_query('DROP TABLE '.sql_table('plugin_openid_nonce'));
                }
        }
        function doAction($type) {
                switch ($type) {
                        case 'verify' :
                                if( $this->login() ){
-                                       $this->_info('Authentication success: identity=' . $this->loginedUser['identity']);
-                                       $this->_doLoginLocal($this->loginedUser['identity']);
+                                       $this->_info('Authentication success: identity=' . $this->loggedinUser['identity']);
                                        $url = preg_replace('/action=logout&?/','', requestVar('return_url'));
+                                       $this->_doLoginLocal($this->loggedinUser['identity']);
                                        $this->_redirect( $url );
                                } else {
                                        $this->_info('Authentication failure');
@@ -203,21 +196,24 @@ class NP_OpenId extends NucleusPlugin {
                                $this->logout();
                                $this->_redirect( requestVar('url') );
                                break;
-                               
+                       
                        case 'updateProfile':
-                               if( $this->isLogined() ){
+                               $te = $this->_getTemplateEngine();
+                               $aVars = array();
+                               if( $this->isLoggedin() ){
                                        $profile = array();
-                                       $profile['nick'] = requestVar('nick');
-                                       $profile['email'] = requestVar('email');
-
-                                       if( requestVar('submit') )      
-                                               $this->_doUpdateProfile($profile);
+                                       $aVars['nick'] = requestVar('nick');
+                                       $aVars['email'] = requestVar('email');
+                                       
+                                       $this->_doUpdateProfile($aVars);
+                                       echo $te->fetchAndFill('updatesucceeded', $aVars, strtolower(__CLASS__));
                                } else {
-                                       $this->_info('Authentication failure');
-                                       return 'Authentication failure';
+                                       $aVars['message'] = 'You aren\'t logged in.';
+                                       echo $te->fetchAndFill('updatefailed', $aVars, strtolower(__CLASS__));
                                }
-                               break;
-                       default :
+                               exit;
+                               //break;
+                       default:
                                return 'Unknown action: '.$type;
                }
                return '';
@@ -277,17 +273,17 @@ class NP_OpenId extends NucleusPlugin {
                $query = sprintf('REPLACE INTO ' . sql_table('plugin_openid_profile') 
                                . ' ( identity, nick, email, ts ) '
                                . " values('%s', '%s', '%s', now())",
-                                mysql_real_escape_string( $this->loginedUser['identity']  ),
+                                mysql_real_escape_string( $this->loggedinUser['identity']  ),
                                 mysql_real_escape_string( $profile['nick']  ),
                                 mysql_real_escape_string( $profile['email'] )
                );
                sql_query($query);
 
-               $this->loginedUser['nick'] = $profile['nick'];
-               $this->loginedUser['email'] = $profile['email'];
+               $this->loggedinUser['nick'] = $profile['nick'];
+               $this->loggedinUser['email'] = $profile['email'];
 
-               setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loginedUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
-               setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loginedUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+               setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loggedinUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+               setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loggedinUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
        }
        
        function _doLoginLocal($name){
@@ -346,9 +342,9 @@ class NP_OpenId extends NucleusPlugin {
                return md5(uniqid(mt_rand()));
        }
        
-       function isLogined(){
+       function isLoggedin(){
                global $CONF;
-               if( $this->loginedUser ) return true;
+               if( $this->loggedinUser ) return true;
                
                $cookie = cookieVar($CONF['CookiePrefix'] . NP_OPENID_AUTH_COOKIE);
                if( ! $cookie ) return false;
@@ -360,8 +356,8 @@ class NP_OpenId extends NucleusPlugin {
                );
                $res = sql_query($query);
                if( @mysql_num_rows($res) > 0) {
-                       $this->loginedUser = mysql_fetch_assoc($res);
-                       $this->loginedUser = array_merge($this->loginedUser, unserialize($this->loginedUser['sreg']));
+                       $this->loggedinUser = mysql_fetch_assoc($res);
+                       $this->loggedinUser = array_merge($this->loggedinUser, unserialize($this->loggedinUser['sreg']));
                        return true;
                }
                return false;
@@ -410,12 +406,12 @@ class NP_OpenId extends NucleusPlugin {
                $res = sql_query($query);               
                
                if( @mysql_num_rows($res) > 0) {
-                       $this->loginedUser = mysql_fetch_assoc($res);
-                       $this->loginedUser = array_merge($this->loginedUser, unserialize($this->loginedUser['sreg']));
+                       $this->loggedinUser = mysql_fetch_assoc($res);
+                       $this->loggedinUser = array_merge($this->loggedinUser, unserialize($this->loggedinUser['sreg']));
                        
                        setcookie($CONF['CookiePrefix'] . NP_OPENID_AUTH_COOKIE , $cookie, 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
-                       setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loginedUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
-                       setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loginedUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+                       setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loggedinUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+                       setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loggedinUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
                        return true;
                }
                
@@ -424,7 +420,7 @@ class NP_OpenId extends NucleusPlugin {
                
        function logout(){
                global $CONF;
-               $this->loginedUser = null;
+               $this->loggedinUser = null;
                setcookie($CONF['CookiePrefix'] . NP_OPENID_AUTH_COOKIE, '', 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
                setcookie($CONF['CookiePrefix'] . 'comment_user', '', 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
                setcookie($CONF['CookiePrefix'] . 'comment_email', '', 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
@@ -437,7 +433,7 @@ class NP_OpenId extends NucleusPlugin {
             return;
         }
                
-               if( $this->isLogined() ){
+               if( $this->isLoggedin() ){
                        $data['externalauth']['result'] = true;
                        $data['externalauth']['plugin'] = $this->getName();
                }
@@ -452,25 +448,34 @@ class NP_OpenId extends NucleusPlugin {
                $manager->notify('ExternalAuth', array ('externalauth' => &$externalauth));
                if (isset($externalauth['result']) && $externalauth['result'] == true) return;
                
+               $te = $this->_getTemplateEngine();
                $aVars = array();
-               if( $this->isLogined() ){
-                       // Logined
+               $aVars['PluginURL'] = $CONF['PluginURL'];
+               
+               $te = $this->_getTemplateEngine();              
+               if( $this->isLoggedin() ){
+                       // Loggedin
                        $return_url = $CONF['PluginURL'] . 'openid/rd.php?action=rd&url='
                                                . urlencode( 'http://'.serverVar("HTTP_HOST") .serverVar("REQUEST_URI") );                      
-                       $aVars['url'] = htmlspecialchars( $return_url, ENT_QUOTES );
-                       $aVars['nick'] = $this->loginedUser['nick'];
-                       $aVars['email'] = $this->loginedUser['email'];
-                       $aVars['ts'] = $this->loginedUser['ts'];
-                       $aVars['profileUpdateUrl'] = $CONF['PluginURL'] . 'openid/profile.php';
-                       $aVars['identity'] = $this->loginedUser['identity'];
+                       $aVars['url'] = $return_url;
+                       $aVars['nick'] = $this->loggedinUser['nick'];
+                       $aVars['email'] = $this->loggedinUser['email'];
+                       $aVars['ts'] = $this->loggedinUser['ts'];
+                       $aVars['identity'] = $this->loggedinUser['identity'];
+                       $aVars['visible'] = $aVars['nick'] ? 'false' : 'true' ;
+                       
+                       $actionUrl = parse_url($CONF['ActionURL']);
+                       $aVars['updateUrl'] = $actionUrl['path'];
                        
-                       echo TEMPLATE::fill($this->getOption('LoginedHtml'), $aVars);
+                       echo $te->fetchAndFill('yui', $aVars, strtolower(__CLASS__));
+                       echo $te->fetchAndFill('loggedin', $aVars, strtolower(__CLASS__));
+                       echo $te->fetchAndFill('form', $aVars, strtolower(__CLASS__));
                } else {
-                       // not logined
+                       // Not loggedin
                        $aVars['url'] = $CONF['PluginURL'] . 'openid/rd.php?action=doauth&return_url='
                                                . urlencode( 'http://'.serverVar("HTTP_HOST") .serverVar("REQUEST_URI") );      
 
-                   echo TEMPLATE::fill($this->getOption('NotLoginedHtml'), $aVars);
+                       echo $te->fetchAndFill('notloggedin', $aVars, strtolower(__CLASS__));
                }               
        }
        
@@ -491,7 +496,7 @@ class NP_OpenId extends NucleusPlugin {
                $manager->notify('ExternalAuth', array ('externalauth' => &$externalauth));
                if (isset($externalauth['result']) && $externalauth['result'] == true) return;
 
-               $this->isLogined();
+               $this->isLoggedin();
        }
 
        function event_ValidateForm(&$data) {
@@ -504,11 +509,11 @@ class NP_OpenId extends NucleusPlugin {
                
                switch ($data['type']) {
                        case 'comment' :
-                               if( (! $this->isLogined() ) && $this->getOption('permitComment') == 'no' )
+                               if( (! $this->isLoggedin() ) && $this->getOption('permitComment') == 'no' )
                                        $data['error'] = $this->getOption('CommentFormError');
                                break;
                        case 'membermail' :
-                               if( (! $this->isLogined() ) && $this->getOption('permitMail') == 'no' )
+                               if( (! $this->isLoggedin() ) && $this->getOption('permitMail') == 'no' )
                                        $data['error'] = $this->getOption('MemberMailError');
                                break;
                        default :
@@ -520,22 +525,22 @@ class NP_OpenId extends NucleusPlugin {
                global $member;
                if( $member->isLoggedIn() ) return;
                
-               if( ! $this->isLogined() ) return;
-               $data['comment']['user'] = $this->loginedUser['nick'].' [OpenID]';
+               if( ! $this->isLoggedin() ) return;
+               $data['comment']['user'] = $this->loggedinUser['nick'].' [OpenID]';
        }
        
        function event_PostAddComment(&$data) {
                global $member;
                if( $member->isLoggedIn() ) return;
                
-               if( ! $this->isLogined() ) return;
+               if( ! $this->isLoggedin() ) return;
                global $itemid;
                $query = sprintf('INSERT INTO ' . sql_table('plugin_openid_comment') 
                                . '( cnumber, citem, identity, ts ) '
                                . "values('%s', '%s', '%s', now() )",
                                 mysql_real_escape_string( $data['commentid'] ),
                                 mysql_real_escape_string( intval($itemid) ),
-                                mysql_real_escape_string( $this->loginedUser['identity']  )
+                                mysql_real_escape_string( $this->loggedinUser['identity']  )
                );
                sql_query($query);
        }
@@ -549,17 +554,19 @@ class NP_OpenId extends NucleusPlugin {
        }
        
        function event_LoginSuccess(&$data) {
-               if( $this->isLogined() )
+               if( $this->isLoggedin() ){
                        $this->logout();
+               }
        }
        
        function event_Logout(&$data) {
-               if( $this->isLogined() )
+               if( $this->isLoggedin() ){
                        $this->logout();
+               }
        }
        
        function doTemplateCommentsVar(&$item, &$comment){
-               global $member;
+               global $member, $CONF;
                $itemid = intval($item['itemid']);
                if( ! $this->comments[$itemid] ){
                        $this->comments[$itemid]['cached'] = true;
@@ -578,14 +585,27 @@ class NP_OpenId extends NucleusPlugin {
                $cnumber = $comment['commentid'];
                if( $openIdComment = $this->comments[$itemid][$cnumber] ){
                        $aVars['identity'] =  $openIdComment['identity'];
+                       $aVars['PluginURL'] =  $CONF['PluginURL'];
+                       
                        $sreg = unserialize($openIdComment['sreg']);
                        if( is_array($sreg) )
                                $aVars = array_merge($aVars, $sreg);
                        
-                       if ( $member->isLoggedIn() )
-                               echo TEMPLATE::fill($this->getOption('TemplateAdminHtml'), $aVars);
-                       else
-                               echo TEMPLATE::fill($this->getOption('TemplateHtml'), $aVars);
+                       $te = $this->_getTemplateEngine();
+                       if ( $member->isLoggedIn() ){
+                               echo $te->fetchAndFill('admin', $aVars, strtolower(__CLASS__));
+                       } else {
+                               echo $te->fetchAndFill('user', $aVars, strtolower(__CLASS__));
+                       }
                }
        }
+       
+       function _getTemplateEngine(){
+               if( ! $this->templateEngine )
+                       $this->templateEngine =& new cles_Template(dirname(__FILE__).'/openid/template');
+                       
+               $this->templateEngine->defaultLang = 'english';
+               return $this->templateEngine;
+       }
+       
 }
index 74cfadd..72bb8a5 100644 (file)
@@ -1,7 +1,14 @@
-<!-- $Id: help.html,v 1.1 2008-02-03 13:11:22 hsur Exp $ -->
+<!-- $Id: help.html,v 1.2 2008-06-07 19:33:43 hsur Exp $ -->
 <h3>バージョン履歴</h3>
 
 <ul>
        <li>Version 1.0: (2008/02/03)</li>
        <li> [New] 初版公開</li>
 </ul>
+
+<ul>
+       <li>Version 1.1: (2008/06/07)</li>
+       <li> [Changed] テンプレートをプラグインオプションから、ファイルベースに変更</li>
+       <li> [Changed] Profileの変更にYUIを使うようにした</li>
+       <li> [Fixed] テーブルの作成に失敗する問題に対応</li>
+</ul>
index 1657831..7b9ba7d 100644 (file)
@@ -2,10 +2,10 @@
 // vim: tabstop=2:shiftwidth=2
 
 /**
-  * index.php ($Revision: 1.1 $)
+  * index.php ($Revision: 1.2 $)
   * 
   * by hsur ( http://blog.cles.jp/np_cles )
-  * $Id: index.php,v 1.1 2008-02-03 13:11:22 hsur Exp $
+  * $Id: index.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
 */
 
 /*
@@ -73,20 +73,22 @@ if (isset ($_POST['page'])) {
 }
 
 // create the admin area page
-$oPluginAdmin = new PluginAdmin('TypeKey');
+$oPluginAdmin = new PluginAdmin('OpenId');
 $oPluginAdmin->start();
 $fb =& new cles_Feedback($oPluginAdmin);
 
 // menu
 echo "<h2>OpenId menu</h2>\n";
 echo "<ul>\n";
-echo "<li><a href=\"".serverVar('PHP_SELF')."?page=report\"><span style=\"font-weight:bold; color:red\">" . $fb->getMenuStr() . "</span></a></li>\n";
+if( strpos(getLanguageName(), 'japanese') !== false )
+       echo "<li><a href=\"".serverVar('PHP_SELF')."?page=report\"><span style=\"font-weight:bold; color:red\">" . $fb->getMenuStr() . "</span></a></li>\n";
 echo "</ul>\n";
 
 //action
 switch ($action) {
        case 'report' :
-               $fb->printForm();
+               if( strpos(getLanguageName(), 'japanese') !== false )
+                       $fb->printForm();
                break;
 
        default :
diff --git a/trunk/NP_OpenId/openid/mkeuc.sh b/trunk/NP_OpenId/openid/mkeuc.sh
new file mode 100644 (file)
index 0000000..5f684ef
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+
+FILES=`find . -name '*japanese-utf8*'`
+
+for utf8file in $FILES
+do
+       eucfile=`echo $utf8file | sed 's/japanese-utf8/japanese-euc/'`
+       nkf -e -W -d < $utf8file > $eucfile
+done
diff --git a/trunk/NP_OpenId/openid/profile.php b/trunk/NP_OpenId/openid/profile.php
deleted file mode 100644 (file)
index 33f1f3c..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-// vim: tabstop=2:shiftwidth=2
-
-/**
-  * profile.php ($Revision: 1.1 $)
-  * 
-  * by hsur ( http://blog.cles.jp/np_cles )
-  * $Id: profile.php,v 1.1 2008-02-03 13:11:22 hsur Exp $
-*/
-
-/*
-  * Copyright (C) 2008 CLES. All rights reserved.
-  *
-  * This program is free software; you can redistribute it and/or
-  * modify it under the terms of the GNU General Public License
-  * as published by the Free Software Foundation; either version 2
-  * of the License, or (at your option) any later version.
-  * 
-  * This program is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  * GNU General Public License for more details.
-  * 
-  * You should have received a copy of the GNU General Public License
-  * along with this program; if not, write to the Free Software
-  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
-  * 
-  * In addition, as a special exception, cles( http://blog.cles.jp/np_cles ) gives
-  * permission to link the code of this program with those files in the PEAR
-  * library that are licensed under the PHP License (or with modified versions
-  * of those files that use the same license as those files), and distribute
-  * linked combinations including the two. You must obey the GNU General Public
-  * License in all respects for all of the code used other than those files in
-  * the PEAR library that are licensed under the PHP License. If you modify
-  * this file, you may extend this exception to your version of the file,
-  * but you are not obligated to do so. If you do not wish to do so, delete
-  * this exception statement from your version.
-*/
-
-$strRel = '../../../';
-require($strRel.'config.php');
-
-require($DIR_LIBS.'PLUGINADMIN.php');
-
-// create the admin area page
-$oPluginAdmin =& new PluginAdmin('OpenId');
-$err = $oPluginAdmin->plugin->doAction('updateProfile');
-$manager->checkTicket();
-
-if ( $err ) {
-       $oPluginAdmin->start();
-       echo "<h2>NP_OpenId Error: $err</h2>";
-       echo "<h3>Debug information</h3><pre>";
-       var_dump($_REQUEST);
-       echo '</pre>';
-       $oPluginAdmin->end();
-       exit;
-}
-
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-<head>
-<title>Update Profile - OpenID</title>
-</head>
-<body>
-<form action="profile.php" method="post">
-<fieldset>
-<legend>Your Profile</legend>
-<dl>
-
-<dt>Identity:</dt>
-<dd><?php echo $oPluginAdmin->plugin->loginedUser['identity']; ?></dd>
-
-<dt>Nickname:</dt>
-<dd>
-       <input type="text" value="<?php echo htmlspecialchars($oPluginAdmin->plugin->loginedUser['nick'], ENT_QUOTES); ?>" size="40" title="nick" name="nick"/>
-</dd>
-
-<dt>eMail:</dt>
-<dd>
-       <input type="text" value="<?php echo htmlspecialchars($oPluginAdmin->plugin->loginedUser['email'], ENT_QUOTES); ?>" size="40" title="email" name="email"/>
-</dd>
-
-<dt></dt>
-<dd><input type="submit" value="UpdateProfile" name="submit"/></dd>
-</dl>
-
-<?php $manager->addTicketHidden() ?>
-
-</fieldset>
-</form>
-
-</body>
-</html>
index 4b7d5ff..c6f01b9 100644 (file)
@@ -2,10 +2,10 @@
 // vim: tabstop=2:shiftwidth=2
 
 /**
-  * rd.php ($Revision: 1.1 $)
+  * rd.php ($Revision: 1.2 $)
   * 
   * by hsur ( http://blog.cles.jp/np_cles )
-  * $Id: rd.php,v 1.1 2008-02-03 13:11:22 hsur Exp $
+  * $Id: rd.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
 */
 
 /*
diff --git a/trunk/NP_OpenId/openid/template/np_openid/admin_english.html b/trunk/NP_OpenId/openid/template/np_openid/admin_english.html
new file mode 100644 (file)
index 0000000..9ebab4f
--- /dev/null
@@ -0,0 +1,3 @@
+<a href="{{identity|}}" rel="nofollow" title="OpenID Profile">
+       <img src="{{PluginURL|}}openid/openid.png" border="0"/>{{identity|}}
+</a>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/form_english.html b/trunk/NP_OpenId/openid/template/np_openid/form_english.html
new file mode 100644 (file)
index 0000000..e900491
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- Dialog -->
+<div class="yui-skin-sam">
+<div id="profile">
+       <div class="hd">Please enter your profile</div>
+       <div class="bd">
+               <form method="POST" action="{{updateUrl}}?action=plugin">
+                       <label for="nick">Nickname:</label><input type="textbox" name="nick" value="{{nick}}" />
+                       <div class="clear"></div>
+                       <label for="email">E-mail:</label><input type="textbox" name="email" value="{{email}}"/>
+                       <div class="clear"></div>
+                       <input type="hidden" name="name" value="OpenId">
+                       <input type="hidden" name="type" value="updateProfile">
+               </form>
+       </div>
+</div>
+</div>
+
+<!-- response -->
+<div id="resp"></div>
diff --git a/trunk/NP_OpenId/openid/template/np_openid/form_japanese-euc.html b/trunk/NP_OpenId/openid/template/np_openid/form_japanese-euc.html
new file mode 100644 (file)
index 0000000..2b9bf0d
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- Dialog -->
+<div class="yui-skin-sam">
+<div id="profile">
+       <div class="hd">¥×¥í¥Õ¥£¡¼¥ë¹¹¿·</div>
+       <div class="bd">
+               <form method="POST" action="{{updateUrl}}?action=plugin">
+                       <label for="nick">¤ªÌ¾Á°:</label><input type="textbox" name="nick" value="{{nick}}" />
+                       <div class="clear"></div>
+                       <label for="email">E-mail:</label><input type="textbox" name="email" value="{{email}}"/>
+                       <div class="clear"></div>
+                       <input type="hidden" name="name" value="OpenId">
+                       <input type="hidden" name="type" value="updateProfile">
+               </form>
+       </div>
+</div>
+</div>
+
+<!-- response -->
+<div id="resp"></div>
diff --git a/trunk/NP_OpenId/openid/template/np_openid/form_japanese-utf8.html b/trunk/NP_OpenId/openid/template/np_openid/form_japanese-utf8.html
new file mode 100644 (file)
index 0000000..4f1a849
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- Dialog -->
+<div class="yui-skin-sam">
+<div id="profile">
+       <div class="hd">プロフィール更新</div>
+       <div class="bd">
+               <form method="POST" action="{{updateUrl}}?action=plugin">
+                       <label for="nick">お名前:</label><input type="textbox" name="nick" value="{{nick}}" />
+                       <div class="clear"></div>
+                       <label for="email">E-mail:</label><input type="textbox" name="email" value="{{email}}"/>
+                       <div class="clear"></div>
+                       <input type="hidden" name="name" value="OpenId">
+                       <input type="hidden" name="type" value="updateProfile">
+               </form>
+       </div>
+</div>
+</div>
+
+<!-- response -->
+<div id="resp"></div>
diff --git a/trunk/NP_OpenId/openid/template/np_openid/loggedin_english.html b/trunk/NP_OpenId/openid/template/np_openid/loggedin_english.html
new file mode 100644 (file)
index 0000000..19876c9
--- /dev/null
@@ -0,0 +1,2 @@
+<p>Thanks for signing in. Now you can comment or send mail. (<a href="{{url|}}" rel="nofollow">Sign out</a>)<br />
+Your OpenID identity: <img src="{{PluginURL}}openid/openid.png" /><strong>{{identity|}}</strong> <button id="show">Update Profile</button></p>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-euc.html b/trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-euc.html
new file mode 100644 (file)
index 0000000..22d7ae4
--- /dev/null
@@ -0,0 +1,3 @@
+<p>OpenID¤Ç¥í¥°¥¤¥óÃæ¤Ç¤¹¡£(<a href="{{url|}}" rel="nofollow">¥í¥°¥¢¥¦¥È</a>)<br />
+OpenID identity: <img src="{{PluginURL}}openid/openid.png" /><strong>{{identity|}}</strong> <button id="show">¥×¥í¥Õ¥£¡¼¥ë¹¹¿·</button><br />
+¤â¤·¡¢Ì¾Á°¤äemail¤ÎÍ󤬶õÍó¤Î¾ì¹ç¤Ë¤Ï¥×¥í¥Õ¥£¡¼¥ë¹¹¿·¤«¤éÊѹ¹¤·¤Æ¤¯¤À¤µ¤¤¡£</p>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-utf8.html b/trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-utf8.html
new file mode 100644 (file)
index 0000000..c6f49c3
--- /dev/null
@@ -0,0 +1,3 @@
+<p>OpenIDでログイン中です。(<a href="{{url|}}" rel="nofollow">ログアウト</a>)<br />
+OpenID identity: <img src="{{PluginURL}}openid/openid.png" /><strong>{{identity|}}</strong> <button id="show">プロフィール更新</button><br />
+もし、名前やemailの欄が空欄の場合にはプロフィール更新から変更してください。</p>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/notloggedin_english.html b/trunk/NP_OpenId/openid/template/np_openid/notloggedin_english.html
new file mode 100644 (file)
index 0000000..9f88815
--- /dev/null
@@ -0,0 +1,5 @@
+<p>If you have a OpenID identity, you can sign in to use it here.<br />
+<form method="post" action="{{url|}}">
+       Identity URL: <input style="padding-left:20px; background:url({{PluginURL}}openid/openid.png) no-repeat left center #FFF;" type="text" name="openid_identifier" value="" size="50"/>
+       <input type="submit" value="Sign in" />
+</form></p>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-euc.html b/trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-euc.html
new file mode 100644 (file)
index 0000000..308de33
--- /dev/null
@@ -0,0 +1,5 @@
+<p>OpenID ¤ò»È¤Ã¤Æ¥í¥°¥¤¥ó¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£<br />
+<form method="post" action="{{url|}}">
+       Identity URL: <input style="padding-left:20px; background:url({{PluginURL}}openid/openid.png) no-repeat left center #FFF;" type="text" name="openid_identifier" value="" size="50"/>
+       <input type="submit" value="¥í¥°¥¤¥ó" />
+</form></p>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-utf8.html b/trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-utf8.html
new file mode 100644 (file)
index 0000000..bdb829c
--- /dev/null
@@ -0,0 +1,5 @@
+<p>OpenID を使ってログインすることができます。<br />
+<form method="post" action="{{url|}}">
+       Identity URL: <input style="padding-left:20px; background:url({{PluginURL}}openid/openid.png) no-repeat left center #FFF;" type="text" name="openid_identifier" value="" size="50"/>
+       <input type="submit" value="ログイン" />
+</form></p>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/updatefailed_english.html b/trunk/NP_OpenId/openid/template/np_openid/updatefailed_english.html
new file mode 100644 (file)
index 0000000..c27b311
--- /dev/null
@@ -0,0 +1 @@
+{{message|}}
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_english.html b/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_english.html
new file mode 100644 (file)
index 0000000..fba9c5a
--- /dev/null
@@ -0,0 +1,3 @@
+document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
+document.getElementById('nucleus_cf_email').value = '{{email}}';
+document.getElementById('resp').innerHTML = 'Thanks, your profile have been updated.';
diff --git a/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-euc.html b/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-euc.html
new file mode 100644 (file)
index 0000000..285912b
--- /dev/null
@@ -0,0 +1,3 @@
+document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
+document.getElementById('nucleus_cf_email').value = '{{email}}';
+document.getElementById('resp').innerHTML = '¥×¥í¥Õ¥£¡¼¥ë¤Î¹¹¿·¤¬´°Î»¤·¤Þ¤·¤¿¡£';
diff --git a/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-utf8.html b/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-utf8.html
new file mode 100644 (file)
index 0000000..ffbb4e5
--- /dev/null
@@ -0,0 +1,3 @@
+document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
+document.getElementById('nucleus_cf_email').value = '{{email}}';
+document.getElementById('resp').innerHTML = 'プロフィールの更新が完了しました。';
diff --git a/trunk/NP_OpenId/openid/template/np_openid/user_english.html b/trunk/NP_OpenId/openid/template/np_openid/user_english.html
new file mode 100644 (file)
index 0000000..9ebab4f
--- /dev/null
@@ -0,0 +1,3 @@
+<a href="{{identity|}}" rel="nofollow" title="OpenID Profile">
+       <img src="{{PluginURL|}}openid/openid.png" border="0"/>{{identity|}}
+</a>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/openid/template/np_openid/yui_english.html b/trunk/NP_OpenId/openid/template/np_openid/yui_english.html
new file mode 100644 (file)
index 0000000..f01ca24
--- /dev/null
@@ -0,0 +1,79 @@
+<!-- css -->
+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/fonts/fonts-min.css" />
+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/button/assets/skins/sam/button.css" />
+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/container/assets/skins/sam/container.css" />
+
+<!-- js --> 
+<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/utilities/utilities.js"></script> 
+<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/button/button-min.js"></script> 
+<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/container/container-min.js"></script>
+
+<script type="text/javascript">
+YAHOO.namespace("openid.container");
+
+function init() {
+       
+       // Define various event handlers for Dialog
+       var handleSubmit = function() {
+               document.getElementById("resp").innerHTML = '';
+               this.submit();
+       };
+       var handleCancel = function() {
+               document.getElementById("resp").innerHTML = '';
+               this.cancel();
+       };
+       var handleSuccess = function(o) {
+               var response = o.responseText;
+               //debug
+               //document.getElementById("resp").innerHTML = response;
+               eval(response);
+       };
+       var handleFailure = function(o) {
+               document.getElementById("resp").innerHTML = "Submission failed: " + o.status;
+       };
+
+       // Instantiate the Dialog
+       YAHOO.openid.container.profile = new YAHOO.widget.Dialog("profile", 
+                                                       { width : "30em",
+                                                         fixedcenter : true,
+                                                         visible : {{visible}}, 
+                                                         constraintoviewport : true,
+                                                         buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
+                                                                     { text:"Cancel", handler:handleCancel } ]
+                                                       });
+
+       // Validate the entries in the form to require that both first and last name are entered
+       YAHOO.openid.container.profile.validate = function() {
+               var data = this.getData();
+               if ( data.nick == "" ) {
+                       alert("Please enter your nickname.");
+                       return false;
+               } else {
+                       return true;
+               }
+       };
+
+       // Wire up the success and failure handlers
+       YAHOO.openid.container.profile.callback = { success: handleSuccess,
+                                                    failure: handleFailure };
+       
+       // Render the Dialog
+       YAHOO.openid.container.profile.render();
+
+       YAHOO.util.Event.addListener("show", "click", YAHOO.openid.container.profile.show, YAHOO.openid.container.profile, true);
+}
+YAHOO.util.Event.onDOMReady(init);
+
+(function(){
+       var onload_org = window.onload;
+       window.onload = function(){
+       if(onload_org) onload_org();
+       document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
+       document.getElementById('nucleus_cf_name').style.background = '#FFFFCC';
+       document.getElementById('nucleus_cf_name').readOnly = true;
+       document.getElementById('nucleus_cf_email').value = '{{email}}';
+       document.getElementById('nucleus_cf_email').style.background = '#FFFFCC';
+       document.getElementById('nucleus_cf_email').readOnly = true;
+       }
+})()
+</script>
\ No newline at end of file
diff --git a/trunk/NP_OpenId/sharedlibs/Auth/TypeKey.php b/trunk/NP_OpenId/sharedlibs/Auth/TypeKey.php
deleted file mode 100644 (file)
index 8013964..0000000
+++ /dev/null
@@ -1,496 +0,0 @@
-<?php
-// Copyright (c) 2004 Daiji Hriata All Right Reserved.
-// $Id: TypeKey.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
-// 
-// Auth_TypeKey Class
-//
-// Simple example:
-//
-// $tk = new Auth_TypeKey();
-// $tk->site_token('PUTYOURTYPEKEYTOKEN');
-// $tk->verifyTypeKey( $msg );
-// if (PEAR::isError($result)) {
-//     echo "INVALID";
-// } else {
-//     echo "VALID";
-// }
-
-require_once 'PEAR.php';
-
-/**
-* Error code
-*/
-define('AUTH_TYPEKEY_ERROR_INVALID', -1);
-define('AUTH_TYPEKEY_ERROR_TIMEOUT', -2);
-define('AUTH_TYPEKEY_ERROR_NOT_EXIST_BIGINT', -3);
-define('AUTH_TYPEKEY_ERROR_NOT_RETRIEVE_PUBKEY', -4);
-define('AUTH_TYPEKEY_ERROR_NOT_SET_SITE_TOKEN', -5);
-define('AUTH_TYPEKEY_ERROR_NOT_EXIST_GMP', -6);
-define('AUTH_TYPEKEY_ERROR_NOT_EXIST_BCMATH', -7);
-
-class Auth_TypeKey extends PEAR {
-       /**
-        * TypeKey Public_Key URLs
-        */
-       var $AUTH_TYPEKEY_BASEURL = 'https://www.typekey.com/t/typekey/';
-       var $AUTH_TYPEKEY_SIG_URL = 'http://www.typekey.com/extras/regkeys.txt';
-
-       /**
-        * TypeKey version
-        */
-       var $AUTH_TYPEKEY_VERSION = '1';
-
-       /**
-        * TypeKey requires site_token
-        */
-       var $AUTH_TYPEKEY_SITE_TOKEN = NULL;
-
-       /**
-        * time limitatino of TypeKey validation (sec)
-        */
-       var $AUTH_TYPEKEY_TIMEOUT = 300;
-
-       /**
-        * function to compute BIGINT
-        */
-       var $AUTH_TYPEKEY_BIGINT = '';
-
-       /**
-        * Initialize.
-        *
-        * @param array $init        parameters for initialize: 
-        *                          'version' : TypeKey version
-        *                          'token' : TypeKey Site Token
-        *
-        * @return mixed  true on success. PEAR_Error on failure.
-        * 
-        * @access public
-        */
-       function Auth_TypeKey($init = array ()) {
-               $this->PEAR();
-               if (!$this->_exist_bigint()) {
-                       return PEAR :: raiseError("BCMATH or GMP is required", AUTH_TYPEKEY_ERROR_NOT_EXIST_BIGINT);
-               }
-               if (array_key_exists('version', $init)) {
-                       $this->version($init['version']);
-               }
-               if (array_key_exists('token', $init)) {
-                       $this->site_token($init['token']);
-               }
-               return true;
-       }
-
-       /**
-        * Set/show TypeKey version
-        *
-        * @param  string $version   TypeKey version to set.  
-        *                           If nothing, just look.
-        *
-        * @return string            Current setting of TypeKey version
-        * 
-        * @access public
-        */
-       function version($version = NULL) {
-               if (!is_null($version)) {
-                       $this->AUTH_TYPEKEY_VERSION = $version;
-               }
-               return $this->AUTH_TYPEKEY_VERSION;
-       }
-
-       /**
-        * Set/show TypeKey Site Token
-        *
-        * @param  string $version        TypeKey Site Token to set.  
-        *                                if nothing, just look.
-        *
-        * @return mixed  string          Current setting of TypeKey Site Token 
-        *                                if set. PEAR_Error if not set.
-        * 
-        * @access public
-        */
-       function site_token($token = NULL) {
-               if (!is_null($token)) {
-                       $this->AUTH_TYPEKEY_SITE_TOKEN = $token;
-               }
-               if (is_null($this->AUTH_TYPEKEY_SITE_TOKEN)) {
-                       return PEAR :: raiseError('SITE TOKEN is not set.', AUTH_TYPEKEY_ERROR_NOT_SET_SITE_TOKEN);
-               }
-               return $this->AUTH_TYPEKEY_SITE_TOKEN;
-       }
-
-       /**
-        * Verify the TypeKey authentication requirement
-        *
-        * @param  array $query        TypeKey Site Token to set.  if nothing, just look.
-        * @param  array $key          Public Keys of TypeKey service.  if NULL, using preset URLs.
-        *
-        * @return mixed  true on success.  PEAR_Error on failure.
-        * 
-        * @access public
-        */
-       function verifyTypeKey($query, $key = NULL) {
-                       // Retrieve key per each request.
-                               if (is_null($key)) {
-                       $key = $this->_fetch_key('');
-                       if ($key == false) {
-                               return PEAR :: raiseError('Cannot get pubkey.', AUTH_TYPEKEY_ERROR_NOT_RETRIEVE_PUBKEY);
-                       }
-               }
-
-               foreach (array ('email', 'name', 'nick', 'ts', 'sig') as $i) {
-                       $$i = $query[$i];
-               }
-
-               // The nickname field is sent as url_encoded utf-8 data(like %xx%xx... )
-               // from Tyepkey but signed before encoded.  Usually all fields are
-               // decoded by PHP automatically, but it might cause invalid_error,
-               // especially using with mb_stirng.  rawurlencoded strings is
-               // better for that case.  It can be gotten from QUERY_STRING
-               $nick = rawurldecode($nick);
-
-               switch ($this->version()) {
-                       case '1' :
-                               $message = implode('::', array ($email, $name, $nick, $ts));
-                               break;
-                       case '1.1' :
-                               $token = $this->site_token();
-                               if (PEAR :: isError($token)) {
-                                       return $token;
-                               }
-                               $message = implode('::', array ($email, $name, $nick, $ts, $token));
-                               break;
-                       default :
-                               // default is version '1'
-                               $message = implode('::', array ($email, $name, $nick, $ts));
-                               break;
-               }
-
-               if ($this->_dsa_verify($message, $sig, $key) == true) {
-                       if (time() - $ts > $this->AUTH_TYPEKEY_TIMEOUT) {
-                               return PEAR :: raiseError("Timestamp from TypeKey is too old", AUTH_TYPEKEY_ERROR_TIMEOUT);
-                       }
-                       return true;
-               } else {
-                       return PEAR :: raiseError("Invalid signature", AUTH_TYPEKEY_ERROR_INVALID);
-               }
-       }
-
-       /* Generate URL to link to Sign-In using TypeKey service
-        * 
-        * @param  string  $return_url        URL to be returned after authentication
-        * @param  boolean $need_email        if true, require email address of user.
-        *
-        * @return mixed   string  $url                URL to link TypeKey Sign-In
-        *                 PEAR_Error on failure
-        *
-        * @access public
-        */
-
-       function urlSignIn($return_url, $need_email = false, $options = array ()) {
-               $token = $this->site_token();
-               if (PEAR :: isError($token)) {
-                       return $token;
-               }
-
-               $option_query = '';
-               foreach ($options as $key => $value) {
-                       $option_query .= '&'.$key.'='.$value;
-               }
-
-               $url = $this->AUTH_TYPEKEY_BASEURL;
-               $url .= "login?t=".$token;
-               $url .= (($need_email == 1) ? "&need_email=1" : '');
-               $url .= (($this->version()) ? "&v=".$this->version() : '');
-               $url .= $option_query;
-               $url .= "&_return=".rawurlencode($return_url);
-               return $url;
-       }
-
-       /* Generate URL to link to sign out
-        * 
-        * @param  string  $return_url        URL to be returned after authentication
-        *
-        * @return string  $url                URL to link TypeKey sign out.
-        *
-        * @access public
-        */
-       function urlSignOut($return_url) {
-               $url = $this->AUTH_TYPEKEY_BASEURL;
-               $url .= "logout?";
-               $url .= "_return=".rawurlencode($return_url);
-               return $url;
-       }
-
-       /* 
-        * Fetch keys of TypeKey service
-        * 
-        * @param  string $url        URL of TypeKey Public Keys
-        *
-        * @return mixed  array of Public keys of TypeKey services
-        *                false on error
-        *
-        * @access private
-        */
-       function _fetch_key($url = '') {
-               if ($url == '') {
-                       $url = $this->AUTH_TYPEKEY_SIG_URL;
-               }
-               $lines = @ file($url);
-               if ($lines == false) {
-                       return false;
-               }
-               $key_raw = explode(" ", $lines[0]);
-
-               foreach ($key_raw as $e) {
-                       list ($key_index, $key_value) = explode("=", $e);
-                       $key[$key_index] = trim($key_value);
-               }
-               return $key;
-       }
-
-       /* 
-        * check existing bigint function
-        * 
-        * @return boolean  true if available bigint funciton gmp or bcmath
-        *                  false if not available.
-        *
-        * @access private
-        *
-        */
-       function _exist_bigint() {
-               $extension_bigint = array ('bcmath', 'gmp');
-               $exist_bigint = false;
-               foreach ($extension_bigint as $ext) {
-                       if (extension_loaded($ext)) {
-                               $exist_bigint = true;
-                               $this->AUTH_TYPEKEY_BIGINT = $ext;
-                       }
-               }
-               return $exist_bigint;
-       }
-
-       /* 
-        * dsa verification
-        * 
-        * @param  string $message Message to verify
-        * @param  string @sig     Sign for the message, two keys are 
-        *                         included separeted by ':' (colon)
-        * @param  array  $key     ublic keys for the signiture
-        *
-        * @access private
-        *
-        */
-       function _dsa_verify($message, $sig, $key) {
-               $func = $this->AUTH_TYPEKEY_BIGINT;
-               $func = '_dsa_verify_'.$func;
-               return $this-> $func ($message, $sig, $key);
-       }
-
-       /* 
-        * dsa verification using gmp
-        * 
-        * @param  string $message Message to verify
-        * @param  string @sig     Sign for the message, two keys are 
-        *                         included separeted by ':' (colon)
-        * @param  array  $key     ublic keys for the signiture
-        *
-        * @access private
-        *
-        */
-       function _dsa_verify_gmp($message, $sig, $key) {
-               list ($r_sig, $s_sig) = explode(":", $sig);
-               $r_sig = base64_decode($r_sig);
-               $s_sig = base64_decode($s_sig);
-
-               foreach ($key as $i => $v) {
-                       $key[$i] = gmp_init($v);
-               }
-               $s1 = gmp_init($this->_gmp_bindec($r_sig));
-               $s2 = gmp_init($this->_gmp_bindec($s_sig));
-
-               $w = gmp_invert($s2, $key['q']);
-               $hash_m = gmp_init('0x'.sha1($message));
-
-               $u1 = gmp_mod(gmp_mul($hash_m, $w), $key['q']);
-               $u2 = gmp_mod(gmp_mul($s1, $w), $key['q']);
-
-               $v = gmp_mod(gmp_mod(gmp_mul(gmp_powm($key['g'], $u1, $key['p']), gmp_powm($key['pub_key'], $u2, $key['p'])), $key['p']), $key['q']);
-               if (gmp_cmp($v, $s1) == 0) {
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       /* 
-        * gmp_bindec
-        * 
-        * @param  string $bin  binary data
-        *
-        * @return gmp    value of $bin
-        *
-        * @access private
-        */
-       function _gmp_bindec($bin) {
-               $dec = gmp_init(0);
-               while (strlen($bin)) {
-                       $i = ord(substr($bin, 0, 1));
-                       $dec = gmp_add(gmp_mul($dec, 256), $i);
-                       $bin = substr($bin, 1);
-               }
-               return gmp_strval($dec);
-       }
-
-       /* 
-        * dsa verification using bcmath
-        * 
-        * @param  string $message Message to verify
-        * @param  string @sig     Sign for the message, two keys are 
-        *                         included separeted by ':' (colon)
-        * @param  array  $key     ublic keys for the signiture
-        *
-        * @access private
-        *
-        */
-       function _dsa_verify_bcmath($message, $sig, $key) {
-               list ($r_sig, $s_sig) = explode(":", $sig);
-
-               $r_sig = base64_decode($r_sig);
-               $s_sig = base64_decode($s_sig);
-
-               $s1 = $this->_bc_bindec($r_sig);
-               $s2 = $this->_bc_bindec($s_sig);
-
-               $w = $this->_bc_invert($s2, $key['q']);
-               $hash_m = $this->_bc_hexdec(sha1($message));
-
-               $u1 = bcmod(bcmul($hash_m, $w), $key['q']);
-               $u2 = bcmod(bcmul($s1, $w), $key['q']);
-
-               $v = bcmod(bcmod(bcmul(bcmod($this->_bc_powmod($key['g'], $u1, $key['p']), $key['p']), bcmod($this->_bc_powmod($key['pub_key'], $u2, $key['p']), $key['p'])), $key['p']), $key['q']);
-
-               if (bccomp($v, $s1) == 0) {
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       /* 
-        * _bc_hexdec
-        * 
-        * @param  string $hex
-        *
-        * @return string dec converted from $hex
-        *
-        * @access private
-        */
-       function _bc_hexdec($hex) {
-               $dec = "0";
-               while (strlen($hex)) {
-                       $i = HexDec(substr($hex, 0, 4));
-                       $dec = bcadd(bcmul($dec, 65536), $i);
-                       $hex = substr($hex, 4);
-               }
-               return $dec;
-       }
-
-       /* 
-        * _bc_bindec
-        * 
-        * @param  string $bin
-        *
-        * @return string dec converted from $bin
-        *
-        * @access private
-        */
-       function _bc_bindec($bin) {
-               $dec = "0";
-               while (strlen($bin)) {
-                       $i = ord(substr($bin, 0, 1));
-                       $dec = bcadd(bcmul($dec, 256), $i);
-                       $bin = substr($bin, 1);
-               }
-               return $dec;
-       }
-
-       /* 
-        * _bc_invert
-        * 
-        * @param  string $x, $y
-        *
-        * @return string inverse $x and $y
-        *
-        * @access private
-        */
-       function _bc_invert($x, $y) {
-               while (bccomp($x, 0) < 0) {
-                       $x = bcadd($x, $y);
-               }
-               $r = $this->_bc_exgcd($x, $y);
-               if ($r[2] == 1) {
-                       $a = $r[0];
-                       while (bccomp($a, 0) < 0) {
-                               $a = bcadd($a, $y);
-                       }
-                       return $a;
-               } else {
-                       return false;
-               }
-       }
-
-       /* 
-        * _bc_exgcd
-        * 
-        * @param  string $x, $y
-        *
-        * @return string extended gcd of $x and $y
-        *
-        * @access private
-        */
-       function _bc_exgcd($x, $y) {
-               $a0 = 1;
-               $a1 = 0;
-               $b0 = 0;
-               $b1 = 1;
-               $c = 0;
-               while ($y > 0) {
-                       $q = bcdiv($x, $y, 0);
-                       $r = bcmod($x, $y);
-                       $x = $y;
-                       $y = $r;
-                       $a2 = bcsub($a0, bcmul($q, $a1));
-                       $b2 = bcsub($b0, bcmul($q, $b1));
-                       $a0 = $a1;
-                       $a1 = $a2;
-                       $b0 = $b1;
-                       $b1 = $b2;
-               }
-               return (array ($a0, $b0, $x));
-       }
-
-       /* 
-        * _bc_powmod
-        * 
-        * @param  string $x, $y, $mod
-        *
-        * @return string bcmod(bcpow($x, $y), $mod)
-        *
-        * @access private
-        */
-       function _bc_powmod($x, $y, $mod) {
-               if (function_exists('bcpowmod')) {
-                       return bcpowmod($x, $y, $mod);
-               } else {
-                       if (bccomp($y, 1) == 0) {
-                               return bcmod($x, $mod);
-                       } else
-                               if (bcmod($y, 2) == 0) {
-                                       return bcmod(bcpow($this->_bc_powmod($x, bcdiv($y, 2), $mod), 2), $mod);
-                               } else {
-                                       return bcmod(bcmul($x, $this->_bc_powmod($x, bcsub($y, 1), $mod)), $mod);
-                               }
-               }
-       }
-}
-?>
index 6e447d0..3d90fdf 100644 (file)
@@ -2,10 +2,10 @@
 // vim: tabstop=2:shiftwidth=2
 
 /**
-  * Feedback.php ($Revision: 1.1 $)
+  * Feedback.php ($Revision: 1.2 $)
   * 
   * by hsur ( http://blog.cles.jp/np_cles )
-  * $Id: Feedback.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
+  * $Id: Feedback.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
 */
 
 /*
@@ -55,14 +55,31 @@ class cles_Feedback {
                echo "<h2>動作確認/不具合報告</h2>";
                echo '<p>下記より、作者への動作確認/不具合の報告を行うことができます。</p>';
 
+               // js
+               echo '<script langage="JavaScript">
+//<![CDATA[
+function selectall(){
+       var elements = document.getElementsByTagName(\'input\');
+       for( var i=0; i < elements.length; i++){
+               var e = elements[i];
+               if( e.type == \'checkbox\' ){
+                       e.checked = true;
+               }
+       }
+       return false;
+}
+//]]>
+</script>';
+               
                echo "<h3>収集する情報と公開について</h3>";
                echo '<p>デフォルトで必要最低限の環境情報(赤字のもの)を開発者のサーバへ送信します。<br />
                                                        <span style="font-weight:bold; color:red">差し支えない範囲で環境情報の提供にご協力ください。</span></p>
                                                        <p>※ 収集した情報は統計処理、及びプラグインのBugFixのみに利用されます。また統計処理した結果については公表することがあります。</p>';
-
+               echo '<p><a href="#" onclick="javascript:selectall();return false;">全て送信する場合はここをクリック</a></p>';
+               
                echo "<h3>サイト固有コードについて</h3>";
-               echo '<p>動作報告の重複を取り除くため、管理画面のURLのmd5を計算したものを送信しています。この情報から管理画面のURLを復元することはできないようになっています。<a href="http://computers.yahoo.co.jp/dict/security/hash/677.html" target="_blank">md5の解説についてはこちらをご覧ください。(Yahoo!コンピュータ用語辞典)</a></p>';
-
+               echo '<p>動作報告の重複を取り除くため、管理画面のURLのmd5を計算したものを送信しています。この情報から管理画面のURLを復元することはできないようになっています。<a href="http://e-words.jp/w/MD5.html" target="_blank">md5の解説についてはこちらをご覧ください。(e-WordsIT用語辞典)</a></p>';
+               
                // form 
                echo '<form method="post" action="http://blog.cles.jp/support/report.php">' . "\n";
 
@@ -71,20 +88,24 @@ class cles_Feedback {
                echo "<tr>\n";
                echo "<th>項目の説明</th>\n";
                echo "<th>送信される値</th>\n";
-               echo "<th>送信する</th>\n";
+               echo "<th><a href=\"#\" onclick=\"javascript:selectall();return false;\">全てチェック</a></th>\n";
                echo "</tr>\n";
 
                $res = sql_query("show variables like 'version'");
                $assoc = mysql_fetch_assoc($res);
                $mysqlVersion = $assoc['Value'];
-               $gdinfo = gd_info();
+               
+               if( function_exists('gd_info') )
+                       $gdinfo = @gd_info();
+               else
+                       $gdinfo['GD Version'] = 'GD is not supported';
 
                global $CONF;
 
                $this->_printtr('siteid', 'サイトの固有コード', md5(trim($CONF['AdminURL'])));
                $this->_printtr('plugin_name', 'プラグイン名', $this->oPluginAdmin->plugin->getName());
                $this->_printtr('plugin_version', 'プラグインのバージョン', $this->oPluginAdmin->plugin->getVersion());
-               $this->_printtr('plugin_info', 'プラグインの情報', $extra, true);
+               $this->_printtr('plugin_info', '追加情報', $extra, true);
                $this->_printtr('nucleus_version', 'Nucleusのバージョン', $nucleus['version'], true);
                $this->_printtr('nucleus_charset', 'Nucleusのキャラクタセット', _CHARSET);
                $this->_printtr('php_version', 'PHPのバージョン', PHP_VERSION, true);
@@ -96,8 +117,8 @@ class cles_Feedback {
                $this->_printtr('mysql_version', 'MySQLのバージョン', $mysqlVersion, true);
 
                echo "<tr>\n";
-               echo "<td>このプラグインは機能しましたか?</td>\n";
-               echo '<td colspan="2"><input type="radio" name="user_intention" value="ok" />はい <br/> <input type="radio" name="intention" value="ng" />いいえ'."</td>\n";
+               echo "<td colspan=\"2\">このプラグインは機能しましたか?</td>\n";
+               echo '<td><input type="radio" name="user_intention" value="ok" />はい <br/> <input type="radio" name="intention" value="ng" />いいえ'."</td>\n";
                echo "</tr>\n";
 
                echo "<tr>\n";
@@ -111,11 +132,11 @@ class cles_Feedback {
                echo "</tr>\n";
                
                echo "<tr>\n";
-               echo "<td>リンク集作成の際、リンクをはらせていただけますか?</td>\n";
-               echo '<td colspan="2"><input type="radio" name="user_disclose" value="yes" />はい <br/> <input type="radio" name="intention" value="no" />いいえ'."</td>\n";
+               echo "<td colspan=\"2\">リンク集作成の際、リンクをはらせていただけますか?</td>\n";
+               echo '<td><input type="radio" name="user_disclose" value="yes" />はい <br/> <input type="radio" name="intention" value="no" />いいえ'."</td>\n";
                echo "</tr>\n";
 
-               echo '<tr><td colspan="3"><div align="right"><input type="submit" name="submit" value="動作確認を送信する" /></div></td></tr>';
+               echo '<tr><td colspan="3"><div align="right"><a href="#" onclick="javascript:selectall();return false;">全てチェック</a> <input type="submit" name="submit" value="動作確認を送信する" /></div></td></tr>';
                echo "</table>\n";
                echo "</form>\n";
                
@@ -134,14 +155,15 @@ class cles_Feedback {
                } else {
                        echo '<td><span style="font-weight:bold; color:red">'.$desc."</span></td>\n";
                        echo '<td><span style="font-weight:bold; color:red">'.htmlspecialchars($value)."</span></td>\n";
-                       echo '<td><span style="font-weight:bold; color:red"><input type="checkbox" name="dummy" value="dummy" checked="checked" disabled="disabled" /><input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" /></span></td>'."\n";
+                       echo '<td>必須<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" readonly="readonly" checked="checked"/></td>'."\n";
                }
                echo "</tr>\n";
        }
        
        function _supportedImageTypes() {
+               if( !function_exists('gd_info') ) return "";
+               
                $aSupportedTypes = array ();
-       
                $aPossibleImageTypeBits = array (IMG_GIF => 'GIF', IMG_JPG => 'JPG', IMG_PNG => 'PNG', IMG_WBMP => 'WBMP');
        
                foreach ($aPossibleImageTypeBits as $iImageTypeBits => $sImageTypeString) {
index 136bebb..55f4a14 100644 (file)
@@ -1,10 +1,10 @@
 <?php
 
 /**
- * MySQLStoreForNucleus.php ($Revision: 1.1 $)
+ * MySQLStoreForNucleus.php ($Revision: 1.2 $)
  * based on Auth_OpenID_SQLStore
  * by hsur ( http://blog.cles.jp/np_cles )
- * $Id: SQLStoreForNucleus.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
+ * $Id: SQLStoreForNucleus.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
  */
 
 /*
@@ -100,7 +100,7 @@ class cles_SQLStoreForNucleus extends Auth_OpenID_OpenIDStore {
     {
         $this->sql['nonce_table'] =
             "CREATE TABLE ".$this->nonces_table_name." (\n".
-            "  server_url VARCHAR(2047),\n".
+            "  server_url VARBINARY(255),\n".
             "  timestamp INTEGER,\n".
             "  salt CHAR(40),\n".
             "  UNIQUE (server_url(150), timestamp, salt)\n".
@@ -108,7 +108,7 @@ class cles_SQLStoreForNucleus extends Auth_OpenID_OpenIDStore {
 
         $this->sql['assoc_table'] =
             "CREATE TABLE ".$this->associations_table_name." (\n".
-            "  server_url BLOB,\n".
+            "  server_url VARBINARY(255),\n".
             "  handle VARCHAR(255),\n".
             "  secret BLOB,\n".
             "  issued INTEGER,\n".
index 985b2e9..bdfe0de 100644 (file)
@@ -2,10 +2,10 @@
 // vim: tabstop=2:shiftwidth=2
 
 /**
-  * Template.php ($Revision: 1.1 $)
+  * Template.php ($Revision: 1.2 $)
   * 
   * by hsur ( http://blog.cles.jp/np_cles )
-  * $Id: Template.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
+  * $Id: Template.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
 */
 
 /*
@@ -73,4 +73,9 @@ class cles_Template {
                        return preg_replace($this->defalutPattern, '("$2") ? htmlspecialchars($values["$1"], ENT_QUOTES) : $values["$1"]', $template);
                return preg_replace($this->defalutPattern, 'isset($values["$1"]) ? ("$2" ? htmlspecialchars($values["$1"], ENT_QUOTES) : $values["$1"]) : "{{$1}}" ', $template);
        }
+       
+       function fetchAndFill($name, $values, $dir = null, $suffix = 'html', $default = null){
+               $tpl = $this->fetch($name, $dir, $suffix);
+               return $this->fill($tpl, $values, $default);
+       }
 }