• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revision944d24205b70c1aeed901f90601d454690b11a27 (tree)
Time2008-06-08 04:33:43
Authorhsur <hsur@1ca2...>
Commiterhsur

Log Message

v1.1.0

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@627 1ca29b6e-896d-4ea0-84a5-967f57386b96

Change Summary

Incremental Difference

--- a/trunk/NP_OpenId/NP_OpenId.php
+++ b/trunk/NP_OpenId/NP_OpenId.php
@@ -2,9 +2,9 @@
22 // vim: tabstop=2:shiftwidth=2
33
44 /**
5- * NP_OpenId ($Revision: 1.1 $)
5+ * NP_OpenId ($Revision: 1.2 $)
66 * by hsur ( http://blog.cles.jp/np_cles )
7- * $Id: NP_OpenId.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
7+ * $Id: NP_OpenId.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
88 *
99 */
1010
@@ -36,6 +36,7 @@
3636 * but you are not obligated to do so. If you do not wish to do so, delete
3737 * this exception statement from your version.
3838 */
39+
3940 // ParanoidHTTPFetcher bug?
4041 define('Auth_Yadis_CURL_OVERRIDE', '1');
4142
@@ -44,10 +45,11 @@ define('NP_OPENID_COOKIE', 'EXTAUTH');
4445
4546 // libs
4647 require(dirname(__FILE__).'/sharedlibs/sharedlibs.php');
47-require_once "Auth/OpenID/Consumer.php";
48-require_once "cles/SQLStoreForNucleus.php";
49-require_once "Auth/OpenID/SReg.php";
50-require_once "Auth/OpenID/PAPE.php";
48+require_once 'cles/Template.php';
49+require_once 'Auth/OpenID/Consumer.php';
50+require_once 'cles/SQLStoreForNucleus.php';
51+require_once 'Auth/OpenID/SReg.php';
52+require_once 'Auth/OpenID/PAPE.php';
5153
5254 class NP_OpenId extends NucleusPlugin {
5355
@@ -61,7 +63,7 @@ class NP_OpenId extends NucleusPlugin {
6163 return 'http://blog.cles.jp/np_cles/category/31/subcatid/21';
6264 }
6365 function getVersion() {
64- return '1.0.0';
66+ return '1.1.0';
6567 }
6668 function getMinNucleusVersion() {
6769 return 330;
@@ -82,7 +84,7 @@ class NP_OpenId extends NucleusPlugin {
8284 );
8385 }
8486 function getDescription() {
85- return '[$Revision: 1.1 $]<br />Adds OpenID authentication to anonymous comment, to prevent robots from spamming.';
87+ return '[$Revision: 1.2 $]<br />Adds OpenID authentication to anonymous comment, to prevent robots from spamming.';
8688 }
8789 function supportsFeature($what) {
8890 switch ($what) {
@@ -108,7 +110,7 @@ class NP_OpenId extends NucleusPlugin {
108110
109111 $this->store = new cles_SQLStoreForNucleus();
110112 $this->consumer = new Auth_OpenID_Consumer($this->store);
111- $this->loginedUser = null;
113+ $this->loggedinUser = null;
112114 $this->comments = array();
113115 }
114116
@@ -149,19 +151,9 @@ class NP_OpenId extends NucleusPlugin {
149151 );
150152
151153 global $CONF;
152- $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>";
153- $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>';
154- $templateHtml = '<a href="<%identity%>" rel="nofollow" title="OpenID Profile"><img src="' . $CONF['PluginURL'] . 'openid/openid.png" border="0"/><%identity%></a>';
155- $templateAdminHtml = '<a href="<%identity%>" rel="nofollow" title="OpenID Profile"><img src="' . $CONF['PluginURL'] . 'openid/openid.png" border="0"/><%identity%></a>';
156-
157154 $this->createOption('permitComment', 'Permit comments w/o login?', 'yesno', 'yes', '');
158155 $this->createOption('permitMail', 'Permit mail w/o login?', 'yesno', 'yes', '');
159156
160- $this->createOption('LoginedHtml', 'Logined Template', 'textarea', $loginedHtml, '');
161- $this->createOption('NotLoginedHtml', 'Not Logined Template', 'textarea', $notLoginedHtml, '');
162- $this->createOption('TemplateHtml', 'Template html', 'textarea', $templateHtml, '');
163- $this->createOption('TemplateAdminHtml', 'Template admin html', 'textarea', $templateAdminHtml, '');
164-
165157 $this->createOption('CommentFormError', 'Error message (comment)', 'text', 'To submit comment, you need to sign-in to OpenID.', '');
166158 $this->createOption('MemberMailError', 'Error message (mail form)', 'text', 'To send email, you need to sign-in to OpenID.', '');
167159
@@ -169,25 +161,26 @@ class NP_OpenId extends NucleusPlugin {
169161 $this->createOption('debug', 'Debug mode ?', 'yesno', 'no');
170162
171163 $this->createOption('enableLinkedWith', 'Enable local account linked with OpenID account ? ', 'yesno', 'no');
172- $this->createMemberOption('linkedWith', 'Linked with following account (hash value)', 'text', '');
164+ $this->createMemberOption('linkedWith', 'Linked with following account', 'text', '');
173165 }
174166
175167 function unInstall() {
168+ sql_query('DROP TABLE '.sql_table('plugin_openid_assc'));
169+ sql_query('DROP TABLE '.sql_table('plugin_openid_nonce'));
170+
176171 if ($this->getOption('dropdb') == 'yes'){
177172 sql_query('DROP TABLE '.sql_table('plugin_openid'));
178173 sql_query('DROP TABLE '.sql_table('plugin_openid_profile'));
179174 sql_query('DROP TABLE '.sql_table('plugin_openid_comment'));
180- sql_query('DROP TABLE '.sql_table('plugin_openid_assc'));
181- sql_query('DROP TABLE '.sql_table('plugin_openid_nonce'));
182175 }
183176 }
184177 function doAction($type) {
185178 switch ($type) {
186179 case 'verify' :
187180 if( $this->login() ){
188- $this->_info('Authentication success: identity=' . $this->loginedUser['identity']);
189- $this->_doLoginLocal($this->loginedUser['identity']);
181+ $this->_info('Authentication success: identity=' . $this->loggedinUser['identity']);
190182 $url = preg_replace('/action=logout&?/','', requestVar('return_url'));
183+ $this->_doLoginLocal($this->loggedinUser['identity']);
191184 $this->_redirect( $url );
192185 } else {
193186 $this->_info('Authentication failure');
@@ -203,21 +196,24 @@ class NP_OpenId extends NucleusPlugin {
203196 $this->logout();
204197 $this->_redirect( requestVar('url') );
205198 break;
206-
199+
207200 case 'updateProfile':
208- if( $this->isLogined() ){
201+ $te = $this->_getTemplateEngine();
202+ $aVars = array();
203+ if( $this->isLoggedin() ){
209204 $profile = array();
210- $profile['nick'] = requestVar('nick');
211- $profile['email'] = requestVar('email');
212-
213- if( requestVar('submit') )
214- $this->_doUpdateProfile($profile);
205+ $aVars['nick'] = requestVar('nick');
206+ $aVars['email'] = requestVar('email');
207+
208+ $this->_doUpdateProfile($aVars);
209+ echo $te->fetchAndFill('updatesucceeded', $aVars, strtolower(__CLASS__));
215210 } else {
216- $this->_info('Authentication failure');
217- return 'Authentication failure';
211+ $aVars['message'] = 'You aren\'t logged in.';
212+ echo $te->fetchAndFill('updatefailed', $aVars, strtolower(__CLASS__));
218213 }
219- break;
220- default :
214+ exit;
215+ //break;
216+ default:
221217 return 'Unknown action: '.$type;
222218 }
223219 return '';
@@ -277,17 +273,17 @@ class NP_OpenId extends NucleusPlugin {
277273 $query = sprintf('REPLACE INTO ' . sql_table('plugin_openid_profile')
278274 . ' ( identity, nick, email, ts ) '
279275 . " values('%s', '%s', '%s', now())",
280- mysql_real_escape_string( $this->loginedUser['identity'] ),
276+ mysql_real_escape_string( $this->loggedinUser['identity'] ),
281277 mysql_real_escape_string( $profile['nick'] ),
282278 mysql_real_escape_string( $profile['email'] )
283279 );
284280 sql_query($query);
285281
286- $this->loginedUser['nick'] = $profile['nick'];
287- $this->loginedUser['email'] = $profile['email'];
282+ $this->loggedinUser['nick'] = $profile['nick'];
283+ $this->loggedinUser['email'] = $profile['email'];
288284
289- setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loginedUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
290- setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loginedUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
285+ setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loggedinUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
286+ setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loggedinUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
291287 }
292288
293289 function _doLoginLocal($name){
@@ -346,9 +342,9 @@ class NP_OpenId extends NucleusPlugin {
346342 return md5(uniqid(mt_rand()));
347343 }
348344
349- function isLogined(){
345+ function isLoggedin(){
350346 global $CONF;
351- if( $this->loginedUser ) return true;
347+ if( $this->loggedinUser ) return true;
352348
353349 $cookie = cookieVar($CONF['CookiePrefix'] . NP_OPENID_AUTH_COOKIE);
354350 if( ! $cookie ) return false;
@@ -360,8 +356,8 @@ class NP_OpenId extends NucleusPlugin {
360356 );
361357 $res = sql_query($query);
362358 if( @mysql_num_rows($res) > 0) {
363- $this->loginedUser = mysql_fetch_assoc($res);
364- $this->loginedUser = array_merge($this->loginedUser, unserialize($this->loginedUser['sreg']));
359+ $this->loggedinUser = mysql_fetch_assoc($res);
360+ $this->loggedinUser = array_merge($this->loggedinUser, unserialize($this->loggedinUser['sreg']));
365361 return true;
366362 }
367363 return false;
@@ -410,12 +406,12 @@ class NP_OpenId extends NucleusPlugin {
410406 $res = sql_query($query);
411407
412408 if( @mysql_num_rows($res) > 0) {
413- $this->loginedUser = mysql_fetch_assoc($res);
414- $this->loginedUser = array_merge($this->loginedUser, unserialize($this->loginedUser['sreg']));
409+ $this->loggedinUser = mysql_fetch_assoc($res);
410+ $this->loggedinUser = array_merge($this->loggedinUser, unserialize($this->loggedinUser['sreg']));
415411
416412 setcookie($CONF['CookiePrefix'] . NP_OPENID_AUTH_COOKIE , $cookie, 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
417- setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loginedUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
418- setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loginedUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
413+ setcookie($CONF['CookiePrefix'] . 'comment_user', $this->loggedinUser['nick'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
414+ setcookie($CONF['CookiePrefix'] . 'comment_email', $this->loggedinUser['email'], 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
419415 return true;
420416 }
421417
@@ -424,7 +420,7 @@ class NP_OpenId extends NucleusPlugin {
424420
425421 function logout(){
426422 global $CONF;
427- $this->loginedUser = null;
423+ $this->loggedinUser = null;
428424 setcookie($CONF['CookiePrefix'] . NP_OPENID_AUTH_COOKIE, '', 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
429425 setcookie($CONF['CookiePrefix'] . 'comment_user', '', 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
430426 setcookie($CONF['CookiePrefix'] . 'comment_email', '', 0, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
@@ -437,7 +433,7 @@ class NP_OpenId extends NucleusPlugin {
437433 return;
438434 }
439435
440- if( $this->isLogined() ){
436+ if( $this->isLoggedin() ){
441437 $data['externalauth']['result'] = true;
442438 $data['externalauth']['plugin'] = $this->getName();
443439 }
@@ -452,25 +448,34 @@ class NP_OpenId extends NucleusPlugin {
452448 $manager->notify('ExternalAuth', array ('externalauth' => &$externalauth));
453449 if (isset($externalauth['result']) && $externalauth['result'] == true) return;
454450
451+ $te = $this->_getTemplateEngine();
455452 $aVars = array();
456- if( $this->isLogined() ){
457- // Logined
453+ $aVars['PluginURL'] = $CONF['PluginURL'];
454+
455+ $te = $this->_getTemplateEngine();
456+ if( $this->isLoggedin() ){
457+ // Loggedin
458458 $return_url = $CONF['PluginURL'] . 'openid/rd.php?action=rd&url='
459459 . urlencode( 'http://'.serverVar("HTTP_HOST") .serverVar("REQUEST_URI") );
460- $aVars['url'] = htmlspecialchars( $return_url, ENT_QUOTES );
461- $aVars['nick'] = $this->loginedUser['nick'];
462- $aVars['email'] = $this->loginedUser['email'];
463- $aVars['ts'] = $this->loginedUser['ts'];
464- $aVars['profileUpdateUrl'] = $CONF['PluginURL'] . 'openid/profile.php';
465- $aVars['identity'] = $this->loginedUser['identity'];
460+ $aVars['url'] = $return_url;
461+ $aVars['nick'] = $this->loggedinUser['nick'];
462+ $aVars['email'] = $this->loggedinUser['email'];
463+ $aVars['ts'] = $this->loggedinUser['ts'];
464+ $aVars['identity'] = $this->loggedinUser['identity'];
465+ $aVars['visible'] = $aVars['nick'] ? 'false' : 'true' ;
466+
467+ $actionUrl = parse_url($CONF['ActionURL']);
468+ $aVars['updateUrl'] = $actionUrl['path'];
466469
467- echo TEMPLATE::fill($this->getOption('LoginedHtml'), $aVars);
470+ echo $te->fetchAndFill('yui', $aVars, strtolower(__CLASS__));
471+ echo $te->fetchAndFill('loggedin', $aVars, strtolower(__CLASS__));
472+ echo $te->fetchAndFill('form', $aVars, strtolower(__CLASS__));
468473 } else {
469- // not logined
474+ // Not loggedin
470475 $aVars['url'] = $CONF['PluginURL'] . 'openid/rd.php?action=doauth&return_url='
471476 . urlencode( 'http://'.serverVar("HTTP_HOST") .serverVar("REQUEST_URI") );
472477
473- echo TEMPLATE::fill($this->getOption('NotLoginedHtml'), $aVars);
478+ echo $te->fetchAndFill('notloggedin', $aVars, strtolower(__CLASS__));
474479 }
475480 }
476481
@@ -491,7 +496,7 @@ class NP_OpenId extends NucleusPlugin {
491496 $manager->notify('ExternalAuth', array ('externalauth' => &$externalauth));
492497 if (isset($externalauth['result']) && $externalauth['result'] == true) return;
493498
494- $this->isLogined();
499+ $this->isLoggedin();
495500 }
496501
497502 function event_ValidateForm(&$data) {
@@ -504,11 +509,11 @@ class NP_OpenId extends NucleusPlugin {
504509
505510 switch ($data['type']) {
506511 case 'comment' :
507- if( (! $this->isLogined() ) && $this->getOption('permitComment') == 'no' )
512+ if( (! $this->isLoggedin() ) && $this->getOption('permitComment') == 'no' )
508513 $data['error'] = $this->getOption('CommentFormError');
509514 break;
510515 case 'membermail' :
511- if( (! $this->isLogined() ) && $this->getOption('permitMail') == 'no' )
516+ if( (! $this->isLoggedin() ) && $this->getOption('permitMail') == 'no' )
512517 $data['error'] = $this->getOption('MemberMailError');
513518 break;
514519 default :
@@ -520,22 +525,22 @@ class NP_OpenId extends NucleusPlugin {
520525 global $member;
521526 if( $member->isLoggedIn() ) return;
522527
523- if( ! $this->isLogined() ) return;
524- $data['comment']['user'] = $this->loginedUser['nick'].' [OpenID]';
528+ if( ! $this->isLoggedin() ) return;
529+ $data['comment']['user'] = $this->loggedinUser['nick'].' [OpenID]';
525530 }
526531
527532 function event_PostAddComment(&$data) {
528533 global $member;
529534 if( $member->isLoggedIn() ) return;
530535
531- if( ! $this->isLogined() ) return;
536+ if( ! $this->isLoggedin() ) return;
532537 global $itemid;
533538 $query = sprintf('INSERT INTO ' . sql_table('plugin_openid_comment')
534539 . '( cnumber, citem, identity, ts ) '
535540 . "values('%s', '%s', '%s', now() )",
536541 mysql_real_escape_string( $data['commentid'] ),
537542 mysql_real_escape_string( intval($itemid) ),
538- mysql_real_escape_string( $this->loginedUser['identity'] )
543+ mysql_real_escape_string( $this->loggedinUser['identity'] )
539544 );
540545 sql_query($query);
541546 }
@@ -549,17 +554,19 @@ class NP_OpenId extends NucleusPlugin {
549554 }
550555
551556 function event_LoginSuccess(&$data) {
552- if( $this->isLogined() )
557+ if( $this->isLoggedin() ){
553558 $this->logout();
559+ }
554560 }
555561
556562 function event_Logout(&$data) {
557- if( $this->isLogined() )
563+ if( $this->isLoggedin() ){
558564 $this->logout();
565+ }
559566 }
560567
561568 function doTemplateCommentsVar(&$item, &$comment){
562- global $member;
569+ global $member, $CONF;
563570 $itemid = intval($item['itemid']);
564571 if( ! $this->comments[$itemid] ){
565572 $this->comments[$itemid]['cached'] = true;
@@ -578,14 +585,27 @@ class NP_OpenId extends NucleusPlugin {
578585 $cnumber = $comment['commentid'];
579586 if( $openIdComment = $this->comments[$itemid][$cnumber] ){
580587 $aVars['identity'] = $openIdComment['identity'];
588+ $aVars['PluginURL'] = $CONF['PluginURL'];
589+
581590 $sreg = unserialize($openIdComment['sreg']);
582591 if( is_array($sreg) )
583592 $aVars = array_merge($aVars, $sreg);
584593
585- if ( $member->isLoggedIn() )
586- echo TEMPLATE::fill($this->getOption('TemplateAdminHtml'), $aVars);
587- else
588- echo TEMPLATE::fill($this->getOption('TemplateHtml'), $aVars);
594+ $te = $this->_getTemplateEngine();
595+ if ( $member->isLoggedIn() ){
596+ echo $te->fetchAndFill('admin', $aVars, strtolower(__CLASS__));
597+ } else {
598+ echo $te->fetchAndFill('user', $aVars, strtolower(__CLASS__));
599+ }
589600 }
590601 }
602+
603+ function _getTemplateEngine(){
604+ if( ! $this->templateEngine )
605+ $this->templateEngine =& new cles_Template(dirname(__FILE__).'/openid/template');
606+
607+ $this->templateEngine->defaultLang = 'english';
608+ return $this->templateEngine;
609+ }
610+
591611 }
--- a/trunk/NP_OpenId/openid/help.html
+++ b/trunk/NP_OpenId/openid/help.html
@@ -1,7 +1,14 @@
1-<!-- $Id: help.html,v 1.1 2008-02-03 13:11:22 hsur Exp $ -->
1+<!-- $Id: help.html,v 1.2 2008-06-07 19:33:43 hsur Exp $ -->
22 <h3>バージョン履歴</h3>
33
44 <ul>
55 <li>Version 1.0: (2008/02/03)</li>
66 <li> [New] 初版公開</li>
77 </ul>
8+
9+<ul>
10+ <li>Version 1.1: (2008/06/07)</li>
11+ <li> [Changed] テンプレートをプラグインオプションから、ファイルベースに変更</li>
12+ <li> [Changed] Profileの変更にYUIを使うようにした</li>
13+ <li> [Fixed] テーブルの作成に失敗する問題に対応</li>
14+</ul>
--- a/trunk/NP_OpenId/openid/index.php
+++ b/trunk/NP_OpenId/openid/index.php
@@ -2,10 +2,10 @@
22 // vim: tabstop=2:shiftwidth=2
33
44 /**
5- * index.php ($Revision: 1.1 $)
5+ * index.php ($Revision: 1.2 $)
66 *
77 * by hsur ( http://blog.cles.jp/np_cles )
8- * $Id: index.php,v 1.1 2008-02-03 13:11:22 hsur Exp $
8+ * $Id: index.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
99 */
1010
1111 /*
@@ -73,20 +73,22 @@ if (isset ($_POST['page'])) {
7373 }
7474
7575 // create the admin area page
76-$oPluginAdmin = new PluginAdmin('TypeKey');
76+$oPluginAdmin = new PluginAdmin('OpenId');
7777 $oPluginAdmin->start();
7878 $fb =& new cles_Feedback($oPluginAdmin);
7979
8080 // menu
8181 echo "<h2>OpenId menu</h2>\n";
8282 echo "<ul>\n";
83-echo "<li><a href=\"".serverVar('PHP_SELF')."?page=report\"><span style=\"font-weight:bold; color:red\">" . $fb->getMenuStr() . "</span></a></li>\n";
83+if( strpos(getLanguageName(), 'japanese') !== false )
84+ echo "<li><a href=\"".serverVar('PHP_SELF')."?page=report\"><span style=\"font-weight:bold; color:red\">" . $fb->getMenuStr() . "</span></a></li>\n";
8485 echo "</ul>\n";
8586
8687 //action
8788 switch ($action) {
8889 case 'report' :
89- $fb->printForm();
90+ if( strpos(getLanguageName(), 'japanese') !== false )
91+ $fb->printForm();
9092 break;
9193
9294 default :
--- /dev/null
+++ b/trunk/NP_OpenId/openid/mkeuc.sh
@@ -0,0 +1,9 @@
1+#!/bin/bash -x
2+
3+FILES=`find . -name '*japanese-utf8*'`
4+
5+for utf8file in $FILES
6+do
7+ eucfile=`echo $utf8file | sed 's/japanese-utf8/japanese-euc/'`
8+ nkf -e -W -d < $utf8file > $eucfile
9+done
--- a/trunk/NP_OpenId/openid/profile.php
+++ /dev/null
@@ -1,95 +0,0 @@
1-<?php
2-// vim: tabstop=2:shiftwidth=2
3-
4-/**
5- * profile.php ($Revision: 1.1 $)
6- *
7- * by hsur ( http://blog.cles.jp/np_cles )
8- * $Id: profile.php,v 1.1 2008-02-03 13:11:22 hsur Exp $
9-*/
10-
11-/*
12- * Copyright (C) 2008 CLES. All rights reserved.
13- *
14- * This program is free software; you can redistribute it and/or
15- * modify it under the terms of the GNU General Public License
16- * as published by the Free Software Foundation; either version 2
17- * of the License, or (at your option) any later version.
18- *
19- * This program is distributed in the hope that it will be useful,
20- * but WITHOUT ANY WARRANTY; without even the implied warranty of
21- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22- * GNU General Public License for more details.
23- *
24- * You should have received a copy of the GNU General Public License
25- * along with this program; if not, write to the Free Software
26- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27- *
28- * In addition, as a special exception, cles( http://blog.cles.jp/np_cles ) gives
29- * permission to link the code of this program with those files in the PEAR
30- * library that are licensed under the PHP License (or with modified versions
31- * of those files that use the same license as those files), and distribute
32- * linked combinations including the two. You must obey the GNU General Public
33- * License in all respects for all of the code used other than those files in
34- * the PEAR library that are licensed under the PHP License. If you modify
35- * this file, you may extend this exception to your version of the file,
36- * but you are not obligated to do so. If you do not wish to do so, delete
37- * this exception statement from your version.
38-*/
39-
40-$strRel = '../../../';
41-require($strRel.'config.php');
42-
43-require($DIR_LIBS.'PLUGINADMIN.php');
44-
45-// create the admin area page
46-$oPluginAdmin =& new PluginAdmin('OpenId');
47-$err = $oPluginAdmin->plugin->doAction('updateProfile');
48-$manager->checkTicket();
49-
50-if ( $err ) {
51- $oPluginAdmin->start();
52- echo "<h2>NP_OpenId Error: $err</h2>";
53- echo "<h3>Debug information</h3><pre>";
54- var_dump($_REQUEST);
55- echo '</pre>';
56- $oPluginAdmin->end();
57- exit;
58-}
59-
60-?>
61-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
62-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
63-<head>
64-<title>Update Profile - OpenID</title>
65-</head>
66-<body>
67-<form action="profile.php" method="post">
68-<fieldset>
69-<legend>Your Profile</legend>
70-<dl>
71-
72-<dt>Identity:</dt>
73-<dd><?php echo $oPluginAdmin->plugin->loginedUser['identity']; ?></dd>
74-
75-<dt>Nickname:</dt>
76-<dd>
77- <input type="text" value="<?php echo htmlspecialchars($oPluginAdmin->plugin->loginedUser['nick'], ENT_QUOTES); ?>" size="40" title="nick" name="nick"/>
78-</dd>
79-
80-<dt>eMail:</dt>
81-<dd>
82- <input type="text" value="<?php echo htmlspecialchars($oPluginAdmin->plugin->loginedUser['email'], ENT_QUOTES); ?>" size="40" title="email" name="email"/>
83-</dd>
84-
85-<dt></dt>
86-<dd><input type="submit" value="UpdateProfile" name="submit"/></dd>
87-</dl>
88-
89-<?php $manager->addTicketHidden() ?>
90-
91-</fieldset>
92-</form>
93-
94-</body>
95-</html>
--- a/trunk/NP_OpenId/openid/rd.php
+++ b/trunk/NP_OpenId/openid/rd.php
@@ -2,10 +2,10 @@
22 // vim: tabstop=2:shiftwidth=2
33
44 /**
5- * rd.php ($Revision: 1.1 $)
5+ * rd.php ($Revision: 1.2 $)
66 *
77 * by hsur ( http://blog.cles.jp/np_cles )
8- * $Id: rd.php,v 1.1 2008-02-03 13:11:22 hsur Exp $
8+ * $Id: rd.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
99 */
1010
1111 /*
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/admin_english.html
@@ -0,0 +1,3 @@
1+<a href="{{identity|}}" rel="nofollow" title="OpenID Profile">
2+ <img src="{{PluginURL|}}openid/openid.png" border="0"/>{{identity|}}
3+</a>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/form_english.html
@@ -0,0 +1,19 @@
1+<!-- Dialog -->
2+<div class="yui-skin-sam">
3+<div id="profile">
4+ <div class="hd">Please enter your profile</div>
5+ <div class="bd">
6+ <form method="POST" action="{{updateUrl}}?action=plugin">
7+ <label for="nick">Nickname:</label><input type="textbox" name="nick" value="{{nick}}" />
8+ <div class="clear"></div>
9+ <label for="email">E-mail:</label><input type="textbox" name="email" value="{{email}}"/>
10+ <div class="clear"></div>
11+ <input type="hidden" name="name" value="OpenId">
12+ <input type="hidden" name="type" value="updateProfile">
13+ </form>
14+ </div>
15+</div>
16+</div>
17+
18+<!-- response -->
19+<div id="resp"></div>
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/form_japanese-euc.html
@@ -0,0 +1,19 @@
1+<!-- Dialog -->
2+<div class="yui-skin-sam">
3+<div id="profile">
4+ <div class="hd">プロフィール更新</div>
5+ <div class="bd">
6+ <form method="POST" action="{{updateUrl}}?action=plugin">
7+ <label for="nick">お名前:</label><input type="textbox" name="nick" value="{{nick}}" />
8+ <div class="clear"></div>
9+ <label for="email">E-mail:</label><input type="textbox" name="email" value="{{email}}"/>
10+ <div class="clear"></div>
11+ <input type="hidden" name="name" value="OpenId">
12+ <input type="hidden" name="type" value="updateProfile">
13+ </form>
14+ </div>
15+</div>
16+</div>
17+
18+<!-- response -->
19+<div id="resp"></div>
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/form_japanese-utf8.html
@@ -0,0 +1,19 @@
1+<!-- Dialog -->
2+<div class="yui-skin-sam">
3+<div id="profile">
4+ <div class="hd">プロフィール更新</div>
5+ <div class="bd">
6+ <form method="POST" action="{{updateUrl}}?action=plugin">
7+ <label for="nick">お名前:</label><input type="textbox" name="nick" value="{{nick}}" />
8+ <div class="clear"></div>
9+ <label for="email">E-mail:</label><input type="textbox" name="email" value="{{email}}"/>
10+ <div class="clear"></div>
11+ <input type="hidden" name="name" value="OpenId">
12+ <input type="hidden" name="type" value="updateProfile">
13+ </form>
14+ </div>
15+</div>
16+</div>
17+
18+<!-- response -->
19+<div id="resp"></div>
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/loggedin_english.html
@@ -0,0 +1,2 @@
1+<p>Thanks for signing in. Now you can comment or send mail. (<a href="{{url|}}" rel="nofollow">Sign out</a>)<br />
2+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
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-euc.html
@@ -0,0 +1,3 @@
1+<p>OpenIDでログイン中です。(<a href="{{url|}}" rel="nofollow">ログアウト</a>)<br />
2+OpenID identity: <img src="{{PluginURL}}openid/openid.png" /><strong>{{identity|}}</strong> <button id="show">プロフィール更新</button><br />
3+もし、名前やemailの欄が空欄の場合にはプロフィール更新から変更してください。</p>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/loggedin_japanese-utf8.html
@@ -0,0 +1,3 @@
1+<p>OpenIDでログイン中です。(<a href="{{url|}}" rel="nofollow">ログアウト</a>)<br />
2+OpenID identity: <img src="{{PluginURL}}openid/openid.png" /><strong>{{identity|}}</strong> <button id="show">プロフィール更新</button><br />
3+もし、名前やemailの欄が空欄の場合にはプロフィール更新から変更してください。</p>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/notloggedin_english.html
@@ -0,0 +1,5 @@
1+<p>If you have a OpenID identity, you can sign in to use it here.<br />
2+<form method="post" action="{{url|}}">
3+ 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"/>
4+ <input type="submit" value="Sign in" />
5+</form></p>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-euc.html
@@ -0,0 +1,5 @@
1+<p>OpenID を使ってログインすることができます。<br />
2+<form method="post" action="{{url|}}">
3+ 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"/>
4+ <input type="submit" value="ログイン" />
5+</form></p>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/notloggedin_japanese-utf8.html
@@ -0,0 +1,5 @@
1+<p>OpenID を使ってログインすることができます。<br />
2+<form method="post" action="{{url|}}">
3+ 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"/>
4+ <input type="submit" value="ログイン" />
5+</form></p>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/updatefailed_english.html
@@ -0,0 +1 @@
1+{{message|}}
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_english.html
@@ -0,0 +1,3 @@
1+document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
2+document.getElementById('nucleus_cf_email').value = '{{email}}';
3+document.getElementById('resp').innerHTML = 'Thanks, your profile have been updated.';
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-euc.html
@@ -0,0 +1,3 @@
1+document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
2+document.getElementById('nucleus_cf_email').value = '{{email}}';
3+document.getElementById('resp').innerHTML = 'プロフィールの更新が完了しました。';
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/updatesucceeded_japanese-utf8.html
@@ -0,0 +1,3 @@
1+document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
2+document.getElementById('nucleus_cf_email').value = '{{email}}';
3+document.getElementById('resp').innerHTML = 'プロフィールの更新が完了しました。';
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/user_english.html
@@ -0,0 +1,3 @@
1+<a href="{{identity|}}" rel="nofollow" title="OpenID Profile">
2+ <img src="{{PluginURL|}}openid/openid.png" border="0"/>{{identity|}}
3+</a>
\ No newline at end of file
--- /dev/null
+++ b/trunk/NP_OpenId/openid/template/np_openid/yui_english.html
@@ -0,0 +1,79 @@
1+<!-- css -->
2+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/fonts/fonts-min.css" />
3+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/button/assets/skins/sam/button.css" />
4+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/container/assets/skins/sam/container.css" />
5+
6+<!-- js -->
7+<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/utilities/utilities.js"></script>
8+<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/button/button-min.js"></script>
9+<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/container/container-min.js"></script>
10+
11+<script type="text/javascript">
12+YAHOO.namespace("openid.container");
13+
14+function init() {
15+
16+ // Define various event handlers for Dialog
17+ var handleSubmit = function() {
18+ document.getElementById("resp").innerHTML = '';
19+ this.submit();
20+ };
21+ var handleCancel = function() {
22+ document.getElementById("resp").innerHTML = '';
23+ this.cancel();
24+ };
25+ var handleSuccess = function(o) {
26+ var response = o.responseText;
27+ //debug
28+ //document.getElementById("resp").innerHTML = response;
29+ eval(response);
30+ };
31+ var handleFailure = function(o) {
32+ document.getElementById("resp").innerHTML = "Submission failed: " + o.status;
33+ };
34+
35+ // Instantiate the Dialog
36+ YAHOO.openid.container.profile = new YAHOO.widget.Dialog("profile",
37+ { width : "30em",
38+ fixedcenter : true,
39+ visible : {{visible}},
40+ constraintoviewport : true,
41+ buttons : [ { text:"Submit", handler:handleSubmit, isDefault:true },
42+ { text:"Cancel", handler:handleCancel } ]
43+ });
44+
45+ // Validate the entries in the form to require that both first and last name are entered
46+ YAHOO.openid.container.profile.validate = function() {
47+ var data = this.getData();
48+ if ( data.nick == "" ) {
49+ alert("Please enter your nickname.");
50+ return false;
51+ } else {
52+ return true;
53+ }
54+ };
55+
56+ // Wire up the success and failure handlers
57+ YAHOO.openid.container.profile.callback = { success: handleSuccess,
58+ failure: handleFailure };
59+
60+ // Render the Dialog
61+ YAHOO.openid.container.profile.render();
62+
63+ YAHOO.util.Event.addListener("show", "click", YAHOO.openid.container.profile.show, YAHOO.openid.container.profile, true);
64+}
65+YAHOO.util.Event.onDOMReady(init);
66+
67+(function(){
68+ var onload_org = window.onload;
69+ window.onload = function(){
70+ if(onload_org) onload_org();
71+ document.getElementById('nucleus_cf_name').value = '{{nick}} [OpenID]';
72+ document.getElementById('nucleus_cf_name').style.background = '#FFFFCC';
73+ document.getElementById('nucleus_cf_name').readOnly = true;
74+ document.getElementById('nucleus_cf_email').value = '{{email}}';
75+ document.getElementById('nucleus_cf_email').style.background = '#FFFFCC';
76+ document.getElementById('nucleus_cf_email').readOnly = true;
77+ }
78+})()
79+</script>
\ No newline at end of file
--- a/trunk/NP_OpenId/sharedlibs/Auth/TypeKey.php
+++ /dev/null
@@ -1,496 +0,0 @@
1-<?php
2-// Copyright (c) 2004 Daiji Hriata All Right Reserved.
3-// $Id: TypeKey.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
4-//
5-// Auth_TypeKey Class
6-//
7-// Simple example:
8-//
9-// $tk = new Auth_TypeKey();
10-// $tk->site_token('PUTYOURTYPEKEYTOKEN');
11-// $tk->verifyTypeKey( $msg );
12-// if (PEAR::isError($result)) {
13-// echo "INVALID";
14-// } else {
15-// echo "VALID";
16-// }
17-
18-require_once 'PEAR.php';
19-
20-/**
21-* Error code
22-*/
23-define('AUTH_TYPEKEY_ERROR_INVALID', -1);
24-define('AUTH_TYPEKEY_ERROR_TIMEOUT', -2);
25-define('AUTH_TYPEKEY_ERROR_NOT_EXIST_BIGINT', -3);
26-define('AUTH_TYPEKEY_ERROR_NOT_RETRIEVE_PUBKEY', -4);
27-define('AUTH_TYPEKEY_ERROR_NOT_SET_SITE_TOKEN', -5);
28-define('AUTH_TYPEKEY_ERROR_NOT_EXIST_GMP', -6);
29-define('AUTH_TYPEKEY_ERROR_NOT_EXIST_BCMATH', -7);
30-
31-class Auth_TypeKey extends PEAR {
32- /**
33- * TypeKey Public_Key URLs
34- */
35- var $AUTH_TYPEKEY_BASEURL = 'https://www.typekey.com/t/typekey/';
36- var $AUTH_TYPEKEY_SIG_URL = 'http://www.typekey.com/extras/regkeys.txt';
37-
38- /**
39- * TypeKey version
40- */
41- var $AUTH_TYPEKEY_VERSION = '1';
42-
43- /**
44- * TypeKey requires site_token
45- */
46- var $AUTH_TYPEKEY_SITE_TOKEN = NULL;
47-
48- /**
49- * time limitatino of TypeKey validation (sec)
50- */
51- var $AUTH_TYPEKEY_TIMEOUT = 300;
52-
53- /**
54- * function to compute BIGINT
55- */
56- var $AUTH_TYPEKEY_BIGINT = '';
57-
58- /**
59- * Initialize.
60- *
61- * @param array $init parameters for initialize:
62- * 'version' : TypeKey version
63- * 'token' : TypeKey Site Token
64- *
65- * @return mixed true on success. PEAR_Error on failure.
66- *
67- * @access public
68- */
69- function Auth_TypeKey($init = array ()) {
70- $this->PEAR();
71- if (!$this->_exist_bigint()) {
72- return PEAR :: raiseError("BCMATH or GMP is required", AUTH_TYPEKEY_ERROR_NOT_EXIST_BIGINT);
73- }
74- if (array_key_exists('version', $init)) {
75- $this->version($init['version']);
76- }
77- if (array_key_exists('token', $init)) {
78- $this->site_token($init['token']);
79- }
80- return true;
81- }
82-
83- /**
84- * Set/show TypeKey version
85- *
86- * @param string $version TypeKey version to set.
87- * If nothing, just look.
88- *
89- * @return string Current setting of TypeKey version
90- *
91- * @access public
92- */
93- function version($version = NULL) {
94- if (!is_null($version)) {
95- $this->AUTH_TYPEKEY_VERSION = $version;
96- }
97- return $this->AUTH_TYPEKEY_VERSION;
98- }
99-
100- /**
101- * Set/show TypeKey Site Token
102- *
103- * @param string $version TypeKey Site Token to set.
104- * if nothing, just look.
105- *
106- * @return mixed string Current setting of TypeKey Site Token
107- * if set. PEAR_Error if not set.
108- *
109- * @access public
110- */
111- function site_token($token = NULL) {
112- if (!is_null($token)) {
113- $this->AUTH_TYPEKEY_SITE_TOKEN = $token;
114- }
115- if (is_null($this->AUTH_TYPEKEY_SITE_TOKEN)) {
116- return PEAR :: raiseError('SITE TOKEN is not set.', AUTH_TYPEKEY_ERROR_NOT_SET_SITE_TOKEN);
117- }
118- return $this->AUTH_TYPEKEY_SITE_TOKEN;
119- }
120-
121- /**
122- * Verify the TypeKey authentication requirement
123- *
124- * @param array $query TypeKey Site Token to set. if nothing, just look.
125- * @param array $key Public Keys of TypeKey service. if NULL, using preset URLs.
126- *
127- * @return mixed true on success. PEAR_Error on failure.
128- *
129- * @access public
130- */
131- function verifyTypeKey($query, $key = NULL) {
132- // Retrieve key per each request.
133- if (is_null($key)) {
134- $key = $this->_fetch_key('');
135- if ($key == false) {
136- return PEAR :: raiseError('Cannot get pubkey.', AUTH_TYPEKEY_ERROR_NOT_RETRIEVE_PUBKEY);
137- }
138- }
139-
140- foreach (array ('email', 'name', 'nick', 'ts', 'sig') as $i) {
141- $$i = $query[$i];
142- }
143-
144- // The nickname field is sent as url_encoded utf-8 data(like %xx%xx... )
145- // from Tyepkey but signed before encoded. Usually all fields are
146- // decoded by PHP automatically, but it might cause invalid_error,
147- // especially using with mb_stirng. rawurlencoded strings is
148- // better for that case. It can be gotten from QUERY_STRING
149- $nick = rawurldecode($nick);
150-
151- switch ($this->version()) {
152- case '1' :
153- $message = implode('::', array ($email, $name, $nick, $ts));
154- break;
155- case '1.1' :
156- $token = $this->site_token();
157- if (PEAR :: isError($token)) {
158- return $token;
159- }
160- $message = implode('::', array ($email, $name, $nick, $ts, $token));
161- break;
162- default :
163- // default is version '1'
164- $message = implode('::', array ($email, $name, $nick, $ts));
165- break;
166- }
167-
168- if ($this->_dsa_verify($message, $sig, $key) == true) {
169- if (time() - $ts > $this->AUTH_TYPEKEY_TIMEOUT) {
170- return PEAR :: raiseError("Timestamp from TypeKey is too old", AUTH_TYPEKEY_ERROR_TIMEOUT);
171- }
172- return true;
173- } else {
174- return PEAR :: raiseError("Invalid signature", AUTH_TYPEKEY_ERROR_INVALID);
175- }
176- }
177-
178- /* Generate URL to link to Sign-In using TypeKey service
179- *
180- * @param string $return_url URL to be returned after authentication
181- * @param boolean $need_email if true, require email address of user.
182- *
183- * @return mixed string $url URL to link TypeKey Sign-In
184- * PEAR_Error on failure
185- *
186- * @access public
187- */
188-
189- function urlSignIn($return_url, $need_email = false, $options = array ()) {
190- $token = $this->site_token();
191- if (PEAR :: isError($token)) {
192- return $token;
193- }
194-
195- $option_query = '';
196- foreach ($options as $key => $value) {
197- $option_query .= '&'.$key.'='.$value;
198- }
199-
200- $url = $this->AUTH_TYPEKEY_BASEURL;
201- $url .= "login?t=".$token;
202- $url .= (($need_email == 1) ? "&need_email=1" : '');
203- $url .= (($this->version()) ? "&v=".$this->version() : '');
204- $url .= $option_query;
205- $url .= "&_return=".rawurlencode($return_url);
206- return $url;
207- }
208-
209- /* Generate URL to link to sign out
210- *
211- * @param string $return_url URL to be returned after authentication
212- *
213- * @return string $url URL to link TypeKey sign out.
214- *
215- * @access public
216- */
217- function urlSignOut($return_url) {
218- $url = $this->AUTH_TYPEKEY_BASEURL;
219- $url .= "logout?";
220- $url .= "_return=".rawurlencode($return_url);
221- return $url;
222- }
223-
224- /*
225- * Fetch keys of TypeKey service
226- *
227- * @param string $url URL of TypeKey Public Keys
228- *
229- * @return mixed array of Public keys of TypeKey services
230- * false on error
231- *
232- * @access private
233- */
234- function _fetch_key($url = '') {
235- if ($url == '') {
236- $url = $this->AUTH_TYPEKEY_SIG_URL;
237- }
238- $lines = @ file($url);
239- if ($lines == false) {
240- return false;
241- }
242- $key_raw = explode(" ", $lines[0]);
243-
244- foreach ($key_raw as $e) {
245- list ($key_index, $key_value) = explode("=", $e);
246- $key[$key_index] = trim($key_value);
247- }
248- return $key;
249- }
250-
251- /*
252- * check existing bigint function
253- *
254- * @return boolean true if available bigint funciton gmp or bcmath
255- * false if not available.
256- *
257- * @access private
258- *
259- */
260- function _exist_bigint() {
261- $extension_bigint = array ('bcmath', 'gmp');
262- $exist_bigint = false;
263- foreach ($extension_bigint as $ext) {
264- if (extension_loaded($ext)) {
265- $exist_bigint = true;
266- $this->AUTH_TYPEKEY_BIGINT = $ext;
267- }
268- }
269- return $exist_bigint;
270- }
271-
272- /*
273- * dsa verification
274- *
275- * @param string $message Message to verify
276- * @param string @sig Sign for the message, two keys are
277- * included separeted by ':' (colon)
278- * @param array $key ublic keys for the signiture
279- *
280- * @access private
281- *
282- */
283- function _dsa_verify($message, $sig, $key) {
284- $func = $this->AUTH_TYPEKEY_BIGINT;
285- $func = '_dsa_verify_'.$func;
286- return $this-> $func ($message, $sig, $key);
287- }
288-
289- /*
290- * dsa verification using gmp
291- *
292- * @param string $message Message to verify
293- * @param string @sig Sign for the message, two keys are
294- * included separeted by ':' (colon)
295- * @param array $key ublic keys for the signiture
296- *
297- * @access private
298- *
299- */
300- function _dsa_verify_gmp($message, $sig, $key) {
301- list ($r_sig, $s_sig) = explode(":", $sig);
302- $r_sig = base64_decode($r_sig);
303- $s_sig = base64_decode($s_sig);
304-
305- foreach ($key as $i => $v) {
306- $key[$i] = gmp_init($v);
307- }
308- $s1 = gmp_init($this->_gmp_bindec($r_sig));
309- $s2 = gmp_init($this->_gmp_bindec($s_sig));
310-
311- $w = gmp_invert($s2, $key['q']);
312- $hash_m = gmp_init('0x'.sha1($message));
313-
314- $u1 = gmp_mod(gmp_mul($hash_m, $w), $key['q']);
315- $u2 = gmp_mod(gmp_mul($s1, $w), $key['q']);
316-
317- $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']);
318- if (gmp_cmp($v, $s1) == 0) {
319- return true;
320- } else {
321- return false;
322- }
323- }
324-
325- /*
326- * gmp_bindec
327- *
328- * @param string $bin binary data
329- *
330- * @return gmp value of $bin
331- *
332- * @access private
333- */
334- function _gmp_bindec($bin) {
335- $dec = gmp_init(0);
336- while (strlen($bin)) {
337- $i = ord(substr($bin, 0, 1));
338- $dec = gmp_add(gmp_mul($dec, 256), $i);
339- $bin = substr($bin, 1);
340- }
341- return gmp_strval($dec);
342- }
343-
344- /*
345- * dsa verification using bcmath
346- *
347- * @param string $message Message to verify
348- * @param string @sig Sign for the message, two keys are
349- * included separeted by ':' (colon)
350- * @param array $key ublic keys for the signiture
351- *
352- * @access private
353- *
354- */
355- function _dsa_verify_bcmath($message, $sig, $key) {
356- list ($r_sig, $s_sig) = explode(":", $sig);
357-
358- $r_sig = base64_decode($r_sig);
359- $s_sig = base64_decode($s_sig);
360-
361- $s1 = $this->_bc_bindec($r_sig);
362- $s2 = $this->_bc_bindec($s_sig);
363-
364- $w = $this->_bc_invert($s2, $key['q']);
365- $hash_m = $this->_bc_hexdec(sha1($message));
366-
367- $u1 = bcmod(bcmul($hash_m, $w), $key['q']);
368- $u2 = bcmod(bcmul($s1, $w), $key['q']);
369-
370- $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']);
371-
372- if (bccomp($v, $s1) == 0) {
373- return true;
374- } else {
375- return false;
376- }
377- }
378-
379- /*
380- * _bc_hexdec
381- *
382- * @param string $hex
383- *
384- * @return string dec converted from $hex
385- *
386- * @access private
387- */
388- function _bc_hexdec($hex) {
389- $dec = "0";
390- while (strlen($hex)) {
391- $i = HexDec(substr($hex, 0, 4));
392- $dec = bcadd(bcmul($dec, 65536), $i);
393- $hex = substr($hex, 4);
394- }
395- return $dec;
396- }
397-
398- /*
399- * _bc_bindec
400- *
401- * @param string $bin
402- *
403- * @return string dec converted from $bin
404- *
405- * @access private
406- */
407- function _bc_bindec($bin) {
408- $dec = "0";
409- while (strlen($bin)) {
410- $i = ord(substr($bin, 0, 1));
411- $dec = bcadd(bcmul($dec, 256), $i);
412- $bin = substr($bin, 1);
413- }
414- return $dec;
415- }
416-
417- /*
418- * _bc_invert
419- *
420- * @param string $x, $y
421- *
422- * @return string inverse $x and $y
423- *
424- * @access private
425- */
426- function _bc_invert($x, $y) {
427- while (bccomp($x, 0) < 0) {
428- $x = bcadd($x, $y);
429- }
430- $r = $this->_bc_exgcd($x, $y);
431- if ($r[2] == 1) {
432- $a = $r[0];
433- while (bccomp($a, 0) < 0) {
434- $a = bcadd($a, $y);
435- }
436- return $a;
437- } else {
438- return false;
439- }
440- }
441-
442- /*
443- * _bc_exgcd
444- *
445- * @param string $x, $y
446- *
447- * @return string extended gcd of $x and $y
448- *
449- * @access private
450- */
451- function _bc_exgcd($x, $y) {
452- $a0 = 1;
453- $a1 = 0;
454- $b0 = 0;
455- $b1 = 1;
456- $c = 0;
457- while ($y > 0) {
458- $q = bcdiv($x, $y, 0);
459- $r = bcmod($x, $y);
460- $x = $y;
461- $y = $r;
462- $a2 = bcsub($a0, bcmul($q, $a1));
463- $b2 = bcsub($b0, bcmul($q, $b1));
464- $a0 = $a1;
465- $a1 = $a2;
466- $b0 = $b1;
467- $b1 = $b2;
468- }
469- return (array ($a0, $b0, $x));
470- }
471-
472- /*
473- * _bc_powmod
474- *
475- * @param string $x, $y, $mod
476- *
477- * @return string bcmod(bcpow($x, $y), $mod)
478- *
479- * @access private
480- */
481- function _bc_powmod($x, $y, $mod) {
482- if (function_exists('bcpowmod')) {
483- return bcpowmod($x, $y, $mod);
484- } else {
485- if (bccomp($y, 1) == 0) {
486- return bcmod($x, $mod);
487- } else
488- if (bcmod($y, 2) == 0) {
489- return bcmod(bcpow($this->_bc_powmod($x, bcdiv($y, 2), $mod), 2), $mod);
490- } else {
491- return bcmod(bcmul($x, $this->_bc_powmod($x, bcsub($y, 1), $mod)), $mod);
492- }
493- }
494- }
495-}
496-?>
--- a/trunk/NP_OpenId/sharedlibs/cles/Feedback.php
+++ b/trunk/NP_OpenId/sharedlibs/cles/Feedback.php
@@ -2,10 +2,10 @@
22 // vim: tabstop=2:shiftwidth=2
33
44 /**
5- * Feedback.php ($Revision: 1.1 $)
5+ * Feedback.php ($Revision: 1.2 $)
66 *
77 * by hsur ( http://blog.cles.jp/np_cles )
8- * $Id: Feedback.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
8+ * $Id: Feedback.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
99 */
1010
1111 /*
@@ -55,14 +55,31 @@ class cles_Feedback {
5555 echo "<h2>動作確認/不具合報告</h2>";
5656 echo '<p>下記より、作者への動作確認/不具合の報告を行うことができます。</p>';
5757
58+ // js
59+ echo '<script langage="JavaScript">
60+//<![CDATA[
61+function selectall(){
62+ var elements = document.getElementsByTagName(\'input\');
63+ for( var i=0; i < elements.length; i++){
64+ var e = elements[i];
65+ if( e.type == \'checkbox\' ){
66+ e.checked = true;
67+ }
68+ }
69+ return false;
70+}
71+//]]>
72+</script>';
73+
5874 echo "<h3>収集する情報と公開について</h3>";
5975 echo '<p>デフォルトで必要最低限の環境情報(赤字のもの)を開発者のサーバへ送信します。<br />
6076 <span style="font-weight:bold; color:red">差し支えない範囲で環境情報の提供にご協力ください。</span></p>
6177 <p>※ 収集した情報は統計処理、及びプラグインのBugFixのみに利用されます。また統計処理した結果については公表することがあります。</p>';
62-
78+ echo '<p><a href="#" onclick="javascript:selectall();return false;">全て送信する場合はここをクリック</a></p>';
79+
6380 echo "<h3>サイト固有コードについて</h3>";
64- echo '<p>動作報告の重複を取り除くため、管理画面のURLのmd5を計算したものを送信しています。この情報から管理画面のURLを復元することはできないようになっています。<a href="http://computers.yahoo.co.jp/dict/security/hash/677.html" target="_blank">md5の解説についてはこちらをご覧ください。(Yahoo!コンピュータ用語辞典)</a></p>';
65-
81+ echo '<p>動作報告の重複を取り除くため、管理画面のURLのmd5を計算したものを送信しています。この情報から管理画面のURLを復元することはできないようになっています。<a href="http://e-words.jp/w/MD5.html" target="_blank">md5の解説についてはこちらをご覧ください。(e-WordsIT用語辞典)</a></p>';
82+
6683 // form
6784 echo '<form method="post" action="http://blog.cles.jp/support/report.php">' . "\n";
6885
@@ -71,20 +88,24 @@ class cles_Feedback {
7188 echo "<tr>\n";
7289 echo "<th>項目の説明</th>\n";
7390 echo "<th>送信される値</th>\n";
74- echo "<th>送信する</th>\n";
91+ echo "<th><a href=\"#\" onclick=\"javascript:selectall();return false;\">全てチェック</a></th>\n";
7592 echo "</tr>\n";
7693
7794 $res = sql_query("show variables like 'version'");
7895 $assoc = mysql_fetch_assoc($res);
7996 $mysqlVersion = $assoc['Value'];
80- $gdinfo = gd_info();
97+
98+ if( function_exists('gd_info') )
99+ $gdinfo = @gd_info();
100+ else
101+ $gdinfo['GD Version'] = 'GD is not supported';
81102
82103 global $CONF;
83104
84105 $this->_printtr('siteid', 'サイトの固有コード', md5(trim($CONF['AdminURL'])));
85106 $this->_printtr('plugin_name', 'プラグイン名', $this->oPluginAdmin->plugin->getName());
86107 $this->_printtr('plugin_version', 'プラグインのバージョン', $this->oPluginAdmin->plugin->getVersion());
87- $this->_printtr('plugin_info', 'プラグインの情報', $extra, true);
108+ $this->_printtr('plugin_info', '追加情報', $extra, true);
88109 $this->_printtr('nucleus_version', 'Nucleusのバージョン', $nucleus['version'], true);
89110 $this->_printtr('nucleus_charset', 'Nucleusのキャラクタセット', _CHARSET);
90111 $this->_printtr('php_version', 'PHPのバージョン', PHP_VERSION, true);
@@ -96,8 +117,8 @@ class cles_Feedback {
96117 $this->_printtr('mysql_version', 'MySQLのバージョン', $mysqlVersion, true);
97118
98119 echo "<tr>\n";
99- echo "<td>このプラグインは機能しましたか?</td>\n";
100- echo '<td colspan="2"><input type="radio" name="user_intention" value="ok" />はい <br/> <input type="radio" name="intention" value="ng" />いいえ'."</td>\n";
120+ echo "<td colspan=\"2\">このプラグインは機能しましたか?</td>\n";
121+ echo '<td><input type="radio" name="user_intention" value="ok" />はい <br/> <input type="radio" name="intention" value="ng" />いいえ'."</td>\n";
101122 echo "</tr>\n";
102123
103124 echo "<tr>\n";
@@ -111,11 +132,11 @@ class cles_Feedback {
111132 echo "</tr>\n";
112133
113134 echo "<tr>\n";
114- echo "<td>リンク集作成の際、リンクをはらせていただけますか?</td>\n";
115- echo '<td colspan="2"><input type="radio" name="user_disclose" value="yes" />はい <br/> <input type="radio" name="intention" value="no" />いいえ'."</td>\n";
135+ echo "<td colspan=\"2\">リンク集作成の際、リンクをはらせていただけますか?</td>\n";
136+ echo '<td><input type="radio" name="user_disclose" value="yes" />はい <br/> <input type="radio" name="intention" value="no" />いいえ'."</td>\n";
116137 echo "</tr>\n";
117138
118- echo '<tr><td colspan="3"><div align="right"><input type="submit" name="submit" value="動作確認を送信する" /></div></td></tr>';
139+ 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>';
119140 echo "</table>\n";
120141 echo "</form>\n";
121142
@@ -134,14 +155,15 @@ class cles_Feedback {
134155 } else {
135156 echo '<td><span style="font-weight:bold; color:red">'.$desc."</span></td>\n";
136157 echo '<td><span style="font-weight:bold; color:red">'.htmlspecialchars($value)."</span></td>\n";
137- 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";
158+ echo '<td>必須<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" readonly="readonly" checked="checked"/></td>'."\n";
138159 }
139160 echo "</tr>\n";
140161 }
141162
142163 function _supportedImageTypes() {
164+ if( !function_exists('gd_info') ) return "";
165+
143166 $aSupportedTypes = array ();
144-
145167 $aPossibleImageTypeBits = array (IMG_GIF => 'GIF', IMG_JPG => 'JPG', IMG_PNG => 'PNG', IMG_WBMP => 'WBMP');
146168
147169 foreach ($aPossibleImageTypeBits as $iImageTypeBits => $sImageTypeString) {
--- a/trunk/NP_OpenId/sharedlibs/cles/SQLStoreForNucleus.php
+++ b/trunk/NP_OpenId/sharedlibs/cles/SQLStoreForNucleus.php
@@ -1,10 +1,10 @@
11 <?php
22
33 /**
4- * MySQLStoreForNucleus.php ($Revision: 1.1 $)
4+ * MySQLStoreForNucleus.php ($Revision: 1.2 $)
55 * based on Auth_OpenID_SQLStore
66 * by hsur ( http://blog.cles.jp/np_cles )
7- * $Id: SQLStoreForNucleus.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
7+ * $Id: SQLStoreForNucleus.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
88 */
99
1010 /*
@@ -100,7 +100,7 @@ class cles_SQLStoreForNucleus extends Auth_OpenID_OpenIDStore {
100100 {
101101 $this->sql['nonce_table'] =
102102 "CREATE TABLE ".$this->nonces_table_name." (\n".
103- " server_url VARCHAR(2047),\n".
103+ " server_url VARBINARY(255),\n".
104104 " timestamp INTEGER,\n".
105105 " salt CHAR(40),\n".
106106 " UNIQUE (server_url(150), timestamp, salt)\n".
@@ -108,7 +108,7 @@ class cles_SQLStoreForNucleus extends Auth_OpenID_OpenIDStore {
108108
109109 $this->sql['assoc_table'] =
110110 "CREATE TABLE ".$this->associations_table_name." (\n".
111- " server_url BLOB,\n".
111+ " server_url VARBINARY(255),\n".
112112 " handle VARCHAR(255),\n".
113113 " secret BLOB,\n".
114114 " issued INTEGER,\n".
--- a/trunk/NP_OpenId/sharedlibs/cles/Template.php
+++ b/trunk/NP_OpenId/sharedlibs/cles/Template.php
@@ -2,10 +2,10 @@
22 // vim: tabstop=2:shiftwidth=2
33
44 /**
5- * Template.php ($Revision: 1.1 $)
5+ * Template.php ($Revision: 1.2 $)
66 *
77 * by hsur ( http://blog.cles.jp/np_cles )
8- * $Id: Template.php,v 1.1 2008-02-03 13:11:23 hsur Exp $
8+ * $Id: Template.php,v 1.2 2008-06-07 19:33:43 hsur Exp $
99 */
1010
1111 /*
@@ -73,4 +73,9 @@ class cles_Template {
7373 return preg_replace($this->defalutPattern, '("$2") ? htmlspecialchars($values["$1"], ENT_QUOTES) : $values["$1"]', $template);
7474 return preg_replace($this->defalutPattern, 'isset($values["$1"]) ? ("$2" ? htmlspecialchars($values["$1"], ENT_QUOTES) : $values["$1"]) : "{{$1}}" ', $template);
7575 }
76+
77+ function fetchAndFill($name, $values, $dir = null, $suffix = 'html', $default = null){
78+ $tpl = $this->fetch($name, $dir, $suffix);
79+ return $this->fill($tpl, $values, $default);
80+ }
7681 }
Show on old repository browser