忍者ブログ

まだ無題

blog no name still

06/30

Tue

2009

Boost Software License - Version 1.0 (俺的)和訳

http://www.boost.org/LICENSE_1_0.txt
 
 
Boost Software License - Version 1.0 - August 17th, 2003
 
あらゆる個人および団体に対して、使用、複製、表示、配布、実行、譲渡を目的として本ライセンスが適用されるそのソフトウェア、およびソフトウェアに付随するドキュメントを入手すること、またはソフトウェアの二次利用を行うこと、そのソフトウェアが供給された第三者として同様の行為を行うことに対して、無料で行えることをここに許可します。 条件は下記の通りです。
 
著作権はソフトウェアと全てのコードに及びます。上記のライセンス許可を含め、この制限と下記の免責条項は、ソフトウェアの一部または全体のコピー、およびそのソフトウェアを元にした派生物にも含まれなくてはいけません。しかし、これらのコピーおよび派生物が単に実行ファイルとして存在する場合は除きます。
 
そのソフトウェアは”現状のまま(AS IS)"として供給されます。商用的利用に耐えうる品質、特定の目的への適合性、著作権の非侵害・所有権を含め、明示的にも、暗示的にもいかなるな保証もありません。
いかなる場合においても、そのソフトウェアを配布する者または著作権の保有者は、たとえ契約書に記載してあった場合でも、
そのソフトウェアの不法行為的使用や、そのソフトウェアと接続するしないにかかわらず、そのソフトウェアの使用もしくはそのソフトウェアの内部的処理により発生したいかなる損害や障害について責任を負わないものとします。
PR

06/30

Tue

2009

【JSON】jsoncppに挑戦・・・失敗。

C++でJSONしようと思う。
CentOS5.2でjsoncppにトライ。
 
参考URL:
http://jsoncpp.sourceforge.net/index.html
 
 
1.jsoncppをDL
2.scons-localをDL
 
jsoncppのReadmeにあるとおりの方法でCentOSでコンパイル。scon-local 1.2.0.d20090223
→エラーがでた。
 
[hogehoge@localhost jsoncpp]$ python scons.py platform=linux-gcc check
scons: Reading SConscript files ...
Using platform 'linux-gcc-4.1.2'
LD_LIBRARY_PATH = :libs/linux-gcc-4.1.2
Building using PLATFORM = linux-gcc-4.1.2
scons: done reading SConscript files.
scons: Building targets ...
RunJSONTests("[<SCons.Node.FS.File instance at 0xb79df70c>]")
scons: *** [check] AttributeError : 'list' object has no attribute 'startswith'
Traceback (most recent call last):
  File "/home/yamamoto/jsoncpp/trunk/jsoncpp/scons-local-1.2.0.d20090223/SCons/Action.py", line 1041, in execute
    result = self.execfunction(target=target, source=rsources, env=env)
  File "/home/yamamoto/jsoncpp/trunk/jsoncpp/scons-local-1.2.0.d20090223/SCons/Action.py", line 1205, in __call__
    return apply(self.parent.actfunc, args, kw)
  File "/home/yamamoto/jsoncpp/trunk/jsoncpp/SConstruct", line 235, in runJSONTests_action
    return runjsontests.runAllTests( os.path.abspath(source), jsontest_path )
  File "/usr/lib/python2.4/posixpath.py", line 403, in abspath
    if not isabs(path):
  File "/usr/lib/python2.4/posixpath.py", line 49, in isabs
    return s.startswith('/')
AttributeError: 'list' object has no attribute 'startswith'
scons: building terminated because of error
s.
 
どうもjsoncpp側の不備のようだが、scons-localのバージョンを1.2.0.d20090113、1.1.0 と落として再試行を繰り返すけどだめ
 
jsoncppはRevison69
Pythonは2.4.3
 
jsconcppのRevison68を試してもだめ。Python2.6.2にしても余計だめでした。ん~。パスしよう。

05/07

Thu

2009

Xoops: XSNSモジュールでサイト登録時に自動的に全てのコミュニティに参加するようにする

 XSNSモジュールで、コミュニティ数を固定とし各サイトユーザーが全てのコミュニティに参加するという使い方をしたい。
 前のエントリーでコミュニティの新規作成を管理者だけが行えるようにし、ユーザーが自由にコミュニティを作れなくする方法を紹介した。次はサイトへの登録時に全てのコミュニティに自動的に参加するように手を加える。


[環境]
XOOPS Cube Legacy 2.1.6
XSNS 1.11
 

① コミュニティへの自動参加用関数の作成
 ユーザーIDを引数にし、未参加のコミュニティを検出し一括参加登録する関数を作成し、
 XOOPS_TRUST_PATH/modules/xsns/act/tmp/add_toAllCommunity.php として保存する。


XOOPS_TRUST_PATH/modules/xsns/act/tmp/add_toAllCommunity.php 
<?php
//全てのコミュニティに参加する

require_once XOOPS_ROOT_PATH."/class/database/database.php";

function addToAllCommunity($uid=0){
 if($uid+0==0) return false;
 
 $db=&Database::getInstance();
 $table="setagaya100_xsns_c_commu";
 $table2="setagaya100_xsns_c_commu_member";
 
 //全コミュニティidリスト
 $prs=$db->query("SELECT c_commu_id FROM $table");
 if(!$prs) die( "xsns custom error: auto add to community : ".__LINE__ ) ;
 $num=$db->getRowsNum( $prs );
 if( $num <= 0 ) die( "xsns custom error: auto add to community : ".__LINE__ ) ;
 $c_commu_ids=array();
 for($i=0;$i<$num;$i++){
  $row=mysql_fetch_row($prs);
  $c_commu_ids[]=$row[0];
 }

 //参加済みコミュニティidリスト
 $prs=$db->query("SELECT c_commu_id FROM $table2 WHERE uid=$uid");
 if(!$prs) die( "xsns custom error: auto add to community : ".__LINE__ ) ;
 $num=$db->getRowsNum( $prs );
 $participate_commus=array();
 for($i=0;$i<$num;$i++){
  $row=mysql_fetch_row($prs);
  $participate_commus[]=$row[0];
 }
 
 //未参加コミュニティidリスト
 $un_participate_commus=array_diff($c_commu_ids,$participate_commus);
 if( !count($un_participate_commus)) return true;
 
 //参加処理
 $count=0;
 foreach( $un_participate_commus as $value){
  $prs=$db->query("INSERT INTO $table2 (uid,c_commu_id,r_datetime) VALUES ($uid,$value,NOW() )");
  //print("sql: INSERT INTO $table2 (uid,c_commu_id,r_datetime) VALUES ($uid,$value,NOW() )");
  if(!$prs) die( "xsns custom error: auto add to community : ".__LINE__ .":".$db->logger->dumpQueries() );
  $count++;
 }
 
 return $count;

}

?>




② サイト登録時に①の関数を実行するように修正
 ユーザーの登録処理は User_UserRegister_confirmActionクラスのexecute()で実行される。XOOPS_ROOT_PATH/modules/user/actions/UserRegister_confirmAction.class.php
の60行目に①で作成した関数を呼び出す処理を追加する。


XOOPS_ROOT_PATH/modules/user/actions/UserRegister_confirmAction.class.php
execure() (30行目以下)
 function execute(&$controller, &$xoopsUser)
 {
  $memberHandler =& xoops_gethandler('member');
  $this->mNewUser =& $memberHandler->createUser();
  $this->mRegistForm->update($this->mNewUser);
  $this->mNewUser->set('uorder', $controller->mRoot->mContext->getXoopsConfig('com_order'), true);
  $this->mNewUser->set('umode', $controller->mRoot->mContext->getXoopsConfig('com_mode'), true);
  if ($this->mConfig['activation_type'] == 1) {
   $this->mNewUser->set('level', 1, true);
  }
  
  if (!$memberHandler->insertUser($this->mNewUser)) {
   $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG;
   return USER_FRAME_VIEW_ERROR;
  }

        if (!$memberHandler->addUserToGroup(XOOPS_GROUP_USERS, $this->mNewUser->get('uid'))) {
   $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG;
   return USER_FRAME_VIEW_ERROR;
  }
  
  //ここを追加
  $file=XOOPS_TRUST_PATH."/modules/xsns/act/tmp/add_toAllCommunity.php";
  if( file_exists($file) ){
   require_once($file);
   if( !addToAllCommunity($this->mNewUser->get('uid')) ){
    die("Failed to add to all communities: XSNS custom error:");
   }
  }

  $this->_clearRegistForm($controller);

  $this->_processMail($controller);
  $this->_eventNotifyMail($controller);
  
  XCube_DelegateUtils::call('Legacy.Event.RegistUser.Success', new XCube_Ref($this->mNewUser));
  
  return USER_FRAME_VIEW_SUCCESS;
 }



以上で、サイトへの登録時に全てのコミュニティに登録される。今後、管理用にサイト登録時以外でもこの機能を呼び出せるようにしたい。また、コミュニティからの退会をできなくするよう手を加えることも必要。

05/03

Sun

2009

Xoops: XSNSモジュールで管理者しかコミュニティを作成できないようにする

XoopsでXSNSを使っている。d3forumなどフォーラム系のモジュールは機能がおおく見づらい気がする。SNSのトピックくらいがちょうどいい。ポータル的に使うことも考えてSNS系モジュールにした。しかしSNSなのでコミュニティはログインユーザーならだれでも作れてしまう。テーマ(?)が決まっているサイトなので、コミュニティはあらかじめテーマの数だけに限定したい。コミュニティの作成を管理者にしかできないようにXSNSを修正する。

[環境]
XOOPS Cube Legacy 2.1.6
XSNS 1.11

[修正箇所]
テンプレート側:「コミュニティ新規作成」出しわけの箇所
php側: 入力フォームオープン時→入力内容確認時→新規作成実行時の各処理の箇所


①テンプレート側
 デフォルトではgestユーザー以外、(管理者を含むxoopsユーザー)の場合はXSNSトップページで
「コミュニティ新規作成」のリンクが表示されるようになっている。
 Xoopsのユーザーかどうかを判別するメソッドはisGuest()としてXsnsCommonActionクラスに定義されている。ここに、管理者かどうかを判別するメソッドisAdmin()を追加する。


XOOPS_TRUST_PATH/modules/xsns/userlib/class/commonAction.php XsnsCommonActionクラス内に下記を追加
function isAdmin()
{
 if($this->isXoopsUser()){
  global $xoopsUser;
  
  return $xoopsUser->isAdmin();
 }
 return false;
}

 isGuest()はXsns_Default_Action->dispatch()(XOOPS_TRUST_PATH/modules/xsns/act/index/defaultAction.php line105)
でコールされ、結果がsmarty変数「is_guest」にセットされる(Xsns_Default_ActionクラスはXsnsCommonActionクラスを継承している。)。同様に先ほどのisAdmin()の結果を「is_admin」にセットするようにする。
 


XOOPS_TRUST_PATH/modules/xsns/act/index/defaultAction.php dispatch()内
 $this->context->setAttribute('is_guest', $this->isGuest());
 $this->context->setAttribute('is_admin', $this->isAdmin()); /*←ここを追加*/
 $this->context->setAttribute('keyword', $keyword);
 $this->context->setAttribute('url', $url);




 XSNSトップページのテンプレート(xsns_index.html)に手を加え「コミュニティ新規作成」のリンクが管理者が閲覧したときのみ表示されるようにする。
 (管理ページ > テンプレートの管理 > XSNS > xsns_index.html)


xsns_index.htmlの1/4くらいのところ
:before
<{if !$is_guest}>
<tr class="even">
<td colspan="2" style="text-align:right;">
<a href="<{$xoops_url}>/modules/<{$mydirname}>/?act=add"><{$smarty.const._MD_XSNS_INDEX_ADD}></a>&nbsp;<{$smarty.const._MD_XSNS_INDEX_ADD_DESC}>
</td>
</tr>
<{/if}>

:after
<{if $is_admin}> <!--←ここを修正 -->
<tr class="even">
<td colspan="2" style="text-align:right;">
<a href="<{$xoops_url}>/modules/<{$mydirname}>/?act=add"><{$smarty.const._MD_XSNS_INDEX_ADD}></a>&nbsp;<{$smarty.const._MD_XSNS_INDEX_ADD_DESC}>
</td>
</tr>
<{/if}>

 



②php側
 テンプレート側でリンクを消しただけだとURLを指定してアクセスされた際にグループ作成ができてしまうので、php側でも管理者だけがグループ作成できるように手を加える。

②-1入力フォームオープン時
 


XOOPS_TRUST_PATH/modules/xsns/act/index/addAction.php dispatch() (line8~)
:before
  if($this->isGuest()){
  redirect_header(XOOPS_URL, 2, _NOPERM);
 }

:after
 if( !$this->isAdmin() ){
  redirect_header(XOOPS_URL, 2, _NOPERM);
 }


②-2入力内容確認時
 


XOOPS_TRUST_PATH/modules/xsns/act/index/add_confirmAction.php dispatch() (line6~)
:before
 if( $this->isGuest() ){
  redirect_header(XOOPS_URL, 2, _NOPERM);
 }

:after
 if( !$this->isAdmin() ){
  redirect_header(XOOPS_URL, 2, _NOPERM);
 }


②-3新規作成実行時
 


XOOPS_TRUST_PATH/modules/xsns/act/index/add_execAction.php dispatch() (line8~)
:before
 if($this->isGuest() || !$this->validateToken('COMMUNITY_ADD')){
  redirect_header(XOOPS_URL, 2, _NOPERM);
 }

:after
 if(!$this->isAdmin() || !$this->validateToken('COMMUNITY_ADD')){
  redirect_header(XOOPS_URL, 2, _NOPERM);
 }


 以上で、管理者でアクセスした場合のみ「コミュニティ新規作成」のリンクが表示され、
通常ユーザーではコミュニティ作成ができないようになる。

 

04/11

Sat

2009

Xoopsに動的コンテンツを組み込む

Xoopsに新規のphpプログラム(動的なページ)を組み込みたい。
d3none で実現することにした。


・モジュール調査
モジュールを調べたところ、TinyContent,TinyD,pico,d3noneなど
静的コンテンツの管理モジュールはあるようだが動的コンテンツを
扱うモジュールは見つけることができなかった。
(そもそも「動的コンテンツを扱う」という考え方がいらないのかも
しれないが。)

pico系はTinyContent → TinyD → pico と進化している模様。
d3noneはそれとは別系で何もない空白のページを組み込むモジュールらしい。
何もない分自由度高いようなのでd3noneを使うことにした。


・方法
 d3noneで参照されるphpファイルに追加コードを書き込むことで動的ページを
表示させられる。
 XOOPS_TRUST_PATH/modules/d3none/main/index.php を下記のように修正
 


include('../../mainfile.php');
include(XOOPS_ROOT_PATH.'/header.php');

print "test test test";  //←ここを追加

// none
include(XOOPS_ROOT_PATH.'/footer.php');
exit();


実行結果









・index.php以外へのアクセス
 index.php以外のファイルに表示するには、ブラウザで http://'yourdomain'/html/modules/d3none/?page=hoge にアクセスすると、XOOPS_ROOT_PATH/modules/d3none/main/hoge.phpにアクセスする。
 

カレンダー

04 2012/05 06
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

フリーエリア

最新CM

最新TB

プロフィール

HN:
No Name Ninja
性別:
非公開

バーコード

ブログ内検索

アクセス解析

Copyright © まだ無題 : All rights reserved

TemplateDesign by KARMA7