2011/08/21 投稿系。
@@ -31,6 +31,8 @@ | ||
31 | 31 | $this->artlSet['delete_mode'] = $GLOBALS['CNF']['delete_mode']; |
32 | 32 | $this->artlSet['edit_mode'] = $GLOBALS['CNF']['edit_mode']; |
33 | 33 | $this->artlSet['img_view'] = $GLOBALS['CNF']['img_view']; |
34 | + | |
35 | + $this->postSet['captcha'] = ""; | |
34 | 36 | |
35 | 37 | $this->set['pager'] = 0; |
36 | 38 |
@@ -81,6 +83,28 @@ | ||
81 | 83 | } |
82 | 84 | |
83 | 85 | |
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 | + | |
84 | 108 | //コンテント |
85 | 109 | $myContent = ''; |
86 | 110 |
@@ -93,13 +117,6 @@ | ||
93 | 117 | } |
94 | 118 | |
95 | 119 | |
96 | - //投稿チケット | |
97 | - if ( empty($_POST) ) { | |
98 | - $dh = $this->loadLib('DataHelper'); | |
99 | - $arc['ticket'] = $dh->encrypt( time(), EPITTAIDTF ); | |
100 | - } | |
101 | - | |
102 | - | |
103 | 120 | //echo "parent=" . $this->postSet['parent_id']; |
104 | 121 | |
105 | 122 | if ( $this->postSet['parent_id'] ) { |
@@ -151,6 +168,7 @@ | ||
151 | 168 | trigger_error ('Invalid article id!'); |
152 | 169 | } |
153 | 170 | |
171 | + | |
154 | 172 | $this->postSet['targetAct'] = 'modify'; |
155 | 173 | $this->initPostConfig(); |
156 | 174 |
@@ -165,12 +183,17 @@ | ||
165 | 183 | $artMdl = new Article_Model(); |
166 | 184 | $org = $artMdl->getSingleArticle( $this->getPost('article_id') ); |
167 | 185 | |
168 | - //パスワードセット確認 | |
186 | + | |
187 | + //投稿者パスワード確認 | |
169 | 188 | if ( empty($org['password']) ) { |
170 | 189 | |
171 | 190 | } |
172 | 191 | |
192 | + | |
193 | + //CAPTCHA | |
194 | + | |
173 | 195 | |
196 | + | |
174 | 197 | if ( $this->getPost('article_id') and ! isset($_POST['timekey']) ) { |
175 | 198 | //記事情報呼び出し |
176 | 199 | $arc = $org; |
@@ -273,42 +296,41 @@ | ||
273 | 296 | //バリデート |
274 | 297 | $vld = $this->loadLib('Validation'); |
275 | 298 | |
299 | + | |
276 | 300 | |
277 | - | |
278 | 301 | //投稿キーワード確認 |
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 | + } | |
280 | 307 | |
281 | - //var_dump($_POST); | |
282 | - | |
283 | - | |
284 | 308 | //投稿チケット確認 |
285 | 309 | $dh = $this->loadLib('DataHelper'); |
286 | 310 | $ticketTime = $dh->decrypt( $this->getPost('ticket'), EPITTAIDTF ); |
287 | 311 | $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']); | |
292 | 315 | } |
293 | 316 | |
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 | + } | |
295 | 323 | |
296 | - echo 'a:'.$now; | |
297 | - echo 'b:'.$ticketTime; | |
298 | - | |
299 | - | |
300 | - | |
301 | 324 | //まずここで |
302 | 325 | if ( ! empty($vld->errMsgs) ) { |
303 | 326 | $this->postSet['errMessage'] = $GLOBALS['LNG']['postInvalid']; |
304 | 327 | $this->postSet['errMsgAry'] = $vld->errMsgs; |
305 | - | |
328 | + | |
306 | 329 | if ( $this->action = 'create' ) { |
307 | 330 | $this->createInput(2); |
308 | 331 | } else { |
309 | 332 | $this->modifyInput(2); |
310 | - } | |
311 | - | |
333 | + } | |
312 | 334 | return; |
313 | 335 | } |
314 | 336 |
@@ -559,7 +581,7 @@ | ||
559 | 581 | * @param int id |
560 | 582 | * @param string password |
561 | 583 | */ |
562 | - private function checkPassword($id, $passoword) | |
584 | + private function checkUserPassword($id, $passoword) | |
563 | 585 | { |
564 | 586 | $ret = true; |
565 | 587 |
@@ -57,39 +57,15 @@ | ||
57 | 57 | |
58 | 58 | |
59 | 59 | |
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 | - | |
85 | 60 | /** |
86 | - * 時間制限キーの暗号化 | |
61 | + * 暗号化。 | |
62 | + * 時間制限キーなど。 | |
87 | 63 | * |
88 | 64 | */ |
89 | - public function encrypt($timestamp, $salt) | |
65 | + public function encrypt($value, $salt) | |
90 | 66 | { |
91 | 67 | |
92 | - if ( ! $timestamp ) return ''; | |
68 | + if ( ! $value ) return ''; | |
93 | 69 | |
94 | 70 | require_once(SYSPATH . '/imports/pcrypt/class.pcrypt.php' ); |
95 | 71 | require_once(SYSPATH . '/imports/pcrypt/cipher/blowfish.php' ); |
@@ -96,7 +72,7 @@ | ||
96 | 72 | |
97 | 73 | //暗号化 |
98 | 74 | $crypt = new pcrypt(MODE_ECB, "BLOWFISH", $salt); |
99 | - $crypted = $crypt->encrypt($timestamp); | |
75 | + $crypted = $crypt->encrypt($value); | |
100 | 76 | |
101 | 77 | // |
102 | 78 | return base64_encode($crypted); |
@@ -105,7 +81,8 @@ | ||
105 | 81 | |
106 | 82 | |
107 | 83 | /** |
108 | - * 時間制限キーを復号化して照合 | |
84 | + * 復号化。 | |
85 | + * 時間制限キーなど。 | |
109 | 86 | * |
110 | 87 | */ |
111 | 88 | public function decrypt($cryptedEnc64, $salt) |
@@ -127,7 +104,26 @@ | ||
127 | 104 | } |
128 | 105 | |
129 | 106 | |
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"; | |
130 | 118 | |
119 | + // | |
120 | + return sprintf($dgt, $rand); | |
121 | + | |
122 | + | |
123 | + } | |
124 | + | |
125 | + | |
126 | + | |
131 | 127 | } |
132 | 128 | |
133 | 129 | ?> |
\ No newline at end of file |
@@ -53,7 +53,9 @@ | ||
53 | 53 | 'icon' => 'アイコン', |
54 | 54 | 'fontColor' => '本文文字色', |
55 | 55 | 'captcha' => '画像認証', |
56 | -'submitKey' => '投稿キーワード', | |
56 | +'captchaKey' => '画像認証キー', | |
57 | +'mySubmitKey' => '投稿キーワード', | |
58 | + | |
57 | 59 | 'submitButton' => ' 投 稿 ', |
58 | 60 | 'modifyButton' => ' 編 集 ', |
59 | 61 | 'addModButton' => ' 追 記 ', |
@@ -96,6 +98,9 @@ | ||
96 | 98 | |
97 | 99 | |
98 | 100 | 'postInvalid' => '入力に不備があります', |
101 | +'invalidTicket' => '投稿までの時間がかかりすぎました。あらためて投稿しなおしてください。', | |
102 | +'invalidPostKeyword' => '投稿キーワードが正しくありません。', | |
103 | + | |
99 | 104 | 'failedPassword' => 'パスワードが不正です。', |
100 | 105 | 'failedFileType' => '添付するファイルのタイプが許可されていません。', |
101 | 106 | 'failedFileSize' => '添付するファイルのサイズが制限を超えています。', |
@@ -41,17 +41,17 @@ | ||
41 | 41 | |
42 | 42 | if ( $clip1 ) { |
43 | 43 | $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> | |
45 | 45 | HTML; |
46 | 46 | } |
47 | 47 | if ( $clip2 ) { |
48 | 48 | $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> | |
50 | 50 | HTML; |
51 | 51 | } |
52 | 52 | if ( $clip3 ) { |
53 | 53 | $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> | |
55 | 55 | HTML; |
56 | 56 | } |
57 | 57 |
@@ -7,7 +7,7 @@ | ||
7 | 7 | $clips = makeFileUpload($postSet['clipfile']); |
8 | 8 | $ftclr = makeFontColorSelect($postSet['ftcolor_on'], $postSet['ftcolors'], $art['fontcolor']); |
9 | 9 | $icon = makeIconSelect($postSet['icon_on'], $postSet['icons'], $art['iconfile']); |
10 | - $captc = makeCaptcha($postSet['captcha_on']); | |
10 | + $captc = makeCaptcha($postSet['captcha_on'], $postSet['captcha']); | |
11 | 11 | $kword = makeKeyword($postSet['keyword_on'], $postSet['keyword_q'], $postSet['keyword_a']); |
12 | 12 | $prev = makePreview($postSet['preview']); |
13 | 13 | $err = makeError($postSet['errMessage'], $postSet['errMsgAry']); |
@@ -412,9 +412,22 @@ | ||
412 | 412 | return $myContent; |
413 | 413 | } |
414 | 414 | |
415 | -function makeCaptcha($flag) { | |
415 | +function makeCaptcha($flag, $strNum) { | |
416 | 416 | $myContent = ''; |
417 | 417 | |
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 | + | |
418 | 431 | return $myContent; |
419 | 432 | } |
420 | 433 |
@@ -422,6 +435,12 @@ | ||
422 | 435 | function makeKeyword($flag, $qst, $asw) { |
423 | 436 | $myContent = ''; |
424 | 437 | |
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 | + | |
425 | 444 | return $myContent; |
426 | 445 | } |
427 | 446 |