2011/05/04 投稿系など。
@@ -124,7 +124,7 @@ | ||
124 | 124 | $this->content = $myContent; |
125 | 125 | |
126 | 126 | |
127 | - //$this->set['view'] = __FUNCTION__; | |
127 | + $this->set['view'] = __FUNCTION__; | |
128 | 128 | $this->setLayout('base'); |
129 | 129 | |
130 | 130 |
@@ -13,6 +13,9 @@ | ||
13 | 13 | class Post_Action extends Base_Action { |
14 | 14 | |
15 | 15 | |
16 | + var $postSet = array(); | |
17 | + | |
18 | + | |
16 | 19 | public function __construct() |
17 | 20 | { |
18 | 21 | parent::__construct(); |
@@ -31,33 +34,81 @@ | ||
31 | 34 | } |
32 | 35 | |
33 | 36 | |
34 | - public function createInput($parentId=0) | |
37 | + /** | |
38 | + * createInput | |
39 | + * | |
40 | + * @param integer $mode 1:投稿 2:投稿戻り 3:確認 | |
41 | + * @param integer $parentId | |
42 | + * @return bool | |
43 | + * | |
44 | + */ | |
45 | + public function createInput($mode=1) | |
35 | 46 | { |
36 | 47 | |
48 | + $this->postSet['targetAct'] = 'create'; | |
49 | + $this->postSet['clipfile'] = $GLOBALS['CNF']['clipfile']; | |
50 | + $this->postSet['ftcolor_on'] = $GLOBALS['CNF']['ftcolor_on']; | |
51 | + $this->postSet['ftcolors'] = $GLOBALS['CNF']['ftcolors']; | |
52 | + $this->postSet['icon_on'] = $GLOBALS['CNF']['icon_on']; | |
53 | + $this->postSet['icons'] = $GLOBALS['CNF']['icons']; | |
54 | + | |
55 | + $this->postSet['keyword_on'] = $GLOBALS['CNF']['keyword_on']; | |
56 | + $this->postSet['keyword_q'] = $GLOBALS['CNF']['keyword_q']; | |
57 | + $this->postSet['keyword_a'] = $GLOBALS['CNF']['keyword_a']; | |
58 | + | |
59 | + $this->postSet['timekey'] = 'faketimekey'; | |
60 | + | |
61 | + $this->postSet['captcha_on'] = $GLOBALS['CNF']['captcha_on']; | |
62 | + $this->postSet['captcha_number'] = ""; | |
63 | + $this->postSet['captcha_key'] = ""; | |
64 | + | |
65 | + $this->postSet['preview'] = ''; | |
66 | + | |
67 | + //$this->postSet = array(); | |
68 | + $this->postSet['article_id'] = 0; | |
69 | + $this->postSet['parent_id'] = ''; | |
70 | + | |
71 | + if ( $mode == 1 ) { | |
72 | + $this->postSet['errMessage'] = ''; | |
73 | + $this->postSet['errMsgAry'] = array(); | |
74 | + } | |
75 | + | |
76 | + | |
77 | + | |
37 | 78 | //スキン |
38 | 79 | $this->readSkin('article_input'); |
80 | + $this->readSkin('article'); | |
39 | 81 | |
82 | + //返信モード切り替え | |
83 | + if ( $this->getPost('parent_id') ){ | |
84 | + $this->postSet['parent_id'] = $this->getPost('parent_id'); | |
85 | + } | |
40 | 86 | |
41 | - $postSet = array(); | |
42 | - $postSet['clipfile'] = $GLOBALS['CNF']['clipfile']; | |
43 | 87 | |
44 | - $postSet['timekey'] = ''; | |
88 | + //1:投稿 2:投稿戻り 3:確認 | |
89 | + if ( $mode == 1 or $this->action=='crtipt' ) { | |
90 | + $arc = $this->getArtcleHash(); | |
45 | 91 | |
46 | - $postSet['captcha_on'] = $GLOBALS['CNF']['captcha_on']; | |
47 | - $postSet['captcha_number'] = ""; | |
48 | - $postSet['captcha_key'] = ""; | |
92 | + } else if ( $mode == 2 ) { | |
93 | + $arc = $this->stripslashes_deep($_POST); | |
49 | 94 | |
50 | - $postSet['keyword_on'] = $GLOBALS['CNF']['keyword_on']; | |
51 | - $postSet['keyword_q'] = $GLOBALS['CNF']['keyword_q']; | |
52 | - $postSet['keyword_a'] = $GLOBALS['CNF']['keyword_a']; | |
95 | + } else { | |
96 | + $arc = $this->stripslashes_deep($_POST); | |
97 | + //var_dump($arc); | |
98 | + } | |
53 | 99 | |
54 | 100 | |
55 | - | |
56 | - | |
57 | 101 | //コンテント |
58 | 102 | $myContent = ''; |
59 | - $myContent = geArticleInput($this->baseSet, $this->getArtcleHash(), $postSet, 1); | |
60 | 103 | |
104 | + if ( $mode==3 ) { | |
105 | + $arc['created_at'] = date( "Y/m/d H:i:s", time() ); | |
106 | + $arc['clipfile1'] = ''; $arc['clipfile2'] = ''; $arc['clipfile3'] = ''; | |
107 | + $this->postSet['preview'] = getArticleHtml($arc); | |
108 | + } | |
109 | + | |
110 | + $myContent .= geArticleInputHtml($this->baseSet, $arc, $this->postSet, 1); | |
111 | + | |
61 | 112 | $this->content = $myContent; |
62 | 113 | |
63 | 114 | $this->set['view'] = 'input'; |
@@ -71,26 +122,80 @@ | ||
71 | 122 | |
72 | 123 | public function resInput() |
73 | 124 | { |
74 | - $parentId = 1; | |
75 | 125 | |
76 | - $this->createInput($parentId); | |
126 | + $this->createInput(1); | |
127 | + return; | |
128 | + | |
77 | 129 | } |
78 | 130 | |
79 | 131 | |
132 | +/* | |
80 | 133 | public function createConfirm() |
81 | 134 | { |
82 | - | |
83 | - | |
135 | + if ( isset($_POST['confirm']) and $_POST['confirm']==1) { | |
136 | + $this->createInput(2); | |
137 | + } else { | |
138 | + $this->create(); | |
139 | + } | |
140 | + return; | |
84 | 141 | } |
85 | - | |
142 | +*/ | |
86 | 143 | |
87 | 144 | |
88 | 145 | |
89 | 146 | public function create() |
90 | 147 | { |
148 | + | |
149 | + //var_dump($_POST); | |
150 | + | |
151 | + | |
152 | + //バリデート | |
153 | + $vld = $this->lordLib('Validation'); | |
154 | + $this->postSet['errMessage'] = ''; | |
155 | + $this->postSet['errMsgAry'] = array(); | |
156 | + | |
157 | + $vld->run( $this->getPost('author'), '投稿者名', "required|max_len&20" ); | |
158 | + $vld->run( $this->getPost('subject'), '題名', "required|max_len&50" ); | |
159 | + $vld->run( $this->getPost('article'), '本文', "required|min_len&3|max_len&5000" ); | |
160 | + $vld->run( $this->getPost('article'), '本文', "required|min_len&3|max_len&5000" ); | |
161 | + | |
162 | + if ( ! empty($vld->errMsgs) ) { | |
163 | + $this->postSet['errMessage'] = translateTo('postInvalid'); | |
164 | + $this->postSet['errMsgAry'] = $vld->errMsgs; | |
165 | + $this->createInput(2); | |
166 | + //var_dump($vld->errMsgs); | |
167 | + return; | |
168 | + } | |
169 | + | |
170 | + if ( isset($_POST['confirm']) and $_POST['confirm']==1) { | |
171 | + $this->createInput(3); | |
172 | + } | |
173 | + | |
174 | + /* | |
175 | + $myPost = $this->getPost(''); | |
176 | + $myPost = $this->getPostAll(''); | |
177 | + | |
178 | + | |
179 | + * | |
180 | + */ | |
181 | + | |
182 | + $data = $this->getPostArticle(); | |
183 | + | |
184 | + var_dump($data); | |
185 | + | |
186 | + if ( ! empty($data['article_id']) and $data['article_id']>0 ) { | |
187 | + | |
188 | + | |
189 | + } else { | |
190 | + | |
191 | + | |
192 | + } | |
193 | + | |
194 | + | |
195 | + | |
196 | + exit; | |
197 | + return; | |
91 | 198 | |
92 | - | |
93 | - | |
94 | 199 | } |
95 | 200 | |
96 | 201 |
@@ -75,6 +75,7 @@ | ||
75 | 75 | } else { |
76 | 76 | $this->set['dataURL'] = DATAURL ."/default"; |
77 | 77 | } |
78 | + $this->set['pubURL'] = PUBURL; | |
78 | 79 | |
79 | 80 | } |
80 | 81 |
@@ -125,23 +126,72 @@ | ||
125 | 126 | } |
126 | 127 | |
127 | 128 | |
128 | - protected function getRequest($param, $def) | |
129 | + protected function getRequest($name, $def) | |
129 | 130 | { |
130 | 131 | $req = $def; |
131 | - if ( isset( $_POST[$param]) ) { | |
132 | - $req = $_POST[$param]; | |
133 | - } else if ( isset( $_GET[$param]) ) { | |
134 | - $req = $_GET[$param]; | |
132 | + if ( isset($_POST[$name]) ) { | |
133 | + $req = $_POST[$name]; | |
134 | + } else if ( isset($_GET[$name]) ) { | |
135 | + $req = $_GET[$name]; | |
135 | 136 | } |
136 | 137 | return $req; |
137 | 138 | } |
138 | 139 | |
139 | 140 | |
141 | + | |
142 | + | |
143 | + protected function lordLib($className) | |
144 | + | |
145 | + { | |
146 | + require_once( APPPATH. "/libs/" . strtolower ($className). '.php' ); | |
147 | + return new $className(); | |
148 | + } | |
149 | + | |
150 | + | |
151 | + | |
152 | + protected function stripslashes_deep($value) | |
153 | + { | |
154 | + $value = is_array($value) ? | |
155 | + array_map( array($this, 'stripslashes_deep'), $value) : | |
156 | + stripslashes($value); | |
157 | + | |
158 | + return $value; | |
159 | + } | |
160 | + | |
161 | + | |
162 | + | |
163 | + protected function getPost($name, $def='') | |
164 | + { | |
165 | + $req = $def; | |
166 | + if ( isset($_POST[$name]) ) { | |
167 | + $req = $_POST[$name]; | |
168 | + } else if ( isset($_GET[$name]) ) { | |
169 | + $req = $_GET[$name]; | |
170 | + } | |
171 | + return $req; | |
172 | + } | |
173 | + | |
174 | + | |
175 | + protected function getPostArticle() | |
176 | + { | |
177 | + | |
178 | + $artHash = $this->getArtcleHash(); | |
179 | + | |
180 | + $data = array(); | |
181 | + foreach( $artHash as $key => $val ) { | |
182 | + | |
183 | + $data[$key] = htmlentities($_POST[$key]); | |
184 | + | |
185 | + } | |
186 | + | |
187 | + } | |
188 | + | |
189 | + | |
140 | 190 | protected function getArtcleHash() { |
141 | 191 | |
142 | 192 | return array( |
143 | 193 | |
144 | - 'id' => '', | |
194 | + 'article_id' => '', //id | |
145 | 195 | 'tree_number' => '', |
146 | 196 | 'parent_id' => '', |
147 | 197 | 'subject' => '', |
@@ -174,6 +224,8 @@ | ||
174 | 224 | |
175 | 225 | |
176 | 226 | |
227 | + | |
228 | + | |
177 | 229 | protected function displayError($msg='') |
178 | 230 | { |
179 | 231 |
@@ -30,7 +30,7 @@ | ||
30 | 30 | $arts = $onPage * ($pageNum-1); |
31 | 31 | //$arts = $onPage * ($pageNum-1); |
32 | 32 | |
33 | - echo "arts=".$arts; | |
33 | + //echo "arts=".$arts; | |
34 | 34 | |
35 | 35 | |
36 | 36 | //最も新しい |
@@ -10,9 +10,12 @@ | ||
10 | 10 | |
11 | 11 | |
12 | 12 | |
13 | -class Post_Action extends Base_Action { | |
13 | +class validation { | |
14 | 14 | |
15 | 15 | |
16 | + var $errMsgs = array(); | |
17 | + | |
18 | + | |
16 | 19 | public function __construct() |
17 | 20 | { |
18 | 21 |
@@ -19,21 +22,444 @@ | ||
19 | 22 | } |
20 | 23 | |
21 | 24 | |
22 | - public function input() | |
25 | + | |
26 | + /** | |
27 | + * バリデーションを実行する。 | |
28 | + * | |
29 | + * @param "required|numeric|length&0|min_len&0|max_len&0|alpha_dash|email" | |
30 | + * @return | |
31 | + * | |
32 | + */ | |
33 | + public function run( $value="", $name="?", $order="" ) { | |
34 | + | |
35 | + try { | |
36 | + | |
37 | + | |
38 | + //事前チェック | |
39 | + if ( empty( $order ) ) { | |
40 | + array_push( $this->errMsgs, $name . $this->getMessage("000") ); | |
41 | + return; | |
42 | + } else { | |
43 | + $orderAry= explode( "|", $order ); | |
44 | + if ( count($orderAry) == 0 ) { | |
45 | + array_push( $this->errMsgs, $name . $this->getMessage("000") ); | |
46 | + return; | |
47 | + } | |
48 | + } | |
49 | + | |
50 | + | |
51 | + // | |
52 | + $errFlag = false; | |
53 | + foreach ( $orderAry as $odr ) { | |
54 | + | |
55 | + if ( $odr == "required" ) { | |
56 | + //必須チェック | |
57 | + if ( ! $this->required($value) ) { | |
58 | + array_push( $this->errMsgs, $name . $this->getMessage("001") ); | |
59 | + $errFlag = true; | |
60 | + } | |
61 | + | |
62 | + } else if ( mb_eregi("length.*", $odr) ) { | |
63 | + //文字数チェック | |
64 | + $lenAry = explode( "&", $odr ); | |
65 | + if ( count($lenAry) == 2 ) { | |
66 | + if ( ! $this->length($value, $lenAry[1] ) ) { | |
67 | + array_push( $this->errMsgs, $name . $this->getMessage("002", $lenAry[1] ) ); | |
68 | + $errFlag = true; | |
69 | + } | |
70 | + } else { | |
71 | + array_push( $this->errMsgs, $name . $this->getMessage("err") ); | |
72 | + } | |
73 | + | |
74 | + } else if ( mb_eregi("min_len.*", $odr) ) { | |
75 | + //最小文字数チェック | |
76 | + $lenAry = explode( "&", $odr ); | |
77 | + if ( count($lenAry) == 2 ) { | |
78 | + if ( ! $this->min_len($value, $lenAry[1] ) ) { | |
79 | + array_push( $this->errMsgs, $name . $this->getMessage("003", $lenAry[1] ) ); | |
80 | + $errFlag = true; | |
81 | + } | |
82 | + } else { | |
83 | + array_push( $this->errMsgs, $name . $this->getMessage("err") ); | |
84 | + } | |
85 | + | |
86 | + } else if ( mb_eregi("max_len.*", $odr) ) { | |
87 | + //最大文字数チェック | |
88 | + $lenAry = explode( "&", $odr ); | |
89 | + if ( count($lenAry) == 2 ) { | |
90 | + if ( ! $this->max_len($value, $lenAry[1] ) ) { | |
91 | + array_push( $this->errMsgs, $name . $this->getMessage("004", $lenAry[1] ) ); | |
92 | + $errFlag = true; | |
93 | + } | |
94 | + } else { | |
95 | + array_push( $this->errMsgs, $name . $this->getMessage("err") ); | |
96 | + } | |
97 | + | |
98 | + } else if ( $odr == "numeric" ) { | |
99 | + //数字チェック | |
100 | + if ( ! $this->numeric($value) ) { | |
101 | + array_push( $this->errMsgs, $name . $this->getMessage("005") ); | |
102 | + $errFlag = true; | |
103 | + } | |
104 | + | |
105 | + } else if ( $odr == "int" ) { | |
106 | + //整数チェック | |
107 | + if ( ! $this->int($value) ) { | |
108 | + array_push( $this->errMsgs, $name . $this->getMessage("005b") ); | |
109 | + $errFlag = true; | |
110 | + } | |
111 | + | |
112 | + } else if ( $odr == "alpha_dash" ) { | |
113 | + //英数字・アンダーバー・ハイフン | |
114 | + if ( ! $this->alpha_dash($value) ) { | |
115 | + array_push( $this->errMsgs, $name . $this->getMessage("006") ); | |
116 | + $errFlag = true; | |
117 | + } | |
118 | + | |
119 | + } else if ( $odr == "email" ) { | |
120 | + //Eメール | |
121 | + if ( ! $this->email($value) ) { | |
122 | + array_push( $this->errMsgs, $name . $this->getMessage("007") ); | |
123 | + $errFlag = true; | |
124 | + } | |
125 | + | |
126 | + } else if ( $odr == "url" ) { | |
127 | + //URL | |
128 | + if ( ! $this->url($value) ) { | |
129 | + array_push( $this->errMsgs, $name . $this->getMessage("008") ); | |
130 | + $errFlag = true; | |
131 | + } | |
132 | + | |
133 | + } else if ( $odr == "hira" ) { | |
134 | + //ひらがな | |
135 | + if ( ! $this->hira($value) ) { | |
136 | + array_push( $this->errMsgs, $name . $this->getMessage("010") ); | |
137 | + $errFlag = true; | |
138 | + } | |
139 | + | |
140 | + } else if ( $odr == "hankana" ) { | |
141 | + //半角カタカナ | |
142 | + if ( ! $this->hankana($value) ) { | |
143 | + array_push( $this->errMsgs, $name . $this->getMessage("011") ); | |
144 | + $errFlag = true; | |
145 | + } | |
146 | + | |
147 | + } else if ( $odr == "date" ) { | |
148 | + //日付 | |
149 | + if ( ! $this->date($value) ) { | |
150 | + array_push( $this->errMsgs, $name . $this->getMessage("021") ); | |
151 | + $errFlag = true; | |
152 | + } | |
153 | + | |
154 | + | |
155 | + } else { | |
156 | + echo $odr . " is not exists in the Validation!\n"; | |
157 | + } | |
158 | + | |
159 | + //エラーはひとつだけ表示する | |
160 | + if ( $errFlag == true ) break; | |
161 | + | |
162 | + } | |
163 | + | |
164 | + | |
165 | + if ( $errFlag == true ) { | |
166 | + return false; | |
167 | + } else { | |
168 | + return true; | |
169 | + } | |
170 | + | |
171 | + | |
172 | + } catch (Exception $ex) { | |
173 | + return; | |
174 | + } | |
175 | + | |
176 | + } | |
177 | + | |
178 | + | |
179 | + | |
180 | + | |
181 | + // -------------------------------------------------------------------- | |
182 | + | |
183 | + | |
184 | + /** | |
185 | + * Required | |
186 | + * | |
187 | + * @access public | |
188 | + * @param string | |
189 | + * | |
190 | + */ | |
191 | + function required($str) | |
23 | 192 | { |
193 | + if ( ! is_array($str)) | |
194 | + { | |
195 | + return (trim($str) == '') ? false : true; | |
196 | + } | |
197 | + else | |
198 | + { | |
199 | + return ( ! empty($str)); | |
200 | + } | |
201 | + } | |
24 | 202 | |
203 | + /** | |
204 | + * Exact Length | |
205 | + * | |
206 | + * @access public | |
207 | + * @param string | |
208 | + * @return bool | |
209 | + */ | |
210 | + function length($str, $val) | |
211 | + { | |
212 | + if (preg_match("/[^0-9]/", $val)) | |
213 | + { | |
214 | + return false; | |
215 | + } | |
25 | 216 | |
217 | + if (function_exists('mb_strlen')) | |
218 | + { | |
219 | + return (mb_strlen($str) != $val) ? false : true; | |
220 | + } | |
221 | + else | |
222 | + { | |
223 | + return (strlen($str) != $val) ? false : true; | |
224 | + } | |
225 | + } | |
26 | 226 | |
227 | + /** | |
228 | + * Minimum Length | |
229 | + * | |
230 | + * @access public | |
231 | + * @param string | |
232 | + * @return bool | |
233 | + */ | |
234 | + function min_len($str, $val) | |
235 | + { | |
236 | + //入力がなければ、OKとする | |
237 | + if ( empty($str) ) return true; | |
238 | + | |
239 | + if (preg_match("/[^0-9]/", $val)) | |
240 | + { | |
241 | + return false; | |
242 | + } | |
243 | + | |
244 | + if (function_exists('mb_strlen')) | |
245 | + { | |
246 | + return (mb_strlen($str) < $val) ? false : true; | |
247 | + } | |
248 | + else | |
249 | + { | |
250 | + return (strlen($str) < $val) ? false : true; | |
251 | + } | |
27 | 252 | } |
28 | 253 | |
29 | 254 | |
30 | - public function confirm() | |
255 | + /** | |
256 | + * Max Length | |
257 | + * | |
258 | + * @access public | |
259 | + * @param string | |
260 | + * @return bool | |
261 | + */ | |
262 | + function max_len($str, $val) | |
31 | 263 | { |
264 | + if (preg_match("/[^0-9]/", $val)) | |
265 | + { | |
266 | + return false; | |
267 | + } | |
32 | 268 | |
269 | + if (function_exists('mb_strlen')) | |
270 | + { | |
271 | + return (mb_strlen($str) > $val) ? false : true; | |
272 | + } | |
273 | + else | |
274 | + { | |
275 | + return (strlen($str) > $val) ? false : true; | |
276 | + } | |
277 | + } | |
33 | 278 | |
279 | + | |
280 | + /** | |
281 | + * Numeric | |
282 | + * | |
283 | + * @access public | |
284 | + * @param string | |
285 | + * @return bool | |
286 | + */ | |
287 | + function numeric($str) | |
288 | + { | |
289 | + if ( empty($str) ) return true; | |
290 | + return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); | |
291 | + | |
34 | 292 | } |
35 | 293 | |
36 | 294 | |
295 | + /** | |
296 | + * Integer | |
297 | + * | |
298 | + * @access public | |
299 | + * @param string | |
300 | + * @return bool | |
301 | + */ | |
302 | + function int($str) | |
303 | + { | |
304 | + if ( empty($str) ) return true; | |
305 | + if ( ! is_numeric($str) ) return false; | |
306 | + | |
307 | + $a = strval( floatval($str) ); | |
308 | + | |
309 | + //echo "<br> int a=" .$a ."<br>"; | |
310 | + | |
311 | + | |
312 | + if ( strpos($a, ".") === false ) { | |
313 | + return true; | |
314 | + } else { | |
315 | + return false; | |
316 | + } | |
317 | + | |
318 | + } | |
319 | + | |
320 | + | |
321 | + /** | |
322 | + * Alpha-numeric with underscores and dashes | |
323 | + * | |
324 | + * @access public | |
325 | + * @param string | |
326 | + * @return bool | |
327 | + */ | |
328 | + function alpha_dash($str) | |
329 | + { | |
330 | + if ( empty($str) ) return true; | |
331 | + return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? false : true; | |
332 | + } | |
333 | + | |
334 | + /** | |
335 | ||
336 | + * | |
337 | + * @access public | |
338 | + * @param string | |
339 | + * @return bool | |
340 | + */ | |
341 | + function email($str) | |
342 | + { | |
343 | + if ( empty($str) ) return true; | |
344 | + return ( ! preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $str)) ? false : true; | |
345 | + } | |
346 | + | |
347 | + /** | |
348 | + * URL | |
349 | + * | |
350 | + * @access public | |
351 | + * @param string | |
352 | + * @return bool | |
353 | + */ | |
354 | + function url($str) | |
355 | + { | |
356 | + if ( empty($str) ) return true; | |
357 | + return ( ! preg_match('/^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/', $str)) ? false : true; | |
358 | + } | |
359 | + | |
360 | + /** | |
361 | + * Hiragana | |
362 | + * | |
363 | + * @access public | |
364 | + * @param string | |
365 | + * @return bool | |
366 | + */ | |
367 | + function hira($str) | |
368 | + { | |
369 | + if ( empty($str) ) return true; | |
370 | + return ( ! mb_ereg("^[あ-ん]+$", $str)) ? false : true; | |
371 | + } | |
372 | + | |
373 | + /** | |
374 | + * Hankaku Katakana | |
375 | + * | |
376 | + * @access public | |
377 | + * @param string | |
378 | + * @return bool | |
379 | + */ | |
380 | + function hankana($str) | |
381 | + { | |
382 | + if ( empty($str) ) return true; | |
383 | + | |
384 | + return ( ! mb_ereg('^[ ヲ-゚ ]+$', $str)) ? false : true; | |
385 | + } | |
386 | + | |
387 | + | |
388 | + // -------------------------------------------------------------------- | |
389 | + | |
390 | + | |
391 | + /** | |
392 | + * エラーメッセージを返す | |
393 | + * | |
394 | + * @access public | |
395 | + * @param string | |
396 | + * string | |
397 | + */ | |
398 | + private function getMessage( $nbr="000", $set="" ) { | |
399 | + | |
400 | + $msg = ""; | |
401 | + | |
402 | + switch ( $nbr ) { | |
403 | + case "000": | |
404 | + $msg = "の値検査に失敗しました。"; | |
405 | + break; | |
406 | + case "001": | |
407 | + $msg = "は必須です。"; | |
408 | + break; | |
409 | + case "002": | |
410 | + $msg = "は半角計算で" .$set ."文字で入力してください。"; | |
411 | + break; | |
412 | + case "003": | |
413 | + $msg = "は" .$set ."文字以上で入力してください。"; | |
414 | + break; | |
415 | + case "004": | |
416 | + $msg = "は半角計算で" .$set ."文字以下で入力してください。"; | |
417 | + break; | |
418 | + case "005": | |
419 | + $msg = "には半角文字の数値しか入力できません。"; | |
420 | + break; | |
421 | + case "005b": | |
422 | + $msg = "には半角文字の整数値しか入力できません。"; | |
423 | + break; | |
424 | + case "006": | |
425 | + $msg = "には英数字・アンダーバー・ハイフンしか入力できません。"; | |
426 | + break; | |
427 | + | |
428 | + case "007": | |
429 | + $msg = "はメールアドレスとして認識できません。"; | |
430 | + break; | |
431 | + | |
432 | + case "008": | |
433 | + $msg = "はURLとして認識できません。"; | |
434 | + break; | |
435 | + | |
436 | + | |
437 | + case "010": | |
438 | + $msg = "にはひらがなしか入力できません。"; | |
439 | + break; | |
440 | + | |
441 | + case "011": | |
442 | + $msg = "には半角カタカナで入力してください。"; | |
443 | + break; | |
444 | + | |
445 | + case "020": | |
446 | + $msg = "に不正な値が入力されています。"; | |
447 | + break; | |
448 | + | |
449 | + case "021": | |
450 | + $msg = "に有効でない日付が入力されています。"; | |
451 | + break; | |
452 | + | |
453 | + default: | |
454 | + $msg = "のエラーメッセージは未設定です。"; | |
455 | + break; | |
456 | + } | |
457 | + | |
458 | + return $msg; | |
459 | + | |
460 | + } | |
461 | + | |
462 | + | |
37 | 463 | } |
38 | 464 | |
39 | 465 | ?> |
\ No newline at end of file |
@@ -12,4 +12,28 @@ | ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | +#ユーザエージェント(クローラー)のブラックリスト(アクセス拒否) | |
16 | +#※現在、百度には生贄になってもらっている。ごめんよ。 | |
17 | +$GLOABLS['APP']['blk_crawler'] = array('Baidu', 'baidu', 'Yeti'); | |
18 | + | |
19 | +#エージェントのグレイリスト(投稿警戒対象) | |
20 | +$GLOABLS['APP']['gry_agent'] = array('Baidu', 'baidu', 'Yeti'); | |
21 | + | |
22 | +#ホストのブラックリスト(アクセス拒否対象 海外系限定) | |
23 | +$GLOABLS['APP']['blk_host'] = array | |
24 | + ( 'your-server.de', 'giga-dns.com', 'ecatel.net', 'comcast.net', 'altushost.com', | |
25 | + 'surehost.ru', 'seocorp.name', 'net.ru', 'cssgroup.lv' ); | |
26 | + | |
27 | +#ホストのグレイリスト(投稿警戒対象) | |
28 | +$GLOABLS['APP']['gry_host'] = array | |
29 | + ( 'Unknown_Host', | |
30 | + 'dy.bbexcite.jp', 'osaka.sannet.ne.jp', 'ap.yournet.ne.jp', | |
31 | + 'oska.nt.ftth.ppp.infoweb.ne.jp', 'oska.nt.ftth4.ppp.infoweb.ne.jp', | |
32 | + 'oska.nt.adsl.ppp.infoweb.ne.jp', | |
33 | + 'ppp11.odn.ad.jp', 'vectant.ne.jp', 'ap.gmo-access.jp', | |
34 | + '.com.cn', 'ap.cyberbb.ne.jp' | |
35 | + ); | |
36 | + | |
37 | + | |
38 | + | |
15 | 39 | ?> |
\ No newline at end of file |
@@ -14,7 +14,7 @@ | ||
14 | 14 | define('DATAPATH', BASEPATH . '/data'); |
15 | 15 | } |
16 | 16 | |
17 | -if( HTMLPATH <> '' ) { | |
17 | +if( HTMLPATH <> '' ) { | |
18 | 18 | define('PUBPATH', HTMLPATH . '/public'); |
19 | 19 | } else { |
20 | 20 | define('PUBPATH', BASEPATH . '/public'); |
@@ -44,8 +44,11 @@ | ||
44 | 44 | define('CHARSET', 'UTF-8'); |
45 | 45 | define('LANG', 'ja'); |
46 | 46 | |
47 | +date_default_timezone_set('Asia/Tokyo'); | |
47 | 48 | |
48 | 49 | |
50 | + | |
51 | + | |
49 | 52 | //アップロードファイル最大サイズ |
50 | 53 | define('MAXFILE', (500 * 1024) ); |
51 | 54 |
@@ -53,9 +53,14 @@ | ||
53 | 53 | |
54 | 54 | 'previous' => '前へ', |
55 | 55 | 'next' => '次へ', |
56 | -'setup' => 'セットアップ' | |
56 | +'setup' => 'セットアップ', | |
57 | 57 | |
58 | 58 | |
59 | +'preview' => 'プレビュー', | |
60 | +'postInvalid' => '入力に不備があります', | |
61 | + | |
62 | + | |
63 | + | |
59 | 64 | ); |
60 | 65 | |
61 | 66 |
@@ -1,19 +1,33 @@ | ||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -function geArticleInput($baseSet, $art, $postSet=array(), $mode=1) { | |
4 | +function geArticleInputHtml($baseSet, $art, $postSet, $mode=1) { | |
5 | 5 | |
6 | - | |
6 | + //パーツ作成 | |
7 | 7 | $clips = makeFileUpload($postSet['clipfile']); |
8 | + $ftclr = makeFontColor($postSet['ftcolor_on'], $postSet['ftcolors']); | |
9 | + $icon = makeIcon($postSet['icon_on'], $postSet['icons']); | |
10 | + $captc = makeCaptcha($postSet['captcha_on']); | |
11 | + $kword = makeKeyword($postSet['keyword_on'], $postSet['keyword_q'], $postSet['keyword_a']); | |
12 | + $prev = makePreview($postSet['preview']); | |
13 | + $err = makeError($postSet['errMessage'], $postSet['errMsgAry']); | |
8 | 14 | |
15 | + | |
9 | 16 | $myContent = ''; |
10 | 17 | $myContent .=<<< HTML |
11 | -<div class="article"> | |
12 | -<table border=1> | |
18 | +<div class="ctr"> | |
19 | + | |
20 | +{$prev} | |
21 | + | |
22 | +<div class="articleInput"> | |
23 | + | |
24 | +{$err} | |
25 | + | |
26 | +<table border=1 class="inputOut"> | |
13 | 27 | <tr> |
14 | 28 | <td> </td> |
29 | +<td class="ctr">記事投稿</td> | |
15 | 30 | <td> </td> |
16 | -<td> </td> | |
17 | 31 | </tr> |
18 | 32 | |
19 | 33 | <tr> |
@@ -29,41 +43,51 @@ | ||
29 | 43 | </form> |
30 | 44 | --> |
31 | 45 | |
32 | -<div class="articleInputForm"> | |
33 | -<form method="post" action="{$baseSet['script']}" enctype="multipart/form-data" accept-charset="UTF-8"> | |
34 | - <dl> | |
35 | - <dt>投稿者名:</dt> | |
36 | - <dd><input name="author" type="text" value="{$art['author']}" /></dd> | |
46 | +<div class="inputForm"> | |
47 | +<form method="post" action="{$baseSet['script']}?act={$postSet['targetAct']}" enctype="multipart/form-data" accept-charset="UTF-8"> | |
48 | +<div class="articleInput"> | |
37 | 49 | |
38 | - <dt>題名:</dt> | |
39 | - <dd><input name="subject" type="text" value="{$art['subject']}" size="40" /></dd> | |
50 | + <div class="itemName"><span class="rqd">*</a>投稿者名:</div> | |
51 | + <div class="itemInput left1"><input name="author" type="text" value="{$art['author']}" class="ime_ac" /></div> | |
40 | 52 | |
41 | - <dt>内容:</dt> | |
42 | - <dd><textarea name="article" cols="60" rows="10" />{$art['article']}</textarea></dd> | |
53 | + <div class="itemName">パスワード:</div> | |
54 | + <div class="itemInput"><input name="password" type="text" value="{$art['password']}" class="ime_ia" /></div><div class="clear"></div> | |
43 | 55 | |
56 | + <div class="itemName"><span class="rqd">*</a>題名:</div> | |
57 | + <div class="itemInput"><input name="subject" type="text" value="{$art['subject']}" size="40" class="ime_ac" /></div><div class="clear"></div> | |
44 | 58 | |
45 | - <dt>Eメール:</dt> | |
46 | - <dd><input name="email" type="text" value="{$art['email']}" /></dd> | |
59 | + {$icon} | |
60 | + {$ftclr}<div class="clear"></div> | |
47 | 61 | |
48 | - <dt>ホームページ:</dt> | |
49 | - <dd><input name="homepage" type="text" value="{$art['homepage']}" size="50" /></dd> | |
62 | + <div class="itemName"><span class="rqd">*</a>内容:</div> | |
63 | + <div class="itemInput"><textarea name="article" cols="60" rows="10" class="ime_ac" />{$art['article']}</textarea></div><div class="clear"></div> | |
50 | 64 | |
51 | - <dt>パスワード:</dt> | |
52 | - <dd><input name="password" type="text" value="{$art['password']}" /></dd> | |
65 | + <div class="itemName">Eメール:</div> | |
66 | + <div class="itemInput"><input name="email" type="text" value="{$art['email']}" class="ime_ia" /></div><div class="clear"></div> | |
53 | 67 | |
68 | + <div class="itemName">ホームページ:</div> | |
69 | + <div class="itemInput"><input name="homepage" type="text" value="{$art['homepage']}" size="50" class="ime_ia" /></div><div class="clear"></div> | |
70 | + | |
54 | 71 | {$clips} |
55 | 72 | |
56 | - </dl> | |
57 | - <!-- | |
73 | + {$captc} | |
74 | + {$kword} | |
75 | + | |
76 | + <input type="text" name="comment" size="1" maxlength="100" title="ダミーです" style="display:inline; display:none;" /> | |
58 | 77 | <input name="id" type="hidden" value="{$baseSet['id']}" /> |
59 | - --> | |
60 | - <input name="id" type="hidden" value="{$baseSet['id']}" /> | |
61 | 78 | <input name="plfm" type="hidden" value="{$baseSet['plfm']}" /> |
62 | - <input name="act" type="hidden" value="crtcfm" /> | |
63 | - <input name="parent_id" type="hidden" value="{$art['id']}" /> | |
64 | - <input name="article_id" type="hidden" value="{$art['id']}" /> | |
79 | + <input name="act" type="hidden" value="{$postSet['targetAct']}" /> | |
80 | + <input name="tree_number" type="hidden" value="{$art['tree_number']}" /> | |
81 | + <input name="parent_id" type="hidden" value="{$art['parent_id']}" /> | |
82 | + <input name="article_id" type="hidden" value="{$art['article_id']}" /> | |
65 | 83 | <input name="timekey" type="hidden" value="{$postSet['timekey']}" /> |
66 | - <div><input type="submit" value="投稿" /></div> | |
84 | + | |
85 | + <div class="itemInput" style="width:40%;"></div> | |
86 | + <div class="itemInput ctr" style="width:19%;"><input type="submit" value=" 投 稿 " /></div> | |
87 | + <div class="itemInput" style="width:40%;"> | |
88 | + <input type="checkbox" name="confirm" value="1" />プレビュー | |
89 | + </div> | |
90 | +</div> | |
67 | 91 | </form> |
68 | 92 | </div> |
69 | 93 |
@@ -79,6 +103,8 @@ | ||
79 | 103 | </tr> |
80 | 104 | </table> |
81 | 105 | |
106 | +</div> | |
107 | +</div> | |
82 | 108 | HTML; |
83 | 109 | |
84 | 110 | return $myContent; |
@@ -86,13 +112,58 @@ | ||
86 | 112 | |
87 | 113 | |
88 | 114 | |
115 | + | |
116 | + | |
117 | +function makePreview($preview) { | |
118 | + if (! $preview) return ''; | |
119 | + | |
120 | + $prvStr = translateTo('preview'); | |
121 | + | |
122 | + $myContent = ''; | |
123 | +$myContent .=<<< HTML | |
124 | + <div class="preview"> | |
125 | + <div class="previewTitle">【プレビュー】</div> | |
126 | + {$preview} | |
127 | + </div> | |
128 | +HTML; | |
129 | + | |
130 | + return $myContent; | |
131 | +} | |
132 | + | |
133 | + | |
134 | +function makeError($msg, $msgAry) { | |
135 | + if (! $msg) return ''; | |
136 | + | |
137 | + $myContent = ''; | |
138 | + | |
139 | +$myContent .=<<< HTML | |
140 | + <div class="ctr"> | |
141 | + <div class="mainError">{$msg}</div> | |
142 | +HTML; | |
143 | + | |
144 | +foreach ($msgAry as $emsg) { | |
145 | +$myContent .=<<< HTML | |
146 | + <div class="itemError">$emsg</div> | |
147 | +HTML; | |
148 | +} | |
149 | + | |
150 | +$myContent .=<<< HTML | |
151 | + </div> | |
152 | +HTML; | |
153 | + | |
154 | + return $myContent; | |
155 | +} | |
156 | + | |
157 | + | |
89 | 158 | function makeFileUpload($number) { |
90 | 159 | $myContent = ''; |
91 | 160 | |
92 | 161 | for ($i=1;$i<=$number;$i++) { |
93 | 162 | $myContent .=<<< HTML |
94 | - <dt>ファイル{$i}</dt> | |
95 | - <dd><input name="clipfile{$i}" type="file" size="50" /></dd> | |
163 | + <div class="itemName">ファイル{$i}:</div> | |
164 | + <div class="itemInput"><input name="clipfile{$i}" type="file" size="50" id="clipfile{$i}" onChange="clipFileChenge({$i})" /> | |
165 | + </div><div class="clear"> | |
166 | + </div> | |
96 | 167 | HTML; |
97 | 168 | } |
98 | 169 | return $myContent; |
@@ -99,28 +170,55 @@ | ||
99 | 170 | } |
100 | 171 | |
101 | 172 | |
102 | -function makeFontColor() { | |
173 | +function makeFontColor($flag, $ftcolors) { | |
103 | 174 | $myContent = ''; |
175 | + if ( $flag ) { | |
176 | +$myContent .=<<< HTML | |
177 | + <div class="itemName">本文文字色:</div> | |
178 | + <div class="itemInput"><select name="ftcolor"> | |
179 | +HTML; | |
104 | 180 | |
105 | - $myContent .= '<input name="ftcolor" />'; | |
181 | + $colorAry = explode(',', $ftcolors); | |
182 | + foreach( $colorAry as $color ) { | |
183 | + if ( !$color ) continue; | |
184 | + $myContent .= " <option name=\"ftcolor\" value=\"{$color}\" style=\"color:{$color};\" />■{$color}</option>"; | |
185 | + } | |
106 | 186 | |
107 | - $myContent .= ''; | |
108 | - | |
187 | +$myContent .=<<< HTML | |
188 | + </select> | |
189 | + </div> | |
190 | +HTML; | |
191 | + } | |
109 | 192 | return $myContent; |
110 | 193 | } |
111 | 194 | |
112 | 195 | |
113 | -function makeIcon() { | |
196 | +function makeIcon($flag, $icons) { | |
114 | 197 | $myContent = ''; |
115 | 198 | |
116 | - $myContent .= '<select name="icon">'; | |
199 | + if ( $flag ) { | |
200 | +$myContent .=<<< HTML | |
201 | + <div class="itemName">アイコン:</div> | |
202 | + <div class="itemInput left1"><select name="icon"> | |
203 | +HTML; | |
117 | 204 | |
118 | - $myContent .= '</select>'; | |
205 | + $iconAry = explode(',', $icons); | |
206 | + foreach( $iconAry as $icon ) { | |
207 | + $icAry = explode('=', $icons); | |
208 | + if ( count($icAry)!=2 ) continue; | |
209 | + $myContent .= " <option name=\"icon\" value=\"{$icAry[0]}\" />{$icAry[1]}</option>"; | |
210 | + } | |
119 | 211 | |
212 | +$myContent .=<<< HTML | |
213 | + </select> | |
214 | + </div> | |
215 | +HTML; | |
216 | + } | |
217 | + | |
120 | 218 | return $myContent; |
121 | 219 | } |
122 | 220 | |
123 | -function makeCaptcha() { | |
221 | +function makeCaptcha($flag) { | |
124 | 222 | $myContent = ''; |
125 | 223 | |
126 | 224 | return $myContent; |
@@ -127,7 +225,7 @@ | ||
127 | 225 | } |
128 | 226 | |
129 | 227 | |
130 | -function makeKeyword() { | |
228 | +function makeKeyword($flag, $qst, $asw) { | |
131 | 229 | $myContent = ''; |
132 | 230 | |
133 | 231 | return $myContent; |
@@ -3,6 +3,10 @@ | ||
3 | 3 | |
4 | 4 | function getArticleHtml($art, $deleteMode=1, $editMode=1, $img=0, $indent=0){ |
5 | 5 | |
6 | + $email = makeEmail($art['email']); | |
7 | + $homepage = makeHomepage($art['homepage']); | |
8 | + $clipfiles = makeClipFiles($art['clipfile1'], $art['clipfile2'], $art['clipfile3']); | |
9 | + $fileimages = makeFileImages($art['clipfile1'], $art['clipfile2'], $art['clipfile3']); | |
6 | 10 | |
7 | 11 | $article =<<< HTML |
8 | 12 | <div style="margin-left:{$indent};"> |
@@ -10,8 +14,10 @@ | ||
10 | 14 | <div class="articleTitleBox">{$art['tree_number']}:{$art['id']}:{$art['subject']}</div> |
11 | 15 | <div class="articleAuthorBox"> |
12 | 16 | {$art['author']}<br /> |
13 | -{$art['homepage']}{$art['email']}<br /> | |
17 | +{$email}{$homepage}<br /> | |
18 | +{$clipfiles} | |
14 | 19 | |
20 | +<br /> | |
15 | 21 | <form class="button res"> |
16 | 22 | <input type="submit" value="返信" class="resBtn" /> |
17 | 23 | </form> |
@@ -33,6 +39,9 @@ | ||
33 | 39 | <div class="articleTextBox"> |
34 | 40 | {$art['article']} |
35 | 41 | |
42 | +{$fileimages} | |
43 | + | |
44 | +<br /> | |
36 | 45 | </div> |
37 | 46 | </div> |
38 | 47 | <br clear="all" class="clear" /> |
@@ -48,7 +57,100 @@ | ||
48 | 57 | } |
49 | 58 | |
50 | 59 | |
60 | +function makeEmail($email) { | |
61 | + if (! $email) return ''; | |
51 | 62 | |
63 | + $myContent = ''; | |
64 | + | |
65 | +$myContent .=<<< HTML | |
66 | + <span><a href="mailto:{$email}">[Email]</a></span> | |
67 | +HTML; | |
68 | + | |
69 | + return $myContent; | |
70 | +} | |
71 | + | |
72 | + | |
73 | +function makeHomepage($homepage) { | |
74 | + if (! $homepage) return ''; | |
75 | + | |
76 | + $myContent = ''; | |
77 | + | |
78 | +$myContent .=<<< HTML | |
79 | + <span><a href="{$homepage}">[Home]</a></span> | |
80 | +HTML; | |
81 | + | |
82 | + return $myContent; | |
83 | +} | |
84 | + | |
85 | + | |
86 | +function makeClipFiles($clip1, $clip2, $clip3) { | |
87 | + if (! $clip1 and $clip2 and $clip3) return ''; | |
88 | + | |
89 | + $myContent = ''; | |
90 | + | |
91 | +$myContent .=<<< HTML | |
92 | + <div class="clipfiles"> | |
93 | +HTML; | |
94 | + | |
95 | +if ( $clip1 ) { | |
96 | +$myContent .=<<< HTML | |
97 | + <div class="clip"><a href="$clip1"><img src="clip.gif"></a></div> | |
98 | +HTML; | |
99 | +} | |
100 | +if ( $clip2 ) { | |
101 | +$myContent .=<<< HTML | |
102 | + <div class="clip"><a href="$clip2"><img src="clip.gif"></a></div> | |
103 | +HTML; | |
104 | +} | |
105 | +if ( $clip3 ) { | |
106 | +$myContent .=<<< HTML | |
107 | + <div class="clip"><a href="$clip3"><img src="clip.gif"></a></div> | |
108 | +HTML; | |
109 | +} | |
110 | + | |
111 | +$myContent .=<<< HTML | |
112 | + </div> | |
113 | +HTML; | |
114 | + | |
115 | + | |
116 | + return $myContent; | |
117 | +} | |
118 | + | |
119 | + | |
120 | +function makeFileImages($clip1, $clip2, $clip3) { | |
121 | + if (! $clip1 and $clip2 and $clip3) return ''; | |
122 | + | |
123 | + $myContent = ''; | |
124 | + | |
125 | +$myContent .=<<< HTML | |
126 | + <div class="imageFileView"> | |
127 | +HTML; | |
128 | + | |
129 | +if ( $clip1 ) { | |
130 | +$myContent .=<<< HTML | |
131 | + <div class="clipImage"><img src="$clip1"></div> | |
132 | +HTML; | |
133 | +} | |
134 | +if ( $clip2 ) { | |
135 | +$myContent .=<<< HTML | |
136 | + <div class="clipImage"><img src="$clip1"></div> | |
137 | +HTML; | |
138 | +} | |
139 | +if ( $clip3 ) { | |
140 | +$myContent .=<<< HTML | |
141 | + <div class="clipImage"><img src="$clip1"></div> | |
142 | +HTML; | |
143 | +} | |
144 | + | |
145 | +$myContent .=<<< HTML | |
146 | + </div> | |
147 | +HTML; | |
148 | + | |
149 | + return $myContent; | |
150 | +} | |
151 | + | |
152 | + | |
153 | + | |
52 | 154 | function getThreadsArticleHtml($art, $deleteMode=1, $editMode=1, $img=0, $indent=0){ |
53 | 155 | |
54 | 156 | $article =<<< HTML |
@@ -6,6 +6,7 @@ | ||
6 | 6 | <meta http-equiv="content-style-type" content="text/css"> |
7 | 7 | <link rel="stylesheet" type="text/css" href="<?php echo $this->set['dataURL']; ?>/base.css"> |
8 | 8 | <link rel="stylesheet" type="text/css" href="<?php echo $this->set['dataURL']; ?>/overwrite.css"> |
9 | +<script type="text/javascript" src="<?php echo $this->set['pubURL']; ?>/js/common.js"></script> | |
9 | 10 | <title><?php echo $this->set['vw_title']; ?></title> |
10 | 11 | </head> |
11 | 12 | <body> |