• R/O
  • SSH
  • HTTPS

zerochplus: Commit


Commit MetaInfo

Revision488 (tree)
Time2013-11-04 21:02:21
Authoriroiro

Log Message

zerochplus 0.7.x
・プラグインから日付ID部分の操作をできるようにした

codes myid
・ID置換テストプラグイン
codes template3
・プラグインテンプレ

Change Summary

Incremental Difference

--- codes/0ch_template3.pl (nonexistent)
+++ codes/0ch_template3.pl (revision 488)
@@ -0,0 +1,139 @@
1+#============================================================================================================
2+#
3+# 拡張機能 - template3
4+# 0ch_template3.pl
5+#
6+#============================================================================================================
7+package ZPL_template3;
8+
9+
10+
11+#------------------------------------------------------------------------------------------------------------
12+# 拡張機能名称取得
13+#------------------------------------------------------------------------------------------------------------
14+sub getName
15+{
16+ return 'template3';
17+}
18+
19+#------------------------------------------------------------------------------------------------------------
20+# 拡張機能説明取得
21+#------------------------------------------------------------------------------------------------------------
22+sub getExplanation
23+{
24+ return '';
25+}
26+
27+#------------------------------------------------------------------------------------------------------------
28+# 拡張機能タイプ取得
29+#------------------------------------------------------------------------------------------------------------
30+sub getType
31+{
32+ return 16;
33+}
34+
35+#------------------------------------------------------------------------------------------------------------
36+# 設定リスト取得 (0ch+ Only)
37+#------------------------------------------------------------------------------------------------------------
38+sub getConfig
39+{
40+ return {};
41+}
42+
43+#------------------------------------------------------------------------------------------------------------
44+# 拡張機能実行インタフェイス
45+#------------------------------------------------------------------------------------------------------------
46+sub execute
47+{
48+ my $this = shift;
49+ my ($Sys, $Form, $type) = @_;
50+
51+
52+
53+
54+ return 0;
55+}
56+
57+#------------------------------------------------------------------------------------------------------------
58+# なんちゃってbbs.cgiエラーページ表示
59+#------------------------------------------------------------------------------------------------------------
60+sub PrintBBSError
61+{
62+ my ($Sys, $err) = @_;
63+
64+ require './module/orald.pl';
65+
66+ my $CGI = $Sys->Get('MainCGI');
67+ my $Page = $CGI->{'PAGE'};
68+
69+ my $Error = ORALD->new;
70+ $Error->Load($Sys);
71+ $Error->Print($CGI, $Page, $err, $Sys->Get('AGENT'));
72+
73+ $Page->Flush('', 0, 0);
74+
75+ exit($err);
76+}
77+
78+
79+
80+#------------------------------------------------------------------------------------------------------------
81+# コンストラクタ
82+#------------------------------------------------------------------------------------------------------------
83+sub new
84+{
85+ my $class = shift;
86+ my ($Config) = @_;
87+
88+ my $this = {};
89+ bless $this, $class;
90+
91+ if (defined $Config) {
92+ $this->{'PLUGINCONF'} = $Config;
93+ $this->{'is0ch+'} = 1;
94+ }
95+ else {
96+ $this->{'CONFIG'} = $class->getConfig();
97+ $this->{'is0ch+'} = 0;
98+ }
99+
100+ return $this;
101+}
102+
103+#------------------------------------------------------------------------------------------------------------
104+# 設定値取得 (0ch+ Only)
105+#------------------------------------------------------------------------------------------------------------
106+sub GetConf
107+{
108+ my $this = shift;
109+ my ($key) = @_;
110+ if ($this->{'is0ch+'}) {
111+ return $this->{'PLUGINCONF'}->GetConfig($key);
112+ }
113+ elsif (defined $this->{'CONFIG'}->{$key}) {
114+ return $this->{'CONFIG'}->{$key}->{'default'};
115+ }
116+}
117+
118+#------------------------------------------------------------------------------------------------------------
119+# 設定値設定 (0ch+ Only)
120+#------------------------------------------------------------------------------------------------------------
121+sub SetConf
122+{
123+ my $this = shift;
124+ my ($key, $val) = @_;
125+ if ($this->{'is0ch+'}) {
126+ $this->{'PLUGINCONF'}->SetConfig($key, $val);
127+ }
128+ elsif (defined $this->{'CONFIG'}->{$key}) {
129+ $this->{'CONFIG'}->{$key}->{'default'} = $val;
130+ }
131+ else {
132+ $this->{'CONFIG'}->{$key} = { 'default' => $val };
133+ }
134+}
135+
136+#============================================================================================================
137+# Module END
138+#============================================================================================================
139+1;
--- codes/0ch_myid.pl (nonexistent)
+++ codes/0ch_myid.pl (revision 488)
@@ -0,0 +1,131 @@
1+#============================================================================================================
2+#
3+# 拡張機能 - myid
4+# 0ch_myid.pl
5+#
6+#============================================================================================================
7+package ZPL_myid;
8+
9+#------------------------------------------------------------------------------------------------------------
10+# コンストラクタ
11+#------------------------------------------------------------------------------------------------------------
12+sub new
13+{
14+ my $class = shift;
15+ my ($Config) = @_;
16+
17+ my $obj = {};
18+ bless $obj, $class;
19+
20+ if (defined $Config) {
21+ $obj->{'PLUGINCONF'} = $Config;
22+ $obj->{'is0ch+'} = 1;
23+ }
24+ else {
25+ $obj->{'CONFIG'} = $class->getConfig();
26+ $obj->{'is0ch+'} = 0;
27+ }
28+
29+ return $obj;
30+}
31+
32+#------------------------------------------------------------------------------------------------------------
33+# 拡張機能名称取得
34+#------------------------------------------------------------------------------------------------------------
35+sub getName
36+{
37+ my $this = shift;
38+ return '[テスト] ID置換';
39+}
40+
41+#------------------------------------------------------------------------------------------------------------
42+# 拡張機能説明取得
43+#------------------------------------------------------------------------------------------------------------
44+sub getExplanation
45+{
46+ my $this = shift;
47+ return 'IDを書き換えるテストプラグインです。※0ch+ 0.7.4以降用';
48+}
49+
50+#------------------------------------------------------------------------------------------------------------
51+# 拡張機能タイプ取得
52+#------------------------------------------------------------------------------------------------------------
53+sub getType
54+{
55+ my $this = shift;
56+ return 16;
57+}
58+
59+#------------------------------------------------------------------------------------------------------------
60+# 設定リスト取得 (0ch+ Only)
61+#------------------------------------------------------------------------------------------------------------
62+sub getConfig
63+{
64+ my $this = shift;
65+ my %config = (
66+ );
67+ return \%config;
68+}
69+
70+#------------------------------------------------------------------------------------------------------------
71+# 拡張機能実行インタフェイス
72+#------------------------------------------------------------------------------------------------------------
73+sub execute
74+{
75+ my $this = shift;
76+ my ($Sys, $Form, $type) = @_;
77+
78+ # メール欄を取得
79+ my $mail = $Form->Get('mail');
80+
81+ # メール欄にid指定がある
82+ if ($mail =~ s/!id(.*)$//) {
83+ my $id = $1;
84+
85+ # メール欄のid指定を削除
86+ $Form->Set('mail', $mail);
87+
88+ # ID部分を再設定
89+ $Form->Set('idpart', "ID:$id");
90+ }
91+
92+ return 0;
93+}
94+
95+#------------------------------------------------------------------------------------------------------------
96+# 設定値取得 (0ch+ Only)
97+#------------------------------------------------------------------------------------------------------------
98+sub GetConf
99+{
100+ my $this = shift;
101+ my ($key) = @_;
102+ if ($this->{'is0ch+'}) {
103+ return $this->{'PLUGINCONF'}->GetConfig($key);
104+ }
105+ elsif (defined $this->{'CONFIG'}->{$key}) {
106+ return $this->{'CONFIG'}->{$key}->{'default'};
107+ }
108+}
109+
110+#------------------------------------------------------------------------------------------------------------
111+# 設定値設定 (0ch+ Only)
112+#------------------------------------------------------------------------------------------------------------
113+sub SetConf
114+{
115+ my $this = shift;
116+ my ($key, $val) = @_;
117+ if ($this->{'is0ch+'}) {
118+ $this->{'PLUGINCONF'}->SetConfig($key, $val);
119+ }
120+ elsif (defined $this->{'CONFIG'}->{$key}) {
121+ $this->{'CONFIG'}->{$key}->{'default'} = $val;
122+ }
123+ else {
124+ $this->{'CONFIG'}->{$key} = { 'default' => $val };
125+ }
126+}
127+
128+#============================================================================================================
129+# Module END
130+#============================================================================================================
131+1;
--- zerochplus/branches/0.7.x/test/module/galadriel.pl (revision 487)
+++ zerochplus/branches/0.7.x/test/module/galadriel.pl (revision 488)
@@ -980,7 +980,7 @@
980980 if (!$noslip && $Set->Equal('BBS_SLIP', 'checked')) {
981981 $str .= " $type";
982982 }
983- return " HOST:$str";
983+ return "HOST:$str";
984984 }
985985
986986 # IP表示 Ver.Siberia
@@ -996,7 +996,7 @@
996996 if (!$noslip && $Set->Equal('BBS_SLIP', 'checked')) {
997997 $str .= " $type";
998998 }
999- return " 発信元:$str";
999+ return "発信元:$str";
10001000 }
10011001
10021002 # IP表示 Ver.Sakhalin
@@ -1014,7 +1014,7 @@
10141014 if (!$noslip && $Set->Equal('BBS_SLIP', 'checked')) {
10151015 $str .= " $type";
10161016 }
1017- return " 発信元:$str";
1017+ return "発信元:$str";
10181018 }
10191019
10201020 # 各キャップ専用ID
@@ -1023,7 +1023,7 @@
10231023 if (!$noslip && $Set->Equal('BBS_SLIP', 'checked')) {
10241024 $str .= " $type";
10251025 }
1026- return " ID:$str";
1026+ return "ID:$str";
10271027 }
10281028
10291029 # ID表示
@@ -1041,7 +1041,7 @@
10411041 if (!$noslip && $Set->Equal('BBS_SLIP', 'checked')) {
10421042 $str .= "$type";
10431043 }
1044- return " ID:$str";
1044+ return "ID:$str";
10451045 }
10461046 }
10471047
--- zerochplus/branches/0.7.x/test/module/vara.pl (revision 487)
+++ zerochplus/branches/0.7.x/test/module/vara.pl (revision 488)
@@ -49,12 +49,12 @@
4949 sub Init
5050 {
5151 my $this = shift;
52- my ($Sys, $Form, $Set, $Thread, $Conv) = @_;
52+ my ($Sys, $Form, $Set, $Threads, $Conv) = @_;
5353
5454 $this->{'SYS'} = $Sys;
5555 $this->{'FORM'} = $Form;
5656 $this->{'SET'} = $Set;
57- $this->{'THREADS'} = $Thread;
57+ $this->{'THREADS'} = $Threads;
5858 $this->{'CONV'} = $Conv;
5959
6060 # モジュールが用意されてない場合はここで生成する
@@ -63,7 +63,7 @@
6363 $this->{'SET'} = ISILDUR->new;
6464 $this->{'SET'}->Load($Sys);
6565 }
66- if (!defined $Thread) {
66+ if (!defined $Threads) {
6767 require './module/baggins.pl';
6868 $this->{'THREADS'} = BILBO->new;
6969 $this->{'THREADS'}->Load($Sys);
@@ -118,27 +118,42 @@
118118 my $Set = $this->{'SET'};
119119 my $Form = $this->{'FORM'};
120120 my $Conv = $this->{'CONV'};
121- my $Thread = $this->{'THREADS'};
121+ my $Threads = $this->{'THREADS'};
122+ my $Sec = $this->{'SECURITY'};
122123
124+ # 情報欄
125+ my $datepart = $Conv->GetDate($Set, $Sys->Get('MSEC'));
126+ my $id = $Conv->MakeIDnew($Sys, 8);
127+ my $idpart = $Conv->GetIDPart($Set, $Form, $Sec, $id, $Sys->Get('CAPID'), $Sys->Get('KOYUU'), $Sys->Get('AGENT'));
128+ my $bepart = '';
129+ my $extrapart = '';
130+ $Form->Set('datepart', $datepart);
131+ $Form->Set('idpart', $idpart);
132+ #$Form->Set('BEID', ''); # type=1|2
133+ $Form->Set('extrapart', $extrapart);
134+
123135 # 書き込み直前処理
124136 $err = $this->ReadyBeforeWrite(ARAGORN::GetNumFromFile($Sys->Get('DATPATH')) + 1);
125137 return $err if ($err != $ZP::E_SUCCESS);
126138
127139 # レス要素の取得
128- my @elem = ();
129- $Form->GetListData(\@elem, 'subject', 'FROM', 'mail', 'MESSAGE');
140+ my $subject = $Form->Get('subject', '');
141+ my $name = $Form->Get('FROM', '');
142+ my $mail = $Form->Get('mail', '');
143+ my $text = $Form->Get('MESSAGE', '');
130144
131- $err = $ZP::E_SUCCESS;
132- my $id = $Conv->MakeIDnew($Sys, 8);
133- my $date = $Conv->GetDate($Set, $Sys->Get('MSEC'));
134- $date .= $Conv->GetIDPart($Set, $Form, $this->{'SECURITY'}, $id, $Sys->Get('CAPID'), $Sys->Get('KOYUU'), $Sys->Get('AGENT'));
145+ $datepart = $Form->Get('datepart', '');
146+ $idpart = $Form->Get('idpart', '');
147+ $bepart = $Form->Get('BEID', '');
148+ $extrapart = $Form->Get('extrapart', '');
149+ my $info = $datepart;
150+ $info .= " $idpart" if ($idpart ne '');
151+ $info .= " $bepart" if ($bepart ne '');
152+ $info .= " $extrapart" if ($extrapart ne '');
135153
136- # プラグイン「 BE(HS)っぽいもの 」ver.0.x.x
137- my $beid = $Form->Get('BEID', '');
138- $date .= " $beid" if ($beid ne '');
154+ my $data = "$name<>$mail<>$info<>$text<>$subject";
155+ my $line = "$data\n";
139156
140- my $data = join('<>', $elem[1], $elem[2], $date, $elem[3], $elem[0]);
141- my $data2 = "$data\n";
142157 my $datPath = $Sys->Get('DATPATH');
143158
144159 # ログ書き込み
@@ -153,16 +168,17 @@
153168
154169 # datファイルへ直接書き込み
155170 my $resNum = 0;
156- my $err2 = ARAGORN::DirectAppend($Sys, $datPath, $data2);
171+ my $err2 = ARAGORN::DirectAppend($Sys, $datPath, $line);
157172 if ($err2 == 0) {
158173 # レス数が最大数を超えたらover設定をする
159174 $resNum = ARAGORN::GetNumFromFile($datPath);
160175 if ($resNum >= $Sys->Get('RESMAX')) {
161176 # datにOVERスレッドレスを書き込む
162- Get1001Data($Sys, \$data2);
163- ARAGORN::DirectAppend($Sys, $datPath, $data2);
177+ Get1001Data($Sys, \$line);
178+ ARAGORN::DirectAppend($Sys, $datPath, $line);
164179 $resNum++;
165180 }
181+ $err = $ZP::E_SUCCESS;
166182 }
167183 # datファイル追記失敗
168184 elsif ($err2 == 1) {
@@ -180,23 +196,23 @@
180196 my $path = $Sys->Get('BBSPATH') . '/' . $Sys->Get('BBS');
181197 my $Pools = FRODO->new;
182198 $Pools->Load($Sys);
183- $Thread->Add($Sys->Get('KEY'), $elem[0], 1);
199+ $Threads->Add($Sys->Get('KEY'), $subject, 1);
184200
185- while ($Thread->GetNum() > $Sys->Get('SUBMAX')) {
186- my $lid = $Thread->GetLastID();
187- $Pools->Add($lid, $Thread->Get('SUBJECT', $lid), $Thread->Get('RES', $lid));
188- $Thread->Delete($lid);
201+ while ($Threads->GetNum() > $Sys->Get('SUBMAX')) {
202+ my $lid = $Threads->GetLastID();
203+ $Pools->Add($lid, $Threads->Get('SUBJECT', $lid), $Threads->Get('RES', $lid));
204+ $Threads->Delete($lid);
189205 EARENDIL::Copy("$path/dat/$lid.dat", "$path/pool/$lid.cgi");
190206 unlink "$path/dat/$lid.dat";
191207 }
192208
193209 $Pools->Save($Sys);
194- $Thread->Save($Sys);
210+ $Threads->Save($Sys);
195211 }
196212 # 書き込みモードならレス数の更新
197213 else {
198214 my $sage = (!$Form->Contain('mail', 'sage') ? 1 : 0);
199- $Thread->OnDemand($Sys, $Sys->Get('KEY'), $resNum, $sage);
215+ $Threads->OnDemand($Sys, $Sys->Get('KEY'), $resNum, $sage);
200216 }
201217 }
202218
@@ -324,8 +340,8 @@
324340 $Form->Set('MESSAGE', " $text ");
325341
326342 # 名無し設定
327- $from = $Form->Get('FROM');
328- if (!$from) {
343+ $from = $Form->Get('FROM', '');
344+ if ($from eq '') {
329345 $from = $this->{'SET'}->Get('BBS_NONAME_NAME');
330346 $Form->Set('FROM', $from);
331347 }
Show on old repository browser