• R/O
  • SSH
  • HTTPS

epitta-bbs: Commit


Commit MetaInfo

Revision30 (tree)
Time2011-08-21 17:34:35
Authorwajett

Log Message

2011/08/21 投稿系。

Change Summary

Incremental Difference

--- app/actions/post_action.php (revision 29)
+++ app/actions/post_action.php (revision 30)
@@ -31,6 +31,8 @@
3131 $this->artlSet['delete_mode'] = $GLOBALS['CNF']['delete_mode'];
3232 $this->artlSet['edit_mode'] = $GLOBALS['CNF']['edit_mode'];
3333 $this->artlSet['img_view'] = $GLOBALS['CNF']['img_view'];
34+
35+ $this->postSet['captcha'] = "";
3436
3537 $this->set['pager'] = 0;
3638
@@ -81,6 +83,28 @@
8183 }
8284
8385
86+ //投稿チケット・CAPTCHAパス
87+ if ( empty($_POST) ) {
88+ $dh = $this->loadLib('DataHelper');
89+
90+ //投稿チケット
91+ $arc['ticket'] = $dh->encrypt( time(), EPITTAIDTF );
92+
93+ //CAPTCHAパス
94+ if ( $GLOBALS['CNF']['captcha_on'] == 1 ) {
95+ $this->postSet['captcha'] = $dh->makeRandomNumbers();
96+ }
97+
98+ } else {
99+
100+ //CAPTCHAパス
101+ if ( $GLOBALS['CNF']['captcha_on'] == 1 ) {
102+ $this->postSet['captcha_enc'] = $this->getPost('captcha_enc');
103+ }
104+
105+ }
106+
107+
84108 //コンテント
85109 $myContent = '';
86110
@@ -93,13 +117,6 @@
93117 }
94118
95119
96- //投稿チケット
97- if ( empty($_POST) ) {
98- $dh = $this->loadLib('DataHelper');
99- $arc['ticket'] = $dh->encrypt( time(), EPITTAIDTF );
100- }
101-
102-
103120 //echo "parent=" . $this->postSet['parent_id'];
104121
105122 if ( $this->postSet['parent_id'] ) {
@@ -151,6 +168,7 @@
151168 trigger_error ('Invalid article id!');
152169 }
153170
171+
154172 $this->postSet['targetAct'] = 'modify';
155173 $this->initPostConfig();
156174
@@ -165,12 +183,17 @@
165183 $artMdl = new Article_Model();
166184 $org = $artMdl->getSingleArticle( $this->getPost('article_id') );
167185
168- //パスワードセット確認
186+
187+ //投稿者パスワード確認
169188 if ( empty($org['password']) ) {
170189
171190 }
172191
192+
193+ //CAPTCHA
194+
173195
196+
174197 if ( $this->getPost('article_id') and ! isset($_POST['timekey']) ) {
175198 //記事情報呼び出し
176199 $arc = $org;
@@ -273,42 +296,41 @@
273296 //バリデート
274297 $vld = $this->loadLib('Validation');
275298
299+
276300
277-
278301 //投稿キーワード確認
279-
302+ if ( $GLOBALS['CNF']['keyword_on'] == 1 ) {
303+ if ( $this->getPost('ticket') != $GLOBALS['CNF']['keyword_a'] ) {
304+ array_push($vld->errMsgs, $GLOBALS['LNG']['invalidPostKeyword']);
305+ }
306+ }
280307
281- //var_dump($_POST);
282-
283-
284308 //投稿チケット確認
285309 $dh = $this->loadLib('DataHelper');
286310 $ticketTime = $dh->decrypt( $this->getPost('ticket'), EPITTAIDTF );
287311 $now = time();
288- if ( $now - $ticketTime < 3600 ) {
289- //
290- //array_push($vld->errMsgs, $GLOBALS['LNG']['invalidTicket'] . " - " . $now . " - " . $ticketTime);
291-
312+ $now = $now + 7000;
313+ if ( empty($ticketTime) or $now - $ticketTime >= $GLOBALS['CNF']['ticket_limit'] ) {
314+ array_push($vld->errMsgs, $GLOBALS['LNG']['invalidTicket']);
292315 }
293316
294- array_push($vld->errMsgs, " - " . $now . " - " . $ticketTime);
317+ //画像認証確認
318+ if ( $GLOBALS['CNF']['captcha_on'] == 1 ) {
319+ if ( $this->getPost('captcha') != $GLOBALS['CNF']['keyword_a'] ) {
320+ array_push($vld->errMsgs, $GLOBALS['LNG']['invalidPostKeyword']);
321+ }
322+ }
295323
296- echo 'a:'.$now;
297- echo 'b:'.$ticketTime;
298-
299-
300-
301324 //まずここで
302325 if ( ! empty($vld->errMsgs) ) {
303326 $this->postSet['errMessage'] = $GLOBALS['LNG']['postInvalid'];
304327 $this->postSet['errMsgAry'] = $vld->errMsgs;
305-
328+
306329 if ( $this->action = 'create' ) {
307330 $this->createInput(2);
308331 } else {
309332 $this->modifyInput(2);
310- }
311-
333+ }
312334 return;
313335 }
314336
@@ -559,7 +581,7 @@
559581 * @param int id
560582 * @param string password
561583 */
562- private function checkPassword($id, $passoword)
584+ private function checkUserPassword($id, $passoword)
563585 {
564586 $ret = true;
565587
--- app/libs/dataHelper.php (revision 29)
+++ app/libs/dataHelper.php (revision 30)
@@ -57,39 +57,15 @@
5757
5858
5959
60-// /**
61-// *
62-// * @param string salt
63-// * @param string pass
64-// */
65-// public function makePasswordHash($pass)
66-// {
67-//
68-// if ( $pass == "") return "";
69-//
70-//
71-// $hashed = "";
72-//
73-//
74-// //if ( ! $pass ) return '';
75-// $str = '';
76-//
77-//
78-// //
79-// return hash('sha1', $str );
80-//
81-// }
82-
83-
84-
8560 /**
86- * 時間制限キーの暗号化
61+ * 暗号化。
62+ * 時間制限キーなど。
8763 *
8864 */
89- public function encrypt($timestamp, $salt)
65+ public function encrypt($value, $salt)
9066 {
9167
92- if ( ! $timestamp ) return '';
68+ if ( ! $value ) return '';
9369
9470 require_once(SYSPATH . '/imports/pcrypt/class.pcrypt.php' );
9571 require_once(SYSPATH . '/imports/pcrypt/cipher/blowfish.php' );
@@ -96,7 +72,7 @@
9672
9773 //暗号化
9874 $crypt = new pcrypt(MODE_ECB, "BLOWFISH", $salt);
99- $crypted = $crypt->encrypt($timestamp);
75+ $crypted = $crypt->encrypt($value);
10076
10177 //
10278 return base64_encode($crypted);
@@ -105,7 +81,8 @@
10581
10682
10783 /**
108- * 時間制限キーを復号化して照合
84+ * 復号化。
85+ * 時間制限キーなど。
10986 *
11087 */
11188 public function decrypt($cryptedEnc64, $salt)
@@ -127,7 +104,26 @@
127104 }
128105
129106
107+ /**
108+ * ランダムな数字の生成。
109+ * CAPTCHAなど。
110+ *
111+ */
112+ public function makeRandomNumbers($max=9999)
113+ {
114+
115+ $rand = mt_rand(1, $max);
116+
117+ $dgt = "%'0" . strlen($max) . "d";
130118
119+ //
120+ return sprintf($dgt, $rand);
121+
122+
123+ }
124+
125+
126+
131127 }
132128
133129 ?>
\ No newline at end of file
--- system/locals/ja/wordlist.php (revision 29)
+++ system/locals/ja/wordlist.php (revision 30)
@@ -53,7 +53,9 @@
5353 'icon' => 'アイコン',
5454 'fontColor' => '本文文字色',
5555 'captcha' => '画像認証',
56-'submitKey' => '投稿キーワード',
56+'captchaKey' => '画像認証キー',
57+'mySubmitKey' => '投稿キーワード',
58+
5759 'submitButton' => ' 投 稿 ',
5860 'modifyButton' => ' 編 集 ',
5961 'addModButton' => ' 追 記 ',
@@ -96,6 +98,9 @@
9698
9799
98100 'postInvalid' => '入力に不備があります',
101+'invalidTicket' => '投稿までの時間がかかりすぎました。あらためて投稿しなおしてください。',
102+'invalidPostKeyword' => '投稿キーワードが正しくありません。',
103+
99104 'failedPassword' => 'パスワードが不正です。',
100105 'failedFileType' => '添付するファイルのタイプが許可されていません。',
101106 'failedFileSize' => '添付するファイルのサイズが制限を超えています。',
--- views/pc/default/tree.php (revision 29)
+++ views/pc/default/tree.php (revision 30)
@@ -41,17 +41,17 @@
4141
4242 if ( $clip1 ) {
4343 $myContent .=<<< HTML
44- <span class="clip"><img src="{$pubUrl}/img/clip.gif"></span>
44+ <span class="clip"><img src="{$pubUrl}/img/icon_clip.gif"></span>
4545 HTML;
4646 }
4747 if ( $clip2 ) {
4848 $myContent .=<<< HTML
49- <span class="clip"><img src="{$pubUrl}/img/clip.gif"></span>
49+ <span class="clip"><img src="{$pubUrl}/img/icon_clip.gif"></span>
5050 HTML;
5151 }
5252 if ( $clip3 ) {
5353 $myContent .=<<< HTML
54- <span class="clip"><img src="{$pubUrl}/img/clip.gif"></a></span>
54+ <span class="clip"><img src="{$pubUrl}/img/icon_clip.gif"></a></span>
5555 HTML;
5656 }
5757
--- views/pc/default/article_input.php (revision 29)
+++ views/pc/default/article_input.php (revision 30)
@@ -7,7 +7,7 @@
77 $clips = makeFileUpload($postSet['clipfile']);
88 $ftclr = makeFontColorSelect($postSet['ftcolor_on'], $postSet['ftcolors'], $art['fontcolor']);
99 $icon = makeIconSelect($postSet['icon_on'], $postSet['icons'], $art['iconfile']);
10- $captc = makeCaptcha($postSet['captcha_on']);
10+ $captc = makeCaptcha($postSet['captcha_on'], $postSet['captcha']);
1111 $kword = makeKeyword($postSet['keyword_on'], $postSet['keyword_q'], $postSet['keyword_a']);
1212 $prev = makePreview($postSet['preview']);
1313 $err = makeError($postSet['errMessage'], $postSet['errMsgAry']);
@@ -412,9 +412,22 @@
412412 return $myContent;
413413 }
414414
415-function makeCaptcha($flag) {
415+function makeCaptcha($flag, $strNum) {
416416 $myContent = '';
417417
418+ if ( $flag == 1 ) {
419+
420+$myContent .=<<< HTML
421+ <div class="itemInput">
422+ $strNum
423+ <img src="">
424+ <input type="hidden" name="captcha_enc" value="$strNum" />
425+ </div>
426+ <div class="clear"></div>
427+HTML;
428+
429+ }
430+
418431 return $myContent;
419432 }
420433
@@ -422,6 +435,12 @@
422435 function makeKeyword($flag, $qst, $asw) {
423436 $myContent = '';
424437
438+$myContent .=<<< HTML
439+ <div class="itemName">{$GLOBALS['LNG']['mySubmitKey']}:</div>
440+ <div class="itemInput"><img src=""></div>
441+ <div class="clear"></div>
442+HTML;
443+
425444 return $myContent;
426445 }
427446
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Show on old repository browser